Jelajahi Sumber

Merged with alteredq.

Mikael Emtinger 14 tahun lalu
induk
melakukan
549f9b03a5
41 mengubah file dengan 2463 tambahan dan 2114 penghapusan
  1. 11 1
      README.md
  2. 249 245
      build/Three.js
  3. 77 79
      build/custom/ThreeCanvas.js
  4. 55 58
      build/custom/ThreeDOM.js
  5. 5 5
      build/custom/ThreeExtras.js
  6. 69 71
      build/custom/ThreeSVG.js
  7. 145 138
      build/custom/ThreeWebGL.js
  8. 0 1
      examples/canvas_lights_pointlights.html
  9. 143 0
      examples/misc_lookat.html
  10. 3 3
      examples/misc_sound.html
  11. 1 0
      examples/scenes/test_scene.js
  12. TEMPAT SAMPAH
      examples/textures/758px-Canestra_di_frutta_(Caravaggio).jpg
  13. 2 2
      examples/webgl_lines_colors.html
  14. 1 1
      examples/webgl_materials_shaders_fresnel.html
  15. 273 0
      examples/webgl_materials_texture_filters.html
  16. 2 2
      examples/webgl_materials_video.html
  17. 0 33
      examples/webgl_performance.html
  18. 2 2
      examples/webgl_postprocessing.html
  19. 2 2
      examples/webgl_postprocessing_dof.html
  20. 4 4
      examples/webgl_ribbons.html
  21. 3 3
      examples/webgl_rtt.html
  22. 0 1
      examples/webgl_sandbox.html
  23. 4 4
      src/animation/Animation.js
  24. 23 129
      src/cameras/Camera.js
  25. 57 40
      src/cameras/QuakeCamera.js
  26. 2 2
      src/core/Geometry.js
  27. 2 2
      src/core/Matrix3.js
  28. 89 238
      src/core/Matrix4.js
  29. 59 26
      src/core/Object3D.js
  30. 31 3
      src/core/Vector3.js
  31. 1 1
      src/extras/SceneUtils.js
  32. 2 2
      src/objects/Bone.js
  33. 2 2
      src/objects/LOD.js
  34. 2 12
      src/objects/SkinnedMesh.js
  35. 2 2
      src/objects/Sound.js
  36. 267 169
      src/renderers/WebGLRenderer.js
  37. 0 822
      src/renderers/WebGLRenderer2.js
  38. 1 1
      utils/REVISION
  39. 3 0
      utils/build.py
  40. 13 8
      utils/exporters/convert_obj_threejs_slim.py
  41. 856 0
      utils/exporters/max/ThreeJSExporter.ms

+ 11 - 1
README.md

@@ -5,7 +5,7 @@ three.js
 
 The aim of this project is to create a lightweight 3D engine with a very low level of abstraction — in other words, for dummies. The engine can render using <canvas>, <svg> and WebGL.
 
-[API Reference](https://github.com/mrdoob/three.js/wiki/r34-API-Reference) — be aware that the API may change from revision to revision breaking backwards compatibility.
+[API Reference](https://github.com/mrdoob/three.js/wiki/r35-API-Reference) — be aware that the API may change from revision to revision breaking backwards compatibility.
 
 More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=three.js)
 
@@ -14,6 +14,8 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre
 
 #### WebGL (Context 3D) ####
 
+[![scissors](http://mrdoob.github.com/three.js/assets/examples/42_scissors.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_texture_filters.html)
+[![lookat](http://mrdoob.github.com/three.js/assets/examples/41_lookat.png)](http://mrdoob.github.com/three.js/examples/misc_lookat.html)
 [![video](http://mrdoob.github.com/three.js/assets/examples/40_video.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_video.html)
 [![dof](http://mrdoob.github.com/three.js/assets/examples/39_dof.png)](http://mrdoob.github.com/three.js/examples/webgl_postprocessing_dof.html)
 [![ribbon](http://mrdoob.github.com/three.js/assets/examples/38_ribbon.png)](http://mrdoob.github.com/three.js/examples/webgl_ribbons.html)
@@ -134,6 +136,14 @@ This code creates a camera, then creates a scene object, adds a bunch of random
 
 ### Change Log ###
 
+2011 03 06 - **r35** (187.875 KB, gzip: 46.433 KB)
+
+* Added methods `translate`, `translateX`, `translateY`, `translateZ` and `lookAt` methods to `Object3D`. ([mrdoob](http://github.com/mrdoob))
+* Added methods `setViewport` and `setScissor` to `WebGLRenderer`. ([alteredq](http://github.com/alteredq))
+* Added support for non-po2 textures. ([mrdoob](http://github.com/mrdoob) and [alteredq](http://github.com/alteredq))
+* Minor API clean up. ([mrdoob](http://github.com/mrdoob))
+
+
 2011 03 02 - **r34** (186.045 KB, gzip: 45.953 KB)
 
 * Now using camera.matrixWorldInverse instead of camera.matrixWorld for projecting. ([empaempa](http://github.com/empaempa) and [mrdoob](http://github.com/mrdoob))

File diff ditekan karena terlalu besar
+ 249 - 245
build/Three.js


+ 77 - 79
build/custom/ThreeCanvas.js

@@ -1,4 +1,4 @@
-// ThreeCanvas.js r34 - http://github.com/mrdoob/three.js
+// ThreeCanvas.js r35 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
 THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,g,j,h;if(c==0)d=e=f=0;else{g=Math.floor(a*6);j=a*6-g;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(g){case 1:d=h;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=h;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=h;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
@@ -8,48 +8,47 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(r,k,D,C){C=C.clone().subSelf(k);D=D.clone().subSelf(k);var I=r.clone().subSelf(k);r=C.dot(C);k=C.dot(D);C=C.dot(I);var F=D.dot(D);D=D.dot(I);I=1/(r*F-k*k);F=(F*C-k*D)*I;r=(r*D-k*C)*I;return F>0&&r>0&&F+r<1}var c,d,e,f,g,j,h,i,n,m,
-o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;c<d;c++){e=q.faces[c];m=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(s[e.a].position.clone());g=h.multiplyVector3(s[e.b].position.clone());j=h.multiplyVector3(s[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(s[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=o.dot(i);if(n<0){i=i.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(o.multiplyScalar(i));
-if(e instanceof THREE.Face3){if(b(m,f,g,j)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};t.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,j,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};t.push(e)}}}return t}};
-THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,n,m){j=!1;b=h;c=i;d=n;e=m;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=b<h?b:h;c=c<i?c:i;d=d>h?d:h;e=e>i?e:i}a()};
-this.add3Points=function(h,i,n,m,o,q){if(j){j=!1;b=h<n?h<o?h:o:n<o?n:o;c=i<m?i<q?i:q:m<q?m:q;d=h>n?h>o?h:o:n>o?n:o;e=i>m?i>q?i:q:m>q?m:q}else{b=h<n?h<o?h<b?h:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;c=i<m?i<q?i<c?i:c:q<c?q:c:m<q?m<c?m:c:q<c?q:c;d=h>n?h>o?h>d?h:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d;e=i>m?i>q?i>e?i:e:q>e?q:e:m>q?m>e?m:e:q>e?q:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(s,k,G,F){F=F.clone().subSelf(k);G=G.clone().subSelf(k);var K=s.clone().subSelf(k);s=F.dot(F);k=F.dot(G);F=F.dot(K);var I=G.dot(G);G=G.dot(K);K=1/(s*I-k*k);I=(I*F-k*G)*K;s=(s*G-k*F)*K;return I>0&&s>0&&I+s<1}var c,d,e,f,g,j,h,i,p,n,
+o,q=a.geometry,u=q.vertices,v=[];c=0;for(d=q.faces.length;c<d;c++){e=q.faces[c];n=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(u[e.a].position.clone());g=h.multiplyVector3(u[e.b].position.clone());j=h.multiplyVector3(u[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(u[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());p=o.dot(i);if(p<0){i=i.dot((new THREE.Vector3).sub(f,n))/p;n=n.addSelf(o.multiplyScalar(i));
+if(e instanceof THREE.Face3){if(b(n,f,g,j)){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};v.push(e)}}else if(e instanceof THREE.Face4&&(b(n,f,g,h)||b(n,g,j,h))){e={distance:this.origin.distanceTo(n),point:n,face:e,object:a};v.push(e)}}}return v}};
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,p,n){j=!1;b=h;c=i;d=p;e=n;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=b<h?b:h;c=c<i?c:i;d=d>h?d:h;e=e>i?e:i}a()};
+this.add3Points=function(h,i,p,n,o,q){if(j){j=!1;b=h<p?h<o?h:o:p<o?p:o;c=i<n?i<q?i:q:n<q?n:q;d=h>p?h>o?h:o:p>o?p:o;e=i>n?i>q?i:q:n>q?n:q}else{b=h<p?h<o?h<b?h:b:o<b?o:b:p<o?p<b?p:b:o<b?o:b;c=i<n?i<q?i<c?i:c:q<c?q:c:n<q?n<c?n:c:q<c?q:c;d=h>p?h>o?h>d?h:d:o>d?o:d:p>o?p>d?p:d:o>d?o:d;e=i>n?i>q?i>e?i:e:q>e?q:e:n>q?n>e?n:e:q>e?q:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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,e,f,g,j,h,i,n,m,o,q,s,t){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,n||1,m||0,o||0,q||0,s||0,t||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,n,m,o,q,s,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=n;this.n34=m;this.n41=o;this.n42=q;this.n43=s;this.n44=t;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.__tmpVec1,
-e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
-b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44,D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34;this.n11=c*
-D+d*N+e*u;this.n12=c*C+d*A+e*K;this.n13=c*I+d*w+e*E;this.n14=c*F+d*J+e*y+f;this.n21=g*D+j*N+h*u;this.n22=g*C+j*A+h*K;this.n23=g*I+j*w+h*E;this.n24=g*F+j*J+h*y+i;this.n31=n*D+m*N+o*u;this.n32=n*C+m*A+o*K;this.n33=n*I+m*w+o*E;this.n34=n*F+m*J+o*y+q;this.n41=s*D+t*N+r*u;this.n42=s*C+t*A+r*K;this.n43=s*I+t*w+r*E;this.n44=s*F+t*J+r*y+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,j=a.n21,h=a.n22,i=a.n23,n=a.n24,m=a.n31,o=a.n32,q=a.n33,s=a.n34,t=a.n41,r=a.n42,k=a.n43;
-a=a.n44;var D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34,B=b.n41,T=b.n42,x=b.n43;b=b.n44;this.n11=d*D+e*N+f*u+g*B;this.n12=d*C+e*A+f*K+g*T;this.n13=d*I+e*w+f*E+g*x;this.n14=d*F+e*J+f*y+g*b;this.n21=j*D+h*N+i*u+n*B;this.n22=j*C+h*A+i*K+n*T;this.n23=j*I+h*w+i*E+n*x;this.n24=j*F+h*J+i*y+n*b;this.n31=m*D+o*N+q*u+s*B;this.n32=m*C+o*A+q*K+s*T;this.n33=m*I+o*w+q*E+s*x;this.n34=m*F+o*J+q*y+s*b;this.n41=t*D+r*N+k*u+a*B;this.n42=t*C+r*A+k*K+a*T;this.n43=t*
-I+r*w+k*E+a*x;this.n44=t*F+r*J+k*y+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){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,j=this.n23,h=this.n24,i=this.n31,n=this.n32,m=this.n33,o=this.n34,q=this.n41,s=this.n42,t=this.n43,r=this.n44,k=a.n11,D=a.n21,
-C=a.n31,I=a.n12,F=a.n22,N=a.n32,A=a.n13,w=a.n23,J=a.n33,u=a.n14,K=a.n24;a=a.n34;this.n11=b*k+c*D+d*C;this.n12=b*I+c*F+d*N;this.n13=b*A+c*w+d*J;this.n14=b*u+c*K+d*a+e;this.n21=f*k+g*D+j*C;this.n22=f*I+g*F+j*N;this.n23=f*A+g*w+j*J;this.n24=f*u+g*K+j*a+h;this.n31=i*k+n*D+m*C;this.n32=i*I+n*F+m*N;this.n33=i*A+n*w+m*J;this.n34=i*u+n*K+m*a+o;this.n41=q*k+s*D+t*C;this.n42=q*I+s*F+t*N;this.n43=q*A+s*w+t*J;this.n44=q*u+s*K+t*a+r;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,e=this.n21,f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,n=this.n33,m=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44;return d*g*i*o-c*j*i*o-d*f*n*o+b*j*n*o+c*f*m*o-b*g*m*o-d*g*h*q+c*j*h*q+d*e*n*q-a*j*n*q-c*e*m*q+a*g*m*q+d*f*h*s-b*j*h*s-d*e*i*s+a*j*i*s+b*e*
-m*s-a*f*m*s-c*f*h*t+b*g*h*t+c*e*i*t-a*g*i*t-b*e*n*t+a*f*n*t},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.flattenToArray(this.flat);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},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=
-b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i)},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}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
-THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*t-i*o*t+i*m*r-j*q*r-h*m*k+j*o*k;b.n12=f*o*t-e*q*t-f*m*r+d*q*r+e*m*k-d*o*k;b.n13=e*i*t-f*h*t+f*j*r-d*i*r-e*j*k+d*h*k;b.n14=f*h*m-e*i*m-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*s-h*q*s-i*n*r+g*q*r+h*n*k-g*o*k;b.n22=e*q*s-f*o*s+f*n*r-c*q*r-e*n*k+c*o*k;b.n23=f*h*s-e*i*s-f*g*r+c*i*r+e*g*k-c*h*k;
-b.n24=e*i*n-f*h*n+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*s-i*m*s+i*n*t-g*q*t-j*n*k+g*m*k;b.n32=f*m*s-d*q*s-f*n*t+c*q*t+d*n*k-c*m*k;b.n33=e*i*s-f*j*s+f*g*t-c*i*t-d*g*k+c*j*k;b.n34=f*j*n-d*i*n-f*g*m+c*i*m+d*g*q-c*j*q;b.n41=h*m*s-j*o*s-h*n*t+g*o*t+j*n*r-g*m*r;b.n42=d*o*s-e*m*s+e*n*t-c*o*t-d*n*r+c*m*r;b.n43=e*j*s-d*h*s-e*g*t+c*h*t+d*g*r-c*j*r;b.n44=d*h*n-e*j*n+e*g*m-c*h*m-d*g*o+c*j*o;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,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*n;c[8]=a*m;return b};
+THREE.Matrix4=function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,p||1,n||0,o||0,q||0,u||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=p;this.n34=n;this.n41=o;this.n42=q;this.n43=u;this.n44=v;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,
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
+multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44,G=b.n11,F=b.n12,K=b.n13,I=b.n14,S=b.n21,C=b.n22,A=b.n23,L=b.n24,y=b.n31,M=b.n32,D=b.n33,x=b.n34;this.n11=c*G+d*S+e*y;this.n12=
+c*F+d*C+e*M;this.n13=c*K+d*A+e*D;this.n14=c*I+d*L+e*x+f;this.n21=g*G+j*S+h*y;this.n22=g*F+j*C+h*M;this.n23=g*K+j*A+h*D;this.n24=g*I+j*L+h*x+i;this.n31=p*G+n*S+o*y;this.n32=p*F+n*C+o*M;this.n33=p*K+n*A+o*D;this.n34=p*I+n*L+o*x+q;this.n41=u*G+v*S+s*y;this.n42=u*F+v*C+s*M;this.n43=u*K+v*A+s*D;this.n44=u*I+v*L+s*x+k;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,e=this.n21,f=this.n22,
+g=this.n23,j=this.n24,h=this.n31,i=this.n32,p=this.n33,n=this.n34,o=this.n41,q=this.n42,u=this.n43,v=this.n44;return d*g*i*o-c*j*i*o-d*f*p*o+b*j*p*o+c*f*n*o-b*g*n*o-d*g*h*q+c*j*h*q+d*e*p*q-a*j*p*q-c*e*n*q+a*g*n*q+d*f*h*u-b*j*h*u-d*e*i*u+a*j*i*u+b*e*n*u-a*f*n*u-c*f*h*v+b*g*h*v+c*e*i*v-a*g*i*v-b*e*p*v+a*f*p*v},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),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;
+c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);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,e=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*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*v-i*o*v+i*n*s-j*q*s-h*n*k+j*o*k;b.n12=f*o*v-e*q*v-f*n*s+d*q*s+e*n*k-d*o*k;b.n13=e*i*v-f*h*v+f*j*s-d*i*s-e*j*k+d*h*k;b.n14=f*h*n-e*i*n-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*u-h*q*u-i*p*s+g*q*s+h*p*k-g*o*k;b.n22=e*q*u-f*o*u+f*p*s-c*q*s-e*p*k+c*o*k;b.n23=f*h*u-e*i*u-f*g*s+c*i*s+e*g*k-c*h*k;
+b.n24=e*i*p-f*h*p+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*u-i*n*u+i*p*v-g*q*v-j*p*k+g*n*k;b.n32=f*n*u-d*q*u-f*p*v+c*q*v+d*p*k-c*n*k;b.n33=e*i*u-f*j*u+f*g*v-c*i*v-d*g*k+c*j*k;b.n34=f*j*p-d*i*p-f*g*n+c*i*n+d*g*q-c*j*q;b.n41=h*n*u-j*o*u-h*p*v+g*o*v+j*p*s-g*n*s;b.n42=d*o*u-e*n*u+e*p*v-c*o*v-d*p*s+c*n*s;b.n43=e*j*u-d*h*u-e*g*v+c*h*v+d*g*s-c*j*s;b.n44=d*h*p-e*j*p+e*g*n-c*h*n-d*g*o+c*j*o;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,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*p;c[8]=a*n;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,j,h,i;g=new THREE.Matrix4;j=b-a;h=c-d;i=f-e;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((b+a)/j);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
-this.visible=!0};
-THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
-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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
-this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}}};
-THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,j,h,i;g=new THREE.Matrix4;j=b-a;h=c-d;i=f-e;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((b+a)/j);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);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=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
+!0;this._vector=new THREE.Vector3};
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
+b,c)}}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var g=a*b,j=d*e;this.w=g*f-j*c;this.x=g*c+j*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.w,f=a.x,g=a.y,j=a.z;a=a.w;this.x=b*a+e*f+c*j-d*g;this.y=c*a+e*g+d*f-b*j;this.z=d*a+e*j+b*g-c*f;this.w=e*a-b*f-c*g-d*j;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,j=this.z,h=this.w,i=h*c+g*e-j*d,n=h*d+j*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-j*e;b.x=i*h+c*-f+n*-j-m*-g;b.y=n*h+c*-g+m*-f-i*-j;b.z=m*h+c*-j+i*-g-n*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,j=this.z,h=this.w,i=h*c+g*e-j*d,p=h*d+j*c-f*e,n=h*e+f*d-g*c;c=-f*c-g*d-j*e;b.x=i*h+c*-f+p*-j-n*-g;b.y=p*h+c*-g+n*-f-i*-j;b.z=n*h+c*-j+i*-g-p*-f;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.0010){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};
 THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={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.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -57,19 +56,18 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,j=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];j.sub(g.position,
 c.position);h.sub(b.position,c.position);j.crossSelf(h)}j.isZero()||j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){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++){c=this.faces[a];if(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];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(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];if(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])}else if(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(y,B,T,x,P,Y,L){f=y.vertices[B].position;g=y.vertices[T].position;j=y.vertices[x].position;h=e[P];i=e[Y];n=e[L];m=g.x-f.x;o=j.x-f.x;q=g.y-f.y;s=j.y-f.y;
-t=g.z-f.z;r=j.z-f.z;k=i.u-h.u;D=n.u-h.u;C=i.v-h.v;I=n.v-h.v;F=1/(k*I-D*C);w.set((I*m-C*o)*F,(I*q-C*s)*F,(I*t-C*r)*F);J.set((k*o-D*m)*F,(k*s-D*q)*F,(k*r-D*t)*F);N[B].addSelf(w);N[T].addSelf(w);N[x].addSelf(w);A[B].addSelf(J);A[T].addSelf(J);A[x].addSelf(J)}var b,c,d,e,f,g,j,h,i,n,m,o,q,s,t,r,k,D,C,I,F,N=[],A=[],w=new THREE.Vector3,J=new THREE.Vector3,u=new THREE.Vector3,K=new THREE.Vector3,E=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;A[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(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])}else if(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(x,z,W,w,O,Y,H){f=x.vertices[z].position;g=x.vertices[W].position;j=x.vertices[w].position;h=e[O];i=e[Y];p=e[H];n=g.x-f.x;o=j.x-f.x;q=g.y-f.y;u=j.y-f.y;
+v=g.z-f.z;s=j.z-f.z;k=i.u-h.u;G=p.u-h.u;F=i.v-h.v;K=p.v-h.v;I=1/(k*K-G*F);A.set((K*n-F*o)*I,(K*q-F*u)*I,(K*v-F*s)*I);L.set((k*o-G*n)*I,(k*u-G*q)*I,(k*s-G*v)*I);S[z].addSelf(A);S[W].addSelf(A);S[w].addSelf(A);C[z].addSelf(L);C[W].addSelf(L);C[w].addSelf(L)}var b,c,d,e,f,g,j,h,i,p,n,o,q,u,v,s,k,G,F,K,I,S=[],C=[],A=new THREE.Vector3,L=new THREE.Vector3,y=new THREE.Vector3,M=new THREE.Vector3,D=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){S[b]=new THREE.Vector3;C[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){E.copy(this.vertices[b].normal);d=N[b];u.copy(d);u.subSelf(E.multiplyScalar(E.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(A[b]);d=d<0?-1:1;this.vertices[b].tangent.set(u.x,u.y,u.z,d)}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],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){D.copy(this.vertices[b].normal);d=S[b];y.copy(d);y.subSelf(D.multiplyScalar(D.dot(d))).normalize();M.cross(this.vertices[b].normal,d);d=M.dot(C[b]);d=d<0?-1:1;this.vertices[b].tangent.set(y.x,y.y,y.z,d)}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=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
-THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
-this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
-THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
-THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||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(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
+THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
 THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
@@ -93,48 +91,48 @@ THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.Clam
 THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;
 THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;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(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
+THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
 THREE.Sound=function(a,b,c,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)e=
 "audio/mpeg";else if(b.indexOf(".ogg")!==-1)e="audio/ogg";else b.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
 THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
 THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
-THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
+THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
 THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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(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.Sound)this.sounds.indexOf(a)===-1&&this.sounds.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 if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(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(A,w){return w.z-A.z}function b(A,w){var J=0,u=1,K=A.z+A.w,E=w.z+w.w,y=-A.z+A.w,B=-w.z+w.w;if(K>=0&&E>=0&&y>=0&&B>=0)return!0;else if(K<0&&E<0||y<0&&B<0)return!1;else{if(K<0)J=Math.max(J,K/(K-E));else E<0&&(u=Math.min(u,K/(K-E)));if(y<0)J=Math.max(J,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(u<J)return!1;else{A.lerpSelf(w,J);w.lerpSelf(A,1-u);return!0}}}var c,d,e=[],f,g,j,h=[],i,n,m=[],o,q,s=[],t=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,D=new THREE.Matrix4,
-C=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,F=new THREE.Vector4,N;this.projectObjects=function(A,w,J){w=[];var u,K,E;d=0;K=A.objects;A=0;for(u=K.length;A<u;A++){E=K[A];var y;if(!(y=!E.visible))if(y=E instanceof THREE.Mesh){a:{y=void 0;for(var B=E.matrixWorld,T=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),x=0;x<6;x++){y=C[x].x*B.n14+C[x].y*B.n24+C[x].z*B.n34+C[x].w;if(y<=T){y=
-!1;break a}}y=!0}y=!y}if(!y){c=e[d]=e[d]||new THREE.RenderableObject;t.copy(E.position);k.multiplyVector3(t);c.object=E;c.z=t.z;w.push(c);d++}}J&&w.sort(a);return w};this.projectScene=function(A,w,J){var u=[],K=w.near,E=w.far,y,B,T,x,P,Y,L,ja,ka,la,ma,$,O,H,U,Q;j=n=q=0;w.matrixAutoUpdate&&w.update();k.multiply(w.projectionMatrix,w.matrixWorldInverse);C[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);C[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);C[2].set(k.n41+k.n21,k.n42+k.n22,
-k.n43+k.n23,k.n44+k.n24);C[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);C[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);C[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(y=0;y<6;y++){Y=C[y];Y.divideScalar(Math.sqrt(Y.x*Y.x+Y.y*Y.y+Y.z*Y.z))}A.update(undefined,!1,w);Y=this.projectObjects(A,w,!0);A=0;for(y=Y.length;A<y;A++){L=Y[A].object;if(L.visible){ja=L.matrixWorld;ma=L.matrixRotationWorld;ka=L.materials;la=L.overdraw;if(L instanceof THREE.Mesh){$=L.geometry;O=$.vertices;
-B=0;for(T=O.length;B<T;B++){H=O[B];H.positionWorld.copy(H.position);ja.multiplyVector3(H.positionWorld);x=H.positionScreen;x.copy(H.positionWorld);k.multiplyVector4(x);x.x/=x.w;x.y/=x.w;H.__visible=x.z>K&&x.z<E}$=$.faces;B=0;for(T=$.length;B<T;B++){H=$[B];if(H instanceof THREE.Face3){x=O[H.a];P=O[H.b];U=O[H.c];if(x.__visible&&P.__visible&&U.__visible&&(L.doubleSided||L.flipSided!=(U.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(U.positionScreen.y-x.positionScreen.y)*
-(P.positionScreen.x-x.positionScreen.x)<0)){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(U.positionWorld);f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(U.positionScreen);f.normalWorld.copy(H.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
-k.multiplyVector3(f.centroidScreen);U=H.vertexNormals;N=f.vertexNormalsWorld;x=0;for(P=U.length;x<P;x++){Q=N[x]=N[x]||new THREE.Vector3;Q.copy(U[x]);ma.multiplyVector3(Q)}f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=H.materials;f.overdraw=la;if(L.geometry.uvs[B]){f.uvs[0]=L.geometry.uvs[B][0];f.uvs[1]=L.geometry.uvs[B][1];f.uvs[2]=L.geometry.uvs[B][2]}u.push(f);j++}}else if(H instanceof THREE.Face4){x=O[H.a];P=O[H.b];U=O[H.c];Q=O[H.d];if(x.__visible&&P.__visible&&U.__visible&&Q.__visible&&
-(L.doubleSided||L.flipSided!=((Q.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(Q.positionScreen.y-x.positionScreen.y)*(P.positionScreen.x-x.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-U.positionScreen.x)<0))){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(Q.positionWorld);
-f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(Q.positionScreen);f.normalWorld.copy(H.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=H.materials;f.overdraw=la;if(L.geometry.uvs[B]){f.uvs[0]=L.geometry.uvs[B][0];f.uvs[1]=L.geometry.uvs[B][1];
-f.uvs[2]=L.geometry.uvs[B][3]}u.push(f);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(P.positionWorld);g.v2.positionWorld.copy(U.positionWorld);g.v3.positionWorld.copy(Q.positionWorld);g.v1.positionScreen.copy(P.positionScreen);g.v2.positionScreen.copy(U.positionScreen);g.v3.positionScreen.copy(Q.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=ka;g.faceMaterials=
-H.materials;g.overdraw=la;if(L.geometry.uvs[B]){g.uvs[0]=L.geometry.uvs[B][1];g.uvs[1]=L.geometry.uvs[B][2];g.uvs[2]=L.geometry.uvs[B][3]}u.push(g);j++}}}}else if(L instanceof THREE.Line){D.multiply(k,ja);O=L.geometry.vertices;H=O[0];H.positionScreen.copy(H.position);D.multiplyVector4(H.positionScreen);B=1;for(T=O.length;B<T;B++){x=O[B];x.positionScreen.copy(x.position);D.multiplyVector4(x.positionScreen);P=O[B-1];I.copy(x.positionScreen);F.copy(P.positionScreen);if(b(I,F)){I.multiplyScalar(1/I.w);
-F.multiplyScalar(1/F.w);i=m[n]=m[n]||new THREE.RenderableLine;i.v1.positionScreen.copy(I);i.v2.positionScreen.copy(F);i.z=Math.max(I.z,F.z);i.materials=L.materials;u.push(i);n++}}}else if(L instanceof THREE.Particle){r.set(L.position.x,L.position.y,L.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=L.rotation.z;o.scale.x=L.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14));
-o.scale.y=L.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=L.materials;u.push(o);q++}}}}J&&u.sort(a);return u};this.unprojectVector=function(A,w){var J=w.matrixWorld.clone();J.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));J.multiplyVector3(A);return A}};
-THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,g,j,h,i=e.getContext("2d"),n=new THREE.Color(0),m=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,J,u=new THREE.Color,
-K=new THREE.Color,E=new THREE.Color,y=new THREE.Color,B=new THREE.Color,T,x,P,Y,L,ja,ka,la,ma,$=new THREE.Rectangle,O=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,Q=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,R=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas");
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){f=V;g=da;j=f/2;h=g/2;e.width=f;e.height=g;$.set(-j,-h,j,h);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){n=V;m=da};this.setClearColorHex=function(V,da){n.setHex(V);m=da};this.clear=function(){i.setTransform(1,0,0,-1,j,h);if(!O.isEmpty()){O.inflate(1);O.minSelf($);if(n.hex==0&&m==0)i.clearRect(O.getX(),
-O.getY(),O.getWidth(),O.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+m+")";i.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(V,da){function Ma(l){var G,z,p,v=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(G=v.length;l<G;l++){z=v[l];p=z.color;if(z instanceof THREE.AmbientLight){aa.r+=p.r;aa.g+=p.g;aa.b+=p.b}else if(z instanceof THREE.DirectionalLight){na.r+=
-p.r;na.g+=p.g;na.b+=p.b}else if(z instanceof THREE.PointLight){oa.r+=p.r;oa.g+=p.g;oa.b+=p.b}}}function ya(l,G,z,p){var v,M,W,X,Z=l.lights;l=0;for(v=Z.length;l<v;l++){M=Z[l];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=z.dot(M.position)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}else if(M instanceof THREE.PointLight){R.sub(M.position,G);R.normalize();M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(l,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p,
-v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*h;z=v*X;p=M*Z;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r=aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString=
-z.color.__styleString;z=G.scale.x*j;p=G.scale.y*h;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath();i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString=
-p.color.__styleString;l=p.linewidth;if(r!=l)i.lineWidth=r=l;l=u.__styleString;if(s!=l)i.strokeStyle=s=l;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(l,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;J=z.positionScreen.y;i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,J);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&
-ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorldInverse;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;L=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]);ja=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ka=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*
-0.5+0.5;ma=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;ua(I,F,N,A,w,J,v.envMap.image,Y,L,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==
-3){K.r=E.r=y.r=aa.r;K.g=E.g=y.g=aa.g;K.b=E.b=y.b=aa.b;ya(M,p.v1.positionWorld,p.vertexNormalsWorld[0],K);ya(M,p.v2.positionWorld,p.vertexNormalsWorld[1],E);ya(M,p.v3.positionWorld,p.vertexNormalsWorld[2],y);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else{Q.r=aa.r;Q.g=aa.g;Q.b=aa.b;ya(M,p.centroidWorld,p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):
-Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;K.r=K.g=K.b=1-Da(l.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){u.r=Ea(p.normalWorld.x);u.g=Ea(p.normalWorld.y);u.b=Ea(p.normalWorld.z);
-u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}}}function za(l,G){if(s!=l)i.strokeStyle=s=l;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(l){if(t!=l)i.fillStyle=t=l;i.fill()}function ua(l,G,z,p,v,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=ea;va*=ia;z-=l;p-=G;v-=l;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*z-ca*v)*ia;ca=(va*p-ca*M)*ia;z=(ga*v-ha*z)*ia;p=(ga*M-ha*p)*
-ia;l=l-ea*X-z*Z;G=G-ca*X-p*Z;i.save();i.transform(ea,ca,z,p,l,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,G,z,p){var v=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(z.r*255),ga=~~(z.g*255);z=~~(z.b*255);var ca=~~(p.r*255),ha=~~(p.g*255);p=~~(p.b*255);ba[0]=v<0?0:v>255?255:v;ba[1]=M<0?0:M>255?255:M;ba[2]=l<0?0:l>255?255:l;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?
-255:ga;ba[10]=z<0?0:z>255?255:z;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=p<0?0:p>255?255:p;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,G,z){l=(l-G)/(z-G);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,G){var z=G.x-l.x,p=G.y-l.y,v=1/Math.sqrt(z*z+p*p);z*=v;p*=v;G.x+=z;G.y+=p;l.x-=z;l.y-=p}var Ba,Ja,S,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,h);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>
-0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){S=c[Ba];H.empty();if(S instanceof THREE.RenderableParticle){k=S;k.x*=j;k.y*=h;fa=0;for(qa=S.materials.length;fa<qa;fa++)Na(k,S,S.materials[fa],V)}else if(S instanceof THREE.RenderableLine){k=S.v1;D=S.v2;k.positionScreen.x*=j;k.positionScreen.y*=h;D.positionScreen.x*=j;D.positionScreen.y*=h;H.addPoint(k.positionScreen.x,k.positionScreen.y);H.addPoint(D.positionScreen.x,D.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.materials.length;fa<qa;)Oa(k,D,S,
-S.materials[fa++],V)}}else if(S instanceof THREE.RenderableFace3){k=S.v1;D=S.v2;C=S.v3;k.positionScreen.x*=j;k.positionScreen.y*=h;D.positionScreen.x*=j;D.positionScreen.y*=h;C.positionScreen.x*=j;C.positionScreen.y*=h;if(S.overdraw){Fa(k.positionScreen,D.positionScreen);Fa(D.positionScreen,C.positionScreen);Fa(C.positionScreen,k.positionScreen)}H.add3Points(k.positionScreen.x,k.positionScreen.y,D.positionScreen.x,D.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if($.instersects(H)){fa=0;
-for(qa=S.meshMaterials.length;fa<qa;){wa=S.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=S.faceMaterials.length;Ga<Ka;)(wa=S.faceMaterials[Ga++])&&Ha(k,D,C,S,wa,V)}else Ha(k,D,C,S,wa,V)}}}O.addRectangle(H)}i.setTransform(1,0,0,1,0,0)}};
+THREE.Projector=function(){function a(C,A){return A.z-C.z}function b(C,A){var L=0,y=1,M=C.z+C.w,D=A.z+A.w,x=-C.z+C.w,z=-A.z+A.w;if(M>=0&&D>=0&&x>=0&&z>=0)return!0;else if(M<0&&D<0||x<0&&z<0)return!1;else{if(M<0)L=Math.max(L,M/(M-D));else D<0&&(y=Math.min(y,M/(M-D)));if(x<0)L=Math.max(L,x/(x-z));else z<0&&(y=Math.min(y,x/(x-z)));if(y<L)return!1;else{C.lerpSelf(A,L);A.lerpSelf(C,1-y);return!0}}}var c,d,e=[],f,g,j,h=[],i,p,n=[],o,q,u=[],v=new THREE.Vector4,s=new THREE.Vector4,k=new THREE.Matrix4,G=new THREE.Matrix4,
+F=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Vector4,I=new THREE.Vector4,S;this.projectObjects=function(C,A,L){A=[];var y,M,D;d=0;M=C.objects;C=0;for(y=M.length;C<y;C++){D=M[C];var x;if(!(x=!D.visible))if(x=D instanceof THREE.Mesh){a:{x=void 0;for(var z=D.matrixWorld,W=-D.geometry.boundingSphere.radius*Math.max(D.scale.x,Math.max(D.scale.y,D.scale.z)),w=0;w<6;w++){x=F[w].x*z.n14+F[w].y*z.n24+F[w].z*z.n34+F[w].w;if(x<=W){x=
+!1;break a}}x=!0}x=!x}if(!x){c=e[d]=e[d]||new THREE.RenderableObject;v.copy(D.position);k.multiplyVector3(v);c.object=D;c.z=v.z;A.push(c);d++}}L&&A.sort(a);return A};this.projectScene=function(C,A,L){var y=[],M=A.near,D=A.far,x,z,W,w,O,Y,H,ja,ka,la,ma,$,N,E,T,P;j=p=q=0;A.matrixAutoUpdate&&A.update();k.multiply(A.projectionMatrix,A.matrixWorldInverse);F[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);F[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);F[2].set(k.n41+k.n21,k.n42+k.n22,
+k.n43+k.n23,k.n44+k.n24);F[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);F[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);F[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(x=0;x<6;x++){Y=F[x];Y.divideScalar(Math.sqrt(Y.x*Y.x+Y.y*Y.y+Y.z*Y.z))}C.update(undefined,!1,A);Y=this.projectObjects(C,A,!0);C=0;for(x=Y.length;C<x;C++){H=Y[C].object;if(H.visible){ja=H.matrixWorld;ma=H.matrixRotationWorld;ka=H.materials;la=H.overdraw;if(H instanceof THREE.Mesh){$=H.geometry;N=$.vertices;
+z=0;for(W=N.length;z<W;z++){E=N[z];E.positionWorld.copy(E.position);ja.multiplyVector3(E.positionWorld);w=E.positionScreen;w.copy(E.positionWorld);k.multiplyVector4(w);w.x/=w.w;w.y/=w.w;E.__visible=w.z>M&&w.z<D}$=$.faces;z=0;for(W=$.length;z<W;z++){E=$[z];if(E instanceof THREE.Face3){w=N[E.a];O=N[E.b];T=N[E.c];if(w.__visible&&O.__visible&&T.__visible&&(H.doubleSided||H.flipSided!=(T.positionScreen.x-w.positionScreen.x)*(O.positionScreen.y-w.positionScreen.y)-(T.positionScreen.y-w.positionScreen.y)*
+(O.positionScreen.x-w.positionScreen.x)<0)){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(w.positionWorld);f.v2.positionWorld.copy(O.positionWorld);f.v3.positionWorld.copy(T.positionWorld);f.v1.positionScreen.copy(w.positionScreen);f.v2.positionScreen.copy(O.positionScreen);f.v3.positionScreen.copy(T.positionScreen);f.normalWorld.copy(E.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(E.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
+k.multiplyVector3(f.centroidScreen);T=E.vertexNormals;S=f.vertexNormalsWorld;w=0;for(O=T.length;w<O;w++){P=S[w]=S[w]||new THREE.Vector3;P.copy(T[w]);ma.multiplyVector3(P)}f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=E.materials;f.overdraw=la;if(H.geometry.uvs[z]){f.uvs[0]=H.geometry.uvs[z][0];f.uvs[1]=H.geometry.uvs[z][1];f.uvs[2]=H.geometry.uvs[z][2]}y.push(f);j++}}else if(E instanceof THREE.Face4){w=N[E.a];O=N[E.b];T=N[E.c];P=N[E.d];if(w.__visible&&O.__visible&&T.__visible&&P.__visible&&
+(H.doubleSided||H.flipSided!=((P.positionScreen.x-w.positionScreen.x)*(O.positionScreen.y-w.positionScreen.y)-(P.positionScreen.y-w.positionScreen.y)*(O.positionScreen.x-w.positionScreen.x)<0||(O.positionScreen.x-T.positionScreen.x)*(P.positionScreen.y-T.positionScreen.y)-(O.positionScreen.y-T.positionScreen.y)*(P.positionScreen.x-T.positionScreen.x)<0))){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(w.positionWorld);f.v2.positionWorld.copy(O.positionWorld);f.v3.positionWorld.copy(P.positionWorld);
+f.v1.positionScreen.copy(w.positionScreen);f.v2.positionScreen.copy(O.positionScreen);f.v3.positionScreen.copy(P.positionScreen);f.normalWorld.copy(E.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(E.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=E.materials;f.overdraw=la;if(H.geometry.uvs[z]){f.uvs[0]=H.geometry.uvs[z][0];f.uvs[1]=H.geometry.uvs[z][1];
+f.uvs[2]=H.geometry.uvs[z][3]}y.push(f);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(O.positionWorld);g.v2.positionWorld.copy(T.positionWorld);g.v3.positionWorld.copy(P.positionWorld);g.v1.positionScreen.copy(O.positionScreen);g.v2.positionScreen.copy(T.positionScreen);g.v3.positionScreen.copy(P.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=ka;g.faceMaterials=
+E.materials;g.overdraw=la;if(H.geometry.uvs[z]){g.uvs[0]=H.geometry.uvs[z][1];g.uvs[1]=H.geometry.uvs[z][2];g.uvs[2]=H.geometry.uvs[z][3]}y.push(g);j++}}}}else if(H instanceof THREE.Line){G.multiply(k,ja);N=H.geometry.vertices;E=N[0];E.positionScreen.copy(E.position);G.multiplyVector4(E.positionScreen);z=1;for(W=N.length;z<W;z++){w=N[z];w.positionScreen.copy(w.position);G.multiplyVector4(w.positionScreen);O=N[z-1];K.copy(w.positionScreen);I.copy(O.positionScreen);if(b(K,I)){K.multiplyScalar(1/K.w);
+I.multiplyScalar(1/I.w);i=n[p]=n[p]||new THREE.RenderableLine;i.v1.positionScreen.copy(K);i.v2.positionScreen.copy(I);i.z=Math.max(K.z,I.z);i.materials=H.materials;y.push(i);p++}}}else if(H instanceof THREE.Particle){s.set(H.position.x,H.position.y,H.position.z,1);k.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){o=u[q]=u[q]||new THREE.RenderableParticle;o.x=s.x/s.w;o.y=s.y/s.w;o.z=s.z;o.rotation=H.rotation.z;o.scale.x=H.scale.x*Math.abs(o.x-(s.x+A.projectionMatrix.n11)/(s.w+A.projectionMatrix.n14));
+o.scale.y=H.scale.y*Math.abs(o.y-(s.y+A.projectionMatrix.n22)/(s.w+A.projectionMatrix.n24));o.materials=H.materials;y.push(o);q++}}}}L&&y.sort(a);return y};this.unprojectVector=function(C,A){var L=A.matrixWorld.clone();L.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));L.multiplyVector3(C);return C}};
+THREE.CanvasRenderer=function(){function a(U){if(o!=U)i.globalAlpha=o=U}function b(U){if(q!=U){switch(U){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=U}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,g,j,h,i=e.getContext("2d"),p=new THREE.Color(0),n=0,o=1,q=0,u=null,v=null,s=1,k,G,F,K,I,S,C,A,L,y=new THREE.Color,
+M=new THREE.Color,D=new THREE.Color,x=new THREE.Color,z=new THREE.Color,W,w,O,Y,H,ja,ka,la,ma,$=new THREE.Rectangle,N=new THREE.Rectangle,E=new THREE.Rectangle,T=!1,P=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,Q=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas");
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(U,da){f=U;g=da;j=f/2;h=g/2;e.width=f;e.height=g;$.set(-j,-h,j,h);o=1;q=0;v=u=null;s=1};this.setClearColor=function(U,da){p=U;n=da};this.setClearColorHex=function(U,da){p.setHex(U);n=da};this.clear=function(){i.setTransform(1,0,0,-1,j,h);if(!N.isEmpty()){N.inflate(1);N.minSelf($);if(p.hex==0&&n==0)i.clearRect(N.getX(),
+N.getY(),N.getWidth(),N.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+n+")";i.fillRect(N.getX(),N.getY(),N.getWidth(),N.getHeight())}N.empty()}};this.render=function(U,da){function Ma(l){var B,t,m,r=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(B=r.length;l<B;l++){t=r[l];m=t.color;if(t instanceof THREE.AmbientLight){aa.r+=m.r;aa.g+=m.g;aa.b+=m.b}else if(t instanceof THREE.DirectionalLight){na.r+=
+m.r;na.g+=m.g;na.b+=m.b}else if(t instanceof THREE.PointLight){oa.r+=m.r;oa.g+=m.g;oa.b+=m.b}}}function ya(l,B,t,m){var r,J,V,X,Z=l.lights;l=0;for(r=Z.length;l<r;l++){J=Z[l];V=J.color;X=J.intensity;if(J instanceof THREE.DirectionalLight){J=t.dot(J.position)*X;if(J>0){m.r+=V.r*J;m.g+=V.g*J;m.b+=V.b*J}}else if(J instanceof THREE.PointLight){Q.sub(J.position,B);Q.normalize();J=t.dot(Q)*X;if(J>0){m.r+=V.r*J;m.g+=V.g*J;m.b+=V.b*J}}}}function Na(l,B,t){if(t.opacity!=0){a(t.opacity);b(t.blending);var m,
+r,J,V,X,Z;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){V=t.map.image;X=V.width>>1;Z=V.height>>1;r=B.scale.x*j;J=B.scale.y*h;t=r*X;m=J*Z;E.set(l.x-t,l.y-m,l.x+t,l.y+m);if($.instersects(E)){i.save();i.translate(l.x,l.y);i.rotate(-B.rotation);i.scale(r,-J);i.translate(-X,-Z);i.drawImage(V,0,0);i.restore()}}}else if(t instanceof THREE.ParticleCircleMaterial){if(T){P.r=aa.r+na.r+oa.r;P.g=aa.g+na.g+oa.g;P.b=aa.b+na.b+oa.b;y.r=t.color.r*P.r;y.g=t.color.g*P.g;y.b=t.color.b*P.b;y.updateStyleString()}else y.__styleString=
+t.color.__styleString;t=B.scale.x*j;m=B.scale.y*h;E.set(l.x-t,l.y-m,l.x+t,l.y+m);if($.instersects(E)){r=y.__styleString;if(v!=r)i.fillStyle=v=r;i.save();i.translate(l.x,l.y);i.rotate(-B.rotation);i.scale(t,m);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,B,t,m){if(m.opacity!=0){a(m.opacity);b(m.blending);i.beginPath();i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(B.positionScreen.x,B.positionScreen.y);i.closePath();if(m instanceof THREE.LineBasicMaterial){y.__styleString=
+m.color.__styleString;l=m.linewidth;if(s!=l)i.lineWidth=s=l;l=y.__styleString;if(u!=l)i.strokeStyle=u=l;i.stroke();E.inflate(m.linewidth*2)}}}function Ha(l,B,t,m,r,J){if(r.opacity!=0){a(r.opacity);b(r.blending);K=l.positionScreen.x;I=l.positionScreen.y;S=B.positionScreen.x;C=B.positionScreen.y;A=t.positionScreen.x;L=t.positionScreen.y;i.beginPath();i.moveTo(K,I);i.lineTo(S,C);i.lineTo(A,L);i.lineTo(K,I);i.closePath();if(r instanceof THREE.MeshBasicMaterial)if(r.map)r.map.mapping instanceof THREE.UVMapping&&
+ua(K,I,S,C,A,L,r.map.image,m.uvs[0].u,m.uvs[0].v,m.uvs[1].u,m.uvs[1].v,m.uvs[2].u,m.uvs[2].v);else if(r.envMap){if(r.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorldInverse;Q.copy(m.vertexNormalsWorld[0]);Y=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)*0.5+0.5;H=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;Q.copy(m.vertexNormalsWorld[1]);ja=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)*0.5+0.5;ka=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;Q.copy(m.vertexNormalsWorld[2]);la=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)*
+0.5+0.5;ma=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;ua(K,I,S,C,A,L,r.envMap.image,Y,H,ja,ka,la,ma)}}else r.wireframe?za(r.color.__styleString,r.wireframeLinewidth):Aa(r.color.__styleString);else if(r instanceof THREE.MeshLambertMaterial){if(r.map&&!r.wireframe){r.map.mapping instanceof THREE.UVMapping&&ua(K,I,S,C,A,L,r.map.image,m.uvs[0].u,m.uvs[0].v,m.uvs[1].u,m.uvs[1].v,m.uvs[2].u,m.uvs[2].v);b(THREE.SubtractiveBlending)}if(T)if(!r.wireframe&&r.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==
+3){M.r=D.r=x.r=aa.r;M.g=D.g=x.g=aa.g;M.b=D.b=x.b=aa.b;ya(J,m.v1.positionWorld,m.vertexNormalsWorld[0],M);ya(J,m.v2.positionWorld,m.vertexNormalsWorld[1],D);ya(J,m.v3.positionWorld,m.vertexNormalsWorld[2],x);z.r=(D.r+x.r)*0.5;z.g=(D.g+x.g)*0.5;z.b=(D.b+x.b)*0.5;O=Ia(M,D,x,z);ua(K,I,S,C,A,L,O,0,0,1,0,0,1)}else{P.r=aa.r;P.g=aa.g;P.b=aa.b;ya(J,m.centroidWorld,m.normalWorld,P);y.r=r.color.r*P.r;y.g=r.color.g*P.g;y.b=r.color.b*P.b;y.updateStyleString();r.wireframe?za(y.__styleString,r.wireframeLinewidth):
+Aa(y.__styleString)}else r.wireframe?za(r.color.__styleString,r.wireframeLinewidth):Aa(r.color.__styleString)}else if(r instanceof THREE.MeshDepthMaterial){W=da.near;w=da.far;M.r=M.g=M.b=1-Da(l.positionScreen.z,W,w);D.r=D.g=D.b=1-Da(B.positionScreen.z,W,w);x.r=x.g=x.b=1-Da(t.positionScreen.z,W,w);z.r=(D.r+x.r)*0.5;z.g=(D.g+x.g)*0.5;z.b=(D.b+x.b)*0.5;O=Ia(M,D,x,z);ua(K,I,S,C,A,L,O,0,0,1,0,0,1)}else if(r instanceof THREE.MeshNormalMaterial){y.r=Ea(m.normalWorld.x);y.g=Ea(m.normalWorld.y);y.b=Ea(m.normalWorld.z);
+y.updateStyleString();r.wireframe?za(y.__styleString,r.wireframeLinewidth):Aa(y.__styleString)}}}function za(l,B){if(u!=l)i.strokeStyle=u=l;if(s!=B)i.lineWidth=s=B;i.stroke();E.inflate(B*2)}function Aa(l){if(v!=l)i.fillStyle=v=l;i.fill()}function ua(l,B,t,m,r,J,V,X,Z,ga,ca,ha,va){var ea,ia;ea=V.width-1;ia=V.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=ea;va*=ia;t-=l;m-=B;r-=l;J-=B;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*t-ca*r)*ia;ca=(va*m-ca*J)*ia;t=(ga*r-ha*t)*ia;m=(ga*J-ha*m)*
+ia;l=l-ea*X-t*Z;B=B-ca*X-m*Z;i.save();i.transform(ea,ca,t,m,l,B);i.clip();i.drawImage(V,0,0);i.restore()}}function Ia(l,B,t,m){var r=~~(l.r*255),J=~~(l.g*255);l=~~(l.b*255);var V=~~(B.r*255),X=~~(B.g*255);B=~~(B.b*255);var Z=~~(t.r*255),ga=~~(t.g*255);t=~~(t.b*255);var ca=~~(m.r*255),ha=~~(m.g*255);m=~~(m.b*255);ba[0]=r<0?0:r>255?255:r;ba[1]=J<0?0:J>255?255:J;ba[2]=l<0?0:l>255?255:l;ba[4]=V<0?0:V>255?255:V;ba[5]=X<0?0:X>255?255:X;ba[6]=B<0?0:B>255?255:B;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?
+255:ga;ba[10]=t<0?0:t>255?255:t;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=m<0?0:m>255?255:m;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,B,t){l=(l-B)/(t-B);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,B){var t=B.x-l.x,m=B.y-l.y,r=1/Math.sqrt(t*t+m*m);t*=r;m*=r;B.x+=t;B.y+=m;l.x-=t;l.y-=m}var Ba,Ja,R,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,h);c=d.projectScene(U,da,this.sortElements);(T=U.lights.length>
+0)&&Ma(U);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){R=c[Ba];E.empty();if(R instanceof THREE.RenderableParticle){k=R;k.x*=j;k.y*=h;fa=0;for(qa=R.materials.length;fa<qa;fa++)Na(k,R,R.materials[fa],U)}else if(R instanceof THREE.RenderableLine){k=R.v1;G=R.v2;k.positionScreen.x*=j;k.positionScreen.y*=h;G.positionScreen.x*=j;G.positionScreen.y*=h;E.addPoint(k.positionScreen.x,k.positionScreen.y);E.addPoint(G.positionScreen.x,G.positionScreen.y);if($.instersects(E)){fa=0;for(qa=R.materials.length;fa<qa;)Oa(k,G,R,
+R.materials[fa++],U)}}else if(R instanceof THREE.RenderableFace3){k=R.v1;G=R.v2;F=R.v3;k.positionScreen.x*=j;k.positionScreen.y*=h;G.positionScreen.x*=j;G.positionScreen.y*=h;F.positionScreen.x*=j;F.positionScreen.y*=h;if(R.overdraw){Fa(k.positionScreen,G.positionScreen);Fa(G.positionScreen,F.positionScreen);Fa(F.positionScreen,k.positionScreen)}E.add3Points(k.positionScreen.x,k.positionScreen.y,G.positionScreen.x,G.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if($.instersects(E)){fa=0;
+for(qa=R.meshMaterials.length;fa<qa;){wa=R.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=R.faceMaterials.length;Ga<Ka;)(wa=R.faceMaterials[Ga++])&&Ha(k,G,F,R,wa,U)}else Ha(k,G,F,R,wa,U)}}}N.addRectangle(E)}i.setTransform(1,0,0,1,0,0)}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,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.Vertex;this.v2=new THREE.Vertex;this.materials=null};

+ 55 - 58
build/custom/ThreeDOM.js

@@ -1,4 +1,4 @@
-// ThreeDOM.js r34 - http://github.com/mrdoob/three.js
+// ThreeDOM.js r35 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
 THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,g,i,h;if(c==0)d=e=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:d=h;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=h;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=h;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
@@ -8,81 +8,78 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(r,k,B,w){w=w.clone().subSelf(k);B=B.clone().subSelf(k);var F=r.clone().subSelf(k);r=w.dot(w);k=w.dot(B);w=w.dot(F);var G=B.dot(B);B=B.dot(F);F=1/(r*G-k*k);G=(G*w-k*B)*F;r=(r*B-k*w)*F;return G>0&&r>0&&G+r<1}var c,d,e,f,g,i,h,j,n,l,
-m,o=a.geometry,p=o.vertices,q=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];l=this.origin.clone();m=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(p[e.a].position.clone());g=h.multiplyVector3(p[e.b].position.clone());i=h.multiplyVector3(p[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(p[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=m.dot(j);if(n<0){j=j.dot((new THREE.Vector3).sub(f,l))/n;l=l.addSelf(m.multiplyScalar(j));
-if(e instanceof THREE.Face3){if(b(l,f,g,i)){e={distance:this.origin.distanceTo(l),point:l,face:e,object:a};q.push(e)}}else if(e instanceof THREE.Face4&&(b(l,f,g,h)||b(l,g,i,h))){e={distance:this.origin.distanceTo(l),point:l,face:e,object:a};q.push(e)}}}return q}};
-THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,j,n,l){i=!1;b=h;c=j;d=n;e=l;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;d=h;e=j}else{b=b<h?b:h;c=c<j?c:j;d=d>h?d:h;e=e>j?e:j}a()};
-this.add3Points=function(h,j,n,l,m,o){if(i){i=!1;b=h<n?h<m?h:m:n<m?n:m;c=j<l?j<o?j:o:l<o?l:o;d=h>n?h>m?h:m:n>m?n:m;e=j>l?j>o?j:o:l>o?l:o}else{b=h<n?h<m?h<b?h:b:m<b?m:b:n<m?n<b?n:b:m<b?m:b;c=j<l?j<o?j<c?j:c:o<c?o:c:l<o?l<c?l:c:o<c?o:c;d=h>n?h>m?h>d?h:d:m>d?m:d:n>m?n>d?n:d:m>d?m:d;e=j>l?j>o?j>e?j:e:o>e?o:e:l>o?l>e?l:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(p,k,D,z){z=z.clone().subSelf(k);D=D.clone().subSelf(k);var G=p.clone().subSelf(k);p=z.dot(z);k=z.dot(D);z=z.dot(G);var H=D.dot(D);D=D.dot(G);G=1/(p*H-k*k);H=(H*z-k*D)*G;p=(p*D-k*z)*G;return H>0&&p>0&&H+p<1}var c,d,e,f,g,i,h,j,n,m,
+l,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();l=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(q[e.a].position.clone());g=h.multiplyVector3(q[e.b].position.clone());i=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=l.dot(j);if(n<0){j=j.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(l.multiplyScalar(j));
+if(e instanceof THREE.Face3){if(b(m,f,g,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};r.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,i,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};r.push(e)}}}return r}};
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,j,n,m){i=!1;b=h;c=j;d=n;e=m;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;d=h;e=j}else{b=b<h?b:h;c=c<j?c:j;d=d>h?d:h;e=e>j?e:j}a()};
+this.add3Points=function(h,j,n,m,l,o){if(i){i=!1;b=h<n?h<l?h:l:n<l?n:l;c=j<m?j<o?j:o:m<o?m:o;d=h>n?h>l?h:l:n>l?n:l;e=j>m?j>o?j:o:m>o?m:o}else{b=h<n?h<l?h<b?h:b:l<b?l:b:n<l?n<b?n:b:l<b?l:b;c=j<m?j<o?j<c?j:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=h>n?h>l?h>d?h:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=j>m?j>o?j>e?j:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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,e,f,g,i,h,j,n,l,m,o,p,q){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,j||0,n||1,l||0,m||0,o||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,j,n,l,m,o,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=n;this.n34=l;this.n41=m;this.n42=o;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.__tmpVec1,
-e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
-b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,l=a.n32,m=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44,B=b.n11,w=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,x=b.n34;this.n11=c*
-B+d*I+e*z;this.n12=c*w+d*v+e*D;this.n13=c*F+d*t+e*E;this.n14=c*G+d*C+e*x+f;this.n21=g*B+i*I+h*z;this.n22=g*w+i*v+h*D;this.n23=g*F+i*t+h*E;this.n24=g*G+i*C+h*x+j;this.n31=n*B+l*I+m*z;this.n32=n*w+l*v+m*D;this.n33=n*F+l*t+m*E;this.n34=n*G+l*C+m*x+o;this.n41=p*B+q*I+r*z;this.n42=p*w+q*v+r*D;this.n43=p*F+q*t+r*E;this.n44=p*G+q*C+r*x+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,j=a.n23,n=a.n24,l=a.n31,m=a.n32,o=a.n33,p=a.n34,q=a.n41,r=a.n42,k=a.n43;
-a=a.n44;var B=b.n11,w=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,x=b.n34,u=b.n41,L=b.n42,s=b.n43;b=b.n44;this.n11=d*B+e*I+f*z+g*u;this.n12=d*w+e*v+f*D+g*L;this.n13=d*F+e*t+f*E+g*s;this.n14=d*G+e*C+f*x+g*b;this.n21=i*B+h*I+j*z+n*u;this.n22=i*w+h*v+j*D+n*L;this.n23=i*F+h*t+j*E+n*s;this.n24=i*G+h*C+j*x+n*b;this.n31=l*B+m*I+o*z+p*u;this.n32=l*w+m*v+o*D+p*L;this.n33=l*F+m*t+o*E+p*s;this.n34=l*G+m*C+o*x+p*b;this.n41=q*B+r*I+k*z+a*u;this.n42=q*w+r*v+k*D+a*L;this.n43=q*
-F+r*t+k*E+a*s;this.n44=q*G+r*C+k*x+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){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,j=this.n31,n=this.n32,l=this.n33,m=this.n34,o=this.n41,p=this.n42,q=this.n43,r=this.n44,k=a.n11,B=a.n21,
-w=a.n31,F=a.n12,G=a.n22,I=a.n32,v=a.n13,t=a.n23,C=a.n33,z=a.n14,D=a.n24;a=a.n34;this.n11=b*k+c*B+d*w;this.n12=b*F+c*G+d*I;this.n13=b*v+c*t+d*C;this.n14=b*z+c*D+d*a+e;this.n21=f*k+g*B+i*w;this.n22=f*F+g*G+i*I;this.n23=f*v+g*t+i*C;this.n24=f*z+g*D+i*a+h;this.n31=j*k+n*B+l*w;this.n32=j*F+n*G+l*I;this.n33=j*v+n*t+l*C;this.n34=j*z+n*D+l*a+m;this.n41=o*k+p*B+q*w;this.n42=o*F+p*G+q*I;this.n43=o*v+p*t+q*C;this.n44=o*z+p*D+q*a+r;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,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,l=this.n34,m=this.n41,o=this.n42,p=this.n43,q=this.n44;return d*g*j*m-c*i*j*m-d*f*n*m+b*i*n*m+c*f*l*m-b*g*l*m-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*l*o+a*g*l*o+d*f*h*p-b*i*h*p-d*e*j*p+a*i*j*p+b*e*
-l*p-a*f*l*p-c*f*h*q+b*g*h*q+c*e*j*q-a*g*j*q-b*e*n*q+a*f*n*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.flattenToArray(this.flat);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},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g,j*i+d*f,e*i*i+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=
-b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j)},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}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
-THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,l=a.n32,m=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*q-j*m*q+j*l*r-i*o*r-h*l*k+i*m*k;b.n12=f*m*q-e*o*q-f*l*r+d*o*r+e*l*k-d*m*k;b.n13=e*j*q-f*h*q+f*i*r-d*j*r-e*i*k+d*h*k;b.n14=f*h*l-e*j*l-f*i*m+d*j*m+e*i*o-d*h*o;b.n21=j*m*p-h*o*p-j*n*r+g*o*r+h*n*k-g*m*k;b.n22=e*o*p-f*m*p+f*n*r-c*o*r-e*n*k+c*m*k;b.n23=f*h*p-e*j*p-f*g*r+c*j*r+e*g*k-c*h*k;
-b.n24=e*j*n-f*h*n+f*g*m-c*j*m-e*g*o+c*h*o;b.n31=i*o*p-j*l*p+j*n*q-g*o*q-i*n*k+g*l*k;b.n32=f*l*p-d*o*p-f*n*q+c*o*q+d*n*k-c*l*k;b.n33=e*j*p-f*i*p+f*g*q-c*j*q-d*g*k+c*i*k;b.n34=f*i*n-d*j*n-f*g*l+c*j*l+d*g*o-c*i*o;b.n41=h*l*p-i*m*p-h*n*q+g*m*q+i*n*r-g*l*r;b.n42=d*m*p-e*l*p+e*n*q-c*m*q-d*n*r+c*l*r;b.n43=e*i*p-d*h*p-e*g*q+c*h*q+d*g*r-c*i*r;b.n44=d*h*n-e*i*n+e*g*l-c*h*l-d*g*m+c*i*m;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,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*n;c[8]=a*l;return b};
+THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,j||0,n||1,m||0,l||0,o||0,q||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=r;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,
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
+multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44,D=b.n11,z=b.n12,G=b.n13,H=b.n14,M=b.n21,x=b.n22,v=b.n23,E=b.n24,B=b.n31,F=b.n32,A=b.n33,w=b.n34;this.n11=c*D+d*M+e*B;this.n12=
+c*z+d*x+e*F;this.n13=c*G+d*v+e*A;this.n14=c*H+d*E+e*w+f;this.n21=g*D+i*M+h*B;this.n22=g*z+i*x+h*F;this.n23=g*G+i*v+h*A;this.n24=g*H+i*E+h*w+j;this.n31=n*D+m*M+l*B;this.n32=n*z+m*x+l*F;this.n33=n*G+m*v+l*A;this.n34=n*H+m*E+l*w+o;this.n41=q*D+r*M+p*B;this.n42=q*z+r*x+p*F;this.n43=q*G+r*v+p*A;this.n44=q*H+r*E+p*w+k;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,e=this.n21,f=this.n22,
+g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*g*j*l-c*i*j*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*j*q+a*i*j*q+b*e*m*q-a*f*m*q-c*f*h*r+b*g*h*r+c*e*j*r-a*g*j*r-b*e*n*r+a*f*n*r},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),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g,j*i+d*f,e*i*i+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var j=c*g;
+c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j);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,e=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*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-j*l*r+j*m*p-i*o*p-h*m*k+i*l*k;b.n12=f*l*r-e*o*r-f*m*p+d*o*p+e*m*k-d*l*k;b.n13=e*j*r-f*h*r+f*i*p-d*j*p-e*i*k+d*h*k;b.n14=f*h*m-e*j*m-f*i*l+d*j*l+e*i*o-d*h*o;b.n21=j*l*q-h*o*q-j*n*p+g*o*p+h*n*k-g*l*k;b.n22=e*o*q-f*l*q+f*n*p-c*o*p-e*n*k+c*l*k;b.n23=f*h*q-e*j*q-f*g*p+c*j*p+e*g*k-c*h*k;
+b.n24=e*j*n-f*h*n+f*g*l-c*j*l-e*g*o+c*h*o;b.n31=i*o*q-j*m*q+j*n*r-g*o*r-i*n*k+g*m*k;b.n32=f*m*q-d*o*q-f*n*r+c*o*r+d*n*k-c*m*k;b.n33=e*j*q-f*i*q+f*g*r-c*j*r-d*g*k+c*i*k;b.n34=f*i*n-d*j*n-f*g*m+c*j*m+d*g*o-c*i*o;b.n41=h*m*q-i*l*q-h*n*r+g*l*r+i*n*p-g*m*p;b.n42=d*l*q-e*m*q+e*n*r-c*l*r-d*n*p+c*m*p;b.n43=e*i*q-d*h*q-e*g*r+c*h*r+d*g*p-c*i*p;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*l+c*i*l;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,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*n;c[8]=a*m;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-d;j=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+e)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
-this.visible=!0};
-THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
-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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
-this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}}};
-THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-d;j=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+e)/j);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=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
+!0;this._vector=new THREE.Vector3};
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
+b,c)}}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*e-i*d,n=h*d+i*c-f*e,l=h*e+f*d-g*c;c=-f*c-g*d-i*e;b.x=j*h+c*-f+n*-i-l*-g;b.y=n*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-n*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*e-i*d,n=h*d+i*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-i*e;b.x=j*h+c*-f+n*-i-m*-g;b.y=n*h+c*-g+m*-f-j*-i;b.z=m*h+c*-i+j*-g-n*-f;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.0010){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};
-THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};
-THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
-this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
-THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
+THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||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(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;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(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
+THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
 THREE.Sound=function(a,b,c,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)e=
 "audio/mpeg";else if(b.indexOf(".ogg")!==-1)e="audio/ogg";else b.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
 THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
 THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
-THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
+THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
 THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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(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.Sound)this.sounds.indexOf(a)===-1&&this.sounds.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 if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(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(v,t){return t.z-v.z}function b(v,t){var C=0,z=1,D=v.z+v.w,E=t.z+t.w,x=-v.z+v.w,u=-t.z+t.w;if(D>=0&&E>=0&&x>=0&&u>=0)return!0;else if(D<0&&E<0||x<0&&u<0)return!1;else{if(D<0)C=Math.max(C,D/(D-E));else E<0&&(z=Math.min(z,D/(D-E)));if(x<0)C=Math.max(C,x/(x-u));else u<0&&(z=Math.min(z,x/(x-u)));if(z<C)return!1;else{v.lerpSelf(t,C);t.lerpSelf(v,1-z);return!0}}}var c,d,e=[],f,g,i,h=[],j,n,l=[],m,o,p=[],q=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,B=new THREE.Matrix4,
-w=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4,I;this.projectObjects=function(v,t,C){t=[];var z,D,E;d=0;D=v.objects;v=0;for(z=D.length;v<z;v++){E=D[v];var x;if(!(x=!E.visible))if(x=E instanceof THREE.Mesh){a:{x=void 0;for(var u=E.matrixWorld,L=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),s=0;s<6;s++){x=w[s].x*u.n14+w[s].y*u.n24+w[s].z*u.n34+w[s].w;if(x<=L){x=
-!1;break a}}x=!0}x=!x}if(!x){c=e[d]=e[d]||new THREE.RenderableObject;q.copy(E.position);k.multiplyVector3(q);c.object=E;c.z=q.z;t.push(c);d++}}C&&t.sort(a);return t};this.projectScene=function(v,t,C){var z=[],D=t.near,E=t.far,x,u,L,s,H,N,y,P,Q,R,S,O,K,A,J,M;i=n=o=0;t.matrixAutoUpdate&&t.update();k.multiply(t.projectionMatrix,t.matrixWorldInverse);w[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);w[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);w[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
-k.n23,k.n44+k.n24);w[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);w[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);w[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(x=0;x<6;x++){N=w[x];N.divideScalar(Math.sqrt(N.x*N.x+N.y*N.y+N.z*N.z))}v.update(undefined,!1,t);N=this.projectObjects(v,t,!0);v=0;for(x=N.length;v<x;v++){y=N[v].object;if(y.visible){P=y.matrixWorld;S=y.matrixRotationWorld;Q=y.materials;R=y.overdraw;if(y instanceof THREE.Mesh){O=y.geometry;K=O.vertices;u=
-0;for(L=K.length;u<L;u++){A=K[u];A.positionWorld.copy(A.position);P.multiplyVector3(A.positionWorld);s=A.positionScreen;s.copy(A.positionWorld);k.multiplyVector4(s);s.x/=s.w;s.y/=s.w;A.__visible=s.z>D&&s.z<E}O=O.faces;u=0;for(L=O.length;u<L;u++){A=O[u];if(A instanceof THREE.Face3){s=K[A.a];H=K[A.b];J=K[A.c];if(s.__visible&&H.__visible&&J.__visible&&(y.doubleSided||y.flipSided!=(J.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(J.positionScreen.y-s.positionScreen.y)*(H.positionScreen.x-
-s.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(J.positionWorld);f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(J.positionScreen);f.normalWorld.copy(A.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(A.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);
-J=A.vertexNormals;I=f.vertexNormalsWorld;s=0;for(H=J.length;s<H;s++){M=I[s]=I[s]||new THREE.Vector3;M.copy(J[s]);S.multiplyVector3(M)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=A.materials;f.overdraw=R;if(y.geometry.uvs[u]){f.uvs[0]=y.geometry.uvs[u][0];f.uvs[1]=y.geometry.uvs[u][1];f.uvs[2]=y.geometry.uvs[u][2]}z.push(f);i++}}else if(A instanceof THREE.Face4){s=K[A.a];H=K[A.b];J=K[A.c];M=K[A.d];if(s.__visible&&H.__visible&&J.__visible&&M.__visible&&(y.doubleSided||y.flipSided!=((M.positionScreen.x-
-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(M.positionScreen.y-s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0||(H.positionScreen.x-J.positionScreen.x)*(M.positionScreen.y-J.positionScreen.y)-(H.positionScreen.y-J.positionScreen.y)*(M.positionScreen.x-J.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(M.positionWorld);f.v1.positionScreen.copy(s.positionScreen);
-f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(M.positionScreen);f.normalWorld.copy(A.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(A.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=A.materials;f.overdraw=R;if(y.geometry.uvs[u]){f.uvs[0]=y.geometry.uvs[u][0];f.uvs[1]=y.geometry.uvs[u][1];f.uvs[2]=y.geometry.uvs[u][3]}z.push(f);i++;g=
-h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(H.positionWorld);g.v2.positionWorld.copy(J.positionWorld);g.v3.positionWorld.copy(M.positionWorld);g.v1.positionScreen.copy(H.positionScreen);g.v2.positionScreen.copy(J.positionScreen);g.v3.positionScreen.copy(M.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=A.materials;g.overdraw=R;if(y.geometry.uvs[u]){g.uvs[0]=
-y.geometry.uvs[u][1];g.uvs[1]=y.geometry.uvs[u][2];g.uvs[2]=y.geometry.uvs[u][3]}z.push(g);i++}}}}else if(y instanceof THREE.Line){B.multiply(k,P);K=y.geometry.vertices;A=K[0];A.positionScreen.copy(A.position);B.multiplyVector4(A.positionScreen);u=1;for(L=K.length;u<L;u++){s=K[u];s.positionScreen.copy(s.position);B.multiplyVector4(s.positionScreen);H=K[u-1];F.copy(s.positionScreen);G.copy(H.positionScreen);if(b(F,G)){F.multiplyScalar(1/F.w);G.multiplyScalar(1/G.w);j=l[n]=l[n]||new THREE.RenderableLine;
-j.v1.positionScreen.copy(F);j.v2.positionScreen.copy(G);j.z=Math.max(F.z,G.z);j.materials=y.materials;z.push(j);n++}}}else if(y instanceof THREE.Particle){r.set(y.position.x,y.position.y,y.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){m=p[o]=p[o]||new THREE.RenderableParticle;m.x=r.x/r.w;m.y=r.y/r.w;m.z=r.z;m.rotation=y.rotation.z;m.scale.x=y.scale.x*Math.abs(m.x-(r.x+t.projectionMatrix.n11)/(r.w+t.projectionMatrix.n14));m.scale.y=y.scale.y*Math.abs(m.y-(r.y+t.projectionMatrix.n22)/
-(r.w+t.projectionMatrix.n24));m.materials=y.materials;z.push(m);o++}}}}C&&z.sort(a);return z};this.unprojectVector=function(v,t){var C=t.matrixWorld.clone();C.multiplySelf(THREE.Matrix4.makeInvert(t.projectionMatrix));C.multiplyVector3(v);return v}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;d=i;e=c/2;f=d/2};this.render=function(g,i){var h,j,n,l,m,o,p,q;a=b.projectScene(g,i);h=0;for(j=a.length;h<j;h++){m=a[h];if(m instanceof THREE.RenderableParticle){p=m.x*e+e;q=m.y*f+f;n=0;for(l=m.material.length;n<l;n++){o=m.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=p+"px";o.style.top=q+"px"}}}}}};
+THREE.Projector=function(){function a(x,v){return v.z-x.z}function b(x,v){var E=0,B=1,F=x.z+x.w,A=v.z+v.w,w=-x.z+x.w,t=-v.z+v.w;if(F>=0&&A>=0&&w>=0&&t>=0)return!0;else if(F<0&&A<0||w<0&&t<0)return!1;else{if(F<0)E=Math.max(E,F/(F-A));else A<0&&(B=Math.min(B,F/(F-A)));if(w<0)E=Math.max(E,w/(w-t));else t<0&&(B=Math.min(B,w/(w-t)));if(B<E)return!1;else{x.lerpSelf(v,E);v.lerpSelf(x,1-B);return!0}}}var c,d,e=[],f,g,i,h=[],j,n,m=[],l,o,q=[],r=new THREE.Vector4,p=new THREE.Vector4,k=new THREE.Matrix4,D=new THREE.Matrix4,
+z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],G=new THREE.Vector4,H=new THREE.Vector4,M;this.projectObjects=function(x,v,E){v=[];var B,F,A;d=0;F=x.objects;x=0;for(B=F.length;x<B;x++){A=F[x];var w;if(!(w=!A.visible))if(w=A instanceof THREE.Mesh){a:{w=void 0;for(var t=A.matrixWorld,N=-A.geometry.boundingSphere.radius*Math.max(A.scale.x,Math.max(A.scale.y,A.scale.z)),s=0;s<6;s++){w=z[s].x*t.n14+z[s].y*t.n24+z[s].z*t.n34+z[s].w;if(w<=N){w=
+!1;break a}}w=!0}w=!w}if(!w){c=e[d]=e[d]||new THREE.RenderableObject;r.copy(A.position);k.multiplyVector3(r);c.object=A;c.z=r.z;v.push(c);d++}}E&&v.sort(a);return v};this.projectScene=function(x,v,E){var B=[],F=v.near,A=v.far,w,t,N,s,C,L,u,P,Q,R,S,O,J,y,I,K;i=n=o=0;v.matrixAutoUpdate&&v.update();k.multiply(v.projectionMatrix,v.matrixWorldInverse);z[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);z[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);z[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
+k.n23,k.n44+k.n24);z[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);z[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);z[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(w=0;w<6;w++){L=z[w];L.divideScalar(Math.sqrt(L.x*L.x+L.y*L.y+L.z*L.z))}x.update(undefined,!1,v);L=this.projectObjects(x,v,!0);x=0;for(w=L.length;x<w;x++){u=L[x].object;if(u.visible){P=u.matrixWorld;S=u.matrixRotationWorld;Q=u.materials;R=u.overdraw;if(u instanceof THREE.Mesh){O=u.geometry;J=O.vertices;t=
+0;for(N=J.length;t<N;t++){y=J[t];y.positionWorld.copy(y.position);P.multiplyVector3(y.positionWorld);s=y.positionScreen;s.copy(y.positionWorld);k.multiplyVector4(s);s.x/=s.w;s.y/=s.w;y.__visible=s.z>F&&s.z<A}O=O.faces;t=0;for(N=O.length;t<N;t++){y=O[t];if(y instanceof THREE.Face3){s=J[y.a];C=J[y.b];I=J[y.c];if(s.__visible&&C.__visible&&I.__visible&&(u.doubleSided||u.flipSided!=(I.positionScreen.x-s.positionScreen.x)*(C.positionScreen.y-s.positionScreen.y)-(I.positionScreen.y-s.positionScreen.y)*(C.positionScreen.x-
+s.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(C.positionWorld);f.v3.positionWorld.copy(I.positionWorld);f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(C.positionScreen);f.v3.positionScreen.copy(I.positionScreen);f.normalWorld.copy(y.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(y.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);
+I=y.vertexNormals;M=f.vertexNormalsWorld;s=0;for(C=I.length;s<C;s++){K=M[s]=M[s]||new THREE.Vector3;K.copy(I[s]);S.multiplyVector3(K)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=y.materials;f.overdraw=R;if(u.geometry.uvs[t]){f.uvs[0]=u.geometry.uvs[t][0];f.uvs[1]=u.geometry.uvs[t][1];f.uvs[2]=u.geometry.uvs[t][2]}B.push(f);i++}}else if(y instanceof THREE.Face4){s=J[y.a];C=J[y.b];I=J[y.c];K=J[y.d];if(s.__visible&&C.__visible&&I.__visible&&K.__visible&&(u.doubleSided||u.flipSided!=((K.positionScreen.x-
+s.positionScreen.x)*(C.positionScreen.y-s.positionScreen.y)-(K.positionScreen.y-s.positionScreen.y)*(C.positionScreen.x-s.positionScreen.x)<0||(C.positionScreen.x-I.positionScreen.x)*(K.positionScreen.y-I.positionScreen.y)-(C.positionScreen.y-I.positionScreen.y)*(K.positionScreen.x-I.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(C.positionWorld);f.v3.positionWorld.copy(K.positionWorld);f.v1.positionScreen.copy(s.positionScreen);
+f.v2.positionScreen.copy(C.positionScreen);f.v3.positionScreen.copy(K.positionScreen);f.normalWorld.copy(y.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(y.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=y.materials;f.overdraw=R;if(u.geometry.uvs[t]){f.uvs[0]=u.geometry.uvs[t][0];f.uvs[1]=u.geometry.uvs[t][1];f.uvs[2]=u.geometry.uvs[t][3]}B.push(f);i++;g=
+h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(C.positionWorld);g.v2.positionWorld.copy(I.positionWorld);g.v3.positionWorld.copy(K.positionWorld);g.v1.positionScreen.copy(C.positionScreen);g.v2.positionScreen.copy(I.positionScreen);g.v3.positionScreen.copy(K.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=y.materials;g.overdraw=R;if(u.geometry.uvs[t]){g.uvs[0]=
+u.geometry.uvs[t][1];g.uvs[1]=u.geometry.uvs[t][2];g.uvs[2]=u.geometry.uvs[t][3]}B.push(g);i++}}}}else if(u instanceof THREE.Line){D.multiply(k,P);J=u.geometry.vertices;y=J[0];y.positionScreen.copy(y.position);D.multiplyVector4(y.positionScreen);t=1;for(N=J.length;t<N;t++){s=J[t];s.positionScreen.copy(s.position);D.multiplyVector4(s.positionScreen);C=J[t-1];G.copy(s.positionScreen);H.copy(C.positionScreen);if(b(G,H)){G.multiplyScalar(1/G.w);H.multiplyScalar(1/H.w);j=m[n]=m[n]||new THREE.RenderableLine;
+j.v1.positionScreen.copy(G);j.v2.positionScreen.copy(H);j.z=Math.max(G.z,H.z);j.materials=u.materials;B.push(j);n++}}}else if(u instanceof THREE.Particle){p.set(u.position.x,u.position.y,u.position.z,1);k.multiplyVector4(p);p.z/=p.w;if(p.z>0&&p.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=p.x/p.w;l.y=p.y/p.w;l.z=p.z;l.rotation=u.rotation.z;l.scale.x=u.scale.x*Math.abs(l.x-(p.x+v.projectionMatrix.n11)/(p.w+v.projectionMatrix.n14));l.scale.y=u.scale.y*Math.abs(l.y-(p.y+v.projectionMatrix.n22)/
+(p.w+v.projectionMatrix.n24));l.materials=u.materials;B.push(l);o++}}}}E&&B.sort(a);return B};this.unprojectVector=function(x,v){var E=v.matrixWorld.clone();E.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));E.multiplyVector3(x);return x}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;d=i;e=c/2;f=d/2};this.render=function(g,i){var h,j,n,m,l,o,q,r;a=b.projectScene(g,i);h=0;for(j=a.length;h<j;h++){l=a[h];if(l instanceof THREE.RenderableParticle){q=l.x*e+e;r=l.y*f+f;n=0;for(m=l.material.length;n<m;n++){o=l.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=q+"px";o.style.top=r+"px"}}}}}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};

+ 5 - 5
build/custom/ThreeExtras.js

@@ -1,13 +1,13 @@
-// ThreeExtras.js r34 - http://github.com/mrdoob/three.js
+// ThreeExtras.js r35 - http://github.com/mrdoob/three.js
 var GeometryUtils={merge:function(a,d){var b=d instanceof THREE.Mesh,f=a.vertices.length,h=b?d.geometry:d,c=a.vertices,e=h.vertices,g=a.faces,j=h.faces,m=a.uvs;h=h.uvs;b&&d.matrixAutoUpdate&&d.updateMatrix();for(var k=0,v=e.length;k<v;k++){var q=new THREE.Vertex(e[k].position.clone());b&&d.matrix.multiplyVector3(q.position);c.push(q)}k=0;for(v=j.length;k<v;k++){e=j[k];var n,p=e.vertexNormals;if(e instanceof THREE.Face3)n=new THREE.Face3(e.a+f,e.b+f,e.c+f);else e instanceof THREE.Face4&&(n=new THREE.Face4(e.a+
 f,e.b+f,e.c+f,e.d+f));n.centroid.copy(e.centroid);n.normal.copy(e.normal);b=0;for(c=p.length;b<c;b++){q=p[b];n.vertexNormals.push(q.clone())}n.materials=e.materials.slice();g.push(n)}k=0;for(v=h.length;k<v;k++){f=h[k];g=[];b=0;for(c=f.length;b<c;b++)g.push(new THREE.UV(f[b].u,f[b].v));m.push(g)}}},ImageUtils={loadTexture:function(a,d,b){var f=new Image,h=new THREE.Texture(f,d);f.onload=function(){h.needsUpdate=!0;b&&b(this)};f.src=a;return h},loadTextureCube:function(a,d,b){var f,h=[],c=new THREE.Texture(h,
 d);d=h.loadCount=0;for(f=a.length;d<f;++d){h[d]=new Image;h[d].onload=function(){h.loadCount+=1;if(h.loadCount==6)c.needsUpdate=!0;b&&b(this)};h[d].src=a[d]}return c}},SceneUtils={loadScene:function(a,d,b,f){a=new Worker(a);a.postMessage(0);a.onmessage=function(h){function c(){for(k in C.objects)if(!G.objects[k]){u=C.objects[k];if(l=G.geometries[u.geometry]){I=[];for(i=0;i<u.materials.length;i++)I[i]=G.materials[u.materials[i]];z=u.position;r=u.rotation;s=u.scale;object=new THREE.Mesh(l,I);object.position.set(z[0],
 z[1],z[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=u.visible;G.scene.addObject(object);G.objects[k]=object}}}function e(N){return function(M){G.geometries[N]=M;c();F-=1;g()}}function g(){f({total_models:K,total_textures:O,loaded_models:K-F,loaded_textures:O-J},G);F==0&&J==0&&b(G)}var j,m,k,v,q,n,p,u,z,w,x,l,D,A,I,C,E,F,J,K,O,G;C=h.data;E=new THREE.Loader;J=F=0;G={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
 fogs:{}};h=function(){J-=1;g()};for(q in C.cameras){w=C.cameras[q];if(w.type=="perspective")D=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){D=new THREE.Camera;D.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}z=w.position;w=w.target;D.position.set(z[0],z[1],z[2]);D.target.position.set(w[0],w[1],w[2]);G.cameras[q]=D}for(v in C.lights){q=C.lights[v];if(q.type=="directional"){z=q.direction;light=new THREE.DirectionalLight;light.position.set(z[0],
 z[1],z[2]);light.position.normalize()}else if(q.type=="point"){z=q.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}w=q.color;i=q.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);G.scene.addLight(light);G.lights[v]=light}for(n in C.fogs){v=C.fogs[n];if(v.type=="linear")A=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(A=new THREE.FogExp2(0,v.density));w=v.color;A.color.setRGB(w[0],w[1],w[2]);G.fogs[n]=A}if(G.cameras&&C.defaults.camera)G.currentCamera=G.cameras[C.defaults.camera];
-if(G.fogs&&C.defaults.fog)G.scene.fog=G.fogs[C.defaults.fog];w=C.defaults.bgcolor;G.bgColor=new THREE.Color;G.bgColor.setRGB(w[0],w[1],w[2]);G.bgColorAlpha=C.defaults.bgalpha;for(j in C.geometries){n=C.geometries[j];if(n.type=="bin_mesh"||n.type=="ascii_mesh")F+=1}K=F;for(j in C.geometries){n=C.geometries[j];if(n.type=="cube"){l=new Cube(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,null,n.flipped,n.sides);G.geometries[j]=l}else if(n.type=="plane"){l=new Plane(n.width,n.height,n.segmentsWidth,
-n.segmentsHeight);G.geometries[j]=l}else if(n.type=="sphere"){l=new Sphere(n.radius,n.segmentsWidth,n.segmentsHeight);G.geometries[j]=l}else if(n.type=="cylinder"){l=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);G.geometries[j]=l}else if(n.type=="torus"){l=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);G.geometries[j]=l}else if(n.type=="icosahedron"){l=new Icosahedron(n.subdivisions);G.geometries[j]=l}else if(n.type=="bin_mesh")E.loadBinary({model:n.url,callback:e(j)});
-else n.type=="ascii_mesh"&&E.loadAscii({model:n.url,callback:e(j)})}for(p in C.textures){j=C.textures[p];J+=j.url instanceof Array?j.url.length:1}O=J;for(p in C.textures){j=C.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)n=ImageUtils.loadTextureCube(j.url,j.mapping,h);else{n=ImageUtils.loadTexture(j.url,j.mapping,h);if(THREE[j.minFilter]!=undefined)n.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)n.magFilter=
+if(G.fogs&&C.defaults.fog)G.scene.fog=G.fogs[C.defaults.fog];w=C.defaults.bgcolor;G.bgColor=new THREE.Color;G.bgColor.setRGB(w[0],w[1],w[2]);G.bgColorAlpha=C.defaults.bgalpha;for(j in C.geometries){n=C.geometries[j];if(n.type=="bin_mesh"||n.type=="ascii_mesh")F+=1}K=F;for(j in C.geometries){n=C.geometries[j];if(n.type=="cube"){l=new Cube(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides);G.geometries[j]=l}else if(n.type=="plane"){l=new Plane(n.width,
+n.height,n.segmentsWidth,n.segmentsHeight);G.geometries[j]=l}else if(n.type=="sphere"){l=new Sphere(n.radius,n.segmentsWidth,n.segmentsHeight);G.geometries[j]=l}else if(n.type=="cylinder"){l=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);G.geometries[j]=l}else if(n.type=="torus"){l=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);G.geometries[j]=l}else if(n.type=="icosahedron"){l=new Icosahedron(n.subdivisions);G.geometries[j]=l}else if(n.type=="bin_mesh")E.loadBinary({model:n.url,
+callback:e(j)});else n.type=="ascii_mesh"&&E.loadAscii({model:n.url,callback:e(j)})}for(p in C.textures){j=C.textures[p];J+=j.url instanceof Array?j.url.length:1}O=J;for(p in C.textures){j=C.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)n=ImageUtils.loadTextureCube(j.url,j.mapping,h);else{n=ImageUtils.loadTexture(j.url,j.mapping,h);if(THREE[j.minFilter]!=undefined)n.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)n.magFilter=
 THREE[j.magFilter]}G.textures[p]=n}for(m in C.materials){p=C.materials[m];for(x in p.parameters)if(x=="envMap"||x=="map"||x=="lightMap")p.parameters[x]=G.textures[p.parameters[x]];else if(x=="shading")p.parameters[x]=p.parameters[x]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(x=="blending")p.parameters[x]=THREE[p.parameters[x]]?THREE[p.parameters[x]]:THREE.NormalBlending;else x=="combine"&&(p.parameters[x]=p.parameters[x]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);p=new THREE[p.type](p.parameters);
 G.materials[m]=p}c();d(G)}},addMesh:function(a,d,b,f,h,c,e,g,j,m){d=new THREE.Mesh(d,m);d.scale.x=d.scale.y=d.scale.z=b;d.position.x=f;d.position.y=h;d.position.z=c;d.rotation.x=e;d.rotation.y=g;d.rotation.z=j;a.addObject(d);return d},addPanoramaCubeWebGL:function(a,d,b){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:f.uniforms});d=new THREE.Mesh(new Cube(d,d,d,1,1,1,null,!0),b);a.addObject(d);
 return d},addPanoramaCube:function(a,d,b){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));d=new THREE.Mesh(new Cube(d,d,d,1,1,f,!0),new THREE.MeshFaceMaterial);
@@ -38,7 +38,7 @@ var Torus=function(a,d,b,f){this.radius=a||100;this.tube=d||40;this.segmentsR=b|
 var Icosahedron=function(a){function d(v,q,n){var p=Math.sqrt(v*v+q*q+n*n);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(v/p,q/p,n/p)))-1}function b(v,q,n,p){p.faces.push(new THREE.Face3(v,q,n))}function f(v,q){var n=h.vertices[v].position,p=h.vertices[q].position;return d((n.x+p.x)/2,(n.y+p.y)/2,(n.z+p.z)/2)}var h=this,c=new THREE.Geometry,e;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;d(-1,a,0);d(1,a,0);d(-1,-a,0);d(1,-a,0);d(0,-1,a);d(0,1,a);d(0,-1,-a);d(0,
 1,-a);d(a,0,-1);d(a,0,1);d(-a,0,-1);d(-a,0,1);b(0,11,5,c);b(0,5,1,c);b(0,1,7,c);b(0,7,10,c);b(0,10,11,c);b(1,5,9,c);b(5,11,4,c);b(11,10,2,c);b(10,7,6,c);b(7,1,8,c);b(3,9,4,c);b(3,4,2,c);b(3,2,6,c);b(3,6,8,c);b(3,8,9,c);b(4,9,5,c);b(2,4,11,c);b(6,2,10,c);b(8,6,7,c);b(9,8,1,c);for(a=0;a<this.subdivisions;a++){e=new THREE.Geometry;for(var g in c.faces){var j=f(c.faces[g].a,c.faces[g].b),m=f(c.faces[g].b,c.faces[g].c),k=f(c.faces[g].c,c.faces[g].a);b(c.faces[g].a,j,k,e);b(c.faces[g].b,m,j,e);b(c.faces[g].c,
 k,m,e);b(j,m,k,e)}c.faces=e.faces}h.faces=c.faces;delete c;delete e;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function LathedObject(a,d,b){THREE.Geometry.call(this);this.nsteps=d||12;this.latheAngle=b||2*Math.PI;d=this.latheAngle/this.nsteps;for(var f=[],h=[],c=[],e=[],g=0;g<a.length;g++){this.vertices.push(new THREE.Vertex(a[g]));h[g]=this.vertices.length-1;f[g]=new THREE.Vector3(a[g].x,a[g].y,a[g].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.001;m+=this.stepSize){for(g=0;g<f.length;g++)if(m<b){f[g]=j.multiplyVector3(f[g].clone());this.vertices.push(new THREE.Vertex(f[g]));
+function LathedObject(a,d,b){THREE.Geometry.call(this);this.nsteps=d||12;this.latheAngle=b||2*Math.PI;d=this.latheAngle/this.nsteps;for(var f=[],h=[],c=[],e=[],g=0;g<a.length;g++){this.vertices.push(new THREE.Vertex(a[g]));h[g]=this.vertices.length-1;f[g]=new THREE.Vector3(a[g].x,a[g].y,a[g].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.0010;m+=this.stepSize){for(g=0;g<f.length;g++)if(m<b){f[g]=j.multiplyVector3(f[g].clone());this.vertices.push(new THREE.Vertex(f[g]));
 c[g]=this.vertices.length-1}else c=e;m==0&&(e=h);for(g=0;g<h.length-1;g++){this.faces.push(new THREE.Face4(c[g],c[g+1],h[g+1],h[g]));this.uvs.push([new THREE.UV(m/b,g/a.length),new THREE.UV(m/b,(g+1)/a.length),new THREE.UV((m-d)/b,(g+1)/a.length),new THREE.UV((m-d)/b,g/a.length)])}h=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
 if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];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=

+ 69 - 71
build/custom/ThreeSVG.js

@@ -1,4 +1,4 @@
-// ThreeSVG.js r34 - http://github.com/mrdoob/three.js
+// ThreeSVG.js r35 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
 THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,g,i,h;if(c==0)d=e=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:d=h;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=h;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=h;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
@@ -8,48 +8,47 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(t,j,H,p){p=p.clone().subSelf(j);H=H.clone().subSelf(j);var y=t.clone().subSelf(j);t=p.dot(p);j=p.dot(H);p=p.dot(y);var C=H.dot(H);H=H.dot(y);y=1/(t*C-j*j);C=(C*p-j*H)*y;t=(t*H-j*p)*y;return C>0&&t>0&&C+t<1}var c,d,e,f,g,i,h,l,n,m,
-k,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();k=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(q[e.a].position.clone());g=h.multiplyVector3(q[e.b].position.clone());i=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;l=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=k.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(k.multiplyScalar(l));
-if(e instanceof THREE.Face3){if(b(m,f,g,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,i,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}}return s}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(u,j,J,q){q=q.clone().subSelf(j);J=J.clone().subSelf(j);var A=u.clone().subSelf(j);u=q.dot(q);j=q.dot(J);q=q.dot(A);var F=J.dot(J);J=J.dot(A);A=1/(u*F-j*j);F=(F*q-j*J)*A;u=(u*J-j*q)*A;return F>0&&u>0&&F+u<1}var c,d,e,f,g,i,h,l,n,m,
+k,o=a.geometry,r=o.vertices,v=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();k=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(r[e.a].position.clone());g=h.multiplyVector3(r[e.b].position.clone());i=h.multiplyVector3(r[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(r[e.d].position.clone()):null;l=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=k.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(k.multiplyScalar(l));
+if(e instanceof THREE.Face3){if(b(m,f,g,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};v.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,i,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};v.push(e)}}}return v}};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,l,n,m){i=!1;b=h;c=l;d=n;e=m;a()};this.addPoint=function(h,l){if(i){i=!1;b=h;c=l;d=h;e=l}else{b=b<h?b:h;c=c<l?c:l;d=d>h?d:h;e=e>l?e:l}a()};
 this.add3Points=function(h,l,n,m,k,o){if(i){i=!1;b=h<n?h<k?h:k:n<k?n:k;c=l<m?l<o?l:o:m<o?m:o;d=h>n?h>k?h:k:n>k?n:k;e=l>m?l>o?l:o:m>o?m:o}else{b=h<n?h<k?h<b?h:b:k<b?k:b:n<k?n<b?n:b:k<b?k:b;c=l<m?l<o?l<c?l:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=h>n?h>k?h>d?h:d:k>d?k:d:n>k?n>d?n:d:k>d?k:d;e=l>m?l>o?l>e?l:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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,e,f,g,i,h,l,n,m,k,o,q,s){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,q||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,q,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=q;this.n44=s;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.__tmpVec1,
-e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
-b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44,H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34;this.n11=c*
-H+d*L+e*E;this.n12=c*p+d*z+e*K;this.n13=c*y+d*v+e*J;this.n14=c*C+d*I+e*u+f;this.n21=g*H+i*L+h*E;this.n22=g*p+i*z+h*K;this.n23=g*y+i*v+h*J;this.n24=g*C+i*I+h*u+l;this.n31=n*H+m*L+k*E;this.n32=n*p+m*z+k*K;this.n33=n*y+m*v+k*J;this.n34=n*C+m*I+k*u+o;this.n41=q*H+s*L+t*E;this.n42=q*p+s*z+t*K;this.n43=q*y+s*v+t*J;this.n44=q*C+s*I+t*u+j;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,l=a.n23,n=a.n24,m=a.n31,k=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,j=a.n43;
-a=a.n44;var H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34,D=b.n41,S=b.n42,x=b.n43;b=b.n44;this.n11=d*H+e*L+f*E+g*D;this.n12=d*p+e*z+f*K+g*S;this.n13=d*y+e*v+f*J+g*x;this.n14=d*C+e*I+f*u+g*b;this.n21=i*H+h*L+l*E+n*D;this.n22=i*p+h*z+l*K+n*S;this.n23=i*y+h*v+l*J+n*x;this.n24=i*C+h*I+l*u+n*b;this.n31=m*H+k*L+o*E+q*D;this.n32=m*p+k*z+o*K+q*S;this.n33=m*y+k*v+o*J+q*x;this.n34=m*C+k*I+o*u+q*b;this.n41=s*H+t*L+j*E+a*D;this.n42=s*p+t*z+j*K+a*S;this.n43=s*
-y+t*v+j*J+a*x;this.n44=s*C+t*I+j*u+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){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,l=this.n31,n=this.n32,m=this.n33,k=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44,j=a.n11,H=a.n21,
-p=a.n31,y=a.n12,C=a.n22,L=a.n32,z=a.n13,v=a.n23,I=a.n33,E=a.n14,K=a.n24;a=a.n34;this.n11=b*j+c*H+d*p;this.n12=b*y+c*C+d*L;this.n13=b*z+c*v+d*I;this.n14=b*E+c*K+d*a+e;this.n21=f*j+g*H+i*p;this.n22=f*y+g*C+i*L;this.n23=f*z+g*v+i*I;this.n24=f*E+g*K+i*a+h;this.n31=l*j+n*H+m*p;this.n32=l*y+n*C+m*L;this.n33=l*z+n*v+m*I;this.n34=l*E+n*K+m*a+k;this.n41=o*j+q*H+s*p;this.n42=o*y+q*C+s*L;this.n43=o*z+q*v+s*I;this.n44=o*E+q*K+s*a+t;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,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,q=this.n43,s=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*l*q+a*i*l*q+b*e*
-m*q-a*f*m*q-c*f*h*s+b*g*h*s+c*e*l*s-a*g*l*s-b*e*n*s+a*f*n*s},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.flattenToArray(this.flat);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},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=
-b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l)},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}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
-THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*s-l*k*s+l*m*t-i*o*t-h*m*j+i*k*j;b.n12=f*k*s-e*o*s-f*m*t+d*o*t+e*m*j-d*k*j;b.n13=e*l*s-f*h*s+f*i*t-d*l*t-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*q-h*o*q-l*n*t+g*o*t+h*n*j-g*k*j;b.n22=e*o*q-f*k*q+f*n*t-c*o*t-e*n*j+c*k*j;b.n23=f*h*q-e*l*q-f*g*t+c*l*t+e*g*j-c*h*j;
-b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*q-l*m*q+l*n*s-g*o*s-i*n*j+g*m*j;b.n32=f*m*q-d*o*q-f*n*s+c*o*s+d*n*j-c*m*j;b.n33=e*l*q-f*i*q+f*g*s-c*l*s-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*q-i*k*q-h*n*s+g*k*s+i*n*t-g*m*t;b.n42=d*k*q-e*m*q+e*n*s-c*k*s-d*n*t+c*m*t;b.n43=e*i*q-d*h*q-e*g*s+c*h*s+d*g*t-c*i*t;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,r||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=r;this.n44=v;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,
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=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)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
+multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;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,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44,J=b.n11,q=b.n12,A=b.n13,F=b.n14,R=b.n21,B=b.n22,z=b.n23,L=b.n24,G=b.n31,N=b.n32,H=b.n33,s=b.n34;this.n11=c*J+d*R+e*G;this.n12=
+c*q+d*B+e*N;this.n13=c*A+d*z+e*H;this.n14=c*F+d*L+e*s+f;this.n21=g*J+i*R+h*G;this.n22=g*q+i*B+h*N;this.n23=g*A+i*z+h*H;this.n24=g*F+i*L+h*s+l;this.n31=n*J+m*R+k*G;this.n32=n*q+m*B+k*N;this.n33=n*A+m*z+k*H;this.n34=n*F+m*L+k*s+o;this.n41=r*J+v*R+u*G;this.n42=r*q+v*B+u*N;this.n43=r*A+v*z+u*H;this.n44=r*F+v*L+u*s+j;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,e=this.n21,f=this.n22,
+g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,r=this.n43,v=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*r-b*i*h*r-d*e*l*r+a*i*l*r+b*e*m*r-a*f*m*r-c*f*h*v+b*g*h*v+c*e*l*v-a*g*l*v-b*e*n*v+a*f*n*v},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),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+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},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;
+c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;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,e=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*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*v-l*k*v+l*m*u-i*o*u-h*m*j+i*k*j;b.n12=f*k*v-e*o*v-f*m*u+d*o*u+e*m*j-d*k*j;b.n13=e*l*v-f*h*v+f*i*u-d*l*u-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*r-h*o*r-l*n*u+g*o*u+h*n*j-g*k*j;b.n22=e*o*r-f*k*r+f*n*u-c*o*u-e*n*j+c*k*j;b.n23=f*h*r-e*l*r-f*g*u+c*l*u+e*g*j-c*h*j;
+b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*r-l*m*r+l*n*v-g*o*v-i*n*j+g*m*j;b.n32=f*m*r-d*o*r-f*n*v+c*o*v+d*n*j-c*m*j;b.n33=e*l*r-f*i*r+f*g*v-c*l*v-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*r-i*k*r-h*n*v+g*k*v+i*n*u-g*m*u;b.n42=d*k*r-e*m*r+e*n*v-c*k*v-d*n*u+c*m*u;b.n43=e*i*r-d*h*r-e*g*v+c*h*v+d*g*u-c*i*u;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;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,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*l;c[7]=a*n;c[8]=a*m;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,l;g=new THREE.Matrix4;i=b-a;h=c-d;l=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/l;g.n34=-((f+e)/l);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
-this.visible=!0};
-THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
-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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
-this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}}};
-THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,l;g=new THREE.Matrix4;i=b-a;h=c-d;l=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/l;g.n34=-((f+e)/l);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=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
+!0;this._vector=new THREE.Vector3};
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);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))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,
+b,c)}}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*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);if(a==0)this.w=this.z=this.y=this.x=0;else{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,e=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,h=this.w,l=h*c+g*e-i*d,n=h*d+i*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-i*e;b.x=l*h+c*-f+n*-i-m*-g;b.y=n*h+c*-g+m*-f-l*-i;b.z=m*h+c*-i+l*-g-n*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.0010){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);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};
 THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={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.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -57,19 +56,18 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,i=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)i.addSelf(f.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];i.sub(g.position,
 c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||i.normalize();f.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){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++){c=this.faces[a];if(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];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(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];if(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])}else if(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(u,D,S,x,N,F,A){f=u.vertices[D].position;g=u.vertices[S].position;i=u.vertices[x].position;h=e[N];l=e[F];n=e[A];m=g.x-f.x;k=i.x-f.x;o=g.y-f.y;q=i.y-f.y;
-s=g.z-f.z;t=i.z-f.z;j=l.u-h.u;H=n.u-h.u;p=l.v-h.v;y=n.v-h.v;C=1/(j*y-H*p);v.set((y*m-p*k)*C,(y*o-p*q)*C,(y*s-p*t)*C);I.set((j*k-H*m)*C,(j*q-H*o)*C,(j*t-H*s)*C);L[D].addSelf(v);L[S].addSelf(v);L[x].addSelf(v);z[D].addSelf(I);z[S].addSelf(I);z[x].addSelf(I)}var b,c,d,e,f,g,i,h,l,n,m,k,o,q,s,t,j,H,p,y,C,L=[],z=[],v=new THREE.Vector3,I=new THREE.Vector3,E=new THREE.Vector3,K=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){L[b]=new THREE.Vector3;z[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(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])}else if(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(s,C,S,y,K,D,w){f=s.vertices[C].position;g=s.vertices[S].position;i=s.vertices[y].position;h=e[K];l=e[D];n=e[w];m=g.x-f.x;k=i.x-f.x;o=g.y-f.y;r=i.y-f.y;
+v=g.z-f.z;u=i.z-f.z;j=l.u-h.u;J=n.u-h.u;q=l.v-h.v;A=n.v-h.v;F=1/(j*A-J*q);z.set((A*m-q*k)*F,(A*o-q*r)*F,(A*v-q*u)*F);L.set((j*k-J*m)*F,(j*r-J*o)*F,(j*u-J*v)*F);R[C].addSelf(z);R[S].addSelf(z);R[y].addSelf(z);B[C].addSelf(L);B[S].addSelf(L);B[y].addSelf(L)}var b,c,d,e,f,g,i,h,l,n,m,k,o,r,v,u,j,J,q,A,F,R=[],B=[],z=new THREE.Vector3,L=new THREE.Vector3,G=new THREE.Vector3,N=new THREE.Vector3,H=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){R[b]=new THREE.Vector3;B[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){J.copy(this.vertices[b].normal);d=L[b];E.copy(d);E.subSelf(J.multiplyScalar(J.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(z[b]);d=d<0?-1:1;this.vertices[b].tangent.set(E.x,E.y,E.z,d)}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],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){H.copy(this.vertices[b].normal);d=R[b];G.copy(d);G.subSelf(H.multiplyScalar(H.dot(d))).normalize();N.cross(this.vertices[b].normal,d);d=N.dot(B[b]);d=d<0?-1:1;this.vertices[b].tangent.set(G.x,G.y,G.z,d)}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=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
-THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
-this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
-THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
-THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
+THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||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(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
+THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
 THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
@@ -91,44 +89,44 @@ undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexCo
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;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(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
+THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++){a=this.children[d];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
 THREE.Sound=function(a,b,c,d){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=d!==undefined?d:!0;this.sources=a instanceof Array?a:[a];var e;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)e=
 "audio/mpeg";else if(b.indexOf(".ogg")!==-1)e="audio/ogg";else b.indexOf(".wav")!==-1&&(e="audio/wav");if(this.domElement.canPlayType(e)){e=document.createElement("source");e.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(e);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
 THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
 THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
-THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
+THREE.Sound.prototype.update=function(a,b,c){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.matrixWorld,b,c)};
 THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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(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.Sound)this.sounds.indexOf(a)===-1&&this.sounds.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 if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(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(z,v){return v.z-z.z}function b(z,v){var I=0,E=1,K=z.z+z.w,J=v.z+v.w,u=-z.z+z.w,D=-v.z+v.w;if(K>=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(E<I)return!1;else{z.lerpSelf(v,I);v.lerpSelf(z,1-E);return!0}}}var c,d,e=[],f,g,i,h=[],l,n,m=[],k,o,q=[],s=new THREE.Vector4,t=new THREE.Vector4,j=new THREE.Matrix4,H=new THREE.Matrix4,
-p=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],y=new THREE.Vector4,C=new THREE.Vector4,L;this.projectObjects=function(z,v,I){v=[];var E,K,J;d=0;K=z.objects;z=0;for(E=K.length;z<E;z++){J=K[z];var u;if(!(u=!J.visible))if(u=J instanceof THREE.Mesh){a:{u=void 0;for(var D=J.matrixWorld,S=-J.geometry.boundingSphere.radius*Math.max(J.scale.x,Math.max(J.scale.y,J.scale.z)),x=0;x<6;x++){u=p[x].x*D.n14+p[x].y*D.n24+p[x].z*D.n34+p[x].w;if(u<=S){u=
-!1;break a}}u=!0}u=!u}if(!u){c=e[d]=e[d]||new THREE.RenderableObject;s.copy(J.position);j.multiplyVector3(s);c.object=J;c.z=s.z;v.push(c);d++}}I&&v.sort(a);return v};this.projectScene=function(z,v,I){var E=[],K=v.near,J=v.far,u,D,S,x,N,F,A,O,Q,B,w,M,P,r,G,R;i=n=o=0;v.matrixAutoUpdate&&v.update();j.multiply(v.projectionMatrix,v.matrixWorldInverse);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
-j.n23,j.n44+j.n24);p[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);p[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);p[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(u=0;u<6;u++){F=p[u];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}z.update(undefined,!1,v);F=this.projectObjects(z,v,!0);z=0;for(u=F.length;z<u;z++){A=F[z].object;if(A.visible){O=A.matrixWorld;w=A.matrixRotationWorld;Q=A.materials;B=A.overdraw;if(A instanceof THREE.Mesh){M=A.geometry;P=M.vertices;D=
-0;for(S=P.length;D<S;D++){r=P[D];r.positionWorld.copy(r.position);O.multiplyVector3(r.positionWorld);x=r.positionScreen;x.copy(r.positionWorld);j.multiplyVector4(x);x.x/=x.w;x.y/=x.w;r.__visible=x.z>K&&x.z<J}M=M.faces;D=0;for(S=M.length;D<S;D++){r=M[D];if(r instanceof THREE.Face3){x=P[r.a];N=P[r.b];G=P[r.c];if(x.__visible&&N.__visible&&G.__visible&&(A.doubleSided||A.flipSided!=(G.positionScreen.x-x.positionScreen.x)*(N.positionScreen.y-x.positionScreen.y)-(G.positionScreen.y-x.positionScreen.y)*(N.positionScreen.x-
-x.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(N.positionWorld);f.v3.positionWorld.copy(G.positionWorld);f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(G.positionScreen);f.normalWorld.copy(r.normal);w.multiplyVector3(f.normalWorld);f.centroidWorld.copy(r.centroid);O.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);
-G=r.vertexNormals;L=f.vertexNormalsWorld;x=0;for(N=G.length;x<N;x++){R=L[x]=L[x]||new THREE.Vector3;R.copy(G[x]);w.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=r.materials;f.overdraw=B;if(A.geometry.uvs[D]){f.uvs[0]=A.geometry.uvs[D][0];f.uvs[1]=A.geometry.uvs[D][1];f.uvs[2]=A.geometry.uvs[D][2]}E.push(f);i++}}else if(r instanceof THREE.Face4){x=P[r.a];N=P[r.b];G=P[r.c];R=P[r.d];if(x.__visible&&N.__visible&&G.__visible&&R.__visible&&(A.doubleSided||A.flipSided!=((R.positionScreen.x-
-x.positionScreen.x)*(N.positionScreen.y-x.positionScreen.y)-(R.positionScreen.y-x.positionScreen.y)*(N.positionScreen.x-x.positionScreen.x)<0||(N.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-(N.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(N.positionWorld);f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(x.positionScreen);
-f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(r.normal);w.multiplyVector3(f.normalWorld);f.centroidWorld.copy(r.centroid);O.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=r.materials;f.overdraw=B;if(A.geometry.uvs[D]){f.uvs[0]=A.geometry.uvs[D][0];f.uvs[1]=A.geometry.uvs[D][1];f.uvs[2]=A.geometry.uvs[D][3]}E.push(f);i++;g=
-h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(G.positionWorld);g.v3.positionWorld.copy(R.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(G.positionScreen);g.v3.positionScreen.copy(R.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=r.materials;g.overdraw=B;if(A.geometry.uvs[D]){g.uvs[0]=
-A.geometry.uvs[D][1];g.uvs[1]=A.geometry.uvs[D][2];g.uvs[2]=A.geometry.uvs[D][3]}E.push(g);i++}}}}else if(A instanceof THREE.Line){H.multiply(j,O);P=A.geometry.vertices;r=P[0];r.positionScreen.copy(r.position);H.multiplyVector4(r.positionScreen);D=1;for(S=P.length;D<S;D++){x=P[D];x.positionScreen.copy(x.position);H.multiplyVector4(x.positionScreen);N=P[D-1];y.copy(x.positionScreen);C.copy(N.positionScreen);if(b(y,C)){y.multiplyScalar(1/y.w);C.multiplyScalar(1/C.w);l=m[n]=m[n]||new THREE.RenderableLine;
-l.v1.positionScreen.copy(y);l.v2.positionScreen.copy(C);l.z=Math.max(y.z,C.z);l.materials=A.materials;E.push(l);n++}}}else if(A instanceof THREE.Particle){t.set(A.position.x,A.position.y,A.position.z,1);j.multiplyVector4(t);t.z/=t.w;if(t.z>0&&t.z<1){k=q[o]=q[o]||new THREE.RenderableParticle;k.x=t.x/t.w;k.y=t.y/t.w;k.z=t.z;k.rotation=A.rotation.z;k.scale.x=A.scale.x*Math.abs(k.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));k.scale.y=A.scale.y*Math.abs(k.y-(t.y+v.projectionMatrix.n22)/
-(t.w+v.projectionMatrix.n24));k.materials=A.materials;E.push(k);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=v.matrixWorld.clone();I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}};
-THREE.SVGRenderer=function(){function a(F,A,O){var Q,B,w,M;Q=0;for(B=F.lights.length;Q<B;Q++){w=F.lights[Q];if(w instanceof THREE.DirectionalLight){M=A.normalWorld.dot(w.position)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}else if(w instanceof THREE.PointLight){I.sub(w.position,A.centroidWorld);I.normalize();M=A.normalWorld.dot(I)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}}}function b(F,A,O,Q,B,w){u=d(D++);u.setAttribute("d","M "+F.positionScreen.x+
-" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(w,Q,y);p.r=B.color.r*y.r;p.g=B.color.g*y.g;p.b=B.color.b*y.b;p.updateStyleString()}else p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){v=1-B.__2near/(B.__farPlusNear-Q.z*B.__farMinusNear);
-p.setRGB(v,v,v)}else B instanceof THREE.MeshNormalMaterial&&p.setRGB(e(Q.normalWorld.x),e(Q.normalWorld.y),e(Q.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+B.wireframeLinewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframeLinecap+"; stroke-linejoin: "+B.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+B.opacity);i.appendChild(u)}function c(F,A,O,Q,B,w,M){u=d(D++);u.setAttribute("d",
-"M "+F.positionScreen.x+" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(M,B,y);p.r=w.color.r*y.r;p.g=w.color.g*y.g;p.b=w.color.b*y.b;p.updateStyleString()}else p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){v=
-1-w.__2near/(w.__farPlusNear-B.z*w.__farMinusNear);p.setRGB(v,v,v)}else w instanceof THREE.MeshNormalMaterial&&p.setRGB(e(B.normalWorld.x),e(B.normalWorld.y),e(B.normalWorld.z));w.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+w.opacity);i.appendChild(u)}
-function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,l,n,m,k,o,q,s,t=new THREE.Rectangle,j=new THREE.Rectangle,H=!1,p=new THREE.Color(16777215),y=new THREE.Color(16777215),C=new THREE.Color(0),L=new THREE.Color(0),z=new THREE.Color(0),
-v,I=new THREE.Vector3,E=[],K=[],J=[],u,D,S,x,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":N=1;break;case "low":N=0}};this.setSize=function(F,A){h=F;l=A;n=h/2;m=l/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+l);i.setAttribute("width",h);i.setAttribute("height",l);t.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,A){var O,Q,B,w,M,P,r,G;this.autoClear&&
-this.clear();f=g.projectScene(F,A,this.sortElements);x=S=D=0;if(H=F.lights.length>0){r=F.lights;C.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);O=0;for(Q=r.length;O<Q;O++){B=r[O];w=B.color;if(B instanceof THREE.AmbientLight){C.r+=w.r;C.g+=w.g;C.b+=w.b}else if(B instanceof THREE.DirectionalLight){L.r+=w.r;L.g+=w.g;L.b+=w.b}else if(B instanceof THREE.PointLight){z.r+=w.r;z.g+=w.g;z.b+=w.b}}}O=0;for(Q=f.length;O<Q;O++){r=f[O];j.empty();if(r instanceof THREE.RenderableParticle){k=r;k.x*=n;k.y*=-m;B=0;
-for(w=r.materials.length;B<w;B++)if(G=r.materials[B]){M=k;P=r;var R=S++;if(K[R]==null){K[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");N==0&&K[R].setAttribute("shape-rendering","crispEdges")}u=K[R];u.setAttribute("cx",M.x);u.setAttribute("cy",M.y);u.setAttribute("r",P.scale.x*n);if(G instanceof THREE.ParticleCircleMaterial){if(H){y.r=C.r+L.r+z.r;y.g=C.g+L.g+z.g;y.b=C.b+L.b+z.b;p.r=G.color.r*y.r;p.g=G.color.g*y.g;p.b=G.color.b*y.b;p.updateStyleString()}else p=G.color;u.setAttribute("style",
-"fill: "+p.__styleString)}i.appendChild(u)}}else if(r instanceof THREE.RenderableLine){k=r.v1;o=r.v2;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.materials.length;B<w;)if(G=r.materials[B++]){M=k;P=o;R=x++;if(J[R]==null){J[R]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&J[R].setAttribute("shape-rendering",
-"crispEdges")}u=J[R];u.setAttribute("x1",M.positionScreen.x);u.setAttribute("y1",M.positionScreen.y);u.setAttribute("x2",P.positionScreen.x);u.setAttribute("y2",P.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){p.__styleString=G.color.__styleString;u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);i.appendChild(u)}}}}else if(r instanceof THREE.RenderableFace3){k=
-r.v1;o=r.v2;q=r.v3;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&b(k,o,q,r,
-G,F)}else G&&b(k,o,q,r,G,F)}}}else if(r instanceof THREE.RenderableFace4){k=r.v1;o=r.v2;q=r.v3;s=r.v4;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;s.positionScreen.x*=n;s.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);j.addPoint(s.positionScreen.x,s.positionScreen.y);if(t.instersects(j)){B=
-0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&c(k,o,q,s,r,G,F)}else G&&c(k,o,q,s,r,G,F)}}}}}};
+THREE.Projector=function(){function a(B,z){return z.z-B.z}function b(B,z){var L=0,G=1,N=B.z+B.w,H=z.z+z.w,s=-B.z+B.w,C=-z.z+z.w;if(N>=0&&H>=0&&s>=0&&C>=0)return!0;else if(N<0&&H<0||s<0&&C<0)return!1;else{if(N<0)L=Math.max(L,N/(N-H));else H<0&&(G=Math.min(G,N/(N-H)));if(s<0)L=Math.max(L,s/(s-C));else C<0&&(G=Math.min(G,s/(s-C)));if(G<L)return!1;else{B.lerpSelf(z,L);z.lerpSelf(B,1-G);return!0}}}var c,d,e=[],f,g,i,h=[],l,n,m=[],k,o,r=[],v=new THREE.Vector4,u=new THREE.Vector4,j=new THREE.Matrix4,J=new THREE.Matrix4,
+q=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],A=new THREE.Vector4,F=new THREE.Vector4,R;this.projectObjects=function(B,z,L){z=[];var G,N,H;d=0;N=B.objects;B=0;for(G=N.length;B<G;B++){H=N[B];var s;if(!(s=!H.visible))if(s=H instanceof THREE.Mesh){a:{s=void 0;for(var C=H.matrixWorld,S=-H.geometry.boundingSphere.radius*Math.max(H.scale.x,Math.max(H.scale.y,H.scale.z)),y=0;y<6;y++){s=q[y].x*C.n14+q[y].y*C.n24+q[y].z*C.n34+q[y].w;if(s<=S){s=
+!1;break a}}s=!0}s=!s}if(!s){c=e[d]=e[d]||new THREE.RenderableObject;v.copy(H.position);j.multiplyVector3(v);c.object=H;c.z=v.z;z.push(c);d++}}L&&z.sort(a);return z};this.projectScene=function(B,z,L){var G=[],N=z.near,H=z.far,s,C,S,y,K,D,w,M,P,x,t,I,O,p,E,Q;i=n=o=0;z.matrixAutoUpdate&&z.update();j.multiply(z.projectionMatrix,z.matrixWorldInverse);q[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);q[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);q[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
+j.n23,j.n44+j.n24);q[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);q[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);q[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(s=0;s<6;s++){D=q[s];D.divideScalar(Math.sqrt(D.x*D.x+D.y*D.y+D.z*D.z))}B.update(undefined,!1,z);D=this.projectObjects(B,z,!0);B=0;for(s=D.length;B<s;B++){w=D[B].object;if(w.visible){M=w.matrixWorld;t=w.matrixRotationWorld;P=w.materials;x=w.overdraw;if(w instanceof THREE.Mesh){I=w.geometry;O=I.vertices;C=
+0;for(S=O.length;C<S;C++){p=O[C];p.positionWorld.copy(p.position);M.multiplyVector3(p.positionWorld);y=p.positionScreen;y.copy(p.positionWorld);j.multiplyVector4(y);y.x/=y.w;y.y/=y.w;p.__visible=y.z>N&&y.z<H}I=I.faces;C=0;for(S=I.length;C<S;C++){p=I[C];if(p instanceof THREE.Face3){y=O[p.a];K=O[p.b];E=O[p.c];if(y.__visible&&K.__visible&&E.__visible&&(w.doubleSided||w.flipSided!=(E.positionScreen.x-y.positionScreen.x)*(K.positionScreen.y-y.positionScreen.y)-(E.positionScreen.y-y.positionScreen.y)*(K.positionScreen.x-
+y.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(y.positionWorld);f.v2.positionWorld.copy(K.positionWorld);f.v3.positionWorld.copy(E.positionWorld);f.v1.positionScreen.copy(y.positionScreen);f.v2.positionScreen.copy(K.positionScreen);f.v3.positionScreen.copy(E.positionScreen);f.normalWorld.copy(p.normal);t.multiplyVector3(f.normalWorld);f.centroidWorld.copy(p.centroid);M.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);
+E=p.vertexNormals;R=f.vertexNormalsWorld;y=0;for(K=E.length;y<K;y++){Q=R[y]=R[y]||new THREE.Vector3;Q.copy(E[y]);t.multiplyVector3(Q)}f.z=f.centroidScreen.z;f.meshMaterials=P;f.faceMaterials=p.materials;f.overdraw=x;if(w.geometry.uvs[C]){f.uvs[0]=w.geometry.uvs[C][0];f.uvs[1]=w.geometry.uvs[C][1];f.uvs[2]=w.geometry.uvs[C][2]}G.push(f);i++}}else if(p instanceof THREE.Face4){y=O[p.a];K=O[p.b];E=O[p.c];Q=O[p.d];if(y.__visible&&K.__visible&&E.__visible&&Q.__visible&&(w.doubleSided||w.flipSided!=((Q.positionScreen.x-
+y.positionScreen.x)*(K.positionScreen.y-y.positionScreen.y)-(Q.positionScreen.y-y.positionScreen.y)*(K.positionScreen.x-y.positionScreen.x)<0||(K.positionScreen.x-E.positionScreen.x)*(Q.positionScreen.y-E.positionScreen.y)-(K.positionScreen.y-E.positionScreen.y)*(Q.positionScreen.x-E.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(y.positionWorld);f.v2.positionWorld.copy(K.positionWorld);f.v3.positionWorld.copy(Q.positionWorld);f.v1.positionScreen.copy(y.positionScreen);
+f.v2.positionScreen.copy(K.positionScreen);f.v3.positionScreen.copy(Q.positionScreen);f.normalWorld.copy(p.normal);t.multiplyVector3(f.normalWorld);f.centroidWorld.copy(p.centroid);M.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=P;f.faceMaterials=p.materials;f.overdraw=x;if(w.geometry.uvs[C]){f.uvs[0]=w.geometry.uvs[C][0];f.uvs[1]=w.geometry.uvs[C][1];f.uvs[2]=w.geometry.uvs[C][3]}G.push(f);i++;g=
+h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(K.positionWorld);g.v2.positionWorld.copy(E.positionWorld);g.v3.positionWorld.copy(Q.positionWorld);g.v1.positionScreen.copy(K.positionScreen);g.v2.positionScreen.copy(E.positionScreen);g.v3.positionScreen.copy(Q.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=P;g.faceMaterials=p.materials;g.overdraw=x;if(w.geometry.uvs[C]){g.uvs[0]=
+w.geometry.uvs[C][1];g.uvs[1]=w.geometry.uvs[C][2];g.uvs[2]=w.geometry.uvs[C][3]}G.push(g);i++}}}}else if(w instanceof THREE.Line){J.multiply(j,M);O=w.geometry.vertices;p=O[0];p.positionScreen.copy(p.position);J.multiplyVector4(p.positionScreen);C=1;for(S=O.length;C<S;C++){y=O[C];y.positionScreen.copy(y.position);J.multiplyVector4(y.positionScreen);K=O[C-1];A.copy(y.positionScreen);F.copy(K.positionScreen);if(b(A,F)){A.multiplyScalar(1/A.w);F.multiplyScalar(1/F.w);l=m[n]=m[n]||new THREE.RenderableLine;
+l.v1.positionScreen.copy(A);l.v2.positionScreen.copy(F);l.z=Math.max(A.z,F.z);l.materials=w.materials;G.push(l);n++}}}else if(w instanceof THREE.Particle){u.set(w.position.x,w.position.y,w.position.z,1);j.multiplyVector4(u);u.z/=u.w;if(u.z>0&&u.z<1){k=r[o]=r[o]||new THREE.RenderableParticle;k.x=u.x/u.w;k.y=u.y/u.w;k.z=u.z;k.rotation=w.rotation.z;k.scale.x=w.scale.x*Math.abs(k.x-(u.x+z.projectionMatrix.n11)/(u.w+z.projectionMatrix.n14));k.scale.y=w.scale.y*Math.abs(k.y-(u.y+z.projectionMatrix.n22)/
+(u.w+z.projectionMatrix.n24));k.materials=w.materials;G.push(k);o++}}}}L&&G.sort(a);return G};this.unprojectVector=function(B,z){var L=z.matrixWorld.clone();L.multiplySelf(THREE.Matrix4.makeInvert(z.projectionMatrix));L.multiplyVector3(B);return B}};
+THREE.SVGRenderer=function(){function a(D,w,M){var P,x,t,I;P=0;for(x=D.lights.length;P<x;P++){t=D.lights[P];if(t instanceof THREE.DirectionalLight){I=w.normalWorld.dot(t.position)*t.intensity;if(I>0){M.r+=t.color.r*I;M.g+=t.color.g*I;M.b+=t.color.b*I}}else if(t instanceof THREE.PointLight){L.sub(t.position,w.centroidWorld);L.normalize();I=w.normalWorld.dot(L)*t.intensity;if(I>0){M.r+=t.color.r*I;M.g+=t.color.g*I;M.b+=t.color.b*I}}}}function b(D,w,M,P,x,t){s=d(C++);s.setAttribute("d","M "+D.positionScreen.x+
+" "+D.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)q.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(J){A.r=F.r;A.g=F.g;A.b=F.b;a(t,P,A);q.r=x.color.r*A.r;q.g=x.color.g*A.g;q.b=x.color.b*A.b;q.updateStyleString()}else q.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){z=1-x.__2near/(x.__farPlusNear-P.z*x.__farMinusNear);
+q.setRGB(z,z,z)}else x instanceof THREE.MeshNormalMaterial&&q.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));x.wireframe?s.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):s.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+x.opacity);i.appendChild(s)}function c(D,w,M,P,x,t,I){s=d(C++);s.setAttribute("d",
+"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)q.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(J){A.r=F.r;A.g=F.g;A.b=F.b;a(I,x,A);q.r=t.color.r*A.r;q.g=t.color.g*A.g;q.b=t.color.b*A.b;q.updateStyleString()}else q.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){z=
+1-t.__2near/(t.__farPlusNear-x.z*t.__farMinusNear);q.setRGB(z,z,z)}else t instanceof THREE.MeshNormalMaterial&&q.setRGB(e(x.normalWorld.x),e(x.normalWorld.y),e(x.normalWorld.z));t.wireframe?s.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):s.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+t.opacity);i.appendChild(s)}
+function d(D){if(G[D]==null){G[D]=document.createElementNS("http://www.w3.org/2000/svg","path");K==0&&G[D].setAttribute("shape-rendering","crispEdges")}return G[D]}function e(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,l,n,m,k,o,r,v,u=new THREE.Rectangle,j=new THREE.Rectangle,J=!1,q=new THREE.Color(16777215),A=new THREE.Color(16777215),F=new THREE.Color(0),R=new THREE.Color(0),B=new THREE.Color(0),
+z,L=new THREE.Vector3,G=[],N=[],H=[],s,C,S,y,K=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(D){switch(D){case "high":K=1;break;case "low":K=0}};this.setSize=function(D,w){h=D;l=w;n=h/2;m=l/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+l);i.setAttribute("width",h);i.setAttribute("height",l);u.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(D,w){var M,P,x,t,I,O,p,E;this.autoClear&&
+this.clear();f=g.projectScene(D,w,this.sortElements);y=S=C=0;if(J=D.lights.length>0){p=D.lights;F.setRGB(0,0,0);R.setRGB(0,0,0);B.setRGB(0,0,0);M=0;for(P=p.length;M<P;M++){x=p[M];t=x.color;if(x instanceof THREE.AmbientLight){F.r+=t.r;F.g+=t.g;F.b+=t.b}else if(x instanceof THREE.DirectionalLight){R.r+=t.r;R.g+=t.g;R.b+=t.b}else if(x instanceof THREE.PointLight){B.r+=t.r;B.g+=t.g;B.b+=t.b}}}M=0;for(P=f.length;M<P;M++){p=f[M];j.empty();if(p instanceof THREE.RenderableParticle){k=p;k.x*=n;k.y*=-m;x=0;
+for(t=p.materials.length;x<t;x++)if(E=p.materials[x]){I=k;O=p;var Q=S++;if(N[Q]==null){N[Q]=document.createElementNS("http://www.w3.org/2000/svg","circle");K==0&&N[Q].setAttribute("shape-rendering","crispEdges")}s=N[Q];s.setAttribute("cx",I.x);s.setAttribute("cy",I.y);s.setAttribute("r",O.scale.x*n);if(E instanceof THREE.ParticleCircleMaterial){if(J){A.r=F.r+R.r+B.r;A.g=F.g+R.g+B.g;A.b=F.b+R.b+B.b;q.r=E.color.r*A.r;q.g=E.color.g*A.g;q.b=E.color.b*A.b;q.updateStyleString()}else q=E.color;s.setAttribute("style",
+"fill: "+q.__styleString)}i.appendChild(s)}}else if(p instanceof THREE.RenderableLine){k=p.v1;o=p.v2;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(u.instersects(j)){x=0;for(t=p.materials.length;x<t;)if(E=p.materials[x++]){I=k;O=o;Q=y++;if(H[Q]==null){H[Q]=document.createElementNS("http://www.w3.org/2000/svg","line");K==0&&H[Q].setAttribute("shape-rendering",
+"crispEdges")}s=H[Q];s.setAttribute("x1",I.positionScreen.x);s.setAttribute("y1",I.positionScreen.y);s.setAttribute("x2",O.positionScreen.x);s.setAttribute("y2",O.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){q.__styleString=E.color.__styleString;s.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.linecap+"; stroke-linejoin: "+E.linejoin);i.appendChild(s)}}}}else if(p instanceof THREE.RenderableFace3){k=
+p.v1;o=p.v2;r=p.v3;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;r.positionScreen.x*=n;r.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(r.positionScreen.x,r.positionScreen.y);if(u.instersects(j)){x=0;for(t=p.meshMaterials.length;x<t;){E=p.meshMaterials[x++];if(E instanceof THREE.MeshFaceMaterial){I=0;for(O=p.faceMaterials.length;I<O;)(E=p.faceMaterials[I++])&&b(k,o,r,p,
+E,D)}else E&&b(k,o,r,p,E,D)}}}else if(p instanceof THREE.RenderableFace4){k=p.v1;o=p.v2;r=p.v3;v=p.v4;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;r.positionScreen.x*=n;r.positionScreen.y*=-m;v.positionScreen.x*=n;v.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(r.positionScreen.x,r.positionScreen.y);j.addPoint(v.positionScreen.x,v.positionScreen.y);if(u.instersects(j)){x=
+0;for(t=p.meshMaterials.length;x<t;){E=p.meshMaterials[x++];if(E instanceof THREE.MeshFaceMaterial){I=0;for(O=p.faceMaterials.length;I<O;)(E=p.faceMaterials[I++])&&c(k,o,r,v,p,E,D)}else E&&c(k,o,r,v,p,E,D)}}}}}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,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.Vertex;this.v2=new THREE.Vertex;this.materials=null};

+ 145 - 138
build/custom/ThreeWebGL.js

@@ -1,6 +1,6 @@
-// ThreeWebGL.js r34 - http://github.com/mrdoob/three.js
+// ThreeWebGL.js r35 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,h,m,k,o,n;if(d==0)e=h=m=0;else{k=Math.floor(a*6);o=a*6-k;a=d*(1-b);n=d*(1-b*o);b=d*(1-b*(1-o));switch(k){case 1:e=n;h=d;m=a;break;case 2:e=a;h=d;m=b;break;case 3:e=a;h=n;m=d;break;case 4:e=b;h=a;m=d;break;case 5:e=d;h=a;m=n;break;case 6:case 0:e=d;h=b;m=a}}this.r=e;this.g=h;this.b=m;if(this.autoUpdate){this.updateHex();
+THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,m,k,o,n;if(d==0)e=g=m=0;else{k=Math.floor(a*6);o=a*6-k;a=d*(1-b);n=d*(1-b*o);b=d*(1-b*(1-o));switch(k){case 1:e=n;g=d;m=a;break;case 2:e=a;g=d;m=b;break;case 3:e=a;g=n;m=d;break;case 4:e=b;g=a;m=d;break;case 5:e=d;g=a;m=n;break;case 6:case 0:e=d;g=b;m=a}}this.r=e;this.g=g;this.b=m;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
 THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
@@ -8,68 +8,66 @@ this.length());return this},length:function(){return Math.sqrt(this.lengthSq())}
 THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
 b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.set(d*a.z-e*a.y,e*a.x-b*a.z,b*a.y-d*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
 a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
-this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,d,e){this.set(a||0,b||0,d||0,e||1)};
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPositionFromMatrix:function(a){this.x=a.n14;this.y=a.n24;this.z=a.n34},setRotationFromMatrix:function(a){this.y=Math.asin(a.n13);var b=Math.cos(this.y);if(Math.abs(b)>1.0E-5){this.x=Math.atan2(-a.n23/b,a.n33/b);this.z=Math.atan2(-a.n13/b,a.n11/b)}else{this.x=0;this.z=Math.atan2(a.n21,a.n22)}},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<
+1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,d,e){this.set(a||0,b||0,d||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(h=h.concat(this.intersectObject(d)))}h.sort(function(m,k){return m.distance-k.distance});return h},intersectObject:function(a){function b(J,H,R,P){P=P.clone().subSelf(H);R=R.clone().subSelf(H);var L=J.clone().subSelf(H);J=P.dot(P);H=P.dot(R);P=P.dot(L);var N=R.dot(R);R=R.dot(L);L=1/(J*N-H*H);N=(N*P-H*R)*L;J=(J*R-H*P)*L;return N>0&&J>0&&N+J<1}var d,e,h,m,k,o,n,t,y,w,
-C,D=a.geometry,F=D.vertices,G=[];d=0;for(e=D.faces.length;d<e;d++){h=D.faces[d];w=this.origin.clone();C=this.direction.clone();n=a.matrixWorld;m=n.multiplyVector3(F[h.a].position.clone());k=n.multiplyVector3(F[h.b].position.clone());o=n.multiplyVector3(F[h.c].position.clone());n=h instanceof THREE.Face4?n.multiplyVector3(F[h.d].position.clone()):null;t=a.matrixRotationWorld.multiplyVector3(h.normal.clone());y=C.dot(t);if(y<0){t=t.dot((new THREE.Vector3).sub(m,w))/y;w=w.addSelf(C.multiplyScalar(t));
-if(h instanceof THREE.Face3){if(b(w,m,k,o)){h={distance:this.origin.distanceTo(w),point:w,face:h,object:a};G.push(h)}}else if(h instanceof THREE.Face4&&(b(w,m,k,n)||b(w,k,o,n))){h={distance:this.origin.distanceTo(w),point:w,face:h,object:a};G.push(h)}}}return G}};
-THREE.Rectangle=function(){function a(){m=e-b;k=h-d}var b,d,e,h,m,k,o=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return m};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(n,t,y,w){o=!1;b=n;d=t;e=y;h=w;a()};this.addPoint=function(n,t){if(o){o=!1;b=n;d=t;e=n;h=t}else{b=b<n?b:n;d=d<t?d:t;e=e>n?e:n;h=h>t?h:t}a()};
-this.add3Points=function(n,t,y,w,C,D){if(o){o=!1;b=n<y?n<C?n:C:y<C?y:C;d=t<w?t<D?t:D:w<D?w:D;e=n>y?n>C?n:C:y>C?y:C;h=t>w?t>D?t:D:w>D?w:D}else{b=n<y?n<C?n<b?n:b:C<b?C:b:y<C?y<b?y:b:C<b?C:b;d=t<w?t<D?t<d?t:d:D<d?D:d:w<D?w<d?w:d:D<d?D:d;e=n>y?n>C?n>e?n:e:C>e?C:e:y>C?y>e?y:e:C>e?C:e;h=t>w?t>D?t>h?t:h:D>h?D:h:w>D?w>h?w:h:D>h?D:h}a()};this.addRectangle=function(n){if(o){o=!1;b=n.getLeft();d=n.getTop();e=n.getRight();h=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();d=d<n.getTop()?d:n.getTop();e=e>n.getRight()?
-e:n.getRight();h=h>n.getBottom()?h:n.getBottom()}a()};this.inflate=function(n){b-=n;d-=n;e+=n;h+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();d=d>n.getTop()?d:n.getTop();e=e<n.getRight()?e:n.getRight();h=h<n.getBottom()?h:n.getBottom();a()};this.instersects=function(n){return Math.min(e,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(h,n.getBottom())-Math.max(d,n.getTop())>=0};this.empty=function(){o=!0;h=e=d=b=0;a()};this.isEmpty=function(){return o}};
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(m,k){return m.distance-k.distance});return g},intersectObject:function(a){function b(L,M,V,X){X=X.clone().subSelf(M);V=V.clone().subSelf(M);var ca=L.clone().subSelf(M);L=X.dot(X);M=X.dot(V);X=X.dot(ca);var aa=V.dot(V);V=V.dot(ca);ca=1/(L*aa-M*M);aa=(aa*X-M*V)*ca;L=(L*V-M*X)*ca;return aa>0&&L>0&&aa+L<1}var d,e,g,m,
+k,o,n,w,z,x,D,E=a.geometry,F=E.vertices,H=[];d=0;for(e=E.faces.length;d<e;d++){g=E.faces[d];x=this.origin.clone();D=this.direction.clone();n=a.matrixWorld;m=n.multiplyVector3(F[g.a].position.clone());k=n.multiplyVector3(F[g.b].position.clone());o=n.multiplyVector3(F[g.c].position.clone());n=g instanceof THREE.Face4?n.multiplyVector3(F[g.d].position.clone()):null;w=a.matrixRotationWorld.multiplyVector3(g.normal.clone());z=D.dot(w);if(z<0){w=w.dot((new THREE.Vector3).sub(m,x))/z;x=x.addSelf(D.multiplyScalar(w));
+if(g instanceof THREE.Face3){if(b(x,m,k,o)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(x,m,k,n)||b(x,k,o,n))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}}return H}};
+THREE.Rectangle=function(){function a(){m=e-b;k=g-d}var b,d,e,g,m,k,o=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return m};this.getHeight=function(){return k};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(n,w,z,x){o=!1;b=n;d=w;e=z;g=x;a()};this.addPoint=function(n,w){if(o){o=!1;b=n;d=w;e=n;g=w}else{b=b<n?b:n;d=d<w?d:w;e=e>n?e:n;g=g>w?g:w}a()};
+this.add3Points=function(n,w,z,x,D,E){if(o){o=!1;b=n<z?n<D?n:D:z<D?z:D;d=w<x?w<E?w:E:x<E?x:E;e=n>z?n>D?n:D:z>D?z:D;g=w>x?w>E?w:E:x>E?x:E}else{b=n<z?n<D?n<b?n:b:D<b?D:b:z<D?z<b?z:b:D<b?D:b;d=w<x?w<E?w<d?w:d:E<d?E:d:x<E?x<d?x:d:E<d?E:d;e=n>z?n>D?n>e?n:e:D>e?D:e:z>D?z>e?z:e:D>e?D:e;g=w>x?w>E?w>g?w:g:E>g?E:g:x>E?x>g?x:g:E>g?E:g}a()};this.addRectangle=function(n){if(o){o=!1;b=n.getLeft();d=n.getTop();e=n.getRight();g=n.getBottom()}else{b=b<n.getLeft()?b:n.getLeft();d=d<n.getTop()?d:n.getTop();e=e>n.getRight()?
+e:n.getRight();g=g>n.getBottom()?g:n.getBottom()}a()};this.inflate=function(n){b-=n;d-=n;e+=n;g+=n;a()};this.minSelf=function(n){b=b>n.getLeft()?b:n.getLeft();d=d>n.getTop()?d:n.getTop();e=e<n.getRight()?e:n.getRight();g=g<n.getBottom()?g:n.getBottom();a()};this.instersects=function(n){return Math.min(e,n.getRight())-Math.max(b,n.getLeft())>=0&&Math.min(g,n.getBottom())-Math.max(d,n.getTop())>=0};this.empty=function(){o=!0;g=e=d=b=0;a()};this.isEmpty=function(){return o}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={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,d,e,h,m,k,o,n,t,y,w,C,D,F,G){this.set(a||1,b||0,d||0,e||0,h||0,m||1,k||0,o||0,n||0,t||0,y||1,w||0,C||0,D||0,F||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,d,e,h,m,k,o,n,t,y,w,C,D,F,G){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=m;this.n23=k;this.n24=o;this.n31=n;this.n32=t;this.n33=y;this.n34=w;this.n41=C;this.n42=D;this.n43=F;this.n44=G;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,d){var e=THREE.Matrix4.__tmpVec1,
-h=THREE.Matrix4.__tmpVec2,m=THREE.Matrix4.__tmpVec3;m.sub(a,b).normalize();e.cross(d,m).normalize();h.cross(m,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=m.x;this.n14=a.x;this.n21=e.y;this.n22=h.y;this.n23=m.y;this.n24=a.y;this.n31=e.z;this.n32=h.z;this.n33=m.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31*
-b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector3OnlyZ:function(a){var b=a.x,d=a.y;a=a.z;return(this.n31*b+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;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 d=a.n11,e=a.n12,h=a.n13,m=a.n14,k=a.n21,o=a.n22,n=a.n23,t=a.n24,y=a.n31,w=a.n32,C=a.n33,D=a.n34,F=a.n41,G=a.n42,J=a.n43,H=a.n44,R=b.n11,P=b.n12,L=b.n13,N=b.n14,c=b.n21,Z=b.n22,ca=b.n23,$=b.n24,aa=b.n31,ha=b.n32,ka=b.n33,la=b.n34;this.n11=
-d*R+e*c+h*aa;this.n12=d*P+e*Z+h*ha;this.n13=d*L+e*ca+h*ka;this.n14=d*N+e*$+h*la+m;this.n21=k*R+o*c+n*aa;this.n22=k*P+o*Z+n*ha;this.n23=k*L+o*ca+n*ka;this.n24=k*N+o*$+n*la+t;this.n31=y*R+w*c+C*aa;this.n32=y*P+w*Z+C*ha;this.n33=y*L+w*ca+C*ka;this.n34=y*N+w*$+C*la+D;this.n41=F*R+G*c+J*aa;this.n42=F*P+G*Z+J*ha;this.n43=F*L+G*ca+J*ka;this.n44=F*N+G*$+J*la+H;return this},multiplyToArray:function(a,b,d){var e=a.n11,h=a.n12,m=a.n13,k=a.n14,o=a.n21,n=a.n22,t=a.n23,y=a.n24,w=a.n31,C=a.n32,D=a.n33,F=a.n34,G=
-a.n41,J=a.n42,H=a.n43;a=a.n44;var R=b.n11,P=b.n12,L=b.n13,N=b.n14,c=b.n21,Z=b.n22,ca=b.n23,$=b.n24,aa=b.n31,ha=b.n32,ka=b.n33,la=b.n34,ia=b.n41,qa=b.n42,ta=b.n43;b=b.n44;this.n11=e*R+h*c+m*aa+k*ia;this.n12=e*P+h*Z+m*ha+k*qa;this.n13=e*L+h*ca+m*ka+k*ta;this.n14=e*N+h*$+m*la+k*b;this.n21=o*R+n*c+t*aa+y*ia;this.n22=o*P+n*Z+t*ha+y*qa;this.n23=o*L+n*ca+t*ka+y*ta;this.n24=o*N+n*$+t*la+y*b;this.n31=w*R+C*c+D*aa+F*ia;this.n32=w*P+C*Z+D*ha+F*qa;this.n33=w*L+C*ca+D*ka+F*ta;this.n34=w*N+C*$+D*la+F*b;this.n41=
-G*R+J*c+H*aa+a*ia;this.n42=G*P+J*Z+H*ha+a*qa;this.n43=G*L+J*ca+H*ka+a*ta;this.n44=G*N+J*$+H*la+a*b;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(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,m=this.n21,k=this.n22,o=this.n23,n=this.n24,t=this.n31,y=this.n32,w=this.n33,C=this.n34,
-D=this.n41,F=this.n42,G=this.n43,J=this.n44,H=a.n11,R=a.n21,P=a.n31,L=a.n12,N=a.n22,c=a.n32,Z=a.n13,ca=a.n23,$=a.n33,aa=a.n14,ha=a.n24;a=a.n34;this.n11=b*H+d*R+e*P;this.n12=b*L+d*N+e*c;this.n13=b*Z+d*ca+e*$;this.n14=b*aa+d*ha+e*a+h;this.n21=m*H+k*R+o*P;this.n22=m*L+k*N+o*c;this.n23=m*Z+k*ca+o*$;this.n24=m*aa+k*ha+o*a+n;this.n31=t*H+y*R+w*P;this.n32=t*L+y*N+w*c;this.n33=t*Z+y*ca+w*$;this.n34=t*aa+y*ha+w*a+C;this.n41=D*H+F*R+G*P;this.n42=D*L+F*N+G*c;this.n43=D*Z+F*ca+G*$;this.n44=D*aa+F*ha+G*a+J;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,d=this.n13,e=this.n14,h=this.n21,m=this.n22,k=this.n23,o=this.n24,n=this.n31,t=this.n32,y=this.n33,w=this.n34,C=this.n41,D=this.n42,F=this.n43,G=this.n44;return e*k*t*C-d*o*t*C-e*m*y*C+b*o*y*C+d*m*w*C-b*k*w*C-e*k*n*D+d*o*
-n*D+e*h*y*D-a*o*y*D-d*h*w*D+a*k*w*D+e*m*n*F-b*o*n*F-e*h*t*F+a*o*t*F+b*h*w*F-a*m*w*F-d*m*n*G+b*k*n*G+d*h*t*G-a*k*t*G-b*h*y*G+a*m*y*G},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.flattenToArray(this.flat);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,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),h=1-d,m=a.x,k=a.y,o=a.z,n=h*m,t=h*k;this.set(n*m+d,n*k-e*o,n*o+e*k,0,n*k+e*o,t*k+d,t*o-e*m,0,n*o-e*k,t*o+e*m,h*o*o+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=
-a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var h=Math.cos(d);d=Math.sin(d);var m=Math.cos(e);e=Math.sin(e);var k=a*d,o=b*d;this.n11=h*m;this.n12=-h*e;this.n13=d;this.n21=o*m+a*e;this.n22=-o*e+a*m;this.n23=-b*h;this.n31=-k*m+b*e;this.n32=k*e+b*m;this.n33=a*h},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,h=a.w,m=b+b,k=d+d,o=e+e;a=b*m;var n=b*k;b*=o;var t=d*k;d*=o;e*=o;m*=h;k*=h;h*=o;this.n11=1-(t+e);this.n12=
-n-h;this.n13=b+k;this.n21=n+h;this.n22=1-(a+e);this.n23=d-m;this.n31=b-k;this.n32=d+m;this.n33=1-(a+t)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};
-THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
-THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,h=a.n13,m=a.n14,k=a.n21,o=a.n22,n=a.n23,t=a.n24,y=a.n31,w=a.n32,C=a.n33,D=a.n34,F=a.n41,G=a.n42,J=a.n43,H=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*D*G-t*C*G+t*w*J-o*D*J-n*w*H+o*C*H;b.n12=m*C*G-h*D*G-m*w*J+e*D*J+h*w*H-e*C*H;b.n13=h*t*G-m*n*G+m*o*J-e*t*J-h*o*H+e*n*H;b.n14=m*n*w-h*t*w-m*o*C+e*t*C+h*o*D-e*n*D;b.n21=t*C*F-n*D*F-t*y*J+k*D*J+n*y*H-k*C*H;b.n22=h*D*F-m*C*F+m*y*J-d*D*J-h*y*H+d*C*H;b.n23=m*n*F-h*t*F-m*k*J+d*t*J+h*k*H-d*n*H;
-b.n24=h*t*y-m*n*y+m*k*C-d*t*C-h*k*D+d*n*D;b.n31=o*D*F-t*w*F+t*y*G-k*D*G-o*y*H+k*w*H;b.n32=m*w*F-e*D*F-m*y*G+d*D*G+e*y*H-d*w*H;b.n33=h*t*F-m*o*F+m*k*G-d*t*G-e*k*H+d*o*H;b.n34=m*o*y-e*t*y-m*k*w+d*t*w+e*k*D-d*o*D;b.n41=n*w*F-o*C*F-n*y*G+k*C*G+o*y*J-k*w*J;b.n42=e*C*F-h*w*F+h*y*G-d*C*G-e*y*J+d*w*J;b.n43=h*o*F-e*n*F-h*k*G+d*n*G+e*k*J-d*o*J;b.n44=e*n*y-h*o*y+h*k*w-d*n*w-e*k*C+d*o*C;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,m=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,y=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*k+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*h;d[2]=a*m;d[3]=a*k;d[4]=a*o;d[5]=a*n;d[6]=a*t;d[7]=a*y;d[8]=a*w;return b};
-THREE.Matrix4.makeFrustum=function(a,b,d,e,h,m){var k;k=new THREE.Matrix4;k.n11=2*h/(b-a);k.n12=0;k.n13=(b+a)/(b-a);k.n14=0;k.n21=0;k.n22=2*h/(e-d);k.n23=(e+d)/(e-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(m+h)/(m-h);k.n34=-2*m*h/(m-h);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,h,m){var k,o,n,t;k=new THREE.Matrix4;o=b-a;n=d-e;t=m-h;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((b+a)/o);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((d+e)/n);k.n31=0;k.n32=0;k.n33=-2/t;k.n34=-((m+h)/t);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
-this.visible=!0};
-THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
-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))}return!0},update:function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var e=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
-this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*e;this.matrixRotationWorld.n23=this.matrixWorld.n23*e;this.matrixRotationWorld.n33=this.matrixWorld.n33*e;this.matrixNeedsUpdate=!1;b=!0}a=0;for(e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,b,d)}}};
-THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,d,e){this.set(a||0,b||0,d||0,e!==undefined?e:1)};
-THREE.Quaternion.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,e=a.y*b,h=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-h);h=Math.sin(-h);var m=Math.cos(d);d=Math.sin(d);var k=a*b,o=e*h;this.w=k*m-o*d;this.x=k*d+o*m;this.y=e*b*m+a*h*d;this.z=a*h*m-e*b*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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,d=this.y,e=this.z,h=this.w,m=a.x,k=a.y,o=a.z;a=a.w;this.x=b*a+h*m+d*o-e*k;this.y=d*a+h*k+e*m-b*o;this.z=e*a+h*o+b*k-d*m;this.w=h*a-b*m-d*k-e*o;return this},
-multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,h=a.z,m=this.x,k=this.y,o=this.z,n=this.w,t=n*d+k*h-o*e,y=n*e+o*d-m*h,w=n*h+m*e-k*d;d=-m*d-k*e-o*h;b.x=t*n+d*-m+y*-o-w*-k;b.y=y*n+d*-k+w*-m-t*-o;b.z=w*n+d*-o+t*-k-y*-m;return b}};
-THREE.Quaternion.slerp=function(a,b,d,e){var h=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(h)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var m=Math.acos(h),k=Math.sqrt(1-h*h);if(Math.abs(k)<0.001){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}h=Math.sin((1-e)*m)/k;e=Math.sin(e*m)/k;d.w=a.w*h+b.w*e;d.x=a.x*h+b.x*e;d.y=a.y*h+b.y*e;d.z=a.z*h+b.z*e;return d};
+THREE.Matrix4=function(a,b,d,e,g,m,k,o,n,w,z,x,D,E,F,H){this.set(a||1,b||0,d||0,e||0,g||0,m||1,k||0,o||0,n||0,w||0,z||1,x||0,D||0,E||0,F||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,d,e,g,m,k,o,n,w,z,x,D,E,F,H){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=m;this.n23=k;this.n24=o;this.n31=n;this.n32=w;this.n33=z;this.n34=x;this.n41=D;this.n42=E;this.n43=F;this.n44=H;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,d){var e=THREE.Matrix4.__v1,
+g=THREE.Matrix4.__v2,m=THREE.Matrix4.__v3;m.sub(a,b).normalize();e.cross(d,m).normalize();g.cross(m,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=m.x;this.n21=e.y;this.n22=g.y;this.n23=m.y;this.n31=e.z;this.n32=g.z;this.n33=m.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},
+multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},rotateAxis:function(a){var b=a.x,d=a.y,e=a.z;a.x=b*this.n11+d*this.n12+e*this.n13;a.y=b*this.n21+d*this.n22+e*this.n23;a.z=b*this.n31+d*this.n32+e*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 d=a.n11,e=a.n12,g=a.n13,m=a.n14,k=a.n21,o=a.n22,n=a.n23,w=a.n24,z=a.n31,x=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44,V=b.n11,X=b.n12,ca=b.n13,aa=b.n14,Y=b.n21,fa=b.n22,c=b.n23,na=b.n24,la=b.n31,ta=b.n32,oa=b.n33,pa=b.n34;this.n11=d*V+e*Y+g*
+la;this.n12=d*X+e*fa+g*ta;this.n13=d*ca+e*c+g*oa;this.n14=d*aa+e*na+g*pa+m;this.n21=k*V+o*Y+n*la;this.n22=k*X+o*fa+n*ta;this.n23=k*ca+o*c+n*oa;this.n24=k*aa+o*na+n*pa+w;this.n31=z*V+x*Y+D*la;this.n32=z*X+x*fa+D*ta;this.n33=z*ca+x*c+D*oa;this.n34=z*aa+x*na+D*pa+E;this.n41=F*V+H*Y+L*la;this.n42=F*X+H*fa+L*ta;this.n43=F*ca+H*c+L*oa;this.n44=F*aa+H*na+L*pa+M;return this},multiplyToArray:function(a,b,d){this.multiply(a,b);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(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,d=
+this.n13,e=this.n14,g=this.n21,m=this.n22,k=this.n23,o=this.n24,n=this.n31,w=this.n32,z=this.n33,x=this.n34,D=this.n41,E=this.n42,F=this.n43,H=this.n44;return e*k*w*D-d*o*w*D-e*m*z*D+b*o*z*D+d*m*x*D-b*k*x*D-e*k*n*E+d*o*n*E+e*g*z*E-a*o*z*E-d*g*x*E+a*k*x*E+e*m*n*F-b*o*n*F-e*g*w*F+a*o*w*F+b*g*x*F-a*m*x*F-d*m*n*H+b*k*n*H+d*g*w*H-a*k*w*H-b*g*z*H+a*m*z*H},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,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,
+0,0,b,0,0,0,0,d,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 d=Math.cos(b),e=Math.sin(b),g=1-d,m=a.x,k=a.y,o=a.z,n=g*m,w=g*k;this.set(n*m+d,n*k-e*o,n*
+o+e*k,0,n*k+e*o,w*k+d,w*o-e*m,0,n*o-e*k,w*o+e*m,g*o*o+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var m=Math.cos(e);e=Math.sin(e);var k=a*d,o=b*d;this.n11=g*m;this.n12=-g*e;this.n13=d;this.n21=o*m+a*e;this.n22=-o*e+a*m;this.n23=-b*g;this.n31=-k*m+b*e;this.n32=k*e+b*m;this.n33=a*g;return this},setRotationFromQuaternion:function(a){var b=
+a.x,d=a.y,e=a.z,g=a.w,m=b+b,k=d+d,o=e+e;a=b*m;var n=b*k;b*=o;var w=d*k;d*=o;e*=o;m*=g;k*=g;g*=o;this.n11=1-(w+e);this.n12=n-g;this.n13=b+k;this.n21=n+g;this.n22=1-(a+e);this.n23=d-m;this.n31=b-k;this.n32=d+m;this.n33=1-(a+w);return this},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;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 d=1/b.x,e=1/b.y,g=1/b.z;this.n11=a.n11*d;this.n21=a.n21*d;this.n31=a.n31*d;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*g;this.n23=a.n23*g;this.n33=a.n33*g}};
+THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,g=a.n13,m=a.n14,k=a.n21,o=a.n22,n=a.n23,w=a.n24,z=a.n31,x=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=n*E*H-w*D*H+w*x*L-o*E*L-n*x*M+o*D*M;b.n12=m*D*H-g*E*H-m*x*L+e*E*L+g*x*M-e*D*M;b.n13=g*w*H-m*n*H+m*o*L-e*w*L-g*o*M+e*n*M;b.n14=m*n*x-g*w*x-m*o*D+e*w*D+g*o*E-e*n*E;b.n21=w*D*F-n*E*F-w*z*L+k*E*L+n*z*M-k*D*M;b.n22=g*E*F-m*D*F+m*z*L-d*E*L-g*z*M+d*D*M;b.n23=m*n*F-g*w*F-m*k*L+d*w*L+g*k*M-d*n*M;
+b.n24=g*w*z-m*n*z+m*k*D-d*w*D-g*k*E+d*n*E;b.n31=o*E*F-w*x*F+w*z*H-k*E*H-o*z*M+k*x*M;b.n32=m*x*F-e*E*F-m*z*H+d*E*H+e*z*M-d*x*M;b.n33=g*w*F-m*o*F+m*k*H-d*w*H-e*k*M+d*o*M;b.n34=m*o*z-e*w*z-m*k*x+d*w*x+e*k*E-d*o*E;b.n41=n*x*F-o*D*F-n*z*H+k*D*H+o*z*L-k*x*L;b.n42=e*D*F-g*x*F+g*z*H-d*D*H-e*z*L+d*x*L;b.n43=g*o*F-e*n*F-g*k*H+d*n*H+e*k*L-d*o*L;b.n44=e*n*z-g*o*z+g*k*x-d*n*x-e*k*D+d*o*D;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,m=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,n=-a.n32*a.n11+a.n31*a.n12,w=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*k+a.n31*w;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*m;d[3]=a*k;d[4]=a*o;d[5]=a*n;d[6]=a*w;d[7]=a*z;d[8]=a*x;return b};
+THREE.Matrix4.makeFrustum=function(a,b,d,e,g,m){var k;k=new THREE.Matrix4;k.n11=2*g/(b-a);k.n12=0;k.n13=(b+a)/(b-a);k.n14=0;k.n21=0;k.n22=2*g/(e-d);k.n23=(e+d)/(e-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(m+g)/(m-g);k.n34=-2*m*g/(m-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
+THREE.Matrix4.makeOrtho=function(a,b,d,e,g,m){var k,o,n,w;k=new THREE.Matrix4;o=b-a;n=d-e;w=m-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((b+a)/o);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((d+e)/n);k.n31=0;k.n32=0;k.n33=-2/w;k.n34=-((m+g)/w);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
+!0;this._vector=new THREE.Vector3};
+THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
+undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);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))}return!0},update:function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,
+b,d)}}};THREE.Quaternion=function(a,b,d,e){this.set(a||0,b||0,d||0,e!==undefined?e:1)};
+THREE.Quaternion.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var m=Math.cos(d);d=Math.sin(d);var k=a*b,o=e*g;this.w=k*m-o*d;this.x=k*d+o*m;this.y=e*b*m+a*g*d;this.z=a*g*m-e*b*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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,d=this.y,e=this.z,g=this.w,m=a.x,k=a.y,o=a.z;a=a.w;this.x=b*a+g*m+d*o-e*k;this.y=d*a+g*k+e*m-b*o;this.z=e*a+g*o+b*k-d*m;this.w=g*a-b*m-d*k-e*o;return this},
+multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,g=a.z,m=this.x,k=this.y,o=this.z,n=this.w,w=n*d+k*g-o*e,z=n*e+o*d-m*g,x=n*g+m*e-k*d;d=-m*d-k*e-o*g;b.x=w*n+d*-m+z*-o-x*-k;b.y=z*n+d*-k+x*-m-w*-o;b.z=x*n+d*-o+w*-k-z*-m;return b}};
+THREE.Quaternion.slerp=function(a,b,d,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var m=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}g=Math.sin((1-e)*m)/k;e=Math.sin(e*m)/k;d.w=a.w*g+b.w*e;d.x=a.x*g+b.x*e;d.y=a.y*g+b.y*e;d.z=a.z*g+b.z*e;return d};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
-THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face4=function(a,b,d,e,h,m){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=m instanceof Array?m:[m]};
+THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face4=function(a,b,d,e,g,m){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=m instanceof Array?m:[m]};
 THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={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.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(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)}else if(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(a){var b,d,e,h,m,k,o=new THREE.Vector3,n=new THREE.Vector3;e=0;for(h=this.vertices.length;e<h;e++){m=this.vertices[e];m.normal.set(0,0,0)}e=0;for(h=this.faces.length;e<h;e++){m=this.faces[e];if(a&&m.vertexNormals.length){o.set(0,0,0);b=0;for(d=m.normal.length;b<d;b++)o.addSelf(m.vertexNormals[b]);o.divideScalar(3)}else{b=this.vertices[m.a];d=this.vertices[m.b];k=this.vertices[m.c];o.sub(k.position,
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,m,k,o=new THREE.Vector3,n=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){m=this.vertices[e];m.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){m=this.faces[e];if(a&&m.vertexNormals.length){o.set(0,0,0);b=0;for(d=m.normal.length;b<d;b++)o.addSelf(m.vertexNormals[b]);o.divideScalar(3)}else{b=this.vertices[m.a];d=this.vertices[m.b];k=this.vertices[m.c];o.sub(k.position,
 d.position);n.sub(b.position,d.position);o.crossSelf(n)}o.isZero()||o.normalize();m.normal.copy(o)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(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;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(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)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){d=this.faces[a];if(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])}else if(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 a(la,ia,qa,ta,Ca,xa,Fa){m=la.vertices[ia].position;k=la.vertices[qa].position;o=la.vertices[ta].position;n=h[Ca];t=h[xa];y=h[Fa];w=k.x-m.x;C=o.x-m.x;D=k.y-
-m.y;F=o.y-m.y;G=k.z-m.z;J=o.z-m.z;H=t.u-n.u;R=y.u-n.u;P=t.v-n.v;L=y.v-n.v;N=1/(H*L-R*P);ca.set((L*w-P*C)*N,(L*D-P*F)*N,(L*G-P*J)*N);$.set((H*C-R*w)*N,(H*F-R*D)*N,(H*J-R*G)*N);c[ia].addSelf(ca);c[qa].addSelf(ca);c[ta].addSelf(ca);Z[ia].addSelf($);Z[qa].addSelf($);Z[ta].addSelf($)}var b,d,e,h,m,k,o,n,t,y,w,C,D,F,G,J,H,R,P,L,N,c=[],Z=[],ca=new THREE.Vector3,$=new THREE.Vector3,aa=new THREE.Vector3,ha=new THREE.Vector3,ka=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){c[b]=new THREE.Vector3;
-Z[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];h=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){ka.copy(this.vertices[b].normal);e=c[b];aa.copy(e);aa.subSelf(ka.multiplyScalar(ka.dot(e))).normalize();ha.cross(this.vertices[b].normal,e);e=ha.dot(Z[b]);e=e<0?-1:1;this.vertices[b].tangent.set(aa.x,aa.y,aa.z,e)}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,d=this.vertices.length;b<d;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=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
-THREE.Camera=function(a,b,d,e,h){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=d||0.1;this.far=e||2E3;this.target=h||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(m,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(m);this.tmpVec.crossSelf(this.up);if(k)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
-this.target.position.addSelf(this.tmpVec)};this.translateZ=function(m,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(m);if(k)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
-THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.update=function(a,b,d){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
-this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,d)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
-THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+b;a++){d=this.faces[a];if(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])}else if(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 a(pa,za,Aa,va,Da,Ea,Fa){m=pa.vertices[za].position;k=pa.vertices[Aa].position;o=pa.vertices[va].position;n=g[Da];w=g[Ea];z=g[Fa];x=k.x-m.x;D=o.x-m.x;E=k.y-
+m.y;F=o.y-m.y;H=k.z-m.z;L=o.z-m.z;M=w.u-n.u;V=z.u-n.u;X=w.v-n.v;ca=z.v-n.v;aa=1/(M*ca-V*X);c.set((ca*x-X*D)*aa,(ca*E-X*F)*aa,(ca*H-X*L)*aa);na.set((M*D-V*x)*aa,(M*F-V*E)*aa,(M*L-V*H)*aa);Y[za].addSelf(c);Y[Aa].addSelf(c);Y[va].addSelf(c);fa[za].addSelf(na);fa[Aa].addSelf(na);fa[va].addSelf(na)}var b,d,e,g,m,k,o,n,w,z,x,D,E,F,H,L,M,V,X,ca,aa,Y=[],fa=[],c=new THREE.Vector3,na=new THREE.Vector3,la=new THREE.Vector3,ta=new THREE.Vector3,oa=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){Y[b]=
+new THREE.Vector3;fa[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
+this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){oa.copy(this.vertices[b].normal);e=Y[b];la.copy(e);la.subSelf(oa.multiplyScalar(oa.dot(e))).normalize();ta.cross(this.vertices[b].normal,e);e=ta.dot(fa[b]);e=e<0?-1:1;this.vertices[b].tangent.set(la.x,la.y,la.z,e)}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,d=this.vertices.length;b<d;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=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
+THREE.Camera=function(a,b,d,e,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=d||0.1;this.far=e||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(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
+THREE.Camera.prototype.update=function(a,b,d){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
+!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,d)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
+THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
+THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
 THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;if(a){a.color!==undefined&&
@@ -91,100 +89,109 @@ a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!=
 undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}};
 THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
 undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
-THREE.Texture=function(a,b,d,e,h,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==undefined?e:THREE.ClampToEdgeWrapping;this.magFilter=h!==undefined?h:THREE.LinearFilter;this.minFilter=m!==undefined?m:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
+THREE.Texture=function(a,b,d,e,g,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrapT=e!==undefined?e:THREE.ClampToEdgeWrapping;this.magFilter=g!==undefined?g:THREE.LinearFilter;this.minFilter=m!==undefined?m:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
 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.RenderTarget=function(a,b,d){this.width=a;this.height=b;d=d||{};this.wrapS=d.wrapS!==undefined?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==undefined?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==undefined?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==undefined?d.minFilter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType};
-var Uniforms={clone:function(a){var b,d,e,h={};for(b in a){h[b]={};for(d in a[b]){e=a[b][d];h[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return h},merge:function(a){var b,d,e,h={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)h[d]=e[d]}return h}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
+var Uniforms={clone:function(a){var b,d,e,g={};for(b in a){g[b]={};for(d in a[b]){e=a[b][d];g[b][d]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,d,e,g={};for(b=0;b<a.length;b++){e=this.clone(a[b]);for(d in e)g[d]=e[d]}return g}};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;
 THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;
 THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;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(a,b,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var e,h=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<h;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,d):a.update(this.matrixWorld,!0,d)}}else for(e=0;e<h;e++)this.children[e].update(this.skinMatrix,
-b,d)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
-THREE.Sound=function(a,b,d,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,d!==undefined?d:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var h;d=this.sources.length;for(a=0;a<d;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)h=
-"audio/mpeg";else if(b.indexOf(".ogg")!==-1)h="audio/ogg";else b.indexOf(".wav")!==-1&&(h="audio/wav");if(this.domElement.canPlayType(h)){h=document.createElement("source");h.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(h);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
+THREE.Bone.prototype.update=function(a,b,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,d):a.update(this.matrixWorld,!0,d)}}else for(e=0;e<g;e++)this.children[e].update(this.skinMatrix,
+b,d)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var d,e,g,m,k,o;if(this.geometry.bones!==undefined){for(d=0;d<this.geometry.bones.length;d++){g=this.geometry.bones[d];m=g.pos;k=g.rotq;o=g.scl;e=this.addBone();e.name=g.name;e.position.set(m[0],m[1],m[2]);e.quaternion.set(k[0],k[1],k[2],k[3]);o!==undefined?e.scale.set(o[0],o[1],o[2]):e.scale.set(1,1,1)}for(d=0;d<this.bones.length;d++){g=this.geometry.bones[d];e=this.bones[d];
+g.parent===-1?this.addChild(e):this.bones[g.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(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,g=this.children.length;for(e=0;e<g;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.identityMatrix,!1,d):a.update(this.matrixWorld,b,d)}}};
+THREE.SkinnedMesh.prototype.addBone=function(a){a===undefined&&(a=new THREE.Bone(this));this.bones.push(a);return a};
+THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var a,b=[],d=0;d<this.bones.length;d++){a=this.bones[d];b.push(THREE.Matrix4.makeInvert(a.skinMatrix));a.skinMatrix.flattenToArrayOffset(this.boneMatrices,d*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var e;for(a=0;a<this.geometry.skinIndices.length;a++){d=this.geometry.vertices[a].position;var g=this.geometry.skinIndices[a].x,m=this.geometry.skinIndices[a].y;
+e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(e));e=new THREE.Vector3(d.x,d.y,d.z);this.geometry.skinVerticesB.push(b[m].multiplyVector3(e));if(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y!==1){d=(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y))*0.5;this.geometry.skinWeights[a].x+=d;this.geometry.skinWeights[a].y+=d}}}};
+THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
+THREE.Sound=function(a,b,d,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,d!==undefined?d:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var g;d=this.sources.length;for(a=0;a<d;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)g=
+"audio/mpeg";else if(b.indexOf(".ogg")!==-1)g="audio/ogg";else b.indexOf(".wav")!==-1&&(g="audio/wav");if(this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[a];this.domElement.THREESound=this;this.domElement.appendChild(g);this.domElement.addEventListener("canplay",this.onLoad,!0);this.domElement.load();break}}};THREE.Sound.prototype=new THREE.Object3D;THREE.Sound.prototype.constructor=THREE.Sound;THREE.Sound.prototype.supr=THREE.Object3D.prototype;
 THREE.Sound.prototype.onLoad=function(){var a=this.THREESound;if(!a.isLoaded){this.removeEventListener("canplay",this.onLoad,!0);a.isLoaded=!0;a.duration=this.duration;a.isPlaying&&a.play()}};THREE.Sound.prototype.addToDOM=function(a){this.isAddedToDOM=!0;a.appendChild(this.domElement)};THREE.Sound.prototype.play=function(a){this.isPlaying=!0;if(this.isLoaded){this.domElement.play();if(a)this.domElement.currentTime=a%this.duration}};THREE.Sound.prototype.pause=function(){this.isPlaying=!1;this.domElement.pause()};
 THREE.Sound.prototype.stop=function(){this.isPlaying=!1;this.domElement.pause();this.domElement.currentTime=0};THREE.Sound.prototype.calculateVolumeAndPan=function(a){a=a.length();this.domElement.volume=a<=this.radius?this.volume*(1-a/this.radius):0};
-THREE.Sound.prototype.update=function(a,b,d){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.matrixWorld,b,d)};
-THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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(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.Sound)this.sounds.indexOf(a)===-1&&this.sounds.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.Sound.prototype.update=function(a,b,d){if(this.matrixAutoUpdate){this.matrix.setPosition(this.position);b=!0}if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e=this.children.length;for(a=0;a<e;a++)this.children[a].update(this.matrixWorld,b,d)};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(a,b){b===undefined&&(b=0);b=Math.abs(b);for(var d=0;d<this.LODs.length;d++)if(b<this.LODs[d].visibleAtDistance)break;this.LODs.splice(d,0,{visibleAtDistance:b,object3D:a});this.addChild(a)};
+THREE.LOD.prototype.update=function(a,b,d){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}if(this.LODs.length>1){a=d.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var e=1;e<this.LODs.length;e++)if(a>=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(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,d)};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];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(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.Sound)this.sounds.indexOf(a)===-1&&this.sounds.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 if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(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.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,d){d&&a.update(undefined,!1,b);d=a.sounds;var e,h=d.length;for(e=0;e<h;e++){a=d[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
-THREE.WebGLRenderer=function(a){function b(f,l,i){var g,j,p,u=f.vertices,x=u.length,z=f.colors,v=z.length,r=f.__vertexArray,K=f.__colorArray,O=f.__sortArray,M=f.__dirtyVertices,I=f.__dirtyColors;if(i.sortParticles){qa.multiplySelf(i.matrixWorld);for(g=0;g<x;g++){j=u[g].position;xa.copy(j);qa.multiplyVector3(xa);O[g]=[xa.z,g]}O.sort(function(Q,da){return da[0]-Q[0]});for(g=0;g<x;g++){j=u[O[g][1]].position;p=g*3;r[p]=j.x;r[p+1]=j.y;r[p+2]=j.z}for(g=0;g<v;g++){p=g*3;color=z[O[g][1]];K[p]=color.r;K[p+
-1]=color.g;K[p+2]=color.b}}else{if(M)for(g=0;g<x;g++){j=u[g].position;p=g*3;r[p]=j.x;r[p+1]=j.y;r[p+2]=j.z}if(I)for(g=0;g<v;g++){color=z[g];p=g*3;K[p]=color.r;K[p+1]=color.g;K[p+2]=color.b}}if(M||i.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,r,l)}if(I||i.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,K,l)}}function d(f,l){f.fragmentShader=l.fragmentShader;f.vertexShader=l.vertexShader;f.uniforms=Uniforms.clone(l.uniforms)}
-function e(f,l,i,g,j){g.program||$.initMaterial(g,l,i);var p=g.program,u=p.uniforms,x=g.uniforms;if(p!=Z){c.useProgram(p);Z=p;c.uniformMatrix4fv(u.projectionMatrix,!1,ta)}if(i&&(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial||g instanceof THREE.LineBasicMaterial||g instanceof THREE.ParticleBasicMaterial)){x.fogColor.value.setHex(i.color.hex);if(i instanceof THREE.Fog){x.fogNear.value=i.near;x.fogFar.value=i.far}else if(i instanceof
-THREE.FogExp2)x.fogDensity.value=i.density}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial){var z,v,r=0,K=0,O=0,M,I,Q,da=$.lights,s=da.directional.colors,ma=da.directional.positions,ea=da.point.colors,na=da.point.positions,A=0,B=0;i=v=v=0;for(z=l.length;i<z;i++){v=l[i];M=v.color;I=v.position;Q=v.intensity;if(v instanceof THREE.AmbientLight){r+=M.r;K+=M.g;O+=M.b}else if(v instanceof THREE.DirectionalLight){v=A*3;s[v]=M.r*Q;s[v+1]=M.g*Q;s[v+2]=M.b*Q;ma[v]=I.x;ma[v+1]=
-I.y;ma[v+2]=I.z;A+=1}else if(v instanceof THREE.PointLight){v=B*3;ea[v]=M.r*Q;ea[v+1]=M.g*Q;ea[v+2]=M.b*Q;na[v]=I.x;na[v+1]=I.y;na[v+2]=I.z;B+=1}}for(i=A*3;i<s.length;i++)s[i]=0;for(i=B*3;i<ea.length;i++)ea[i]=0;da.point.length=B;da.directional.length=A;da.ambient[0]=r;da.ambient[1]=K;da.ambient[2]=O;l=$.lights;x.enableLighting.value=l.directional.length+l.point.length;x.ambientLightColor.value=l.ambient;x.directionalLightColor.value=l.directional.colors;x.directionalLightDirection.value=l.directional.positions;
-x.pointLightColor.value=l.point.colors;x.pointLightPosition.value=l.point.positions}if(g instanceof THREE.MeshBasicMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshPhongMaterial){x.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);x.opacity.value=g.opacity;x.map.texture=g.map;x.lightMap.texture=g.lightMap;x.envMap.texture=g.envMap;x.reflectivity.value=g.reflectivity;x.refractionRatio.value=g.refractionRatio;x.combine.value=g.combine;x.useRefract.value=
-g.envMap&&g.envMap.mapping instanceof THREE.CubeRefractionMapping}if(g instanceof THREE.LineBasicMaterial){x.diffuse.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);x.opacity.value=g.opacity}else if(g instanceof THREE.ParticleBasicMaterial){x.psColor.value.setRGB(g.color.r*g.opacity,g.color.g*g.opacity,g.color.b*g.opacity);x.opacity.value=g.opacity;x.size.value=g.size;x.map.texture=g.map}else if(g instanceof THREE.MeshPhongMaterial){x.ambient.value.setRGB(g.ambient.r,g.ambient.g,
-g.ambient.b);x.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);x.shininess.value=g.shininess}else if(g instanceof THREE.MeshDepthMaterial){x.mNear.value=f.near;x.mFar.value=f.far;x.opacity.value=g.opacity}else if(g instanceof THREE.MeshNormalMaterial)x.opacity.value=g.opacity;for(var E in x)if(r=p.uniforms[E]){i=x[E];z=i.type;l=i.value;if(z=="i")c.uniform1i(r,l);else if(z=="f")c.uniform1f(r,l);else if(z=="fv1")c.uniform1fv(r,l);else if(z=="fv")c.uniform3fv(r,l);else if(z=="v2")c.uniform2f(r,
-l.x,l.y);else if(z=="v3")c.uniform3f(r,l.x,l.y,l.z);else if(z=="c")c.uniform3f(r,l.r,l.g,l.b);else if(z=="t"){c.uniform1i(r,l);if(i=i.texture)if(i.image instanceof Array&&i.image.length==6){if(i.image.length==6){if(i.needsUpdate){if(!i.image.__webGLTextureCube)i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);
-c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(z=0;z<6;++z)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+z,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[z]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.needsUpdate=!1}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube)}}else{if(i.needsUpdate){if(i.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,
-i.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(i.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(i.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(i.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(i.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}else{i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,
-0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(i.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(i.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(i.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(i.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null);i.__wasSetOnce=!0}i.needsUpdate=!1}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}}}c.uniformMatrix4fv(u.modelViewMatrix,
-!1,j._modelViewMatrixArray);c.uniformMatrix3fv(u.normalMatrix,!1,j._normalMatrixArray);(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshPhongMaterial||g.envMap)&&c.uniform3f(u.cameraPosition,f.position.x,f.position.y,f.position.z);(g instanceof THREE.MeshShaderMaterial||g.envMap||g.skinning)&&c.uniformMatrix4fv(u.objectMatrix,!1,j._objectMatrixArray);(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshShaderMaterial||g.skinning)&&c.uniformMatrix4fv(u.viewMatrix,
-!1,Ca);if(g.skinning){c.uniformMatrix4fv(u.cameraInverseMatrix,!1,Ca);c.uniformMatrix4fv(u.boneGlobalMatrices,!1,j.boneMatrices)}return p}function h(f,l,i,g,j,p){f=e(f,l,i,g,p).attributes;c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,
-3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(j.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(j.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);
-if(g.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,
-4,c.FLOAT,!1,0,0)}if(p instanceof THREE.Mesh)if(g.wireframe){c.lineWidth(g.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);c.drawElements(c.LINES,j.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,j.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(p instanceof THREE.Line){p=p.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(g.linewidth);c.drawArrays(p,0,j.__webGLLineCount)}else if(p instanceof
-THREE.ParticleSystem)c.drawArrays(c.POINTS,0,j.__webGLParticleCount);else p instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,j.__webGLVertexCount)}function m(f,l){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(l.attributes.position);c.vertexAttribPointer(l.attributes.position,
-3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(l.attributes.normal);c.vertexAttribPointer(l.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function k(f){if(aa!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);aa=f.doubleSided}if(ha!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);ha=f.flipSided}}function o(f){if(la!=
-f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);la=f}}function n(f){ia[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);ia[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);ia[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);ia[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);ia[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);ia[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var l;for(f=0;f<6;f++){l=ia[f];l.divideScalar(Math.sqrt(l.x*l.x+l.y*l.y+l.z*
-l.z))}}function t(f){for(var l=f.matrixWorld,i=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),g=0;g<6;g++){f=ia[g].x*l.n14+ia[g].y*l.n24+ia[g].z*l.n34+ia[g].w;if(f<=i)return!1}return!0}function y(f,l){f.list[f.count]=l;f.count+=1}function w(f){var l,i,g=f.object,j=f.opaque,p=f.transparent;p.count=0;f=j.count=0;for(l=g.materials.length;f<l;f++){i=g.materials[f];i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?y(p,i):y(j,i)}}function C(f){var l,i,g,j,p=f.object,
-u=f.buffer,x=f.opaque,z=f.transparent;z.count=0;f=x.count=0;for(g=p.materials.length;f<g;f++){l=p.materials[f];if(l instanceof THREE.MeshFaceMaterial){l=0;for(i=u.materials.length;l<i;l++)(j=u.materials[l])&&(j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?y(z,j):y(x,j))}else{j=l;j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?y(z,j):y(x,j)}}}function D(f,l){return l.z-f.z}function F(f,l){f._modelViewMatrix.multiplyToArray(l.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);
-THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function G(f){function l(K){var O=[];i=0;for(g=K.length;i<g;i++)K[i]==undefined?O.push("undefined"):O.push(K[i].id);return O.join("_")}var i,g,j,p,u,x,z,v,r={};f.geometryGroups={};j=0;for(p=f.faces.length;j<p;j++){u=f.faces[j];x=u.materials;z=l(x);r[z]==undefined&&(r[z]={hash:z,counter:0});v=r[z].hash+"_"+r[z].counter;f.geometryGroups[v]==undefined&&(f.geometryGroups[v]={faces:[],materials:x,vertices:0});u=u instanceof
-THREE.Face3?3:4;if(f.geometryGroups[v].vertices+u>65535){r[z].counter+=1;v=r[z].hash+"_"+r[z].counter;f.geometryGroups[v]==undefined&&(f.geometryGroups[v]={faces:[],materials:x,vertices:0})}f.geometryGroups[v].faces.push(j);f.geometryGroups[v].vertices+=u}}function J(f,l,i){f.push({buffer:l,object:i,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(f){if(f!=ka){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
-c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}ka=f}}function R(f,l){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,
-f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,L(f.format),f.width,f.height,0,L(f.format),L(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,
-f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var i,g,j;if(f){i=f.__webGLFramebuffer;g=f.width;j=f.height}else{i=null;g=N.width;j=N.height}if(i!=ca){c.bindFramebuffer(c.FRAMEBUFFER,i);c.viewport(0,0,g,j);l&&c.clear(c.COLOR_BUFFER_BIT|
-c.DEPTH_BUFFER_BIT);ca=i}}function P(f,l){var i;if(f=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(i=c.createShader(c.VERTEX_SHADER));c.shaderSource(i,l);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function L(f){switch(f){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 N=document.createElement("canvas"),c,Z=null,ca=null,$=this,aa=null,ha=null,ka=null,la=null,ia=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],
-qa=new THREE.Matrix4,ta=new Float32Array(16),Ca=new Float32Array(16),xa=new THREE.Vector4,Fa=!0,La=new THREE.Color(0),Ma=0;if(a){if(a.antialias!==undefined)Fa=a.antialias;a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ma=a.clearAlpha}this.domElement=N;this.autoClear=!0;this.sortObjects=!1;(function(f,l,i){try{c=N.getContext("experimental-webgl",{antialias:f})}catch(g){console.log(g)}if(!c)throw"cannot create webgl context";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.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(l.r,l.g,l.b,i);_cullEnabled=!0})(Fa,La,Ma);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,l){N.width=f;N.height=l;c.viewport(0,0,N.width,N.height)};this.setClearColorHex=function(f,l){var i=new THREE.Color(f);c.clearColor(i.r,i.g,i.b,l)};this.setClearColor=
-function(f,l){c.clearColor(f.r,f.g,f.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,l,i){var g,j;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);
-else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var p,u,x,z;j=x=z=0;for(p=l.length;j<p;j++){u=l[j];u instanceof THREE.DirectionalLight&&x++;u instanceof THREE.PointLight&&z++}if(z+x<=4)l=x;else{l=Math.ceil(4*x/(z+x));z=4-l}j={directional:l,point:z};z=f.fragmentShader;l=f.vertexShader;p={fog:i,map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,skinning:f.skinning,maxDirLights:j.directional,
-maxPointLights:j.point};i=c.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+p.maxDirLights,"#define MAX_POINT_LIGHTS "+p.maxPointLights,p.fog?"#define USE_FOG":"",p.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",p.map?"#define USE_MAP":"",p.envMap?"#define USE_ENVMAP":"",p.lightMap?"#define USE_LIGHTMAP":"",p.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");p=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
-0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+p.maxDirLights,"#define MAX_POINT_LIGHTS "+p.maxPointLights,p.map?"#define USE_MAP":"",p.envMap?"#define USE_ENVMAP":"",p.lightMap?"#define USE_LIGHTMAP":"",p.vertexColors?"#define USE_COLOR":"",p.skinning?"#define USE_SKINNING":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-c.attachShader(i,P("fragment",j+z));c.attachShader(i,P("vertex",p+l));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};f.program=i;i=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in f.uniforms)i.push(g);g=f.program;z=0;for(l=i.length;z<
-l;z++){j=i[z];g.uniforms[j]=c.getUniformLocation(g,j)}g=f.program;i=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];z=0;for(l=i.length;z<l;z++){j=i[z];g.attributes[j]=c.getAttribLocation(g,j)}g=f.program.attributes;c.enableVertexAttribArray(g.position);g.color>=0&&c.enableVertexAttribArray(g.color);g.normal>=0&&c.enableVertexAttribArray(g.normal);g.tangent>=0&&c.enableVertexAttribArray(g.tangent);if(f.skinning&&g.skinVertexA>=0&&g.skinVertexB>=
-0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(f,l,i,g){var j,p,u,x,z,v,r,K,O=f.lights,M=f.fog;l.matrixAutoUpdate&&l.update();l.matrixWorldInverse.flattenToArray(Ca);l.projectionMatrix.flattenToArray(ta);qa.multiply(l.projectionMatrix,l.matrixWorldInverse);n(qa);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,
-!1,l);this.initWebGLObjects(f,l);R(i,g!==undefined?g:!0);this.autoClear&&this.clear();z=f.__webglObjects.length;for(g=0;g<z;g++){j=f.__webglObjects[g];r=j.object;if(r.visible)if(!(r instanceof THREE.Mesh)||t(r)){r.matrixWorld.flattenToArray(r._objectMatrixArray);F(r,l);C(j);j.render=!0;if(this.sortObjects){xa.copy(r.position);qa.multiplyVector3(xa);j.z=xa.z}}else j.render=!1;else j.render=!1}this.sortObjects&&f.__webglObjects.sort(D);v=f.__webglObjectsImmediate.length;for(g=0;g<v;g++){j=f.__webglObjectsImmediate[g];
-r=j.object;if(r.visible){r.matrixAutoUpdate&&r.matrixWorld.flattenToArray(r._objectMatrixArray);F(r,l);w(j)}}H(THREE.NormalBlending);for(g=0;g<z;g++){j=f.__webglObjects[g];if(j.render){r=j.object;K=j.buffer;u=j.opaque;k(r);for(j=0;j<u.count;j++){x=u.list[j];o(x.depthTest);h(l,O,M,x,K,r)}}}for(g=0;g<v;g++){j=f.__webglObjectsImmediate[g];r=j.object;if(r.visible){u=j.opaque;k(r);for(j=0;j<u.count;j++){x=u.list[j];o(x.depthTest);p=e(l,O,M,x,r);r.render(function(I){m(I,p)})}}}for(g=0;g<z;g++){j=f.__webglObjects[g];
-if(j.render){r=j.object;K=j.buffer;u=j.transparent;k(r);for(j=0;j<u.count;j++){x=u.list[j];H(x.blending);o(x.depthTest);h(l,O,M,x,K,r)}}}for(g=0;g<v;g++){j=f.__webglObjectsImmediate[g];r=j.object;if(r.visible){u=j.transparent;k(r);for(j=0;j<u.count;j++){x=u.list[j];H(x.blending);o(x.depthTest);p=e(l,O,M,x,r);r.render(function(I){m(I,p)})}}}if(i&&i.minFilter!==THREE.NearestFilter&&i.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
-null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[]}for(;f.__objectsRemoved.length;){var l=f.__objectsRemoved[0],i=f,g=void 0,j=void 0;for(g=i.__webglObjects.length-1;g>=0;g--){j=i.__webglObjects[g].object;l==j&&i.__webglObjects.splice(g,1)}f.__objectsRemoved.splice(0,1)}for(;f.__objectsAdded.length;){l=f.__objectsAdded[0];var p=f;g=void 0;i=void 0;j=void 0;if(l._modelViewMatrix==undefined){l._modelViewMatrix=new THREE.Matrix4;l._normalMatrixArray=
-new Float32Array(9);l._modelViewMatrixArray=new Float32Array(16);l._objectMatrixArray=new Float32Array(16);l.matrixWorld.flattenToArray(l._objectMatrixArray)}objlist=p.__webglObjects;if(l instanceof THREE.Mesh){i=l.geometry;i.geometryGroups==undefined&&G(i);for(g in i.geometryGroups){j=i.geometryGroups[g];if(!j.__webGLVertexBuffer){p=j;p.__webGLVertexBuffer=c.createBuffer();p.__webGLNormalBuffer=c.createBuffer();p.__webGLTangentBuffer=c.createBuffer();p.__webGLColorBuffer=c.createBuffer();p.__webGLUVBuffer=
-c.createBuffer();p.__webGLUV2Buffer=c.createBuffer();p.__webGLSkinVertexABuffer=c.createBuffer();p.__webGLSkinVertexBBuffer=c.createBuffer();p.__webGLSkinIndicesBuffer=c.createBuffer();p.__webGLSkinWeightsBuffer=c.createBuffer();p.__webGLFaceBuffer=c.createBuffer();p.__webGLLineBuffer=c.createBuffer();p=j;var u=l,x=void 0,z=void 0,v=0,r=0,K=0,O=u.geometry.faces,M=p.faces;x=0;for(z=M.length;x<z;x++){fi=M[x];face=O[fi];if(face instanceof THREE.Face3){v+=3;r+=1;K+=3}else if(face instanceof THREE.Face4){v+=
-4;r+=2;K+=4}}p.__vertexArray=new Float32Array(v*3);p.__normalArray=new Float32Array(v*3);p.__tangentArray=new Float32Array(v*4);p.__colorArray=new Float32Array(v*3);p.__uvArray=new Float32Array(v*2);p.__uv2Array=new Float32Array(v*2);p.__skinVertexAArray=new Float32Array(v*4);p.__skinVertexBArray=new Float32Array(v*4);p.__skinIndexArray=new Float32Array(v*4);p.__skinWeightArray=new Float32Array(v*4);p.__faceArray=new Uint16Array(r*3);p.__lineArray=new Uint16Array(K*2);z=x=p;v=void 0;O=void 0;var I=
-void 0,Q=void 0;I=void 0;M=!1;v=0;for(O=u.materials.length;v<O;v++){I=u.materials[v];if(I instanceof THREE.MeshFaceMaterial){I=0;for(Q=z.materials.length;I<Q;I++)if(z.materials[I]&&z.materials[I].shading!=undefined&&z.materials[I].shading==THREE.SmoothShading){M=!0;break}}else if(I&&I.shading!=undefined&&I.shading==THREE.SmoothShading){M=!0;break}if(M)break}x.__needsSmoothNormals=M;p.__webGLFaceCount=r*3;p.__webGLLineCount=K*2;i.__dirtyVertices=!0;i.__dirtyElements=!0;i.__dirtyUvs=!0;i.__dirtyNormals=
-!0;i.__dirtyTangents=!0;i.__dirtyColors=!0}J(objlist,j,l)}}else if(l instanceof THREE.Ribbon){i=l.geometry;if(!i.__webGLVertexBuffer){g=i;g.__webGLVertexBuffer=c.createBuffer();g.__webGLColorBuffer=c.createBuffer();g=i;j=g.vertices.length;g.__vertexArray=new Float32Array(j*3);g.__colorArray=new Float32Array(j*3);g.__webGLVertexCount=j;i.__dirtyVertices=!0;i.__dirtyColors=!0}J(objlist,i,l)}else if(l instanceof THREE.Line){i=l.geometry;if(!i.__webGLVertexBuffer){g=i;g.__webGLVertexBuffer=c.createBuffer();
-g.__webGLColorBuffer=c.createBuffer();g=i;j=g.vertices.length;g.__vertexArray=new Float32Array(j*3);g.__colorArray=new Float32Array(j*3);g.__webGLLineCount=j;i.__dirtyVertices=!0;i.__dirtyColors=!0}J(objlist,i,l)}else if(l instanceof THREE.ParticleSystem){i=l.geometry;if(!i.__webGLVertexBuffer){g=i;g.__webGLVertexBuffer=c.createBuffer();g.__webGLColorBuffer=c.createBuffer();g=i;j=g.vertices.length;g.__vertexArray=new Float32Array(j*3);g.__colorArray=new Float32Array(j*3);g.__sortArray=[];g.__webGLParticleCount=
-j;i.__dirtyVertices=!0;i.__dirtyColors=!0}J(objlist,i,l)}else THREE.MarchingCubes!==undefined&&l instanceof THREE.MarchingCubes&&p.__webglObjectsImmediate.push({object:l,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}l=0;for(i=f.__webglObjects.length;l<i;l++){j=void 0;g=void 0;r=void 0;p=void 0;p=f.__webglObjects[l].object;if(p instanceof THREE.Mesh){g=p.geometry;for(j in g.geometryGroups){r=g.geometryGroups[j];if(g.__dirtyVertices||g.__dirtyElements||g.__dirtyUvs||
-g.__dirtyNormals||g.__dirtyColors||g.__dirtyTangents){K=c.DYNAMIC_DRAW;x=void 0;z=void 0;var da=void 0,s=void 0,ma=void 0,ea=void 0,na=void 0;da=void 0;var A=void 0,B=void 0,E=void 0,S=void 0;A=void 0;B=void 0;E=void 0;s=void 0;A=void 0;B=void 0;E=void 0;S=void 0;A=void 0;B=void 0;E=void 0;S=void 0;A=void 0;B=void 0;E=void 0;S=void 0;A=void 0;B=void 0;E=void 0;S=void 0;A=void 0;B=void 0;E=void 0;S=void 0;s=void 0;ea=void 0;ma=void 0;na=void 0;var T=Q=I=M=O=v=u=0,oa=0,ba=0,q=0,fa=r.__vertexArray,Da=
-r.__uvArray,Ea=r.__uv2Array,sa=r.__normalArray,U=r.__tangentArray,ga=r.__colorArray,V=r.__skinVertexAArray,W=r.__skinVertexBArray,X=r.__skinIndexArray,Y=r.__skinWeightArray,ua=r.__faceArray,pa=r.__lineArray,Na=r.__needsSmoothNormals,ja=p.geometry,Ga=ja.__dirtyVertices,Ha=ja.__dirtyElements,Ba=ja.__dirtyUvs,Ia=ja.__dirtyNormals,Ja=ja.__dirtyTangents,Ka=ja.__dirtyColors,ra=ja.vertices,Oa=r.faces,Pa=ja.faces,Qa=ja.uvs,Ra=ja.uvs2,va=ja.colors,ya=ja.skinVerticesA,za=ja.skinVerticesB,Aa=ja.skinIndices,
-wa=ja.skinWeights;x=0;for(z=Oa.length;x<z;x++){da=Oa[x];s=Pa[da];na=Qa[da];da=Ra[da];ma=s.vertexNormals;ea=s.normal;if(s instanceof THREE.Face3){if(Ga){A=ra[s.a].position;B=ra[s.b].position;E=ra[s.c].position;fa[v]=A.x;fa[v+1]=A.y;fa[v+2]=A.z;fa[v+3]=B.x;fa[v+4]=B.y;fa[v+5]=B.z;fa[v+6]=E.x;fa[v+7]=E.y;fa[v+8]=E.z;v+=9}if(wa.length){A=wa[s.a];B=wa[s.b];E=wa[s.c];Y[q]=A.x;Y[q+1]=A.y;Y[q+2]=A.z;Y[q+3]=A.w;Y[q+4]=B.x;Y[q+5]=B.y;Y[q+6]=B.z;Y[q+7]=B.w;Y[q+8]=E.x;Y[q+9]=E.y;Y[q+10]=E.z;Y[q+11]=E.w;A=Aa[s.a];
-B=Aa[s.b];E=Aa[s.c];X[q]=A.x;X[q+1]=A.y;X[q+2]=A.z;X[q+3]=A.w;X[q+4]=B.x;X[q+5]=B.y;X[q+6]=B.z;X[q+7]=B.w;X[q+8]=E.x;X[q+9]=E.y;X[q+10]=E.z;X[q+11]=E.w;A=ya[s.a];B=ya[s.b];E=ya[s.c];V[q]=A.x;V[q+1]=A.y;V[q+2]=A.z;V[q+3]=1;V[q+4]=B.x;V[q+5]=B.y;V[q+6]=B.z;V[q+7]=1;V[q+8]=E.x;V[q+9]=E.y;V[q+10]=E.z;V[q+11]=1;A=za[s.a];B=za[s.b];E=za[s.c];W[q]=A.x;W[q+1]=A.y;W[q+2]=A.z;W[q+3]=1;W[q+4]=B.x;W[q+5]=B.y;W[q+6]=B.z;W[q+7]=1;W[q+8]=E.x;W[q+9]=E.y;W[q+10]=E.z;W[q+11]=1;q+=12}if(Ka&&va.length){A=va[s.a];B=va[s.b];
-E=va[s.c];ga[ba]=A.r;ga[ba+1]=A.g;ga[ba+2]=A.b;ga[ba+3]=B.r;ga[ba+4]=B.g;ga[ba+5]=B.b;ga[ba+6]=E.r;ga[ba+7]=E.g;ga[ba+8]=E.b;ba+=9}if(Ja&&ja.hasTangents){A=ra[s.a].tangent;B=ra[s.b].tangent;E=ra[s.c].tangent;U[T]=A.x;U[T+1]=A.y;U[T+2]=A.z;U[T+3]=A.w;U[T+4]=B.x;U[T+5]=B.y;U[T+6]=B.z;U[T+7]=B.w;U[T+8]=E.x;U[T+9]=E.y;U[T+10]=E.z;U[T+11]=E.w;T+=12}if(Ia)if(ma.length==3&&Na)for(s=0;s<3;s++){ea=ma[s];sa[Q]=ea.x;sa[Q+1]=ea.y;sa[Q+2]=ea.z;Q+=3}else for(s=0;s<3;s++){sa[Q]=ea.x;sa[Q+1]=ea.y;sa[Q+2]=ea.z;Q+=
-3}if(Ba&&na)for(s=0;s<3;s++){ma=na[s];Da[O]=ma.u;Da[O+1]=ma.v;O+=2}if(Ba&&da)for(s=0;s<3;s++){na=da[s];Ea[M]=na.u;Ea[M+1]=na.v;M+=2}if(Ha){ua[I]=u;ua[I+1]=u+1;ua[I+2]=u+2;I+=3;pa[oa]=u;pa[oa+1]=u+1;pa[oa+2]=u;pa[oa+3]=u+2;pa[oa+4]=u+1;pa[oa+5]=u+2;oa+=6;u+=3}}else if(s instanceof THREE.Face4){if(Ga){A=ra[s.a].position;B=ra[s.b].position;E=ra[s.c].position;S=ra[s.d].position;fa[v]=A.x;fa[v+1]=A.y;fa[v+2]=A.z;fa[v+3]=B.x;fa[v+4]=B.y;fa[v+5]=B.z;fa[v+6]=E.x;fa[v+7]=E.y;fa[v+8]=E.z;fa[v+9]=S.x;fa[v+10]=
-S.y;fa[v+11]=S.z;v+=12}if(wa.length){A=wa[s.a];B=wa[s.b];E=wa[s.c];S=wa[s.d];Y[q]=A.x;Y[q+1]=A.y;Y[q+2]=A.z;Y[q+3]=A.w;Y[q+4]=B.x;Y[q+5]=B.y;Y[q+6]=B.z;Y[q+7]=B.w;Y[q+8]=E.x;Y[q+9]=E.y;Y[q+10]=E.z;Y[q+11]=E.w;Y[q+12]=S.x;Y[q+13]=S.y;Y[q+14]=S.z;Y[q+15]=S.w;A=Aa[s.a];B=Aa[s.b];E=Aa[s.c];S=Aa[s.d];X[q]=A.x;X[q+1]=A.y;X[q+2]=A.z;X[q+3]=A.w;X[q+4]=B.x;X[q+5]=B.y;X[q+6]=B.z;X[q+7]=B.w;X[q+8]=E.x;X[q+9]=E.y;X[q+10]=E.z;X[q+11]=E.w;X[q+12]=S.x;X[q+13]=S.y;X[q+14]=S.z;X[q+15]=S.w;A=ya[s.a];B=ya[s.b];E=ya[s.c];
-S=ya[s.d];V[q]=A.x;V[q+1]=A.y;V[q+2]=A.z;V[q+3]=1;V[q+4]=B.x;V[q+5]=B.y;V[q+6]=B.z;V[q+7]=1;V[q+8]=E.x;V[q+9]=E.y;V[q+10]=E.z;V[q+11]=1;V[q+12]=S.x;V[q+13]=S.y;V[q+14]=S.z;V[q+15]=1;A=za[s.a];B=za[s.b];E=za[s.c];S=za[s.d];W[q]=A.x;W[q+1]=A.y;W[q+2]=A.z;W[q+3]=1;W[q+4]=B.x;W[q+5]=B.y;W[q+6]=B.z;W[q+7]=1;W[q+8]=E.x;W[q+9]=E.y;W[q+10]=E.z;W[q+11]=1;W[q+12]=S.x;W[q+13]=S.y;W[q+14]=S.z;W[q+15]=1;q+=16}if(Ka&&va.length){A=va[s.a];B=va[s.b];E=va[s.c];S=va[s.d];ga[ba]=A.r;ga[ba+1]=A.g;ga[ba+2]=A.b;ga[ba+
-3]=B.r;ga[ba+4]=B.g;ga[ba+5]=B.b;ga[ba+6]=E.r;ga[ba+7]=E.g;ga[ba+8]=E.b;ga[ba+9]=S.r;ga[ba+10]=S.g;ga[ba+11]=S.b;ba+=12}if(Ja&&ja.hasTangents){A=ra[s.a].tangent;B=ra[s.b].tangent;E=ra[s.c].tangent;s=ra[s.d].tangent;U[T]=A.x;U[T+1]=A.y;U[T+2]=A.z;U[T+3]=A.w;U[T+4]=B.x;U[T+5]=B.y;U[T+6]=B.z;U[T+7]=B.w;U[T+8]=E.x;U[T+9]=E.y;U[T+10]=E.z;U[T+11]=E.w;U[T+12]=s.x;U[T+13]=s.y;U[T+14]=s.z;U[T+15]=s.w;T+=16}if(Ia)if(ma.length==4&&Na)for(s=0;s<4;s++){ea=ma[s];sa[Q]=ea.x;sa[Q+1]=ea.y;sa[Q+2]=ea.z;Q+=3}else for(s=
-0;s<4;s++){sa[Q]=ea.x;sa[Q+1]=ea.y;sa[Q+2]=ea.z;Q+=3}if(Ba&&na)for(s=0;s<4;s++){ma=na[s];Da[O]=ma.u;Da[O+1]=ma.v;O+=2}if(Ba&&da)for(s=0;s<4;s++){na=da[s];Ea[M]=na.u;Ea[M+1]=na.v;M+=2}if(Ha){ua[I]=u;ua[I+1]=u+1;ua[I+2]=u+2;ua[I+3]=u;ua[I+4]=u+2;ua[I+5]=u+3;I+=6;pa[oa]=u;pa[oa+1]=u+1;pa[oa+2]=u;pa[oa+3]=u+3;pa[oa+4]=u+1;pa[oa+5]=u+2;pa[oa+6]=u+2;pa[oa+7]=u+3;oa+=8;u+=4}}}if(Ga){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,fa,K)}if(Ka&&va.length){c.bindBuffer(c.ARRAY_BUFFER,
-r.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,ga,K)}if(Ia){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,sa,K)}if(Ja&&ja.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,U,K)}if(Ba&&O>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Da,K)}if(Ba&&M>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ea,K)}if(Ha){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);
-c.bufferData(c.ELEMENT_ARRAY_BUFFER,ua,K);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,pa,K)}if(q>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,V,K);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,W,K);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,X,K);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,Y,
-K)}}}g.__dirtyVertices=!1;g.__dirtyElements=!1;g.__dirtyUvs=!1;g.__dirtyNormals=!1;g.__dirtyTangents=!1;g.__dirtyColors=!1}else if(p instanceof THREE.Ribbon){g=p.geometry;if(g.__dirtyVertices||g.__dirtyColors){j=g;p=c.DYNAMIC_DRAW;u=void 0;u=void 0;v=void 0;r=void 0;O=j.vertices;K=j.colors;M=O.length;x=K.length;I=j.__vertexArray;z=j.__colorArray;Q=j.__dirtyColors;if(j.__dirtyVertices){for(u=0;u<M;u++){v=O[u].position;r=u*3;I[r]=v.x;I[r+1]=v.y;I[r+2]=v.z}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);
-c.bufferData(c.ARRAY_BUFFER,I,p)}if(Q){for(u=0;u<x;u++){color=K[u];r=u*3;z[r]=color.r;z[r+1]=color.g;z[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,z,p)}}g.__dirtyVertices=!1;g.__dirtyColors=!1}else if(p instanceof THREE.Line){g=p.geometry;if(g.__dirtyVertices||g.__dirtyColors){j=g;p=c.DYNAMIC_DRAW;u=void 0;u=void 0;v=void 0;r=void 0;O=j.vertices;K=j.colors;M=O.length;x=K.length;I=j.__vertexArray;z=j.__colorArray;Q=j.__dirtyColors;if(j.__dirtyVertices){for(u=
-0;u<M;u++){v=O[u].position;r=u*3;I[r]=v.x;I[r+1]=v.y;I[r+2]=v.z}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,I,p)}if(Q){for(u=0;u<x;u++){color=K[u];r=u*3;z[r]=color.r;z[r+1]=color.g;z[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,z,p)}}g.__dirtyVertices=!1;g.__dirtyColors=!1}else if(p instanceof THREE.ParticleSystem){g=p.geometry;(g.__dirtyVertices||g.__dirtyColors||p.sortParticles)&&b(g,c.DYNAMIC_DRAW,p);g.__dirtyVertices=
-!1;g.__dirtyColors=!1}}};this.setFaceCulling=function(f,l){if(f){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
-THREE.Snippets={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_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
-lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,d){d&&a.update(undefined,!1,b);d=a.sounds;var e,g=d.length;for(e=0;e<g;e++){a=d[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
+THREE.WebGLRenderer=function(a){function b(f,j,l){var h,i,t,p=f.vertices,s=p.length,A=f.colors,r=A.length,v=f.__vertexArray,J=f.__colorArray,P=f.__sortArray,N=f.__dirtyVertices,I=f.__dirtyColors;if(l.sortParticles){Ga.multiplySelf(l.matrixWorld);for(h=0;h<s;h++){i=p[h].position;Ba.copy(i);Ga.multiplyVector3(Ba);P[h]=[Ba.z,h]}P.sort(function(K,G){return G[0]-K[0]});for(h=0;h<s;h++){i=p[P[h][1]].position;t=h*3;v[t]=i.x;v[t+1]=i.y;v[t+2]=i.z}for(h=0;h<r;h++){t=h*3;color=A[P[h][1]];J[t]=color.r;J[t+1]=
+color.g;J[t+2]=color.b}}else{if(N)for(h=0;h<s;h++){i=p[h].position;t=h*3;v[t]=i.x;v[t+1]=i.y;v[t+2]=i.z}if(I)for(h=0;h<r;h++){color=A[h];t=h*3;J[t]=color.r;J[t+1]=color.g;J[t+2]=color.b}}if(N||l.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,v,j)}if(I||l.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,J,j)}}function d(f,j){f.fragmentShader=j.fragmentShader;f.vertexShader=j.vertexShader;f.uniforms=Uniforms.clone(j.uniforms)}
+function e(f,j,l,h,i){h.program||ta.initMaterial(h,j,l,i);var t=h.program,p=t.uniforms,s=h.uniforms;if(t!=na){c.useProgram(t);na=t;c.uniformMatrix4fv(p.projectionMatrix,!1,Pa)}if(l&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){s.fogColor.value.setHex(l.color.hex);if(l instanceof THREE.Fog){s.fogNear.value=l.near;s.fogFar.value=l.far}else if(l instanceof
+THREE.FogExp2)s.fogDensity.value=l.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var A,r,v=0,J=0,P=0,N,I,K,G=Qa,ha=G.directional.colors,u=G.directional.positions,da=G.point.colors,ba=G.point.positions,ga=0,y=0;l=r=r=0;for(A=j.length;l<A;l++){r=j[l];N=r.color;I=r.position;K=r.intensity;if(r instanceof THREE.AmbientLight){v+=N.r;J+=N.g;P+=N.b}else if(r instanceof THREE.DirectionalLight){r=ga*3;ha[r]=N.r*K;ha[r+1]=N.g*K;ha[r+2]=N.b*K;u[r]=I.x;u[r+1]=I.y;u[r+
+2]=I.z;ga+=1}else if(r instanceof THREE.PointLight){r=y*3;da[r]=N.r*K;da[r+1]=N.g*K;da[r+2]=N.b*K;ba[r]=I.x;ba[r+1]=I.y;ba[r+2]=I.z;y+=1}}for(l=ga*3;l<ha.length;l++)ha[l]=0;for(l=y*3;l<da.length;l++)da[l]=0;G.point.length=y;G.directional.length=ga;G.ambient[0]=v;G.ambient[1]=J;G.ambient[2]=P;j=Qa;s.enableLighting.value=j.directional.length+j.point.length;s.ambientLightColor.value=j.ambient;s.directionalLightColor.value=j.directional.colors;s.directionalLightDirection.value=j.directional.positions;
+s.pointLightColor.value=j.point.colors;s.pointLightPosition.value=j.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){s.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);s.opacity.value=h.opacity;s.map.texture=h.map;s.lightMap.texture=h.lightMap;s.envMap.texture=h.envMap;s.reflectivity.value=h.reflectivity;s.refractionRatio.value=h.refractionRatio;s.combine.value=h.combine;s.useRefract.value=
+h.envMap&&h.envMap.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){s.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);s.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){s.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);s.opacity.value=h.opacity;s.size.value=h.size;s.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){s.ambient.value.setRGB(h.ambient.r,h.ambient.g,
+h.ambient.b);s.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);s.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){s.mNear.value=f.near;s.mFar.value=f.far;s.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)s.opacity.value=h.opacity;for(var B in s)if(v=t.uniforms[B]){l=s[B];A=l.type;j=l.value;if(A=="i")c.uniform1i(v,j);else if(A=="f")c.uniform1f(v,j);else if(A=="fv1")c.uniform1fv(v,j);else if(A=="fv")c.uniform3fv(v,j);else if(A=="v2")c.uniform2f(v,
+j.x,j.y);else if(A=="v3")c.uniform3f(v,j.x,j.y,j.z);else if(A=="c")c.uniform3f(v,j.r,j.g,j.b);else if(A=="t"){c.uniform1i(v,j);if(l=l.texture)if(l.image instanceof Array&&l.image.length==6){if(l.image.length==6){if(l.needsUpdate){if(l.__wasSetOnce){c.bindTexture(c.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube);for(A=0;A<6;++A)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,0,0,c.RGBA,c.UNSIGNED_BYTE,l.image[A])}else{l.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube);
+for(A=0;A<6;++A)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+A,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,l.image[A]);l.__wasSetOnce=!0}V(c.TEXTURE_CUBE_MAP,l,l.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);l.needsUpdate=!1}c.activeTexture(c.TEXTURE0+j);c.bindTexture(c.TEXTURE_CUBE_MAP,l.image.__webGLTextureCube)}}else{if(l.needsUpdate){if(l.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,l.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,l.image)}else{l.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,
+l.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,l.image);l.__wasSetOnce=!0}V(c.TEXTURE_2D,l,l.image);c.bindTexture(c.TEXTURE_2D,null);l.needsUpdate=!1}c.activeTexture(c.TEXTURE0+j);c.bindTexture(c.TEXTURE_2D,l.__webGLTexture)}}}c.uniformMatrix4fv(p.modelViewMatrix,!1,i._modelViewMatrixArray);c.uniformMatrix3fv(p.normalMatrix,!1,i._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.envMap)&&c.uniform3f(p.cameraPosition,f.position.x,
+f.position.y,f.position.z);(h instanceof THREE.MeshShaderMaterial||h.envMap||h.skinning)&&c.uniformMatrix4fv(p.objectMatrix,!1,i._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&c.uniformMatrix4fv(p.viewMatrix,!1,Ja);if(h.skinning){c.uniformMatrix4fv(p.cameraInverseMatrix,!1,Ja);c.uniformMatrix4fv(p.boneGlobalMatrices,!1,i.boneMatrices)}return t}function g(f,j,l,h,i,t){f=e(f,j,l,h,t).attributes;c.bindBuffer(c.ARRAY_BUFFER,
+i.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(i.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUVBuffer);
+c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(h.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,
+!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(t instanceof THREE.Mesh)if(h.wireframe){c.lineWidth(h.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);c.drawElements(c.LINES,i.__webGLLineCount,
+c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(h.linewidth);c.drawArrays(t,0,i.__webGLLineCount)}else if(t instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,i.__webGLParticleCount);else t instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,i.__webGLVertexCount)}function m(f,j){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=
+c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(j.attributes.position);c.vertexAttribPointer(j.attributes.position,3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(j.attributes.normal);c.vertexAttribPointer(j.attributes.normal,
+3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function k(f){if(oa!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);oa=f.doubleSided}if(pa!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);pa=f.flipSided}}function o(f){if(Aa!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);Aa=f}}function n(f){qa[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);qa[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);qa[2].set(f.n41+f.n21,f.n42+f.n22,
+f.n43+f.n23,f.n44+f.n24);qa[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);qa[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);qa[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var j;for(f=0;f<6;f++){j=qa[f];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z*j.z))}}function w(f){for(var j=f.matrixWorld,l=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),h=0;h<6;h++){f=qa[h].x*j.n14+qa[h].y*j.n24+qa[h].z*j.n34+qa[h].w;if(f<=l)return!1}return!0}function z(f,
+j){f.list[f.count]=j;f.count+=1}function x(f){var j,l,h=f.object,i=f.opaque,t=f.transparent;t.count=0;f=i.count=0;for(j=h.materials.length;f<j;f++){l=h.materials[f];l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?z(t,l):z(i,l)}}function D(f){var j,l,h,i,t=f.object,p=f.buffer,s=f.opaque,A=f.transparent;A.count=0;f=s.count=0;for(h=t.materials.length;f<h;f++){j=t.materials[f];if(j instanceof THREE.MeshFaceMaterial){j=0;for(l=p.materials.length;j<l;j++)(i=p.materials[j])&&(i.opacity&&i.opacity<
+1||i.blending!=THREE.NormalBlending?z(A,i):z(s,i))}else{i=j;i.opacity&&i.opacity<1||i.blending!=THREE.NormalBlending?z(A,i):z(s,i)}}}function E(f,j){return j.z-f.z}function F(f,j){f._modelViewMatrix.multiplyToArray(j.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function H(f){function j(J){var P=[];l=0;for(h=J.length;l<h;l++)J[l]==undefined?P.push("undefined"):P.push(J[l].id);return P.join("_")}var l,
+h,i,t,p,s,A,r,v={};f.geometryGroups={};i=0;for(t=f.faces.length;i<t;i++){p=f.faces[i];s=p.materials;A=j(s);v[A]==undefined&&(v[A]={hash:A,counter:0});r=v[A].hash+"_"+v[A].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:s,vertices:0});p=p instanceof THREE.Face3?3:4;if(f.geometryGroups[r].vertices+p>65535){v[A].counter+=1;r=v[A].hash+"_"+v[A].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:s,vertices:0})}f.geometryGroups[r].faces.push(i);
+f.geometryGroups[r].vertices+=p}}function L(f,j,l){f.push({buffer:j,object:l,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(f){if(f!=za){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);
+c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}za=f}}function V(f,j,l){if((l.width&l.width-1)==0&&(l.height&l.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,Y(j.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,Y(j.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,Y(j.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Y(j.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,
+c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,aa(j.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,aa(j.minFilter))}}function X(f){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,
+c.TEXTURE_WRAP_S,Y(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,Y(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,Y(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,Y(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,Y(f.format),f.width,f.height,0,Y(f.format),Y(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,
+c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var j,l;if(f){j=f.__webGLFramebuffer;l=f.width;f=f.height}else{j=null;l=Ea;f=Fa}if(j!=la){c.bindFramebuffer(c.FRAMEBUFFER,j);c.viewport(va,Da,l,f);la=j}}function ca(f,j){var l;if(f=="fragment")l=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(l=c.createShader(c.VERTEX_SHADER));c.shaderSource(l,j);c.compileShader(l);if(!c.getShaderParameter(l,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(l));
+return null}return l}function aa(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return c.LINEAR}}function Y(f){switch(f){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 fa=document.createElement("canvas"),c,na=null,la=null,ta=this,oa=null,pa=null,za=null,Aa=null,va=0,Da=0,Ea=0,Fa=0,qa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Pa=new Float32Array(16),Ja=new Float32Array(16),
+Ba=new THREE.Vector4,Qa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Ra=!0,Sa=new THREE.Color(0),Ta=0;if(a){if(a.antialias!==undefined)Ra=a.antialias;a.clearColor!==undefined&&Sa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ta=a.clearAlpha}this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(f,j,l){try{if(!(c=fa.getContext("experimental-webgl",{antialias:f})))throw"Error creating WebGL context.";}catch(h){console.error(h)}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.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(j.r,j.g,j.b,l);_cullEnabled=!0})(Ra,Sa,Ta);this.context=c;this.setSize=function(f,j){fa.width=f;fa.height=j;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(f,j,l,h){va=f;Da=j;Ea=l;Fa=h;c.viewport(va,Da,Ea,Fa)};this.setScissor=function(f,j,l,h){c.scissor(f,j,l,h)};this.enableScissorTest=
+function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){c.depthMask(f)};this.setClearColorHex=function(f,j){var l=new THREE.Color(f);c.clearColor(l.r,l.g,l.b,j)};this.setClearColor=function(f,j){c.clearColor(f.r,f.g,f.b,j)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,j,l,h){var i;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,
+THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var t,p,s,A,r;t=A=r=0;for(p=j.length;t<p;t++){s=j[t];s instanceof THREE.DirectionalLight&&A++;s instanceof
+THREE.PointLight&&r++}if(r+A<=4)j=A;else{j=Math.ceil(4*A/(r+A));r=4-j}j={directional:j,point:r};t=50;if(h!==undefined&&h instanceof THREE.SkinnedMesh)t=h.bones.length;h=f.fragmentShader;r=f.vertexShader;t={fog:l,map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,skinning:f.skinning,maxDirLights:j.directional,maxPointLights:j.point,maxBones:t};l=c.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+
+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.lightMap?"#define USE_LIGHTMAP":"",t.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,"#define MAX_BONES "+t.maxBones,
+t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.lightMap?"#define USE_LIGHTMAP":"",t.vertexColors?"#define USE_COLOR":"",t.skinning?"#define USE_SKINNING":"","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 vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+c.attachShader(l,ca("fragment",j+h));c.attachShader(l,ca("vertex",t+r));c.linkProgram(l);c.getProgramParameter(l,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(l,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");l.uniforms={};l.attributes={};f.program=l;l=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(i in f.uniforms)l.push(i);i=f.program;h=0;for(r=l.length;h<
+r;h++){j=l[h];i.uniforms[j]=c.getUniformLocation(i,j)}i=f.program;l=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];h=0;for(r=l.length;h<r;h++){j=l[h];i.attributes[j]=c.getAttribLocation(i,j)}i=f.program.attributes;c.enableVertexAttribArray(i.position);i.color>=0&&c.enableVertexAttribArray(i.color);i.normal>=0&&c.enableVertexAttribArray(i.normal);i.tangent>=0&&c.enableVertexAttribArray(i.tangent);if(f.skinning&&i.skinVertexA>=0&&i.skinVertexB>=
+0&&i.skinIndex>=0&&i.skinWeight>=0){c.enableVertexAttribArray(i.skinVertexA);c.enableVertexAttribArray(i.skinVertexB);c.enableVertexAttribArray(i.skinIndex);c.enableVertexAttribArray(i.skinWeight)}};this.render=function(f,j,l,h){var i,t,p,s,A,r,v,J,P=f.lights,N=f.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Ja);j.projectionMatrix.flattenToArray(Pa);Ga.multiply(j.projectionMatrix,j.matrixWorldInverse);n(Ga);f.update(undefined,!1,j);this.initWebGLObjects(f);X(l);(this.autoClear||
+h)&&this.clear();A=f.__webglObjects.length;for(h=0;h<A;h++){i=f.__webglObjects[h];v=i.object;if(v.visible)if(!(v instanceof THREE.Mesh)||w(v)){v.matrixWorld.flattenToArray(v._objectMatrixArray);F(v,j);D(i);i.render=!0;if(this.sortObjects){Ba.copy(v.position);Ga.multiplyVector3(Ba);i.z=Ba.z}}else i.render=!1;else i.render=!1}this.sortObjects&&f.__webglObjects.sort(E);r=f.__webglObjectsImmediate.length;for(h=0;h<r;h++){i=f.__webglObjectsImmediate[h];v=i.object;if(v.visible){v.matrixAutoUpdate&&v.matrixWorld.flattenToArray(v._objectMatrixArray);
+F(v,j);x(i)}}M(THREE.NormalBlending);for(h=0;h<A;h++){i=f.__webglObjects[h];if(i.render){v=i.object;J=i.buffer;p=i.opaque;k(v);for(i=0;i<p.count;i++){s=p.list[i];o(s.depthTest);g(j,P,N,s,J,v)}}}for(h=0;h<r;h++){i=f.__webglObjectsImmediate[h];v=i.object;if(v.visible){p=i.opaque;k(v);for(i=0;i<p.count;i++){s=p.list[i];o(s.depthTest);t=e(j,P,N,s,v);v.render(function(I){m(I,t)})}}}for(h=0;h<A;h++){i=f.__webglObjects[h];if(i.render){v=i.object;J=i.buffer;p=i.transparent;k(v);for(i=0;i<p.count;i++){s=p.list[i];
+M(s.blending);o(s.depthTest);g(j,P,N,s,J,v)}}}for(h=0;h<r;h++){i=f.__webglObjectsImmediate[h];v=i.object;if(v.visible){p=i.transparent;k(v);for(i=0;i<p.count;i++){s=p.list[i];M(s.blending);o(s.depthTest);t=e(j,P,N,s,v);v.render(function(I){m(I,t)})}}}if(l&&l.minFilter!==THREE.NearestFilter&&l.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,l.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=
+[];f.__webglObjectsImmediate=[]}for(;f.__objectsAdded.length;){var j=f.__objectsAdded[0],l=f,h=void 0,i=void 0,t=void 0;if(j._modelViewMatrix==undefined){j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);j.matrixWorld.flattenToArray(j._objectMatrixArray)}if(j instanceof THREE.Mesh){i=j.geometry;i.geometryGroups==undefined&&H(i);for(h in i.geometryGroups){t=i.geometryGroups[h];if(!t.__webGLVertexBuffer){var p=
+t;p.__webGLVertexBuffer=c.createBuffer();p.__webGLNormalBuffer=c.createBuffer();p.__webGLTangentBuffer=c.createBuffer();p.__webGLColorBuffer=c.createBuffer();p.__webGLUVBuffer=c.createBuffer();p.__webGLUV2Buffer=c.createBuffer();p.__webGLSkinVertexABuffer=c.createBuffer();p.__webGLSkinVertexBBuffer=c.createBuffer();p.__webGLSkinIndicesBuffer=c.createBuffer();p.__webGLSkinWeightsBuffer=c.createBuffer();p.__webGLFaceBuffer=c.createBuffer();p.__webGLLineBuffer=c.createBuffer();p=t;var s=j,A=void 0,r=
+void 0,v=0,J=0,P=0,N=s.geometry.faces,I=p.faces;A=0;for(r=I.length;A<r;A++){fi=I[A];face=N[fi];if(face instanceof THREE.Face3){v+=3;J+=1;P+=3}else if(face instanceof THREE.Face4){v+=4;J+=2;P+=4}}p.__vertexArray=new Float32Array(v*3);p.__normalArray=new Float32Array(v*3);p.__tangentArray=new Float32Array(v*4);p.__colorArray=new Float32Array(v*3);p.__uvArray=new Float32Array(v*2);p.__uv2Array=new Float32Array(v*2);p.__skinVertexAArray=new Float32Array(v*4);p.__skinVertexBArray=new Float32Array(v*4);
+p.__skinIndexArray=new Float32Array(v*4);p.__skinWeightArray=new Float32Array(v*4);p.__faceArray=new Uint16Array(J*3);p.__lineArray=new Uint16Array(P*2);r=A=p;v=void 0;N=void 0;var K=void 0,G=void 0;K=void 0;I=!1;v=0;for(N=s.materials.length;v<N;v++){K=s.materials[v];if(K instanceof THREE.MeshFaceMaterial){K=0;for(G=r.materials.length;K<G;K++)if(r.materials[K]&&r.materials[K].shading!=undefined&&r.materials[K].shading==THREE.SmoothShading){I=!0;break}}else if(K&&K.shading!=undefined&&K.shading==THREE.SmoothShading){I=
+!0;break}if(I)break}A.__needsSmoothNormals=I;p.__webGLFaceCount=J*3;p.__webGLLineCount=P*2;i.__dirtyVertices=!0;i.__dirtyElements=!0;i.__dirtyUvs=!0;i.__dirtyNormals=!0;i.__dirtyTangents=!0;i.__dirtyColors=!0}L(l.__webglObjects,t,j)}}else if(j instanceof THREE.Ribbon){i=j.geometry;if(!i.__webGLVertexBuffer){h=i;h.__webGLVertexBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=i;t=h.vertices.length;h.__vertexArray=new Float32Array(t*3);h.__colorArray=new Float32Array(t*3);h.__webGLVertexCount=
+t;i.__dirtyVertices=!0;i.__dirtyColors=!0}L(l.__webglObjects,i,j)}else if(j instanceof THREE.Line){i=j.geometry;if(!i.__webGLVertexBuffer){h=i;h.__webGLVertexBuffer=c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=i;t=h.vertices.length;h.__vertexArray=new Float32Array(t*3);h.__colorArray=new Float32Array(t*3);h.__webGLLineCount=t;i.__dirtyVertices=!0;i.__dirtyColors=!0}L(l.__webglObjects,i,j)}else if(j instanceof THREE.ParticleSystem){i=j.geometry;if(!i.__webGLVertexBuffer){h=i;h.__webGLVertexBuffer=
+c.createBuffer();h.__webGLColorBuffer=c.createBuffer();h=i;t=h.vertices.length;h.__vertexArray=new Float32Array(t*3);h.__colorArray=new Float32Array(t*3);h.__sortArray=[];h.__webGLParticleCount=t;i.__dirtyVertices=!0;i.__dirtyColors=!0}L(l.__webglObjects,i,j)}else THREE.MarchingCubes!==undefined&&j instanceof THREE.MarchingCubes&&l.__webglObjectsImmediate.push({object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}for(;f.__objectsRemoved.length;){j=f.__objectsRemoved[0];
+l=f;i=void 0;h=void 0;for(i=l.__webglObjects.length-1;i>=0;i--){h=l.__webglObjects[i].object;j==h&&l.__webglObjects.splice(i,1)}f.__objectsRemoved.splice(0,1)}j=0;for(l=f.__webglObjects.length;j<l;j++){h=f.__webglObjects[j].object;t=void 0;i=void 0;p=void 0;if(h instanceof THREE.Mesh){i=h.geometry;for(t in i.geometryGroups){p=i.geometryGroups[t];if(i.__dirtyVertices||i.__dirtyElements||i.__dirtyUvs||i.__dirtyNormals||i.__dirtyColors||i.__dirtyTangents){J=c.DYNAMIC_DRAW;P=void 0;A=void 0;var ha=void 0,
+u=void 0,da=void 0,ba=void 0,ga=void 0;ha=void 0;var y=void 0,B=void 0,C=void 0,O=void 0;y=void 0;B=void 0;C=void 0;u=void 0;y=void 0;B=void 0;C=void 0;O=void 0;y=void 0;B=void 0;C=void 0;O=void 0;y=void 0;B=void 0;C=void 0;O=void 0;y=void 0;B=void 0;C=void 0;O=void 0;y=void 0;B=void 0;C=void 0;O=void 0;u=void 0;ba=void 0;da=void 0;ga=void 0;var ia=G=K=I=N=v=s=r=0,W=0,q=0,Z=p.__vertexArray,Ha=p.__uvArray,Ia=p.__uv2Array,ma=p.__normalArray,Q=p.__tangentArray,$=p.__colorArray,R=p.__skinVertexAArray,
+S=p.__skinVertexBArray,T=p.__skinIndexArray,U=p.__skinWeightArray,ra=p.__faceArray,ja=p.__lineArray,Ua=p.__needsSmoothNormals,ea=h.geometry,Ka=ea.__dirtyVertices,La=ea.__dirtyElements,Ca=ea.__dirtyUvs,Ma=ea.__dirtyNormals,Na=ea.__dirtyTangents,Oa=ea.__dirtyColors,ka=ea.vertices,Va=p.faces,Wa=ea.faces,Xa=ea.uvs,Ya=ea.uvs2,sa=ea.colors,wa=ea.skinVerticesA,xa=ea.skinVerticesB,ya=ea.skinIndices,ua=ea.skinWeights;P=0;for(A=Va.length;P<A;P++){ha=Va[P];u=Wa[ha];ga=Xa[ha];ha=Ya[ha];da=u.vertexNormals;ba=
+u.normal;if(u instanceof THREE.Face3){if(Ka){y=ka[u.a].position;B=ka[u.b].position;C=ka[u.c].position;Z[s]=y.x;Z[s+1]=y.y;Z[s+2]=y.z;Z[s+3]=B.x;Z[s+4]=B.y;Z[s+5]=B.z;Z[s+6]=C.x;Z[s+7]=C.y;Z[s+8]=C.z;s+=9}if(ua.length){y=ua[u.a];B=ua[u.b];C=ua[u.c];U[q]=y.x;U[q+1]=y.y;U[q+2]=y.z;U[q+3]=y.w;U[q+4]=B.x;U[q+5]=B.y;U[q+6]=B.z;U[q+7]=B.w;U[q+8]=C.x;U[q+9]=C.y;U[q+10]=C.z;U[q+11]=C.w;y=ya[u.a];B=ya[u.b];C=ya[u.c];T[q]=y.x;T[q+1]=y.y;T[q+2]=y.z;T[q+3]=y.w;T[q+4]=B.x;T[q+5]=B.y;T[q+6]=B.z;T[q+7]=B.w;T[q+8]=
+C.x;T[q+9]=C.y;T[q+10]=C.z;T[q+11]=C.w;y=wa[u.a];B=wa[u.b];C=wa[u.c];R[q]=y.x;R[q+1]=y.y;R[q+2]=y.z;R[q+3]=1;R[q+4]=B.x;R[q+5]=B.y;R[q+6]=B.z;R[q+7]=1;R[q+8]=C.x;R[q+9]=C.y;R[q+10]=C.z;R[q+11]=1;y=xa[u.a];B=xa[u.b];C=xa[u.c];S[q]=y.x;S[q+1]=y.y;S[q+2]=y.z;S[q+3]=1;S[q+4]=B.x;S[q+5]=B.y;S[q+6]=B.z;S[q+7]=1;S[q+8]=C.x;S[q+9]=C.y;S[q+10]=C.z;S[q+11]=1;q+=12}if(Oa&&sa.length){y=sa[u.a];B=sa[u.b];C=sa[u.c];$[W]=y.r;$[W+1]=y.g;$[W+2]=y.b;$[W+3]=B.r;$[W+4]=B.g;$[W+5]=B.b;$[W+6]=C.r;$[W+7]=C.g;$[W+8]=C.b;
+W+=9}if(Na&&ea.hasTangents){y=ka[u.a].tangent;B=ka[u.b].tangent;C=ka[u.c].tangent;Q[G]=y.x;Q[G+1]=y.y;Q[G+2]=y.z;Q[G+3]=y.w;Q[G+4]=B.x;Q[G+5]=B.y;Q[G+6]=B.z;Q[G+7]=B.w;Q[G+8]=C.x;Q[G+9]=C.y;Q[G+10]=C.z;Q[G+11]=C.w;G+=12}if(Ma)if(da.length==3&&Ua)for(u=0;u<3;u++){ba=da[u];ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}else for(u=0;u<3;u++){ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}if(Ca&&ga)for(u=0;u<3;u++){da=ga[u];Ha[v]=da.u;Ha[v+1]=da.v;v+=2}if(Ca&&ha)for(u=0;u<3;u++){ga=ha[u];Ia[N]=ga.u;Ia[N+1]=ga.v;
+N+=2}if(La){ra[I]=r;ra[I+1]=r+1;ra[I+2]=r+2;I+=3;ja[ia]=r;ja[ia+1]=r+1;ja[ia+2]=r;ja[ia+3]=r+2;ja[ia+4]=r+1;ja[ia+5]=r+2;ia+=6;r+=3}}else if(u instanceof THREE.Face4){if(Ka){y=ka[u.a].position;B=ka[u.b].position;C=ka[u.c].position;O=ka[u.d].position;Z[s]=y.x;Z[s+1]=y.y;Z[s+2]=y.z;Z[s+3]=B.x;Z[s+4]=B.y;Z[s+5]=B.z;Z[s+6]=C.x;Z[s+7]=C.y;Z[s+8]=C.z;Z[s+9]=O.x;Z[s+10]=O.y;Z[s+11]=O.z;s+=12}if(ua.length){y=ua[u.a];B=ua[u.b];C=ua[u.c];O=ua[u.d];U[q]=y.x;U[q+1]=y.y;U[q+2]=y.z;U[q+3]=y.w;U[q+4]=B.x;U[q+5]=
+B.y;U[q+6]=B.z;U[q+7]=B.w;U[q+8]=C.x;U[q+9]=C.y;U[q+10]=C.z;U[q+11]=C.w;U[q+12]=O.x;U[q+13]=O.y;U[q+14]=O.z;U[q+15]=O.w;y=ya[u.a];B=ya[u.b];C=ya[u.c];O=ya[u.d];T[q]=y.x;T[q+1]=y.y;T[q+2]=y.z;T[q+3]=y.w;T[q+4]=B.x;T[q+5]=B.y;T[q+6]=B.z;T[q+7]=B.w;T[q+8]=C.x;T[q+9]=C.y;T[q+10]=C.z;T[q+11]=C.w;T[q+12]=O.x;T[q+13]=O.y;T[q+14]=O.z;T[q+15]=O.w;y=wa[u.a];B=wa[u.b];C=wa[u.c];O=wa[u.d];R[q]=y.x;R[q+1]=y.y;R[q+2]=y.z;R[q+3]=1;R[q+4]=B.x;R[q+5]=B.y;R[q+6]=B.z;R[q+7]=1;R[q+8]=C.x;R[q+9]=C.y;R[q+10]=C.z;R[q+11]=
+1;R[q+12]=O.x;R[q+13]=O.y;R[q+14]=O.z;R[q+15]=1;y=xa[u.a];B=xa[u.b];C=xa[u.c];O=xa[u.d];S[q]=y.x;S[q+1]=y.y;S[q+2]=y.z;S[q+3]=1;S[q+4]=B.x;S[q+5]=B.y;S[q+6]=B.z;S[q+7]=1;S[q+8]=C.x;S[q+9]=C.y;S[q+10]=C.z;S[q+11]=1;S[q+12]=O.x;S[q+13]=O.y;S[q+14]=O.z;S[q+15]=1;q+=16}if(Oa&&sa.length){y=sa[u.a];B=sa[u.b];C=sa[u.c];O=sa[u.d];$[W]=y.r;$[W+1]=y.g;$[W+2]=y.b;$[W+3]=B.r;$[W+4]=B.g;$[W+5]=B.b;$[W+6]=C.r;$[W+7]=C.g;$[W+8]=C.b;$[W+9]=O.r;$[W+10]=O.g;$[W+11]=O.b;W+=12}if(Na&&ea.hasTangents){y=ka[u.a].tangent;
+B=ka[u.b].tangent;C=ka[u.c].tangent;u=ka[u.d].tangent;Q[G]=y.x;Q[G+1]=y.y;Q[G+2]=y.z;Q[G+3]=y.w;Q[G+4]=B.x;Q[G+5]=B.y;Q[G+6]=B.z;Q[G+7]=B.w;Q[G+8]=C.x;Q[G+9]=C.y;Q[G+10]=C.z;Q[G+11]=C.w;Q[G+12]=u.x;Q[G+13]=u.y;Q[G+14]=u.z;Q[G+15]=u.w;G+=16}if(Ma)if(da.length==4&&Ua)for(u=0;u<4;u++){ba=da[u];ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}else for(u=0;u<4;u++){ma[K]=ba.x;ma[K+1]=ba.y;ma[K+2]=ba.z;K+=3}if(Ca&&ga)for(u=0;u<4;u++){da=ga[u];Ha[v]=da.u;Ha[v+1]=da.v;v+=2}if(Ca&&ha)for(u=0;u<4;u++){ga=ha[u];Ia[N]=
+ga.u;Ia[N+1]=ga.v;N+=2}if(La){ra[I]=r;ra[I+1]=r+1;ra[I+2]=r+2;ra[I+3]=r;ra[I+4]=r+2;ra[I+5]=r+3;I+=6;ja[ia]=r;ja[ia+1]=r+1;ja[ia+2]=r;ja[ia+3]=r+3;ja[ia+4]=r+1;ja[ia+5]=r+2;ja[ia+6]=r+2;ja[ia+7]=r+3;ia+=8;r+=4}}}if(Ka){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Z,J)}if(Oa&&sa.length){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,$,J)}if(Ma){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ma,J)}if(Na&&
+ea.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,Q,J)}if(Ca&&v>0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ha,J)}if(Ca&&N>0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ia,J)}if(La){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ra,J);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ja,J)}if(q>0){c.bindBuffer(c.ARRAY_BUFFER,
+p.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,R,J);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,S,J);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,T,J);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,U,J)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(h instanceof THREE.Ribbon){i=h.geometry;if(i.__dirtyVertices||
+i.__dirtyColors){h=i;t=c.DYNAMIC_DRAW;r=void 0;r=void 0;s=void 0;p=void 0;v=h.vertices;J=h.colors;N=v.length;P=J.length;I=h.__vertexArray;A=h.__colorArray;K=h.__dirtyColors;if(h.__dirtyVertices){for(r=0;r<N;r++){s=v[r].position;p=r*3;I[p]=s.x;I[p+1]=s.y;I[p+2]=s.z}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,I,t)}if(K){for(r=0;r<P;r++){color=J[r];p=r*3;A[p]=color.r;A[p+1]=color.g;A[p+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,
+A,t)}}i.__dirtyVertices=!1;i.__dirtyColors=!1}else if(h instanceof THREE.Line){i=h.geometry;if(i.__dirtyVertices||i.__dirtyColors){h=i;t=c.DYNAMIC_DRAW;r=void 0;r=void 0;s=void 0;p=void 0;v=h.vertices;J=h.colors;N=v.length;P=J.length;I=h.__vertexArray;A=h.__colorArray;K=h.__dirtyColors;if(h.__dirtyVertices){for(r=0;r<N;r++){s=v[r].position;p=r*3;I[p]=s.x;I[p+1]=s.y;I[p+2]=s.z}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,I,t)}if(K){for(r=0;r<P;r++){color=J[r];p=r*
+3;A[p]=color.r;A[p+1]=color.g;A[p+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,h.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,A,t)}}i.__dirtyVertices=!1;i.__dirtyColors=!1}else if(h instanceof THREE.ParticleSystem){i=h.geometry;(i.__dirtyVertices||i.__dirtyColors||h.sortParticles)&&b(i,c.DYNAMIC_DRAW,h);i.__dirtyVertices=!1;i.__dirtyColors=!1}}};this.setFaceCulling=function(f,j){if(f){!j||j=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):
+c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.Snippets={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_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
+lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
-color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
+color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
 THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},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},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:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{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)}}};
 THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",

+ 0 - 1
examples/canvas_lights_pointlights.html

@@ -100,7 +100,6 @@
 			function animate() {
 
 				requestAnimationFrame( animate );
-
 				render();
 
 			}

+ 143 - 0
examples/misc_lookat.html

@@ -0,0 +1,143 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js misc - lookAt</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				color: #404040;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+
+				background-color: #ffffff;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+			}
+
+			a {
+
+				color: #0080bb;
+			}
+		</style>
+	</head>
+	<body>
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - Object3D::lookAt() demo</div>
+
+		<script type="text/javascript" src="../build/custom/ThreeWebGL.js"></script>
+		<script type="text/javascript" src="../build/custom/ThreeExtras.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, zmesh, lightMesh, geometry, target;
+
+			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 = 3200;
+
+				scene = new THREE.Scene();
+
+				var geometry = new Cube( 10, 10, 100 );
+				var material = new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } );
+
+				target = new THREE.Mesh( new Sphere( 100, 20, 20 ), material );
+				scene.addObject( target );
+
+				for ( var i = 0; i < 1000; i ++ ) {
+
+					var mesh = new THREE.Mesh( geometry, material );
+					mesh.position.x = Math.random() * 4000 - 2000;
+					mesh.position.y = Math.random() * 4000 - 2000;
+					mesh.position.z = Math.random() * 4000 - 2000;
+					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 4 + 2;
+
+					scene.addObject( mesh );
+
+				}
+
+				scene.matrixAutoUpdate = false;
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.sortObjects = false;
+				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 ) * 10;
+				mouseY = ( event.clientY - windowHalfY ) * 10;
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - mouseY - camera.position.y ) * .05;
+
+				var time = new Date().getTime() * 0.0005;
+
+				target.position.x = Math.sin( time * 0.7 ) * 2000;
+				target.position.y = Math.cos( time * 0.5 ) * 2000;
+				target.position.z = Math.cos( time * 0.3 ) * 2000;
+
+				for ( var i = 0, l = scene.objects.length; i < l; i ++ ) {
+
+					scene.objects[ i ].lookAt( target.position );
+
+				}
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 3 - 3
examples/misc_sound.html

@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html lang="en">
 	<head>
-		<title>three.js - misc - sound</title>
+		<title>three.js misc - sound</title>
 		<meta charset="utf-8">
 		<style type="text/css">
 			body {
@@ -226,7 +226,7 @@
 
 					// Render scene into texture
 
-					renderer.render( scene, camera, postprocessing.rtTexture1 );
+					renderer.render( scene, camera, postprocessing.rtTexture1, true );
 
 					// Render quad with blured scene into texture (convolution pass 1)
 
@@ -251,7 +251,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.3;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
 
 					// Render to screen
 

+ 1 - 0
examples/scenes/test_scene.js

@@ -131,6 +131,7 @@ var scene = {
 		"depth" : 10, 
 		"segmentsWidth"  : 1, 
 		"segmentsHeight" : 1,
+		"segmentsDepth"  : 1,
 		"flipped" : false, 
 		"sides"   : { "px": true, "nx": true, "py": true, "ny": true, "pz": true, "nz": true }
 	},

TEMPAT SAMPAH
examples/textures/758px-Canestra_di_frutta_(Caravaggio).jpg


+ 2 - 2
examples/webgl_lines_colors.html

@@ -298,7 +298,7 @@
 
 				// Render scene into texture
 
-				renderer.render( scene, camera, rtTexture1 );
+				renderer.render( scene, camera, rtTexture1, true );
 
 				// Render quad with blured scene into texture (convolution pass 1)
 
@@ -323,7 +323,7 @@
 				materialScreen.uniforms.tDiffuse.texture = rtTexture3;
 				materialScreen.uniforms.opacity.value = 1.3;
 
-				renderer.render( sceneScreen, cameraOrtho, rtTexture1, false );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture1 );
 
 				// Render to screen
 

+ 1 - 1
examples/webgl_materials_shaders_fresnel.html

@@ -5,7 +5,7 @@
 		<meta charset="utf-8">
 		<style type="text/css">
 			body {
-				background:#030;
+				background:#000;
 				padding:0;
 				margin:0;
 				font-weight: bold;

+ 273 - 0
examples/webgl_materials_texture_filters.html

@@ -0,0 +1,273 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js webgl - materials - texture filtering</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				color: #aaa;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+
+				background-color: #000;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+				z-index:100;
+			}
+			
+			.lbl { color:#fff; font-size:16px; font-weight:bold; position: absolute; bottom:0px; z-index:100; text-shadow:#000 1px 1px 1px; background-color:rgba(0,0,0,0.85); padding:1em }
+			#lbl_left { text-align:left; left:0px }
+			#lbl_right { text-align:left; right:0px }
+			
+			.g { color:#aaa }
+			.c { color:#fa0 }
+			
+			a { color:red }						
+			
+		</style>
+	</head>
+
+	<body>
+		<div id="info">
+			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - texture filtering example
+			- painting by <a href="http://en.wikipedia.org/wiki/Basket_of_Fruit_%28Caravaggio%29">Caravaggio</a>
+		</div>		
+		
+		<div id="lbl_left" class="lbl">
+		Floor <span class="g">(128x128)</span><br/>
+		mag: <span class="c">Linear</span><br/>
+		min: <span class="c">LinearMipMapLinear</span><br/>
+		<br/>
+		Painting <span class="g">(748x600)</span><br/>
+		mag: <span class="c">Linear</span><br/>
+		min: <span class="c">Linear</span>
+		</div>
+
+		<div id="lbl_right" class="lbl">
+		Floor <br/>
+		mag: <span class="c">Nearest</span><br/>
+		min: <span class="c">Nearest</span><br/>
+		<br/>
+		Painting <br/>
+		mag: <span class="c">Nearest</span><br/>
+		min: <span class="c">Nearest</span>
+		</div>
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript" src="js/Detector.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+			
+			var SCREEN_WIDTH = window.innerWidth;
+			var SCREEN_HEIGHT = window.innerHeight;
+
+			var container,stats;
+
+			var camera, scene, scene2, renderer;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			init();
+			animate();
+
+
+			function init() {
+
+				container = document.createElement('div');
+				document.body.appendChild(container);
+
+				camera = new THREE.Camera( 35, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 5000 );
+				camera.position.z = 1500;
+
+				scene = new THREE.Scene();
+				scene2 = new THREE.Scene();
+				
+				scene.fog = new THREE.Fog( 0x000000, 1500, 4000 );
+				scene2.fog = scene.fog;
+				
+				// GROUND
+
+				var imageCanvas = document.createElement( "canvas" ),
+					context = imageCanvas.getContext( "2d" );
+
+				imageCanvas.width = imageCanvas.height = 128;
+
+				context.fillStyle = "#444";
+				context.fillRect( 0, 0, 128, 128 );
+				context.fillStyle = "#fff";
+				context.fillRect( 0, 0, 64, 64);
+				context.fillRect( 64, 64, 64, 64 );
+				
+				var textureCanvas = new THREE.Texture( imageCanvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping );
+					materialCanvas = new THREE.MeshBasicMaterial( { map: textureCanvas } );
+
+				textureCanvas.needsUpdate = true;
+
+				var textureCanvas2 = new THREE.Texture( imageCanvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping, THREE.NearestFilter, THREE.NearestFilter );
+					materialCanvas2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: textureCanvas2 } );
+
+				textureCanvas2.needsUpdate = true;
+
+				var i, j, uvs,
+					geometryRepeat = new Plane( 100, 100, 1, 1 );
+					
+				for( i = 0; i < geometryRepeat.uvs.length; i++ ) {
+					
+					uvs = geometryRepeat.uvs[i];
+					
+					for ( j = 0; j < uvs.length; j++ ) {
+					
+						uvs[j].u *= 1000;
+						uvs[j].v *= 1000;
+
+					}
+
+				}
+				
+				
+				var meshCanvas = new THREE.Mesh( geometryRepeat, materialCanvas );
+				meshCanvas.rotation.x = Math.PI / 2;
+				meshCanvas.scale.x = meshCanvas.scale.y = meshCanvas.scale.z = 1000;
+				meshCanvas.doubleSided = true;
+				
+				var meshCanvas2 = new THREE.Mesh( geometryRepeat, materialCanvas2 );
+				meshCanvas2.rotation.x = Math.PI / 2;
+				meshCanvas2.scale.x = meshCanvas2.scale.y = meshCanvas2.scale.z = 1000;
+				meshCanvas2.doubleSided = true;
+				
+
+				// PAINTING
+				
+				var callbackPainting = function( image ) {
+				
+					texturePainting2.image = image;
+					texturePainting2.needsUpdate = true;
+
+					scene.addObject( meshCanvas );
+					scene2.addObject( meshCanvas2 );
+
+					var geometry = new Plane( 100, 100, 1, 1 ),
+						mesh = new THREE.Mesh( geometry, materialPainting ),
+						mesh2 = new THREE.Mesh( geometry, materialPainting2 );
+
+					addPainting( scene, mesh );
+					addPainting( scene2, mesh2 );
+					
+					function addPainting( zscene, zmesh ) {
+						
+						zmesh.scale.x = image.width / 100;
+						zmesh.scale.y = image.height / 100;
+
+						zscene.addObject( zmesh );
+
+						var meshFrame = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000 } )  );
+
+						meshFrame.position.z = -0.5;
+						meshFrame.scale.x = 1.1 * image.width / 100;
+						meshFrame.scale.y = 1.1 * image.height / 100;
+						
+						zscene.addObject( meshFrame );
+
+						var meshShadow = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.9 } )  );
+
+						meshShadow.position.z = - 1.1 * image.height/2;
+						meshShadow.scale.x = 1.1 * image.width / 100;
+						meshShadow.scale.y = 1.1 * image.height / 100;
+						meshShadow.rotation.x = -Math.PI / 2;
+						zscene.addObject( meshShadow );
+
+						meshShadow.position.y = - 1.1 * image.height/2;
+						
+						var floorHeight = - 1.117 * image.height/2;
+						meshCanvas.position.y = meshCanvas2.position.y = floorHeight;
+
+					}
+
+					
+				};
+				
+				var texturePainting = ImageUtils.loadTexture( "textures/758px-Canestra_di_frutta_(Caravaggio).jpg", THREE.UVMapping, callbackPainting ),
+					texturePainting2 = new THREE.Texture(),
+					materialPainting = new THREE.MeshBasicMaterial( { color:0xffffff, map: texturePainting } ),
+					materialPainting2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: texturePainting2 } );
+					
+				texturePainting2.minFilter = texturePainting2.magFilter = THREE.NearestFilter;
+				texturePainting.minFilter = texturePainting.magFilter = THREE.LinearFilter;
+
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
+				renderer.domElement.style.position = "relative";
+				container.appendChild( renderer.domElement );
+				
+				renderer.setClearColor( scene.fog.color, 1 );
+				renderer.autoClear = false;
+				
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.zIndex = 100;
+				//container.appendChild( stats.domElement );
+				
+				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			}
+
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX );
+				mouseY = ( event.clientY - windowHalfY );
+
+			}
+
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .05;
+				camera.position.y += ( - ( mouseY - 200) - camera.position.y ) * .05;
+
+				renderer.enableScissorTest( false );
+				renderer.clear();
+				renderer.enableScissorTest( true );
+				
+				//renderer.setViewport( 0, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
+				renderer.setScissor( 0, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT );
+				renderer.render( scene, camera );
+
+				
+				//renderer.setViewport( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2, SCREEN_HEIGHT );
+				renderer.setScissor( SCREEN_WIDTH/2, 0, SCREEN_WIDTH/2 - 2, SCREEN_HEIGHT  );
+				renderer.render( scene2, camera );
+				
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 2 - 2
examples/webgl_materials_video.html

@@ -328,7 +328,7 @@
 
 					// Render scene into texture
 
-					renderer.render( scene, camera, postprocessing.rtTexture1 );
+					renderer.render( scene, camera, postprocessing.rtTexture1, true );
 
 					// Render quad with blured scene into texture (convolution pass 1)
 
@@ -353,7 +353,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.3;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
 
 					// Render to screen
 

+ 0 - 33
examples/webgl_performance.html

@@ -144,8 +144,6 @@
 
 				}
 
-				scene.matrixAutoUpdate = false;
-
 				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortObjects = false;
@@ -159,37 +157,6 @@
 
 			}
 
-			function generateTexture( r, g, b ) {
-
-				var canvas = document.createElement( 'canvas' );
-				canvas.loaded = true;
-				canvas.width = 256;
-				canvas.height = 256;
-
-				var context = canvas.getContext( '2d' );
-				var image = context.getImageData( 0, 0, 256, 256 );
-
-				var x = 0, y = 0, p;
-
-				for ( var i = 0, j = 0, l = image.data.length; i < l; i += 4, j ++ ) {
-
-					x = j % 256;
-					y = x == 0 ? y + 1 : y;
-					p = Math.floor( x ^ y );
-
-					image.data[ i ] = ~~ p * r;
-					image.data[ i + 1 ] = ~~ p * g;
-					image.data[ i + 2 ] = ~~ p * b;
-					image.data[ i + 3 ] = 255;
-
-				}
-
-				context.putImageData( image, 0, 0 );
-
-				return canvas;
-
-			}
-
 			function onDocumentMouseMove(event) {
 
 				mouseX = ( event.clientX - windowHalfX ) * 10;

+ 2 - 2
examples/webgl_postprocessing.html

@@ -280,7 +280,7 @@
 
 				// background
 
-				renderer.render( sceneBG, cameraOrtho, rtTexture1 );
+				renderer.render( sceneBG, cameraOrtho, rtTexture1, true );
 
 				// model
 
@@ -305,7 +305,7 @@
 
 				materialScreen.uniforms.tDiffuse.texture = rtTexture3;
 				materialScreen.uniforms.opacity.value = 1.0;
-				renderer.render( sceneScreen, cameraOrtho, rtTexture1, false );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture1 );
 
 				// Render final scene to the screen with film shader
 

+ 2 - 2
examples/webgl_postprocessing_dof.html

@@ -305,7 +305,7 @@
 						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ materials[i] ];
 
 
-					renderer.render( scene, camera, postprocessing.rtTextureColor );
+					renderer.render( scene, camera, postprocessing.rtTextureColor, true );
 
 					// Render depth into texture
 
@@ -314,7 +314,7 @@
 					else
 						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ material_depth ];
 
-					renderer.render( scene, camera, postprocessing.rtTextureDepth );
+					renderer.render( scene, camera, postprocessing.rtTextureDepth, true );
 
 					// Render bokeh composite
 

+ 4 - 4
examples/webgl_ribbons.html

@@ -114,8 +114,8 @@
 				}
 
 				var tmpRot = new THREE.Matrix4();
-				tmpRot.setRotAxis( new THREE.Vector3( 1, 0, 0 ), 1.57 );
-				
+				tmpRot.setRotationAxis( new THREE.Vector3( 1, 0, 0 ), 1.57 );
+
 				var material_base = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } );
 
 				renderer.initMaterial( material_base, scene.lights, scene.fog );
@@ -323,7 +323,7 @@
 
 					// Render scene into texture
 
-					renderer.render( scene, camera, postprocessing.rtTexture1 );
+					renderer.render( scene, camera, postprocessing.rtTexture1, true );
 
 					// Render quad with blured scene into texture (convolution pass 1)
 
@@ -348,7 +348,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.2;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
 
 					// Render to screen
 

+ 3 - 3
examples/webgl_rtt.html

@@ -264,15 +264,15 @@
 
 				// Render first scene into texture
 
-				renderer.render( sceneRTT, cameraRTT, rtTexture );
+				renderer.render( sceneRTT, cameraRTT, rtTexture, true );
 
 				// Render full screen quad with generated texture
 				// (disable depth writing so that it stays in the background)
 
-				renderer.context.depthMask( 0 );
+				renderer.enableDepthBufferWrite( false );
 				renderer.render( sceneScreen, cameraRTT );
 				//renderer.render( sceneRTT, cameraRTT );
-				renderer.context.depthMask( 1 );
+				renderer.enableDepthBufferWrite( true );
 
 				// Render second scene to screen
 				// (using first scene as regular texture)

+ 0 - 1
examples/webgl_sandbox.html

@@ -205,7 +205,6 @@
 
 				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
-				// renderer.sortObjects = false;
 				container.appendChild( renderer.domElement );
 
 				if ( statsEnabled ) {

+ 4 - 4
src/animation/Animation.js

@@ -169,14 +169,14 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
 				object.skinMatrix = JIThierarchy[ h ][ frame ];
 				
 				object.matrixAutoUpdate = false;
-				object.matrixNeedsUpdate = false;
+				object.matrixWorldNeedsUpdate = false;
 			}
 			else {
 			
 				object.matrix = JIThierarchy[ h ][ frame ];
 				
 				object.matrixAutoUpdate = false;
-				object.matrixNeedsUpdate = true;
+				object.matrixWorldNeedsUpdate = true;
 			}
 			
 		// use interpolation
@@ -255,13 +255,13 @@ THREE.Animation.prototype.update = function( deltaTimeMS ) {
 
 
 				object.matrixAutoUpdate = true;
-				object.matrixNeedsUpdate = true;
+				object.matrixWorldNeedsUpdate = true;
 
 				scale = ( currentTime - prevKey.time ) / ( nextKey.time - prevKey.time );
 				prevXYZ = prevKey[ type ];
 				nextXYZ = nextKey[ type ];
 
-				
+
 				// check scale error
 
 				if ( scale < 0 || scale > 1 ) {

+ 23 - 129
src/cameras/Camera.js

@@ -3,58 +3,20 @@
  * @author mikael emtinger / http://gomo.se/
  */
 
-THREE.Camera = function( fov, aspect, near, far, target ) {
+THREE.Camera = function ( fov, aspect, near, far, target ) {
 
 	THREE.Object3D.call( this );
 
 	this.fov = fov || 50;
-	this.aspect = aspect || 1.0;
+	this.aspect = aspect || 1;
 	this.near = near || 0.1;
 	this.far = far || 2000;
 
-	// this.screenCenterX = 0;
-	// this.screenCenterY = 0;
-
 	this.target = target || new THREE.Object3D();
 	this.useTarget = true;
 
-	this.up = new THREE.Vector3( 0, 1, 0 );
-
 	this.matrixWorldInverse = new THREE.Matrix4();
-	this.projectionMatrix   = null;
-
-	// movement
-
-	this.tmpVec = new THREE.Vector3();
-
-	this.translateX = function ( amount, noFly ) {
-
-		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
-		this.tmpVec.crossSelf( this.up );
-
-		if ( noFly ) this.tmpVec.y = 0;
-
-		this.position.addSelf( this.tmpVec );
-		this.target.position.addSelf( this.tmpVec );
-
-	};
-
-	/* TODO
-	this.translateY = function ( amount ) {
-
-	};
-	*/
-
-	this.translateZ = function ( amount, noFly ) {
-
-		this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount );
-
-		if ( noFly ) this.tmpVec.y = 0;
-
-		this.position.subSelf( this.tmpVec );
-		this.target.position.subSelf( this.tmpVec );
-
-	};
+	this.projectionMatrix = null;
 
 	this.updateProjectionMatrix();
 
@@ -65,30 +27,30 @@ THREE.Camera.prototype.constructor = THREE.Camera;
 THREE.Camera.prototype.supr = THREE.Object3D.prototype;
 
 
-/*
- * Update projection matrix
- *
- * TODO: make it work also for ortho camera
-*/
+THREE.Camera.prototype.translate = function ( distance, axis ) {
 
-THREE.Camera.prototype.updateProjectionMatrix = function() {
+	this.matrix.rotateAxis( axis );
+	this.position.addSelf( axis.multiplyScalar( distance ) );
+	this.target.position.addSelf( axis.multiplyScalar( distance ) );
+
+}
+
+
+THREE.Camera.prototype.updateProjectionMatrix = function () {
 
 	this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
 
 }
 
 
-/*
- * Update
- */
-
 THREE.Camera.prototype.update = function( parentMatrixWorld, forceUpdate, camera ) {
 
-	if( this.useTarget ) {
+	if ( this.useTarget ) {
 
 		// local
 
 		this.matrix.lookAt( this.position, this.target.position, this.up );
+		this.matrix.setPosition( this.position );
 
 
 		// global
@@ -109,12 +71,15 @@ THREE.Camera.prototype.update = function( parentMatrixWorld, forceUpdate, camera
 
 	} else {
 
-		if( this.matrixAutoUpdate )
+		if ( this.matrixAutoUpdate ) {
+
 			forceUpdate |= this.updateMatrix();
 
-		if( forceUpdate || this.matrixNeedsUpdate ) {
+		}
+
+		if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
-			if( parentMatrixWorld ) {
+			if ( parentMatrixWorld ) {
 
 				this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
 
@@ -124,8 +89,8 @@ THREE.Camera.prototype.update = function( parentMatrixWorld, forceUpdate, camera
 
 			}
 
-			this.matrixNeedsUpdate = false;
-			forceUpdate            = true;
+			this.matrixWorldNeedsUpdate = false;
+			forceUpdate = true;
 
 			THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse );
 
@@ -135,81 +100,10 @@ THREE.Camera.prototype.update = function( parentMatrixWorld, forceUpdate, camera
 
 	// update children
 
-	for ( var i = 0; i < this.children.length; i++ ) {
+	for ( var i = 0; i < this.children.length; i ++ ) {
 
 		this.children[ i ].update( this.matrixWorld, forceUpdate, camera );
 
 	}
 
 };
-
-/*
- * FrustumContains
- * Checks object against projected image (as opposed to ordinary 3D frustum check)
- *
- * TODO: make it work also for ortho camera
- */
-
-/*
-THREE.Camera.prototype.frustumContains = function( object3D ) {
-
-	// object pos
-
-	var vx0 = object3D.matrixWorld.n14,
-	vy0 = object3D.matrixWorld.n24,
-	vz0 = object3D.matrixWorld.n34;
-
-	// check z
-
-	var inverse = this.matrixWorldInverse;
-	var radius = object3D.boundRadius * object3D.boundRadiusScale;
-	var vz1 = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 );
-
-	if( vz1 - radius > - this.near ) {
-
-		return false;
-
-	}
-
-	if( vz1 + radius < - this.far ) {
-
-		return false;
-
-	}
-
-	// check x
-
-	vz1 -= radius;
-
-	var perspective      = this.projectionMatrix;
-	var ooZ              = 1 / ( perspective.n43 * vz1 );
-	var ooZscreenCenterX = ooZ * this.screenCenterX;
-	var vx1              = ( inverse.n11 * vx0 + inverse.n12 * vy0 + inverse.n13 * vz0 + inverse.n14 ) * perspective.n11 * ooZscreenCenterX;
-	radius               = perspective.n11 * radius * ooZscreenCenterX;
-
-	if( vx1 + radius < -this.screenCenterX )
-		return false;
-
-	if( vx1 - radius > this.screenCenterX )
-		return false;
-
-
-	// check y
-
-	var vy1 = ( inverse.n21 * vx0 + inverse.n22 * vy0 + inverse.n23 * vz0 + inverse.n24 ) * perspective.n22 * ooZ * this.screenCenterY;
-
-	if( vy1 + radius < -this.screenCenterY )
-		return false;
-
-	if( vy1 - radius > this.screenCenterY )
-		return false;
-
-
-	// inside
-
-	object3D.positionScreen.set( vx1, vy1, vz1, radius );
-
-	return true;
-
-};
-*/

+ 57 - 40
src/cameras/QuakeCamera.js

@@ -9,45 +9,23 @@
  *  near: <float>,
  *  far: <float>,
  *  target: <THREE.Object3D>,
- 
+
  *  movementSpeed: <float>,
  *  lookSpeed: <float>,
- 
- *  noFly: <bool>, 
+
+ *  noFly: <bool>,
  *  lookVertical: <bool>,
  *  autoForward: <bool>,
- 
+
  *  heightSpeed: <bool>,
  *  heightCoef: <float>,
  *  heightMin: <float>,
  *  heightMax: <float>,
- 
- *  domElement: <HTMLElement>, 
+
+ *  domElement: <HTMLElement>,
  * }
  */
 
-function bind( scope, fn ) {
-
-	return function () {
-
-		fn.apply( scope, arguments );
-
-	};
-
-}
-
-function clamp_bottom( x, a ) {
-	
-	return x < a ? a : x;
-	
-};
-
-function clamp( x, a, b ) {
-	
-	return x < a ? a : ( x > b ? b : x );
-	
-};
-
 THREE.QuakeCamera = function ( parameters ) {
 
 	THREE.Camera.call( this, parameters.fov, parameters.aspect, parameters.near, parameters.far, parameters.target );
@@ -58,11 +36,11 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.noFly = false;
 	this.lookVertical = true;
 	this.autoForward = false;
-	
+
 	this.heightSpeed = false;
 	this.heightCoef = 1.0;
 	this.heightMin = 0.0;
-	
+
 	this.domElement = document;
 
 	if ( parameters ) {
@@ -71,9 +49,9 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( parameters.lookSpeed !== undefined ) this.lookSpeed  = parameters.lookSpeed;
 		if ( parameters.noFly !== undefined ) this.noFly = parameters.noFly;
 		if ( parameters.lookVertical !== undefined ) this.lookVertical = parameters.lookVertical;
-		
+
 		if ( parameters.autoForward !== undefined ) this.autoForward = parameters.autoForward;
-		
+
 		if ( parameters.heightSpeed !== undefined ) this.heightSpeed = parameters.heightSpeed;
 		if ( parameters.heightCoef !== undefined ) this.heightCoef = parameters.heightCoef;
 		if ( parameters.heightMin !== undefined ) this.heightMin = parameters.heightMin;
@@ -84,7 +62,7 @@ THREE.QuakeCamera = function ( parameters ) {
 	}
 
 	this.autoSpeedFactor = 0.0;
-	
+
 	this.mouseX = 0;
 	this.mouseY = 0;
 
@@ -182,19 +160,19 @@ THREE.QuakeCamera = function ( parameters ) {
 
 			var y = clamp( this.position.y, this.heightMin, this.heightMax ),
 				delta = y - this.heightMin;
-			
+
 			this.autoSpeedFactor = delta * this.heightCoef;
-			
+
 		} else {
-				
+
 			this.autoSpeedFactor = 0.0;
 
 		}
 
-		if ( this.moveForward || this.autoForward ) this.translateZ( - ( this.movementSpeed + this.autoSpeedFactor ), this.noFly );
-		if ( this.moveBackward ) this.translateZ( this.movementSpeed, this.noFly );
-		if ( this.moveLeft ) this.translateX( - this.movementSpeed, this.noFly );
-		if ( this.moveRight ) this.translateX( this.movementSpeed, this.noFly );
+		if ( this.moveForward || this.autoForward ) this.translateZ( - ( this.movementSpeed + this.autoSpeedFactor ) );
+		if ( this.moveBackward ) this.translateZ( this.movementSpeed );
+		if ( this.moveLeft ) this.translateX( - this.movementSpeed );
+		if ( this.moveRight ) this.translateX( this.movementSpeed );
 
 		this.lon += this.mouseX * this.lookSpeed;
 		if( this.lookVertical ) this.lat -= this.mouseY * this.lookSpeed;
@@ -223,8 +201,47 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.domElement.addEventListener( 'keydown', bind( this, this.onKeyDown ), false );
 	this.domElement.addEventListener( 'keyup', bind( this, this.onKeyUp ), false );
 
+	function bind( scope, fn ) {
+
+		return function () {
+
+			fn.apply( scope, arguments );
+
+		};
+
+	}
+
+	function clamp_bottom( x, a ) {
+
+		return x < a ? a : x;
+
+	};
+
+	function clamp( x, a, b ) {
+
+		return x < a ? a : ( x > b ? b : x );
+
+	};
+
 };
 
+
 THREE.QuakeCamera.prototype = new THREE.Camera();
 THREE.QuakeCamera.prototype.constructor = THREE.QuakeCamera;
 THREE.QuakeCamera.prototype.supr = THREE.Camera.prototype;
+
+
+THREE.QuakeCamera.prototype.translate = function ( distance, axis ) {
+
+	this.matrix.rotateAxis( axis );
+	
+	if ( this.noFly ) {
+		
+		axis.y = 0;
+
+	}
+	
+	this.position.addSelf( axis.multiplyScalar( distance ) );
+	this.target.position.addSelf( axis.multiplyScalar( distance ) );
+
+};

+ 2 - 2
src/core/Geometry.js

@@ -7,7 +7,7 @@
 
 THREE.Geometry = function () {
 
-	this.id = "Geometry" + THREE.GeometryIdCounter++;
+	this.id = "Geometry" + THREE.GeometryIdCounter ++;
 
 	this.vertices = [];
 	this.faces = [];
@@ -213,7 +213,7 @@ THREE.Geometry.prototype = {
 
 	},
 
-	computeTangents: function() {
+	computeTangents: function () {
 
 		// based on http://www.terathon.com/code/tangent.html
 		// tangents go to vertices

+ 2 - 2
src/core/Matrix3.js

@@ -6,7 +6,7 @@ THREE.Matrix3 = function () {
 
 THREE.Matrix3.prototype = {
 
-	transpose: function () {
+	transpose : function () {
 
 		var tmp, m = this.m;
 
@@ -18,7 +18,7 @@ THREE.Matrix3.prototype = {
 
 	},
 
-	transposeIntoArray: function ( r ) {
+	transposeIntoArray : function ( r ) {
 
 		var m = this.m;
 

+ 89 - 238
src/core/Matrix4.js

@@ -26,7 +26,7 @@ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33
 
 THREE.Matrix4.prototype = {
 
-	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+	set : function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 
 		this.n11 = n11; this.n12 = n12; this.n13 = n13; this.n14 = n14;
 		this.n21 = n21; this.n22 = n22; this.n23 = n23; this.n24 = n24;
@@ -37,7 +37,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	identity: function () {
+	identity : function () {
 
 		this.set(
 
@@ -52,7 +52,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	copy: function ( m ) {
+	copy : function ( m ) {
 
 		this.set(
 
@@ -67,9 +67,9 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	lookAt: function ( eye, center, up ) {
+	lookAt : function ( eye, center, up ) {
 
-		var x = THREE.Matrix4.__tmpVec1, y = THREE.Matrix4.__tmpVec2, z = THREE.Matrix4.__tmpVec3;
+		var x = THREE.Matrix4.__v1, y = THREE.Matrix4.__v2, z = THREE.Matrix4.__v3;
 
 		z.sub( eye, center ).normalize();
 		
@@ -89,14 +89,6 @@ THREE.Matrix4.prototype = {
 
 		y.cross( z, x ).normalize();
 
-//		if ( x.length() === 0 ) x.set( 1, 0, 0 );
-//		if ( y.length() === 0 ) y.set( 0, 1, 0 );
-
-/*		this.n11 = x.x; this.n12 = x.y; this.n13 = x.z; this.n14 = - x.dot( eye );
-		this.n21 = y.x; this.n22 = y.y; this.n23 = y.z; this.n24 = - y.dot( eye );
-		this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye );
-		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
-*/
 
 		this.n11 = x.x; this.n12 = y.x; this.n13 = z.x; this.n14 = eye.x;
 		this.n21 = x.y; this.n22 = y.y; this.n23 = z.y; this.n24 = eye.y;
@@ -106,7 +98,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	multiplyVector3: function ( v ) {
+	multiplyVector3 : function ( v ) {
 
 		var vx = v.x, vy = v.y, vz = v.z,
 		d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 );
@@ -119,16 +111,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	multiplyVector3OnlyZ: function( v ) {
-
-		var vx = v.x, vy = v.y, vz = v.z,
-		d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 );
-
-		return ( this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34 ) * d;
-
-	},
-
-	multiplyVector4: function ( v ) {
+	multiplyVector4 : function ( v ) {
 
 		var vx = v.x, vy = v.y, vz = v.z, vw = v.w;
 
@@ -141,7 +124,21 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	crossVector: function ( a ) {
+	rotateAxis : function ( v ) {
+
+		var vx = v.x, vy = v.y, vz = v.z;
+
+		v.x = vx * this.n11 + vy * this.n12 + vz * this.n13;
+		v.y = vx * this.n21 + vy * this.n22 + vz * this.n23;
+		v.z = vx * this.n31 + vy * this.n32 + vz * this.n33;
+
+		v.normalize();
+
+		return v;
+
+	},
+
+	crossVector : function ( a ) {
 
 		var v = new THREE.Vector4();
 
@@ -155,7 +152,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	multiply: function ( a, b ) {
+	multiply : function ( a, b ) {
 
 		var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14,
 		a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24,
@@ -167,28 +164,6 @@ THREE.Matrix4.prototype = {
 		b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34,
 		b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44;
 
-		/*
-		this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
-		this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
-		this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
-		this.n14 = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
-
-		this.n21 = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
-		this.n22 = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
-		this.n23 = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
-		this.n24 = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
-
-		this.n31 = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
-		this.n32 = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
-		this.n33 = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
-		this.n34 = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
-
-		this.n41 = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
-		this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
-		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
-		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
-		*/
-
 		this.n11 = a11 * b11 + a12 * b21 + a13 * b31;
 		this.n12 = a11 * b12 + a12 * b22 + a13 * b32;
 		this.n13 = a11 * b13 + a12 * b23 + a13 * b33;
@@ -209,22 +184,7 @@ THREE.Matrix4.prototype = {
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44;
 
-		return this;
-
-	},
-
-	multiplyToArray: function ( a, b, r ) {
-
-		var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14,
-		a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24,
-		a31 = a.n31, a32 = a.n32, a33 = a.n33, a34 = a.n34,
-		a41 = a.n41, a42 = a.n42, a43 = a.n43, a44 = a.n44,
-
-		b11 = b.n11, b12 = b.n12, b13 = b.n13, b14 = b.n14,
-		b21 = b.n21, b22 = b.n22, b23 = b.n23, b24 = b.n24,
-		b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34,
-		b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44;
-
+		/*
 		this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
 		this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
 		this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
@@ -244,74 +204,34 @@ THREE.Matrix4.prototype = {
 		this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
-
-		r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41;
-		r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42;
-		r[ 8 ]  = this.n13; r[ 9 ]  = this.n23; r[ 10 ] = this.n33; r[ 11 ] = this.n43;
-		r[ 12 ] = this.n14; r[ 13 ] = this.n24; r[ 14 ] = this.n34; r[ 15 ] = this.n44;
+		*/
 
 		return this;
 
 	},
 
-	multiplySelf: function ( m ) {
+	multiplyToArray : function ( a, b, r ) {
 
-		var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14,
-		n21 = this.n21, n22 = this.n22, n23 = this.n23, n24 = this.n24,
-		n31 = this.n31, n32 = this.n32, n33 = this.n33, n34 = this.n34,
-		n41 = this.n41, n42 = this.n42, n43 = this.n43, n44 = this.n44,
-		mn11 = m.n11, mn21 = m.n21, mn31 = m.n31, mn41 = m.n41,
-		mn12 = m.n12, mn22 = m.n22, mn32 = m.n32, mn42 = m.n42,
-		mn13 = m.n13, mn23 = m.n23, mn33 = m.n33, mn43 = m.n43,
-		mn14 = m.n14, mn24 = m.n24, mn34 = m.n34, mn44 = m.n44;
+		this.multiply( a, b );
 
-		/*
-		this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31 + n14 * mn41;
-		this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32 + n14 * mn42;
-		this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33 + n14 * mn43;
-		this.n14 = n11 * mn14 + n12 * mn24 + n13 * mn34 + n14 * mn44;
-
-		this.n21 = n21 * mn11 + n22 * mn21 + n23 * mn31 + n24 * mn41;
-		this.n22 = n21 * mn12 + n22 * mn22 + n23 * mn32 + n24 * mn42;
-		this.n23 = n21 * mn13 + n22 * mn23 + n23 * mn33 + n24 * mn43;
-		this.n24 = n21 * mn14 + n22 * mn24 + n23 * mn34 + n24 * mn44;
-
-		this.n31 = n31 * mn11 + n32 * mn21 + n33 * mn31 + n34 * mn41;
-		this.n32 = n31 * mn12 + n32 * mn22 + n33 * mn32 + n34 * mn42;
-		this.n33 = n31 * mn13 + n32 * mn23 + n33 * mn33 + n34 * mn43;
-		this.n34 = n31 * mn14 + n32 * mn24 + n33 * mn34 + n34 * mn44;
-
-		this.n41 = n41 * mn11 + n42 * mn21 + n43 * mn31 + n44 * mn41;
-		this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32 + n44 * mn42;
-		this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33 + n44 * mn43;
-		this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44 * mn44;
-		*/
+		r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41;
+		r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42;
+		r[ 8 ]  = this.n13; r[ 9 ]  = this.n23; r[ 10 ] = this.n33; r[ 11 ] = this.n43;
+		r[ 12 ] = this.n14; r[ 13 ] = this.n24; r[ 14 ] = this.n34; r[ 15 ] = this.n44;
 
-		this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31;
-		this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32;
-		this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33;
-		this.n14 = n11 * mn14 + n12 * mn24 + n13 * mn34 + n14;
+		return this;
 
-		this.n21 = n21 * mn11 + n22 * mn21 + n23 * mn31;
-		this.n22 = n21 * mn12 + n22 * mn22 + n23 * mn32;
-		this.n23 = n21 * mn13 + n22 * mn23 + n23 * mn33;
-		this.n24 = n21 * mn14 + n22 * mn24 + n23 * mn34 + n24;
+	},
 
-		this.n31 = n31 * mn11 + n32 * mn21 + n33 * mn31;
-		this.n32 = n31 * mn12 + n32 * mn22 + n33 * mn32;
-		this.n33 = n31 * mn13 + n32 * mn23 + n33 * mn33;
-		this.n34 = n31 * mn14 + n32 * mn24 + n33 * mn34 + n34;
+	multiplySelf : function ( m ) {
 
-		this.n41 = n41 * mn11 + n42 * mn21 + n43 * mn31;
-		this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32;
-		this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33;
-		this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44;
+		this.multiply( this, m );
 
 		return this;
 
 	},
 
-	multiplyScalar: function ( s ) {
+	multiplyScalar : function ( s ) {
 
 		this.n11 *= s; this.n12 *= s; this.n13 *= s; this.n14 *= s;
 		this.n21 *= s; this.n22 *= s; this.n23 *= s; this.n24 *= s;
@@ -322,7 +242,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	determinant: function () {
+	determinant : function () {
 
 		var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14,
 		n21 = this.n21, n22 = this.n22, n23 = this.n23, n24 = this.n24,
@@ -365,7 +285,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	transpose: function () {
+	transpose : function () {
 
 		var tmp;
 
@@ -381,7 +301,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	clone: function () {
+	clone : function () {
 
 		var m = new THREE.Matrix4();
 
@@ -394,14 +314,18 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	flatten: function () {
+	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;
 
-		this.flattenToArray( this.flat );
 		return this.flat;
 
 	},
 
-	flattenToArray: function ( flat ) {
+	flattenToArray : function ( flat ) {
 
 		flat[ 0 ] = this.n11; flat[ 1 ] = this.n21; flat[ 2 ] = this.n31; flat[ 3 ] = this.n41;
 		flat[ 4 ] = this.n12; flat[ 5 ] = this.n22; flat[ 6 ] = this.n32; flat[ 7 ] = this.n42;
@@ -412,7 +336,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	flattenToArrayOffset: function( flat, offset ) {
+	flattenToArrayOffset : function( flat, offset ) {
 
 		flat[ offset ] = this.n11;
 		flat[ offset + 1 ] = this.n21;
@@ -438,7 +362,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setTranslation: function( x, y, z ) {
+	setTranslation : function( x, y, z ) {
 
 		this.set(
 
@@ -453,7 +377,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setScale: function ( x, y, z ) {
+	setScale : function ( x, y, z ) {
 
 		this.set(
 
@@ -468,7 +392,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotX: function ( theta ) {
+	setRotationX : function ( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -485,7 +409,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotY: function( theta ) {
+	setRotationY : function( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -502,7 +426,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotZ: function( theta ) {
+	setRotationZ : function( theta ) {
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
@@ -519,7 +443,7 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setRotAxis: function( axis, angle ) {
+	setRotationAxis : function( axis, angle ) {
 
 		// Based on http://www.gamedev.net/reference/articles/article1199.asp
 
@@ -542,19 +466,19 @@ THREE.Matrix4.prototype = {
 
 	},
 
-	setPosition: function( vec3 ) {
+	setPosition : function( v ) {
 
-		this.n14 = vec3.x;
-		this.n24 = vec3.y;
-		this.n34 = vec3.z;
+		this.n14 = v.x;
+		this.n24 = v.y;
+		this.n34 = v.z;
 
 		return this;
 
 	},
 
-	setRotationFromEuler: function( vec3 ) {
+	setRotationFromEuler : function( v ) {
 
-		var x = vec3.x, y = vec3.y, z = vec3.z,
+		var x = v.x, y = v.y, z = v.z,
 		a = Math.cos( x ), b = Math.sin( x ),
 		c = Math.cos( y ), d = Math.sin( y ),
 		e = Math.cos( z ), f = Math.sin( z ),
@@ -572,11 +496,13 @@ THREE.Matrix4.prototype = {
 		this.n32 = ad * f + b * e;
 		this.n33 = a * c;
 
+		return this;
+
 	},
 
-	setRotationFromQuaternion: function( quat ) {
+	setRotationFromQuaternion : function( q ) {
 
-		var x = quat.x, y = quat.y, z = quat.z, w = quat.w,
+		var x = q.x, y = q.y, z = q.z, w = q.w,
 		x2 = x + x, y2 = y + y, z2 = z + z,
 		xx = x * x2, xy = x * y2, xz = x * z2,
 		yy = y * y2, yz = y * z2, zz = z * z2,
@@ -594,11 +520,13 @@ THREE.Matrix4.prototype = {
 		this.n32 = yz + wx;
 		this.n33 = 1 - ( xx + yy );
 
+		return this;
+
 	},
 
-	scale : function ( vec3 ) {
+	scale : function ( v ) {
 
-		var x = vec3.x, y = vec3.y, z = vec3.z;
+		var x = v.x, y = v.y, z = v.z;
 
 		this.n11 *= x; this.n12 *= y; this.n13 *= z;
 		this.n21 *= x; this.n22 *= y; this.n23 *= z;
@@ -607,67 +535,33 @@ THREE.Matrix4.prototype = {
 
 		return this;
 
-	}
-
-};
-
-THREE.Matrix4.translationMatrix = function ( x, y, z ) {
-
-	var m = new THREE.Matrix4();
-
-	m.setTranslation( x, y, z );
-
-	return m;
-
-};
-
-THREE.Matrix4.scaleMatrix = function ( x, y, z ) {
-
-	var m = new THREE.Matrix4();
-
-	m.setScale( x, y, z );
-
-	return m;
-
-};
-
-THREE.Matrix4.rotationXMatrix = function ( theta ) {
-
-	var m = new THREE.Matrix4();
-
-	m.setRotX( theta );
-
-	return m;
-
-};
-
-THREE.Matrix4.rotationYMatrix = function ( theta ) {
-
-	var m = new THREE.Matrix4();
-
-	m.setRotY( theta );
-
-	return m;
-
-};
+	},
 
-THREE.Matrix4.rotationZMatrix = function ( theta ) {
+	extractPosition : function ( m ) {
 
-	var m = new THREE.Matrix4();
+		this.n14 = m.n14;
+		this.n24 = m.n24;
+		this.n34 = m.n34;
 
-	m.setRotZ( theta );
+	},
 
-	return m;
+	extractRotation : function ( m, s ) {
 
-};
+		var invScaleX = 1 / s.x, invScaleY = 1 / s.y, invScaleZ = 1 / s.z;
 
-THREE.Matrix4.rotationAxisAngleMatrix = function ( axis, angle ) {
+		this.n11 = m.n11 * invScaleX;
+		this.n21 = m.n21 * invScaleX;
+		this.n31 = m.n31 * invScaleX;
 
-	var m = new THREE.Matrix4();
+		this.n12 = m.n12 * invScaleY;
+		this.n22 = m.n22 * invScaleY;
+		this.n32 = m.n32 * invScaleY;
 
-	m.setRotAxis( axis, angle );
+		this.n13 = m.n13 * invScaleZ;
+		this.n23 = m.n23 * invScaleZ;
+		this.n33 = m.n33 * invScaleZ;
 
-	return m;
+	}
 
 };
 
@@ -704,55 +598,12 @@ THREE.Matrix4.makeInvert = function ( m1, m2 ) {
 
 };
 
-/*
-THREE.Matrix4.makeInvert = function ( m1 ) {
-
-	var m2 = new THREE.Matrix4();
-
-	return THREE.Matrix4.makeInvertTo( m1, m2 );
-
-};
-
-THREE.Matrix4.makeInvertTo = function ( m1, m2 ) {
-
-	var n11 = m1.n11, n12 = m1.n12, n13 = m1.n13, n14 = m1.n14,
-		n21 = m1.n21, n22 = m1.n22, n23 = m1.n23, n24 = m1.n24,
-		n31 = m1.n31, n32 = m1.n32, n33 = m1.n33, n34 = m1.n34,
-		n41 = m1.n41, n42 = m1.n42, n43 = m1.n43, n44 = m1.n44;
-
-	//TODO: make this more efficient
-	//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
-
-	m2.n11 = n23*n34*n42 - n24*n33*n42 + n24*n32*n43 - n22*n34*n43 - n23*n32*n44 + n22*n33*n44;
-	m2.n12 = n14*n33*n42 - n13*n34*n42 - n14*n32*n43 + n12*n34*n43 + n13*n32*n44 - n12*n33*n44;
-	m2.n13 = n13*n24*n42 - n14*n23*n42 + n14*n22*n43 - n12*n24*n43 - n13*n22*n44 + n12*n23*n44;
-	m2.n14 = n14*n23*n32 - n13*n24*n32 - n14*n22*n33 + n12*n24*n33 + n13*n22*n34 - n12*n23*n34;
-	m2.n21 = n24*n33*n41 - n23*n34*n41 - n24*n31*n43 + n21*n34*n43 + n23*n31*n44 - n21*n33*n44;
-	m2.n22 = n13*n34*n41 - n14*n33*n41 + n14*n31*n43 - n11*n34*n43 - n13*n31*n44 + n11*n33*n44;
-	m2.n23 = n14*n23*n41 - n13*n24*n41 - n14*n21*n43 + n11*n24*n43 + n13*n21*n44 - n11*n23*n44;
-	m2.n24 = n13*n24*n31 - n14*n23*n31 + n14*n21*n33 - n11*n24*n33 - n13*n21*n34 + n11*n23*n34;
-	m2.n31 = n22*n34*n41 - n24*n32*n41 + n24*n31*n42 - n21*n34*n42 - n22*n31*n44 + n21*n32*n44;
-	m2.n32 = n14*n32*n41 - n12*n34*n41 - n14*n31*n42 + n11*n34*n42 + n12*n31*n44 - n11*n32*n44;
-	m2.n33 = n13*n24*n41 - n14*n22*n41 + n14*n21*n42 - n11*n24*n42 - n12*n21*n44 + n11*n22*n44;
-	m2.n34 = n14*n22*n31 - n12*n24*n31 - n14*n21*n32 + n11*n24*n32 + n12*n21*n34 - n11*n22*n34;
-	m2.n41 = n23*n32*n41 - n22*n33*n41 - n23*n31*n42 + n21*n33*n42 + n22*n31*n43 - n21*n32*n43;
-	m2.n42 = n12*n33*n41 - n13*n32*n41 + n13*n31*n42 - n11*n33*n42 - n12*n31*n43 + n11*n32*n43;
-	m2.n43 = n13*n22*n41 - n12*n23*n41 - n13*n21*n42 + n11*n23*n42 + n12*n21*n43 - n11*n22*n43;
-	m2.n44 = n12*n23*n31 - n13*n22*n31 + n13*n21*n32 - n11*n23*n32 - n12*n21*n33 + n11*n22*n33;
-	m2.multiplyScalar( 1 / m1.determinant() );
-
-	return m2;
-
-};
-*/
 THREE.Matrix4.makeInvert3x3 = function ( m1 ) {
 
 	// input:  THREE.Matrix4, output: THREE.Matrix3
 	// ( based on http://code.google.com/p/webgl-mjs/ )
 
-	var m33 = m1.m33,
-		m33m = m33.m,
-
+	var m33 = m1.m33, m33m = m33.m,
 	a11 =   m1.n33 * m1.n22 - m1.n32 * m1.n23,
 	a21 = - m1.n33 * m1.n21 + m1.n31 * m1.n23,
 	a31 =   m1.n32 * m1.n21 - m1.n31 * m1.n22,
@@ -837,6 +688,6 @@ THREE.Matrix4.makeOrtho = function ( left, right, top, bottom, near, far ) {
 
 };
 
-THREE.Matrix4.__tmpVec1 = new THREE.Vector3();
-THREE.Matrix4.__tmpVec2 = new THREE.Vector3();
-THREE.Matrix4.__tmpVec3 = new THREE.Vector3();
+THREE.Matrix4.__v1 = new THREE.Vector3();
+THREE.Matrix4.__v2 = new THREE.Vector3();
+THREE.Matrix4.__v3 = new THREE.Vector3();

+ 59 - 26
src/core/Object3D.js

@@ -6,21 +6,23 @@
 
 THREE.Object3D = function() {
 
-	this.id = THREE.Object3DCounter.value ++;
-
 	this.parent = undefined;
 	this.children = [];
 
+	this.up = new THREE.Vector3( 0, 1, 0 );
+
 	this.position = new THREE.Vector3();
-	this.positionScreen = new THREE.Vector4();
 	this.rotation = new THREE.Vector3();
-	this.scale = new THREE.Vector3( 1.0, 1.0, 1.0 );
+	this.scale = new THREE.Vector3( 1, 1, 1 );
+
+	this.rotationAutoUpdate = true;
 
 	this.matrix = new THREE.Matrix4();
 	this.matrixWorld = new THREE.Matrix4();
 	this.matrixRotationWorld = new THREE.Matrix4();
-	this.matrixNeedsUpdate = true;
+
 	this.matrixAutoUpdate = true;
+	this.matrixWorldNeedsUpdate = true;
 
 	this.quaternion = new THREE.Quaternion();
 	this.useQuaternion = false;
@@ -30,11 +32,52 @@ THREE.Object3D = function() {
 
 	this.visible = true;
 
+	this._vector = new THREE.Vector3();
+
 };
 
 
 THREE.Object3D.prototype = {
 
+	translate : function ( distance, axis ) {
+
+		this.matrix.rotateAxis( axis );
+		this.position.addSelf( axis.multiplyScalar( distance ) );
+
+	},
+
+	translateX : function ( distance ) {
+
+		this.translate( distance, this._vector.set( 1, 0, 0 ) );
+
+	},
+
+	translateY : function ( distance ) {
+
+		this.translate( distance, this._vector.set( 0, 1, 0 ) );
+
+	},
+
+	translateZ : function ( distance ) {
+
+		this.translate( distance, this._vector.set( 0, 0, 1 ) );
+
+	},
+
+	lookAt : function ( vector ) {
+
+		// TODO: Add hierarchy support.
+
+		this.matrix.lookAt( this.position, vector, this.up );
+
+		if ( this.rotationAutoUpdate ) {
+
+			this.rotation.setRotationFromMatrix( this.matrix );
+
+		}
+
+	},
+
 	addChild: function ( child ) {
 
 		if ( this.children.indexOf( child ) === - 1 ) {
@@ -52,12 +95,18 @@ THREE.Object3D.prototype = {
 
 			var scene = this;
 
-			while( scene instanceof THREE.Scene === false && scene !== undefined )
+			while ( scene instanceof THREE.Scene === false && scene !== undefined ) {
+
 				scene = scene.parent;
 
-			if( scene !== undefined ) 
+			}
+
+			if ( scene !== undefined )  {
+
 				scene.addChildRecurse( child );
 
+			}
+
 		}
 
 	},
@@ -112,7 +161,7 @@ THREE.Object3D.prototype = {
 
 			// update matrixWorld
 
-			if ( forceUpdate || this.matrixNeedsUpdate ) {
+			if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
 				if ( parentMatrixWorld ) {
 
@@ -124,23 +173,9 @@ THREE.Object3D.prototype = {
 
 				}
 
-				// extract rotation matrix
+				this.matrixRotationWorld.extractRotation( this.matrixWorld, this.scale );
 
-				var invScaleX = 1 / this.scale.x, invScaleY = 1 / this.scale.y, invScaleZ = 1 / this.scale.z;
-
-				this.matrixRotationWorld.n11 = this.matrixWorld.n11 * invScaleX;
-				this.matrixRotationWorld.n21 = this.matrixWorld.n21 * invScaleX;
-				this.matrixRotationWorld.n31 = this.matrixWorld.n31 * invScaleX;
-
-				this.matrixRotationWorld.n12 = this.matrixWorld.n12 * invScaleY;
-				this.matrixRotationWorld.n22 = this.matrixWorld.n22 * invScaleY;
-				this.matrixRotationWorld.n32 = this.matrixWorld.n32 * invScaleY;
-
-				this.matrixRotationWorld.n13 = this.matrixWorld.n13 * invScaleZ;
-				this.matrixRotationWorld.n23 = this.matrixWorld.n23 * invScaleZ;
-				this.matrixRotationWorld.n33 = this.matrixWorld.n33 * invScaleZ;
-
-				this.matrixNeedsUpdate = false;
+				this.matrixWorldNeedsUpdate = false;
 				forceUpdate = true;
 
 			}
@@ -158,5 +193,3 @@ THREE.Object3D.prototype = {
 	}
 
 }
-
-THREE.Object3DCounter = { value: 0 };

+ 31 - 3
src/core/Vector3.js

@@ -20,7 +20,7 @@ THREE.Vector3 = function ( x, y, z ) {
 
 THREE.Vector3.prototype = {
 
-	set: function ( x, y, z ) {
+	set : function ( x, y, z ) {
 
 		this.x = x;
 		this.y = y;
@@ -280,9 +280,37 @@ THREE.Vector3.prototype = {
 
 	},
 
-	setLength : function( len ) {
+	setPositionFromMatrix : function ( m ) {
 
-		return this.normalize().multiplyScalar( len );
+		this.x = m.n14;
+		this.y = m.n24;
+		this.z = m.n34;
+
+	},
+
+	setRotationFromMatrix : function ( m ) {
+
+		this.y = Math.asin( m.n13 );
+
+		var cosY = Math.cos( this.y );
+
+		if ( Math.abs( cosY ) > 0.00001 ) {
+
+			this.x = Math.atan2( - m.n23 / cosY, m.n33 / cosY );
+			this.z = Math.atan2( - m.n13 / cosY, m.n11 / cosY );
+
+		} else {
+
+			this.x = 0;
+			this.z = Math.atan2( m.n21, m.n22 );
+
+		}
+
+	},
+
+	setLength : function ( l ) {
+
+		return this.normalize().multiplyScalar( l );
 
 	},
 

+ 1 - 1
src/extras/SceneUtils.js

@@ -260,7 +260,7 @@ var SceneUtils = {
 
 				if ( g.type == "cube" ) {
 
-					geometry = new Cube( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, null, g.flipped, g.sides );
+					geometry = new Cube( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "plane" ) {

+ 2 - 2
src/objects/Bone.js

@@ -33,7 +33,7 @@ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera )
 
 	// update skin matrix
 
-	if ( forceUpdate || this.matrixNeedsUpdate ) {
+	if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
 		if( parentSkinMatrix ) {
 
@@ -45,7 +45,7 @@ THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera )
 
 		}
 
-		this.matrixNeedsUpdate = false;
+		this.matrixWorldNeedsUpdate = false;
 		forceUpdate = true;
 
 	}

+ 2 - 2
src/objects/LOD.js

@@ -60,7 +60,7 @@ THREE.LOD.prototype.update = function ( parentMatrixWorld, forceUpdate, camera )
 
 	// update global
 
-	if ( forceUpdate || this.matrixNeedsUpdate ) {
+	if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
 		if ( parentMatrixWorld ) {
 
@@ -72,7 +72,7 @@ THREE.LOD.prototype.update = function ( parentMatrixWorld, forceUpdate, camera )
 
 		}
 
-		this.matrixNeedsUpdate = false;
+		this.matrixWorldNeedsUpdate = false;
 		forceUpdate = true;
 
 	}

+ 2 - 12
src/objects/SkinnedMesh.js

@@ -17,7 +17,6 @@ THREE.SkinnedMesh = function( geometry, materials ) {
 	// init bones
 
 	this.identityMatrix = new THREE.Matrix4();
-
 	this.bones = [];
 	this.boneMatrices = [];
 
@@ -50,8 +49,6 @@ THREE.SkinnedMesh = function( geometry, materials ) {
 
 			}
 
-			bone.scale.set( 1, 1, 1 );
-
 		}
 
 		for ( b = 0; b < this.bones.length; b++ ) {
@@ -104,7 +101,7 @@ THREE.SkinnedMesh.prototype.update = function ( parentMatrixWorld, forceUpdate,
 
 		// update global
 
-		if ( forceUpdate || this.matrixNeedsUpdate ) {
+		if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
 			if ( parentMatrixWorld ) {
 
@@ -116,7 +113,7 @@ THREE.SkinnedMesh.prototype.update = function ( parentMatrixWorld, forceUpdate,
 
 			}
 
-			this.matrixNeedsUpdate = false;
+			this.matrixWorldNeedsUpdate = false;
 			forceUpdate = true;
 
 		}
@@ -211,11 +208,6 @@ THREE.SkinnedMesh.prototype.pose = function() {
 
 			orgVertex = this.geometry.vertices[ i ].position;
 
-		// 20, 23
-
-//			this.geometry.skinIndices[ i ].x = 23;
-	//		this.geometry.skinIndices[ i ].y = 23;
-			
 			var indexA = this.geometry.skinIndices[ i ].x;
 			var indexB = this.geometry.skinIndices[ i ].y;
 
@@ -236,8 +228,6 @@ THREE.SkinnedMesh.prototype.pose = function() {
 				this.geometry.skinWeights[ i ].y += len;
 
 			}
-		//		this.geometry.skinWeights[ i ].x = 1;
-			//	this.geometry.skinWeights[ i ].y = 0;
 
 		}
 

+ 2 - 2
src/objects/Sound.js

@@ -159,7 +159,7 @@ THREE.Sound.prototype.update = function ( parentMatrixWorld, forceUpdate, camera
 
 	// update global
 
-	if ( forceUpdate || this.matrixNeedsUpdate ) {
+	if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
 
 		if ( parentMatrixWorld ) {
 
@@ -171,7 +171,7 @@ THREE.Sound.prototype.update = function ( parentMatrixWorld, forceUpdate, camera
 
 		}
 
-		this.matrixNeedsUpdate = false;
+		this.matrixWorldNeedsUpdate = false;
 		forceUpdate = true;
 
 	}

+ 267 - 169
src/renderers/WebGLRenderer.js

@@ -33,6 +33,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_oldBlending = null,
 	_oldDepth = null,
 
+	_viewportX = 0,
+	_viewportY = 0,
+	_viewportWidth = 0,
+	_viewportHeight = 0,
+
 	// camera matrices caches
 
 	_frustum = [
@@ -50,6 +55,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	_vector3 = new THREE.Vector4(),
 
+	// light arrays cache
+	
+	_lights = {
+
+		ambient: 	 [ 0, 0, 0 ],
+		directional: { length: 0, colors: new Array(), positions: new Array() },
+		point: 		 { length: 0, colors: new Array(), positions: new Array() }
+
+	},
+
 	// parameters defaults
 
 	antialias = true,
@@ -66,7 +81,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.domElement = _canvas;
 	this.autoClear = true;
-	this.sortObjects = false;
+	this.sortObjects = true;
 
 	initGL( antialias, clearColor, clearAlpha );
 
@@ -74,22 +89,48 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	//alert( dumpObject( getGLParams() ) );
 
-	this.lights = {
-
-		ambient: 	 [ 0, 0, 0 ],
-		directional: { length: 0, colors: new Array(), positions: new Array() },
-		point: 		 { length: 0, colors: new Array(), positions: new Array() }
-
-	};
-
 	this.setSize = function ( width, height ) {
 
 		_canvas.width = width;
 		_canvas.height = height;
-		_gl.viewport( 0, 0, _canvas.width, _canvas.height );
+		
+		this.setViewport( 0, 0, _canvas.width, _canvas.height );
 
 	};
 
+	this.setViewport = function ( x, y, width, height ) {
+		
+		_viewportX = x;
+		_viewportY = y;
+		
+		_viewportWidth = width;
+		_viewportHeight = height;
+		
+		_gl.viewport( _viewportX, _viewportY, _viewportWidth, _viewportHeight );
+		
+	};
+	
+	this.setScissor = function ( x, y, width, height ) {
+
+		_gl.scissor( x, y, width, height );
+		
+	};
+	
+	this.enableScissorTest = function ( enable ) {
+		
+		if ( enable )
+			_gl.enable( _gl.SCISSOR_TEST );
+		else
+			_gl.disable( _gl.SCISSOR_TEST );
+		
+	};
+	
+	this.enableDepthBufferWrite = function ( enable ) {
+		
+		_gl.depthMask( enable );
+
+	};
+	
 	this.setClearColorHex = function ( hex, alpha ) {
 
 		var color = new THREE.Color( hex );
@@ -115,7 +156,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		var l, ll, light, r = 0, g = 0, b = 0,
 			color, position, intensity,
 
-			zlights = _this.lights,
+			zlights = _lights,
 
 			dcolors    = zlights.directional.colors,
 			dpositions = zlights.directional.positions,
@@ -210,7 +251,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function createMeshBuffers( geometryGroup ) {
+	function createMeshBuffers ( geometryGroup ) {
 
 		geometryGroup.__webGLVertexBuffer = _gl.createBuffer();
 		geometryGroup.__webGLNormalBuffer = _gl.createBuffer();
@@ -229,7 +270,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function initLineBuffers( geometry ) {
+	function initLineBuffers ( geometry ) {
 
 		var nvertices = geometry.vertices.length;
 
@@ -240,7 +281,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function initRibbonBuffers( geometry ) {
+	function initRibbonBuffers ( geometry ) {
 
 		var nvertices = geometry.vertices.length;
 
@@ -251,7 +292,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function initParticleBuffers( geometry ) {
+	function initParticleBuffers ( geometry ) {
 
 		var nvertices = geometry.vertices.length;
 
@@ -264,7 +305,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function initMeshBuffers( geometryGroup, object ) {
+	function initMeshBuffers ( geometryGroup, object ) {
 
 		var f, fl, nvertices = 0, ntris = 0, nlines = 0,
 			obj_faces = object.geometry.faces,
@@ -315,7 +356,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setMeshBuffers( geometryGroup, object, hint ) {
+	function setMeshBuffers ( geometryGroup, object, hint ) {
 
 		var f, fl, fi, face, vertexNormals, faceNormal, normal,
 			uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4,
@@ -897,7 +938,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if( dirtyElements ) {
+				if ( dirtyElements ) {
 
 					faceArray[ offset_face ]     = vertexIndex;
 					faceArray[ offset_face + 1 ] = vertexIndex + 1;
@@ -1001,7 +1042,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setLineBuffers( geometry, hint ) {
+	function setLineBuffers ( geometry, hint ) {
 
 		var v, c, vertex, offset,
 			vertices = geometry.vertices,
@@ -1055,7 +1096,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setRibbonBuffers( geometry, hint ) {
+	function setRibbonBuffers ( geometry, hint ) {
 
 		var v, c, vertex, offset,
 			vertices = geometry.vertices,
@@ -1109,7 +1150,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setParticleBuffers( geometry, hint, object ) {
+	function setParticleBuffers ( geometry, hint, object ) {
 
 		var v, c, vertex, offset,
 			vertices = geometry.vertices,
@@ -1221,7 +1262,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setMaterialShaders( material, shaders ) {
+	function setMaterialShaders ( material, shaders ) {
 
 		material.fragmentShader = shaders.fragmentShader;
 		material.vertexShader = shaders.vertexShader;
@@ -1229,7 +1270,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function refreshUniformsCommon( uniforms, material ) {
+	function refreshUniformsCommon ( uniforms, material ) {
 
 		// premultiply alpha
 		uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
@@ -1250,14 +1291,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function refreshUniformsLine( uniforms, material ) {
+	function refreshUniformsLine ( uniforms, material ) {
 
 		uniforms.diffuse.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
 		uniforms.opacity.value = material.opacity;
 
 	};
 
-	function refreshUniformsParticle( uniforms, material ) {
+	function refreshUniformsParticle ( uniforms, material ) {
 
 		uniforms.psColor.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
 		uniforms.opacity.value = material.opacity;
@@ -1266,7 +1307,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function refreshUniformsFog( uniforms, fog ) {
+	function refreshUniformsFog ( uniforms, fog ) {
 
 		uniforms.fogColor.value.setHex( fog.color.hex );
 
@@ -1283,7 +1324,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function refreshUniformsPhong( uniforms, material ) {
+	function refreshUniformsPhong ( uniforms, material ) {
 
 		//uniforms.ambient.value.setHex( material.ambient.hex );
 		//uniforms.specular.value.setHex( material.specular.hex );
@@ -1294,7 +1335,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	};
 
 
-	function refreshUniformsLights( uniforms, lights ) {
+	function refreshUniformsLights ( uniforms, lights ) {
 
 		uniforms.enableLighting.value = lights.directional.length + lights.point.length;
 		uniforms.ambientLightColor.value = lights.ambient;
@@ -1305,9 +1346,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	this.initMaterial = function( material, lights, fog ) {
+	this.initMaterial = function ( material, lights, fog, object ) {
 
-		var u, identifiers, parameters, maxLightCount;
+		var u, identifiers, parameters, maxLightCount, maxBones;
 
 		if ( material instanceof THREE.MeshDepthMaterial ) {
 
@@ -1344,9 +1385,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		maxLightCount = allocateLights( lights, 4 );
 
+		maxBones = allocateBones( object );
+		
 		parameters = { fog: fog, map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors,
 					   skinning: material.skinning,
-					   maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point };
+					   maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point,
+					   maxBones: maxBones };
 
 		material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters );
 
@@ -1385,9 +1429,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setProgram( camera, lights, fog, material, object ) {
+	function setProgram ( camera, lights, fog, material, object ) {
 
-		if ( !material.program ) _this.initMaterial( material, lights, fog );
+		if ( !material.program ) _this.initMaterial( material, lights, fog, object );
 
 		var program = material.program,
 			p_uniforms = program.uniforms,
@@ -1420,7 +1464,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			 material instanceof THREE.MeshLambertMaterial ) {
 
 			setupLights( program, lights );
-			refreshUniformsLights( m_uniforms, _this.lights );
+			refreshUniformsLights( m_uniforms, _lights );
 
 		}
 
@@ -1501,7 +1545,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function renderBuffer( camera, lights, fog, material, geometryGroup, object ) {
+	function renderBuffer ( camera, lights, fog, material, geometryGroup, object ) {
 
 		var program, attributes, linewidth, primitives;
 
@@ -1641,7 +1685,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function renderBufferImmediate( object, program ) {
+	function renderBufferImmediate ( object, program ) {
 
 		if ( ! object.__webGLVertexBuffer ) object.__webGLVertexBuffer = _gl.createBuffer();
 		if ( ! object.__webGLNormalBuffer ) object.__webGLNormalBuffer = _gl.createBuffer();
@@ -1670,7 +1714,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setObjectFaces( object ) {
+	function setObjectFaces ( object ) {
 
 		if ( _oldDoubleSided != object.doubleSided ) {
 
@@ -1706,7 +1750,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setDepthTest( test ) {
+	function setDepthTest ( test ) {
 
 		if ( _oldDepth != test ) {
 
@@ -1726,7 +1770,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function computeFrustum( m ) {
+	function computeFrustum ( m ) {
 
 		_frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 );
 		_frustum[ 1 ].set( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 );
@@ -1746,7 +1790,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function isInFrustum( object ) {
+	function isInFrustum ( object ) {
 
 		var distance, matrix = object.matrixWorld,
 		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
@@ -1762,14 +1806,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function addToFixedArray( where, what ) {
+	function addToFixedArray ( where, what ) {
 
 		where.list[ where.count ] = what;
 		where.count += 1;
 
 	};
 
-	function unrollImmediateBufferMaterials( globject ) {
+	function unrollImmediateBufferMaterials ( globject ) {
 
 		var i, l, m, ml, material,
 			object = globject.object,
@@ -1792,7 +1836,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function unrollBufferMaterials( globject ) {
+	function unrollBufferMaterials ( globject ) {
 
 		var i, l, m, ml, material, meshMaterial,
 			object = globject.object,
@@ -1845,13 +1889,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 	};
 
 
-	function painterSort( a, b ) {
+	function painterSort ( a, b ) {
 
 		return b.z - a.z;
 
 	};
 
-	this.render = function( scene, camera, renderTarget, clear ) {
+	this.render = function ( scene, camera, renderTarget, forceClear ) {
 
 		var i, program, opaque, transparent, material,
 			o, ol, oil, webglObject, object, buffer,
@@ -1869,11 +1913,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		scene.update( undefined, false, camera );
 
-		this.initWebGLObjects( scene, camera );
+		this.initWebGLObjects( scene );
 
-		setRenderTarget( renderTarget, clear !== undefined ? clear : true );
+		setRenderTarget( renderTarget );
 
-		if ( this.autoClear ) {
+		if ( this.autoClear || forceClear ) {
 
 			this.clear();
 
@@ -2077,14 +2121,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setupMatrices( object, camera ) {
+	function setupMatrices ( object, camera ) {
 
 		object._modelViewMatrix.multiplyToArray( camera.matrixWorldInverse, object.matrixWorld, object._modelViewMatrixArray );
 		THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray );
 
 	};
 
-	this.initWebGLObjects = function ( scene, camera ) {
+	this.initWebGLObjects = function ( scene ) {
 
 		if ( !scene.__webglObjects ) {
 
@@ -2093,32 +2137,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		while ( scene.__objectsRemoved.length ) {
+		while ( scene.__objectsAdded.length ) {
 
-			removeObject( scene.__objectsRemoved[ 0 ], scene );
-			scene.__objectsRemoved.splice( 0, 1 );
+			addObject( scene.__objectsAdded[ 0 ], scene );
+			scene.__objectsAdded.splice( 0, 1 );
 
 		}
 
-		while ( scene.__objectsAdded.length ) {
+		while ( scene.__objectsRemoved.length ) {
 
-			addObject( scene.__objectsAdded[ 0 ], scene );
-			scene.__objectsAdded.splice( 0, 1 );
+			removeObject( scene.__objectsRemoved[ 0 ], scene );
+			scene.__objectsRemoved.splice( 0, 1 );
 
 		}
 
 		// update must be called after objects adding / removal
-		
+
 		for ( var o = 0, ol = scene.__webglObjects.length; o < ol; o ++ ) {
 
-			updateObject( scene.__webglObjects[ o ], scene );
+			updateObject( scene.__webglObjects[ o ].object, scene );
 
 		}
-		
 
 	};
 
-	function addObject( object, scene ) {
+	function addObject ( object, scene ) {
 
 		var g, geometry, geometryGroup;
 
@@ -2134,8 +2177,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		objlist = scene.__webglObjects;
-
 		if ( object instanceof THREE.Mesh ) {
 
 			geometry = object.geometry;
@@ -2170,7 +2211,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				// create separate wrapper per each use of VBO
 
-				addBuffer( objlist, geometryGroup, object );
+				addBuffer( scene.__webglObjects, geometryGroup, object );
 
 			}
 
@@ -2188,7 +2229,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
-			addBuffer( objlist, geometry, object );
+			addBuffer( scene.__webglObjects, geometry, object );
 
 		} else if ( object instanceof THREE.Line ) {
 
@@ -2204,7 +2245,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
-			addBuffer( objlist, geometry, object );
+			addBuffer( scene.__webglObjects, geometry, object );
 
 		} else if ( object instanceof THREE.ParticleSystem ) {
 
@@ -2220,7 +2261,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			}
 
-			addBuffer( objlist, geometry, object );
+			addBuffer( scene.__webglObjects, geometry, object );
 
 		} else if ( THREE.MarchingCubes !== undefined && object instanceof THREE.MarchingCubes ) {
 
@@ -2232,11 +2273,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function updateObject( webGLObject, scene ) {
-
-		var g, geometry, geometryGroup, webGLObject, object;
+	function updateObject ( object, scene ) {
 
-		object = webGLObject.object;
+		var g, geometry, geometryGroup;
 
 		if ( object instanceof THREE.Mesh ) {
 
@@ -2314,7 +2353,25 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function sortFacesByMaterial( geometry ) {
+	function removeObject ( object, scene ) {
+
+		var o, ol, zobject;
+
+		for ( o = scene.__webglObjects.length - 1; o >= 0; o-- ) {
+
+			zobject = scene.__webglObjects[ o ].object;
+
+			if ( object == zobject ) {
+
+				scene.__webglObjects.splice( o, 1 );
+
+			}
+
+		}
+
+	};
+
+	function sortFacesByMaterial ( geometry ) {
 
 		// TODO
 		// Should optimize by grouping faces with ColorFill / ColorStroke materials
@@ -2390,7 +2447,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function addBuffer( objlist, buffer, object ) {
+	function addBuffer ( objlist, buffer, object ) {
 
 		objlist.push( { buffer: buffer, object: object,
 				opaque: { list: [], count: 0 },
@@ -2399,7 +2456,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function addBufferImmediate( objlist, object ) {
+	function addBufferImmediate ( objlist, object ) {
 
 		objlist.push( { object: object,
 				opaque: { list: [], count: 0 },
@@ -2408,25 +2465,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function removeObject( object, scene ) {
-
-		var o, ol, zobject;
-
-		for ( o = scene.__webglObjects.length - 1; o >= 0; o-- ) {
-
-			zobject = scene.__webglObjects[ o ].object;
-
-			if ( object == zobject ) {
-
-				scene.__webglObjects.splice( o, 1 );
-
-			}
-
-		}
-
-	};
-
-	this.setFaceCulling = function( cullFace, frontFace ) {
+	this.setFaceCulling = function ( cullFace, frontFace ) {
 
 		if ( cullFace ) {
 
@@ -2464,30 +2503,31 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	this.supportsVertexTextures = function() {
+	this.supportsVertexTextures = function () {
 
 		return maxVertexTextures() > 0;
 
 	};
 
-	function maxVertexTextures() {
+	function maxVertexTextures () {
 
 		return _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
 
 	};
 
-	function initGL( antialias, clearColor, clearAlpha ) {
+	function initGL ( antialias, clearColor, clearAlpha ) {
 
 		try {
 
-			_gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } );
+			if ( ! ( _gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } ) ) ) {
+
+				throw 'Error creating WebGL context.';
 
-		} catch(e) { console.log(e) }
+			}
 
-		if (!_gl) {
+		} catch ( e ) {
 
-			// alert("WebGL not supported");
-			throw "cannot create webgl context";
+			console.error( e );
 
 		}
 
@@ -2509,7 +2549,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function buildProgram( fragmentShader, vertexShader, parameters ) {
+	function buildProgram ( fragmentShader, vertexShader, parameters ) {
 
 		var program = _gl.createProgram(),
 
@@ -2540,6 +2580,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			"#define MAX_DIR_LIGHTS " + parameters.maxDirLights,
 			"#define MAX_POINT_LIGHTS " + parameters.maxPointLights,
 
+			"#define MAX_BONES " + parameters.maxBones,
+
 			parameters.map ? "#define USE_MAP" : "",
 			parameters.envMap ? "#define USE_ENVMAP" : "",
 			parameters.lightMap ? "#define USE_LIGHTMAP" : "",
@@ -2593,21 +2635,21 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function loadUniformsSkinning( uniforms, object ) {
+	function loadUniformsSkinning ( uniforms, object ) {
 
 		_gl.uniformMatrix4fv( uniforms.cameraInverseMatrix, false, _viewMatrixArray );
 		_gl.uniformMatrix4fv( uniforms.boneGlobalMatrices, false, object.boneMatrices );
 
 	};
 
-	function loadUniformsMatrices( uniforms, object ) {
+	function loadUniformsMatrices ( uniforms, object ) {
 
 		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
 		_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray );
 
 	};
 
-	function loadUniformsGeneric( program, uniforms ) {
+	function loadUniformsGeneric ( program, uniforms ) {
 
 		var u, uniform, value, type, location, texture;
 
@@ -2673,7 +2715,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setBlending( blending ) {
+	function setBlending ( blending ) {
 
 		if ( blending != _oldBlending ) {
 
@@ -2721,93 +2763,109 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setCubeTexture( texture, slot ) {
+	function setTextureParameters ( textureType, texture, image ) {
 
-		if ( texture.image.length == 6 ) {
+		if ( isPowerOfTwo( image.width ) && isPowerOfTwo( image.height ) ) {
 
-			if ( texture.needsUpdate ) {
+			_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
+			_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrapT ) );
 
-				if ( !texture.image.__webGLTextureCube ) {
+			_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( texture.magFilter ) );
+			_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( texture.minFilter ) );
 
-					texture.image.__webGLTextureCube = _gl.createTexture();
+			_gl.generateMipmap( textureType );
 
-				}
+		} else {
 
-				_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
+			_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
+			_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
+			
+			_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
+			_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
 
-				_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
-				_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
+		}
 
-				_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MAG_FILTER, _gl.LINEAR );
-				_gl.texParameteri( _gl.TEXTURE_CUBE_MAP, _gl.TEXTURE_MIN_FILTER, _gl.LINEAR_MIPMAP_LINEAR );
+	};
+	
+	function setTexture ( texture, slot ) {
 
-				for ( var i = 0; i < 6; ++i ) {
+		if ( texture.needsUpdate ) {
 
-					_gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
+			if ( !texture.__wasSetOnce ) {
 
-				}
+				texture.__webGLTexture = _gl.createTexture();
 
-				_gl.generateMipmap( _gl.TEXTURE_CUBE_MAP );
+				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
+				_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
 
-				_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, null );
+				texture.__wasSetOnce = true;
 
-				texture.needsUpdate = false;
+			} else {
+
+				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
+				_gl.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
 
 			}
 
-			_gl.activeTexture( _gl.TEXTURE0 + slot );
-			_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
+			setTextureParameters( _gl.TEXTURE_2D, texture, texture.image );
+			_gl.bindTexture( _gl.TEXTURE_2D, null );
+			
+			texture.needsUpdate = false;
 
 		}
 
+		_gl.activeTexture( _gl.TEXTURE0 + slot );
+		_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
+
 	};
 
-	function setTexture( texture, slot ) {
+	function setCubeTexture ( texture, slot ) {
 
-		if ( texture.needsUpdate ) {
+		if ( texture.image.length == 6 ) {
 
-			if ( !texture.__wasSetOnce ) {
+			if ( texture.needsUpdate ) {
+				
+				if ( !texture.__wasSetOnce ) {
 
-				texture.__webGLTexture = _gl.createTexture();
+					texture.image.__webGLTextureCube = _gl.createTexture();
 
-				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
-				_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
+					_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
 
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrapT ) );
+					for ( var i = 0; i < 6; ++i ) {
 
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( texture.magFilter ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( texture.minFilter ) );
-				_gl.generateMipmap( _gl.TEXTURE_2D );
-				_gl.bindTexture( _gl.TEXTURE_2D, null );
+						_gl.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
 
-				texture.__wasSetOnce = true;
+					}
+				
+					texture.__wasSetOnce = true;
 
-			} else {
+				} else {
 
-				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
-				_gl.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
+					_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
+
+					for ( var i = 0; i < 6; ++i ) {
 
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrapT ) );
+						_gl.texSubImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, 0, 0, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image[ i ] );
 
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( texture.magFilter ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( texture.minFilter ) );
-				_gl.generateMipmap( _gl.TEXTURE_2D );
-				_gl.bindTexture( _gl.TEXTURE_2D, null );
+					}
+
+				}
+
+				setTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, texture.image[0] );
+				_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, null );
 
+				texture.needsUpdate = false;
+				
 			}
 
-			texture.needsUpdate = false;
+			_gl.activeTexture( _gl.TEXTURE0 + slot );
+			_gl.bindTexture( _gl.TEXTURE_CUBE_MAP, texture.image.__webGLTextureCube );
 
 		}
 
-		_gl.activeTexture( _gl.TEXTURE0 + slot );
-		_gl.bindTexture( _gl.TEXTURE_2D, texture.__webGLTexture );
-
 	};
 
-	function setRenderTarget( renderTexture, clear ) {
+	function setRenderTarget ( renderTexture ) {
 
 		if ( renderTexture && !renderTexture.__webGLFramebuffer ) {
 
@@ -2854,21 +2912,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 		} else {
 
 			framebuffer = null;
-			width = _canvas.width;
-			height = _canvas.height;
+			width = _viewportWidth;
+			height = _viewportHeight;
 
 		}
 
 		if( framebuffer != _oldFramebuffer ) {
 
 			_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
-			_gl.viewport( 0, 0, width, height );
-
-			if ( clear ) {
-
-				_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );
-
-			}
+			_gl.viewport( _viewportX, _viewportY, width, height );
 
 			_oldFramebuffer = framebuffer;
 
@@ -2876,7 +2928,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function updateRenderTargetMipmap( renderTarget ) {
+	function updateRenderTargetMipmap ( renderTarget ) {
 
 		_gl.bindTexture( _gl.TEXTURE_2D, renderTarget.__webGLTexture );
 		_gl.generateMipmap( _gl.TEXTURE_2D );
@@ -2884,7 +2936,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function cacheUniformLocations( program, identifiers ) {
+	function cacheUniformLocations ( program, identifiers ) {
 
 		var i, l, id;
 
@@ -2897,7 +2949,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function cacheAttributeLocations( program, identifiers ) {
+	function cacheAttributeLocations ( program, identifiers ) {
 
 		var i, l, id;
 
@@ -2910,7 +2962,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function getShader( type, string ) {
+	function getShader ( type, string ) {
 
 		var shader;
 
@@ -2938,7 +2990,25 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function paramThreeToGL( p ) {
+	// fallback filters for non-power-of-2 textures
+	
+	function filterFallback ( f ) {
+		
+		switch ( f ) {
+
+			case THREE.NearestFilter:
+			case THREE.NearestMipMapNearestFilter:
+			case THREE.NearestMipMapLinearFilter: return _gl.NEAREST; break;
+
+			case THREE.LinearFilter:
+			case THREE.LinearMipMapNearestFilter:
+			case THREE.LinearMipMapLinearFilter: return _gl.LINEAR; break;
+
+		}
+		
+	};
+	
+	function paramThreeToGL ( p ) {
 
 		switch ( p ) {
 
@@ -2974,13 +3044,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function materialNeedsSmoothNormals( material ) {
+	function isPowerOfTwo ( value ) {
+
+		return ( value & ( value - 1 ) ) == 0;
+
+	};
+
+	function materialNeedsSmoothNormals ( material ) {
 
 		return material && material.shading != undefined && material.shading == THREE.SmoothShading;
 
 	};
 
-	function bufferNeedsSmoothNormals( geometryGroup, object ) {
+	function bufferNeedsSmoothNormals ( geometryGroup, object ) {
 
 		var m, ml, i, l, meshMaterial, needsSmoothNormals = false;
 
@@ -3020,7 +3096,29 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function allocateLights( lights, maxLights ) {
+	function allocateBones ( object ) {
+		
+		// default for when object is not specified
+		// ( for example when prebuilding shader
+		//   to be used with multiple objects )
+		//
+		// 	- leave some extra space for other uniforms
+		//  - limit here is ANGLE's 254 max uniform vectors
+		//    (up to 54 should be safe)
+		
+		var maxBones = 50;
+		
+		if ( object !== undefined && object instanceof THREE.SkinnedMesh ) {
+			
+			maxBones = object.bones.length;
+
+		}
+
+		return maxBones;
+		
+	};
+	
+	function allocateLights ( lights, maxLights ) {
 
 		var l, ll, light, dirLights, pointLights, maxDirLights, maxPointLights;
 		dirLights = pointLights = maxDirLights = maxPointLights = 0;
@@ -3511,7 +3609,7 @@ THREE.Snippets = {
 
 	"#ifdef USE_SKINNING",
 
-		"uniform mat4 boneGlobalMatrices[20];",
+		"uniform mat4 boneGlobalMatrices[ MAX_BONES ];",
 
 	"#endif"
 

+ 0 - 822
src/renderers/WebGLRenderer2.js

@@ -1,822 +0,0 @@
-/**
- * @author mrdoob / http://mrdoob.com/
- *
- * Based on code by:
- * @author alteredq / http://alteredqualia.com/
- * @author supereggbert / http://www.paulbrunt.co.uk/
- */
-
-THREE.WebGLRenderer2 = function ( antialias ) {
-
-	var _renderList = null,
-	_projector = new THREE.Projector(),
-
-	_canvas = document.createElement( 'canvas' ),
-
-	_clearColor = new THREE.Color( 0x000000 ),
-	_clearOpacity = 0,
-
-	_gl, _currentProgram,
-
-	_modelViewMatrix = new THREE.Matrix4(),
-	_normalMatrix = new THREE.Matrix4(),
-	_viewMatrixArray = new Float32Array( 16 ),
-	_modelViewMatrixArray = new Float32Array( 16 ),
-	_projectionMatrixArray = new Float32Array( 16 ),
-	_normalMatrixArray = new Float32Array( 9 ),
-	_objectMatrixArray = new Float32Array( 16 );
-
-	try {
-
-		antialias = antialias !== undefined ? antialias : true;
-		_gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } );
-
-	} catch(e) { }
-
-	if ( !_gl ) {
-
-		alert("WebGL not supported");
-		throw "cannot create webgl context";
-
-	}
-
-	_gl.clearColor( 0, 0, 0, 1 );
-	_gl.clearDepth( 1 );
-
-	_gl.enable( _gl.DEPTH_TEST );
-	_gl.depthFunc( _gl.LEQUAL );
-
-	_gl.frontFace( _gl.CCW );
-	_gl.cullFace( _gl.BACK );
-	_gl.enable( _gl.CULL_FACE );
-
-	_gl.enable( _gl.BLEND );
-	_gl.blendFunc( _gl.ONE, _gl.ONE_MINUS_SRC_ALPHA );
-	_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
-
-	this.domElement = _canvas;
-
-	this.autoClear = true;
-	this.sortObjects = true;
-
-	this.setSize = function ( width, height ) {
-
-		_canvas.width = width;
-		_canvas.height = height;
-		_gl.viewport( 0, 0, _canvas.width, _canvas.height );
-
-	};
-
-	this.setClearColor = function( color, opacity ) {
-
-		_clearColor = color;
-		_clearOpacity = opacity;
-
-		_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
-
-	};
-
-	this.setClearColorHex = function( hex, opacity ) {
-
-		_clearColor.setHex( hex );
-		_clearOpacity = opacity;
-
-		_gl.clearColor( _clearColor.r, _clearColor.g, _clearColor.b, _clearOpacity );
-
-	};
-
-	this.clear = function () {
-
-		_gl.clear( _gl.COLOR_BUFFER_BIT | _gl.DEPTH_BUFFER_BIT );
-
-	};
-
-	this.render = function( scene, camera ) {
-
-		var o, ol;
-
-		this.autoClear && this.clear();
-
-		camera.matrixAutoUpdate && camera.update();
-
-		// Setup camera matrices
-
-		_viewMatrixArray.set( camera.matrixWorld.flatten() );
-		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
-
-		_currentProgram = null;
-
-		/*
-		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
-
-			renderObject( scene.objects[ o ] );
-
-		}
-		*/
-
-		scene.update( undefined, false, camera );
-
-		_renderList = _projector.projectObjects( scene, camera, this.sortObjects );
-
-		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
-
-			renderObject( _renderList[ o ].object );
-
-		}
-
-		function renderObject( object ) {
-
-			var geometry, material, m, ml,
-			program, uniforms, attributes;
-
-			object.matrixAutoUpdate && object.updateMatrix();
-
-			// Setup object matrices
-
-			object.matrixWorld.flattenToArray( _objectMatrixArray )
-
-			_modelViewMatrix.multiply( camera.matrixWorld, object.matrixWorld );
-			_modelViewMatrix.flattenToArray( _modelViewMatrixArray );
-
-			_normalMatrix = THREE.Matrix4.makeInvert3x3( _modelViewMatrix ).transpose();
-			_normalMatrixArray.set( _normalMatrix.m );
-
-			if ( object instanceof THREE.Mesh ) {
-
-				geometry = object.geometry;
-
-				if ( geometry.__webglBuffers == undefined ) {
-
-					if ( buildBuffers( geometry ) == false ) return;
-
-				}
-
-				for ( m = 0, ml = object.materials.length; m < ml; m ++ ) {
-
-					material = object.materials[ m ];
-
-					if ( material.__webglProgram == undefined ) {
-
-						if ( createProgram( material ) == false ) continue;
-
-					}
-
-					program = material.__webglProgram;
-					uniforms = program.uniforms;
-					attributes = program.attributes;
-
-					if( program != _currentProgram ) {
-
-						_currentProgram = program;
-
-						_gl.useProgram( program );
-
-						// scene
-
-						if ( scene.fog ) {
-
-							_gl.uniform1f( uniforms.fog, 1 );
-							_gl.uniform1f( uniforms.fogNear, scene.fog.near );
-							_gl.uniform1f( uniforms.fogFar, scene.fog.far );
-							_gl.uniform3f( uniforms.fogColor, scene.fog.color.r, scene.fog.color.g, scene.fog.color.b );
-
-						} else {
-
-							_gl.uniform1f( uniforms.fog, 0 );
-
-						}
-
-						// material
-
-						if ( material instanceof THREE.MeshBasicMaterial ||
-						material instanceof THREE.MeshLambertMaterial ||
-						material instanceof THREE.MeshPhongMaterial ) {
-
-							_gl.uniform3f( uniforms.mColor, material.color.r, material.color.g, material.color.b );
-							_gl.uniform1f( uniforms.mOpacity, material.opacity );
-
-							if ( material.map ) {
-
-								setTexture( material.map, 0 );
-								_gl.uniform1i( uniforms.tMap, 0 );
-
-							}
-
-							if ( material.envMap ) {
-
-								setTexture( material.envMap, 1 );
-								_gl.uniform1i( uniforms.tSpherical, 1 );
-
-							}
-
-						} else if ( material instanceof THREE.MeshNormalMaterial ) {
-
-							_gl.uniform1f( uniforms.mOpacity, material.opacity );
-
-						} else if ( material instanceof THREE.MeshDepthMaterial ) {
-
-							_gl.uniform1f( uniforms.mNear, camera.near );
-							_gl.uniform1f( uniforms.mFar, camera.far );
-							_gl.uniform1f( uniforms.mOpacity, material.opacity );
-
-						}
-
-						_gl.uniform3f( uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
-						_gl.uniformMatrix4fv( uniforms.viewMatrix, false, _viewMatrixArray );
-						_gl.uniformMatrix4fv( uniforms.projectionMatrix, false, _projectionMatrixArray );
-
-					}
-
-					_gl.uniformMatrix4fv( uniforms.objectMatrix, false, _objectMatrixArray );
-					_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, _modelViewMatrixArray );
-					_gl.uniformMatrix3fv( uniforms.normalMatrix, false, _normalMatrixArray );
-
-					var buffer, buffers = geometry.__webglBuffers;
-
-					for ( var i = 0, l = buffers.length; i < l; i ++ ) {
-
-						buffer = buffers[ i ];
-
-						// vertices
-
-						_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.vertices );
-						_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
-						_gl.enableVertexAttribArray( attributes.position );
-
-						// normals
-
-						if ( attributes.normal >= 0 ) {
-
-							_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.normals );
-							_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
-							_gl.enableVertexAttribArray( attributes.normal );
-
-						}
-
-						// uvs
-
-						if ( attributes.uv >= 0 ) {
-
-							if ( buffer.uvs ) {
-
-								_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.uvs );
-								_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
-								_gl.enableVertexAttribArray( attributes.uv );
-
-							} else {
-
-								_gl.disableVertexAttribArray( attributes.uv );
-
-							}
-
-						}
-
-						// render triangles
-
-						if ( ! material.wireframe ) {
-
-							_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffer.faces );
-							_gl.drawElements( _gl.TRIANGLES, buffer.faceCount, _gl.UNSIGNED_SHORT, 0 );
-
-						// render lines
-
-						} else {
-
-							_gl.lineWidth( material.wireframeLinewidth );
-							_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffer.lines );
-							_gl.drawElements( _gl.LINES, buffer.lineCount, _gl.UNSIGNED_SHORT, 0 );
-
-						}
-
-					}
-
-				}
-
-			} else if ( object instanceof THREE.Line ) {
-
-
-
-			} else if ( object instanceof THREE.Particle ) {
-
-
-
-			}
-
-		}
-
-		// Buffers
-
-		function buildBuffers( geometry ) {
-
-			var itemCount = 0, vertexIndex, group,
-			f, fl, face, v1, v2, v3, v4, vertexNormals, faceNormal, normal, uv,
-			vertexGroups = [], faceGroups = [], lineGroups = [], normalGroups = [], uvGroups = [],
-			vertices, faces, lines, normals, uvs;
-
-			for ( f = 0, fl = geometry.faces.length; f < fl; f++ ) {
-
-				face = geometry.faces[ f ];
-				uv = geometry.uvs[ f ];
-				vertexNormals = face.vertexNormals;
-				faceNormal = face.normal;
-
-				if ( face instanceof THREE.Face3 ) {
-
-					itemCount += 3;
-					group = Math.floor( itemCount / 65535 );
-
-					if ( !vertexGroups[ group ] ) {
-
-						vertexIndex = 0;
-						vertices = vertexGroups[ group ] = [];
-						normals = normalGroups[ group ] = [];
-						uvs = uvGroups[ group ] = [];
-						faces = faceGroups[ group ] = [];
-						lines = lineGroups[ group ] = [];
-
-					}
-
-					v1 = geometry.vertices[ face.a ].position;
-					v2 = geometry.vertices[ face.b ].position;
-					v3 = geometry.vertices[ face.c ].position;
-
-					vertices.push( v1.x, v1.y, v1.z );
-					vertices.push( v2.x, v2.y, v2.z );
-					vertices.push( v3.x, v3.y, v3.z );
-
-					if ( vertexNormals.length == 3 ) {
-
-						for ( i = 0; i < 3; i ++ ) {
-
-							normals.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z );
-
-						}
-
-					} else {
-
-						for ( i = 0; i < 3; i ++ ) {
-
-							normals.push( faceNormal.x, faceNormal.y, faceNormal.z );
-
-						}
-
-					}
-
-					if ( uv ) {
-
-						for ( i = 0; i < 3; i ++ ) {
-
-							uvs.push( uv[ i ].u, uv[ i ].v );
-
-						}
-
-					}
-
-					faces.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
-
-					// TODO: don't add lines that already exist (faces sharing edge)
-
-					lines.push( vertexIndex, vertexIndex + 1 );
-					lines.push( vertexIndex, vertexIndex + 2 );
-					lines.push( vertexIndex + 1, vertexIndex + 2 );
-
-					vertexIndex += 3;
-
-				} else if ( face instanceof THREE.Face4 ) {
-
-					itemCount += 4;
-					group = Math.floor( itemCount / 65535 );
-
-					if ( !vertexGroups[ group ] ) {
-
-						vertexIndex = 0;
-						vertices = vertexGroups[ group ] = [];
-						normals = normalGroups[ group ] = [];
-						uvs = uvGroups[ group ] = [];
-						faces = faceGroups[ group ] = [];
-						lines = lineGroups[ group ] = [];
-
-					}
-
-					v1 = geometry.vertices[ face.a ].position;
-					v2 = geometry.vertices[ face.b ].position;
-					v3 = geometry.vertices[ face.c ].position;
-					v4 = geometry.vertices[ face.d ].position;
-
-					vertices.push( v1.x, v1.y, v1.z );
-					vertices.push( v2.x, v2.y, v2.z );
-					vertices.push( v3.x, v3.y, v3.z );
-					vertices.push( v4.x, v4.y, v4.z );
-
-					if ( vertexNormals.length == 4 ) {
-
-						for ( i = 0; i < 4; i ++ ) {
-
-							normals.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z );
-
-						}
-
-					} else {
-
-						for ( i = 0; i < 4; i ++ ) {
-
-							normals.push( faceNormal.x, faceNormal.y, faceNormal.z );
-
-						}
-
-					}
-
-					if ( uv ) {
-
-						for ( i = 0; i < 4; i ++ ) {
-
-							uvs.push( uv[ i ].u, uv[ i ].v );
-
-						}
-
-					}
-
-					faces.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 );
-					faces.push( vertexIndex, vertexIndex + 2, vertexIndex + 3 );
-
-					// TODO: don't add lines that already exist (faces sharing edge)
-
-					lines.push( vertexIndex, vertexIndex + 1 );
-					lines.push( vertexIndex, vertexIndex + 3 );
-					lines.push( vertexIndex + 1, vertexIndex + 2 );
-					lines.push( vertexIndex + 2, vertexIndex + 3 );
-
-					vertexIndex += 4;
-
-				}
-
-			}
-
-			if ( !vertices.length ) return false;
-
-			var buffer, buffers = [];
-
-			for ( var i = 0, l = group; i <= l; i ++ ) {
-
-				buffer = {
-
-					vertices: null,
-					faces: null,
-					faceCount: faceGroups[ i ].length,
-					normals: null,
-					lines: null,
-					lineCount: lineGroups[ i ].length,
-					uvs: null
-
-				};
-
-				buffer.vertices = _gl.createBuffer();
-				_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.vertices );
-				_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexGroups[ i ] ), _gl.STATIC_DRAW );
-
-				buffer.normals = _gl.createBuffer();
-				_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.normals );
-				_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalGroups[ i ] ), _gl.STATIC_DRAW );
-
-				if ( uvs.length > 0 ) {
-
-					buffer.uvs = _gl.createBuffer();
-					_gl.bindBuffer( _gl.ARRAY_BUFFER, buffer.uvs );
-					_gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( uvGroups[ i ] ), _gl.STATIC_DRAW );
-
-				}
-
-				buffer.faces = _gl.createBuffer();
-				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffer.faces );
-				_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faceGroups[ i ] ), _gl.STATIC_DRAW );
-
-				buffer.lines = _gl.createBuffer();
-				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, buffer.lines );
-				_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( lineGroups[ i ] ), _gl.STATIC_DRAW );
-
-				buffers.push( buffer );
-
-			}
-
-			geometry.__webglBuffers = buffers;
-
-			return true;
-
-		}
-
-		// Shaders
-
-		function createProgram( material ) {
-
-			var vs, fs, identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
-
-			if ( material instanceof THREE.MeshBasicMaterial ||
-			material instanceof THREE.MeshLambertMaterial ||
-			material instanceof THREE.MeshPhongMaterial ) {
-
-				vs = [
-					material.map ? 'varying vec2 vUv;' : null,
-					material.envMap ? 'varying vec2 vSpherical;' : null,
-
-					'void main() {',
-						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
-
-						material.map ? 'vUv = uv;' : null,
-
-						material.envMap ? 'vec3 u = normalize( modelViewMatrix * vec4( position, 1.0 ) ).xyz;' : null,
-						material.envMap ? 'vec3 n = normalize( normalMatrix * normal );' : null,
-						material.envMap ? 'vec3 r = reflect( u, n );' : null,
-						material.envMap ? 'float m = 2.0 * sqrt( r.x * r.x + r.y * r.y + ( r.z + 1.0 ) * ( r.z + 1.0 ) );' : null,
-						material.envMap ? 'vSpherical.x = r.x / m + 0.5;' : null,
-						material.envMap ? 'vSpherical.y = - r.y / m + 0.5;' : null,
-
-					'}'
-				].filter( removeNull ).join( '\n' );
-
-				fs = [
-					'uniform vec3 mColor;',
-					'uniform float mOpacity;',
-
-					material.map ? 'uniform sampler2D tMap;' : null,
-					material.map ? 'varying vec2 vUv;' : null,
-
-					material.envMap ? 'uniform sampler2D tSpherical;' : null,
-					material.envMap ? 'varying vec2 vSpherical;' : null,
-
-					material.fog ? 'uniform float fog;' : null,
-					material.fog ? 'uniform float fogNear;' : null,
-					material.fog ? 'uniform float fogFar;' : null,
-					material.fog ? 'uniform vec3 fogColor;' : null,
-
-					'void main() {',
-						'gl_FragColor = vec4( mColor.xyz, mOpacity );',
-
-						/* Premultiply alpha
-						material.map ? 'vec4 mapColor = texture2D( tMap, vUv );' : null,
-						material.map ? 'mapColor.xyz *= mapColor.w;' : null,
-						*/
-
-						material.map ? 'gl_FragColor *= texture2D( tMap, vUv );' : null,
-
-						material.envMap ? 'gl_FragColor += texture2D( tSpherical, vSpherical );' : null,
-
-						material.fog ? 'float depth = gl_FragCoord.z / gl_FragCoord.w;' : null,
-						material.fog ? 'float fogFactor = fog * smoothstep( fogNear, fogFar, depth );' : null,
-						material.fog ? 'gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );' : null,
-					'}'
-				].filter( removeNull ).join( '\n' );
-
-				identifiers.push( 'mColor', 'mOpacity' );
-
-				if ( material.map ) identifiers.push( 'tMap' );
-				if ( material.envMap ) identifiers.push( 'tSpherical' );
-				if ( material.fog ) identifiers.push( 'fog', 'fogColor', 'fogNear', 'fogFar' );
-
-
-			} else if ( material instanceof THREE.MeshNormalMaterial ) {
-
-				vs = [
-					'varying vec3 vNormal;',
-
-					'void main() {',
-						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
-						'vNormal = normalize( normalMatrix * normal );',
-					'}'
-				].join( '\n' );
-
-				fs = [
-					'uniform float mOpacity;',
-					'varying vec3 vNormal;',
-
-					'void main() {',
-						'gl_FragColor = vec4( ( normalize( vNormal ) + 1.0 ) * 0.5, mOpacity );',
-					'}'
-				].join( '\n' );
-
-				identifiers.push( 'mOpacity' );
-
-			} else if ( material instanceof THREE.MeshDepthMaterial ) {
-
-				vs = [
-					'void main() {',
-						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
-					'}'
-
-				].join( '\n' );
-
-				fs = [
-					'uniform float mNear;',
-					'uniform float mFar;',
-					'uniform float mOpacity;',
-
-					'void main() {',
-						'float depth = gl_FragCoord.z / gl_FragCoord.w;',
-						'float color = 1.0 - smoothstep( mNear, mFar, depth );',
-						'gl_FragColor = vec4( vec3( color ), 1.0 );',
-					'}'
-				].join( '\n' );
-
-				identifiers.push( 'mNear', 'mFar', 'mOpacity' );
-
-			} else if ( material instanceof THREE.MeshShaderMaterial ) {
-
-				vs = material.vertexShader;
-				fs = material.fragmentShader;
-
-				for( uniform in material.uniforms ) {
-
-					identifiers.push( uniform );
-
-				}
-
-			} else {
-
-				return false;
-
-			}
-
-			material.__webglProgram = compileProgram( vs, fs );
-
-			cacheUniformLocations( material.__webglProgram, identifiers );
-			cacheAttributeLocations( material.__webglProgram, [ "position", "normal", "uv"/*, "tangent"*/ ] );
-
-			return true;
-
-		}
-
-		function compileProgram( vertexShader, fragmentShader ) {
-
-			var program = _gl.createProgram(), shader, prefix_vertex, prefix_fragment;
-
-			prefix_vertex = [
-				maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "",
-
-				"uniform mat4 objectMatrix;",
-				"uniform mat4 modelViewMatrix;",
-				"uniform mat4 projectionMatrix;",
-				//"uniform mat4 viewMatrix;",
-				"uniform mat3 normalMatrix;",
-				"uniform vec3 cameraPosition;",
-				"attribute vec3 position;",
-				"attribute vec3 normal;",
-				"attribute vec2 uv;",
-				""
-			].join("\n"),
-
-			prefix_fragment = [
-				"#ifdef GL_ES",
-					"precision highp float;",
-				"#endif",
-				//"uniform mat4 viewMatrix;",
-				""
-			].join("\n");
-
-			// Vertex shader
-
-			shader = _gl.createShader( _gl.VERTEX_SHADER );
-			_gl.shaderSource( shader, prefix_vertex + vertexShader );
-			_gl.compileShader( shader );
-			_gl.attachShader( program, shader );
-
-			if ( !_gl.getShaderParameter( shader, _gl.COMPILE_STATUS ) ) {
-
-				alert( _gl.getShaderInfoLog( shader ) );
-				return null;
-
-			}
-
-			// Fragment Shader
-
-			shader = _gl.createShader( _gl.FRAGMENT_SHADER );
-			_gl.shaderSource( shader, prefix_fragment + fragmentShader );
-			_gl.compileShader( shader );
-			_gl.attachShader( program, shader );
-
-			if ( !_gl.getShaderParameter( shader, _gl.COMPILE_STATUS ) ) {
-
-				alert( _gl.getShaderInfoLog( shader ) );
-				return null;
-
-			}
-
-			_gl.linkProgram( program );
-
-			if ( !_gl.getProgramParameter( program, _gl.LINK_STATUS ) ) {
-
-				alert( "Could not initialise shaders.\n" +
-				"VALIDATE_STATUS: " + _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ) + "\n" +
-				"ERROR: " + _gl.getError() + "\n\n" +
-				"- Vertex Shader -\n" + prefix_vertex + vertexShader + "\n\n" +
-				"- Fragment Shader -\n" + prefix_fragment + fragmentShader );
-
-			}
-
-			program.uniforms = {};
-			program.attributes = {};
-
-			return program;
-
-		}
-
-		function cacheUniformLocations( program, identifiers ) {
-
-			var i, l, id;
-
-			for( i = 0, l = identifiers.length; i < l; i++ ) {
-
-				id = identifiers[ i ];
-				program.uniforms[ id ] = _gl.getUniformLocation( program, id );
-
-			}
-
-		}
-
-		function cacheAttributeLocations( program, identifiers ) {
-
-			var i, l, id;
-
-			for( i = 0, l = identifiers.length; i < l; i++ ) {
-
-				id = identifiers[ i ];
-				program.attributes[ id ] = _gl.getAttribLocation( program, id );
-
-				if ( program.attributes[ id ] >= 0 ) {
-
-					_gl.enableVertexAttribArray( program.attributes[ id ] );
-
-				}
-
-			}
-
-		}
-
-		// Textures
-
-		function setTexture( texture, slot ) {
-
-			if ( !texture.__webglTexture ) {
-				
-				texture.__webglTexture = _gl.createTexture();
-				
-			}
-			
-			if ( texture.needsUpdate ) {
-
-				_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
-				_gl.texImage2D( _gl.TEXTURE_2D, 0, _gl.RGBA, _gl.RGBA, _gl.UNSIGNED_BYTE, texture.image );
-
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_S, paramThreeToGL( texture.wrapS ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_WRAP_T, paramThreeToGL( texture.wrapT ) );
-
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MAG_FILTER, paramThreeToGL( texture.magFilter ) );
-				_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( texture.minFilter ) );
-				_gl.generateMipmap( _gl.TEXTURE_2D );
-				_gl.bindTexture( _gl.TEXTURE_2D, null );
-				
-				texture.needsUpdate = false;
-
-			}
-
-			_gl.activeTexture( _gl.TEXTURE0 + slot );
-			_gl.bindTexture( _gl.TEXTURE_2D, texture.__webglTexture );
-
-		};
-		
-		function maxVertexTextures() {
-
-			return _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
-
-		};
-
-		function paramThreeToGL( p ) {
-
-			switch ( p ) {
-
-				case THREE.RepeatWrapping: return _gl.REPEAT; break;
-				case THREE.ClampToEdgeWrapping: return _gl.CLAMP_TO_EDGE; break;
-				case THREE.MirroredRepeatWrapping: return _gl.MIRRORED_REPEAT; break;
-
-				case THREE.NearestFilter: return _gl.NEAREST; break;
-				case THREE.NearestMipMapNearestFilter: return _gl.NEAREST_MIPMAP_NEAREST; break;
-				case THREE.NearestMipMapLinearFilter: return _gl.NEAREST_MIPMAP_LINEAR; break;
-
-				case THREE.LinearFilter: return _gl.LINEAR; break;
-				case THREE.LinearMipMapNearestFilter: return _gl.LINEAR_MIPMAP_NEAREST; break;
-				case THREE.LinearMipMapLinearFilter: return _gl.LINEAR_MIPMAP_LINEAR; break;
-
-			}
-
-			return 0;
-
-		}
-
-		function removeNull( element ) {
-
-			return element !== null;
-
-		}
-
-
-	};
-
-};

+ 1 - 1
utils/REVISION

@@ -1 +1 @@
-34
+35

+ 3 - 0
utils/build.py

@@ -259,7 +259,10 @@ WEBGL_FILES = [
 'objects/Line.js',
 'objects/Mesh.js',
 'objects/Bone.js',
+'objects/SkinnedMesh.js',
+'objects/Ribbon.js',
 'objects/Sound.js',
+'objects/LOD.js',
 'scenes/Scene.js',
 'scenes/Fog.js',
 'scenes/FogExp2.js',

+ 13 - 8
utils/exporters/convert_obj_threejs_slim.py

@@ -323,13 +323,18 @@ def normalize(v):
     """Normalize 3d vector"""
     
     l = math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
-    v[0] /= l
-    v[1] /= l
-    v[2] /= l
+    if l:
+        v[0] /= l
+        v[1] /= l
+        v[2] /= l
 
 # #####################################################
 # MTL parser
 # #####################################################
+def texture_relative_path(fullpath):
+    texture_file = os.path.basename(fullpath)
+    return texture_file
+    
 def parse_mtl(fname):
     """Parse MTL file.
     """
@@ -383,27 +388,27 @@ def parse_mtl(fname):
             # Diffuse texture
             # map_Kd texture_diffuse.jpg
             if chunks[0] == "map_Kd" and len(chunks) == 2:
-                materials[identifier]["mapDiffuse"] = chunks[1]
+                materials[identifier]["mapDiffuse"] = texture_relative_path(chunks[1])
 
             # Ambient texture
             # map_Ka texture_ambient.jpg
             if chunks[0] == "map_Ka" and len(chunks) == 2:
-                materials[identifier]["mapAmbient"] = chunks[1]
+                materials[identifier]["mapAmbient"] = texture_relative_path(chunks[1])
 
             # Specular texture
             # map_Ks texture_specular.jpg
             if chunks[0] == "map_Ks" and len(chunks) == 2:
-                materials[identifier]["mapSpecular"] = chunks[1]
+                materials[identifier]["mapSpecular"] = texture_relative_path(chunks[1])
 
             # Alpha texture
             # map_d texture_alpha.png
             if chunks[0] == "map_d" and len(chunks) == 2:
-                materials[identifier]["mapAlpha"] = chunks[1]
+                materials[identifier]["mapAlpha"] = texture_relative_path(chunks[1])
 
             # Bump texture
             # map_bump texture_bump.jpg or bump texture_bump.jpg
             if (chunks[0] == "map_bump" or chunks[0] == "bump") and len(chunks) == 2:
-                materials[identifier]["mapBump"] = chunks[1]
+                materials[identifier]["mapBump"] = texture_relative_path(chunks[1])
 
             # Illumination
             # illum 2

+ 856 - 0
utils/exporters/max/ThreeJSExporter.ms

@@ -0,0 +1,856 @@
+-------------------------------------------------------------------------------------
+-- ThreeJSExporter.ms
+-- Exports geometry from 3ds max to Three.js models in ASCII JSON format
+-- By alteredq / http://alteredqualia.com
+-------------------------------------------------------------------------------------
+
+rollout ThreeJSExporter "ThreeJSExporter"
+(
+	-- Variables
+
+	local ostream,
+
+	headerFormat = "// Converted from: %
+//  vertices: %
+//  normals: %
+//  uvs: %
+//  triangles: %
+//  materials: %
+//
+//  Generated with 3ds max ThreeJSExporter
+//  http://github.com/alteredq/three.js/blob/master/utils/exporters/max/ThreeJSExporter.ms
+
+
+",
+
+	vertexFormat = "%,%,%",
+
+	vertexNormalFormat = "%,%,%",
+	UVFormat = "%,%",
+
+	triFormat = "%,%,%,%",
+	triUVFormat = "%,%,%,%,%,%,%",
+	triNFormat = "%,%,%,%,%,%,%",
+	triUVNFormat = "%,%,%,%,%,%,%,%,%,%",
+
+	footerFormat = "}\n\npostMessage( model );"
+
+	-------------------------------------------------------------------------------------
+	-- User interface
+
+	group "ThreeJSExporter  v0.2" 
+	(
+
+		label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
+		hyperLink lab1 "Original source at GitHub" address:"https://github.com/mrdoob/three.js" align:#left
+
+		checkbox exportUv "Export uvs" checked:true enabled:true
+		checkbox exportNormal "Export normals" checked:true enabled:true
+		checkbox smoothNormal "Use vertex normals" checked:false enabled:true
+		checkbox exportColor "Export vertex colors" checked:false enabled:false
+		checkbox flipYZ "Flip YZ" checked:true enabled:true
+		checkbox flipUV "Flip UV" checked:true enabled:true
+		checkbox flipFace "Flip all faces" checked:false enabled:true
+		checkbox autoflipFace "Try fixing flipped faces" checked:false enabled:true
+
+	)
+
+	button btn_export "Export selected objects"
+
+	-------------------------------------------------------------------------------------
+	-- Dump vertices
+
+	function DumpVertices src = 
+	(
+
+		Format "'vertices': [" to:ostream
+
+		num = src.count
+
+		if num > 0 then
+		(
+
+			for i = 1 to num do
+			(
+
+				vert = src[i]
+
+				if flipYZ.checked then
+				(
+					x = vert.x
+					y = vert.z
+					z = vert.y
+
+					z *= -1
+
+				)
+				else
+				(
+
+					x = vert.x
+					y = vert.y
+					z = vert.z
+
+				)
+				
+				Format vertexFormat x y z to:ostream
+				
+				if i < num then Format "," to:ostream
+
+			)
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump normals
+
+	function DumpNormals src = 
+	(
+
+		Format "'normals': [" to:ostream
+
+		num = src.count
+
+		if num > 0 and exportNormal.checked then
+		(
+
+			for i = 1 to num do
+			(
+
+				normal = src[i]
+				normal = normalize normal as point3
+
+				if flipYZ.checked then
+				(
+
+					x = normal.x
+					y = normal.z
+					z = normal.y
+					
+					z *= -1
+					
+				)
+				else
+				(
+
+					x = normal.x
+					y = normal.y
+					z = normal.z
+
+				)
+
+				Format vertexNormalFormat x y z to:ostream
+
+				if i < num then Format "," to:ostream
+
+			)
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump uvs
+
+	function DumpUvs src = 
+	(
+
+		Format "'uvs': [" to:ostream
+
+		num = src.count
+
+		if num > 0 and exportUv.checked then
+		(
+
+			for i = 1 to num do
+			(
+
+				uvw = src[i]
+
+				u = uvw.x
+
+				if flipUV.checked then 
+				(
+					v = 1 - uvw.y
+				)
+				else
+				(
+					v = uvw.y
+				)
+
+				Format UVFormat u v to:ostream
+
+				if i < num then Format "," to:ostream
+
+			)
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump face type
+
+	function DumpFaceType label content = 
+	(
+		Format "'%': [" label to:ostream
+
+		num = content.count
+
+		if num > 0 then 
+		(
+
+			for i = 1 to num do
+			(
+
+				zface = content[i]
+
+				fv  = zface[1]
+				fuv = zface[2]
+				m   = zface[3] - 1
+
+				needsFlip = zface[4]
+
+				hasUVs = (classof fuv == Point3)
+
+				va = (fv.x - 1) as Integer
+				vb = (fv.y - 1) as Integer
+				vc = (fv.z - 1) as Integer
+
+				if smoothNormal.checked then 
+				(
+
+					-- normals have the same indices as vertices
+
+					na = va
+					nb = vb
+					nc = vc
+
+				)
+				else 
+				(
+					-- normals have the same indices as face
+
+					na = i - 1
+					nb = na
+					nc = na
+
+				)
+
+				if hasUVs then
+				(
+				
+					ua = (fuv.x - 1) as Integer
+					ub = (fuv.y - 1) as Integer
+					uc = (fuv.z - 1) as Integer
+
+				)
+
+				if flipFace.checked or needsFlip then 
+				(
+					tmp = vb
+					vb = vc
+					vc = tmp
+
+					tmp = nb
+					nb = nc
+					nc = tmp
+
+					if hasUVs then
+					(
+
+						tmp = ub
+						ub = uc
+						uc = tmp
+
+					)
+
+				)
+
+				if label == "triangles" then
+				(
+					Format triFormat va vb vc m to:ostream
+				)
+				else if label == "trianglesUvs" then
+				(
+					Format triUVFormat va vb vc m ua ub uc to:ostream
+				)
+				else if label == "trianglesNormals" then
+				(
+					Format triNFormat va vb vc m na nb nc to:ostream
+				)
+				else if label == "trianglesNormalsUvs" then
+				(
+					Format triUVNFormat va vb vc m na nb nc ua ub uc to:ostream
+				)
+
+				if i < num then Format "," to:ostream
+
+			)
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump faces
+
+	function DumpFaces src = 
+	(
+
+		hasUVs = true
+
+		triangles = #()
+		trianglesUvs = #()
+		trianglesNormals = #()
+		trianglesNormalsUvs = #()
+
+		quads = #()
+		quadsUvs = #()
+		quadsNormals = #()
+		quadsNormalsUvs = #()
+
+		num = src.count
+
+		if num > 0 then
+		(
+
+			for i = 1 to num do
+			(
+
+				zface = src[i]
+				fuv = zface[2]
+
+				hasUVs = (classof fuv == Point3)
+
+				if hasUVs and exportUv.checked and exportNormal.checked then
+				(
+					append trianglesNormalsUvs zface
+				)
+				else if exportNormal.checked then
+				(
+					append trianglesNormals zface
+				)
+				else if hasUVs and exportUv.checked then
+				(
+					append trianglesUvs zface
+				)
+				else
+				(
+					append triangles zface
+				)
+
+			)
+
+		)
+
+		DumpFaceType "triangles" triangles
+		DumpFaceType "trianglesUvs" trianglesUvs
+		DumpFaceType "trianglesNormals" trianglesNormals
+		DumpFaceType "trianglesNormalsUvs" trianglesNormalsUvs
+
+		DumpFaceType "quads" quads
+		DumpFaceType "quadsUvs" quadsUvs
+		DumpFaceType "quadsNormals" quadsNormals
+		DumpFaceType "quadsNormalsUvs" quadsNormalsUvs
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump color
+
+	function DumpColor pcolor label = 
+	(
+		r = pcolor.r / 255
+		g = pcolor.g / 255
+		b = pcolor.b / 255
+
+		fr = formattedPrint r format:".4f"
+		fg = formattedPrint g format:".4f"
+		fb = formattedPrint b format:".4f"
+
+		Format "'%'  : [%, %, %],\n" label fr fg fb to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Dump map
+
+	function DumpMap pmap label = 
+	(
+
+		if classof pmap == BitmapTexture then
+		(
+			bm = pmap.bitmap
+
+			if bm != undefined then 
+			(
+
+				fname = filenameFromPath bm.filename
+				Format "'%'    : '%',\n" label fname to:ostream
+
+			)
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Export materials
+
+	function ExportMaterials zmaterials = 
+	(
+
+		Format "'materials': [\n" to:ostream
+
+		totalMaterials = zmaterials.count
+
+		for i = 1 to totalMaterials do
+		(
+			mat = zmaterials[i]
+
+			Format "{\n" to:ostream
+
+			-- debug
+
+			Format "'DbgIndex' : %,\n" (i-1) to:ostream
+			Format "'DbgName'  : '%',\n" mat.name to:ostream
+
+			-- colors
+
+			DumpColor mat.diffuse  "colorDiffuse"
+			DumpColor mat.ambient  "colorAmbient"
+			DumpColor mat.specular "colorSpecular"
+
+			t = mat.opacity / 100
+			s = mat.glossiness
+			
+			Format "'transparency'  : %,\n" t to:ostream
+			Format "'specularCoef'  : %,\n" s to:ostream
+
+			-- maps
+
+			DumpMap mat.diffuseMap  "mapDiffuse"
+			DumpMap mat.ambientMap  "mapAmbient"
+			DumpMap mat.specularMap "mapSpecular"
+			DumpMap mat.bumpMap 	"mapBump"
+			DumpMap mat.opacityMap 	"mapAlpha"
+
+			Format "}" to:ostream
+
+			if i < totalMaterials then Format "," to:ostream
+			Format "\n\n" to:ostream
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract vertices from mesh
+
+	function ExtractVertices obj whereto =
+	(
+
+		n = obj.numVerts
+
+		for i = 1 to n do 
+		(
+
+			v = GetVert obj i
+			append whereto v
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract normals from mesh
+
+	function ExtractNormals obj whereto needsFlip =
+	(
+		if smoothNormal.checked then
+		(
+
+			num = obj.numVerts
+			
+			for i = 1 to num do 
+			(
+
+				n = GetNormal obj i
+
+				if flipFace.checked or needsFlip then
+				(
+					n.x *= -1
+					n.y *= -1
+					n.z *= -1
+				)
+
+				append whereto n
+
+			)
+
+		)
+		else
+		(
+
+			num = obj.numFaces
+
+			for i = 1 to num do 
+			(
+
+				n = GetFaceNormal obj i
+
+				if flipFace.checked or needsFlip then
+				(
+					n.x *= -1
+					n.y *= -1
+					n.z *= -1
+				)
+
+				append whereto n
+
+			)
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract uvs from mesh
+
+	function ExtractUvs obj whereto =
+	(
+		n = obj.numTVerts
+		
+		for i = 1 to n do 
+		(
+
+			v = GetTVert obj i
+			append whereto v
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract faces from mesh
+
+	function ExtractFaces objMesh objMaterial whereto allMaterials needsFlip offsetVert offsetUv =
+	(
+		n = objMesh.numFaces
+		hasUVs = objMesh.numTVerts > 0
+
+		useMultiMaterial = false
+		materialIDList = #()
+
+		if ( classof objMaterial ) == StandardMaterial then 
+		(
+			fm = findItem allMaterials objMaterial
+		)
+		else
+		(
+			useMultiMaterial = true
+
+			for i = 1 to n do 
+			(
+				mID = GetFaceMatID objMesh i
+				materialIndex = findItem objMaterial.materialIDList mID
+				subMaterial = objMaterial.materialList[materialIndex]
+
+				mMergedIndex = findItem allMaterials subMaterial
+				if mMergedIndex > 0 then 
+				(
+					materialIDList[mID] = mMergedIndex
+				)
+
+			)
+
+		)
+		
+		for i = 1 to n do 
+		(
+
+			zface = #()
+			
+			fv = GetFace objMesh i
+
+			fv.x += offsetVert
+			fv.y += offsetVert
+			fv.z += offsetVert
+
+			if useMultiMaterial then 
+			(
+				mID = GetFaceMatID objMesh i
+				fm = materialIDList[mID]
+			)
+
+			if hasUVs then
+			(
+
+				fuv = GetTVFace objMesh i
+				
+				fuv.x += offsetUv
+				fuv.y += offsetUv
+				fuv.z += offsetUv
+
+			)
+			else
+			(
+				fuv = false
+			)
+
+			append zface fv 
+			append zface fuv
+			append zface fm
+			append zface needsFlip
+
+			append whereto zface
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract materials from eventual multimaterial
+	
+	function ExtractMaterials objMesh objMaterial whereto =
+	(
+		
+		materialClass = classof objMaterial
+
+		if materialClass == StandardMaterial then
+		(
+			if ( findItem whereto objMaterial ) == 0 then
+			(
+				append whereto objMaterial
+			)
+
+		)
+		else if materialClass == MultiMaterial then
+		(
+
+			n = objMesh.numFaces
+			
+			for i = 1 to n do 
+			(
+			
+				mID = getFaceMatId objMesh i
+				materialIndex = findItem objMaterial.materialIDList mID
+				subMaterial = objMaterial.materialList[materialIndex]
+
+				if ( findItem whereto subMaterial ) == 0 then
+				(
+					append whereto subMaterial
+				)
+
+			)
+
+		)
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Hack to figure out if normals are messed up
+	
+	function NeedsFaceFlip node = 
+	(
+		needsFlip = false
+
+		local tmp = Snapshot node
+
+		face_normal = normalize ( getfacenormal tmp 1 )
+
+		face = getface tmp 1
+
+		va = getvert tmp face[1]
+		vb = getvert tmp face[2]
+		vc = getvert tmp face[3]
+
+		computed_normal = normalize ( cross (vc - vb)  (va - vb) )
+
+		if distance computed_normal face_normal > 0.1 then needsFlip = true
+
+		delete tmp
+
+		return needsFlip
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Extract only things that either already are or can be converted to meshes
+
+	function ExtractMesh node =
+	(
+
+		if SuperClassOf node == GeometryClass then
+		(
+			needsFlip = false
+			
+			if autoflipFace.checked then
+			(
+				needsFlip = NeedsFaceFlip node
+			)
+			
+			return #( SnapshotAsMesh node, node.name, node.material, needsFlip )
+
+		)
+
+		-- Not geometry ... could be a camera, light, etc.
+		
+		return #( false, node.name, 0 )
+
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Export scene
+
+	function ExportScene =
+	(
+
+		-- Extract meshes
+
+		meshObjects = #()
+
+		mergedVertices = #()
+		mergedNormals = #()
+		mergedUvs = #()
+		mergedFaces = #()
+		mergedMaterials = #()
+
+		for obj in selection do 
+		(
+
+			result = ExtractMesh obj
+
+			meshObj   	 = result[1]
+			meshName     = result[2]
+			meshMaterial = result[3]
+			needsFlip    = result[4]
+
+			if ClassOf meshObj == TriMesh then 
+			(
+
+				append meshObjects result
+
+				vertexOffset = mergedVertices.count
+				uvOffset = mergedUvs.count
+
+				ExtractMaterials meshObj meshMaterial mergedMaterials
+
+				ExtractVertices meshObj mergedVertices
+				ExtractNormals meshObj mergedNormals needsFlip
+				ExtractUvs meshObj mergedUvs
+
+				ExtractFaces meshObj meshMaterial mergedFaces mergedMaterials needsFlip vertexOffset uvOffset
+
+			)
+
+		)
+
+		totalVertices = mergedVertices.count
+		totalFaces = mergedFaces.count
+		totalMaterials = mergedMaterials.count
+
+		totalNormals = 0
+		if exportNormal.checked then 
+		(
+			totalNormals = mergedNormals.count
+		)
+
+		totalUvs = 0
+		if exportUv.checked then
+		(
+			totalUvs = mergedUvs.count
+		)
+
+
+		-- Dump header
+
+		Format headerFormat maxFileName totalVertices totalNormals totalUvs totalFaces totalMaterials to:ostream
+
+		-- Dump objects (debug)
+
+		Format "// Source objects:\n\n" to:ostream
+
+		i = 0
+
+		for obj in meshObjects do 
+		(
+
+			meshName = obj[2]
+			Format "// %: %\n" i meshName to:ostream
+			i += 1
+
+		)
+
+		-- Dump model
+
+		Format "\n\nvar model = {\n\n" to:ostream
+
+		-- Dump all materials in the scene
+
+		ExportMaterials mergedMaterials
+
+		-- Dump merged data from all selected geometries
+
+		DumpVertices mergedVertices
+		DumpNormals mergedNormals
+		DumpUvs mergedUvs
+		DumpFaces mergedFaces
+
+		-- Dump footer
+
+		Format footerFormat to:ostream
+
+	)
+
+
+	-------------------------------------------------------------------------------------
+	-- Open and prepare a file handle for writing
+
+	function GetSaveFileStream =
+	(
+		zname = getFilenameFile maxFileName
+		zname += ".js"
+
+		fname = GetSaveFileName filename:zname types:"JavaScript file (*.js)|*.js|All Files(*.*)|*.*|"
+		if fname == undefined then
+			return undefined
+
+		ostream = CreateFile fname
+		if ostream == undefined then
+		(
+			MessageBox "Couldn't open file for writing !"
+			return undefined
+		)
+
+		return ostream
+	)
+
+	-------------------------------------------------------------------------------------
+	-- Export button click handler
+
+	on btn_export pressed do
+	(
+		ostream = GetSaveFileStream()
+		if ostream != undefined then
+		(
+			ExportScene()
+			close ostream
+		)
+
+	)
+
+) 
+createDialog ThreeJSExporter width:300

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini