Browse Source

Merged latest master branch into physics branch.

alteredq 14 years ago
parent
commit
65e3f92d55
42 changed files with 2152 additions and 1359 deletions
  1. 211 214
      build/Three.js
  2. 54 52
      build/custom/ThreeCanvas.js
  3. 24 24
      build/custom/ThreeDOM.js
  4. 7 16
      build/custom/ThreeExtras.js
  5. 60 58
      build/custom/ThreeSVG.js
  6. 172 166
      build/custom/ThreeWebGL.js
  7. 2 2
      examples/js/Stats.js
  8. 1 1
      examples/obj/female02/Female02_bin.js
  9. 5 3
      examples/obj/female02/Female02_slim.js
  10. 1 1
      examples/obj/lucy/Lucy100k_bin.js
  11. 5 3
      examples/obj/lucy/Lucy100k_slim.js
  12. 1 1
      examples/obj/male02/Male02_bin.js
  13. 5 3
      examples/obj/male02/Male02_slim.js
  14. 1 1
      examples/obj/ninja/NinjaLo_bin.js
  15. 1 1
      examples/obj/torus/Torus_bin.js
  16. 5 3
      examples/obj/torus/Torus_slim.js
  17. 1 1
      examples/obj/walt/WaltHead_bin.js
  18. 5 3
      examples/obj/walt/WaltHead_slim.js
  19. 1 1
      examples/webgl_materials_video.html
  20. 21 1
      examples/webgl_panorama_equirectangular.html
  21. 29 28
      examples/webgl_postprocessing_dof.html
  22. 1 1
      examples/webgl_ribbons.html
  23. 3 1
      examples/webgl_scene_test.html
  24. 4 89
      examples/webgl_scene_test_blender.html
  25. 3 1
      examples/webgl_shader_lava.html
  26. 14 0
      src/core/Edge.js
  27. 105 0
      src/core/Geometry.js
  28. 1 1
      src/core/Ray.js
  29. 0 445
      src/extras/SceneUtils.js
  30. 44 23
      src/extras/cameras/QuakeCamera.js
  31. 55 5
      src/extras/io/JSONLoader.js
  32. 25 9
      src/extras/io/Loader.js
  33. 455 0
      src/extras/io/SceneLoader.js
  34. 1 0
      src/materials/MeshShaderMaterial.js
  35. 3 1
      src/objects/ShadowVolume.js
  36. 3 0
      src/renderers/WebGLRenderTarget.js
  37. 299 102
      src/renderers/WebGLRenderer.js
  38. 2 0
      utils/build.py
  39. 13 2
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
  40. 111 17
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
  41. 28 3
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
  42. 370 76
      utils/exporters/convert_obj_three.py

File diff suppressed because it is too large
+ 211 - 214
build/Three.js


+ 54 - 52
build/custom/ThreeCanvas.js

@@ -1,7 +1,7 @@
 // ThreeCanvas.js r38 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},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 e,d,f,g,i,h;if(c==0)e=d=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:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
-f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;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*
+THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},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 e,d,g,f,i,h;if(c==0)e=d=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:e=h;d=c;g=a;break;case 2:e=a;d=c;g=b;break;case 3:e=a;d=h;g=c;break;case 4:e=b;d=a;g=c;break;case 5:e=c;d=a;
+g=h;break;case 6:case 0:e=c;d=b;g=a}}this.r=e;this.g=d;this.b=g;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/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
@@ -12,71 +12,73 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 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,e){this.set(a||0,b||0,c||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(D,A,U,V){V=V.clone().subSelf(A);U=U.clone().subSelf(A);var B=D.clone().subSelf(A);D=V.dot(V);A=V.dot(U);V=V.dot(B);var u=U.dot(U);U=U.dot(B);B=1/(D*u-A*A);u=(u*V-A*U)*B;D=(D*U-A*V)*B;return u>0&&D>0&&u+D<1}var c,e,d,f,g,i,h,j,k,n,
-q,o=a.geometry,w=o.vertices,z=[];c=0;for(e=o.faces.length;c<e;c++){d=o.faces[c];n=this.origin.clone();q=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(w[d.a].position.clone());g=h.multiplyVector3(w[d.b].position.clone());i=h.multiplyVector3(w[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(w[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());k=q.dot(j);if(k<0){j=j.dot((new THREE.Vector3).sub(f,n))/k;n=n.addSelf(q.multiplyScalar(j));
-if(d instanceof THREE.Face3){if(b(n,f,g,i)){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};z.push(d)}}else if(d instanceof THREE.Face4&&(b(n,f,g,h)||b(n,g,i,h))){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};z.push(d)}}}return z}};
-THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,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 e};this.getBottom=function(){return d};this.set=function(h,j,k,n){i=!1;b=h;c=j;e=k;d=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(g,f){return g.distance-f.distance});return d},intersectObject:function(a){function b(D,A,U,V){V=V.clone().subSelf(A);U=U.clone().subSelf(A);var B=D.clone().subSelf(A);D=V.dot(V);A=V.dot(U);V=V.dot(B);var u=U.dot(U);U=U.dot(B);B=1/(D*u-A*A);u=(u*V-A*U)*B;D=(D*U-A*V)*B;return u>0&&D>0&&u+D<1}var c,e,d,g,f,i,h,j,k,n,
+q,o=a.geometry,w=o.vertices,z=[];c=0;for(e=o.faces.length;c<e;c++){d=o.faces[c];n=this.origin.clone();q=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(w[d.a].position.clone());f=h.multiplyVector3(w[d.b].position.clone());i=h.multiplyVector3(w[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(w[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());k=q.dot(j);if(a.doubleSided||(a.flipSided?k>0:k<0)){j=j.dot((new THREE.Vector3).sub(g,n))/
+k;n=n.addSelf(q.multiplyScalar(j));if(d instanceof THREE.Face3){if(b(n,g,f,i)){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};z.push(d)}}else if(d instanceof THREE.Face4&&(b(n,g,f,h)||b(n,f,i,h))){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};z.push(d)}}}return z}};
+THREE.Rectangle=function(){function a(){g=e-b;f=d-c}var b,c,e,d,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,k,n){i=!1;b=h;c=j;e=k;d=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
 this.add3Points=function(h,j,k,n,q,o){if(i){i=!1;b=h<k?h<q?h:q:k<q?k:q;c=j<n?j<o?j:o:n<o?n:o;e=h>k?h>q?h:q:k>q?k:q;d=j>n?j>o?j:o:n>o?n:o}else{b=h<k?h<q?h<b?h:b:q<b?q:b:k<q?k<b?k:b:q<b?q:b;c=j<n?j<o?j<c?j:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;e=h>k?h>q?h>e?h:e:q>e?q:e:k>q?k>e?k:e:q>e?q:e;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
 e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=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,e,d,f,g,i,h,j,k,n,q,o,w,z){this.set(a||1,b||0,c||0,e||0,d||0,f||1,g||0,i||0,h||0,j||0,k||1,n||0,q||0,o||0,w||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,e,d,f,g,i,h,j,k,n,q,o,w,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=k;this.n34=n;this.n41=q;this.n42=o;this.n43=w;this.n44=z;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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 e=THREE.Matrix4.__v1,
-d=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;e.cross(c,f).normalize();if(e.length()===0){f.x+=1.0E-4;e.cross(c,f).normalize()}d.cross(f,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=f.x;this.n21=e.y;this.n22=d.y;this.n23=f.y;this.n31=e.z;this.n32=d.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
+THREE.Matrix4=function(a,b,c,e,d,g,f,i,h,j,k,n,q,o,w,z){this.set(a||1,b||0,c||0,e||0,d||0,g||1,f||0,i||0,h||0,j||0,k||1,n||0,q||0,o||0,w||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,e,d,g,f,i,h,j,k,n,q,o,w,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=k;this.n34=n;this.n41=q;this.n42=o;this.n43=w;this.n44=z;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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 e=THREE.Matrix4.__v1,
+d=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x+=1.0E-4;e.cross(c,g).normalize()}d.cross(g,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=g.x;this.n21=e.y;this.n22=d.y;this.n23=g.y;this.n31=e.z;this.n32=d.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
 e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*d;return a},rotateAxis:function(a){var b=a.x,c=a.y,e=a.z;a.x=b*this.n11+c*this.n12+e*this.n13;a.y=b*this.n21+c*this.n22+e*this.n23;a.z=b*this.n31+c*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 c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,q=a.n33,o=a.n34,w=a.n41,z=a.n42,D=a.n43,A=a.n44,U=b.n11,V=b.n12,B=b.n13,u=b.n14,p=b.n21,Y=b.n22,
-Z=b.n23,aa=b.n24,P=b.n31,x=b.n32,t=b.n33,K=b.n34;this.n11=c*U+e*p+d*P;this.n12=c*V+e*Y+d*x;this.n13=c*B+e*Z+d*t;this.n14=c*u+e*aa+d*K+f;this.n21=g*U+i*p+h*P;this.n22=g*V+i*Y+h*x;this.n23=g*B+i*Z+h*t;this.n24=g*u+i*aa+h*K+j;this.n31=k*U+n*p+q*P;this.n32=k*V+n*Y+q*x;this.n33=k*B+n*Z+q*t;this.n34=k*u+n*aa+q*K+o;this.n41=w*U+z*p+D*P;this.n42=w*V+z*Y+D*x;this.n43=w*B+z*Z+D*t;this.n44=w*u+z*aa+D*K+A;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
+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,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,q=a.n33,o=a.n34,w=a.n41,z=a.n42,D=a.n43,A=a.n44,U=b.n11,V=b.n12,B=b.n13,u=b.n14,p=b.n21,Y=b.n22,
+Z=b.n23,aa=b.n24,P=b.n31,x=b.n32,t=b.n33,K=b.n34;this.n11=c*U+e*p+d*P;this.n12=c*V+e*Y+d*x;this.n13=c*B+e*Z+d*t;this.n14=c*u+e*aa+d*K+g;this.n21=f*U+i*p+h*P;this.n22=f*V+i*Y+h*x;this.n23=f*B+i*Z+h*t;this.n24=f*u+i*aa+h*K+j;this.n31=k*U+n*p+q*P;this.n32=k*V+n*Y+q*x;this.n33=k*B+n*Z+q*t;this.n34=k*u+n*aa+q*K+o;this.n41=w*U+z*p+D*P;this.n42=w*V+z*Y+D*x;this.n43=w*B+z*Z+D*t;this.n44=w*u+z*aa+D*K+A;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,e=this.n14,d=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,k=this.n33,n=this.n34,q=this.n41,o=this.n42,w=this.n43,z=this.n44;return e*g*j*q-c*i*j*q-e*f*k*q+b*i*k*q+c*f*n*q-b*g*n*q-e*g*h*o+c*i*h*o+e*d*k*o-a*i*k*o-c*d*n*o+a*g*n*o+e*f*h*w-b*i*h*w-e*d*j*w+a*i*j*w+b*d*n*w-a*f*n*w-c*f*h*z+b*g*h*z+c*d*j*z-a*g*j*z-b*d*k*z+a*f*k*z},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.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,k=this.n33,n=this.n34,q=this.n41,o=this.n42,w=this.n43,z=this.n44;return e*f*j*q-c*i*j*q-e*g*k*q+b*i*k*q+c*g*n*q-b*f*n*q-e*f*h*o+c*i*h*o+e*d*k*o-a*i*k*o-c*d*n*o+a*f*n*o+e*g*h*w-b*i*h*w-e*d*j*w+a*i*j*w+b*d*n*w-a*g*n*w-c*g*h*z+b*f*h*z+c*d*j*z-a*f*j*z-b*d*k*z+a*g*k*z},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),e=Math.sin(b),d=1-c,f=a.x,g=a.y,i=a.z,h=d*f,j=d*g;this.set(h*
-f+c,h*g-e*i,h*i+e*g,0,h*g+e*i,j*g+c,j*i-e*f,0,h*i-e*g,j*i+e*f,d*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,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,i=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=i*f+a*e;this.n22=-i*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,e=a.z,d=a.w,f=b+b,g=c+c,i=e+e;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;e*=i;f*=d;g*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);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=
+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),e=Math.sin(b),d=1-c,g=a.x,f=a.y,i=a.z,h=d*g,j=d*f;this.set(h*
+g+c,h*f-e*i,h*i+e*f,0,h*f+e*i,j*f+c,j*i-e*g,0,h*i-e*f,j*i+e*g,d*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,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var g=Math.cos(e);e=Math.sin(e);var f=a*c,i=b*c;this.n11=d*g;this.n12=-d*e;this.n13=c;this.n21=i*g+a*e;this.n22=-i*e+a*g;this.n23=-b*d;this.n31=-f*g+b*e;this.n32=f*e+b*g;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,e=a.z,d=a.w,g=b+b,f=c+c,i=e+e;a=b*g;var h=b*f;b*=i;var j=c*f;c*=i;e*=i;g*=d;f*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+f;this.n21=h+d;this.n22=1-(a+e);this.n23=c-g;this.n31=b-f;this.n32=c+g;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,e=1/b.y,d=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*d;this.n23=a.n23*d;this.n33=a.n33*d}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,q=a.n33,o=a.n34,w=a.n41,z=a.n42,D=a.n43,A=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*z-j*q*z+j*n*D-i*o*D-h*n*A+i*q*A;b.n12=f*q*z-d*o*z-f*n*D+e*o*D+d*n*A-e*q*A;b.n13=d*j*z-f*h*z+f*i*D-e*j*D-d*i*A+e*h*A;b.n14=f*h*n-d*j*n-f*i*q+e*j*q+d*i*o-e*h*o;b.n21=j*q*w-h*o*w-j*k*D+g*o*D+h*k*A-g*q*A;b.n22=d*o*w-f*q*w+f*k*D-c*o*D-d*k*A+c*q*A;b.n23=f*h*w-d*j*w-f*g*D+c*j*D+d*g*A-c*h*A;
-b.n24=d*j*k-f*h*k+f*g*q-c*j*q-d*g*o+c*h*o;b.n31=i*o*w-j*n*w+j*k*z-g*o*z-i*k*A+g*n*A;b.n32=f*n*w-e*o*w-f*k*z+c*o*z+e*k*A-c*n*A;b.n33=d*j*w-f*i*w+f*g*z-c*j*z-e*g*A+c*i*A;b.n34=f*i*k-e*j*k-f*g*n+c*j*n+e*g*o-c*i*o;b.n41=h*n*w-i*q*w-h*k*z+g*q*z+i*k*D-g*n*D;b.n42=e*q*w-d*n*w+d*k*z-c*q*z-e*k*D+c*n*D;b.n43=d*i*w-e*h*w-d*g*z+c*h*z+e*g*D-c*i*D;b.n44=e*h*k-d*i*k+d*g*n-c*h*n-e*g*q+c*i*q;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-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,k=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*k;c[8]=a*n;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
-THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;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+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/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.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,q=a.n33,o=a.n34,w=a.n41,z=a.n42,D=a.n43,A=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*z-j*q*z+j*n*D-i*o*D-h*n*A+i*q*A;b.n12=g*q*z-d*o*z-g*n*D+e*o*D+d*n*A-e*q*A;b.n13=d*j*z-g*h*z+g*i*D-e*j*D-d*i*A+e*h*A;b.n14=g*h*n-d*j*n-g*i*q+e*j*q+d*i*o-e*h*o;b.n21=j*q*w-h*o*w-j*k*D+f*o*D+h*k*A-f*q*A;b.n22=d*o*w-g*q*w+g*k*D-c*o*D-d*k*A+c*q*A;b.n23=g*h*w-d*j*w-g*f*D+c*j*D+d*f*A-c*h*A;
+b.n24=d*j*k-g*h*k+g*f*q-c*j*q-d*f*o+c*h*o;b.n31=i*o*w-j*n*w+j*k*z-f*o*z-i*k*A+f*n*A;b.n32=g*n*w-e*o*w-g*k*z+c*o*z+e*k*A-c*n*A;b.n33=d*j*w-g*i*w+g*f*z-c*j*z-e*f*A+c*i*A;b.n34=g*i*k-e*j*k-g*f*n+c*j*n+e*f*o-c*i*o;b.n41=h*n*w-i*q*w-h*k*z+f*q*z+i*k*D-f*n*D;b.n42=e*q*w-d*n*w+d*k*z-c*q*z-e*k*D+c*n*D;b.n43=d*i*w-e*h*w-d*f*z+c*h*z+e*f*D-c*i*D;b.n44=e*h*k-d*i*k+d*f*n-c*h*n-e*f*q+c*i*q;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-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,k=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*k;c[8]=a*n;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,e,d,g){var f;f=new THREE.Matrix4;f.n11=2*d/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*d/(e-c);f.n23=(e+c)/(e-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+d)/(g-d);f.n34=-2*g*d/(g-d);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
+THREE.Matrix4.makeOrtho=function(a,b,c,e,d,g){var f,i,h,j;f=new THREE.Matrix4;i=b-a;h=c-e;j=g-d;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+e)/h);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((g+d)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};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))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){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,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?e:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*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,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,k=h*e+i*c-f*d,n=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+k*-i-n*-g;b.y=k*h+c*-g+n*-f-j*-i;b.z=n*h+c*-i+j*-g-k*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
-THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.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.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
+THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,k=h*e+i*c-g*d,n=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+k*-i-n*-f;b.y=k*h+c*-f+n*-g-j*-i;b.z=n*h+c*-i+j*-f-k*-g;return b}};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<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}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};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.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,f,g,i=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){f=this.faces[e];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.vertexNormals.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,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++){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{e=
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,g,f,i=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){g=this.faces[e];if(a&&g.vertexNormals.length){i.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)i.addSelf(g.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];f=this.vertices[g.c];i.sub(f.position,c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||
+i.normalize();g.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,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++){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{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++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[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(e[c.a]);
-c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(E,R,S,W,H,C,F){i=E.vertices[R].position;h=E.vertices[S].position;j=E.vertices[W].position;k=g[H];n=g[C];q=g[F];o=h.x-i.x;w=j.x-i.x;z=h.y-i.y;D=j.y-i.y;A=h.z-i.z;U=j.z-i.z;V=n.u-k.u;B=q.u-k.u;u=n.v-k.v;p=q.v-k.v;Y=1/(V*p-B*u);x.set((p*
-o-u*w)*Y,(p*z-u*D)*Y,(p*A-u*U)*Y);t.set((V*w-B*o)*Y,(V*D-B*z)*Y,(V*U-B*A)*Y);aa[R].addSelf(x);aa[S].addSelf(x);aa[W].addSelf(x);P[R].addSelf(t);P[S].addSelf(t);P[W].addSelf(t)}var b,c,e,d,f,g,i,h,j,k,n,q,o,w,z,D,A,U,V,B,u,p,Y,Z,aa=[],P=[],x=new THREE.Vector3,t=new THREE.Vector3,K=new THREE.Vector3,N=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];g=this.faceVertexUvs[0][b];
-if(f instanceof THREE.Face3)a(this,f.a,f.b,f.c,0,1,2);else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3)}}var T=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++){Q.copy(f.vertexNormals[e]);d=f[T[e]];Z=aa[d];K.copy(Z);K.subSelf(Q.multiplyScalar(Q.dot(Z))).normalize();N.cross(f.vertexNormals[e],Z);d=N.dot(P[d]);d=d<0?-1:1;f.vertexTangents[e]=new THREE.Vector4(K.x,K.y,K.z,d)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(E,R,S,W,H,C,F){i=E.vertices[R].position;h=E.vertices[S].position;j=E.vertices[W].position;k=f[H];n=f[C];q=f[F];o=h.x-i.x;w=j.x-i.x;z=h.y-i.y;D=j.y-i.y;A=h.z-i.z;U=j.z-i.z;V=n.u-k.u;B=q.u-k.u;u=n.v-k.v;p=q.v-k.v;Y=1/(V*p-B*u);x.set((p*
+o-u*w)*Y,(p*z-u*D)*Y,(p*A-u*U)*Y);t.set((V*w-B*o)*Y,(V*D-B*z)*Y,(V*U-B*A)*Y);aa[R].addSelf(x);aa[S].addSelf(x);aa[W].addSelf(x);P[R].addSelf(t);P[S].addSelf(t);P[W].addSelf(t)}var b,c,e,d,g,f,i,h,j,k,n,q,o,w,z,D,A,U,V,B,u,p,Y,Z,aa=[],P=[],x=new THREE.Vector3,t=new THREE.Vector3,K=new THREE.Vector3,N=new THREE.Vector3,Q=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){aa[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];f=this.faceVertexUvs[0][b];
+if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var T=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(e=0;e<g.vertexNormals.length;e++){Q.copy(g.vertexNormals[e]);d=g[T[e]];Z=aa[d];K.copy(Z);K.subSelf(Q.multiplyScalar(Q.dot(Z))).normalize();N.cross(g.vertexNormals[e],Z);d=N.dot(P[d]);d=d<0?-1:1;g.vertexTangents[e]=new THREE.Vector4(K.x,K.y,K.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.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var f=0;f<a.length;f++)a[f].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var f=0;f<d.hierarchy.length;f++){for(var g=0;g<d.hierarchy[f].keys.length;g++){if(d.hierarchy[f].keys[g].time<
-0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var i=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){i={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++){var j=d.hierarchy[f].keys[g].morphTargets[h];i[j]=-1}d.hierarchy[f].usedMorphTargets=i;for(g=0;g<d.hierarchy[f].keys.length;g++){var k=
-{};for(j in i){for(h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++)if(d.hierarchy[f].keys[g].morphTargets[h]===j){k[j]=d.hierarchy[f].keys[g].morphTargetsInfluences[h];break}h===d.hierarchy[f].keys[g].morphTargets.length&&(k[j]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=k}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
-d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(f=0;f<d.hierarchy.length;f++)d.JIT.hierarchy.push(Array(g));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var f=[];if(d instanceof THREE.SkinnedMesh)for(var g=0;g<d.bones.length;g++)f.push(d.bones[g]);else e(d,f);return f};var e=function(d,f){f.push(d);for(var g=0;g<d.children.length;g++)e(d.children[g],f)};c.LINEAR=
+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}},computeEdgeFaces:function(){function a(h,j){return Math.min(h,
+j)+"_"+Math.max(h,j)}function b(h,j,k){if(h[j]===undefined){h[j]={set:{},array:[]};h[j].set[k]=1;h[j].array.push(k)}else if(h[j].set[k]===undefined){h[j].set[k]=1;h[j].array.push(k)}}var c,e,d,g,f,i={};c=0;for(e=this.faces.length;c<e;c++){f=this.faces[c];if(f instanceof THREE.Face3){d=a(f.a,f.b);b(i,d,c);d=a(f.b,f.c);b(i,d,c);d=a(f.a,f.c);b(i,d,c)}else if(f instanceof THREE.Face4){d=a(f.b,f.d);b(i,d,c);d=a(f.a,f.b);b(i,d,c);d=a(f.a,f.d);b(i,d,c);d=a(f.b,f.c);b(i,d,c);d=a(f.c,f.d);b(i,d,c)}}c=0;for(e=
+this.edges.length;c<e;c++){f=this.edges[c];d=f.vertexIndices[0];g=f.vertexIndices[1];f.faceIndices=i[a(d,g)].array;for(d=0;d<f.faceIndices.length;d++){g=f.faceIndices[d];f.faces.push(this.faces[g])}}}};THREE.GeometryIdCounter=0;
+THREE.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var g=0;g<a.length;g++)a[g].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var g=0;g<d.hierarchy.length;g++){for(var f=0;f<d.hierarchy[g].keys.length;f++){if(d.hierarchy[g].keys[f].time<
+0)d.hierarchy[g].keys[f].time=0;if(d.hierarchy[g].keys[f].rot!==undefined&&!(d.hierarchy[g].keys[f].rot instanceof THREE.Quaternion)){var i=d.hierarchy[g].keys[f].rot;d.hierarchy[g].keys[f].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[g].keys[0].morphTargets!==undefined){i={};for(f=0;f<d.hierarchy[g].keys.length;f++)for(var h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++){var j=d.hierarchy[g].keys[f].morphTargets[h];i[j]=-1}d.hierarchy[g].usedMorphTargets=i;for(f=0;f<d.hierarchy[g].keys.length;f++){var k=
+{};for(j in i){for(h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++)if(d.hierarchy[g].keys[f].morphTargets[h]===j){k[j]=d.hierarchy[g].keys[f].morphTargetsInfluences[h];break}h===d.hierarchy[g].keys[f].morphTargets.length&&(k[j]=0)}d.hierarchy[g].keys[f].morphTargetsInfluences=k}}for(f=1;f<d.hierarchy[g].keys.length;f++)if(d.hierarchy[g].keys[f].time===d.hierarchy[g].keys[f-1].time){d.hierarchy[g].keys.splice(f,1);f--}for(f=1;f<d.hierarchy[g].keys.length;f++)d.hierarchy[g].keys[f].index=f}f=parseInt(d.length*
+d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(g=0;g<d.hierarchy.length;g++)d.JIT.hierarchy.push(Array(f));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var g=[];if(d instanceof THREE.SkinnedMesh)for(var f=0;f<d.bones.length;f++)g.push(d.bones[f]);else e(d,g);return g};var e=function(d,g){g.push(d);for(var f=0;f<d.children.length;f++)e(d.children[f],g)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;var c,e=this.hierarchy.length,d;for(c=0;c<e;c++){d=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)d.useQuaternion=!0;d.matrixAutoUpdate=!0;if(d.animationCache===undefined){d.animationCache={};d.animationCache.prevKey={pos:0,rot:0,scl:0};d.animationCache.nextKey={pos:0,rot:0,scl:0};d.animationCache.originalMatrix=
-d instanceof THREE.Bone?d.skinMatrix:d.matrix}var f=d.animationCache.prevKey;d=d.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
+d instanceof THREE.Bone?d.skinMatrix:d.matrix}var g=d.animationCache.prevKey;d=d.animationCache.nextKey;g.pos=this.data.hierarchy[c].keys[0];g.rot=this.data.hierarchy[c].keys[0];g.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,f,g,i,h,j,k=this.data.JIT.hierarchy,n,q;this.currentTime+=a*this.timeScale;q=this.currentTime;n=this.currentTime%=this.data.length;j=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,w=this.hierarchy.length;o<w;o++){a=this.hierarchy[o];h=a.animationCache;if(this.JITCompile&&k[o][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
-!1}else{a.matrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var z=0;z<3;z++){c=b[z];g=h.prevKey[c];i=h.nextKey[c];if(i.time<=q){if(n<q)if(this.loop){g=this.data.hierarchy[o].keys[0];for(i=this.getNextKeyWith(c,o,1);i.time<n;){g=i;i=this.getNextKeyWith(c,o,i.index+1)}}else{this.stop();return}else{do{g=i;i=this.getNextKeyWith(c,o,i.index+1)}while(i.time<
-n)}h.prevKey[c]=g;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-g.time)/(i.time-g.time);d=g[c];f=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",o,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",o,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&k[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o<this.hierarchy.length;o++)k[o][j]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,f,g,i,h,j;d=(a.length-1)*b;f=Math.floor(d);d-=f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;g=d*c;e[0]=this.interpolate(f[0],i[0],h[0],j[0],d,c,g);e[1]=this.interpolate(f[1],i[1],h[1],j[1],d,c,g);e[2]=this.interpolate(f[2],i[2],h[2],j[2],d,c,g);return e};
-THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*f+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,g,f,i,h,j,k=this.data.JIT.hierarchy,n,q;this.currentTime+=a*this.timeScale;q=this.currentTime;n=this.currentTime%=this.data.length;j=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,w=this.hierarchy.length;o<w;o++){a=this.hierarchy[o];h=a.animationCache;if(this.JITCompile&&k[o][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
+!1}else{a.matrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var z=0;z<3;z++){c=b[z];f=h.prevKey[c];i=h.nextKey[c];if(i.time<=q){if(n<q)if(this.loop){f=this.data.hierarchy[o].keys[0];for(i=this.getNextKeyWith(c,o,1);i.time<n;){f=i;i=this.getNextKeyWith(c,o,i.index+1)}}else{this.stop();return}else{do{f=i;i=this.getNextKeyWith(c,o,i.index+1)}while(i.time<
+n)}h.prevKey[c]=f;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-f.time)/(i.time-f.time);d=f[c];g=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",o,f.index-1).pos;this.points[1]=d;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",o,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(d,g,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}}}}if(this.JITCompile&&k[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o<this.hierarchy.length;o++)k[o][j]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,g,f,i,h,j;d=(a.length-1)*b;g=Math.floor(d);d-=g;c[0]=g==0?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;f=d*c;e[0]=this.interpolate(g[0],i[0],h[0],j[0],d,c,f);e[1]=this.interpolate(g[1],i[1],h[1],j[1],d,c,f);e[2]=this.interpolate(g[2],i[2],h[2],j[2],d,c,f);return e};
+THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*f+(-3*(b-c)-2*a-e)*g+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
 THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.target=d||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.updateMatrix=function(){this.update(undefined,!0)};
@@ -99,7 +101,7 @@ THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.sha
 THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==undefined?a.map:null;this.size=a.size!==undefined?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==undefined?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==undefined?a.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==undefined?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==undefined?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;
-THREE.Texture=function(a,b,c,e,d,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=e!==undefined?e:THREE.ClampToEdgeWrapping;this.magFilter=d!==undefined?d:THREE.LinearFilter;this.minFilter=f!==undefined?f: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,c,e,d,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=e!==undefined?e:THREE.ClampToEdgeWrapping;this.magFilter=d!==undefined?d:THREE.LinearFilter;this.minFilter=g!==undefined?g: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.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;
@@ -117,20 +119,20 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 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(){var x=h[i]=h[i]||new THREE.RenderableVertex;i++;return x}function b(x,t){return t.z-x.z}function c(x,t){var K=0,N=1,Q=x.z+x.w,T=t.z+t.w,E=-x.z+x.w,R=-t.z+t.w;if(Q>=0&&T>=0&&E>=0&&R>=0)return!0;else if(Q<0&&T<0||E<0&&R<0)return!1;else{if(Q<0)K=Math.max(K,Q/(Q-T));else T<0&&(N=Math.min(N,Q/(Q-T)));if(E<0)K=Math.max(K,E/(E-R));else R<0&&(N=Math.min(N,E/(E-R)));if(N<K)return!1;else{x.lerpSelf(t,K);t.lerpSelf(x,1-N);return!0}}}var e,d,f=[],g,i,h=[],j,k,n=[],q,o=
+THREE.Projector=function(){function a(){var x=h[i]=h[i]||new THREE.RenderableVertex;i++;return x}function b(x,t){return t.z-x.z}function c(x,t){var K=0,N=1,Q=x.z+x.w,T=t.z+t.w,E=-x.z+x.w,R=-t.z+t.w;if(Q>=0&&T>=0&&E>=0&&R>=0)return!0;else if(Q<0&&T<0||E<0&&R<0)return!1;else{if(Q<0)K=Math.max(K,Q/(Q-T));else T<0&&(N=Math.min(N,Q/(Q-T)));if(E<0)K=Math.max(K,E/(E-R));else R<0&&(N=Math.min(N,E/(E-R)));if(N<K)return!1;else{x.lerpSelf(t,K);t.lerpSelf(x,1-N);return!0}}}var e,d,g=[],f,i,h=[],j,k,n=[],q,o=
 [],w,z,D=[],A,U,V=[],B=new THREE.Vector4,u=new THREE.Vector4,p=new THREE.Matrix4,Y=new THREE.Matrix4,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],aa=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(x,t){p.multiply(t.projectionMatrix,t.matrixWorldInverse);p.multiplyVector3(x);return x};this.unprojectVector=function(x,t){p.multiply(t.matrixWorld,THREE.Matrix4.makeInvert(t.projectionMatrix));p.multiplyVector3(x);return x};
-this.projectObjects=function(x,t,K){t=[];var N,Q,T;d=0;Q=x.objects;x=0;for(N=Q.length;x<N;x++){T=Q[x];var E;if(!(E=!T.visible))if(E=T instanceof THREE.Mesh){a:{E=void 0;for(var R=T.matrixWorld,S=-T.geometry.boundingSphere.radius*Math.max(T.scale.x,Math.max(T.scale.y,T.scale.z)),W=0;W<6;W++){E=Z[W].x*R.n14+Z[W].y*R.n24+Z[W].z*R.n34+Z[W].w;if(E<=S){E=!1;break a}}E=!0}E=!E}if(!E){E=f[d]=f[d]||new THREE.RenderableObject;d++;e=E;B.copy(T.position);p.multiplyVector3(B);e.object=T;e.z=B.z;t.push(e)}}K&&
+this.projectObjects=function(x,t,K){t=[];var N,Q,T;d=0;Q=x.objects;x=0;for(N=Q.length;x<N;x++){T=Q[x];var E;if(!(E=!T.visible))if(E=T instanceof THREE.Mesh){a:{E=void 0;for(var R=T.matrixWorld,S=-T.geometry.boundingSphere.radius*Math.max(T.scale.x,Math.max(T.scale.y,T.scale.z)),W=0;W<6;W++){E=Z[W].x*R.n14+Z[W].y*R.n24+Z[W].z*R.n34+Z[W].w;if(E<=S){E=!1;break a}}E=!0}E=!E}if(!E){E=g[d]=g[d]||new THREE.RenderableObject;d++;e=E;B.copy(T.position);p.multiplyVector3(B);e.object=T;e.z=B.z;t.push(e)}}K&&
 t.sort(b);return t};this.projectScene=function(x,t,K){var N=[],Q=t.near,T=t.far,E,R,S,W,H,C,F,I,M,G,da,ia,ja,fa,pa,Da,wa;U=z=q=k=0;t.matrixAutoUpdate&&t.updateMatrix();x.update(undefined,!1,t);p.multiply(t.projectionMatrix,t.matrixWorldInverse);Z[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);Z[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);Z[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);Z[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);Z[4].set(p.n41-p.n31,p.n42-
-p.n32,p.n43-p.n33,p.n44-p.n34);Z[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);for(E=0;E<6;E++){M=Z[E];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}M=this.projectObjects(x,t,!0);x=0;for(E=M.length;x<E;x++){G=M[x].object;if(G.visible){da=G.matrixWorld;ia=G.matrixRotationWorld;ja=G.materials;fa=G.overdraw;i=0;if(G instanceof THREE.Mesh){pa=G.geometry;W=pa.vertices;Da=pa.faces;pa=pa.faceVertexUvs;R=0;for(S=W.length;R<S;R++){g=a();g.positionWorld.copy(W[R].position);da.multiplyVector3(g.positionWorld);
-g.positionScreen.copy(g.positionWorld);p.multiplyVector4(g.positionScreen);g.positionScreen.x/=g.positionScreen.w;g.positionScreen.y/=g.positionScreen.w;g.visible=g.positionScreen.z>Q&&g.positionScreen.z<T}W=0;for(R=Da.length;W<R;W++){S=Da[W];if(S instanceof THREE.Face3){H=h[S.a];C=h[S.b];F=h[S.c];if(H.visible&&C.visible&&F.visible&&(G.doubleSided||G.flipSided!=(F.positionScreen.x-H.positionScreen.x)*(C.positionScreen.y-H.positionScreen.y)-(F.positionScreen.y-H.positionScreen.y)*(C.positionScreen.x-
+p.n32,p.n43-p.n33,p.n44-p.n34);Z[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);for(E=0;E<6;E++){M=Z[E];M.divideScalar(Math.sqrt(M.x*M.x+M.y*M.y+M.z*M.z))}M=this.projectObjects(x,t,!0);x=0;for(E=M.length;x<E;x++){G=M[x].object;if(G.visible){da=G.matrixWorld;ia=G.matrixRotationWorld;ja=G.materials;fa=G.overdraw;i=0;if(G instanceof THREE.Mesh){pa=G.geometry;W=pa.vertices;Da=pa.faces;pa=pa.faceVertexUvs;R=0;for(S=W.length;R<S;R++){f=a();f.positionWorld.copy(W[R].position);da.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);p.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>Q&&f.positionScreen.z<T}W=0;for(R=Da.length;W<R;W++){S=Da[W];if(S instanceof THREE.Face3){H=h[S.a];C=h[S.b];F=h[S.c];if(H.visible&&C.visible&&F.visible&&(G.doubleSided||G.flipSided!=(F.positionScreen.x-H.positionScreen.x)*(C.positionScreen.y-H.positionScreen.y)-(F.positionScreen.y-H.positionScreen.y)*(C.positionScreen.x-
 H.positionScreen.x)<0)){I=n[k]=n[k]||new THREE.RenderableFace3;k++;j=I;j.v1.copy(H);j.v2.copy(C);j.v3.copy(F)}else continue}else if(S instanceof THREE.Face4){H=h[S.a];C=h[S.b];F=h[S.c];I=h[S.d];if(H.visible&&C.visible&&F.visible&&I.visible&&(G.doubleSided||G.flipSided!=((I.positionScreen.x-H.positionScreen.x)*(C.positionScreen.y-H.positionScreen.y)-(I.positionScreen.y-H.positionScreen.y)*(C.positionScreen.x-H.positionScreen.x)<0||(C.positionScreen.x-F.positionScreen.x)*(I.positionScreen.y-F.positionScreen.y)-
 (C.positionScreen.y-F.positionScreen.y)*(I.positionScreen.x-F.positionScreen.x)<0))){wa=o[q]=o[q]||new THREE.RenderableFace4;q++;j=wa;j.v1.copy(H);j.v2.copy(C);j.v3.copy(F);j.v4.copy(I)}else continue}j.normalWorld.copy(S.normal);ia.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);da.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.multiplyVector3(j.centroidScreen);F=S.vertexNormals;H=0;for(C=F.length;H<C;H++){I=j.vertexNormalsWorld[H];I.copy(F[H]);ia.multiplyVector3(I)}H=
 0;for(C=pa.length;H<C;H++)if(wa=pa[H][W]){F=0;for(I=wa.length;F<I;F++)j.uvs[H][F]=wa[F]}j.meshMaterials=ja;j.faceMaterials=S.materials;j.overdraw=fa;j.z=j.centroidScreen.z;N.push(j)}}else if(G instanceof THREE.Line){Y.multiply(p,da);W=G.geometry.vertices;H=a();H.positionScreen.copy(W[0].position);Y.multiplyVector4(H.positionScreen);R=1;for(S=W.length;R<S;R++){H=a();H.positionScreen.copy(W[R].position);Y.multiplyVector4(H.positionScreen);C=h[i-2];aa.copy(H.positionScreen);P.copy(C.positionScreen);
 if(c(aa,P)){aa.multiplyScalar(1/aa.w);P.multiplyScalar(1/P.w);da=D[z]=D[z]||new THREE.RenderableLine;z++;w=da;w.v1.positionScreen.copy(aa);w.v2.positionScreen.copy(P);w.z=Math.max(aa.z,P.z);w.materials=G.materials;N.push(w)}}}else if(G instanceof THREE.Particle){u.set(G.position.x,G.position.y,G.position.z,1);p.multiplyVector4(u);u.z/=u.w;if(u.z>0&&u.z<1){da=V[U]=V[U]||new THREE.RenderableParticle;U++;A=da;A.x=u.x/u.w;A.y=u.y/u.w;A.z=u.z;A.rotation=G.rotation.z;A.scale.x=G.scale.x*Math.abs(A.x-(u.x+
 t.projectionMatrix.n11)/(u.w+t.projectionMatrix.n14));A.scale.y=G.scale.y*Math.abs(A.y-(u.y+t.projectionMatrix.n22)/(u.w+t.projectionMatrix.n24));A.materials=G.materials;N.push(A)}}}}K&&N.sort(b);return N}};
-THREE.CanvasRenderer=function(){function a($){if(o!=$)k.globalAlpha=o=$}function b($){if(w!=$){switch($){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}w=$}}function c($){if(z!=$)k.strokeStyle=z=$}var e=null,d=new THREE.Projector,f=document.createElement("canvas"),g,i,h,j,k=f.getContext("2d"),n=new THREE.Color(0),q=0,o=1,w=0,z=null,D=null,
+THREE.CanvasRenderer=function(){function a($){if(o!=$)k.globalAlpha=o=$}function b($){if(w!=$){switch($){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}w=$}}function c($){if(z!=$)k.strokeStyle=z=$}var e=null,d=new THREE.Projector,g=document.createElement("canvas"),f,i,h,j,k=g.getContext("2d"),n=new THREE.Color(0),q=0,o=1,w=0,z=null,D=null,
 A=null,U=null,V=null,B,u,p,Y,Z=new THREE.RenderableVertex,aa=new THREE.RenderableVertex,P,x,t,K,N,Q,T,E,R,S,W,H,C=new THREE.Color,F=new THREE.Color,I=new THREE.Color,M=new THREE.Color,G=new THREE.Color,da,ia,ja,fa,pa,Da,wa,Wa,Xa,Ya,Ba=new THREE.Rectangle,ka=new THREE.Rectangle,ea=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,ba=new THREE.Vector3,Ha,Ia,Va,la,Ja,Oa,Ea=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");
-Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function($,ma){g=$;i=ma;h=g/2;j=i/2;f.width=g;f.height=i;Ba.set(-h,-j,h,j);o=1;w=0;V=U=A=D=z=null};this.setClearColor=function($,ma){n=$;q=ma};this.setClearColorHex=function($,ma){n.setHex($);q=
+Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);la=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ea;Oa=Ja.getContext("2d");Oa.translate(-Ea/2,-Ea/2);Oa.scale(Ea,Ea);Ea--;this.domElement=g;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function($,ma){f=$;i=ma;h=f/2;j=i/2;g.width=f;g.height=i;Ba.set(-h,-j,h,j);o=1;w=0;V=U=A=D=z=null};this.setClearColor=function($,ma){n=$;q=ma};this.setClearColorHex=function($,ma){n.setHex($);q=
 ma};this.clear=function(){k.setTransform(1,0,0,-1,h,j);if(!ka.isEmpty()){ka.inflate(1);ka.minSelf(Ba);if(n.hex==0&&q==0)k.clearRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight());else{b(THREE.NormalBlending);a(1);k.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+q+")";k.fillRect(ka.getX(),ka.getY(),ka.getWidth(),ka.getHeight())}ka.empty()}};this.render=function($,ma){function ab(m){var y,s,r,L=m.lights;ga.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);
 m=0;for(y=L.length;m<y;m++){s=L[m];r=s.color;if(s instanceof THREE.AmbientLight){ga.r+=r.r;ga.g+=r.g;ga.b+=r.b}else if(s instanceof THREE.DirectionalLight){Ma.r+=r.r;Ma.g+=r.g;Ma.b+=r.b}else if(s instanceof THREE.PointLight){Na.r+=r.r;Na.g+=r.g;Na.b+=r.b}}}function ra(m,y,s,r){var L,J,v,l,X=m.lights;m=0;for(L=X.length;m<L;m++){J=X[m];v=J.color;if(J instanceof THREE.DirectionalLight){l=s.dot(J.position);if(!(l<=0)){l*=J.intensity;r.r+=v.r*l;r.g+=v.g*l;r.b+=v.b*l}}else if(J instanceof THREE.PointLight){l=
 s.dot(ba.sub(J.position,y).normalize());if(!(l<=0)){l*=J.distance==0?1:1-Math.min(y.distanceTo(J.position)/J.distance,1);if(l!=0){l*=J.intensity;r.r+=v.r*l;r.g+=v.g*l;r.b+=v.b*l}}}}}function bb(m,y,s){a(s.opacity);b(s.blending);var r,L,J,v,l,X;if(s instanceof THREE.ParticleBasicMaterial){if(s.map){v=s.map.image;l=v.width>>1;X=v.height>>1;s=y.scale.x*h;J=y.scale.y*j;r=s*l;L=J*X;ea.set(m.x-r,m.y-L,m.x+r,m.y+L);if(Ba.instersects(ea)){k.save();k.translate(m.x,m.y);k.rotate(-y.rotation);k.scale(s,-J);

+ 24 - 24
build/custom/ThreeDOM.js

@@ -12,21 +12,21 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 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,e){this.set(a||0,b||0,c||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(g,f){return g.distance-f.distance});return d},intersectObject:function(a){function b(t,r,C,G){G=G.clone().subSelf(r);C=C.clone().subSelf(r);var K=t.clone().subSelf(r);t=G.dot(G);r=G.dot(C);G=G.dot(K);var x=C.dot(C);C=C.dot(K);K=1/(t*x-r*r);x=(x*G-r*C)*K;t=(t*C-r*G)*K;return x>0&&t>0&&x+t<1}var c,e,d,g,f,i,h,j,m,l,
-n,k=a.geometry,p=k.vertices,q=[];c=0;for(e=k.faces.length;c<e;c++){d=k.faces[c];l=this.origin.clone();n=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(p[d.a].position.clone());f=h.multiplyVector3(p[d.b].position.clone());i=h.multiplyVector3(p[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(p[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());m=n.dot(j);if(m<0){j=j.dot((new THREE.Vector3).sub(g,l))/m;l=l.addSelf(n.multiplyScalar(j));
-if(d instanceof THREE.Face3){if(b(l,g,f,i)){d={distance:this.origin.distanceTo(l),point:l,face:d,object:a};q.push(d)}}else if(d instanceof THREE.Face4&&(b(l,g,f,h)||b(l,f,i,h))){d={distance:this.origin.distanceTo(l),point:l,face:d,object:a};q.push(d)}}}return q}};
-THREE.Rectangle=function(){function a(){g=e-b;f=d-c}var b,c,e,d,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,m,l){i=!1;b=h;c=j;e=m;d=l;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
-this.add3Points=function(h,j,m,l,n,k){if(i){i=!1;b=h<m?h<n?h:n:m<n?m:n;c=j<l?j<k?j:k:l<k?l:k;e=h>m?h>n?h:n:m>n?m:n;d=j>l?j>k?j:k:l>k?l:k}else{b=h<m?h<n?h<b?h:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b;c=j<l?j<k?j<c?j:c:k<c?k:c:l<k?l<c?l:c:k<c?k:c;e=h>m?h>n?h>e?h:e:n>e?n:e:m>n?m>e?m:e:n>e?n:e;d=j>l?j>k?j>d?j:d:k>d?k:d:l>k?l>d?l:d:k>d?k:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(g,f){return g.distance-f.distance});return d},intersectObject:function(a){function b(t,r,C,G){G=G.clone().subSelf(r);C=C.clone().subSelf(r);var K=t.clone().subSelf(r);t=G.dot(G);r=G.dot(C);G=G.dot(K);var x=C.dot(C);C=C.dot(K);K=1/(t*x-r*r);x=(x*G-r*C)*K;t=(t*C-r*G)*K;return x>0&&t>0&&x+t<1}var c,e,d,g,f,i,h,j,l,m,
+n,k=a.geometry,p=k.vertices,q=[];c=0;for(e=k.faces.length;c<e;c++){d=k.faces[c];m=this.origin.clone();n=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(p[d.a].position.clone());f=h.multiplyVector3(p[d.b].position.clone());i=h.multiplyVector3(p[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(p[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());l=n.dot(j);if(a.doubleSided||(a.flipSided?l>0:l<0)){j=j.dot((new THREE.Vector3).sub(g,m))/
+l;m=m.addSelf(n.multiplyScalar(j));if(d instanceof THREE.Face3){if(b(m,g,f,i)){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};q.push(d)}}else if(d instanceof THREE.Face4&&(b(m,g,f,h)||b(m,f,i,h))){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};q.push(d)}}}return q}};
+THREE.Rectangle=function(){function a(){g=e-b;f=d-c}var b,c,e,d,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,l,m){i=!1;b=h;c=j;e=l;d=m;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
+this.add3Points=function(h,j,l,m,n,k){if(i){i=!1;b=h<l?h<n?h:n:l<n?l:n;c=j<m?j<k?j:k:m<k?m:k;e=h>l?h>n?h:n:l>n?l:n;d=j>m?j>k?j:k:m>k?m:k}else{b=h<l?h<n?h<b?h:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b;c=j<m?j<k?j<c?j:c:k<c?k:c:m<k?m<c?m:c:k<c?k:c;e=h>l?h>n?h>e?h:e:n>e?n:e:l>n?l>e?l:e:n>e?n:e;d=j>m?j>k?j>d?j:d:k>d?k:d:m>k?m>d?m:d:k>d?k:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
 e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=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,e,d,g,f,i,h,j,m,l,n,k,p,q){this.set(a||1,b||0,c||0,e||0,d||0,g||1,f||0,i||0,h||0,j||0,m||1,l||0,n||0,k||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,e,d,g,f,i,h,j,m,l,n,k,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=m;this.n34=l;this.n41=n;this.n42=k;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__v1,
+THREE.Matrix4=function(a,b,c,e,d,g,f,i,h,j,l,m,n,k,p,q){this.set(a||1,b||0,c||0,e||0,d||0,g||1,f||0,i||0,h||0,j||0,l||1,m||0,n||0,k||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,e,d,g,f,i,h,j,l,m,n,k,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=l;this.n34=m;this.n41=n;this.n42=k;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__v1,
 d=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x+=1.0E-4;e.cross(c,g).normalize()}d.cross(g,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=g.x;this.n21=e.y;this.n22=d.y;this.n23=g.y;this.n31=e.z;this.n32=d.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
 e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*d;return a},rotateAxis:function(a){var b=a.x,c=a.y,e=a.z;a.x=b*this.n11+c*this.n12+e*this.n13;a.y=b*this.n21+c*this.n22+e*this.n23;a.z=b*this.n31+c*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 c=a.n11,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,l=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,t=a.n43,r=a.n44,C=b.n11,G=b.n12,K=b.n13,x=b.n14,o=b.n21,Q=b.n22,
-H=b.n23,N=b.n24,O=b.n31,u=b.n32,s=b.n33,I=b.n34;this.n11=c*C+e*o+d*O;this.n12=c*G+e*Q+d*u;this.n13=c*K+e*H+d*s;this.n14=c*x+e*N+d*I+g;this.n21=f*C+i*o+h*O;this.n22=f*G+i*Q+h*u;this.n23=f*K+i*H+h*s;this.n24=f*x+i*N+h*I+j;this.n31=m*C+l*o+n*O;this.n32=m*G+l*Q+n*u;this.n33=m*K+l*H+n*s;this.n34=m*x+l*N+n*I+k;this.n41=p*C+q*o+t*O;this.n42=p*G+q*Q+t*u;this.n43=p*K+q*H+t*s;this.n44=p*x+q*N+t*I+r;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]=
+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,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,l=a.n31,m=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,t=a.n43,r=a.n44,C=b.n11,G=b.n12,K=b.n13,x=b.n14,o=b.n21,Q=b.n22,
+H=b.n23,N=b.n24,O=b.n31,u=b.n32,s=b.n33,I=b.n34;this.n11=c*C+e*o+d*O;this.n12=c*G+e*Q+d*u;this.n13=c*K+e*H+d*s;this.n14=c*x+e*N+d*I+g;this.n21=f*C+i*o+h*O;this.n22=f*G+i*Q+h*u;this.n23=f*K+i*H+h*s;this.n24=f*x+i*N+h*I+j;this.n31=l*C+m*o+n*O;this.n32=l*G+m*Q+n*u;this.n33=l*K+m*H+n*s;this.n34=l*x+m*N+n*I+k;this.n41=p*C+q*o+t*O;this.n42=p*G+q*Q+t*u;this.n43=p*K+q*H+t*s;this.n44=p*x+q*N+t*I+r;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,e=this.n14,d=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,m=this.n33,l=this.n34,n=this.n41,k=this.n42,p=this.n43,q=this.n44;return e*f*j*n-c*i*j*n-e*g*m*n+b*i*m*n+c*g*l*n-b*f*l*n-e*f*h*k+c*i*h*k+e*d*m*k-a*i*m*k-c*d*l*k+a*f*l*k+e*g*h*p-b*i*h*p-e*d*j*p+a*i*j*p+b*d*l*p-a*g*l*p-c*g*h*q+b*f*h*q+c*d*j*q-a*f*j*q-b*d*m*q+a*g*m*q},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,l=this.n33,m=this.n34,n=this.n41,k=this.n42,p=this.n43,q=this.n44;return e*f*j*n-c*i*j*n-e*g*l*n+b*i*l*n+c*g*m*n-b*f*m*n-e*f*h*k+c*i*h*k+e*d*l*k-a*i*l*k-c*d*m*k+a*f*m*k+e*g*h*p-b*i*h*p-e*d*j*p+a*i*j*p+b*d*m*p-a*g*m*p-c*g*h*q+b*f*h*q+c*d*j*q-a*f*j*q-b*d*l*q+a*g*l*q},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
@@ -34,9 +34,9 @@ b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:functio
 g+c,h*f-e*i,h*i+e*f,0,h*f+e*i,j*f+c,j*i-e*g,0,h*i-e*f,j*i+e*g,d*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,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var g=Math.cos(e);e=Math.sin(e);var f=a*c,i=b*c;this.n11=d*g;this.n12=-d*e;this.n13=c;this.n21=i*g+a*e;this.n22=-i*e+a*g;this.n23=-b*d;this.n31=-f*g+b*e;this.n32=f*e+b*g;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
 a.x,c=a.y,e=a.z,d=a.w,g=b+b,f=c+c,i=e+e;a=b*g;var h=b*f;b*=i;var j=c*f;c*=i;e*=i;g*=d;f*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+f;this.n21=h+d;this.n22=1-(a+e);this.n23=c-g;this.n31=b-f;this.n32=c+g;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,e=1/b.y,d=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*d;this.n23=a.n23*d;this.n33=a.n33*d}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,l=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,t=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*q-j*n*q+j*l*t-i*k*t-h*l*r+i*n*r;b.n12=g*n*q-d*k*q-g*l*t+e*k*t+d*l*r-e*n*r;b.n13=d*j*q-g*h*q+g*i*t-e*j*t-d*i*r+e*h*r;b.n14=g*h*l-d*j*l-g*i*n+e*j*n+d*i*k-e*h*k;b.n21=j*n*p-h*k*p-j*m*t+f*k*t+h*m*r-f*n*r;b.n22=d*k*p-g*n*p+g*m*t-c*k*t-d*m*r+c*n*r;b.n23=g*h*p-d*j*p-g*f*t+c*j*t+d*f*r-c*h*r;
-b.n24=d*j*m-g*h*m+g*f*n-c*j*n-d*f*k+c*h*k;b.n31=i*k*p-j*l*p+j*m*q-f*k*q-i*m*r+f*l*r;b.n32=g*l*p-e*k*p-g*m*q+c*k*q+e*m*r-c*l*r;b.n33=d*j*p-g*i*p+g*f*q-c*j*q-e*f*r+c*i*r;b.n34=g*i*m-e*j*m-g*f*l+c*j*l+e*f*k-c*i*k;b.n41=h*l*p-i*n*p-h*m*q+f*n*q+i*m*t-f*l*t;b.n42=e*n*p-d*l*p+d*m*q-c*n*q-e*m*t+c*l*t;b.n43=d*i*p-e*h*p-d*f*q+c*h*q+e*f*t-c*i*t;b.n44=e*h*m-d*i*m+d*f*l-c*h*l-e*f*n+c*i*n;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-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,m=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*m;c[8]=a*l;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,l=a.n31,m=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,t=a.n43,r=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*q-j*n*q+j*m*t-i*k*t-h*m*r+i*n*r;b.n12=g*n*q-d*k*q-g*m*t+e*k*t+d*m*r-e*n*r;b.n13=d*j*q-g*h*q+g*i*t-e*j*t-d*i*r+e*h*r;b.n14=g*h*m-d*j*m-g*i*n+e*j*n+d*i*k-e*h*k;b.n21=j*n*p-h*k*p-j*l*t+f*k*t+h*l*r-f*n*r;b.n22=d*k*p-g*n*p+g*l*t-c*k*t-d*l*r+c*n*r;b.n23=g*h*p-d*j*p-g*f*t+c*j*t+d*f*r-c*h*r;
+b.n24=d*j*l-g*h*l+g*f*n-c*j*n-d*f*k+c*h*k;b.n31=i*k*p-j*m*p+j*l*q-f*k*q-i*l*r+f*m*r;b.n32=g*m*p-e*k*p-g*l*q+c*k*q+e*l*r-c*m*r;b.n33=d*j*p-g*i*p+g*f*q-c*j*q-e*f*r+c*i*r;b.n34=g*i*l-e*j*l-g*f*m+c*j*m+e*f*k-c*i*k;b.n41=h*m*p-i*n*p-h*l*q+f*n*q+i*l*t-f*m*t;b.n42=e*n*p-d*m*p+d*l*q-c*n*q-e*l*t+c*m*t;b.n43=d*i*p-e*h*p-d*f*q+c*h*q+e*f*t-c*i*t;b.n44=e*h*l-d*i*l+d*f*m-c*h*m-e*f*n+c*i*n;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-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,l=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*l;c[8]=a*m;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,d,g){var f;f=new THREE.Matrix4;f.n11=2*d/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*d/(e-c);f.n23=(e+c)/(e-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+d)/(g-d);f.n34=-2*g*d/(g-d);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
 THREE.Matrix4.makeOrtho=function(a,b,c,e,d,g){var f,i,h,j;f=new THREE.Matrix4;i=b-a;h=c-e;j=g-d;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+e)/h);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((g+d)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};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=
@@ -47,25 +47,25 @@ undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b
 b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?e:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,m=h*e+i*c-g*d,l=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+m*-i-l*-f;b.y=m*h+c*-f+l*-g-j*-i;b.z=l*h+c*-i+j*-f-m*-g;return b}};
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,l=h*e+i*c-g*d,m=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+l*-i-m*-f;b.y=l*h+c*-f+m*-g-j*-i;b.z=m*h+c*-i+j*-f-l*-g;return b}};
 THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<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}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};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.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var g=0;g<a.length;g++)a[g].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var g=0;g<d.hierarchy.length;g++){for(var f=0;f<d.hierarchy[g].keys.length;f++){if(d.hierarchy[g].keys[f].time<
-0)d.hierarchy[g].keys[f].time=0;if(d.hierarchy[g].keys[f].rot!==undefined&&!(d.hierarchy[g].keys[f].rot instanceof THREE.Quaternion)){var i=d.hierarchy[g].keys[f].rot;d.hierarchy[g].keys[f].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[g].keys[0].morphTargets!==undefined){i={};for(f=0;f<d.hierarchy[g].keys.length;f++)for(var h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++){var j=d.hierarchy[g].keys[f].morphTargets[h];i[j]=-1}d.hierarchy[g].usedMorphTargets=i;for(f=0;f<d.hierarchy[g].keys.length;f++){var m=
-{};for(j in i){for(h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++)if(d.hierarchy[g].keys[f].morphTargets[h]===j){m[j]=d.hierarchy[g].keys[f].morphTargetsInfluences[h];break}h===d.hierarchy[g].keys[f].morphTargets.length&&(m[j]=0)}d.hierarchy[g].keys[f].morphTargetsInfluences=m}}for(f=1;f<d.hierarchy[g].keys.length;f++)if(d.hierarchy[g].keys[f].time===d.hierarchy[g].keys[f-1].time){d.hierarchy[g].keys.splice(f,1);f--}for(f=1;f<d.hierarchy[g].keys.length;f++)d.hierarchy[g].keys[f].index=f}f=parseInt(d.length*
+0)d.hierarchy[g].keys[f].time=0;if(d.hierarchy[g].keys[f].rot!==undefined&&!(d.hierarchy[g].keys[f].rot instanceof THREE.Quaternion)){var i=d.hierarchy[g].keys[f].rot;d.hierarchy[g].keys[f].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[g].keys[0].morphTargets!==undefined){i={};for(f=0;f<d.hierarchy[g].keys.length;f++)for(var h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++){var j=d.hierarchy[g].keys[f].morphTargets[h];i[j]=-1}d.hierarchy[g].usedMorphTargets=i;for(f=0;f<d.hierarchy[g].keys.length;f++){var l=
+{};for(j in i){for(h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++)if(d.hierarchy[g].keys[f].morphTargets[h]===j){l[j]=d.hierarchy[g].keys[f].morphTargetsInfluences[h];break}h===d.hierarchy[g].keys[f].morphTargets.length&&(l[j]=0)}d.hierarchy[g].keys[f].morphTargetsInfluences=l}}for(f=1;f<d.hierarchy[g].keys.length;f++)if(d.hierarchy[g].keys[f].time===d.hierarchy[g].keys[f-1].time){d.hierarchy[g].keys.splice(f,1);f--}for(f=1;f<d.hierarchy[g].keys.length;f++)d.hierarchy[g].keys[f].index=f}f=parseInt(d.length*
 d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(g=0;g<d.hierarchy.length;g++)d.JIT.hierarchy.push(Array(f));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var g=[];if(d instanceof THREE.SkinnedMesh)for(var f=0;f<d.bones.length;f++)g.push(d.bones[f]);else e(d,g);return g};var e=function(d,g){g.push(d);for(var f=0;f<d.children.length;f++)e(d.children[f],g)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;var c,e=this.hierarchy.length,d;for(c=0;c<e;c++){d=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)d.useQuaternion=!0;d.matrixAutoUpdate=!0;if(d.animationCache===undefined){d.animationCache={};d.animationCache.prevKey={pos:0,rot:0,scl:0};d.animationCache.nextKey={pos:0,rot:0,scl:0};d.animationCache.originalMatrix=
 d instanceof THREE.Bone?d.skinMatrix:d.matrix}var g=d.animationCache.prevKey;d=d.animationCache.nextKey;g.pos=this.data.hierarchy[c].keys[0];g.rot=this.data.hierarchy[c].keys[0];g.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,g,f,i,h,j,m=this.data.JIT.hierarchy,l,n;this.currentTime+=a*this.timeScale;n=this.currentTime;l=this.currentTime%=this.data.length;j=parseInt(Math.min(l*this.data.fps,this.data.length*this.data.fps),10);for(var k=0,p=this.hierarchy.length;k<p;k++){a=this.hierarchy[k];h=a.animationCache;if(this.JITCompile&&m[k][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=m[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
-!1}else{a.matrix=m[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var q=0;q<3;q++){c=b[q];f=h.prevKey[c];i=h.nextKey[c];if(i.time<=n){if(l<n)if(this.loop){f=this.data.hierarchy[k].keys[0];for(i=this.getNextKeyWith(c,k,1);i.time<l;){f=i;i=this.getNextKeyWith(c,k,i.index+1)}}else{this.stop();return}else{do{f=i;i=this.getNextKeyWith(c,k,i.index+1)}while(i.time<
-l)}h.prevKey[c]=f;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(l-f.time)/(i.time-f.time);d=f[c];g=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+k);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,g,f,i,h,j,l=this.data.JIT.hierarchy,m,n;this.currentTime+=a*this.timeScale;n=this.currentTime;m=this.currentTime%=this.data.length;j=parseInt(Math.min(m*this.data.fps,this.data.length*this.data.fps),10);for(var k=0,p=this.hierarchy.length;k<p;k++){a=this.hierarchy[k];h=a.animationCache;if(this.JITCompile&&l[k][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=l[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
+!1}else{a.matrix=l[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var q=0;q<3;q++){c=b[q];f=h.prevKey[c];i=h.nextKey[c];if(i.time<=n){if(m<n)if(this.loop){f=this.data.hierarchy[k].keys[0];for(i=this.getNextKeyWith(c,k,1);i.time<m;){f=i;i=this.getNextKeyWith(c,k,i.index+1)}}else{this.stop();return}else{do{f=i;i=this.getNextKeyWith(c,k,i.index+1)}while(i.time<
+m)}h.prevKey[c]=f;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(m-f.time)/(i.time-f.time);d=f[c];g=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+k);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
 this.getPrevKeyWith("pos",k,f.index-1).pos;this.points[1]=d;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",k,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(d,g,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}}}}if(this.JITCompile&&m[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(k=0;k<this.hierarchy.length;k++)m[k][j]=this.hierarchy[k]instanceof THREE.Bone?this.hierarchy[k].skinMatrix.clone():this.hierarchy[k].matrix.clone()}}};
+"rot")THREE.Quaternion.slerp(d,g,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}}}}if(this.JITCompile&&l[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(k=0;k<this.hierarchy.length;k++)l[k][j]=this.hierarchy[k]instanceof THREE.Bone?this.hierarchy[k].skinMatrix.clone():this.hierarchy[k].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,g,f,i,h,j;d=(a.length-1)*b;g=Math.floor(d);d-=g;c[0]=g==0?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;f=d*c;e[0]=this.interpolate(g[0],i[0],h[0],j[0],d,c,f);e[1]=this.interpolate(g[1],i[1],h[1],j[1],d,c,f);e[2]=this.interpolate(g[2],i[2],h[2],j[2],d,c,f);return e};
 THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*f+(-3*(b-c)-2*a-e)*g+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
@@ -85,17 +85,17 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 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(){var u=h[i]=h[i]||new THREE.RenderableVertex;i++;return u}function b(u,s){return s.z-u.z}function c(u,s){var I=0,J=1,M=u.z+u.w,E=s.z+s.w,w=-u.z+u.w,z=-s.z+s.w;if(M>=0&&E>=0&&w>=0&&z>=0)return!0;else if(M<0&&E<0||w<0&&z<0)return!1;else{if(M<0)I=Math.max(I,M/(M-E));else E<0&&(J=Math.min(J,M/(M-E)));if(w<0)I=Math.max(I,w/(w-z));else z<0&&(J=Math.min(J,w/(w-z)));if(J<I)return!1;else{u.lerpSelf(s,I);s.lerpSelf(u,1-J);return!0}}}var e,d,g=[],f,i,h=[],j,m,l=[],n,k=
+THREE.Projector=function(){function a(){var u=h[i]=h[i]||new THREE.RenderableVertex;i++;return u}function b(u,s){return s.z-u.z}function c(u,s){var I=0,J=1,M=u.z+u.w,E=s.z+s.w,w=-u.z+u.w,z=-s.z+s.w;if(M>=0&&E>=0&&w>=0&&z>=0)return!0;else if(M<0&&E<0||w<0&&z<0)return!1;else{if(M<0)I=Math.max(I,M/(M-E));else E<0&&(J=Math.min(J,M/(M-E)));if(w<0)I=Math.max(I,w/(w-z));else z<0&&(J=Math.min(J,w/(w-z)));if(J<I)return!1;else{u.lerpSelf(s,I);s.lerpSelf(u,1-J);return!0}}}var e,d,g=[],f,i,h=[],j,l,m=[],n,k=
 [],p,q,t=[],r,C,G=[],K=new THREE.Vector4,x=new THREE.Vector4,o=new THREE.Matrix4,Q=new THREE.Matrix4,H=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(u,s){o.multiply(s.projectionMatrix,s.matrixWorldInverse);o.multiplyVector3(u);return u};this.unprojectVector=function(u,s){o.multiply(s.matrixWorld,THREE.Matrix4.makeInvert(s.projectionMatrix));o.multiplyVector3(u);return u};
 this.projectObjects=function(u,s,I){s=[];var J,M,E;d=0;M=u.objects;u=0;for(J=M.length;u<J;u++){E=M[u];var w;if(!(w=!E.visible))if(w=E instanceof THREE.Mesh){a:{w=void 0;for(var z=E.matrixWorld,A=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),D=0;D<6;D++){w=H[D].x*z.n14+H[D].y*z.n24+H[D].z*z.n34+H[D].w;if(w<=A){w=!1;break a}}w=!0}w=!w}if(!w){w=g[d]=g[d]||new THREE.RenderableObject;d++;e=w;K.copy(E.position);o.multiplyVector3(K);e.object=E;e.z=K.z;s.push(e)}}I&&
-s.sort(b);return s};this.projectScene=function(u,s,I){var J=[],M=s.near,E=s.far,w,z,A,D,v,F,B,L,P,y,R,U,W,X,S,V,T;C=q=n=m=0;s.matrixAutoUpdate&&s.updateMatrix();u.update(undefined,!1,s);o.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);H[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);H[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);H[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);H[4].set(o.n41-o.n31,o.n42-o.n32,
+s.sort(b);return s};this.projectScene=function(u,s,I){var J=[],M=s.near,E=s.far,w,z,A,D,v,F,B,L,P,y,R,U,W,X,S,V,T;C=q=n=l=0;s.matrixAutoUpdate&&s.updateMatrix();u.update(undefined,!1,s);o.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);H[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);H[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);H[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);H[4].set(o.n41-o.n31,o.n42-o.n32,
 o.n43-o.n33,o.n44-o.n34);H[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(w=0;w<6;w++){P=H[w];P.divideScalar(Math.sqrt(P.x*P.x+P.y*P.y+P.z*P.z))}P=this.projectObjects(u,s,!0);u=0;for(w=P.length;u<w;u++){y=P[u].object;if(y.visible){R=y.matrixWorld;U=y.matrixRotationWorld;W=y.materials;X=y.overdraw;i=0;if(y instanceof THREE.Mesh){S=y.geometry;D=S.vertices;V=S.faces;S=S.faceVertexUvs;z=0;for(A=D.length;z<A;z++){f=a();f.positionWorld.copy(D[z].position);R.multiplyVector3(f.positionWorld);
 f.positionScreen.copy(f.positionWorld);o.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>M&&f.positionScreen.z<E}D=0;for(z=V.length;D<z;D++){A=V[D];if(A instanceof THREE.Face3){v=h[A.a];F=h[A.b];B=h[A.c];if(v.visible&&F.visible&&B.visible&&(y.doubleSided||y.flipSided!=(B.positionScreen.x-v.positionScreen.x)*(F.positionScreen.y-v.positionScreen.y)-(B.positionScreen.y-v.positionScreen.y)*(F.positionScreen.x-
-v.positionScreen.x)<0)){L=l[m]=l[m]||new THREE.RenderableFace3;m++;j=L;j.v1.copy(v);j.v2.copy(F);j.v3.copy(B)}else continue}else if(A instanceof THREE.Face4){v=h[A.a];F=h[A.b];B=h[A.c];L=h[A.d];if(v.visible&&F.visible&&B.visible&&L.visible&&(y.doubleSided||y.flipSided!=((L.positionScreen.x-v.positionScreen.x)*(F.positionScreen.y-v.positionScreen.y)-(L.positionScreen.y-v.positionScreen.y)*(F.positionScreen.x-v.positionScreen.x)<0||(F.positionScreen.x-B.positionScreen.x)*(L.positionScreen.y-B.positionScreen.y)-
+v.positionScreen.x)<0)){L=m[l]=m[l]||new THREE.RenderableFace3;l++;j=L;j.v1.copy(v);j.v2.copy(F);j.v3.copy(B)}else continue}else if(A instanceof THREE.Face4){v=h[A.a];F=h[A.b];B=h[A.c];L=h[A.d];if(v.visible&&F.visible&&B.visible&&L.visible&&(y.doubleSided||y.flipSided!=((L.positionScreen.x-v.positionScreen.x)*(F.positionScreen.y-v.positionScreen.y)-(L.positionScreen.y-v.positionScreen.y)*(F.positionScreen.x-v.positionScreen.x)<0||(F.positionScreen.x-B.positionScreen.x)*(L.positionScreen.y-B.positionScreen.y)-
 (F.positionScreen.y-B.positionScreen.y)*(L.positionScreen.x-B.positionScreen.x)<0))){T=k[n]=k[n]||new THREE.RenderableFace4;n++;j=T;j.v1.copy(v);j.v2.copy(F);j.v3.copy(B);j.v4.copy(L)}else continue}j.normalWorld.copy(A.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(A.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);o.multiplyVector3(j.centroidScreen);B=A.vertexNormals;v=0;for(F=B.length;v<F;v++){L=j.vertexNormalsWorld[v];L.copy(B[v]);U.multiplyVector3(L)}v=
 0;for(F=S.length;v<F;v++)if(T=S[v][D]){B=0;for(L=T.length;B<L;B++)j.uvs[v][B]=T[B]}j.meshMaterials=W;j.faceMaterials=A.materials;j.overdraw=X;j.z=j.centroidScreen.z;J.push(j)}}else if(y instanceof THREE.Line){Q.multiply(o,R);D=y.geometry.vertices;v=a();v.positionScreen.copy(D[0].position);Q.multiplyVector4(v.positionScreen);z=1;for(A=D.length;z<A;z++){v=a();v.positionScreen.copy(D[z].position);Q.multiplyVector4(v.positionScreen);F=h[i-2];N.copy(v.positionScreen);O.copy(F.positionScreen);if(c(N,O)){N.multiplyScalar(1/
 N.w);O.multiplyScalar(1/O.w);R=t[q]=t[q]||new THREE.RenderableLine;q++;p=R;p.v1.positionScreen.copy(N);p.v2.positionScreen.copy(O);p.z=Math.max(N.z,O.z);p.materials=y.materials;J.push(p)}}}else if(y instanceof THREE.Particle){x.set(y.position.x,y.position.y,y.position.z,1);o.multiplyVector4(x);x.z/=x.w;if(x.z>0&&x.z<1){R=G[C]=G[C]||new THREE.RenderableParticle;C++;r=R;r.x=x.x/x.w;r.y=x.y/x.w;r.z=x.z;r.rotation=y.rotation.z;r.scale.x=y.scale.x*Math.abs(r.x-(x.x+s.projectionMatrix.n11)/(x.w+s.projectionMatrix.n14));
 r.scale.y=y.scale.y*Math.abs(r.y-(x.y+s.projectionMatrix.n22)/(x.w+s.projectionMatrix.n24));r.materials=y.materials;J.push(r)}}}}I&&J.sort(b);return J}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,d,g;this.domElement=document.createElement("div");this.setSize=function(f,i){c=f;e=i;d=c/2;g=e/2};this.render=function(f,i){var h,j,m,l,n,k,p,q;a=b.projectScene(f,i);h=0;for(j=a.length;h<j;h++){n=a[h];if(n instanceof THREE.RenderableParticle){p=n.x*d+d;q=n.y*g+g;m=0;for(l=n.material.length;m<l;m++){k=n.material[m];if(k instanceof THREE.ParticleDOMMaterial){k=k.domElement;k.style.left=p+"px";k.style.top=q+"px"}}}}}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,d,g;this.domElement=document.createElement("div");this.setSize=function(f,i){c=f;e=i;d=c/2;g=e/2};this.render=function(f,i){var h,j,l,m,n,k,p,q;a=b.projectScene(f,i);h=0;for(j=a.length;h<j;h++){n=a[h];if(n instanceof THREE.RenderableParticle){p=n.x*d+d;q=n.y*g+g;l=0;for(m=n.material.length;l<m;l++){k=n.material[l];if(k instanceof THREE.ParticleDOMMaterial){k=k.domElement;k.style.left=p+"px";k.style.top=q+"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 e,d=c.length;for(e=0;e<d;e++){a=c[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.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};

File diff suppressed because it is too large
+ 7 - 16
build/custom/ThreeExtras.js


+ 60 - 58
build/custom/ThreeSVG.js

@@ -1,7 +1,7 @@
 // ThreeSVG.js r38 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},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 e,d,f,g,i,h;if(c==0)e=d=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:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
-f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;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*
+THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},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 e,d,g,f,i,h;if(c==0)e=d=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:e=h;d=c;g=a;break;case 2:e=a;d=c;g=b;break;case 3:e=a;d=h;g=c;break;case 4:e=b;d=a;g=c;break;case 5:e=c;d=a;
+g=h;break;case 6:case 0:e=c;d=b;g=a}}this.r=e;this.g=d;this.b=g;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/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
@@ -12,71 +12,73 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 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,e){this.set(a||0,b||0,c||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(B,t,K,x){x=x.clone().subSelf(t);K=K.clone().subSelf(t);var G=B.clone().subSelf(t);B=x.dot(x);t=x.dot(K);x=x.dot(G);var C=K.dot(K);K=K.dot(G);G=1/(B*C-t*t);C=(C*x-t*K)*G;B=(B*K-t*x)*G;return C>0&&B>0&&C+B<1}var c,e,d,f,g,i,h,j,m,l,
-n,k=a.geometry,r=k.vertices,u=[];c=0;for(e=k.faces.length;c<e;c++){d=k.faces[c];l=this.origin.clone();n=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(r[d.a].position.clone());g=h.multiplyVector3(r[d.b].position.clone());i=h.multiplyVector3(r[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(r[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());m=n.dot(j);if(m<0){j=j.dot((new THREE.Vector3).sub(f,l))/m;l=l.addSelf(n.multiplyScalar(j));
-if(d instanceof THREE.Face3){if(b(l,f,g,i)){d={distance:this.origin.distanceTo(l),point:l,face:d,object:a};u.push(d)}}else if(d instanceof THREE.Face4&&(b(l,f,g,h)||b(l,g,i,h))){d={distance:this.origin.distanceTo(l),point:l,face:d,object:a};u.push(d)}}}return u}};
-THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,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 e};this.getBottom=function(){return d};this.set=function(h,j,m,l){i=!1;b=h;c=j;e=m;d=l;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
-this.add3Points=function(h,j,m,l,n,k){if(i){i=!1;b=h<m?h<n?h:n:m<n?m:n;c=j<l?j<k?j:k:l<k?l:k;e=h>m?h>n?h:n:m>n?m:n;d=j>l?j>k?j:k:l>k?l:k}else{b=h<m?h<n?h<b?h:b:n<b?n:b:m<n?m<b?m:b:n<b?n:b;c=j<l?j<k?j<c?j:c:k<c?k:c:l<k?l<c?l:c:k<c?k:c;e=h>m?h>n?h>e?h:e:n>e?n:e:m>n?m>e?m:e:n>e?n:e;d=j>l?j>k?j>d?j:d:k>d?k:d:l>k?l>d?l:d:k>d?k:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(g,f){return g.distance-f.distance});return d},intersectObject:function(a){function b(B,t,K,x){x=x.clone().subSelf(t);K=K.clone().subSelf(t);var G=B.clone().subSelf(t);B=x.dot(x);t=x.dot(K);x=x.dot(G);var C=K.dot(K);K=K.dot(G);G=1/(B*C-t*t);C=(C*x-t*K)*G;B=(B*K-t*x)*G;return C>0&&B>0&&C+B<1}var c,e,d,g,f,i,h,j,l,m,
+n,k=a.geometry,r=k.vertices,u=[];c=0;for(e=k.faces.length;c<e;c++){d=k.faces[c];m=this.origin.clone();n=this.direction.clone();h=a.matrixWorld;g=h.multiplyVector3(r[d.a].position.clone());f=h.multiplyVector3(r[d.b].position.clone());i=h.multiplyVector3(r[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(r[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());l=n.dot(j);if(a.doubleSided||(a.flipSided?l>0:l<0)){j=j.dot((new THREE.Vector3).sub(g,m))/
+l;m=m.addSelf(n.multiplyScalar(j));if(d instanceof THREE.Face3){if(b(m,g,f,i)){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};u.push(d)}}else if(d instanceof THREE.Face4&&(b(m,g,f,h)||b(m,f,i,h))){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};u.push(d)}}}return u}};
+THREE.Rectangle=function(){function a(){g=e-b;f=d-c}var b,c,e,d,g,f,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,l,m){i=!1;b=h;c=j;e=l;d=m;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
+this.add3Points=function(h,j,l,m,n,k){if(i){i=!1;b=h<l?h<n?h:n:l<n?l:n;c=j<m?j<k?j:k:m<k?m:k;e=h>l?h>n?h:n:l>n?l:n;d=j>m?j>k?j:k:m>k?m:k}else{b=h<l?h<n?h<b?h:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b;c=j<m?j<k?j<c?j:c:k<c?k:c:m<k?m<c?m:c:k<c?k:c;e=h>l?h>n?h>e?h:e:n>e?n:e:l>n?l>e?l:e:n>e?n:e;d=j>m?j>k?j>d?j:d:k>d?k:d:m>k?m>d?m:d:k>d?k:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
 e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=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,e,d,f,g,i,h,j,m,l,n,k,r,u){this.set(a||1,b||0,c||0,e||0,d||0,f||1,g||0,i||0,h||0,j||0,m||1,l||0,n||0,k||0,r||0,u||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,e,d,f,g,i,h,j,m,l,n,k,r,u){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=m;this.n34=l;this.n41=n;this.n42=k;this.n43=r;this.n44=u;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 e=THREE.Matrix4.__v1,
-d=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;e.cross(c,f).normalize();if(e.length()===0){f.x+=1.0E-4;e.cross(c,f).normalize()}d.cross(f,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=f.x;this.n21=e.y;this.n22=d.y;this.n23=f.y;this.n31=e.z;this.n32=d.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
+THREE.Matrix4=function(a,b,c,e,d,g,f,i,h,j,l,m,n,k,r,u){this.set(a||1,b||0,c||0,e||0,d||0,g||1,f||0,i||0,h||0,j||0,l||1,m||0,n||0,k||0,r||0,u||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,e,d,g,f,i,h,j,l,m,n,k,r,u){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=g;this.n23=f;this.n24=i;this.n31=h;this.n32=j;this.n33=l;this.n34=m;this.n41=n;this.n42=k;this.n43=r;this.n44=u;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 e=THREE.Matrix4.__v1,
+d=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;e.cross(c,g).normalize();if(e.length()===0){g.x+=1.0E-4;e.cross(c,g).normalize()}d.cross(g,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=g.x;this.n21=e.y;this.n22=d.y;this.n23=g.y;this.n31=e.z;this.n32=d.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
 e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*d;return a},rotateAxis:function(a){var b=a.x,c=a.y,e=a.z;a.x=b*this.n11+c*this.n12+e*this.n13;a.y=b*this.n21+c*this.n22+e*this.n23;a.z=b*this.n31+c*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 c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,l=a.n32,n=a.n33,k=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44,K=b.n11,x=b.n12,G=b.n13,C=b.n14,p=b.n21,O=b.n22,
-H=b.n23,P=b.n24,M=b.n31,A=b.n32,s=b.n33,L=b.n34;this.n11=c*K+e*p+d*M;this.n12=c*x+e*O+d*A;this.n13=c*G+e*H+d*s;this.n14=c*C+e*P+d*L+f;this.n21=g*K+i*p+h*M;this.n22=g*x+i*O+h*A;this.n23=g*G+i*H+h*s;this.n24=g*C+i*P+h*L+j;this.n31=m*K+l*p+n*M;this.n32=m*x+l*O+n*A;this.n33=m*G+l*H+n*s;this.n34=m*C+l*P+n*L+k;this.n41=r*K+u*p+B*M;this.n42=r*x+u*O+B*A;this.n43=r*G+u*H+B*s;this.n44=r*C+u*P+B*L+t;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]=
+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,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,l=a.n31,m=a.n32,n=a.n33,k=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44,K=b.n11,x=b.n12,G=b.n13,C=b.n14,p=b.n21,O=b.n22,
+H=b.n23,P=b.n24,M=b.n31,A=b.n32,s=b.n33,L=b.n34;this.n11=c*K+e*p+d*M;this.n12=c*x+e*O+d*A;this.n13=c*G+e*H+d*s;this.n14=c*C+e*P+d*L+g;this.n21=f*K+i*p+h*M;this.n22=f*x+i*O+h*A;this.n23=f*G+i*H+h*s;this.n24=f*C+i*P+h*L+j;this.n31=l*K+m*p+n*M;this.n32=l*x+m*O+n*A;this.n33=l*G+m*H+n*s;this.n34=l*C+m*P+n*L+k;this.n41=r*K+u*p+B*M;this.n42=r*x+u*O+B*A;this.n43=r*G+u*H+B*s;this.n44=r*C+u*P+B*L+t;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,e=this.n14,d=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,m=this.n33,l=this.n34,n=this.n41,k=this.n42,r=this.n43,u=this.n44;return e*g*j*n-c*i*j*n-e*f*m*n+b*i*m*n+c*f*l*n-b*g*l*n-e*g*h*k+c*i*h*k+e*d*m*k-a*i*m*k-c*d*l*k+a*g*l*k+e*f*h*r-b*i*h*r-e*d*j*r+a*i*j*r+b*d*l*r-a*f*l*r-c*f*h*u+b*g*h*u+c*d*j*u-a*g*j*u-b*d*m*u+a*f*m*u},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.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,g=this.n22,f=this.n23,i=this.n24,h=this.n31,j=this.n32,l=this.n33,m=this.n34,n=this.n41,k=this.n42,r=this.n43,u=this.n44;return e*f*j*n-c*i*j*n-e*g*l*n+b*i*l*n+c*g*m*n-b*f*m*n-e*f*h*k+c*i*h*k+e*d*l*k-a*i*l*k-c*d*m*k+a*f*m*k+e*g*h*r-b*i*h*r-e*d*j*r+a*i*j*r+b*d*m*r-a*g*m*r-c*g*h*u+b*f*h*u+c*d*j*u-a*f*j*u-b*d*l*u+a*g*l*u},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),e=Math.sin(b),d=1-c,f=a.x,g=a.y,i=a.z,h=d*f,j=d*g;this.set(h*
-f+c,h*g-e*i,h*i+e*g,0,h*g+e*i,j*g+c,j*i-e*f,0,h*i-e*g,j*i+e*f,d*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,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,i=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=i*f+a*e;this.n22=-i*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,e=a.z,d=a.w,f=b+b,g=c+c,i=e+e;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;e*=i;f*=d;g*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);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=
+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),e=Math.sin(b),d=1-c,g=a.x,f=a.y,i=a.z,h=d*g,j=d*f;this.set(h*
+g+c,h*f-e*i,h*i+e*f,0,h*f+e*i,j*f+c,j*i-e*g,0,h*i-e*f,j*i+e*g,d*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,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var g=Math.cos(e);e=Math.sin(e);var f=a*c,i=b*c;this.n11=d*g;this.n12=-d*e;this.n13=c;this.n21=i*g+a*e;this.n22=-i*e+a*g;this.n23=-b*d;this.n31=-f*g+b*e;this.n32=f*e+b*g;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,e=a.z,d=a.w,g=b+b,f=c+c,i=e+e;a=b*g;var h=b*f;b*=i;var j=c*f;c*=i;e*=i;g*=d;f*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+f;this.n21=h+d;this.n22=1-(a+e);this.n23=c-g;this.n31=b-f;this.n32=c+g;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,e=1/b.y,d=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*d;this.n23=a.n23*d;this.n33=a.n33*d}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,l=a.n32,n=a.n33,k=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*u-j*n*u+j*l*B-i*k*B-h*l*t+i*n*t;b.n12=f*n*u-d*k*u-f*l*B+e*k*B+d*l*t-e*n*t;b.n13=d*j*u-f*h*u+f*i*B-e*j*B-d*i*t+e*h*t;b.n14=f*h*l-d*j*l-f*i*n+e*j*n+d*i*k-e*h*k;b.n21=j*n*r-h*k*r-j*m*B+g*k*B+h*m*t-g*n*t;b.n22=d*k*r-f*n*r+f*m*B-c*k*B-d*m*t+c*n*t;b.n23=f*h*r-d*j*r-f*g*B+c*j*B+d*g*t-c*h*t;
-b.n24=d*j*m-f*h*m+f*g*n-c*j*n-d*g*k+c*h*k;b.n31=i*k*r-j*l*r+j*m*u-g*k*u-i*m*t+g*l*t;b.n32=f*l*r-e*k*r-f*m*u+c*k*u+e*m*t-c*l*t;b.n33=d*j*r-f*i*r+f*g*u-c*j*u-e*g*t+c*i*t;b.n34=f*i*m-e*j*m-f*g*l+c*j*l+e*g*k-c*i*k;b.n41=h*l*r-i*n*r-h*m*u+g*n*u+i*m*B-g*l*B;b.n42=e*n*r-d*l*r+d*m*u-c*n*u-e*m*B+c*l*B;b.n43=d*i*r-e*h*r-d*g*u+c*h*u+e*g*B-c*i*B;b.n44=e*h*m-d*i*m+d*g*l-c*h*l-e*g*n+c*i*n;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-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,m=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*m;c[8]=a*l;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
-THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;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+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/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.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,g=a.n14,f=a.n21,i=a.n22,h=a.n23,j=a.n24,l=a.n31,m=a.n32,n=a.n33,k=a.n34,r=a.n41,u=a.n42,B=a.n43,t=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*k*u-j*n*u+j*m*B-i*k*B-h*m*t+i*n*t;b.n12=g*n*u-d*k*u-g*m*B+e*k*B+d*m*t-e*n*t;b.n13=d*j*u-g*h*u+g*i*B-e*j*B-d*i*t+e*h*t;b.n14=g*h*m-d*j*m-g*i*n+e*j*n+d*i*k-e*h*k;b.n21=j*n*r-h*k*r-j*l*B+f*k*B+h*l*t-f*n*t;b.n22=d*k*r-g*n*r+g*l*B-c*k*B-d*l*t+c*n*t;b.n23=g*h*r-d*j*r-g*f*B+c*j*B+d*f*t-c*h*t;
+b.n24=d*j*l-g*h*l+g*f*n-c*j*n-d*f*k+c*h*k;b.n31=i*k*r-j*m*r+j*l*u-f*k*u-i*l*t+f*m*t;b.n32=g*m*r-e*k*r-g*l*u+c*k*u+e*l*t-c*m*t;b.n33=d*j*r-g*i*r+g*f*u-c*j*u-e*f*t+c*i*t;b.n34=g*i*l-e*j*l-g*f*m+c*j*m+e*f*k-c*i*k;b.n41=h*m*r-i*n*r-h*l*u+f*n*u+i*l*B-f*m*B;b.n42=e*n*r-d*m*r+d*l*u-c*n*u-e*l*B+c*m*B;b.n43=d*i*r-e*h*r-d*f*u+c*h*u+e*f*B-c*i*B;b.n44=e*h*l-d*i*l+d*f*m-c*h*m-e*f*n+c*i*n;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-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,l=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*f+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*g;c[3]=a*f;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*l;c[8]=a*m;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,e,d,g){var f;f=new THREE.Matrix4;f.n11=2*d/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*d/(e-c);f.n23=(e+c)/(e-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+d)/(g-d);f.n34=-2*g*d/(g-d);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
+THREE.Matrix4.makeOrtho=function(a,b,c,e,d,g){var f,i,h,j;f=new THREE.Matrix4;i=b-a;h=c-e;j=g-d;f.n11=2/i;f.n12=0;f.n13=0;f.n14=-((b+a)/i);f.n21=0;f.n22=2/h;f.n23=0;f.n24=-((c+e)/h);f.n31=0;f.n32=0;f.n33=-2/j;f.n34=-((g+d)/j);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};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))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){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,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?e:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*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,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,m=h*e+i*c-f*d,l=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+m*-i-l*-g;b.y=m*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-m*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
-THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.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.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
+THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,l=h*e+i*c-g*d,m=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+l*-i-m*-f;b.y=l*h+c*-f+m*-g-j*-i;b.z=m*h+c*-i+j*-f-l*-g;return b}};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<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}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};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.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,f,g,i=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){f=this.faces[e];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.vertexNormals.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,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++){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{e=
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,g,f,i=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){g=this.faces[e];if(a&&g.vertexNormals.length){i.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)i.addSelf(g.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];f=this.vertices[g.c];i.sub(f.position,c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||
+i.normalize();g.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,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++){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{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++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[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(e[c.a]);
-c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(z,y,D,q,o,E,I){i=z.vertices[y].position;h=z.vertices[D].position;j=z.vertices[q].position;m=g[o];l=g[E];n=g[I];k=h.x-i.x;r=j.x-i.x;u=h.y-i.y;B=j.y-i.y;t=h.z-i.z;K=j.z-i.z;x=l.u-m.u;G=n.u-m.u;C=l.v-m.v;p=n.v-m.v;O=1/(x*p-G*C);A.set((p*
-k-C*r)*O,(p*u-C*B)*O,(p*t-C*K)*O);s.set((x*r-G*k)*O,(x*B-G*u)*O,(x*K-G*t)*O);P[y].addSelf(A);P[D].addSelf(A);P[q].addSelf(A);M[y].addSelf(s);M[D].addSelf(s);M[q].addSelf(s)}var b,c,e,d,f,g,i,h,j,m,l,n,k,r,u,B,t,K,x,G,C,p,O,H,P=[],M=[],A=new THREE.Vector3,s=new THREE.Vector3,L=new THREE.Vector3,Q=new THREE.Vector3,N=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){P[b]=new THREE.Vector3;M[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];g=this.faceVertexUvs[0][b];
-if(f instanceof THREE.Face3)a(this,f.a,f.b,f.c,0,1,2);else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3)}}var v=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++){N.copy(f.vertexNormals[e]);d=f[v[e]];H=P[d];L.copy(H);L.subSelf(N.multiplyScalar(N.dot(H))).normalize();Q.cross(f.vertexNormals[e],H);d=Q.dot(M[d]);d=d<0?-1:1;f.vertexTangents[e]=new THREE.Vector4(L.x,L.y,L.z,d)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(z,y,D,q,o,E,I){i=z.vertices[y].position;h=z.vertices[D].position;j=z.vertices[q].position;l=f[o];m=f[E];n=f[I];k=h.x-i.x;r=j.x-i.x;u=h.y-i.y;B=j.y-i.y;t=h.z-i.z;K=j.z-i.z;x=m.u-l.u;G=n.u-l.u;C=m.v-l.v;p=n.v-l.v;O=1/(x*p-G*C);A.set((p*
+k-C*r)*O,(p*u-C*B)*O,(p*t-C*K)*O);s.set((x*r-G*k)*O,(x*B-G*u)*O,(x*K-G*t)*O);P[y].addSelf(A);P[D].addSelf(A);P[q].addSelf(A);M[y].addSelf(s);M[D].addSelf(s);M[q].addSelf(s)}var b,c,e,d,g,f,i,h,j,l,m,n,k,r,u,B,t,K,x,G,C,p,O,H,P=[],M=[],A=new THREE.Vector3,s=new THREE.Vector3,L=new THREE.Vector3,Q=new THREE.Vector3,N=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){P[b]=new THREE.Vector3;M[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];f=this.faceVertexUvs[0][b];
+if(g instanceof THREE.Face3)a(this,g.a,g.b,g.c,0,1,2);else if(g instanceof THREE.Face4){a(this,g.a,g.b,g.c,0,1,2);a(this,g.a,g.b,g.d,0,1,3)}}var v=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(e=0;e<g.vertexNormals.length;e++){N.copy(g.vertexNormals[e]);d=g[v[e]];H=P[d];L.copy(H);L.subSelf(N.multiplyScalar(N.dot(H))).normalize();Q.cross(g.vertexNormals[e],H);d=Q.dot(M[d]);d=d<0?-1:1;g.vertexTangents[e]=new THREE.Vector4(L.x,L.y,L.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.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var f=0;f<a.length;f++)a[f].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var f=0;f<d.hierarchy.length;f++){for(var g=0;g<d.hierarchy[f].keys.length;g++){if(d.hierarchy[f].keys[g].time<
-0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var i=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){i={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++){var j=d.hierarchy[f].keys[g].morphTargets[h];i[j]=-1}d.hierarchy[f].usedMorphTargets=i;for(g=0;g<d.hierarchy[f].keys.length;g++){var m=
-{};for(j in i){for(h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++)if(d.hierarchy[f].keys[g].morphTargets[h]===j){m[j]=d.hierarchy[f].keys[g].morphTargetsInfluences[h];break}h===d.hierarchy[f].keys[g].morphTargets.length&&(m[j]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=m}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
-d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(f=0;f<d.hierarchy.length;f++)d.JIT.hierarchy.push(Array(g));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var f=[];if(d instanceof THREE.SkinnedMesh)for(var g=0;g<d.bones.length;g++)f.push(d.bones[g]);else e(d,f);return f};var e=function(d,f){f.push(d);for(var g=0;g<d.children.length;g++)e(d.children[g],f)};c.LINEAR=
+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}},computeEdgeFaces:function(){function a(h,j){return Math.min(h,
+j)+"_"+Math.max(h,j)}function b(h,j,l){if(h[j]===undefined){h[j]={set:{},array:[]};h[j].set[l]=1;h[j].array.push(l)}else if(h[j].set[l]===undefined){h[j].set[l]=1;h[j].array.push(l)}}var c,e,d,g,f,i={};c=0;for(e=this.faces.length;c<e;c++){f=this.faces[c];if(f instanceof THREE.Face3){d=a(f.a,f.b);b(i,d,c);d=a(f.b,f.c);b(i,d,c);d=a(f.a,f.c);b(i,d,c)}else if(f instanceof THREE.Face4){d=a(f.b,f.d);b(i,d,c);d=a(f.a,f.b);b(i,d,c);d=a(f.a,f.d);b(i,d,c);d=a(f.b,f.c);b(i,d,c);d=a(f.c,f.d);b(i,d,c)}}c=0;for(e=
+this.edges.length;c<e;c++){f=this.edges[c];d=f.vertexIndices[0];g=f.vertexIndices[1];f.faceIndices=i[a(d,g)].array;for(d=0;d<f.faceIndices.length;d++){g=f.faceIndices[d];f.faces.push(this.faces[g])}}}};THREE.GeometryIdCounter=0;
+THREE.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var g=0;g<a.length;g++)a[g].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var g=0;g<d.hierarchy.length;g++){for(var f=0;f<d.hierarchy[g].keys.length;f++){if(d.hierarchy[g].keys[f].time<
+0)d.hierarchy[g].keys[f].time=0;if(d.hierarchy[g].keys[f].rot!==undefined&&!(d.hierarchy[g].keys[f].rot instanceof THREE.Quaternion)){var i=d.hierarchy[g].keys[f].rot;d.hierarchy[g].keys[f].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[g].keys[0].morphTargets!==undefined){i={};for(f=0;f<d.hierarchy[g].keys.length;f++)for(var h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++){var j=d.hierarchy[g].keys[f].morphTargets[h];i[j]=-1}d.hierarchy[g].usedMorphTargets=i;for(f=0;f<d.hierarchy[g].keys.length;f++){var l=
+{};for(j in i){for(h=0;h<d.hierarchy[g].keys[f].morphTargets.length;h++)if(d.hierarchy[g].keys[f].morphTargets[h]===j){l[j]=d.hierarchy[g].keys[f].morphTargetsInfluences[h];break}h===d.hierarchy[g].keys[f].morphTargets.length&&(l[j]=0)}d.hierarchy[g].keys[f].morphTargetsInfluences=l}}for(f=1;f<d.hierarchy[g].keys.length;f++)if(d.hierarchy[g].keys[f].time===d.hierarchy[g].keys[f-1].time){d.hierarchy[g].keys.splice(f,1);f--}for(f=1;f<d.hierarchy[g].keys.length;f++)d.hierarchy[g].keys[f].index=f}f=parseInt(d.length*
+d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(g=0;g<d.hierarchy.length;g++)d.JIT.hierarchy.push(Array(f));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var g=[];if(d instanceof THREE.SkinnedMesh)for(var f=0;f<d.bones.length;f++)g.push(d.bones[f]);else e(d,g);return g};var e=function(d,g){g.push(d);for(var f=0;f<d.children.length;f++)e(d.children[f],g)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;var c,e=this.hierarchy.length,d;for(c=0;c<e;c++){d=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)d.useQuaternion=!0;d.matrixAutoUpdate=!0;if(d.animationCache===undefined){d.animationCache={};d.animationCache.prevKey={pos:0,rot:0,scl:0};d.animationCache.nextKey={pos:0,rot:0,scl:0};d.animationCache.originalMatrix=
-d instanceof THREE.Bone?d.skinMatrix:d.matrix}var f=d.animationCache.prevKey;d=d.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
+d instanceof THREE.Bone?d.skinMatrix:d.matrix}var g=d.animationCache.prevKey;d=d.animationCache.nextKey;g.pos=this.data.hierarchy[c].keys[0];g.rot=this.data.hierarchy[c].keys[0];g.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,f,g,i,h,j,m=this.data.JIT.hierarchy,l,n;this.currentTime+=a*this.timeScale;n=this.currentTime;l=this.currentTime%=this.data.length;j=parseInt(Math.min(l*this.data.fps,this.data.length*this.data.fps),10);for(var k=0,r=this.hierarchy.length;k<r;k++){a=this.hierarchy[k];h=a.animationCache;if(this.JITCompile&&m[k][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=m[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
-!1}else{a.matrix=m[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var u=0;u<3;u++){c=b[u];g=h.prevKey[c];i=h.nextKey[c];if(i.time<=n){if(l<n)if(this.loop){g=this.data.hierarchy[k].keys[0];for(i=this.getNextKeyWith(c,k,1);i.time<l;){g=i;i=this.getNextKeyWith(c,k,i.index+1)}}else{this.stop();return}else{do{g=i;i=this.getNextKeyWith(c,k,i.index+1)}while(i.time<
-l)}h.prevKey[c]=g;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(l-g.time)/(i.time-g.time);d=g[c];f=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+k);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",k,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",k,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&m[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(k=0;k<this.hierarchy.length;k++)m[k][j]=this.hierarchy[k]instanceof THREE.Bone?this.hierarchy[k].skinMatrix.clone():this.hierarchy[k].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,f,g,i,h,j;d=(a.length-1)*b;f=Math.floor(d);d-=f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;g=d*c;e[0]=this.interpolate(f[0],i[0],h[0],j[0],d,c,g);e[1]=this.interpolate(f[1],i[1],h[1],j[1],d,c,g);e[2]=this.interpolate(f[2],i[2],h[2],j[2],d,c,g);return e};
-THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*f+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,g,f,i,h,j,l=this.data.JIT.hierarchy,m,n;this.currentTime+=a*this.timeScale;n=this.currentTime;m=this.currentTime%=this.data.length;j=parseInt(Math.min(m*this.data.fps,this.data.length*this.data.fps),10);for(var k=0,r=this.hierarchy.length;k<r;k++){a=this.hierarchy[k];h=a.animationCache;if(this.JITCompile&&l[k][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=l[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
+!1}else{a.matrix=l[k][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var u=0;u<3;u++){c=b[u];f=h.prevKey[c];i=h.nextKey[c];if(i.time<=n){if(m<n)if(this.loop){f=this.data.hierarchy[k].keys[0];for(i=this.getNextKeyWith(c,k,1);i.time<m;){f=i;i=this.getNextKeyWith(c,k,i.index+1)}}else{this.stop();return}else{do{f=i;i=this.getNextKeyWith(c,k,i.index+1)}while(i.time<
+m)}h.prevKey[c]=f;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(m-f.time)/(i.time-f.time);d=f[c];g=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+k);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",k,f.index-1).pos;this.points[1]=d;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",k,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(d,g,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(g[0]-d[0])*e;c.y=d[1]+(g[1]-d[1])*e;c.z=d[2]+(g[2]-d[2])*e}}}}if(this.JITCompile&&l[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(k=0;k<this.hierarchy.length;k++)l[k][j]=this.hierarchy[k]instanceof THREE.Bone?this.hierarchy[k].skinMatrix.clone():this.hierarchy[k].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,g,f,i,h,j;d=(a.length-1)*b;g=Math.floor(d);d-=g;c[0]=g==0?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;f=d*c;e[0]=this.interpolate(g[0],i[0],h[0],j[0],d,c,f);e[1]=this.interpolate(g[1],i[1],h[1],j[1],d,c,f);e[2]=this.interpolate(g[2],i[2],h[2],j[2],d,c,f);return e};
+THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*f+(-3*(b-c)-2*a-e)*g+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
 THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.target=d||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.updateMatrix=function(){this.update(undefined,!0)};
@@ -113,13 +115,13 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 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(){var A=h[i]=h[i]||new THREE.RenderableVertex;i++;return A}function b(A,s){return s.z-A.z}function c(A,s){var L=0,Q=1,N=A.z+A.w,v=s.z+s.w,z=-A.z+A.w,y=-s.z+s.w;if(N>=0&&v>=0&&z>=0&&y>=0)return!0;else if(N<0&&v<0||z<0&&y<0)return!1;else{if(N<0)L=Math.max(L,N/(N-v));else v<0&&(Q=Math.min(Q,N/(N-v)));if(z<0)L=Math.max(L,z/(z-y));else y<0&&(Q=Math.min(Q,z/(z-y)));if(Q<L)return!1;else{A.lerpSelf(s,L);s.lerpSelf(A,1-Q);return!0}}}var e,d,f=[],g,i,h=[],j,m,l=[],n,k=
+THREE.Projector=function(){function a(){var A=h[i]=h[i]||new THREE.RenderableVertex;i++;return A}function b(A,s){return s.z-A.z}function c(A,s){var L=0,Q=1,N=A.z+A.w,v=s.z+s.w,z=-A.z+A.w,y=-s.z+s.w;if(N>=0&&v>=0&&z>=0&&y>=0)return!0;else if(N<0&&v<0||z<0&&y<0)return!1;else{if(N<0)L=Math.max(L,N/(N-v));else v<0&&(Q=Math.min(Q,N/(N-v)));if(z<0)L=Math.max(L,z/(z-y));else y<0&&(Q=Math.min(Q,z/(z-y)));if(Q<L)return!1;else{A.lerpSelf(s,L);s.lerpSelf(A,1-Q);return!0}}}var e,d,g=[],f,i,h=[],j,l,m=[],n,k=
 [],r,u,B=[],t,K,x=[],G=new THREE.Vector4,C=new THREE.Vector4,p=new THREE.Matrix4,O=new THREE.Matrix4,H=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],P=new THREE.Vector4,M=new THREE.Vector4;this.projectVector=function(A,s){p.multiply(s.projectionMatrix,s.matrixWorldInverse);p.multiplyVector3(A);return A};this.unprojectVector=function(A,s){p.multiply(s.matrixWorld,THREE.Matrix4.makeInvert(s.projectionMatrix));p.multiplyVector3(A);return A};
-this.projectObjects=function(A,s,L){s=[];var Q,N,v;d=0;N=A.objects;A=0;for(Q=N.length;A<Q;A++){v=N[A];var z;if(!(z=!v.visible))if(z=v instanceof THREE.Mesh){a:{z=void 0;for(var y=v.matrixWorld,D=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),q=0;q<6;q++){z=H[q].x*y.n14+H[q].y*y.n24+H[q].z*y.n34+H[q].w;if(z<=D){z=!1;break a}}z=!0}z=!z}if(!z){z=f[d]=f[d]||new THREE.RenderableObject;d++;e=z;G.copy(v.position);p.multiplyVector3(G);e.object=v;e.z=G.z;s.push(e)}}L&&
-s.sort(b);return s};this.projectScene=function(A,s,L){var Q=[],N=s.near,v=s.far,z,y,D,q,o,E,I,w,F,J,R,U,W,X,S,V,T;K=u=n=m=0;s.matrixAutoUpdate&&s.updateMatrix();A.update(undefined,!1,s);p.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);H[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);H[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);H[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);H[4].set(p.n41-p.n31,p.n42-p.n32,
-p.n43-p.n33,p.n44-p.n34);H[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);for(z=0;z<6;z++){F=H[z];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}F=this.projectObjects(A,s,!0);A=0;for(z=F.length;A<z;A++){J=F[A].object;if(J.visible){R=J.matrixWorld;U=J.matrixRotationWorld;W=J.materials;X=J.overdraw;i=0;if(J instanceof THREE.Mesh){S=J.geometry;q=S.vertices;V=S.faces;S=S.faceVertexUvs;y=0;for(D=q.length;y<D;y++){g=a();g.positionWorld.copy(q[y].position);R.multiplyVector3(g.positionWorld);
-g.positionScreen.copy(g.positionWorld);p.multiplyVector4(g.positionScreen);g.positionScreen.x/=g.positionScreen.w;g.positionScreen.y/=g.positionScreen.w;g.visible=g.positionScreen.z>N&&g.positionScreen.z<v}q=0;for(y=V.length;q<y;q++){D=V[q];if(D instanceof THREE.Face3){o=h[D.a];E=h[D.b];I=h[D.c];if(o.visible&&E.visible&&I.visible&&(J.doubleSided||J.flipSided!=(I.positionScreen.x-o.positionScreen.x)*(E.positionScreen.y-o.positionScreen.y)-(I.positionScreen.y-o.positionScreen.y)*(E.positionScreen.x-
-o.positionScreen.x)<0)){w=l[m]=l[m]||new THREE.RenderableFace3;m++;j=w;j.v1.copy(o);j.v2.copy(E);j.v3.copy(I)}else continue}else if(D instanceof THREE.Face4){o=h[D.a];E=h[D.b];I=h[D.c];w=h[D.d];if(o.visible&&E.visible&&I.visible&&w.visible&&(J.doubleSided||J.flipSided!=((w.positionScreen.x-o.positionScreen.x)*(E.positionScreen.y-o.positionScreen.y)-(w.positionScreen.y-o.positionScreen.y)*(E.positionScreen.x-o.positionScreen.x)<0||(E.positionScreen.x-I.positionScreen.x)*(w.positionScreen.y-I.positionScreen.y)-
+this.projectObjects=function(A,s,L){s=[];var Q,N,v;d=0;N=A.objects;A=0;for(Q=N.length;A<Q;A++){v=N[A];var z;if(!(z=!v.visible))if(z=v instanceof THREE.Mesh){a:{z=void 0;for(var y=v.matrixWorld,D=-v.geometry.boundingSphere.radius*Math.max(v.scale.x,Math.max(v.scale.y,v.scale.z)),q=0;q<6;q++){z=H[q].x*y.n14+H[q].y*y.n24+H[q].z*y.n34+H[q].w;if(z<=D){z=!1;break a}}z=!0}z=!z}if(!z){z=g[d]=g[d]||new THREE.RenderableObject;d++;e=z;G.copy(v.position);p.multiplyVector3(G);e.object=v;e.z=G.z;s.push(e)}}L&&
+s.sort(b);return s};this.projectScene=function(A,s,L){var Q=[],N=s.near,v=s.far,z,y,D,q,o,E,I,w,F,J,R,U,W,X,S,V,T;K=u=n=l=0;s.matrixAutoUpdate&&s.updateMatrix();A.update(undefined,!1,s);p.multiply(s.projectionMatrix,s.matrixWorldInverse);H[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);H[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);H[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);H[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);H[4].set(p.n41-p.n31,p.n42-p.n32,
+p.n43-p.n33,p.n44-p.n34);H[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+p.n33,p.n44+p.n34);for(z=0;z<6;z++){F=H[z];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}F=this.projectObjects(A,s,!0);A=0;for(z=F.length;A<z;A++){J=F[A].object;if(J.visible){R=J.matrixWorld;U=J.matrixRotationWorld;W=J.materials;X=J.overdraw;i=0;if(J instanceof THREE.Mesh){S=J.geometry;q=S.vertices;V=S.faces;S=S.faceVertexUvs;y=0;for(D=q.length;y<D;y++){f=a();f.positionWorld.copy(q[y].position);R.multiplyVector3(f.positionWorld);
+f.positionScreen.copy(f.positionWorld);p.multiplyVector4(f.positionScreen);f.positionScreen.x/=f.positionScreen.w;f.positionScreen.y/=f.positionScreen.w;f.visible=f.positionScreen.z>N&&f.positionScreen.z<v}q=0;for(y=V.length;q<y;q++){D=V[q];if(D instanceof THREE.Face3){o=h[D.a];E=h[D.b];I=h[D.c];if(o.visible&&E.visible&&I.visible&&(J.doubleSided||J.flipSided!=(I.positionScreen.x-o.positionScreen.x)*(E.positionScreen.y-o.positionScreen.y)-(I.positionScreen.y-o.positionScreen.y)*(E.positionScreen.x-
+o.positionScreen.x)<0)){w=m[l]=m[l]||new THREE.RenderableFace3;l++;j=w;j.v1.copy(o);j.v2.copy(E);j.v3.copy(I)}else continue}else if(D instanceof THREE.Face4){o=h[D.a];E=h[D.b];I=h[D.c];w=h[D.d];if(o.visible&&E.visible&&I.visible&&w.visible&&(J.doubleSided||J.flipSided!=((w.positionScreen.x-o.positionScreen.x)*(E.positionScreen.y-o.positionScreen.y)-(w.positionScreen.y-o.positionScreen.y)*(E.positionScreen.x-o.positionScreen.x)<0||(E.positionScreen.x-I.positionScreen.x)*(w.positionScreen.y-I.positionScreen.y)-
 (E.positionScreen.y-I.positionScreen.y)*(w.positionScreen.x-I.positionScreen.x)<0))){T=k[n]=k[n]||new THREE.RenderableFace4;n++;j=T;j.v1.copy(o);j.v2.copy(E);j.v3.copy(I);j.v4.copy(w)}else continue}j.normalWorld.copy(D.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(D.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);p.multiplyVector3(j.centroidScreen);I=D.vertexNormals;o=0;for(E=I.length;o<E;o++){w=j.vertexNormalsWorld[o];w.copy(I[o]);U.multiplyVector3(w)}o=
 0;for(E=S.length;o<E;o++)if(T=S[o][q]){I=0;for(w=T.length;I<w;I++)j.uvs[o][I]=T[I]}j.meshMaterials=W;j.faceMaterials=D.materials;j.overdraw=X;j.z=j.centroidScreen.z;Q.push(j)}}else if(J instanceof THREE.Line){O.multiply(p,R);q=J.geometry.vertices;o=a();o.positionScreen.copy(q[0].position);O.multiplyVector4(o.positionScreen);y=1;for(D=q.length;y<D;y++){o=a();o.positionScreen.copy(q[y].position);O.multiplyVector4(o.positionScreen);E=h[i-2];P.copy(o.positionScreen);M.copy(E.positionScreen);if(c(P,M)){P.multiplyScalar(1/
 P.w);M.multiplyScalar(1/M.w);R=B[u]=B[u]||new THREE.RenderableLine;u++;r=R;r.v1.positionScreen.copy(P);r.v2.positionScreen.copy(M);r.z=Math.max(P.z,M.z);r.materials=J.materials;Q.push(r)}}}else if(J instanceof THREE.Particle){C.set(J.position.x,J.position.y,J.position.z,1);p.multiplyVector4(C);C.z/=C.w;if(C.z>0&&C.z<1){R=x[K]=x[K]||new THREE.RenderableParticle;K++;t=R;t.x=C.x/C.w;t.y=C.y/C.w;t.z=C.z;t.rotation=J.rotation.z;t.scale.x=J.scale.x*Math.abs(t.x-(C.x+s.projectionMatrix.n11)/(C.w+s.projectionMatrix.n14));
@@ -129,13 +131,13 @@ THREE.SVGRenderer=function(){function a(v,z,y){var D,q,o,E;D=0;for(q=v.lights.le
 x.setRGB(H,H,H)}else q instanceof THREE.MeshNormalMaterial&&x.setRGB(d(D.normalWorld.x),d(D.normalWorld.y),d(D.normalWorld.z));q.wireframe?s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+q.wireframeLinewidth+"; stroke-opacity: "+q.opacity+"; stroke-linecap: "+q.wireframeLinecap+"; stroke-linejoin: "+q.wireframeLinejoin):s.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+q.opacity);i.appendChild(s)}function c(v,z,y,D,q,o,E){s=e(L++);s.setAttribute("d",
 "M "+v.positionScreen.x+" "+v.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+D.positionScreen.x+","+D.positionScreen.y+"z");if(o instanceof THREE.MeshBasicMaterial)x.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshLambertMaterial)if(K){G.r=C.r;G.g=C.g;G.b=C.b;a(E,q,G);x.r=o.color.r*G.r;x.g=o.color.g*G.g;x.b=o.color.b*G.b;x.updateStyleString()}else x.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshDepthMaterial){H=
 1-o.__2near/(o.__farPlusNear-q.z*o.__farMinusNear);x.setRGB(H,H,H)}else o instanceof THREE.MeshNormalMaterial&&x.setRGB(d(q.normalWorld.x),d(q.normalWorld.y),d(q.normalWorld.z));o.wireframe?s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):s.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+o.opacity);i.appendChild(s)}
-function e(v){if(M[v]==null){M[v]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&M[v].setAttribute("shape-rendering","crispEdges")}return M[v]}function d(v){return v<0?Math.min((1+v)*0.5,0.5):0.5+Math.min(v*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,j,m,l,n,k,r,u,B=new THREE.Rectangle,t=new THREE.Rectangle,K=!1,x=new THREE.Color(16777215),G=new THREE.Color(16777215),C=new THREE.Color(0),p=new THREE.Color(0),O=new THREE.Color(0),
-H,P=new THREE.Vector3,M=[],A=[],s,L,Q,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(v){switch(v){case "high":N=1;break;case "low":N=0}};this.setSize=function(v,z){h=v;j=z;m=h/2;l=j/2;i.setAttribute("viewBox",-m+" "+-l+" "+h+" "+j);i.setAttribute("width",h);i.setAttribute("height",j);B.set(-m,-l,m,l)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(v,z){var y,D,q,o,E,I,w,F;this.autoClear&&
-this.clear();f=g.projectScene(v,z,this.sortElements);Q=L=0;if(K=v.lights.length>0){w=v.lights;C.setRGB(0,0,0);p.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(D=w.length;y<D;y++){q=w[y];o=q.color;if(q instanceof THREE.AmbientLight){C.r+=o.r;C.g+=o.g;C.b+=o.b}else if(q instanceof THREE.DirectionalLight){p.r+=o.r;p.g+=o.g;p.b+=o.b}else if(q instanceof THREE.PointLight){O.r+=o.r;O.g+=o.g;O.b+=o.b}}}y=0;for(D=f.length;y<D;y++){w=f[y];t.empty();if(w instanceof THREE.RenderableParticle){n=w;n.x*=m;n.y*=-l;q=0;for(o=
-w.materials.length;q<o;)q++}else if(w instanceof THREE.RenderableLine){n=w.v1;k=w.v2;n.positionScreen.x*=m;n.positionScreen.y*=-l;k.positionScreen.x*=m;k.positionScreen.y*=-l;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);if(B.instersects(t)){q=0;for(o=w.materials.length;q<o;)if((F=w.materials[q++])&&F.opacity!=0){E=n;I=k;var J=Q++;if(A[J]==null){A[J]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&A[J].setAttribute("shape-rendering",
+function e(v){if(M[v]==null){M[v]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&M[v].setAttribute("shape-rendering","crispEdges")}return M[v]}function d(v){return v<0?Math.min((1+v)*0.5,0.5):0.5+Math.min(v*0.5,0.5)}var g=null,f=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,j,l,m,n,k,r,u,B=new THREE.Rectangle,t=new THREE.Rectangle,K=!1,x=new THREE.Color(16777215),G=new THREE.Color(16777215),C=new THREE.Color(0),p=new THREE.Color(0),O=new THREE.Color(0),
+H,P=new THREE.Vector3,M=[],A=[],s,L,Q,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(v){switch(v){case "high":N=1;break;case "low":N=0}};this.setSize=function(v,z){h=v;j=z;l=h/2;m=j/2;i.setAttribute("viewBox",-l+" "+-m+" "+h+" "+j);i.setAttribute("width",h);i.setAttribute("height",j);B.set(-l,-m,l,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(v,z){var y,D,q,o,E,I,w,F;this.autoClear&&
+this.clear();g=f.projectScene(v,z,this.sortElements);Q=L=0;if(K=v.lights.length>0){w=v.lights;C.setRGB(0,0,0);p.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(D=w.length;y<D;y++){q=w[y];o=q.color;if(q instanceof THREE.AmbientLight){C.r+=o.r;C.g+=o.g;C.b+=o.b}else if(q instanceof THREE.DirectionalLight){p.r+=o.r;p.g+=o.g;p.b+=o.b}else if(q instanceof THREE.PointLight){O.r+=o.r;O.g+=o.g;O.b+=o.b}}}y=0;for(D=g.length;y<D;y++){w=g[y];t.empty();if(w instanceof THREE.RenderableParticle){n=w;n.x*=l;n.y*=-m;q=0;for(o=
+w.materials.length;q<o;)q++}else if(w instanceof THREE.RenderableLine){n=w.v1;k=w.v2;n.positionScreen.x*=l;n.positionScreen.y*=-m;k.positionScreen.x*=l;k.positionScreen.y*=-m;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);if(B.instersects(t)){q=0;for(o=w.materials.length;q<o;)if((F=w.materials[q++])&&F.opacity!=0){E=n;I=k;var J=Q++;if(A[J]==null){A[J]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&A[J].setAttribute("shape-rendering",
 "crispEdges")}s=A[J];s.setAttribute("x1",E.positionScreen.x);s.setAttribute("y1",E.positionScreen.y);s.setAttribute("x2",I.positionScreen.x);s.setAttribute("y2",I.positionScreen.y);if(F instanceof THREE.LineBasicMaterial){x.__styleString=F.color.__styleString;s.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+F.linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.linecap+"; stroke-linejoin: "+F.linejoin);i.appendChild(s)}}}}else if(w instanceof THREE.RenderableFace3){n=
-w.v1;k=w.v2;r=w.v3;n.positionScreen.x*=m;n.positionScreen.y*=-l;k.positionScreen.x*=m;k.positionScreen.y*=-l;r.positionScreen.x*=m;r.positionScreen.y*=-l;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);if(B.instersects(t)){q=0;for(o=w.meshMaterials.length;q<o;){F=w.meshMaterials[q++];if(F instanceof THREE.MeshFaceMaterial){E=0;for(I=w.faceMaterials.length;E<I;)(F=w.faceMaterials[E++])&&F.opacity!=
-0&&b(n,k,r,w,F,v)}else F&&F.opacity!=0&&b(n,k,r,w,F,v)}}}else if(w instanceof THREE.RenderableFace4){n=w.v1;k=w.v2;r=w.v3;u=w.v4;n.positionScreen.x*=m;n.positionScreen.y*=-l;k.positionScreen.x*=m;k.positionScreen.y*=-l;r.positionScreen.x*=m;r.positionScreen.y*=-l;u.positionScreen.x*=m;u.positionScreen.y*=-l;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);
+w.v1;k=w.v2;r=w.v3;n.positionScreen.x*=l;n.positionScreen.y*=-m;k.positionScreen.x*=l;k.positionScreen.y*=-m;r.positionScreen.x*=l;r.positionScreen.y*=-m;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);if(B.instersects(t)){q=0;for(o=w.meshMaterials.length;q<o;){F=w.meshMaterials[q++];if(F instanceof THREE.MeshFaceMaterial){E=0;for(I=w.faceMaterials.length;E<I;)(F=w.faceMaterials[E++])&&F.opacity!=
+0&&b(n,k,r,w,F,v)}else F&&F.opacity!=0&&b(n,k,r,w,F,v)}}}else if(w instanceof THREE.RenderableFace4){n=w.v1;k=w.v2;r=w.v3;u=w.v4;n.positionScreen.x*=l;n.positionScreen.y*=-m;k.positionScreen.x*=l;k.positionScreen.y*=-m;r.positionScreen.x*=l;r.positionScreen.y*=-m;u.positionScreen.x*=l;u.positionScreen.y*=-m;t.addPoint(n.positionScreen.x,n.positionScreen.y);t.addPoint(k.positionScreen.x,k.positionScreen.y);t.addPoint(r.positionScreen.x,r.positionScreen.y);t.addPoint(u.positionScreen.x,u.positionScreen.y);
 if(B.instersects(t)){q=0;for(o=w.meshMaterials.length;q<o;){F=w.meshMaterials[q++];if(F instanceof THREE.MeshFaceMaterial){E=0;for(I=w.faceMaterials.length;E<I;)(F=w.faceMaterials[E++])&&F.opacity!=0&&c(n,k,r,u,w,F,v)}else F&&F.opacity!=0&&c(n,k,r,u,w,F,v)}}}}}};
 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 e,d=c.length;for(e=0;e<d;e++){a=c[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.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};

+ 172 - 166
build/custom/ThreeWebGL.js

@@ -1,7 +1,7 @@
 // ThreeWebGL.js r38 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(b){this.setHex(b)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,e){var h,g,j,k,o,q;if(e==0)h=g=j=0;else{k=Math.floor(b*6);o=b*6-k;b=e*(1-d);q=e*(1-d*o);d=e*(1-d*(1-o));switch(k){case 1:h=q;g=e;j=b;break;case 2:h=b;g=e;j=d;break;case 3:h=b;g=q;j=e;break;case 4:h=d;g=b;j=e;break;case 5:h=e;g=b;
-j=q;break;case 6:case 0:h=e;g=d;j=b}}this.r=h;this.g=g;this.b=j;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&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*
+THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,e){var h,g,k,j,o,p;if(e==0)h=g=k=0;else{j=Math.floor(b*6);o=b*6-j;b=e*(1-d);p=e*(1-d*o);d=e*(1-d*(1-o));switch(j){case 1:h=p;g=e;k=b;break;case 2:h=b;g=e;k=d;break;case 3:h=b;g=p;k=e;break;case 4:h=d;g=b;k=e;break;case 5:h=e;g=b;
+k=p;break;case 6:case 0:h=e;g=d;k=b}}this.r=h;this.g=g;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&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(b,d){this.set(b||0,d||0)};
 THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
@@ -12,72 +12,73 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 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(b,d,e,h){this.set(b||0,d||0,e||0,h||1)};
 THREE.Vector4.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,e,h=b.objects,g=[];b=0;for(d=h.length;b<d;b++){e=h[b];e instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(e)))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(b){function d(W,P,ra,ca){ca=ca.clone().subSelf(P);ra=ra.clone().subSelf(P);var sa=W.clone().subSelf(P);W=ca.dot(ca);P=ca.dot(ra);ca=ca.dot(sa);var Z=ra.dot(ra);ra=ra.dot(sa);sa=1/(W*Z-P*P);Z=(Z*ca-P*ra)*sa;W=(W*ra-P*ca)*sa;return Z>0&&W>0&&Z+W<
-1}var e,h,g,j,k,o,q,v,D,F,J,G=b.geometry,N=G.vertices,O=[];e=0;for(h=G.faces.length;e<h;e++){g=G.faces[e];F=this.origin.clone();J=this.direction.clone();q=b.matrixWorld;j=q.multiplyVector3(N[g.a].position.clone());k=q.multiplyVector3(N[g.b].position.clone());o=q.multiplyVector3(N[g.c].position.clone());q=g instanceof THREE.Face4?q.multiplyVector3(N[g.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(g.normal.clone());D=J.dot(v);if(D<0){v=v.dot((new THREE.Vector3).sub(j,F))/D;F=F.addSelf(J.multiplyScalar(v));
-if(g instanceof THREE.Face3){if(d(F,j,k,o)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}else if(g instanceof THREE.Face4&&(d(F,j,k,q)||d(F,k,o,q))){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}}return O}};
-THREE.Rectangle=function(){function b(){j=h-d;k=g-e}var d,e,h,g,j,k,o=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(q,v,D,F){o=!1;d=q;e=v;h=D;g=F;b()};this.addPoint=function(q,v){if(o){o=!1;d=q;e=v;h=q;g=v}else{d=d<q?d:q;e=e<v?e:v;h=h>q?h:q;g=g>v?g:v}b()};
-this.add3Points=function(q,v,D,F,J,G){if(o){o=!1;d=q<D?q<J?q:J:D<J?D:J;e=v<F?v<G?v:G:F<G?F:G;h=q>D?q>J?q:J:D>J?D:J;g=v>F?v>G?v:G:F>G?F:G}else{d=q<D?q<J?q<d?q:d:J<d?J:d:D<J?D<d?D:d:J<d?J:d;e=v<F?v<G?v<e?v:e:G<e?G:e:F<G?F<e?F:e:G<e?G:e;h=q>D?q>J?q>h?q:h:J>h?J:h:D>J?D>h?D:h:J>h?J:h;g=v>F?v>G?v>g?v:g:G>g?G:g:F>G?F>g?F:g:G>g?G:g}b()};this.addRectangle=function(q){if(o){o=!1;d=q.getLeft();e=q.getTop();h=q.getRight();g=q.getBottom()}else{d=d<q.getLeft()?d:q.getLeft();e=e<q.getTop()?e:q.getTop();h=h>q.getRight()?
-h:q.getRight();g=g>q.getBottom()?g:q.getBottom()}b()};this.inflate=function(q){d-=q;e-=q;h+=q;g+=q;b()};this.minSelf=function(q){d=d>q.getLeft()?d:q.getLeft();e=e>q.getTop()?e:q.getTop();h=h<q.getRight()?h:q.getRight();g=g<q.getBottom()?g:q.getBottom();b()};this.instersects=function(q){return Math.min(h,q.getRight())-Math.max(d,q.getLeft())>=0&&Math.min(g,q.getBottom())-Math.max(e,q.getTop())>=0};this.empty=function(){o=!0;g=h=e=d=0;b()};this.isEmpty=function(){return o}};
+THREE.Ray.prototype={intersectScene:function(b){var d,e,h=b.objects,g=[];b=0;for(d=h.length;b<d;b++){e=h[b];e instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(e)))}g.sort(function(k,j){return k.distance-j.distance});return g},intersectObject:function(b){function d(Y,O,ca,ma){ma=ma.clone().subSelf(O);ca=ca.clone().subSelf(O);var wa=Y.clone().subSelf(O);Y=ma.dot(ma);O=ma.dot(ca);ma=ma.dot(wa);var $=ca.dot(ca);ca=ca.dot(wa);wa=1/(Y*$-O*O);$=($*ma-O*ca)*wa;Y=(Y*ca-O*ma)*wa;return $>0&&Y>0&&$+Y<
+1}var e,h,g,k,j,o,p,u,D,F,I,G=b.geometry,L=G.vertices,M=[];e=0;for(h=G.faces.length;e<h;e++){g=G.faces[e];F=this.origin.clone();I=this.direction.clone();p=b.matrixWorld;k=p.multiplyVector3(L[g.a].position.clone());j=p.multiplyVector3(L[g.b].position.clone());o=p.multiplyVector3(L[g.c].position.clone());p=g instanceof THREE.Face4?p.multiplyVector3(L[g.d].position.clone()):null;u=b.matrixRotationWorld.multiplyVector3(g.normal.clone());D=I.dot(u);if(b.doubleSided||(b.flipSided?D>0:D<0)){u=u.dot((new THREE.Vector3).sub(k,
+F))/D;F=F.addSelf(I.multiplyScalar(u));if(g instanceof THREE.Face3){if(d(F,k,j,o)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};M.push(g)}}else if(g instanceof THREE.Face4&&(d(F,k,j,p)||d(F,j,o,p))){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};M.push(g)}}}return M}};
+THREE.Rectangle=function(){function b(){k=h-d;j=g-e}var d,e,h,g,k,j,o=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(p,u,D,F){o=!1;d=p;e=u;h=D;g=F;b()};this.addPoint=function(p,u){if(o){o=!1;d=p;e=u;h=p;g=u}else{d=d<p?d:p;e=e<u?e:u;h=h>p?h:p;g=g>u?g:u}b()};
+this.add3Points=function(p,u,D,F,I,G){if(o){o=!1;d=p<D?p<I?p:I:D<I?D:I;e=u<F?u<G?u:G:F<G?F:G;h=p>D?p>I?p:I:D>I?D:I;g=u>F?u>G?u:G:F>G?F:G}else{d=p<D?p<I?p<d?p:d:I<d?I:d:D<I?D<d?D:d:I<d?I:d;e=u<F?u<G?u<e?u:e:G<e?G:e:F<G?F<e?F:e:G<e?G:e;h=p>D?p>I?p>h?p:h:I>h?I:h:D>I?D>h?D:h:I>h?I:h;g=u>F?u>G?u>g?u:g:G>g?G:g:F>G?F>g?F:g:G>g?G:g}b()};this.addRectangle=function(p){if(o){o=!1;d=p.getLeft();e=p.getTop();h=p.getRight();g=p.getBottom()}else{d=d<p.getLeft()?d:p.getLeft();e=e<p.getTop()?e:p.getTop();h=h>p.getRight()?
+h:p.getRight();g=g>p.getBottom()?g:p.getBottom()}b()};this.inflate=function(p){d-=p;e-=p;h+=p;g+=p;b()};this.minSelf=function(p){d=d>p.getLeft()?d:p.getLeft();e=e>p.getTop()?e:p.getTop();h=h<p.getRight()?h:p.getRight();g=g<p.getBottom()?g:p.getBottom();b()};this.instersects=function(p){return Math.min(h,p.getRight())-Math.max(d,p.getLeft())>=0&&Math.min(g,p.getBottom())-Math.max(e,p.getTop())>=0};this.empty=function(){o=!0;g=h=e=d=0;b()};this.isEmpty=function(){return o}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};
-THREE.Matrix4=function(b,d,e,h,g,j,k,o,q,v,D,F,J,G,N,O){this.set(b||1,d||0,e||0,h||0,g||0,j||1,k||0,o||0,q||0,v||0,D||1,F||0,J||0,G||0,N||0,O||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(b,d,e,h,g,j,k,o,q,v,D,F,J,G,N,O){this.n11=b;this.n12=d;this.n13=e;this.n14=h;this.n21=g;this.n22=j;this.n23=k;this.n24=o;this.n31=q;this.n32=v;this.n33=D;this.n34=F;this.n41=J;this.n42=G;this.n43=N;this.n44=O;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var h=THREE.Matrix4.__v1,
-g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,d).normalize();if(j.length()===0)j.z=1;h.cross(e,j).normalize();if(h.length()===0){j.x+=1.0E-4;h.cross(e,j).normalize()}g.cross(j,h).normalize();this.n11=h.x;this.n12=g.x;this.n13=j.x;this.n21=h.y;this.n22=g.y;this.n23=j.y;this.n31=h.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,h=b.z,g=1/(this.n41*d+this.n42*e+this.n43*h+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*h+this.n14)*g;b.y=(this.n21*d+this.n22*e+this.n23*
+THREE.Matrix4=function(b,d,e,h,g,k,j,o,p,u,D,F,I,G,L,M){this.set(b||1,d||0,e||0,h||0,g||0,k||1,j||0,o||0,p||0,u||0,D||1,F||0,I||0,G||0,L||0,M||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(b,d,e,h,g,k,j,o,p,u,D,F,I,G,L,M){this.n11=b;this.n12=d;this.n13=e;this.n14=h;this.n21=g;this.n22=k;this.n23=j;this.n24=o;this.n31=p;this.n32=u;this.n33=D;this.n34=F;this.n41=I;this.n42=G;this.n43=L;this.n44=M;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var h=THREE.Matrix4.__v1,
+g=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,d).normalize();if(k.length()===0)k.z=1;h.cross(e,k).normalize();if(h.length()===0){k.x+=1.0E-4;h.cross(e,k).normalize()}g.cross(k,h).normalize();this.n11=h.x;this.n12=g.x;this.n13=k.x;this.n21=h.y;this.n22=g.y;this.n23=k.y;this.n31=h.z;this.n32=g.z;this.n33=k.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,h=b.z,g=1/(this.n41*d+this.n42*e+this.n43*h+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*h+this.n14)*g;b.y=(this.n21*d+this.n22*e+this.n23*
 h+this.n24)*g;b.z=(this.n31*d+this.n32*e+this.n33*h+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,e=b.y,h=b.z,g=b.w;b.x=this.n11*d+this.n12*e+this.n13*h+this.n14*g;b.y=this.n21*d+this.n22*e+this.n23*h+this.n24*g;b.z=this.n31*d+this.n32*e+this.n33*h+this.n34*g;b.w=this.n41*d+this.n42*e+this.n43*h+this.n44*g;return b},rotateAxis:function(b){var d=b.x,e=b.y,h=b.z;b.x=d*this.n11+e*this.n12+h*this.n13;b.y=d*this.n21+e*this.n22+h*this.n23;b.z=d*this.n31+e*this.n32+h*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,o=b.n22,q=b.n23,v=b.n24,D=b.n31,F=b.n32,J=b.n33,G=b.n34,N=b.n41,O=b.n42,W=b.n43,P=b.n44,ra=d.n11,ca=d.n12,sa=d.n13,Z=d.n14,K=d.n21,Ia=d.n22,
-ka=d.n23,Da=d.n24,ea=d.n31,c=d.n32,S=d.n33,oa=d.n34;this.n11=e*ra+h*K+g*ea;this.n12=e*ca+h*Ia+g*c;this.n13=e*sa+h*ka+g*S;this.n14=e*Z+h*Da+g*oa+j;this.n21=k*ra+o*K+q*ea;this.n22=k*ca+o*Ia+q*c;this.n23=k*sa+o*ka+q*S;this.n24=k*Z+o*Da+q*oa+v;this.n31=D*ra+F*K+J*ea;this.n32=D*ca+F*Ia+J*c;this.n33=D*sa+F*ka+J*S;this.n34=D*Z+F*Da+J*oa+G;this.n41=N*ra+O*K+W*ea;this.n42=N*ca+O*Ia+W*c;this.n43=N*sa+O*ka+W*S;this.n44=N*Z+O*Da+W*oa+P;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,h=b.n12,g=b.n13,k=b.n14,j=b.n21,o=b.n22,p=b.n23,u=b.n24,D=b.n31,F=b.n32,I=b.n33,G=b.n34,L=b.n41,M=b.n42,Y=b.n43,O=b.n44,ca=d.n11,ma=d.n12,wa=d.n13,$=d.n14,J=d.n21,xa=d.n22,
+ta=d.n23,ea=d.n24,c=d.n31,U=d.n32,V=d.n33,na=d.n34;this.n11=e*ca+h*J+g*c;this.n12=e*ma+h*xa+g*U;this.n13=e*wa+h*ta+g*V;this.n14=e*$+h*ea+g*na+k;this.n21=j*ca+o*J+p*c;this.n22=j*ma+o*xa+p*U;this.n23=j*wa+o*ta+p*V;this.n24=j*$+o*ea+p*na+u;this.n31=D*ca+F*J+I*c;this.n32=D*ma+F*xa+I*U;this.n33=D*wa+F*ta+I*V;this.n34=D*$+F*ea+I*na+G;this.n41=L*ca+M*J+Y*c;this.n42=L*ma+M*xa+Y*U;this.n43=L*wa+M*ta+Y*V;this.n44=L*$+M*ea+Y*na+O;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
 e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
-b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,g=this.n21,j=this.n22,k=this.n23,o=this.n24,q=this.n31,v=this.n32,D=this.n33,F=this.n34,J=this.n41,G=this.n42,N=this.n43,O=this.n44;return h*k*v*J-e*o*v*J-h*j*D*J+d*o*D*J+e*j*F*J-d*k*F*J-h*k*q*G+e*o*q*G+h*g*D*G-b*o*D*G-e*g*F*G+b*k*F*G+h*j*q*N-d*o*q*N-h*g*v*N+b*o*v*N+d*g*F*N-b*j*F*N-e*j*q*O+d*k*q*O+e*g*v*O-b*k*v*O-d*g*D*O+b*j*D*O},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
+b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,g=this.n21,k=this.n22,j=this.n23,o=this.n24,p=this.n31,u=this.n32,D=this.n33,F=this.n34,I=this.n41,G=this.n42,L=this.n43,M=this.n44;return h*j*u*I-e*o*u*I-h*k*D*I+d*o*D*I+e*k*F*I-d*j*F*I-h*j*p*G+e*o*p*G+h*g*D*G-b*o*D*G-e*g*F*G+b*j*F*G+h*k*p*L-d*o*p*L-h*g*u*L+b*o*u*L+d*g*F*L-b*k*F*L-e*k*p*M+d*j*p*M+e*g*u*M-b*j*u*M-d*g*D*M+b*k*D*M},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
 this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
 this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;
 b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,
 0,1);return this},setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),h=Math.sin(d),g=
-1-e,j=b.x,k=b.y,o=b.z,q=g*j,v=g*k;this.set(q*j+e,q*k-h*o,q*o+h*k,0,q*k+h*o,v*k+e,v*o-h*j,0,q*o-h*k,v*o+h*j,g*o*o+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,e=b.y,h=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(e);e=Math.sin(e);var j=Math.cos(h);h=Math.sin(h);var k=b*e,o=d*e;this.n11=g*j;this.n12=-g*h;this.n13=e;this.n21=o*j+b*h;this.n22=-o*h+b*j;this.n23=-d*g;this.n31=-k*j+d*h;this.n32=k*h+d*j;this.n33=
-b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,h=b.z,g=b.w,j=d+d,k=e+e,o=h+h;b=d*j;var q=d*k;d*=o;var v=e*k;e*=o;h*=o;j*=g;k*=g;g*=o;this.n11=1-(v+h);this.n12=q-g;this.n13=d+k;this.n21=q+g;this.n22=1-(b+h);this.n23=e-j;this.n31=d-k;this.n32=e+j;this.n33=1-(b+v);return this},scale:function(b){var d=b.x,e=b.y;b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
+1-e,k=b.x,j=b.y,o=b.z,p=g*k,u=g*j;this.set(p*k+e,p*j-h*o,p*o+h*j,0,p*j+h*o,u*j+e,u*o-h*k,0,p*o-h*j,u*o+h*k,g*o*o+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,e=b.y,h=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(e);e=Math.sin(e);var k=Math.cos(h);h=Math.sin(h);var j=b*e,o=d*e;this.n11=g*k;this.n12=-g*h;this.n13=e;this.n21=o*k+b*h;this.n22=-o*h+b*k;this.n23=-d*g;this.n31=-j*k+d*h;this.n32=j*h+d*k;this.n33=
+b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,h=b.z,g=b.w,k=d+d,j=e+e,o=h+h;b=d*k;var p=d*j;d*=o;var u=e*j;e*=o;h*=o;k*=g;j*=g;g*=o;this.n11=1-(u+h);this.n12=p-g;this.n13=d+j;this.n21=p+g;this.n22=1-(b+h);this.n23=e-k;this.n31=d-j;this.n32=e+k;this.n33=1-(b+u);return this},scale:function(b){var d=b.x,e=b.y;b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var e=1/d.x,h=1/d.y,g=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*h;this.n22=b.n22*h;this.n32=b.n32*h;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
-THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,o=b.n22,q=b.n23,v=b.n24,D=b.n31,F=b.n32,J=b.n33,G=b.n34,N=b.n41,O=b.n42,W=b.n43,P=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=q*G*O-v*J*O+v*F*W-o*G*W-q*F*P+o*J*P;d.n12=j*J*O-g*G*O-j*F*W+h*G*W+g*F*P-h*J*P;d.n13=g*v*O-j*q*O+j*o*W-h*v*W-g*o*P+h*q*P;d.n14=j*q*F-g*v*F-j*o*J+h*v*J+g*o*G-h*q*G;d.n21=v*J*N-q*G*N-v*D*W+k*G*W+q*D*P-k*J*P;d.n22=g*G*N-j*J*N+j*D*W-e*G*W-g*D*P+e*J*P;d.n23=j*q*N-g*v*N-j*k*W+e*v*W+g*k*P-e*q*P;
-d.n24=g*v*D-j*q*D+j*k*J-e*v*J-g*k*G+e*q*G;d.n31=o*G*N-v*F*N+v*D*O-k*G*O-o*D*P+k*F*P;d.n32=j*F*N-h*G*N-j*D*O+e*G*O+h*D*P-e*F*P;d.n33=g*v*N-j*o*N+j*k*O-e*v*O-h*k*P+e*o*P;d.n34=j*o*D-h*v*D-j*k*F+e*v*F+h*k*G-e*o*G;d.n41=q*F*N-o*J*N-q*D*O+k*J*O+o*D*W-k*F*W;d.n42=h*J*N-g*F*N+g*D*O-e*J*O-h*D*W+e*F*W;d.n43=g*o*N-h*q*N-g*k*O+e*q*O+h*k*W-e*o*W;d.n44=h*q*D-g*o*D+g*k*F-e*q*F-h*k*J+e*o*J;d.multiplyScalar(1/b.determinant());return d};
-THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,o=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,v=b.n23*b.n12-b.n22*b.n13,D=-b.n23*b.n11+b.n21*b.n13,F=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*k+b.n31*v;if(b==0)throw"matrix not invertible";b=1/b;e[0]=b*h;e[1]=b*g;e[2]=b*j;e[3]=b*k;e[4]=b*o;e[5]=b*q;e[6]=b*v;e[7]=b*D;e[8]=b*F;return d};
-THREE.Matrix4.makeFrustum=function(b,d,e,h,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(d-b);k.n12=0;k.n13=(d+b)/(d-b);k.n14=0;k.n21=0;k.n22=2*g/(h-e);k.n23=(h+e)/(h-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,d,e,h){var g;b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,e,h)};
-THREE.Matrix4.makeOrtho=function(b,d,e,h,g,j){var k,o,q,v;k=new THREE.Matrix4;o=d-b;q=e-h;v=j-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((d+b)/o);k.n21=0;k.n22=2/q;k.n23=0;k.n24=-((e+h)/q);k.n31=0;k.n32=0;k.n33=-2/v;k.n34=-((j+g)/v);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,h=b.n12,g=b.n13,k=b.n14,j=b.n21,o=b.n22,p=b.n23,u=b.n24,D=b.n31,F=b.n32,I=b.n33,G=b.n34,L=b.n41,M=b.n42,Y=b.n43,O=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=p*G*M-u*I*M+u*F*Y-o*G*Y-p*F*O+o*I*O;d.n12=k*I*M-g*G*M-k*F*Y+h*G*Y+g*F*O-h*I*O;d.n13=g*u*M-k*p*M+k*o*Y-h*u*Y-g*o*O+h*p*O;d.n14=k*p*F-g*u*F-k*o*I+h*u*I+g*o*G-h*p*G;d.n21=u*I*L-p*G*L-u*D*Y+j*G*Y+p*D*O-j*I*O;d.n22=g*G*L-k*I*L+k*D*Y-e*G*Y-g*D*O+e*I*O;d.n23=k*p*L-g*u*L-k*j*Y+e*u*Y+g*j*O-e*p*O;
+d.n24=g*u*D-k*p*D+k*j*I-e*u*I-g*j*G+e*p*G;d.n31=o*G*L-u*F*L+u*D*M-j*G*M-o*D*O+j*F*O;d.n32=k*F*L-h*G*L-k*D*M+e*G*M+h*D*O-e*F*O;d.n33=g*u*L-k*o*L+k*j*M-e*u*M-h*j*O+e*o*O;d.n34=k*o*D-h*u*D-k*j*F+e*u*F+h*j*G-e*o*G;d.n41=p*F*L-o*I*L-p*D*M+j*I*M+o*D*Y-j*F*Y;d.n42=h*I*L-g*F*L+g*D*M-e*I*M-h*D*Y+e*F*Y;d.n43=g*o*L-h*p*L-g*j*M+e*p*M+h*j*Y-e*o*Y;d.n44=h*p*D-g*o*D+g*j*F-e*p*F-h*j*I+e*o*I;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,o=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,u=b.n23*b.n12-b.n22*b.n13,D=-b.n23*b.n11+b.n21*b.n13,F=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*j+b.n31*u;if(b==0)throw"matrix not invertible";b=1/b;e[0]=b*h;e[1]=b*g;e[2]=b*k;e[3]=b*j;e[4]=b*o;e[5]=b*p;e[6]=b*u;e[7]=b*D;e[8]=b*F;return d};
+THREE.Matrix4.makeFrustum=function(b,d,e,h,g,k){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(h-e);j.n23=(h+e)/(h-e);j.n24=0;j.n31=0;j.n32=0;j.n33=-(k+g)/(k-g);j.n34=-2*k*g/(k-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,e,h){var g;b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,e,h)};
+THREE.Matrix4.makeOrtho=function(b,d,e,h,g,k){var j,o,p,u;j=new THREE.Matrix4;o=d-b;p=e-h;u=k-g;j.n11=2/o;j.n12=0;j.n13=0;j.n14=-((d+b)/o);j.n21=0;j.n22=2/p;j.n23=0;j.n24=-((e+h)/p);j.n31=0;j.n32=0;j.n33=-2/u;j.n34=-((k+g)/u);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};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(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
 undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,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))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var h=this.children.length;b<h;b++)this.children[b].update(this.matrixWorld,
 d,e)}};THREE.Quaternion=function(b,d,e,h){this.set(b||0,d||0,e||0,h!==undefined?h:1)};
-THREE.Quaternion.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,h=b.y*d,g=b.z*d;b=Math.cos(h);h=Math.sin(h);d=Math.cos(-g);g=Math.sin(-g);var j=Math.cos(e);e=Math.sin(e);var k=b*d,o=h*g;this.w=k*j-o*e;this.x=k*e+o*j;this.y=h*d*j+b*g*e;this.z=b*g*j-h*d*e;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,e=this.y,h=this.z,g=this.w,j=b.x,k=b.y,o=b.z;b=b.w;this.x=d*b+g*j+e*o-h*k;this.y=e*b+g*k+h*j-d*o;this.z=h*b+g*o+d*k-e*j;this.w=g*b-d*j-e*k-h*o;return this},
-multiplyVector3:function(b,d){d||(d=b);var e=b.x,h=b.y,g=b.z,j=this.x,k=this.y,o=this.z,q=this.w,v=q*e+k*g-o*h,D=q*h+o*e-j*g,F=q*g+j*h-k*e;e=-j*e-k*h-o*g;d.x=v*q+e*-j+D*-o-F*-k;d.y=D*q+e*-k+F*-j-v*-o;d.z=F*q+e*-o+v*-k-D*-j;return d}};
-THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var j=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}g=Math.sin((1-h)*j)/k;h=Math.sin(h*j)/k;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
-THREE.Face3=function(b,d,e,h,g,j){this.a=b;this.b=d;this.c=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};
-THREE.Face4=function(b,d,e,h,g,j,k){this.a=b;this.b=d;this.c=e;this.d=h;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
-THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
+THREE.Quaternion.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,h=b.y*d,g=b.z*d;b=Math.cos(h);h=Math.sin(h);d=Math.cos(-g);g=Math.sin(-g);var k=Math.cos(e);e=Math.sin(e);var j=b*d,o=h*g;this.w=j*k-o*e;this.x=j*e+o*k;this.y=h*d*k+b*g*e;this.z=b*g*k-h*d*e;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
+-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,e=this.y,h=this.z,g=this.w,k=b.x,j=b.y,o=b.z;b=b.w;this.x=d*b+g*k+e*o-h*j;this.y=e*b+g*j+h*k-d*o;this.z=h*b+g*o+d*j-e*k;this.w=g*b-d*k-e*j-h*o;return this},
+multiplyVector3:function(b,d){d||(d=b);var e=b.x,h=b.y,g=b.z,k=this.x,j=this.y,o=this.z,p=this.w,u=p*e+j*g-o*h,D=p*h+o*e-k*g,F=p*g+k*h-j*e;e=-k*e-j*h-o*g;d.x=u*p+e*-k+D*-o-F*-j;d.y=D*p+e*-j+F*-k-u*-o;d.z=F*p+e*-o+u*-j-D*-k;return d}};
+THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var k=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}g=Math.sin((1-h)*k)/j;h=Math.sin(h*k)/j;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Face3=function(b,d,e,h,g,k){this.a=b;this.b=d;this.c=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};
+THREE.Face4=function(b,d,e,h,g,k,j){this.a=b;this.b=d;this.c=e;this.d=h;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
+THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var b,d,e;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
-e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,e,h,g,j,k,o=new THREE.Vector3,q=new THREE.Vector3;h=0;for(g=this.faces.length;h<g;h++){j=this.faces[h];if(b&&j.vertexNormals.length){o.set(0,0,0);d=0;for(e=j.vertexNormals.length;d<e;d++)o.addSelf(j.vertexNormals[d]);o.divideScalar(3)}else{d=this.vertices[j.a];e=this.vertices[j.b];k=this.vertices[j.c];o.sub(k.position,e.position);q.sub(d.position,e.position);o.crossSelf(q)}o.isZero()||
-o.normalize();j.normal.copy(o)}},computeVertexNormals:function(){var b,d,e,h;if(this.__tmpVertices==undefined){h=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)h[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{h=
+e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,e,h,g,k,j,o=new THREE.Vector3,p=new THREE.Vector3;h=0;for(g=this.faces.length;h<g;h++){k=this.faces[h];if(b&&k.vertexNormals.length){o.set(0,0,0);d=0;for(e=k.vertexNormals.length;d<e;d++)o.addSelf(k.vertexNormals[d]);o.divideScalar(3)}else{d=this.vertices[k.a];e=this.vertices[k.b];j=this.vertices[k.c];o.sub(j.position,e.position);p.sub(d.position,e.position);o.crossSelf(p)}o.isZero()||
+o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var b,d,e,h;if(this.__tmpVertices==undefined){h=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)h[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{h=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)h[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){h[e.a].addSelf(e.normal);h[e.b].addSelf(e.normal);h[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){h[e.a].addSelf(e.normal);h[e.b].addSelf(e.normal);h[e.c].addSelf(e.normal);h[e.d].addSelf(e.normal)}}b=0;for(d=this.vertices.length;b<d;b++)h[b].normalize();b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(h[e.a]);
-e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(h[e.a]);e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c]);e.vertexNormals[3].copy(h[e.d])}}},computeTangents:function(){function b(aa,ma,na,la,Y,va,pa){o=aa.vertices[ma].position;q=aa.vertices[na].position;v=aa.vertices[la].position;D=k[Y];F=k[va];J=k[pa];G=q.x-o.x;N=v.x-o.x;O=q.y-o.y;W=v.y-o.y;P=q.z-o.z;ra=v.z-o.z;ca=F.u-D.u;sa=J.u-D.u;Z=F.v-D.v;K=J.v-D.v;Ia=1/(ca*
-K-sa*Z);c.set((K*G-Z*N)*Ia,(K*O-Z*W)*Ia,(K*P-Z*ra)*Ia);S.set((ca*N-sa*G)*Ia,(ca*W-sa*O)*Ia,(ca*ra-sa*P)*Ia);Da[ma].addSelf(c);Da[na].addSelf(c);Da[la].addSelf(c);ea[ma].addSelf(S);ea[na].addSelf(S);ea[la].addSelf(S)}var d,e,h,g,j,k,o,q,v,D,F,J,G,N,O,W,P,ra,ca,sa,Z,K,Ia,ka,Da=[],ea=[],c=new THREE.Vector3,S=new THREE.Vector3,oa=new THREE.Vector3,ta=new THREE.Vector3,Ea=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){Da[d]=new THREE.Vector3;ea[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
-e;d++){j=this.faces[d];k=this.faceVertexUvs[0][d];if(j instanceof THREE.Face3)b(this,j.a,j.b,j.c,0,1,2);else if(j instanceof THREE.Face4){b(this,j.a,j.b,j.c,0,1,2);b(this,j.a,j.b,j.d,0,1,3)}}var wa=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){j=this.faces[d];for(h=0;h<j.vertexNormals.length;h++){Ea.copy(j.vertexNormals[h]);g=j[wa[h]];ka=Da[g];oa.copy(ka);oa.subSelf(Ea.multiplyScalar(Ea.dot(ka))).normalize();ta.cross(j.vertexNormals[h],ka);g=ta.dot(ea[g]);g=g<0?-1:1;j.vertexTangents[h]=new THREE.Vector4(oa.x,
-oa.y,oa.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
+e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(h[e.a]);e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c]);e.vertexNormals[3].copy(h[e.d])}}},computeTangents:function(){function b(aa,pa,fa,qa,Z,ua,oa){o=aa.vertices[pa].position;p=aa.vertices[fa].position;u=aa.vertices[qa].position;D=j[Z];F=j[ua];I=j[oa];G=p.x-o.x;L=u.x-o.x;M=p.y-o.y;Y=u.y-o.y;O=p.z-o.z;ca=u.z-o.z;ma=F.u-D.u;wa=I.u-D.u;$=F.v-D.v;J=I.v-D.v;xa=1/(ma*
+J-wa*$);U.set((J*G-$*L)*xa,(J*M-$*Y)*xa,(J*O-$*ca)*xa);V.set((ma*L-wa*G)*xa,(ma*Y-wa*M)*xa,(ma*ca-wa*O)*xa);ea[pa].addSelf(U);ea[fa].addSelf(U);ea[qa].addSelf(U);c[pa].addSelf(V);c[fa].addSelf(V);c[qa].addSelf(V)}var d,e,h,g,k,j,o,p,u,D,F,I,G,L,M,Y,O,ca,ma,wa,$,J,xa,ta,ea=[],c=[],U=new THREE.Vector3,V=new THREE.Vector3,na=new THREE.Vector3,Fa=new THREE.Vector3,Ga=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){ea[d]=new THREE.Vector3;c[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
+e;d++){k=this.faces[d];j=this.faceVertexUvs[0][d];if(k instanceof THREE.Face3)b(this,k.a,k.b,k.c,0,1,2);else if(k instanceof THREE.Face4){b(this,k.a,k.b,k.c,0,1,2);b(this,k.a,k.b,k.d,0,1,3)}}var ya=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){k=this.faces[d];for(h=0;h<k.vertexNormals.length;h++){Ga.copy(k.vertexNormals[h]);g=k[ya[h]];ta=ea[g];na.copy(ta);na.subSelf(Ga.multiplyScalar(Ga.dot(ta))).normalize();Fa.cross(k.vertexNormals[h],ta);g=Fa.dot(c[g]);g=g<0?-1:1;k.vertexTangents[h]=new THREE.Vector4(na.x,
+na.y,na.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,e=this.vertices.length;d<e;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
-{radius:b}}};THREE.GeometryIdCounter=0;
-THREE.AnimationHandler=function(){var b=[],d={},e={};e.update=function(g){for(var j=0;j<b.length;j++)b[j].update(g)};e.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};e.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};e.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var j=0;j<g.hierarchy.length;j++){for(var k=0;k<g.hierarchy[j].keys.length;k++){if(g.hierarchy[j].keys[k].time<
-0)g.hierarchy[j].keys[k].time=0;if(g.hierarchy[j].keys[k].rot!==undefined&&!(g.hierarchy[j].keys[k].rot instanceof THREE.Quaternion)){var o=g.hierarchy[j].keys[k].rot;g.hierarchy[j].keys[k].rot=new THREE.Quaternion(o[0],o[1],o[2],o[3])}}if(g.hierarchy[j].keys[0].morphTargets!==undefined){o={};for(k=0;k<g.hierarchy[j].keys.length;k++)for(var q=0;q<g.hierarchy[j].keys[k].morphTargets.length;q++){var v=g.hierarchy[j].keys[k].morphTargets[q];o[v]=-1}g.hierarchy[j].usedMorphTargets=o;for(k=0;k<g.hierarchy[j].keys.length;k++){var D=
-{};for(v in o){for(q=0;q<g.hierarchy[j].keys[k].morphTargets.length;q++)if(g.hierarchy[j].keys[k].morphTargets[q]===v){D[v]=g.hierarchy[j].keys[k].morphTargetsInfluences[q];break}q===g.hierarchy[j].keys[k].morphTargets.length&&(D[v]=0)}g.hierarchy[j].keys[k].morphTargetsInfluences=D}}for(k=1;k<g.hierarchy[j].keys.length;k++)if(g.hierarchy[j].keys[k].time===g.hierarchy[j].keys[k-1].time){g.hierarchy[j].keys.splice(k,1);k--}for(k=1;k<g.hierarchy[j].keys.length;k++)g.hierarchy[j].keys[k].index=k}k=parseInt(g.length*
-g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(j=0;j<g.hierarchy.length;j++)g.JIT.hierarchy.push(Array(k));g.initialized=!0}};e.get=function(g){if(typeof g==="string")if(d[g])return d[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};e.parse=function(g){var j=[];if(g instanceof THREE.SkinnedMesh)for(var k=0;k<g.bones.length;k++)j.push(g.bones[k]);else h(g,j);return j};var h=function(g,j){j.push(g);for(var k=0;k<g.children.length;k++)h(g.children[k],j)};e.LINEAR=
+{radius:b}},computeEdgeFaces:function(){function b(p,u){return Math.min(p,u)+"_"+Math.max(p,u)}function d(p,u,D){if(p[u]===undefined){p[u]={set:{},array:[]};p[u].set[D]=1;p[u].array.push(D)}else if(p[u].set[D]===undefined){p[u].set[D]=1;p[u].array.push(D)}}var e,h,g,k,j,o={};e=0;for(h=this.faces.length;e<h;e++){j=this.faces[e];if(j instanceof THREE.Face3){g=b(j.a,j.b);d(o,g,e);g=b(j.b,j.c);d(o,g,e);g=b(j.a,j.c);d(o,g,e)}else if(j instanceof THREE.Face4){g=b(j.b,j.d);d(o,g,e);g=b(j.a,j.b);d(o,g,e);
+g=b(j.a,j.d);d(o,g,e);g=b(j.b,j.c);d(o,g,e);g=b(j.c,j.d);d(o,g,e)}}e=0;for(h=this.edges.length;e<h;e++){j=this.edges[e];g=j.vertexIndices[0];k=j.vertexIndices[1];j.faceIndices=o[b(g,k)].array;for(g=0;g<j.faceIndices.length;g++){k=j.faceIndices[g];j.faces.push(this.faces[k])}}}};THREE.GeometryIdCounter=0;
+THREE.AnimationHandler=function(){var b=[],d={},e={};e.update=function(g){for(var k=0;k<b.length;k++)b[k].update(g)};e.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};e.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};e.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var k=0;k<g.hierarchy.length;k++){for(var j=0;j<g.hierarchy[k].keys.length;j++){if(g.hierarchy[k].keys[j].time<
+0)g.hierarchy[k].keys[j].time=0;if(g.hierarchy[k].keys[j].rot!==undefined&&!(g.hierarchy[k].keys[j].rot instanceof THREE.Quaternion)){var o=g.hierarchy[k].keys[j].rot;g.hierarchy[k].keys[j].rot=new THREE.Quaternion(o[0],o[1],o[2],o[3])}}if(g.hierarchy[k].keys[0].morphTargets!==undefined){o={};for(j=0;j<g.hierarchy[k].keys.length;j++)for(var p=0;p<g.hierarchy[k].keys[j].morphTargets.length;p++){var u=g.hierarchy[k].keys[j].morphTargets[p];o[u]=-1}g.hierarchy[k].usedMorphTargets=o;for(j=0;j<g.hierarchy[k].keys.length;j++){var D=
+{};for(u in o){for(p=0;p<g.hierarchy[k].keys[j].morphTargets.length;p++)if(g.hierarchy[k].keys[j].morphTargets[p]===u){D[u]=g.hierarchy[k].keys[j].morphTargetsInfluences[p];break}p===g.hierarchy[k].keys[j].morphTargets.length&&(D[u]=0)}g.hierarchy[k].keys[j].morphTargetsInfluences=D}}for(j=1;j<g.hierarchy[k].keys.length;j++)if(g.hierarchy[k].keys[j].time===g.hierarchy[k].keys[j-1].time){g.hierarchy[k].keys.splice(j,1);j--}for(j=1;j<g.hierarchy[k].keys.length;j++)g.hierarchy[k].keys[j].index=j}j=parseInt(g.length*
+g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(k=0;k<g.hierarchy.length;k++)g.JIT.hierarchy.push(Array(j));g.initialized=!0}};e.get=function(g){if(typeof g==="string")if(d[g])return d[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};e.parse=function(g){var k=[];if(g instanceof THREE.SkinnedMesh)for(var j=0;j<g.bones.length;j++)k.push(g.bones[j]);else h(g,k);return k};var h=function(g,k){k.push(g);for(var j=0;j<g.children.length;j++)h(g.children[j],k)};e.LINEAR=
 0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=2;return e}();THREE.Animation=function(b,d,e,h){this.root=b;this.data=THREE.AnimationHandler.get(d);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=e!==undefined?e:THREE.AnimationHandler.LINEAR;this.JITCompile=h!==undefined?h:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(b,d){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==undefined?b:!0;this.currentTime=d!==undefined?d:0;var e,h=this.hierarchy.length,g;for(e=0;e<h;e++){g=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===undefined){g.animationCache={};g.animationCache.prevKey={pos:0,rot:0,scl:0};g.animationCache.nextKey={pos:0,rot:0,scl:0};g.animationCache.originalMatrix=
-g instanceof THREE.Bone?g.skinMatrix:g.matrix}var j=g.animationCache.prevKey;g=g.animationCache.nextKey;j.pos=this.data.hierarchy[e].keys[0];j.rot=this.data.hierarchy[e].keys[0];j.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
+g instanceof THREE.Bone?g.skinMatrix:g.matrix}var k=g.animationCache.prevKey;g=g.animationCache.nextKey;k.pos=this.data.hierarchy[e].keys[0];k.rot=this.data.hierarchy[e].keys[0];k.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==undefined){if(this.hierarchy[b]instanceof THREE.Bone)this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix;else this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix;delete this.hierarchy[b].animationCache}};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],e,h,g,j,k,o,q,v,D=this.data.JIT.hierarchy,F,J;this.currentTime+=b*this.timeScale;J=this.currentTime;F=this.currentTime%=this.data.length;v=parseInt(Math.min(F*this.data.fps,this.data.length*this.data.fps),10);for(var G=0,N=this.hierarchy.length;G<N;G++){b=this.hierarchy[G];q=b.animationCache;if(this.JITCompile&&D[G][v]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=D[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
-!1}else{b.matrix=D[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var O=0;O<3;O++){e=d[O];k=q.prevKey[e];o=q.nextKey[e];if(o.time<=J){if(F<J)if(this.loop){k=this.data.hierarchy[G].keys[0];for(o=this.getNextKeyWith(e,G,1);o.time<F;){k=o;o=this.getNextKeyWith(e,G,o.index+1)}}else{this.stop();return}else{do{k=o;o=this.getNextKeyWith(e,G,o.index+1)}while(o.time<
-F)}q.prevKey[e]=k;q.nextKey[e]=o}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;h=(F-k.time)/(o.time-k.time);g=k[e];j=o[e];if(h<0||h>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+h+" on bone "+G);h=h<0?0:1}if(e==="pos"){e=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",G,k.index-1).pos;this.points[1]=g;this.points[2]=j;this.points[3]=this.getNextKeyWith("pos",G,o.index+1).pos;h=h*0.33+0.33;g=this.interpolateCatmullRom(this.points,h);e.x=g[0];e.y=g[1];e.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){h=this.interpolateCatmullRom(this.points,h*1.01);this.target.set(h[0],h[1],h[2]);this.target.subSelf(e);this.target.y=0;this.target.normalize();h=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,h,0)}}}else if(e===
-"rot")THREE.Quaternion.slerp(g,j,b.quaternion,h);else if(e==="scl"){e=b.scale;e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}}}}if(this.JITCompile&&D[0][v]===undefined){this.hierarchy[0].update(undefined,!0);for(G=0;G<this.hierarchy.length;G++)D[G][v]=this.hierarchy[G]instanceof THREE.Bone?this.hierarchy[G].skinMatrix.clone():this.hierarchy[G].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var e=[],h=[],g,j,k,o,q,v;g=(b.length-1)*d;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];o=b[e[1]];q=b[e[2]];v=b[e[3]];e=g*g;k=g*e;h[0]=this.interpolate(j[0],o[0],q[0],v[0],g,e,k);h[1]=this.interpolate(j[1],o[1],q[1],v[1],g,e,k);h[2]=this.interpolate(j[2],o[2],q[2],v[2],g,e,k);return h};
-THREE.Animation.prototype.interpolate=function(b,d,e,h,g,j,k){b=(e-b)*0.5;h=(h-d)*0.5;return(2*(d-e)+b+h)*k+(-3*(d-e)-2*b-h)*j+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,e){var h=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=e<h.length-1?e:h.length-1;else e%=h.length;for(;e<h.length;e++)if(h[e][b]!==undefined)return h[e];return this.data.hierarchy[d].keys[0]};
+THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],e,h,g,k,j,o,p,u,D=this.data.JIT.hierarchy,F,I;this.currentTime+=b*this.timeScale;I=this.currentTime;F=this.currentTime%=this.data.length;u=parseInt(Math.min(F*this.data.fps,this.data.length*this.data.fps),10);for(var G=0,L=this.hierarchy.length;G<L;G++){b=this.hierarchy[G];p=b.animationCache;if(this.JITCompile&&D[G][u]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=D[G][u];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
+!1}else{b.matrix=D[G][u];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var M=0;M<3;M++){e=d[M];j=p.prevKey[e];o=p.nextKey[e];if(o.time<=I){if(F<I)if(this.loop){j=this.data.hierarchy[G].keys[0];for(o=this.getNextKeyWith(e,G,1);o.time<F;){j=o;o=this.getNextKeyWith(e,G,o.index+1)}}else{this.stop();return}else{do{j=o;o=this.getNextKeyWith(e,G,o.index+1)}while(o.time<
+F)}p.prevKey[e]=j;p.nextKey[e]=o}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;h=(F-j.time)/(o.time-j.time);g=j[e];k=o[e];if(h<0||h>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+h+" on bone "+G);h=h<0?0:1}if(e==="pos"){e=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){e.x=g[0]+(k[0]-g[0])*h;e.y=g[1]+(k[1]-g[1])*h;e.z=g[2]+(k[2]-g[2])*h}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",G,j.index-1).pos;this.points[1]=g;this.points[2]=k;this.points[3]=this.getNextKeyWith("pos",G,o.index+1).pos;h=h*0.33+0.33;g=this.interpolateCatmullRom(this.points,h);e.x=g[0];e.y=g[1];e.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){h=this.interpolateCatmullRom(this.points,h*1.01);this.target.set(h[0],h[1],h[2]);this.target.subSelf(e);this.target.y=0;this.target.normalize();h=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,h,0)}}}else if(e===
+"rot")THREE.Quaternion.slerp(g,k,b.quaternion,h);else if(e==="scl"){e=b.scale;e.x=g[0]+(k[0]-g[0])*h;e.y=g[1]+(k[1]-g[1])*h;e.z=g[2]+(k[2]-g[2])*h}}}}if(this.JITCompile&&D[0][u]===undefined){this.hierarchy[0].update(undefined,!0);for(G=0;G<this.hierarchy.length;G++)D[G][u]=this.hierarchy[G]instanceof THREE.Bone?this.hierarchy[G].skinMatrix.clone():this.hierarchy[G].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var e=[],h=[],g,k,j,o,p,u;g=(b.length-1)*d;k=Math.floor(g);g-=k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>b.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];o=b[e[1]];p=b[e[2]];u=b[e[3]];e=g*g;j=g*e;h[0]=this.interpolate(k[0],o[0],p[0],u[0],g,e,j);h[1]=this.interpolate(k[1],o[1],p[1],u[1],g,e,j);h[2]=this.interpolate(k[2],o[2],p[2],u[2],g,e,j);return h};
+THREE.Animation.prototype.interpolate=function(b,d,e,h,g,k,j){b=(e-b)*0.5;h=(h-d)*0.5;return(2*(d-e)+b+h)*j+(-3*(d-e)-2*b-h)*k+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,e){var h=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=e<h.length-1?e:h.length-1;else e%=h.length;for(;e<h.length;e++)if(h[e][b]!==undefined)return h[e];return this.data.hierarchy[d].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,d,e){var h=this.data.hierarchy[d].keys;for(e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?e:0:e>=0?e:e+h.length;e>=0;e--)if(h[e][b]!==undefined)return h[e];return this.data.hierarchy[d].keys[h.length-1]};
 THREE.Camera=function(b,d,e,h,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=h||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
@@ -99,12 +100,12 @@ b.wireframeLinejoin!==undefined?b.wireframeLinejoin:"round";this.vertexColors=b.
 THREE.MeshDepthMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading!==undefined?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==undefined?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==undefined?b.wireframeLinewidth:1};THREE.MeshDepthMaterial.prototype=new THREE.Material;THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
 THREE.MeshNormalMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.shading=b.shading?b.shading:THREE.FlatShading;this.wireframe=b.wireframe?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth?b.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.MeshShaderMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.fragmentShader=b.fragmentShader!==undefined?b.fragmentShader:"void main() {}";this.vertexShader=b.vertexShader!==undefined?b.vertexShader:"void main() {}";this.uniforms=b.uniforms!==undefined?b.uniforms:{};this.attributes=b.attributes;this.shading=b.shading!==undefined?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==undefined?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==undefined?b.wireframeLinewidth:
-1;this.lights=b.lights!==undefined?b.lights:!1;this.vertexColors=b.vertexColors!==undefined?b.vertexColors:!1;this.skinning=b.skinning!==undefined?b.skinning:!1;this.morphTargets=b.morphTargets!==undefined?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
+1;this.fog=b.fog!==undefined?b.fog:!1;this.lights=b.lights!==undefined?b.lights:!1;this.vertexColors=b.vertexColors!==undefined?b.vertexColors:!1;this.skinning=b.skinning!==undefined?b.skinning:!1;this.morphTargets=b.morphTargets!==undefined?b.morphTargets:!1};THREE.MeshShaderMaterial.prototype=new THREE.Material;THREE.MeshShaderMaterial.prototype.constructor=THREE.MeshShaderMaterial;
 THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==undefined?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==undefined?b.map:null;this.size=b.size!==undefined?b.size:1;this.sizeAttenuation=b.sizeAttenuation!==undefined?b.sizeAttenuation:!0;this.vertexColors=b.vertexColors!==undefined?b.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ShadowVolumeDynamicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==undefined?new THREE.Color(b.color):new THREE.Color(16777215);this.map=b.map!==undefined?b.map:null;this.lightMap=b.lightMap!==undefined?b.lightMap:null;this.envMap=b.envMap!==undefined?b.envMap:null;this.combine=b.combine!==undefined?b.combine:THREE.MultiplyOperation;this.reflectivity=b.reflectivity!==undefined?b.reflectivity:1;this.refractionRatio=b.refractionRatio!==undefined?b.refractionRatio:
 0.98;this.shading=b.shading!==undefined?b.shading:THREE.SmoothShading;this.wireframe=b.wireframe!==undefined?b.wireframe:!1;this.wireframeLinewidth=b.wireframeLinewidth!==undefined?b.wireframeLinewidth:1;this.wireframeLinecap=b.wireframeLinecap!==undefined?b.wireframeLinecap:"round";this.wireframeLinejoin=b.wireframeLinejoin!==undefined?b.wireframeLinejoin:"round";this.vertexColors=b.vertexColors!==undefined?b.vertexColors:!1;this.skinning=b.skinning!==undefined?b.skinning:!1;this.morphTargets=b.morphTargets!==
 undefined?b.morphTargets:!1};THREE.ShadowVolumeDynamicMaterial.prototype=new THREE.Material;THREE.ShadowVolumeDynamicMaterial.prototype.constructor=THREE.ShadowVolumeDynamicMaterial;
-THREE.Texture=function(b,d,e,h,g,j){this.image=b;this.mapping=d!==undefined?d:new THREE.UVMapping;this.wrapS=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrapT=h!==undefined?h:THREE.ClampToEdgeWrapping;this.magFilter=g!==undefined?g:THREE.LinearFilter;this.minFilter=j!==undefined?j: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(b,d,e,h,g,k){this.image=b;this.mapping=d!==undefined?d:new THREE.UVMapping;this.wrapS=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrapT=h!==undefined?h:THREE.ClampToEdgeWrapping;this.magFilter=g!==undefined?g:THREE.LinearFilter;this.minFilter=k!==undefined?k: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;var Uniforms={clone:function(b){var d,e,h,g={};for(d in b){g[d]={};for(e in b[d]){h=b[d][e];g[d][e]=h instanceof THREE.Color||h instanceof THREE.Vector3||h instanceof THREE.Texture?h.clone():h}}return g},merge:function(b){var d,e,h,g={};for(d=0;d<b.length;d++){h=this.clone(b[d]);for(e in h)g[e]=h[e]}return g}};
 THREE.Particle=function(b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.sortParticles=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
@@ -114,12 +115,12 @@ this.morphTargetDictionary[this.geometry.morphTargets[e].name]=e}}}};THREE.Mesh.
 THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}var h,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(h=0;h<g;h++){b=this.children[h];b instanceof THREE.Bone?b.update(this.skinMatrix,d,e):b.update(this.matrixWorld,!0,e)}}else for(h=0;h<g;h++)this.children[h].update(this.skinMatrix,
 d,e)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1){b.parent!==undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);if(!(b instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
-THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,h,g,j,k,o;if(this.geometry.bones!==undefined){for(e=0;e<this.geometry.bones.length;e++){g=this.geometry.bones[e];j=g.pos;k=g.rotq;o=g.scl;h=this.addBone();h.name=g.name;h.position.set(j[0],j[1],j[2]);h.quaternion.set(k[0],k[1],k[2],k[3]);h.useQuaternion=!0;o!==undefined?h.scale.set(o[0],o[1],o[2]):h.scale.set(1,1,1)}for(e=0;e<this.bones.length;e++){g=this.geometry.bones[e];
+THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,h,g,k,j,o;if(this.geometry.bones!==undefined){for(e=0;e<this.geometry.bones.length;e++){g=this.geometry.bones[e];k=g.pos;j=g.rotq;o=g.scl;h=this.addBone();h.name=g.name;h.position.set(k[0],k[1],k[2]);h.quaternion.set(j[0],j[1],j[2],j[3]);h.useQuaternion=!0;o!==undefined?h.scale.set(o[0],o[1],o[2]):h.scale.set(1,1,1)}for(e=0;e<this.bones.length;e++){g=this.geometry.bones[e];
 h=this.bones[e];g.parent===-1?this.addChild(h):this.bones[g.parent].addChild(h)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
 THREE.SkinnedMesh.prototype.update=function(b,d,e){if(this.visible){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}var h,g=this.children.length;for(h=0;h<g;h++){b=this.children[h];b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,d,e)}e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(d=0;d<e;d++)ba[d].skinMatrix.flattenToArrayOffset(bm,
 d*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===undefined&&(b=new THREE.Bone(this));this.bones.push(b);return b};
-THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var b,d=[],e=0;e<this.bones.length;e++){b=this.bones[e];d.push(THREE.Matrix4.makeInvert(b.skinMatrix));b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var h;for(b=0;b<this.geometry.skinIndices.length;b++){e=this.geometry.vertices[b].position;var g=this.geometry.skinIndices[b].x,j=this.geometry.skinIndices[b].y;
-h=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesA.push(d[g].multiplyVector3(h));h=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(d[j].multiplyVector3(h));if(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1){e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5;this.geometry.skinWeights[b].x+=e;this.geometry.skinWeights[b].y+=e}}}};
+THREE.SkinnedMesh.prototype.pose=function(){this.update(undefined,!0);for(var b,d=[],e=0;e<this.bones.length;e++){b=this.bones[e];d.push(THREE.Matrix4.makeInvert(b.skinMatrix));b.skinMatrix.flattenToArrayOffset(this.boneMatrices,e*16)}if(this.geometry.skinVerticesA===undefined){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];var h;for(b=0;b<this.geometry.skinIndices.length;b++){e=this.geometry.vertices[b].position;var g=this.geometry.skinIndices[b].x,k=this.geometry.skinIndices[b].y;
+h=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesA.push(d[g].multiplyVector3(h));h=new THREE.Vector3(e.x,e.y,e.z);this.geometry.skinVerticesB.push(d[k].multiplyVector3(h));if(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y!==1){e=(1-(this.geometry.skinWeights[b].x+this.geometry.skinWeights[b].y))*0.5;this.geometry.skinWeights[b].x+=e;this.geometry.skinWeights[b].y+=e}}}};
 THREE.Ribbon=function(b,d){THREE.Object3D.call(this);this.geometry=b;this.materials=d instanceof Array?d:[d];this.flipSided=!1;this.doubleSided=!1};THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;
 THREE.Sound=function(b,d,e,h){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=d!==undefined?Math.abs(d):100;this.volume=Math.min(1,Math.max(0,e!==undefined?e:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=h!==undefined?h:!0;this.sources=b instanceof Array?b:[b];var g;e=this.sources.length;for(b=0;b<e;b++){d=this.sources[b];d.toLowerCase();if(d.indexOf(".mp3")!==-1)g=
 "audio/mpeg";else if(d.indexOf(".ogg")!==-1)g="audio/ogg";else d.indexOf(".wav")!==-1&&(g="audio/wav");if(this.domElement.canPlayType(g)){g=document.createElement("source");g.src=this.sources[b];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;
@@ -130,24 +131,24 @@ THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=functi
 THREE.LOD.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}if(this.LODs.length>1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var h=1;h<this.LODs.length;h++)if(b>=this.LODs[h].visibleAtDistance){this.LODs[h-1].object3D.visible=
 !1;this.LODs[h].object3D.visible=!0}else break;for(;h<this.LODs.length;h++)this.LODs[h].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.ShadowVolume=function(b,d){THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);b.addChild(this);this.calculateShadowVolumeGeometry(b.geometry)};THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;
 THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,h=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var j=g.length,k,o,q,v,D,F=["a","b","c","d"];for(q=0;q<j;q++){o=d.length;k=g[q];if(k instanceof THREE.Face4){v=4;o=new THREE.Face4(o,o+1,o+2,o+3)}else{v=3;o=new THREE.Face3(o,o+1,o+2)}o.normal.copy(k.normal);e.push(o);for(o=
-0;o<v;o++){D=b[k[F[o]]];d.push(new THREE.Vertex(D.position.clone()))}}for(j=0;j<g.length-1;j++){b=e[j];for(k=j+1;k<g.length;k++){o=e[k];o=this.facesShareEdge(d,b,o);if(o!==undefined){o=new THREE.Face4(o.indices[0],o.indices[3],o.indices[2],o.indices[1]);o.normal.set(1,0,0);h.push(o)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var h,g,j,k,o,q,v,D,F,J,G,N,O,W=0,P=["a","b","c","d"];h=d instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(N=0;N<h;N++){j=d[P[N]];o=b[j];for(O=0;O<g;O++){k=e[P[O]];q=b[k];if(Math.abs(o.position.x-q.position.x)<1.0E-4&&Math.abs(o.position.y-q.position.y)<1.0E-4&&Math.abs(o.position.z-q.position.z)<1.0E-4){W++;if(W===1){v=o;D=q;F=j;J=k;G=P[N]}if(W===2){G+=P[N];return G==="ad"||G==="ac"?{faces:[d,e],vertices:[v,D,q,o],indices:[F,
-J,k,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[v,o,q,D],indices:[F,j,k,J],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};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.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,h=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var k=g.length,j,o,p,u,D,F=["a","b","c","d"];for(p=0;p<k;p++){o=d.length;j=g[p];if(j instanceof THREE.Face4){u=4;o=new THREE.Face4(o,o+1,o+2,o+3)}else{u=3;o=new THREE.Face3(o,o+1,o+2)}o.normal.copy(j.normal);e.push(o);for(o=
+0;o<u;o++){D=b[j[F[o]]];d.push(new THREE.Vertex(D.position.clone()))}}for(k=0;k<g.length-1;k++){b=e[k];for(j=k+1;j<g.length;j++){o=e[j];o=this.facesShareEdge(d,b,o);if(o!==undefined){o=new THREE.Face4(o.indices[0],o.indices[3],o.indices[2],o.indices[1]);o.normal.set(1,0,0);h.push(o)}}}};
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var h,g,k,j,o,p,u,D,F,I,G,L,M,Y=0,O=["a","b","c","d"];h=d instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(L=0;L<h;L++){k=d[O[L]];o=b[k];for(M=0;M<g;M++){j=e[O[M]];p=b[j];if(Math.abs(o.position.x-p.position.x)<1.0E-4&&Math.abs(o.position.y-p.position.y)<1.0E-4&&Math.abs(o.position.z-p.position.z)<1.0E-4){Y++;if(Y===1){u=o;D=p;F=k;I=j;G=O[L]}if(Y===2){G+=O[L];return G==="ad"||G==="ac"?{faces:[d,e],vertices:[u,D,p,o],indices:[F,
+I,j,k],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[u,o,p,D],indices:[F,k,j,I],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};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(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,e){this.color=new THREE.Color(b);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
-THREE.Projector=function(){function b(){var c=q[o]=q[o]||new THREE.RenderableVertex;o++;return c}function d(c,S){return S.z-c.z}function e(c,S){var oa=0,ta=1,Ea=c.z+c.w,wa=S.z+S.w,aa=-c.z+c.w,ma=-S.z+S.w;if(Ea>=0&&wa>=0&&aa>=0&&ma>=0)return!0;else if(Ea<0&&wa<0||aa<0&&ma<0)return!1;else{if(Ea<0)oa=Math.max(oa,Ea/(Ea-wa));else wa<0&&(ta=Math.min(ta,Ea/(Ea-wa)));if(aa<0)oa=Math.max(oa,aa/(aa-ma));else ma<0&&(ta=Math.min(ta,aa/(aa-ma)));if(ta<oa)return!1;else{c.lerpSelf(S,oa);S.lerpSelf(c,1-ta);return!0}}}
-var h,g,j=[],k,o,q=[],v,D,F=[],J,G=[],N,O,W=[],P,ra,ca=[],sa=new THREE.Vector4,Z=new THREE.Vector4,K=new THREE.Matrix4,Ia=new THREE.Matrix4,ka=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Da=new THREE.Vector4,ea=new THREE.Vector4;this.projectVector=function(c,S){K.multiply(S.projectionMatrix,S.matrixWorldInverse);K.multiplyVector3(c);return c};this.unprojectVector=function(c,S){K.multiply(S.matrixWorld,THREE.Matrix4.makeInvert(S.projectionMatrix));
-K.multiplyVector3(c);return c};this.projectObjects=function(c,S,oa){S=[];var ta,Ea,wa;g=0;Ea=c.objects;c=0;for(ta=Ea.length;c<ta;c++){wa=Ea[c];var aa;if(!(aa=!wa.visible))if(aa=wa instanceof THREE.Mesh){a:{aa=void 0;for(var ma=wa.matrixWorld,na=-wa.geometry.boundingSphere.radius*Math.max(wa.scale.x,Math.max(wa.scale.y,wa.scale.z)),la=0;la<6;la++){aa=ka[la].x*ma.n14+ka[la].y*ma.n24+ka[la].z*ma.n34+ka[la].w;if(aa<=na){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=j[g]=j[g]||new THREE.RenderableObject;g++;
-h=aa;sa.copy(wa.position);K.multiplyVector3(sa);h.object=wa;h.z=sa.z;S.push(h)}}oa&&S.sort(d);return S};this.projectScene=function(c,S,oa){var ta=[],Ea=S.near,wa=S.far,aa,ma,na,la,Y,va,pa,Fa,Ha,$,Oa,Va,Wa,Ta,Ra,Xa,Ya;ra=O=J=D=0;S.matrixAutoUpdate&&S.updateMatrix();c.update(undefined,!1,S);K.multiply(S.projectionMatrix,S.matrixWorldInverse);ka[0].set(K.n41-K.n11,K.n42-K.n12,K.n43-K.n13,K.n44-K.n14);ka[1].set(K.n41+K.n11,K.n42+K.n12,K.n43+K.n13,K.n44+K.n14);ka[2].set(K.n41+K.n21,K.n42+K.n22,K.n43+K.n23,
-K.n44+K.n24);ka[3].set(K.n41-K.n21,K.n42-K.n22,K.n43-K.n23,K.n44-K.n24);ka[4].set(K.n41-K.n31,K.n42-K.n32,K.n43-K.n33,K.n44-K.n34);ka[5].set(K.n41+K.n31,K.n42+K.n32,K.n43+K.n33,K.n44+K.n34);for(aa=0;aa<6;aa++){Ha=ka[aa];Ha.divideScalar(Math.sqrt(Ha.x*Ha.x+Ha.y*Ha.y+Ha.z*Ha.z))}Ha=this.projectObjects(c,S,!0);c=0;for(aa=Ha.length;c<aa;c++){$=Ha[c].object;if($.visible){Oa=$.matrixWorld;Va=$.matrixRotationWorld;Wa=$.materials;Ta=$.overdraw;o=0;if($ instanceof THREE.Mesh){Ra=$.geometry;la=Ra.vertices;
-Xa=Ra.faces;Ra=Ra.faceVertexUvs;ma=0;for(na=la.length;ma<na;ma++){k=b();k.positionWorld.copy(la[ma].position);Oa.multiplyVector3(k.positionWorld);k.positionScreen.copy(k.positionWorld);K.multiplyVector4(k.positionScreen);k.positionScreen.x/=k.positionScreen.w;k.positionScreen.y/=k.positionScreen.w;k.visible=k.positionScreen.z>Ea&&k.positionScreen.z<wa}la=0;for(ma=Xa.length;la<ma;la++){na=Xa[la];if(na instanceof THREE.Face3){Y=q[na.a];va=q[na.b];pa=q[na.c];if(Y.visible&&va.visible&&pa.visible&&($.doubleSided||
-$.flipSided!=(pa.positionScreen.x-Y.positionScreen.x)*(va.positionScreen.y-Y.positionScreen.y)-(pa.positionScreen.y-Y.positionScreen.y)*(va.positionScreen.x-Y.positionScreen.x)<0)){Fa=F[D]=F[D]||new THREE.RenderableFace3;D++;v=Fa;v.v1.copy(Y);v.v2.copy(va);v.v3.copy(pa)}else continue}else if(na instanceof THREE.Face4){Y=q[na.a];va=q[na.b];pa=q[na.c];Fa=q[na.d];if(Y.visible&&va.visible&&pa.visible&&Fa.visible&&($.doubleSided||$.flipSided!=((Fa.positionScreen.x-Y.positionScreen.x)*(va.positionScreen.y-
-Y.positionScreen.y)-(Fa.positionScreen.y-Y.positionScreen.y)*(va.positionScreen.x-Y.positionScreen.x)<0||(va.positionScreen.x-pa.positionScreen.x)*(Fa.positionScreen.y-pa.positionScreen.y)-(va.positionScreen.y-pa.positionScreen.y)*(Fa.positionScreen.x-pa.positionScreen.x)<0))){Ya=G[J]=G[J]||new THREE.RenderableFace4;J++;v=Ya;v.v1.copy(Y);v.v2.copy(va);v.v3.copy(pa);v.v4.copy(Fa)}else continue}v.normalWorld.copy(na.normal);Va.multiplyVector3(v.normalWorld);v.centroidWorld.copy(na.centroid);Oa.multiplyVector3(v.centroidWorld);
-v.centroidScreen.copy(v.centroidWorld);K.multiplyVector3(v.centroidScreen);pa=na.vertexNormals;Y=0;for(va=pa.length;Y<va;Y++){Fa=v.vertexNormalsWorld[Y];Fa.copy(pa[Y]);Va.multiplyVector3(Fa)}Y=0;for(va=Ra.length;Y<va;Y++)if(Ya=Ra[Y][la]){pa=0;for(Fa=Ya.length;pa<Fa;pa++)v.uvs[Y][pa]=Ya[pa]}v.meshMaterials=Wa;v.faceMaterials=na.materials;v.overdraw=Ta;v.z=v.centroidScreen.z;ta.push(v)}}else if($ instanceof THREE.Line){Ia.multiply(K,Oa);la=$.geometry.vertices;Y=b();Y.positionScreen.copy(la[0].position);
-Ia.multiplyVector4(Y.positionScreen);ma=1;for(na=la.length;ma<na;ma++){Y=b();Y.positionScreen.copy(la[ma].position);Ia.multiplyVector4(Y.positionScreen);va=q[o-2];Da.copy(Y.positionScreen);ea.copy(va.positionScreen);if(e(Da,ea)){Da.multiplyScalar(1/Da.w);ea.multiplyScalar(1/ea.w);Oa=W[O]=W[O]||new THREE.RenderableLine;O++;N=Oa;N.v1.positionScreen.copy(Da);N.v2.positionScreen.copy(ea);N.z=Math.max(Da.z,ea.z);N.materials=$.materials;ta.push(N)}}}else if($ instanceof THREE.Particle){Z.set($.position.x,
-$.position.y,$.position.z,1);K.multiplyVector4(Z);Z.z/=Z.w;if(Z.z>0&&Z.z<1){Oa=ca[ra]=ca[ra]||new THREE.RenderableParticle;ra++;P=Oa;P.x=Z.x/Z.w;P.y=Z.y/Z.w;P.z=Z.z;P.rotation=$.rotation.z;P.scale.x=$.scale.x*Math.abs(P.x-(Z.x+S.projectionMatrix.n11)/(Z.w+S.projectionMatrix.n14));P.scale.y=$.scale.y*Math.abs(P.y-(Z.y+S.projectionMatrix.n22)/(Z.w+S.projectionMatrix.n24));P.materials=$.materials;ta.push(P)}}}}oa&&ta.sort(d);return ta}};
+THREE.Projector=function(){function b(){var U=p[o]=p[o]||new THREE.RenderableVertex;o++;return U}function d(U,V){return V.z-U.z}function e(U,V){var na=0,Fa=1,Ga=U.z+U.w,ya=V.z+V.w,aa=-U.z+U.w,pa=-V.z+V.w;if(Ga>=0&&ya>=0&&aa>=0&&pa>=0)return!0;else if(Ga<0&&ya<0||aa<0&&pa<0)return!1;else{if(Ga<0)na=Math.max(na,Ga/(Ga-ya));else ya<0&&(Fa=Math.min(Fa,Ga/(Ga-ya)));if(aa<0)na=Math.max(na,aa/(aa-pa));else pa<0&&(Fa=Math.min(Fa,aa/(aa-pa)));if(Fa<na)return!1;else{U.lerpSelf(V,na);V.lerpSelf(U,1-Fa);return!0}}}
+var h,g,k=[],j,o,p=[],u,D,F=[],I,G=[],L,M,Y=[],O,ca,ma=[],wa=new THREE.Vector4,$=new THREE.Vector4,J=new THREE.Matrix4,xa=new THREE.Matrix4,ta=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,c=new THREE.Vector4;this.projectVector=function(U,V){J.multiply(V.projectionMatrix,V.matrixWorldInverse);J.multiplyVector3(U);return U};this.unprojectVector=function(U,V){J.multiply(V.matrixWorld,THREE.Matrix4.makeInvert(V.projectionMatrix));
+J.multiplyVector3(U);return U};this.projectObjects=function(U,V,na){V=[];var Fa,Ga,ya;g=0;Ga=U.objects;U=0;for(Fa=Ga.length;U<Fa;U++){ya=Ga[U];var aa;if(!(aa=!ya.visible))if(aa=ya instanceof THREE.Mesh){a:{aa=void 0;for(var pa=ya.matrixWorld,fa=-ya.geometry.boundingSphere.radius*Math.max(ya.scale.x,Math.max(ya.scale.y,ya.scale.z)),qa=0;qa<6;qa++){aa=ta[qa].x*pa.n14+ta[qa].y*pa.n24+ta[qa].z*pa.n34+ta[qa].w;if(aa<=fa){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=k[g]=k[g]||new THREE.RenderableObject;g++;
+h=aa;wa.copy(ya.position);J.multiplyVector3(wa);h.object=ya;h.z=wa.z;V.push(h)}}na&&V.sort(d);return V};this.projectScene=function(U,V,na){var Fa=[],Ga=V.near,ya=V.far,aa,pa,fa,qa,Z,ua,oa,Ca,za,ga,Pa,Ua,Va,hb,Sa,fb,Ya;ca=M=I=D=0;V.matrixAutoUpdate&&V.updateMatrix();U.update(undefined,!1,V);J.multiply(V.projectionMatrix,V.matrixWorldInverse);ta[0].set(J.n41-J.n11,J.n42-J.n12,J.n43-J.n13,J.n44-J.n14);ta[1].set(J.n41+J.n11,J.n42+J.n12,J.n43+J.n13,J.n44+J.n14);ta[2].set(J.n41+J.n21,J.n42+J.n22,J.n43+
+J.n23,J.n44+J.n24);ta[3].set(J.n41-J.n21,J.n42-J.n22,J.n43-J.n23,J.n44-J.n24);ta[4].set(J.n41-J.n31,J.n42-J.n32,J.n43-J.n33,J.n44-J.n34);ta[5].set(J.n41+J.n31,J.n42+J.n32,J.n43+J.n33,J.n44+J.n34);for(aa=0;aa<6;aa++){za=ta[aa];za.divideScalar(Math.sqrt(za.x*za.x+za.y*za.y+za.z*za.z))}za=this.projectObjects(U,V,!0);U=0;for(aa=za.length;U<aa;U++){ga=za[U].object;if(ga.visible){Pa=ga.matrixWorld;Ua=ga.matrixRotationWorld;Va=ga.materials;hb=ga.overdraw;o=0;if(ga instanceof THREE.Mesh){Sa=ga.geometry;qa=
+Sa.vertices;fb=Sa.faces;Sa=Sa.faceVertexUvs;pa=0;for(fa=qa.length;pa<fa;pa++){j=b();j.positionWorld.copy(qa[pa].position);Pa.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);J.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Ga&&j.positionScreen.z<ya}qa=0;for(pa=fb.length;qa<pa;qa++){fa=fb[qa];if(fa instanceof THREE.Face3){Z=p[fa.a];ua=p[fa.b];oa=p[fa.c];if(Z.visible&&ua.visible&&oa.visible&&
+(ga.doubleSided||ga.flipSided!=(oa.positionScreen.x-Z.positionScreen.x)*(ua.positionScreen.y-Z.positionScreen.y)-(oa.positionScreen.y-Z.positionScreen.y)*(ua.positionScreen.x-Z.positionScreen.x)<0)){Ca=F[D]=F[D]||new THREE.RenderableFace3;D++;u=Ca;u.v1.copy(Z);u.v2.copy(ua);u.v3.copy(oa)}else continue}else if(fa instanceof THREE.Face4){Z=p[fa.a];ua=p[fa.b];oa=p[fa.c];Ca=p[fa.d];if(Z.visible&&ua.visible&&oa.visible&&Ca.visible&&(ga.doubleSided||ga.flipSided!=((Ca.positionScreen.x-Z.positionScreen.x)*
+(ua.positionScreen.y-Z.positionScreen.y)-(Ca.positionScreen.y-Z.positionScreen.y)*(ua.positionScreen.x-Z.positionScreen.x)<0||(ua.positionScreen.x-oa.positionScreen.x)*(Ca.positionScreen.y-oa.positionScreen.y)-(ua.positionScreen.y-oa.positionScreen.y)*(Ca.positionScreen.x-oa.positionScreen.x)<0))){Ya=G[I]=G[I]||new THREE.RenderableFace4;I++;u=Ya;u.v1.copy(Z);u.v2.copy(ua);u.v3.copy(oa);u.v4.copy(Ca)}else continue}u.normalWorld.copy(fa.normal);Ua.multiplyVector3(u.normalWorld);u.centroidWorld.copy(fa.centroid);
+Pa.multiplyVector3(u.centroidWorld);u.centroidScreen.copy(u.centroidWorld);J.multiplyVector3(u.centroidScreen);oa=fa.vertexNormals;Z=0;for(ua=oa.length;Z<ua;Z++){Ca=u.vertexNormalsWorld[Z];Ca.copy(oa[Z]);Ua.multiplyVector3(Ca)}Z=0;for(ua=Sa.length;Z<ua;Z++)if(Ya=Sa[Z][qa]){oa=0;for(Ca=Ya.length;oa<Ca;oa++)u.uvs[Z][oa]=Ya[oa]}u.meshMaterials=Va;u.faceMaterials=fa.materials;u.overdraw=hb;u.z=u.centroidScreen.z;Fa.push(u)}}else if(ga instanceof THREE.Line){xa.multiply(J,Pa);qa=ga.geometry.vertices;Z=
+b();Z.positionScreen.copy(qa[0].position);xa.multiplyVector4(Z.positionScreen);pa=1;for(fa=qa.length;pa<fa;pa++){Z=b();Z.positionScreen.copy(qa[pa].position);xa.multiplyVector4(Z.positionScreen);ua=p[o-2];ea.copy(Z.positionScreen);c.copy(ua.positionScreen);if(e(ea,c)){ea.multiplyScalar(1/ea.w);c.multiplyScalar(1/c.w);Pa=Y[M]=Y[M]||new THREE.RenderableLine;M++;L=Pa;L.v1.positionScreen.copy(ea);L.v2.positionScreen.copy(c);L.z=Math.max(ea.z,c.z);L.materials=ga.materials;Fa.push(L)}}}else if(ga instanceof
+THREE.Particle){$.set(ga.position.x,ga.position.y,ga.position.z,1);J.multiplyVector4($);$.z/=$.w;if($.z>0&&$.z<1){Pa=ma[ca]=ma[ca]||new THREE.RenderableParticle;ca++;O=Pa;O.x=$.x/$.w;O.y=$.y/$.w;O.z=$.z;O.rotation=ga.rotation.z;O.scale.x=ga.scale.x*Math.abs(O.x-($.x+V.projectionMatrix.n11)/($.w+V.projectionMatrix.n14));O.scale.y=ga.scale.y*Math.abs(O.y-($.y+V.projectionMatrix.n22)/($.w+V.projectionMatrix.n24));O.materials=ga.materials;Fa.push(O)}}}}na&&Fa.sort(d);return Fa}};
 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(b,d,e){e&&b.update(undefined,!1,d);e=b.sounds;var h,g=e.length;for(h=0;h<g;h++){b=e[h];this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34);this.soundPosition.subSelf(d.position);if(b.isPlaying&&b.isLoaded){b.isAddedToDOM||b.addToDOM(this.domElement);b.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
@@ -175,103 +176,108 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
 THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
 THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(f,p,n){var i,m,z,s=f.vertices,u=s.length,w=f.colors,r=w.length,t=f.__vertexArray,A=f.__colorArray,M=f.__sortArray,B=f.__dirtyVertices,Q=f.__dirtyColors;if(n.sortParticles){Oa.multiplySelf(n.matrixWorld);for(i=0;i<u;i++){m=s[i].position;Ta.copy(m);Oa.multiplyVector3(Ta);M[i]=[Ta.z,i]}M.sort(function(U,R){return R[0]-U[0]});for(i=0;i<u;i++){m=s[M[i][1]].position;z=i*3;t[z]=m.x;t[z+1]=m.y;t[z+2]=m.z}for(i=0;i<r;i++){z=i*3;color=w[M[i][1]];A[z]=color.r;A[z+1]=
-color.g;A[z+2]=color.b}}else{if(B)for(i=0;i<u;i++){m=s[i].position;z=i*3;t[z]=m.x;t[z+1]=m.y;t[z+2]=m.z}if(Q)for(i=0;i<r;i++){color=w[i];z=i*3;A[z]=color.r;A[z+1]=color.g;A[z+2]=color.b}}if(B||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,t,p)}if(Q||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,A,p)}}function e(f,p){f.uniforms=Uniforms.clone(p.uniforms);f.vertexShader=p.vertexShader;f.fragmentShader=
-p.fragmentShader}function h(f,p,n,i,m){i.program||aa.initMaterial(i,p,n,m);var z=i.program,s=z.uniforms,u=i.uniforms;if(z!=ta){c.useProgram(z);ta=z}c.uniformMatrix4fv(s.projectionMatrix,!1,Va);if(n&&(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial||i instanceof THREE.LineBasicMaterial||i instanceof THREE.ParticleBasicMaterial||i.fog)){u.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){u.fogNear.value=n.near;u.fogFar.value=
-n.far}else if(n instanceof THREE.FogExp2)u.fogDensity.value=n.density}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i.lights){var w,r,t=0,A=0,M=0,B,Q,U,R,T=Ra,Ca=T.directional.colors,H=T.directional.positions,E=T.point.colors,I=T.point.positions,X=T.point.distances,C=0,x=0;n=r=R=0;for(w=p.length;n<w;n++){r=p[n];B=r.color;Q=r.position;U=r.intensity;R=r.distance;if(r instanceof THREE.AmbientLight){t+=B.r;A+=B.g;M+=B.b}else if(r instanceof THREE.DirectionalLight){R=
-C*3;Ca[R]=B.r*U;Ca[R+1]=B.g*U;Ca[R+2]=B.b*U;H[R]=Q.x;H[R+1]=Q.y;H[R+2]=Q.z;C+=1}else if(r instanceof THREE.PointLight){r=x*3;E[r]=B.r*U;E[r+1]=B.g*U;E[r+2]=B.b*U;I[r]=Q.x;I[r+1]=Q.y;I[r+2]=Q.z;X[x]=R;x+=1}}for(n=C*3;n<Ca.length;n++)Ca[n]=0;for(n=x*3;n<E.length;n++)E[n]=0;T.point.length=x;T.directional.length=C;T.ambient[0]=t;T.ambient[1]=A;T.ambient[2]=M;n=Ra;u.enableLighting.value=n.directional.length+n.point.length;u.ambientLightColor.value=n.ambient;u.directionalLightColor.value=n.directional.colors;
-u.directionalLightDirection.value=n.directional.positions;u.pointLightColor.value=n.point.colors;u.pointLightPosition.value=n.point.positions;u.pointLightDistance.value=n.point.distances}if(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.map.texture=i.map;u.lightMap.texture=i.lightMap;u.envMap.texture=i.envMap;u.reflectivity.value=i.reflectivity;u.refractionRatio.value=
-i.refractionRatio;u.combine.value=i.combine;u.useRefract.value=i.envMap&&i.envMap.mapping instanceof THREE.CubeRefractionMapping}if(i instanceof THREE.LineBasicMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity}else if(i instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.size.value=i.size;u.scale.value=S.height/2;u.map.texture=i.map}else if(i instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(i.ambient.r,
-i.ambient.g,i.ambient.b);u.specular.value.setRGB(i.specular.r,i.specular.g,i.specular.b);u.shininess.value=i.shininess}else if(i instanceof THREE.MeshDepthMaterial){u.mNear.value=f.near;u.mFar.value=f.far;u.opacity.value=i.opacity}else if(i instanceof THREE.MeshNormalMaterial)u.opacity.value=i.opacity;for(var qa in u)if(A=z.uniforms[qa]){w=u[qa];t=w.type;n=w.value;if(t=="i")c.uniform1i(A,n);else if(t=="f")c.uniform1f(A,n);else if(t=="fv1")c.uniform1fv(A,n);else if(t=="fv")c.uniform3fv(A,n);else if(t==
-"v2")c.uniform2f(A,n.x,n.y);else if(t=="v3")c.uniform3f(A,n.x,n.y,n.z);else if(t=="v4")c.uniform4f(A,n.x,n.y,n.z,n.w);else if(t=="c")c.uniform3f(A,n.r,n.g,n.b);else if(t=="t"){c.uniform1i(A,n);if(w=w.texture)if(w.image instanceof Array&&w.image.length==6){if(w.image.length==6){if(w.needsUpdate){if(w.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(t=0;t<6;++t)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,c.RGBA,c.UNSIGNED_BYTE,w.image[t])}else{w.image.__webglTextureCube=
-c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,w.image[t]);w.__webglInit=!0}Z(c.TEXTURE_CUBE_MAP,w,w.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);w.needsUpdate=!1}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube)}}else K(w,n)}}c.uniformMatrix4fv(s.modelViewMatrix,!1,m._modelViewMatrixArray);c.uniformMatrix3fv(s.normalMatrix,!1,m._normalMatrixArray);
-(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshPhongMaterial||i.envMap)&&c.uniform3f(s.cameraPosition,f.position.x,f.position.y,f.position.z);(i instanceof THREE.MeshShaderMaterial||i.envMap||i.skinning)&&c.uniformMatrix4fv(s.objectMatrix,!1,m._objectMatrixArray);(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshShaderMaterial||i.skinning)&&c.uniformMatrix4fv(s.viewMatrix,!1,Wa);if(i instanceof THREE.ShadowVolumeDynamicMaterial){f=
-u.directionalLightDirection.value;f[0]=-p.position.x;f[1]=-p.position.y;f[2]=-p.position.z;c.uniform3fv(s.directionalLightDirection,f);c.uniformMatrix4fv(s.objectMatrix,!1,m._objectMatrixArray);c.uniformMatrix4fv(s.viewMatrix,!1,Wa)}if(i.skinning){c.uniformMatrix4fv(s.cameraInverseMatrix,!1,Wa);c.uniformMatrix4fv(s.boneGlobalMatrices,!1,m.boneMatrices)}return z}function g(f,p,n,i,m,z){if(i.opacity!=0){var s;f=h(f,p,n,i,z).attributes;if(i.morphTargets){p=i.program.attributes;z.morphTargetBase!==-1?
-c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[z.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,!1,0,0);if(z.morphTargetForcedOrder.length){n=0;for(var u=z.morphTargetForcedOrder,w=z.morphTargetInfluences;n<i.numSupportedMorphTargets&&n<u.length;){c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[u[n]]);c.vertexAttribPointer(p["morphTarget"+n],3,c.FLOAT,!1,0,0);z.__webglMorphTargetInfluences[n]=w[u[n]];n++}}else{u=[];
-var r=-1,t=0;w=z.morphTargetInfluences;var A,M=w.length;n=0;for(z.morphTargetBase!==-1&&(u[z.morphTargetBase]=!0);n<i.numSupportedMorphTargets;){for(A=0;A<M;A++)if(!u[A]&&w[A]>r){t=A;r=w[t]}c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[t]);c.vertexAttribPointer(p["morphTarget"+n],3,c.FLOAT,!1,0,0);z.__webglMorphTargetInfluences[n]=r;u[t]=1;r=-1;n++}}c.uniform1fv(i.program.uniforms.morphTargetInfluences,z.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);
-c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(m.__webglCustomAttributes)for(s in m.__webglCustomAttributes)if(f[s]>=0){p=m.__webglCustomAttributes[s];c.bindBuffer(c.ARRAY_BUFFER,p.buffer);c.vertexAttribPointer(f[s],p.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,
-m.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(m.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__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(m.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(i.skinning&&f.skinVertexA>=0&&
-f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(z instanceof
-THREE.Mesh)if(i.wireframe){c.lineWidth(i.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer);c.drawElements(c.LINES,m.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer);c.drawElements(c.TRIANGLES,m.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(z instanceof THREE.Line){z=z.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(i.linewidth);c.drawArrays(z,0,m.__webglLineCount)}else if(z instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,
-0,m.__webglParticleCount);else z instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,m.__webglVertexCount)}}function j(f,p){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(p.attributes.position);c.vertexAttribPointer(p.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(p.attributes.normal);c.vertexAttribPointer(p.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function k(f){if(ma!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ma=f.doubleSided}if(na!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);na=f.flipSided}}function o(f){if(Y!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);
-Y=f}}function q(f){$[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);$[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);$[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);$[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);$[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);$[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var p;for(f=0;f<6;f++){p=$[f];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function v(f){for(var p=f.matrixWorld,n=-f.geometry.boundingSphere.radius*
-Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),i=0;i<6;i++){f=$[i].x*p.n14+$[i].y*p.n24+$[i].z*p.n34+$[i].w;if(f<=n)return!1}return!0}function D(f,p){f.list[f.count]=p;f.count+=1}function F(f){var p,n,i=f.object,m=f.opaque,z=f.transparent;z.count=0;f=m.count=0;for(p=i.materials.length;f<p;f++){n=i.materials[f];n.transparent?D(z,n):D(m,n)}}function J(f){var p,n,i,m,z=f.object,s=f.buffer,u=f.opaque,w=f.transparent;w.count=0;f=u.count=0;for(i=z.materials.length;f<i;f++){p=z.materials[f];if(p instanceof
-THREE.MeshFaceMaterial){p=0;for(n=s.materials.length;p<n;p++)(m=s.materials[p])&&(m.transparent?D(w,m):D(u,m))}else(m=p)&&(m.transparent?D(w,m):D(u,m))}}function G(f,p){return p.z-f.z}function N(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var p,n=f.lights.length,i,m=f.lights,z=[],s,u,w,r,t,A=
-f.__webglShadowVolumes.length;for(p=0;p<n;p++){i=f.lights[p];if(i instanceof THREE.DirectionalLight){z[0]=-i.position.x;z[1]=-i.position.y;z[2]=-i.position.z;for(t=0;t<A;t++){i=f.__webglShadowVolumes[t].object;s=f.__webglShadowVolumes[t].buffer;u=i.materials[0];u.program||aa.initMaterial(u,m,undefined,i);u=u.program;w=u.uniforms;r=u.attributes;if(ta!==u){c.useProgram(u);ta=u;c.uniformMatrix4fv(w.projectionMatrix,!1,Va);c.uniformMatrix4fv(w.viewMatrix,!1,Wa);c.uniform3fv(w.directionalLightDirection,
-z)}i.matrixWorld.flattenToArray(i._objectMatrixArray);c.uniformMatrix4fv(w.objectMatrix,!1,i._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,s.__webglVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,s.__webglNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,s.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,
-s.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);la="";ta=V.program;c.useProgram(V.program);c.uniformMatrix4fv(V.projectionLocation,!1,Va);c.uniform1f(V.darknessLocation,V.darkness);c.bindBuffer(c.ARRAY_BUFFER,V.vertexBuffer);c.vertexAttribPointer(V.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(V.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);
-c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,V.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(wa)}function O(f,p){var n,i,m,z=f.__webglLensFlares.length,s,u,w;s=new THREE.Vector3;var r=Ha/Fa;u=Fa*0.5;w=Ha*0.5;var t=16/Ha,A=[t*r,t],M=[1,1,0];t=[1,1];var B,Q=L.readBackPixels,U,R,T=L.uniforms;n=L.attributes;c.useProgram(L.program);ta=L.program;la="";c.uniform1i(T.map,0);c.activeTexture(c.TEXTURE0);c.uniform1f(T.opacity,
-1);c.uniform1f(T.rotation,0);c.uniform2fv(T.scale,A);c.bindBuffer(c.ARRAY_BUFFER,L.vertexBuffer);c.vertexAttribPointer(n.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,2,c.FLOAT,!1,16,8);c.bindTexture(c.TEXTURE_2D,L.tempTexture);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);for(m=0;m<z;m++){n=f.__webglLensFlares[m].object;s.set(n.matrixWorld.n14,n.matrixWorld.n24,n.matrixWorld.n34);p.matrixWorldInverse.multiplyVector3(s);i=s.z;p.projectionMatrix.multiplyVector3(s);
-M[0]=s.x;M[1]=s.y;M[2]=s.z;t[0]=M[0]*u+u;t[1]=M[1]*w+w;c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,t[0]-8,t[1]-8,16,16);c.uniform3fv(T.screenPosition,M);c.uniform1i(T.renderPink,1);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);try{c.readPixels(t[0]-8,t[1]-8,16,16,c.RGBA,c.UNSIGNED_BYTE,L.readBackPixels)}catch(Ca){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}c.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*
-(1-Math.max(0,Math.min(-i,p.far))/p.far),10)+2;i=sampleDistance*4;B=sampleDistance*64;R=0;U=28-i+(448-B);L.readBackPixels[U+0]===255&&L.readBackPixels[U+1]===0&&L.readBackPixels[U+2]===255&&(R+=0.2);U=28+i+(448-B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=28+i+(448+B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=28-i+(448+B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=476;Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);n.positionScreen.x=M[0];n.positionScreen.y=M[1];n.positionScreen.z=
-M[2];n.customUpdateCallback?n.customUpdateCallback(R,n):n.updateLensFlares(R);c.uniform1i(T.renderPink,0);c.disable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}for(m=0;m<z;m++){n=f.__webglLensFlares[m].object;s=0;for(u=n.lensFlares.length;s<u;s++){w=n.lensFlares[s];if(w.opacity>0.0010&&w.scale>0.0010){M[0]=w.x;M[1]=w.y;M[2]=w.z;t=w.size*w.scale/Ha;A[0]=t*r;A[1]=t;c.uniform3fv(T.screenPosition,M);c.uniform1f(T.rotation,w.rotation);c.uniform2fv(T.scale,A);c.uniform1f(T.opacity,w.opacity);
-sa(w.blending);K(w.texture,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(wa)}function W(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function P(f){var p,n,i,m,z;if(f instanceof THREE.Mesh){n=f.geometry;for(p in n.geometryGroups){i=n.geometryGroups[p];z=!1;for(m in i.__webglCustomAttributes)if(i.__webglCustomAttributes[m].needsUpdate){z=
-!0;break}if(n.__dirtyVertices||n.__dirtyMorphTargets||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents||z){z=c.DYNAMIC_DRAW;var s=void 0,u=void 0,w=void 0,r=void 0;w=void 0;var t=void 0,A=void 0,M=void 0,B=void 0,Q=void 0,U=void 0,R=void 0,T=void 0,Ca=void 0,H=void 0,E=void 0,I=void 0,X=void 0;A=void 0;M=void 0;r=void 0;B=void 0;r=void 0;H=void 0;E=void 0;A=void 0;H=void 0;E=void 0;I=void 0;X=void 0;H=void 0;E=void 0;I=void 0;X=void 0;H=void 0;E=void 0;I=void 0;
-X=void 0;H=void 0;E=void 0;I=void 0;r=void 0;B=void 0;t=void 0;w=void 0;w=void 0;var C=void 0,x=void 0,qa=void 0,Za=void 0,ua=0,ya=0,ab=0,bb=0,Ja=0,Ka=0,da=0,La=0,xa=0,y=0,za=0;C=0;var Aa=i.__vertexArray,hb=i.__uvArray,ib=i.__uv2Array,Pa=i.__normalArray,fa=i.__tangentArray,Ba=i.__colorArray,ga=i.__skinVertexAArray,ha=i.__skinVertexBArray,ia=i.__skinIndexArray,ja=i.__skinWeightArray,jb=i.__morphTargetsArrays,Qa=i.__webglCustomAttributes;x=void 0;var Ma=i.__faceArray,Na=i.__lineArray,qb=i.__needsSmoothNormals;
-U=i.__vertexColorType;Q=i.__uvType;R=i.__normalType;var Ga=f.geometry,kb=Ga.__dirtyVertices,lb=Ga.__dirtyElements,gb=Ga.__dirtyUvs,mb=Ga.__dirtyNormals,nb=Ga.__dirtyTangents,ob=Ga.__dirtyColors,pb=Ga.__dirtyMorphTargets,cb=Ga.vertices,rb=i.faces,wb=Ga.faces,sb=Ga.faceVertexUvs[0],tb=Ga.faceVertexUvs[1],db=Ga.skinVerticesA,eb=Ga.skinVerticesB,fb=Ga.skinIndices,Ua=Ga.skinWeights,$a=Ga.edgeFaces,Sa=Ga.morphTargets;if(Qa)for(Za in Qa)Qa[Za].offset=0;s=0;for(u=rb.length;s<u;s++){w=rb[s];r=wb[w];sb&&(T=
-sb[w]);tb&&(Ca=tb[w]);w=r.vertexNormals;t=r.normal;A=r.vertexColors;M=r.color;B=r.vertexTangents;if(r instanceof THREE.Face3){if(kb){H=cb[r.a].position;E=cb[r.b].position;I=cb[r.c].position;Aa[ya]=H.x;Aa[ya+1]=H.y;Aa[ya+2]=H.z;Aa[ya+3]=E.x;Aa[ya+4]=E.y;Aa[ya+5]=E.z;Aa[ya+6]=I.x;Aa[ya+7]=I.y;Aa[ya+8]=I.z;ya+=9}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){C=x.offset;if(x.size===1){x.array[C+0]=x.value[r.a];x.array[C+1]=x.value[r.b];x.array[C+2]=x.value[r.c];x.offset+=3}else{H=x.value[r.a];E=x.value[r.b];
-I=x.value[r.c];if(x.size===2){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=E.x;x.array[C+3]=E.y;x.array[C+4]=I.x;x.array[C+5]=I.y;x.offset+=6}else if(x.size===3){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=E.x;x.array[C+4]=E.y;x.array[C+5]=E.z;x.array[C+6]=I.x;x.array[C+7]=I.y;x.array[C+8]=I.z;x.offset+=9}else{x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=H.w;x.array[C+4]=E.x;x.array[C+5]=E.y;x.array[C+6]=E.z;x.array[C+7]=E.w;x.array[C+8]=I.x;x.array[C+9]=I.y;
-x.array[C+10]=I.z;x.array[C+11]=I.w;x.offset+=12}}}}if(pb){C=0;for(x=Sa.length;C<x;C++){H=Sa[C].vertices[r.a].position;E=Sa[C].vertices[r.b].position;I=Sa[C].vertices[r.c].position;qa=jb[C];qa[za+0]=H.x;qa[za+1]=H.y;qa[za+2]=H.z;qa[za+3]=E.x;qa[za+4]=E.y;qa[za+5]=E.z;qa[za+6]=I.x;qa[za+7]=I.y;qa[za+8]=I.z}za+=9}if(Ua.length){H=Ua[r.a];E=Ua[r.b];I=Ua[r.c];ja[y]=H.x;ja[y+1]=H.y;ja[y+2]=H.z;ja[y+3]=H.w;ja[y+4]=E.x;ja[y+5]=E.y;ja[y+6]=E.z;ja[y+7]=E.w;ja[y+8]=I.x;ja[y+9]=I.y;ja[y+10]=I.z;ja[y+11]=I.w;
-H=fb[r.a];E=fb[r.b];I=fb[r.c];ia[y]=H.x;ia[y+1]=H.y;ia[y+2]=H.z;ia[y+3]=H.w;ia[y+4]=E.x;ia[y+5]=E.y;ia[y+6]=E.z;ia[y+7]=E.w;ia[y+8]=I.x;ia[y+9]=I.y;ia[y+10]=I.z;ia[y+11]=I.w;H=db[r.a];E=db[r.b];I=db[r.c];ga[y]=H.x;ga[y+1]=H.y;ga[y+2]=H.z;ga[y+3]=1;ga[y+4]=E.x;ga[y+5]=E.y;ga[y+6]=E.z;ga[y+7]=1;ga[y+8]=I.x;ga[y+9]=I.y;ga[y+10]=I.z;ga[y+11]=1;H=eb[r.a];E=eb[r.b];I=eb[r.c];ha[y]=H.x;ha[y+1]=H.y;ha[y+2]=H.z;ha[y+3]=1;ha[y+4]=E.x;ha[y+5]=E.y;ha[y+6]=E.z;ha[y+7]=1;ha[y+8]=I.x;ha[y+9]=I.y;ha[y+10]=I.z;ha[y+
-11]=1;y+=12}if(ob&&U){if(A.length==3&&U==THREE.VertexColors){r=A[0];H=A[1];E=A[2]}else E=H=r=M;Ba[xa]=r.r;Ba[xa+1]=r.g;Ba[xa+2]=r.b;Ba[xa+3]=H.r;Ba[xa+4]=H.g;Ba[xa+5]=H.b;Ba[xa+6]=E.r;Ba[xa+7]=E.g;Ba[xa+8]=E.b;xa+=9}if(nb&&Ga.hasTangents){A=B[0];M=B[1];r=B[2];fa[da]=A.x;fa[da+1]=A.y;fa[da+2]=A.z;fa[da+3]=A.w;fa[da+4]=M.x;fa[da+5]=M.y;fa[da+6]=M.z;fa[da+7]=M.w;fa[da+8]=r.x;fa[da+9]=r.y;fa[da+10]=r.z;fa[da+11]=r.w;da+=12}if(mb&&R)if(w.length==3&&qb)for(B=0;B<3;B++){t=w[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+
-2]=t.z;Ka+=3}else for(B=0;B<3;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(gb&&T!==undefined&&Q)for(B=0;B<3;B++){w=T[B];hb[ab]=w.u;hb[ab+1]=w.v;ab+=2}if(gb&&Ca!==undefined&&Q)for(B=0;B<3;B++){w=Ca[B];ib[bb]=w.u;ib[bb+1]=w.v;bb+=2}if(lb){Ma[Ja]=ua;Ma[Ja+1]=ua+1;Ma[Ja+2]=ua+2;Ja+=3;Na[La]=ua;Na[La+1]=ua+1;Na[La+2]=ua;Na[La+3]=ua+2;Na[La+4]=ua+1;Na[La+5]=ua+2;La+=6;ua+=3}}else if(r instanceof THREE.Face4){if(kb){H=cb[r.a].position;E=cb[r.b].position;I=cb[r.c].position;X=cb[r.d].position;Aa[ya]=
-H.x;Aa[ya+1]=H.y;Aa[ya+2]=H.z;Aa[ya+3]=E.x;Aa[ya+4]=E.y;Aa[ya+5]=E.z;Aa[ya+6]=I.x;Aa[ya+7]=I.y;Aa[ya+8]=I.z;Aa[ya+9]=X.x;Aa[ya+10]=X.y;Aa[ya+11]=X.z;ya+=12}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){C=x.offset;if(x.size===1){x.array[C+0]=x.value[r.a];x.array[C+1]=x.value[r.b];x.array[C+2]=x.value[r.c];x.array[C+2]=x.value[r.d];x.offset+=4}else{H=x.value[r.a];E=x.value[r.b];I=x.value[r.c];X=x.value[r.d];if(x.size===2){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=E.x;x.array[C+3]=E.y;x.array[C+
-4]=I.x;x.array[C+5]=I.y;x.array[C+6]=X.x;x.array[C+7]=X.y;x.offset+=8}else if(x.size===3){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=E.x;x.array[C+4]=E.y;x.array[C+5]=E.z;x.array[C+6]=I.x;x.array[C+7]=I.y;x.array[C+8]=I.z;x.array[C+9]=X.x;x.array[C+10]=X.y;x.array[C+11]=X.z;x.offset+=12}else{x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=H.w;x.array[C+4]=E.x;x.array[C+5]=E.y;x.array[C+6]=E.z;x.array[C+7]=E.w;x.array[C+8]=I.x;x.array[C+9]=I.y;x.array[C+10]=I.z;
-x.array[C+11]=I.w;x.array[C+12]=X.x;x.array[C+13]=X.y;x.array[C+14]=X.z;x.array[C+15]=X.w;x.offset+=16}}}}if(pb){C=0;for(x=Sa.length;C<x;C++){H=Sa[C].vertices[r.a].position;E=Sa[C].vertices[r.b].position;I=Sa[C].vertices[r.c].position;X=Sa[C].vertices[r.d].position;qa=jb[C];qa[za+0]=H.x;qa[za+1]=H.y;qa[za+2]=H.z;qa[za+3]=E.x;qa[za+4]=E.y;qa[za+5]=E.z;qa[za+6]=I.x;qa[za+7]=I.y;qa[za+8]=I.z;qa[za+9]=X.x;qa[za+10]=X.y;qa[za+11]=X.z}za+=12}if(Ua.length){H=Ua[r.a];E=Ua[r.b];I=Ua[r.c];X=Ua[r.d];ja[y]=H.x;
-ja[y+1]=H.y;ja[y+2]=H.z;ja[y+3]=H.w;ja[y+4]=E.x;ja[y+5]=E.y;ja[y+6]=E.z;ja[y+7]=E.w;ja[y+8]=I.x;ja[y+9]=I.y;ja[y+10]=I.z;ja[y+11]=I.w;ja[y+12]=X.x;ja[y+13]=X.y;ja[y+14]=X.z;ja[y+15]=X.w;H=fb[r.a];E=fb[r.b];I=fb[r.c];X=fb[r.d];ia[y]=H.x;ia[y+1]=H.y;ia[y+2]=H.z;ia[y+3]=H.w;ia[y+4]=E.x;ia[y+5]=E.y;ia[y+6]=E.z;ia[y+7]=E.w;ia[y+8]=I.x;ia[y+9]=I.y;ia[y+10]=I.z;ia[y+11]=I.w;ia[y+12]=X.x;ia[y+13]=X.y;ia[y+14]=X.z;ia[y+15]=X.w;H=db[r.a];E=db[r.b];I=db[r.c];X=db[r.d];ga[y]=H.x;ga[y+1]=H.y;ga[y+2]=H.z;ga[y+
-3]=1;ga[y+4]=E.x;ga[y+5]=E.y;ga[y+6]=E.z;ga[y+7]=1;ga[y+8]=I.x;ga[y+9]=I.y;ga[y+10]=I.z;ga[y+11]=1;ga[y+12]=X.x;ga[y+13]=X.y;ga[y+14]=X.z;ga[y+15]=1;H=eb[r.a];E=eb[r.b];I=eb[r.c];r=eb[r.d];ha[y]=H.x;ha[y+1]=H.y;ha[y+2]=H.z;ha[y+3]=1;ha[y+4]=E.x;ha[y+5]=E.y;ha[y+6]=E.z;ha[y+7]=1;ha[y+8]=I.x;ha[y+9]=I.y;ha[y+10]=I.z;ha[y+11]=1;ha[y+12]=r.x;ha[y+13]=r.y;ha[y+14]=r.z;ha[y+15]=1;y+=16}if(ob&&U){if(A.length==4&&U==THREE.VertexColors){r=A[0];H=A[1];E=A[2];A=A[3]}else A=E=H=r=M;Ba[xa]=r.r;Ba[xa+1]=r.g;Ba[xa+
-2]=r.b;Ba[xa+3]=H.r;Ba[xa+4]=H.g;Ba[xa+5]=H.b;Ba[xa+6]=E.r;Ba[xa+7]=E.g;Ba[xa+8]=E.b;Ba[xa+9]=A.r;Ba[xa+10]=A.g;Ba[xa+11]=A.b;xa+=12}if(nb&&Ga.hasTangents){A=B[0];M=B[1];r=B[2];B=B[3];fa[da]=A.x;fa[da+1]=A.y;fa[da+2]=A.z;fa[da+3]=A.w;fa[da+4]=M.x;fa[da+5]=M.y;fa[da+6]=M.z;fa[da+7]=M.w;fa[da+8]=r.x;fa[da+9]=r.y;fa[da+10]=r.z;fa[da+11]=r.w;fa[da+12]=B.x;fa[da+13]=B.y;fa[da+14]=B.z;fa[da+15]=B.w;da+=16}if(mb&&R)if(w.length==4&&qb)for(B=0;B<4;B++){t=w[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}else for(B=
-0;B<4;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(gb&&T!==undefined&&Q)for(B=0;B<4;B++){w=T[B];hb[ab]=w.u;hb[ab+1]=w.v;ab+=2}if(gb&&Ca!==undefined&&Q)for(B=0;B<4;B++){w=Ca[B];ib[bb]=w.u;ib[bb+1]=w.v;bb+=2}if(lb){Ma[Ja]=ua;Ma[Ja+1]=ua+1;Ma[Ja+2]=ua+3;Ma[Ja+3]=ua+1;Ma[Ja+4]=ua+2;Ma[Ja+5]=ua+3;Ja+=6;Na[La]=ua;Na[La+1]=ua+1;Na[La+2]=ua;Na[La+3]=ua+3;Na[La+4]=ua+1;Na[La+5]=ua+2;Na[La+6]=ua+2;Na[La+7]=ua+3;La+=8;ua+=4}}}if($a){s=0;for(u=$a.length;s<u;s++){Ma[Ja]=$a[s].a;Ma[Ja+1]=$a[s].b;Ma[Ja+2]=
-$a[s].c;Ma[Ja+3]=$a[s].a;Ma[Ja+4]=$a[s].c;Ma[Ja+5]=$a[s].d;Ja+=6}}if(kb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Aa,z)}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,x.buffer);c.bufferData(c.ARRAY_BUFFER,x.array,z);x.needsUpdate=!1}}if(pb){C=0;for(x=Sa.length;C<x;C++){c.bindBuffer(c.ARRAY_BUFFER,i.__webglMorphTargetsBuffers[C]);c.bufferData(c.ARRAY_BUFFER,jb[C],z)}}if(ob&&xa>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,
-Ba,z)}if(mb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Pa,z)}if(nb&&Ga.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,i.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,fa,z)}if(gb&&ab>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,hb,z)}if(gb&&bb>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,ib,z)}if(lb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Ma,z);
-c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,z)}if(y>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ga,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ha,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ia,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,ja,z)}}}n.__dirtyVertices=!1;n.__dirtyMorphTargets=
-!1;n.__dirtyElements=!1;n.__dirtyUvs=!1;n.__dirtyNormals=!1;n.__dirtyTangents=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;p=c.DYNAMIC_DRAW;U=f.vertices;i=f.colors;R=U.length;z=i.length;T=f.__vertexArray;s=f.__colorArray;Ca=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){Q=U[u].position;m=u*3;T[m]=Q.x;T[m+1]=Q.y;T[m+2]=Q.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,p)}if(Ca){for(u=0;u<
-z;u++){color=i[u];m=u*3;s[m]=color.r;s[m+1]=color.g;s[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,s,p)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Line){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;p=c.DYNAMIC_DRAW;U=f.vertices;i=f.colors;R=U.length;z=i.length;T=f.__vertexArray;s=f.__colorArray;Ca=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){Q=U[u].position;m=u*3;T[m]=Q.x;T[m+1]=Q.y;T[m+2]=Q.z}c.bindBuffer(c.ARRAY_BUFFER,
-f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,p)}if(Ca){for(u=0;u<z;u++){color=i[u];m=u*3;s[m]=color.r;s[m+1]=color.g;s[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,s,p)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){n=f.geometry;(n.__dirtyVertices||n.__dirtyColors||f.sortParticles)&&d(n,c.DYNAMIC_DRAW,f);n.__dirtyVertices=!1;n.__dirtyColors=!1}}function ra(f){function p(M){var B=[];n=0;for(i=M.length;n<i;n++)M[n]==
-undefined?B.push("undefined"):B.push(M[n].id);return B.join("_")}var n,i,m,z,s,u,w,r,t={},A=f.morphTargets!==undefined?f.morphTargets.length:0;f.geometryGroups={};m=0;for(z=f.faces.length;m<z;m++){s=f.faces[m];u=s.materials;w=p(u);t[w]==undefined&&(t[w]={hash:w,counter:0});r=t[w].hash+"_"+t[w].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:A});s=s instanceof THREE.Face3?3:4;if(f.geometryGroups[r].vertices+s>65535){t[w].counter+=1;r=t[w].hash+
-"_"+t[w].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:A})}f.geometryGroups[r].faces.push(m);f.geometryGroups[r].vertices+=s}}function ca(f,p,n){f.push({buffer:p,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function sa(f){if(f!=la){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);
-break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}la=f}}function Z(f,p,n){if((n.width&n.width-1)==0&&(n.height&n.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,ea(p.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,ea(p.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,ea(p.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,
-ea(p.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,Da(p.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Da(p.minFilter))}}function K(f,p){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);
-c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);f.__webglInit=!0}Z(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function Ia(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,ea(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,ea(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,ea(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,ea(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,ea(f.format),f.width,f.height,0,ea(f.format),ea(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 p,n;if(f){p=f.__webglFramebuffer;n=f.width;f=f.height}else{p=null;n=Fa;f=Ha}if(p!=Ea){c.bindFramebuffer(c.FRAMEBUFFER,p);c.viewport(va,pa,n,f);Ea=p}}function ka(f,p){var n;if(f=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(n=c.createShader(c.VERTEX_SHADER));
-c.shaderSource(n,p);c.compileShader(n);if(!c.getShaderParameter(n,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(n));console.error(p);return null}return n}function Da(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function ea(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 c,S=document.createElement("canvas"),oa=[],ta=null,Ea=null,wa=!0,aa=this,ma=null,na=null,la=null,Y=null,va=0,pa=0,Fa=0,Ha=0,$=[new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Oa=new THREE.Matrix4,Va=new Float32Array(16),Wa=new Float32Array(16),Ta=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Xa=!0,Ya=!0,ub=new THREE.Color(0),vb=0;if(b){if(b.stencil!=undefined)Xa=b.stencil;if(b.antialias!==undefined)Ya=b.antialias;b.clearColor!==undefined&&ub.setHex(b.clearColor);if(b.clearAlpha!==undefined)vb=b.clearAlpha}this.maxMorphTargets=
-8;this.domElement=S;this.autoClear=!0;this.sortObjects=!0;(function(f,p,n,i){try{if(!(c=S.getContext("experimental-webgl",{antialias:f,stencil:i})))throw"Error creating WebGL context.";}catch(m){console.error(m)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(p.r,p.g,p.b,n)})(Ya,ub,vb,Xa);this.context=
-c;if(Xa){var V={};V.vertices=new Float32Array(12);V.faces=new Uint16Array(6);V.darkness=0.5;V.vertices[0]=-2;V.vertices[1]=-1;V.vertices[2]=-1;V.vertices[3]=2;V.vertices[4]=-1;V.vertices[5]=-1;V.vertices[6]=2;V.vertices[7]=1;V.vertices[8]=-1;V.vertices[9]=-2;V.vertices[10]=1;V.vertices[11]=-1;V.faces[0]=0;V.faces[1]=1;V.faces[2]=2;V.faces[3]=0;V.faces[4]=2;V.faces[5]=3;V.vertexBuffer=c.createBuffer();V.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,V.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,
-V.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,V.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,V.faces,c.STATIC_DRAW);V.program=c.createProgram();c.attachShader(V.program,ka("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(V.program,ka("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(V.program);V.vertexLocation=c.getAttribLocation(V.program,"position");V.projectionLocation=c.getUniformLocation(V.program,"projectionMatrix");V.darknessLocation=
-c.getUniformLocation(V.program,"darkness")}var L={};L.vertices=new Float32Array(16);L.faces=new Uint16Array(6);L.transparency=0.5;b=0;L.vertices[b++]=-1;L.vertices[b++]=-1;L.vertices[b++]=0;L.vertices[b++]=0;L.vertices[b++]=1;L.vertices[b++]=-1;L.vertices[b++]=1;L.vertices[b++]=0;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=-1;L.vertices[b++]=1;L.vertices[b++]=0;L.vertices[b++]=1;b=0;L.faces[b++]=0;L.faces[b++]=1;L.faces[b++]=2;L.faces[b++]=0;L.faces[b++]=
-2;L.faces[b++]=3;L.vertexBuffer=c.createBuffer();L.elementBuffer=c.createBuffer();L.tempTexture=c.createTexture();L.readBackPixels=new Uint8Array(1024);c.bindBuffer(c.ARRAY_BUFFER,L.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,L.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,L.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,L.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,
-c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);L.program=c.createProgram();c.attachShader(L.program,ka("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(L.program,ka("vertex",THREE.ShaderLib.lensFlare.vertexShader));c.linkProgram(L.program);L.attributes={};L.uniforms={};L.attributes.vertex=c.getAttribLocation(L.program,
-"position");L.attributes.uv=c.getAttribLocation(L.program,"UV");L.uniforms.map=c.getUniformLocation(L.program,"map");L.uniforms.opacity=c.getUniformLocation(L.program,"opacity");L.uniforms.scale=c.getUniformLocation(L.program,"scale");L.uniforms.rotation=c.getUniformLocation(L.program,"rotation");L.uniforms.screenPosition=c.getUniformLocation(L.program,"screenPosition");L.uniforms.renderPink=c.getUniformLocation(L.program,"renderPink");this.setSize=function(f,p){S.width=f;S.height=p;this.setViewport(0,
-0,S.width,S.height)};this.setViewport=function(f,p,n,i){va=f;pa=p;Fa=n;Ha=i;c.viewport(va,pa,Fa,Ha)};this.setScissor=function(f,p,n,i){c.scissor(f,p,n,i)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){wa=f;c.depthMask(f)};this.setClearColorHex=function(f,p){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,p)};this.setClearColor=function(f,p){c.clearColor(f.r,f.g,f.b,p)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
-c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){V.darkness=f};this.initMaterial=function(f,p,n,i){var m,z,s,u;if(f instanceof THREE.MeshDepthMaterial)e(f,THREE.ShaderLib.depth);else if(f instanceof THREE.ShadowVolumeDynamicMaterial)e(f,THREE.ShaderLib.shadowVolumeDynamic);else if(f instanceof THREE.MeshNormalMaterial)e(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)e(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)e(f,
-THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)e(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)e(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&e(f,THREE.ShaderLib.particle_basic);var w,r,t,A;u=t=A=0;for(w=p.length;u<w;u++){r=p[u];r instanceof THREE.DirectionalLight&&t++;r instanceof THREE.PointLight&&A++}if(A+t<=4)p=t;else{p=Math.ceil(4*t/(A+t));A=4-p}u={directional:p,point:A};w=50;if(i!==undefined&&i instanceof THREE.SkinnedMesh)w=
-i.bones.length;a:{A=f.fragmentShader;p=f.vertexShader;n={map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,fog:n,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxDirLights:u.directional,maxPointLights:u.point,maxBones:w};u=A+"\n\n"+p+"\n\n";for(s in n)u+=s+": "+n[s]+",\n";s=0;for(w=oa.length;s<w;s++)if(oa[s].code==u){s=oa[s].program;break a}s=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
-n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+
-n.maxPointLights,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-c.attachShader(s,ka("fragment",prefix_fragment+A));c.attachShader(s,ka("vertex",prefix_vertex+p));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};oa.push({program:s,code:u})}f.program=s;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices",
-"morphTargetInfluences"];for(m in f.uniforms)s.push(m);m=f.program;n=0;for(A=s.length;n<A;n++){p=s[n];m.uniforms[p]=c.getUniformLocation(m,p)}s=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(m=0;m<this.maxMorphTargets;m++)s.push("morphTarget"+m);for(z in f.attributes)s.push(z);m=f.program;n=0;for(A=s.length;n<A;n++){p=s[n];m.attributes[p]=c.getAttribLocation(m,p)}m=f.program.attributes;c.enableVertexAttribArray(m.position);m.color>=0&&c.enableVertexAttribArray(m.color);
-m.normal>=0&&c.enableVertexAttribArray(m.normal);m.tangent>=0&&c.enableVertexAttribArray(m.tangent);if(f.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){c.enableVertexAttribArray(m.skinVertexA);c.enableVertexAttribArray(m.skinVertexB);c.enableVertexAttribArray(m.skinIndex);c.enableVertexAttribArray(m.skinWeight)}for(z in f.attributes)m[z]>=0&&c.enableVertexAttribArray(m[z]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(m.morphTarget0>=0){c.enableVertexAttribArray(m.morphTarget0);
-f.numSupportedMorphTargets++}if(m.morphTarget1>=0){c.enableVertexAttribArray(m.morphTarget1);f.numSupportedMorphTargets++}if(m.morphTarget2>=0){c.enableVertexAttribArray(m.morphTarget2);f.numSupportedMorphTargets++}if(m.morphTarget3>=0){c.enableVertexAttribArray(m.morphTarget3);f.numSupportedMorphTargets++}if(m.morphTarget4>=0){c.enableVertexAttribArray(m.morphTarget4);f.numSupportedMorphTargets++}if(m.morphTarget5>=0){c.enableVertexAttribArray(m.morphTarget5);f.numSupportedMorphTargets++}if(m.morphTarget6>=
-0){c.enableVertexAttribArray(m.morphTarget6);f.numSupportedMorphTargets++}if(m.morphTarget7>=0){c.enableVertexAttribArray(m.morphTarget7);f.numSupportedMorphTargets++}i.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);m=0;for(f=this.maxMorphTargets;m<f;m++)i.__webglMorphTargetInfluences[m]=0}};this.render=function(f,p,n,i){var m,z,s,u,w,r,t,A,M=f.lights,B=f.fog;p.matrixAutoUpdate&&p.updateMatrix();f.update(undefined,!1,p);p.matrixWorldInverse.flattenToArray(Wa);p.projectionMatrix.flattenToArray(Va);
-Oa.multiply(p.projectionMatrix,p.matrixWorldInverse);q(Oa);this.initWebGLObjects(f);Ia(n);(this.autoClear||i)&&this.clear();w=f.__webglObjects.length;for(i=0;i<w;i++){m=f.__webglObjects[i];t=m.object;if(t.visible)if(!(t instanceof THREE.Mesh)||v(t)){t.matrixWorld.flattenToArray(t._objectMatrixArray);W(t,p);J(m);m.render=!0;if(this.sortObjects){Ta.copy(t.position);Oa.multiplyVector3(Ta);m.z=Ta.z}}else m.render=!1;else m.render=!1}this.sortObjects&&f.__webglObjects.sort(G);r=f.__webglObjectsImmediate.length;
-for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){t.matrixAutoUpdate&&t.matrixWorld.flattenToArray(t._objectMatrixArray);W(t,p);F(m)}}sa(THREE.NormalBlending);for(i=0;i<w;i++){m=f.__webglObjects[i];if(m.render){t=m.object;A=m.buffer;s=m.opaque;k(t);for(m=0;m<s.count;m++){u=s.list[m];o(u.depthTest);g(p,M,B,u,A,t)}}}for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){s=m.opaque;k(t);for(m=0;m<s.count;m++){u=s.list[m];o(u.depthTest);z=h(p,M,B,u,t);t.render(function(Q){j(Q,
-z)})}}}for(i=0;i<w;i++){m=f.__webglObjects[i];if(m.render){t=m.object;A=m.buffer;s=m.transparent;k(t);for(m=0;m<s.count;m++){u=s.list[m];sa(u.blending);o(u.depthTest);g(p,M,B,u,A,t)}}}for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){s=m.transparent;k(t);for(m=0;m<s.count;m++){u=s.list[m];sa(u.blending);o(u.depthTest);z=h(p,M,B,u,t);t.render(function(Q){j(Q,z)})}}}Xa&&f.__webglShadowVolumes.length&&f.lights.length&&N(f);f.__webglLensFlares.length&&O(f,p);if(n&&n.minFilter!==
-THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,n.__webglTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[]}for(;f.__objectsAdded.length;){var p=f.__objectsAdded[0],n=f,i=void 0,m=void 0,z=void 0;if(p._modelViewMatrix==undefined){p._modelViewMatrix=new THREE.Matrix4;p._normalMatrixArray=new Float32Array(9);
-p._modelViewMatrixArray=new Float32Array(16);p._objectMatrixArray=new Float32Array(16);p.matrixWorld.flattenToArray(p._objectMatrixArray)}if(p instanceof THREE.Mesh){m=p.geometry;m.geometryGroups==undefined&&ra(m);for(i in m.geometryGroups){z=m.geometryGroups[i];if(!z.__webglVertexBuffer){var s=z;s.__webglVertexBuffer=c.createBuffer();s.__webglNormalBuffer=c.createBuffer();s.__webglTangentBuffer=c.createBuffer();s.__webglColorBuffer=c.createBuffer();s.__webglUVBuffer=c.createBuffer();s.__webglUV2Buffer=
-c.createBuffer();s.__webglSkinVertexABuffer=c.createBuffer();s.__webglSkinVertexBBuffer=c.createBuffer();s.__webglSkinIndicesBuffer=c.createBuffer();s.__webglSkinWeightsBuffer=c.createBuffer();s.__webglFaceBuffer=c.createBuffer();s.__webglLineBuffer=c.createBuffer();if(s.numMorphTargets){var u=void 0,w=void 0;s.__webglMorphTargetsBuffers=[];u=0;for(w=s.numMorphTargets;u<w;u++)s.__webglMorphTargetsBuffers.push(c.createBuffer())}s=z;u=p;var r=void 0,t=void 0,A=void 0;A=void 0;var M=void 0,B=void 0,
-Q=void 0,U=Q=w=0;t=void 0;A=void 0;var R=void 0;r=void 0;t=void 0;M=u.geometry;R=M.faces;B=s.faces;r=0;for(t=B.length;r<t;r++){A=B[r];A=R[A];if(A instanceof THREE.Face3){w+=3;Q+=1;U+=3}else if(A instanceof THREE.Face4){w+=4;Q+=2;U+=4}}r=s;t=u;R=void 0;B=void 0;var T=void 0,Ca=void 0;T=void 0;A=[];R=0;for(B=t.materials.length;R<B;R++){T=t.materials[R];if(T instanceof THREE.MeshFaceMaterial){T=0;for(l=r.materials.length;T<l;T++)(Ca=r.materials[T])&&A.push(Ca)}else(Ca=T)&&A.push(Ca)}r=A;a:{t=void 0;
-R=void 0;B=r.length;for(t=0;t<B;t++){R=r[t];if(R.map||R.lightMap||R instanceof THREE.MeshShaderMaterial){t=!0;break a}}t=!1}a:{R=void 0;B=void 0;A=r.length;for(R=0;R<A;R++){B=r[R];if(!(B instanceof THREE.MeshBasicMaterial&&!B.envMap||B instanceof THREE.MeshDepthMaterial)){R=B&&B.shading!=undefined&&B.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}R=!1}a:{B=void 0;A=void 0;T=r.length;for(B=0;B<T;B++){A=r[B];if(A.vertexColors){A=A.vertexColors;break a}}A=!1}s.__vertexArray=
-new Float32Array(w*3);if(R)s.__normalArray=new Float32Array(w*3);if(M.hasTangents)s.__tangentArray=new Float32Array(w*4);if(A)s.__colorArray=new Float32Array(w*3);if(t){if(M.faceUvs.length>0||M.faceVertexUvs.length>0)s.__uvArray=new Float32Array(w*2);if(M.faceUvs.length>1||M.faceVertexUvs.length>1)s.__uv2Array=new Float32Array(w*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length){s.__skinVertexAArray=new Float32Array(w*4);s.__skinVertexBArray=new Float32Array(w*4);s.__skinIndexArray=
-new Float32Array(w*4);s.__skinWeightArray=new Float32Array(w*4)}s.__faceArray=new Uint16Array(Q*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0));s.__lineArray=new Uint16Array(U*2);if(s.numMorphTargets){s.__morphTargetsArrays=[];M=0;for(B=s.numMorphTargets;M<B;M++)s.__morphTargetsArrays.push(new Float32Array(w*3))}s.__needsSmoothNormals=R==THREE.SmoothShading;s.__uvType=t;s.__vertexColorType=A;s.__normalType=R;s.__webglFaceCount=Q*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0);s.__webglLineCount=
-U*2;M=0;for(B=r.length;M<B;M++)if(r[M].attributes){s.__webglCustomAttributes={};for(a in r[M].attributes){t=r[M].attributes[a];Q=1;if(t.type==="v2")Q=2;else if(t.type==="v3")Q=3;else if(t.type==="v4")Q=4;else t.type==="c"&&(Q=3);t.size=Q;t.needsUpdate=!0;t.array=new Float32Array(w*Q);t.buffer=c.createBuffer();s.__webglCustomAttributes[a]=t}}m.__dirtyVertices=!0;m.__dirtyMorphTargets=!0;m.__dirtyElements=!0;m.__dirtyUvs=!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}p instanceof THREE.ShadowVolume?
-ca(n.__webglShadowVolumes,z,p):ca(n.__webglObjects,z,p)}}else if(p instanceof THREE.LensFlare)ca(n.__webglLensFlares,undefined,p);else if(p instanceof THREE.Ribbon){m=p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__webglVertexCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else if(p instanceof THREE.Line){m=
-p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__webglLineCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else if(p instanceof THREE.ParticleSystem){m=p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=
-new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__sortArray=[];i.__webglParticleCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else THREE.MarchingCubes!==undefined&&p instanceof THREE.MarchingCubes&&n.__webglObjectsImmediate.push({object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}for(;f.__objectsRemoved.length;){p=f.__objectsRemoved[0];n=f;m=void 0;i=void 0;for(m=n.__webglObjects.length-1;m>=0;m--){i=n.__webglObjects[m].object;
-p==i&&n.__webglObjects.splice(m,1)}f.__objectsRemoved.splice(0,1)}p=0;for(n=f.__webglObjects.length;p<n;p++)P(f.__webglObjects[p].object,f);p=0;for(n=f.__webglShadowVolumes.length;p<n;p++)P(f.__webglShadowVolumes[p].object,f);p=0;for(n=f.__webglLensFlares.length;p<n;p++)P(f.__webglLensFlares[p].object,f)};this.setFaceCulling=function(f,p){if(f){!p||p=="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)};
+THREE.WebGLRenderer=function(b){function d(f,s,n){var m,r,A,v=f.vertices,x=v.length,z=f.colors,t=z.length,w=f.__vertexArray,y=f.__colorArray,H=f.__sortArray,C=f.__dirtyVertices,N=f.__dirtyColors;if(n.sortParticles){ga.multiplySelf(n.matrixWorld);for(m=0;m<x;m++){r=v[m].position;Va.copy(r);ga.multiplyVector3(Va);H[m]=[Va.z,m]}H.sort(function(W,P){return P[0]-W[0]});for(m=0;m<x;m++){r=v[H[m][1]].position;A=m*3;w[A]=r.x;w[A+1]=r.y;w[A+2]=r.z}for(m=0;m<t;m++){A=m*3;color=z[H[m][1]];y[A]=color.r;y[A+1]=
+color.g;y[A+2]=color.b}}else{if(C)for(m=0;m<x;m++){r=v[m].position;A=m*3;w[A]=r.x;w[A+1]=r.y;w[A+2]=r.z}if(N)for(m=0;m<t;m++){color=z[m];A=m*3;y[A]=color.r;y[A+1]=color.g;y[A+2]=color.b}}if(C||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,w,s)}if(N||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,y,s)}}function e(f,s,n,m,r){m.program||ya.initMaterial(m,s,n,r);var A=m.program,v=A.uniforms,x=m.uniforms;
+if(A!=na){c.useProgram(A);na=A}c.uniformMatrix4fv(v.projectionMatrix,!1,Pa);if(n&&(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial||m instanceof THREE.LineBasicMaterial||m instanceof THREE.ParticleBasicMaterial||m.fog)){x.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){x.fogNear.value=n.near;x.fogFar.value=n.far}else if(n instanceof THREE.FogExp2)x.fogDensity.value=n.density}if(m instanceof THREE.MeshPhongMaterial||m instanceof
+THREE.MeshLambertMaterial||m.lights){var z,t,w=0,y=0,H=0,C,N,W,P,T=hb,Ha=T.directional.colors,R=T.directional.positions,Q=T.point.colors,S=T.point.positions,ra=T.point.distances,q=0,E=0;n=t=P=0;for(z=s.length;n<z;n++){t=s[n];C=t.color;N=t.position;W=t.intensity;P=t.distance;if(t instanceof THREE.AmbientLight){w+=C.r;y+=C.g;H+=C.b}else if(t instanceof THREE.DirectionalLight){P=q*3;Ha[P]=C.r*W;Ha[P+1]=C.g*W;Ha[P+2]=C.b*W;R[P]=N.x;R[P+1]=N.y;R[P+2]=N.z;q+=1}else if(t instanceof THREE.PointLight){t=E*
+3;Q[t]=C.r*W;Q[t+1]=C.g*W;Q[t+2]=C.b*W;S[t]=N.x;S[t+1]=N.y;S[t+2]=N.z;ra[E]=P;E+=1}}for(n=q*3;n<Ha.length;n++)Ha[n]=0;for(n=E*3;n<Q.length;n++)Q[n]=0;T.point.length=E;T.directional.length=q;T.ambient[0]=w;T.ambient[1]=y;T.ambient[2]=H;n=hb;x.enableLighting.value=n.directional.length+n.point.length;x.ambientLightColor.value=n.ambient;x.directionalLightColor.value=n.directional.colors;x.directionalLightDirection.value=n.directional.positions;x.pointLightColor.value=n.point.colors;x.pointLightPosition.value=
+n.point.positions;x.pointLightDistance.value=n.point.distances}if(m instanceof THREE.MeshBasicMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshPhongMaterial){x.diffuse.value.setRGB(m.color.r,m.color.g,m.color.b);x.opacity.value=m.opacity;x.map.texture=m.map;x.lightMap.texture=m.lightMap;x.envMap.texture=m.envMap;x.reflectivity.value=m.reflectivity;x.refractionRatio.value=m.refractionRatio;x.combine.value=m.combine;x.useRefract.value=m.envMap&&m.envMap.mapping instanceof THREE.CubeRefractionMapping}if(m instanceof
+THREE.LineBasicMaterial){x.diffuse.value.setRGB(m.color.r,m.color.g,m.color.b);x.opacity.value=m.opacity}else if(m instanceof THREE.ParticleBasicMaterial){x.psColor.value.setRGB(m.color.r,m.color.g,m.color.b);x.opacity.value=m.opacity;x.size.value=m.size;x.scale.value=U.height/2;x.map.texture=m.map}else if(m instanceof THREE.MeshPhongMaterial){x.ambient.value.setRGB(m.ambient.r,m.ambient.g,m.ambient.b);x.specular.value.setRGB(m.specular.r,m.specular.g,m.specular.b);x.shininess.value=m.shininess}else if(m instanceof
+THREE.MeshDepthMaterial){x.mNear.value=f.near;x.mFar.value=f.far;x.opacity.value=m.opacity}else if(m instanceof THREE.MeshNormalMaterial)x.opacity.value=m.opacity;for(var i in x)if(y=A.uniforms[i]){z=x[i];w=z.type;n=z.value;if(w=="i")c.uniform1i(y,n);else if(w=="f")c.uniform1f(y,n);else if(w=="fv1")c.uniform1fv(y,n);else if(w=="fv")c.uniform3fv(y,n);else if(w=="v2")c.uniform2f(y,n.x,n.y);else if(w=="v3")c.uniform3f(y,n.x,n.y,n.z);else if(w=="v4")c.uniform4f(y,n.x,n.y,n.z,n.w);else if(w=="c")c.uniform3f(y,
+n.r,n.g,n.b);else if(w=="t"){c.uniform1i(y,n);if(z=z.texture)if(z.image instanceof Array&&z.image.length==6){if(z.image.length==6){if(z.needsUpdate){if(z.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,z.image.__webglTextureCube);for(w=0;w<6;++w)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+w,0,0,0,c.RGBA,c.UNSIGNED_BYTE,z.image[w])}else{z.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,z.image.__webglTextureCube);for(w=0;w<6;++w)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+
+w,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,z.image[w]);z.__webglInit=!0}wa(c.TEXTURE_CUBE_MAP,z,z.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);z.needsUpdate=!1}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_CUBE_MAP,z.image.__webglTextureCube)}}else $(z,n)}}c.uniformMatrix4fv(v.modelViewMatrix,!1,r._modelViewMatrixArray);c.uniformMatrix3fv(v.normalMatrix,!1,r._normalMatrixArray);(m instanceof THREE.MeshShaderMaterial||m instanceof THREE.MeshPhongMaterial||m.envMap)&&c.uniform3f(v.cameraPosition,
+f.position.x,f.position.y,f.position.z);(m instanceof THREE.MeshShaderMaterial||m.envMap||m.skinning)&&c.uniformMatrix4fv(v.objectMatrix,!1,r._objectMatrixArray);(m instanceof THREE.MeshPhongMaterial||m instanceof THREE.MeshLambertMaterial||m instanceof THREE.MeshShaderMaterial||m.skinning)&&c.uniformMatrix4fv(v.viewMatrix,!1,Ua);if(m instanceof THREE.ShadowVolumeDynamicMaterial){f=x.directionalLightDirection.value;f[0]=-s.position.x;f[1]=-s.position.y;f[2]=-s.position.z;c.uniform3fv(v.directionalLightDirection,
+f);c.uniformMatrix4fv(v.objectMatrix,!1,r._objectMatrixArray);c.uniformMatrix4fv(v.viewMatrix,!1,Ua)}if(m.skinning){c.uniformMatrix4fv(v.cameraInverseMatrix,!1,Ua);c.uniformMatrix4fv(v.boneGlobalMatrices,!1,r.boneMatrices)}return A}function h(f,s,n,m,r,A){if(m.opacity!=0){var v;f=e(f,s,n,m,A).attributes;if(m.morphTargets){s=m.program.attributes;A.morphTargetBase!==-1?c.bindBuffer(c.ARRAY_BUFFER,r.__webglMorphTargetsBuffers[A.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,r.__webglVertexBuffer);c.vertexAttribPointer(s.position,
+3,c.FLOAT,!1,0,0);if(A.morphTargetForcedOrder.length){n=0;for(var x=A.morphTargetForcedOrder,z=A.morphTargetInfluences;n<m.numSupportedMorphTargets&&n<x.length;){c.bindBuffer(c.ARRAY_BUFFER,r.__webglMorphTargetsBuffers[x[n]]);c.vertexAttribPointer(s["morphTarget"+n],3,c.FLOAT,!1,0,0);A.__webglMorphTargetInfluences[n]=z[x[n]];n++}}else{x=[];var t=-1,w=0;z=A.morphTargetInfluences;var y,H=z.length;n=0;for(A.morphTargetBase!==-1&&(x[A.morphTargetBase]=!0);n<m.numSupportedMorphTargets;){for(y=0;y<H;y++)if(!x[y]&&
+z[y]>t){w=y;t=z[w]}c.bindBuffer(c.ARRAY_BUFFER,r.__webglMorphTargetsBuffers[w]);c.vertexAttribPointer(s["morphTarget"+n],3,c.FLOAT,!1,0,0);A.__webglMorphTargetInfluences[n]=t;x[w]=1;t=-1;n++}}c.uniform1fv(m.program.uniforms.morphTargetInfluences,A.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,r.__webglVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(r.__webglCustomAttributes)for(v in r.__webglCustomAttributes)if(f[v]>=0){s=r.__webglCustomAttributes[v];c.bindBuffer(c.ARRAY_BUFFER,
+s.buffer);c.vertexAttribPointer(f[v],s.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webglNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(r.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,r.__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(r.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,r.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(m.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,
+r.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,r.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,r.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(A instanceof THREE.Mesh)if(m.wireframe){c.lineWidth(m.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webglLineBuffer);c.drawElements(c.LINES,r.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+r.__webglFaceBuffer);c.drawElements(c.TRIANGLES,r.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(A instanceof THREE.Line){A=A.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(m.linewidth);c.drawArrays(A,0,r.__webglLineCount)}else if(A instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,r.__webglParticleCount);else A instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,r.__webglVertexCount)}}function g(f,s){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(s.attributes.position);c.vertexAttribPointer(s.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(s.attributes.normal);c.vertexAttribPointer(s.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(pa!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);pa=f.flipSided}}function j(f){if(qa!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);qa=f}}function o(f){za[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);za[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);za[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);za[3].set(f.n41-
+f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);za[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);za[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var s;for(f=0;f<6;f++){s=za[f];s.divideScalar(Math.sqrt(s.x*s.x+s.y*s.y+s.z*s.z))}}function p(f){for(var s=f.matrixWorld,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),m=0;m<6;m++){f=za[m].x*s.n14+za[m].y*s.n24+za[m].z*s.n34+za[m].w;if(f<=n)return!1}return!0}function u(f,s){f.list[f.count]=s;f.count+=
+1}function D(f){var s,n,m=f.object,r=f.opaque,A=f.transparent;A.count=0;f=r.count=0;for(s=m.materials.length;f<s;f++){n=m.materials[f];n.transparent?u(A,n):u(r,n)}}function F(f){var s,n,m,r,A=f.object,v=f.buffer,x=f.opaque,z=f.transparent;z.count=0;f=x.count=0;for(m=A.materials.length;f<m;f++){s=A.materials[f];if(s instanceof THREE.MeshFaceMaterial){s=0;for(n=v.materials.length;s<n;s++)(r=v.materials[s])&&(r.transparent?u(z,r):u(x,r))}else(r=s)&&(r.transparent?u(z,r):u(x,r))}}function I(f,s){return s.z-
+f.z}function G(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var s,n=f.lights.length,m,r=f.lights,A=[],v,x,z,t,w,y=f.__webglShadowVolumes.length;for(s=0;s<n;s++){m=f.lights[s];if(m instanceof THREE.DirectionalLight){A[0]=-m.position.x;A[1]=-m.position.y;A[2]=-m.position.z;
+for(w=0;w<y;w++){m=f.__webglShadowVolumes[w].object;v=f.__webglShadowVolumes[w].buffer;x=m.materials[0];x.program||ya.initMaterial(x,r,undefined,m);x=x.program;z=x.uniforms;t=x.attributes;if(na!==x){c.useProgram(x);na=x;c.uniformMatrix4fv(z.projectionMatrix,!1,Pa);c.uniformMatrix4fv(z.viewMatrix,!1,Ua);c.uniform3fv(z.directionalLightDirection,A)}m.matrixWorld.flattenToArray(m._objectMatrixArray);c.uniformMatrix4fv(z.objectMatrix,!1,m._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,v.__webglVertexBuffer);
+c.vertexAttribPointer(t.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,v.__webglNormalBuffer);c.vertexAttribPointer(t.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,v.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,v.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);
+c.disable(c.DEPTH_TEST);fa="";na=X.program;c.useProgram(X.program);c.uniformMatrix4fv(X.projectionLocation,!1,Pa);c.uniform1f(X.darknessLocation,X.darkness);c.bindBuffer(c.ARRAY_BUFFER,X.vertexBuffer);c.vertexAttribPointer(X.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(X.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,X.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);
+c.depthMask(Ga)}function L(f,s){var n,m,r,A=f.__webglLensFlares.length,v,x,z;v=new THREE.Vector3;var t=Ca/oa;x=oa*0.5;z=Ca*0.5;var w=16/Ca,y=[w*t,w],H=[1,1,0];w=[1,1];var C,N=K.readBackPixels,W,P,T=K.uniforms;n=K.attributes;c.useProgram(K.program);na=K.program;fa="";c.uniform1i(T.map,0);c.activeTexture(c.TEXTURE0);c.uniform1f(T.opacity,1);c.uniform1f(T.rotation,0);c.uniform2fv(T.scale,y);c.bindBuffer(c.ARRAY_BUFFER,K.vertexBuffer);c.vertexAttribPointer(n.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,
+2,c.FLOAT,!1,16,8);c.bindTexture(c.TEXTURE_2D,K.tempTexture);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);for(r=0;r<A;r++){n=f.__webglLensFlares[r].object;v.set(n.matrixWorld.n14,n.matrixWorld.n24,n.matrixWorld.n34);s.matrixWorldInverse.multiplyVector3(v);m=v.z;s.projectionMatrix.multiplyVector3(v);H[0]=v.x;H[1]=v.y;H[2]=v.z;w[0]=H[0]*x+x;w[1]=H[1]*z+z;c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,w[0]-8,w[1]-8,16,16);c.uniform3fv(T.screenPosition,H);c.uniform1i(T.renderPink,
+1);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);try{c.readPixels(w[0]-8,w[1]-8,16,16,c.RGBA,c.UNSIGNED_BYTE,K.readBackPixels)}catch(Ha){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}c.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-m,s.far))/s.far),10)+2;m=sampleDistance*4;C=sampleDistance*64;P=0;W=28-m+(448-C);K.readBackPixels[W+0]===255&&K.readBackPixels[W+1]===0&&K.readBackPixels[W+
+2]===255&&(P+=0.2);W=28+m+(448-C);N[W+0]===255&&N[W+1]===0&&N[W+2]===255&&(P+=0.2);W=28+m+(448+C);N[W+0]===255&&N[W+1]===0&&N[W+2]===255&&(P+=0.2);W=28-m+(448+C);N[W+0]===255&&N[W+1]===0&&N[W+2]===255&&(P+=0.2);W=476;N[W+0]===255&&N[W+1]===0&&N[W+2]===255&&(P+=0.2);n.positionScreen.x=H[0];n.positionScreen.y=H[1];n.positionScreen.z=H[2];n.customUpdateCallback?n.customUpdateCallback(P,n):n.updateLensFlares(P);c.uniform1i(T.renderPink,0);c.disable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,
+0)}for(r=0;r<A;r++){n=f.__webglLensFlares[r].object;v=0;for(x=n.lensFlares.length;v<x;v++){z=n.lensFlares[v];if(z.opacity>0.0010&&z.scale>0.0010){H[0]=z.x;H[1]=z.y;H[2]=z.z;w=z.size*z.scale/Ca;y[0]=w*t;y[1]=w;c.uniform3fv(T.screenPosition,H);c.uniform1f(T.rotation,z.rotation);c.uniform2fv(T.scale,y);c.uniform1f(T.opacity,z.opacity);ma(z.blending);$(z.texture,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Ga)}function M(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,
+f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function Y(f){var s,n,m,r,A;if(f instanceof THREE.Mesh){n=f.geometry;for(s in n.geometryGroups){m=n.geometryGroups[s];A=!1;for(r in m.__webglCustomAttributes)if(m.__webglCustomAttributes[r].needsUpdate){A=!0;break}if(n.__dirtyVertices||n.__dirtyMorphTargets||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents||A){A=c.DYNAMIC_DRAW;var v=void 0,
+x=void 0,z=void 0,t=void 0;z=void 0;var w=void 0,y=void 0,H=void 0,C=void 0,N=void 0,W=void 0,P=void 0,T=void 0,Ha=void 0,R=void 0,Q=void 0,S=void 0,ra=void 0;y=void 0;H=void 0;t=void 0;C=void 0;t=void 0;var q=void 0,E=void 0;y=void 0;q=void 0;E=void 0;var i=void 0,Ka=void 0;q=void 0;E=void 0;i=void 0;Ka=void 0;q=void 0;E=void 0;i=void 0;Ka=void 0;q=void 0;E=void 0;i=void 0;t=void 0;C=void 0;w=void 0;z=void 0;z=void 0;q=void 0;E=void 0;i=void 0;var Wa=void 0,sa=0,Aa=0,$a=0,ab=0,Ja=0,La=0,da=0,Ma=
+0,va=0,B=0,Ba=0;E=q=0;var Da=m.__vertexArray,ib=m.__uvArray,jb=m.__uv2Array,Qa=m.__normalArray,ha=m.__tangentArray,Ea=m.__colorArray,ia=m.__skinVertexAArray,ja=m.__skinVertexBArray,ka=m.__skinIndexArray,la=m.__skinWeightArray,kb=m.__morphTargetsArrays,Ra=m.__webglCustomAttributes;i=void 0;var Na=m.__faceArray,Oa=m.__lineArray,rb=m.__needsSmoothNormals;W=m.__vertexColorType;N=m.__uvType;P=m.__normalType;var Ia=f.geometry,lb=Ia.__dirtyVertices,mb=Ia.__dirtyElements,gb=Ia.__dirtyUvs,nb=Ia.__dirtyNormals,
+ob=Ia.__dirtyTangents,pb=Ia.__dirtyColors,qb=Ia.__dirtyMorphTargets,bb=Ia.vertices,sb=m.faces,wb=Ia.faces,tb=Ia.faceVertexUvs[0],ub=Ia.faceVertexUvs[1],cb=Ia.skinVerticesA,db=Ia.skinVerticesB,eb=Ia.skinIndices,Xa=Ia.skinWeights,Za=Ia.edgeFaces,Ta=Ia.morphTargets;if(Ra)for(Wa in Ra){Ra[Wa].offset=0;Ra[Wa].offsetSrc=0}v=0;for(x=sb.length;v<x;v++){z=sb[v];t=wb[z];tb&&(T=tb[z]);ub&&(Ha=ub[z]);z=t.vertexNormals;w=t.normal;y=t.vertexColors;H=t.color;C=t.vertexTangents;if(t instanceof THREE.Face3){if(lb){R=
+bb[t.a].position;Q=bb[t.b].position;S=bb[t.c].position;Da[Aa]=R.x;Da[Aa+1]=R.y;Da[Aa+2]=R.z;Da[Aa+3]=Q.x;Da[Aa+4]=Q.y;Da[Aa+5]=Q.z;Da[Aa+6]=S.x;Da[Aa+7]=S.y;Da[Aa+8]=S.z;Aa+=9}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){q=i.offset;E=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[q+0]=i.value[t.a];i.array[q+1]=i.value[t.b];i.array[q+2]=i.value[t.c]}else if(i.boundTo==="faces"){i.array[q+0]=i.value[E];i.array[q+1]=i.value[E];i.array[q+2]=i.value[E];i.offsetSrc++}else if(i.boundTo===
+"faceVertices"){i.array[q+0]=i.value[E+0];i.array[q+1]=i.value[E+1];i.array[q+2]=i.value[E+2];i.offsetSrc+=3}i.offset+=3}else{if(i.boundTo===undefined||i.boundTo==="vertices"){R=i.value[t.a];Q=i.value[t.b];S=i.value[t.c]}else if(i.boundTo==="faces"){R=i.value[E];Q=i.value[E];S=i.value[E];i.offsetSrc++}else if(i.boundTo==="faceVertices"){R=i.value[E+0];Q=i.value[E+1];S=i.value[E+2];i.offsetSrc+=3}if(i.size===2){i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+2]=Q.x;i.array[q+3]=Q.y;i.array[q+4]=S.x;i.array[q+
+5]=S.y;i.offset+=6}else if(i.size===3){if(i.type==="c"){i.array[q+0]=R.r;i.array[q+1]=R.g;i.array[q+2]=R.b;i.array[q+3]=Q.r;i.array[q+4]=Q.g;i.array[q+5]=Q.b;i.array[q+6]=S.r;i.array[q+7]=S.g;i.array[q+8]=S.b}else{i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+2]=R.z;i.array[q+3]=Q.x;i.array[q+4]=Q.y;i.array[q+5]=Q.z;i.array[q+6]=S.x;i.array[q+7]=S.y;i.array[q+8]=S.z}i.offset+=9}else{i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+2]=R.z;i.array[q+3]=R.w;i.array[q+4]=Q.x;i.array[q+5]=Q.y;i.array[q+6]=Q.z;
+i.array[q+7]=Q.w;i.array[q+8]=S.x;i.array[q+9]=S.y;i.array[q+10]=S.z;i.array[q+11]=S.w;i.offset+=12}}}}if(qb){q=0;for(E=Ta.length;q<E;q++){R=Ta[q].vertices[t.a].position;Q=Ta[q].vertices[t.b].position;S=Ta[q].vertices[t.c].position;i=kb[q];i[Ba+0]=R.x;i[Ba+1]=R.y;i[Ba+2]=R.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=S.x;i[Ba+7]=S.y;i[Ba+8]=S.z}Ba+=9}if(Xa.length){q=Xa[t.a];E=Xa[t.b];i=Xa[t.c];la[B]=q.x;la[B+1]=q.y;la[B+2]=q.z;la[B+3]=q.w;la[B+4]=E.x;la[B+5]=E.y;la[B+6]=E.z;la[B+7]=E.w;la[B+8]=i.x;
+la[B+9]=i.y;la[B+10]=i.z;la[B+11]=i.w;q=eb[t.a];E=eb[t.b];i=eb[t.c];ka[B]=q.x;ka[B+1]=q.y;ka[B+2]=q.z;ka[B+3]=q.w;ka[B+4]=E.x;ka[B+5]=E.y;ka[B+6]=E.z;ka[B+7]=E.w;ka[B+8]=i.x;ka[B+9]=i.y;ka[B+10]=i.z;ka[B+11]=i.w;q=cb[t.a];E=cb[t.b];i=cb[t.c];ia[B]=q.x;ia[B+1]=q.y;ia[B+2]=q.z;ia[B+3]=1;ia[B+4]=E.x;ia[B+5]=E.y;ia[B+6]=E.z;ia[B+7]=1;ia[B+8]=i.x;ia[B+9]=i.y;ia[B+10]=i.z;ia[B+11]=1;q=db[t.a];E=db[t.b];i=db[t.c];ja[B]=q.x;ja[B+1]=q.y;ja[B+2]=q.z;ja[B+3]=1;ja[B+4]=E.x;ja[B+5]=E.y;ja[B+6]=E.z;ja[B+7]=1;ja[B+
+8]=i.x;ja[B+9]=i.y;ja[B+10]=i.z;ja[B+11]=1;B+=12}if(pb&&W){if(y.length==3&&W==THREE.VertexColors){t=y[0];q=y[1];E=y[2]}else E=q=t=H;Ea[va]=t.r;Ea[va+1]=t.g;Ea[va+2]=t.b;Ea[va+3]=q.r;Ea[va+4]=q.g;Ea[va+5]=q.b;Ea[va+6]=E.r;Ea[va+7]=E.g;Ea[va+8]=E.b;va+=9}if(ob&&Ia.hasTangents){y=C[0];H=C[1];t=C[2];ha[da]=y.x;ha[da+1]=y.y;ha[da+2]=y.z;ha[da+3]=y.w;ha[da+4]=H.x;ha[da+5]=H.y;ha[da+6]=H.z;ha[da+7]=H.w;ha[da+8]=t.x;ha[da+9]=t.y;ha[da+10]=t.z;ha[da+11]=t.w;da+=12}if(nb&&P)if(z.length==3&&rb)for(C=0;C<3;C++){w=
+z[C];Qa[La]=w.x;Qa[La+1]=w.y;Qa[La+2]=w.z;La+=3}else for(C=0;C<3;C++){Qa[La]=w.x;Qa[La+1]=w.y;Qa[La+2]=w.z;La+=3}if(gb&&T!==undefined&&N)for(C=0;C<3;C++){z=T[C];ib[$a]=z.u;ib[$a+1]=z.v;$a+=2}if(gb&&Ha!==undefined&&N)for(C=0;C<3;C++){z=Ha[C];jb[ab]=z.u;jb[ab+1]=z.v;ab+=2}if(mb){Na[Ja]=sa;Na[Ja+1]=sa+1;Na[Ja+2]=sa+2;Ja+=3;Oa[Ma]=sa;Oa[Ma+1]=sa+1;Oa[Ma+2]=sa;Oa[Ma+3]=sa+2;Oa[Ma+4]=sa+1;Oa[Ma+5]=sa+2;Ma+=6;sa+=3}}else if(t instanceof THREE.Face4){if(lb){R=bb[t.a].position;Q=bb[t.b].position;S=bb[t.c].position;
+ra=bb[t.d].position;Da[Aa]=R.x;Da[Aa+1]=R.y;Da[Aa+2]=R.z;Da[Aa+3]=Q.x;Da[Aa+4]=Q.y;Da[Aa+5]=Q.z;Da[Aa+6]=S.x;Da[Aa+7]=S.y;Da[Aa+8]=S.z;Da[Aa+9]=ra.x;Da[Aa+10]=ra.y;Da[Aa+11]=ra.z;Aa+=12}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){q=i.offset;E=i.offsetSrc;if(i.size===1){if(i.boundTo===undefined||i.boundTo==="vertices"){i.array[q+0]=i.value[t.a];i.array[q+1]=i.value[t.b];i.array[q+2]=i.value[t.c];i.array[q+2]=i.value[t.d]}else if(i.boundTo==="faces"){i.array[q+0]=i.value[E];i.array[q+1]=i.value[E];
+i.array[q+2]=i.value[E];i.array[q+2]=i.value[E];i.offsetSrc++}else if(i.boundTo==="faceVertices"){i.array[q+0]=i.value[E+0];i.array[q+1]=i.value[E+1];i.array[q+2]=i.value[E+2];i.array[q+2]=i.value[E+3];i.offsetSrc+=4}i.offset+=4}else{if(i.boundTo===undefined||i.boundTo==="vertices"){R=i.value[t.a];Q=i.value[t.b];S=i.value[t.c];ra=i.value[t.d]}else if(i.boundTo==="faces"){R=i.value[E];Q=i.value[E];S=i.value[E];ra=i.value[E];i.offsetSrc++}else if(i.boundTo==="faceVertices"){R=i.value[E+0];Q=i.value[E+
+1];S=i.value[E+2];ra=i.value[E+3];i.offsetSrc+=4}if(i.size===2){i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+2]=Q.x;i.array[q+3]=Q.y;i.array[q+4]=S.x;i.array[q+5]=S.y;i.array[q+6]=ra.x;i.array[q+7]=ra.y;i.offset+=8}else if(i.size===3){if(i.type==="c"){i.array[q+0]=R.r;i.array[q+1]=R.g;i.array[q+2]=R.b;i.array[q+3]=Q.r;i.array[q+4]=Q.g;i.array[q+5]=Q.b;i.array[q+6]=S.r;i.array[q+7]=S.g;i.array[q+8]=S.b;i.array[q+9]=ra.r;i.array[q+10]=ra.g;i.array[q+11]=ra.b}else{i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+
+2]=R.z;i.array[q+3]=Q.x;i.array[q+4]=Q.y;i.array[q+5]=Q.z;i.array[q+6]=S.x;i.array[q+7]=S.y;i.array[q+8]=S.z;i.array[q+9]=ra.x;i.array[q+10]=ra.y;i.array[q+11]=ra.z}i.offset+=12}else{i.array[q+0]=R.x;i.array[q+1]=R.y;i.array[q+2]=R.z;i.array[q+3]=R.w;i.array[q+4]=Q.x;i.array[q+5]=Q.y;i.array[q+6]=Q.z;i.array[q+7]=Q.w;i.array[q+8]=S.x;i.array[q+9]=S.y;i.array[q+10]=S.z;i.array[q+11]=S.w;i.array[q+12]=ra.x;i.array[q+13]=ra.y;i.array[q+14]=ra.z;i.array[q+15]=ra.w;i.offset+=16}}}}if(qb){q=0;for(E=Ta.length;q<
+E;q++){R=Ta[q].vertices[t.a].position;Q=Ta[q].vertices[t.b].position;S=Ta[q].vertices[t.c].position;ra=Ta[q].vertices[t.d].position;i=kb[q];i[Ba+0]=R.x;i[Ba+1]=R.y;i[Ba+2]=R.z;i[Ba+3]=Q.x;i[Ba+4]=Q.y;i[Ba+5]=Q.z;i[Ba+6]=S.x;i[Ba+7]=S.y;i[Ba+8]=S.z;i[Ba+9]=ra.x;i[Ba+10]=ra.y;i[Ba+11]=ra.z}Ba+=12}if(Xa.length){q=Xa[t.a];E=Xa[t.b];i=Xa[t.c];Ka=Xa[t.d];la[B]=q.x;la[B+1]=q.y;la[B+2]=q.z;la[B+3]=q.w;la[B+4]=E.x;la[B+5]=E.y;la[B+6]=E.z;la[B+7]=E.w;la[B+8]=i.x;la[B+9]=i.y;la[B+10]=i.z;la[B+11]=i.w;la[B+12]=
+Ka.x;la[B+13]=Ka.y;la[B+14]=Ka.z;la[B+15]=Ka.w;q=eb[t.a];E=eb[t.b];i=eb[t.c];Ka=eb[t.d];ka[B]=q.x;ka[B+1]=q.y;ka[B+2]=q.z;ka[B+3]=q.w;ka[B+4]=E.x;ka[B+5]=E.y;ka[B+6]=E.z;ka[B+7]=E.w;ka[B+8]=i.x;ka[B+9]=i.y;ka[B+10]=i.z;ka[B+11]=i.w;ka[B+12]=Ka.x;ka[B+13]=Ka.y;ka[B+14]=Ka.z;ka[B+15]=Ka.w;q=cb[t.a];E=cb[t.b];i=cb[t.c];Ka=cb[t.d];ia[B]=q.x;ia[B+1]=q.y;ia[B+2]=q.z;ia[B+3]=1;ia[B+4]=E.x;ia[B+5]=E.y;ia[B+6]=E.z;ia[B+7]=1;ia[B+8]=i.x;ia[B+9]=i.y;ia[B+10]=i.z;ia[B+11]=1;ia[B+12]=Ka.x;ia[B+13]=Ka.y;ia[B+14]=
+Ka.z;ia[B+15]=1;q=db[t.a];E=db[t.b];i=db[t.c];t=db[t.d];ja[B]=q.x;ja[B+1]=q.y;ja[B+2]=q.z;ja[B+3]=1;ja[B+4]=E.x;ja[B+5]=E.y;ja[B+6]=E.z;ja[B+7]=1;ja[B+8]=i.x;ja[B+9]=i.y;ja[B+10]=i.z;ja[B+11]=1;ja[B+12]=t.x;ja[B+13]=t.y;ja[B+14]=t.z;ja[B+15]=1;B+=16}if(pb&&W){if(y.length==4&&W==THREE.VertexColors){t=y[0];q=y[1];E=y[2];y=y[3]}else y=E=q=t=H;Ea[va]=t.r;Ea[va+1]=t.g;Ea[va+2]=t.b;Ea[va+3]=q.r;Ea[va+4]=q.g;Ea[va+5]=q.b;Ea[va+6]=E.r;Ea[va+7]=E.g;Ea[va+8]=E.b;Ea[va+9]=y.r;Ea[va+10]=y.g;Ea[va+11]=y.b;va+=
+12}if(ob&&Ia.hasTangents){y=C[0];H=C[1];t=C[2];C=C[3];ha[da]=y.x;ha[da+1]=y.y;ha[da+2]=y.z;ha[da+3]=y.w;ha[da+4]=H.x;ha[da+5]=H.y;ha[da+6]=H.z;ha[da+7]=H.w;ha[da+8]=t.x;ha[da+9]=t.y;ha[da+10]=t.z;ha[da+11]=t.w;ha[da+12]=C.x;ha[da+13]=C.y;ha[da+14]=C.z;ha[da+15]=C.w;da+=16}if(nb&&P)if(z.length==4&&rb)for(C=0;C<4;C++){w=z[C];Qa[La]=w.x;Qa[La+1]=w.y;Qa[La+2]=w.z;La+=3}else for(C=0;C<4;C++){Qa[La]=w.x;Qa[La+1]=w.y;Qa[La+2]=w.z;La+=3}if(gb&&T!==undefined&&N)for(C=0;C<4;C++){z=T[C];ib[$a]=z.u;ib[$a+1]=
+z.v;$a+=2}if(gb&&Ha!==undefined&&N)for(C=0;C<4;C++){z=Ha[C];jb[ab]=z.u;jb[ab+1]=z.v;ab+=2}if(mb){Na[Ja]=sa;Na[Ja+1]=sa+1;Na[Ja+2]=sa+3;Na[Ja+3]=sa+1;Na[Ja+4]=sa+2;Na[Ja+5]=sa+3;Ja+=6;Oa[Ma]=sa;Oa[Ma+1]=sa+1;Oa[Ma+2]=sa;Oa[Ma+3]=sa+3;Oa[Ma+4]=sa+1;Oa[Ma+5]=sa+2;Oa[Ma+6]=sa+2;Oa[Ma+7]=sa+3;Ma+=8;sa+=4}}}if(Za){v=0;for(x=Za.length;v<x;v++){Na[Ja]=Za[v].a;Na[Ja+1]=Za[v].b;Na[Ja+2]=Za[v].c;Na[Ja+3]=Za[v].a;Na[Ja+4]=Za[v].c;Na[Ja+5]=Za[v].d;Ja+=6}}if(lb){c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);
+c.bufferData(c.ARRAY_BUFFER,Da,A)}if(Ra)for(Wa in Ra){i=Ra[Wa];if(i.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,i.buffer);c.bufferData(c.ARRAY_BUFFER,i.array,A);i.needsUpdate=!1}}if(qb){q=0;for(E=Ta.length;q<E;q++){c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[q]);c.bufferData(c.ARRAY_BUFFER,kb[q],A)}}if(pb&&va>0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Ea,A)}if(nb){c.bindBuffer(c.ARRAY_BUFFER,m.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,A)}if(ob&&
+Ia.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,m.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,A)}if(gb&&$a>0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,ib,A)}if(gb&&ab>0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,jb,A)}if(mb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,A)}if(B>
+0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,A);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,A);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,A);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,la,A)}}}n.__dirtyVertices=!1;n.__dirtyMorphTargets=!1;n.__dirtyElements=!1;n.__dirtyUvs=!1;n.__dirtyNormals=!1;n.__dirtyTangents=!1;n.__dirtyColors=
+!1}else if(f instanceof THREE.Ribbon){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;s=c.DYNAMIC_DRAW;W=f.vertices;m=f.colors;P=W.length;A=m.length;T=f.__vertexArray;v=f.__colorArray;Ha=f.__dirtyColors;if(f.__dirtyVertices){for(x=0;x<P;x++){N=W[x].position;r=x*3;T[r]=N.x;T[r+1]=N.y;T[r+2]=N.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,s)}if(Ha){for(x=0;x<A;x++){color=m[x];r=x*3;v[r]=color.r;v[r+1]=color.g;v[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);
+c.bufferData(c.ARRAY_BUFFER,v,s)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Line){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;s=c.DYNAMIC_DRAW;W=f.vertices;m=f.colors;P=W.length;A=m.length;T=f.__vertexArray;v=f.__colorArray;Ha=f.__dirtyColors;if(f.__dirtyVertices){for(x=0;x<P;x++){N=W[x].position;r=x*3;T[r]=N.x;T[r+1]=N.y;T[r+2]=N.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,s)}if(Ha){for(x=0;x<A;x++){color=m[x];r=x*3;v[r]=
+color.r;v[r+1]=color.g;v[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,v,s)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){n=f.geometry;(n.__dirtyVertices||n.__dirtyColors||f.sortParticles)&&d(n,c.DYNAMIC_DRAW,f);n.__dirtyVertices=!1;n.__dirtyColors=!1}}function O(f){function s(H){var C=[];n=0;for(m=H.length;n<m;n++)H[n]==undefined?C.push("undefined"):C.push(H[n].id);return C.join("_")}var n,m,r,A,v,x,z,t,w={},y=f.morphTargets!==
+undefined?f.morphTargets.length:0;f.geometryGroups={};r=0;for(A=f.faces.length;r<A;r++){v=f.faces[r];x=v.materials;z=s(x);w[z]==undefined&&(w[z]={hash:z,counter:0});t=w[z].hash+"_"+w[z].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:x,vertices:0,numMorphTargets:y});v=v instanceof THREE.Face3?3:4;if(f.geometryGroups[t].vertices+v>65535){w[z].counter+=1;t=w[z].hash+"_"+w[z].counter;f.geometryGroups[t]==undefined&&(f.geometryGroups[t]={faces:[],materials:x,vertices:0,
+numMorphTargets:y})}f.geometryGroups[t].faces.push(r);f.geometryGroups[t].vertices+=v}}function ca(f,s,n){f.push({buffer:s,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function ma(f){if(f!=fa){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);
+break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}fa=f}}function wa(f,s,n){if((n.width&n.width-1)==0&&(n.height&n.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,ea(s.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,ea(s.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,ea(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,ea(s.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,ta(s.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,ta(s.minFilter))}}function $(f,s){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);f.__webglInit=!0}wa(c.TEXTURE_2D,
+f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+s);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function J(f){if(f&&!f.__webglFramebuffer){if(f.depthBuffer===undefined)f.depthBuffer=!0;if(f.stencilBuffer===undefined)f.stencilBuffer=!0;f.__webglFramebuffer=c.createFramebuffer();f.__webglRenderbuffer=c.createRenderbuffer();f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,ea(f.wrapS));
+c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,ea(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,ea(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,ea(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,ea(f.format),f.width,f.height,0,ea(f.format),ea(f.type),null);c.bindRenderbuffer(c.RENDERBUFFER,f.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,f.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webglTexture,0);if(f.depthBuffer&&
+!f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else if(f.depthBuffer&&f.stencilBuffer){c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,f.width,f.height);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,f.__webglRenderbuffer)}else c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,f.width,f.height);c.bindTexture(c.TEXTURE_2D,
+null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var s,n;if(f){s=f.__webglFramebuffer;n=f.width;f=f.height}else{s=null;n=oa;f=Ca}if(s!=Fa){c.bindFramebuffer(c.FRAMEBUFFER,s);c.viewport(Z,ua,n,f);Fa=s}}function xa(f,s){var n;if(f=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(n=c.createShader(c.VERTEX_SHADER));c.shaderSource(n,s);c.compileShader(n);if(!c.getShaderParameter(n,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(n));console.error(s);
+return null}return n}function ta(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function ea(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 c,U=document.createElement("canvas"),V=[],na=null,Fa=null,Ga=!0,ya=this,aa=null,pa=null,fa=null,qa=null,Z=0,ua=0,oa=0,Ca=0,za=[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),Ua=new Float32Array(16),Va=new THREE.Vector4,
+hb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Sa=!0,fb=!0,Ya=new THREE.Color(0),vb=0;if(b){if(b.stencil!=undefined)Sa=b.stencil;if(b.antialias!==undefined)fb=b.antialias;b.clearColor!==undefined&&Ya.setHex(b.clearColor);if(b.clearAlpha!==undefined)vb=b.clearAlpha}this.maxMorphTargets=8;this.domElement=U;this.autoClear=!0;this.sortObjects=!0;(function(f,s,n,m){try{if(!(c=U.getContext("experimental-webgl",{antialias:f,stencil:m})))throw"Error creating WebGL context.";
+}catch(r){console.error(r)}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(s.r,s.g,s.b,n)})(fb,Ya,vb,Sa);this.context=c;if(Sa){var X={};X.vertices=new Float32Array(12);X.faces=new Uint16Array(6);X.darkness=0.5;X.vertices[0]=-20;X.vertices[1]=-20;X.vertices[2]=-1;X.vertices[3]=20;X.vertices[4]=-20;X.vertices[5]=
+-1;X.vertices[6]=20;X.vertices[7]=20;X.vertices[8]=-1;X.vertices[9]=-20;X.vertices[10]=20;X.vertices[11]=-1;X.faces[0]=0;X.faces[1]=1;X.faces[2]=2;X.faces[3]=0;X.faces[4]=2;X.faces[5]=3;X.vertexBuffer=c.createBuffer();X.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,X.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,X.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,X.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,X.faces,c.STATIC_DRAW);X.program=c.createProgram();c.attachShader(X.program,
+xa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(X.program,xa("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(X.program);X.vertexLocation=c.getAttribLocation(X.program,"position");X.projectionLocation=c.getUniformLocation(X.program,"projectionMatrix");X.darknessLocation=c.getUniformLocation(X.program,"darkness")}var K={};K.vertices=new Float32Array(16);K.faces=new Uint16Array(6);K.transparency=0.5;b=0;K.vertices[b++]=-1;K.vertices[b++]=-1;K.vertices[b++]=0;
+K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=1;K.vertices[b++]=-1;K.vertices[b++]=1;K.vertices[b++]=0;K.vertices[b++]=1;b=0;K.faces[b++]=0;K.faces[b++]=1;K.faces[b++]=2;K.faces[b++]=0;K.faces[b++]=2;K.faces[b++]=3;K.vertexBuffer=c.createBuffer();K.elementBuffer=c.createBuffer();K.tempTexture=c.createTexture();K.readBackPixels=new Uint8Array(1024);c.bindBuffer(c.ARRAY_BUFFER,K.vertexBuffer);
+c.bufferData(c.ARRAY_BUFFER,K.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,K.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,K.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
+c.NEAREST);K.program=c.createProgram();c.attachShader(K.program,xa("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(K.program,xa("vertex",THREE.ShaderLib.lensFlare.vertexShader));c.linkProgram(K.program);K.attributes={};K.uniforms={};K.attributes.vertex=c.getAttribLocation(K.program,"position");K.attributes.uv=c.getAttribLocation(K.program,"UV");K.uniforms.map=c.getUniformLocation(K.program,"map");K.uniforms.opacity=c.getUniformLocation(K.program,"opacity");K.uniforms.scale=c.getUniformLocation(K.program,
+"scale");K.uniforms.rotation=c.getUniformLocation(K.program,"rotation");K.uniforms.screenPosition=c.getUniformLocation(K.program,"screenPosition");K.uniforms.renderPink=c.getUniformLocation(K.program,"renderPink");this.setSize=function(f,s){U.width=f;U.height=s;this.setViewport(0,0,U.width,U.height)};this.setViewport=function(f,s,n,m){Z=f;ua=s;oa=n;Ca=m;c.viewport(Z,ua,oa,Ca)};this.setScissor=function(f,s,n,m){c.scissor(f,s,n,m)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};
+this.enableDepthBufferWrite=function(f){Ga=f;c.depthMask(f)};this.setClearColorHex=function(f,s){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,s)};this.setClearColor=function(f,s){c.clearColor(f.r,f.g,f.b,s)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){X.darkness=f};this.initMaterial=function(f,s,n,m){var r,A,v;if(f instanceof THREE.MeshDepthMaterial)v="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)v=
+"shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)v="normal";else if(f instanceof THREE.MeshBasicMaterial)v="basic";else if(f instanceof THREE.MeshLambertMaterial)v="lambert";else if(f instanceof THREE.MeshPhongMaterial)v="phong";else if(f instanceof THREE.LineBasicMaterial)v="basic";else f instanceof THREE.ParticleBasicMaterial&&(v="particle_basic");if(v){var x=THREE.ShaderLib[v];f.uniforms=Uniforms.clone(x.uniforms);f.vertexShader=x.vertexShader;f.fragmentShader=x.fragmentShader}var z,
+t,w;z=w=x=0;for(t=s.length;z<t;z++){A=s[z];A instanceof THREE.DirectionalLight&&w++;A instanceof THREE.PointLight&&x++}if(x+w<=4)s=w;else{s=Math.ceil(4*w/(x+w));x=4-s}A={directional:s,point:x};w=50;if(m!==undefined&&m instanceof THREE.SkinnedMesh)w=m.bones.length;var y;a:{z=f.fragmentShader;t=f.vertexShader;x=f.uniforms;s=f.attributes;n={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:n,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,
+maxMorphTargets:this.maxMorphTargets,maxDirLights:A.directional,maxPointLights:A.point,maxBones:w};var H;A=[];if(v)A.push(v);else{A.push(z);A.push(t)}for(H in n){A.push(H);A.push(n[H])}v=A.join();H=0;for(A=V.length;H<A;H++)if(V[H].code==v){y=V[H].program;break a}H=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":
+"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":
+"",n.vertexColors?"#define USE_COLOR":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+c.attachShader(H,xa("fragment",prefix_fragment+z));c.attachShader(H,xa("vertex",prefix_vertex+t));c.linkProgram(H);c.getProgramParameter(H,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(H,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");H.uniforms={};H.attributes={};var C;z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(C in x)z.push(C);
+C=z;x=0;for(z=C.length;x<z;x++){t=C[x];H.uniforms[t]=c.getUniformLocation(H,t)}z=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(C=0;C<n.maxMorphTargets;C++)z.push("morphTarget"+C);for(y in s)z.push(y);y=z;C=0;for(s=y.length;C<s;C++){n=y[C];H.attributes[n]=c.getAttribLocation(H,n)}V.push({program:H,code:v});y=H}f.program=y;y=f.program.attributes;c.enableVertexAttribArray(y.position);y.color>=0&&c.enableVertexAttribArray(y.color);y.normal>=
+0&&c.enableVertexAttribArray(y.normal);y.tangent>=0&&c.enableVertexAttribArray(y.tangent);if(f.skinning&&y.skinVertexA>=0&&y.skinVertexB>=0&&y.skinIndex>=0&&y.skinWeight>=0){c.enableVertexAttribArray(y.skinVertexA);c.enableVertexAttribArray(y.skinVertexB);c.enableVertexAttribArray(y.skinIndex);c.enableVertexAttribArray(y.skinWeight)}for(r in f.attributes)y[r]>=0&&c.enableVertexAttribArray(y[r]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(y.morphTarget0>=0){c.enableVertexAttribArray(y.morphTarget0);
+f.numSupportedMorphTargets++}if(y.morphTarget1>=0){c.enableVertexAttribArray(y.morphTarget1);f.numSupportedMorphTargets++}if(y.morphTarget2>=0){c.enableVertexAttribArray(y.morphTarget2);f.numSupportedMorphTargets++}if(y.morphTarget3>=0){c.enableVertexAttribArray(y.morphTarget3);f.numSupportedMorphTargets++}if(y.morphTarget4>=0){c.enableVertexAttribArray(y.morphTarget4);f.numSupportedMorphTargets++}if(y.morphTarget5>=0){c.enableVertexAttribArray(y.morphTarget5);f.numSupportedMorphTargets++}if(y.morphTarget6>=
+0){c.enableVertexAttribArray(y.morphTarget6);f.numSupportedMorphTargets++}if(y.morphTarget7>=0){c.enableVertexAttribArray(y.morphTarget7);f.numSupportedMorphTargets++}m.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(r=this.maxMorphTargets;f<r;f++)m.__webglMorphTargetInfluences[f]=0}};this.render=function(f,s,n,m){var r,A,v,x,z,t,w,y,H=f.lights,C=f.fog;s.matrixAutoUpdate&&s.updateMatrix();f.update(undefined,!1,s);s.matrixWorldInverse.flattenToArray(Ua);s.projectionMatrix.flattenToArray(Pa);
+ga.multiply(s.projectionMatrix,s.matrixWorldInverse);o(ga);this.initWebGLObjects(f);J(n);(this.autoClear||m)&&this.clear();z=f.__webglObjects.length;for(m=0;m<z;m++){r=f.__webglObjects[m];w=r.object;if(w.visible)if(!(w instanceof THREE.Mesh)||p(w)){w.matrixWorld.flattenToArray(w._objectMatrixArray);M(w,s);F(r);r.render=!0;if(this.sortObjects){Va.copy(w.position);ga.multiplyVector3(Va);r.z=Va.z}}else r.render=!1;else r.render=!1}this.sortObjects&&f.__webglObjects.sort(I);t=f.__webglObjectsImmediate.length;
+for(m=0;m<t;m++){r=f.__webglObjectsImmediate[m];w=r.object;if(w.visible){w.matrixAutoUpdate&&w.matrixWorld.flattenToArray(w._objectMatrixArray);M(w,s);D(r)}}ma(THREE.NormalBlending);for(m=0;m<z;m++){r=f.__webglObjects[m];if(r.render){w=r.object;y=r.buffer;v=r.opaque;k(w);for(r=0;r<v.count;r++){x=v.list[r];j(x.depthTest);h(s,H,C,x,y,w)}}}for(m=0;m<t;m++){r=f.__webglObjectsImmediate[m];w=r.object;if(w.visible){v=r.opaque;k(w);for(r=0;r<v.count;r++){x=v.list[r];j(x.depthTest);A=e(s,H,C,x,w);w.render(function(N){g(N,
+A)})}}}for(m=0;m<z;m++){r=f.__webglObjects[m];if(r.render){w=r.object;y=r.buffer;v=r.transparent;k(w);for(r=0;r<v.count;r++){x=v.list[r];ma(x.blending);j(x.depthTest);h(s,H,C,x,y,w)}}}for(m=0;m<t;m++){r=f.__webglObjectsImmediate[m];w=r.object;if(w.visible){v=r.transparent;k(w);for(r=0;r<v.count;r++){x=v.list[r];ma(x.blending);j(x.depthTest);A=e(s,H,C,x,w);w.render(function(N){g(N,A)})}}}Sa&&f.__webglShadowVolumes.length&&f.lights.length&&G(f);f.__webglLensFlares.length&&L(f,s);if(n&&n.minFilter!==
+THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,n.__webglTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[]}for(;f.__objectsAdded.length;){var s=f.__objectsAdded[0],n=f,m=void 0,r=void 0,A=void 0;if(s._modelViewMatrix==undefined){s._modelViewMatrix=new THREE.Matrix4;s._normalMatrixArray=new Float32Array(9);
+s._modelViewMatrixArray=new Float32Array(16);s._objectMatrixArray=new Float32Array(16);s.matrixWorld.flattenToArray(s._objectMatrixArray)}if(s instanceof THREE.Mesh){r=s.geometry;r.geometryGroups==undefined&&O(r);for(m in r.geometryGroups){A=r.geometryGroups[m];if(!A.__webglVertexBuffer){var v=A;v.__webglVertexBuffer=c.createBuffer();v.__webglNormalBuffer=c.createBuffer();v.__webglTangentBuffer=c.createBuffer();v.__webglColorBuffer=c.createBuffer();v.__webglUVBuffer=c.createBuffer();v.__webglUV2Buffer=
+c.createBuffer();v.__webglSkinVertexABuffer=c.createBuffer();v.__webglSkinVertexBBuffer=c.createBuffer();v.__webglSkinIndicesBuffer=c.createBuffer();v.__webglSkinWeightsBuffer=c.createBuffer();v.__webglFaceBuffer=c.createBuffer();v.__webglLineBuffer=c.createBuffer();if(v.numMorphTargets){var x=void 0,z=void 0;v.__webglMorphTargetsBuffers=[];x=0;for(z=v.numMorphTargets;x<z;x++)v.__webglMorphTargetsBuffers.push(c.createBuffer())}v=A;x=s;var t=void 0,w=void 0,y=void 0;y=void 0;var H=void 0,C=void 0,
+N=void 0,W=N=z=0;w=void 0;y=void 0;var P=void 0;t=void 0;w=void 0;H=x.geometry;P=H.faces;C=v.faces;t=0;for(w=C.length;t<w;t++){y=C[t];y=P[y];if(y instanceof THREE.Face3){z+=3;N+=1;W+=3}else if(y instanceof THREE.Face4){z+=4;N+=2;W+=4}}t=v;w=x;P=void 0;C=void 0;var T=void 0,Ha=void 0;T=void 0;y=[];P=0;for(C=w.materials.length;P<C;P++){T=w.materials[P];if(T instanceof THREE.MeshFaceMaterial){T=0;for(l=t.materials.length;T<l;T++)(Ha=t.materials[T])&&y.push(Ha)}else(Ha=T)&&y.push(Ha)}t=y;a:{w=void 0;
+P=void 0;C=t.length;for(w=0;w<C;w++){P=t[w];if(P.map||P.lightMap||P instanceof THREE.MeshShaderMaterial){w=!0;break a}}w=!1}a:{P=void 0;C=void 0;y=t.length;for(P=0;P<y;P++){C=t[P];if(!(C instanceof THREE.MeshBasicMaterial&&!C.envMap||C instanceof THREE.MeshDepthMaterial)){P=C&&C.shading!=undefined&&C.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}P=!1}a:{C=void 0;y=void 0;T=t.length;for(C=0;C<T;C++){y=t[C];if(y.vertexColors){y=y.vertexColors;break a}}y=!1}v.__vertexArray=
+new Float32Array(z*3);if(P)v.__normalArray=new Float32Array(z*3);if(H.hasTangents)v.__tangentArray=new Float32Array(z*4);if(y)v.__colorArray=new Float32Array(z*3);if(w){if(H.faceUvs.length>0||H.faceVertexUvs.length>0)v.__uvArray=new Float32Array(z*2);if(H.faceUvs.length>1||H.faceVertexUvs.length>1)v.__uv2Array=new Float32Array(z*2)}if(x.geometry.skinWeights.length&&x.geometry.skinIndices.length){v.__skinVertexAArray=new Float32Array(z*4);v.__skinVertexBArray=new Float32Array(z*4);v.__skinIndexArray=
+new Float32Array(z*4);v.__skinWeightArray=new Float32Array(z*4)}v.__faceArray=new Uint16Array(N*3+(x.geometry.edgeFaces?x.geometry.edgeFaces.length*6:0));v.__lineArray=new Uint16Array(W*2);if(v.numMorphTargets){v.__morphTargetsArrays=[];H=0;for(C=v.numMorphTargets;H<C;H++)v.__morphTargetsArrays.push(new Float32Array(z*3))}v.__needsSmoothNormals=P==THREE.SmoothShading;v.__uvType=w;v.__vertexColorType=y;v.__normalType=P;v.__webglFaceCount=N*3+(x.geometry.edgeFaces?x.geometry.edgeFaces.length*6:0);v.__webglLineCount=
+W*2;H=0;for(C=t.length;H<C;H++)if(t[H].attributes){v.__webglCustomAttributes={};for(a in t[H].attributes){w=t[H].attributes[a];N=1;if(w.type==="v2")N=2;else if(w.type==="v3")N=3;else if(w.type==="v4")N=4;else w.type==="c"&&(N=3);w.size=N;w.needsUpdate=!0;w.array=new Float32Array(z*N);w.buffer=c.createBuffer();v.__webglCustomAttributes[a]=w}}r.__dirtyVertices=!0;r.__dirtyMorphTargets=!0;r.__dirtyElements=!0;r.__dirtyUvs=!0;r.__dirtyNormals=!0;r.__dirtyTangents=!0;r.__dirtyColors=!0}s instanceof THREE.ShadowVolume?
+ca(n.__webglShadowVolumes,A,s):ca(n.__webglObjects,A,s)}}else if(s instanceof THREE.LensFlare)ca(n.__webglLensFlares,undefined,s);else if(s instanceof THREE.Ribbon){r=s.geometry;if(!r.__webglVertexBuffer){m=r;m.__webglVertexBuffer=c.createBuffer();m.__webglColorBuffer=c.createBuffer();m=r;A=m.vertices.length;m.__vertexArray=new Float32Array(A*3);m.__colorArray=new Float32Array(A*3);m.__webglVertexCount=A;r.__dirtyVertices=!0;r.__dirtyColors=!0}ca(n.__webglObjects,r,s)}else if(s instanceof THREE.Line){r=
+s.geometry;if(!r.__webglVertexBuffer){m=r;m.__webglVertexBuffer=c.createBuffer();m.__webglColorBuffer=c.createBuffer();m=r;A=m.vertices.length;m.__vertexArray=new Float32Array(A*3);m.__colorArray=new Float32Array(A*3);m.__webglLineCount=A;r.__dirtyVertices=!0;r.__dirtyColors=!0}ca(n.__webglObjects,r,s)}else if(s instanceof THREE.ParticleSystem){r=s.geometry;if(!r.__webglVertexBuffer){m=r;m.__webglVertexBuffer=c.createBuffer();m.__webglColorBuffer=c.createBuffer();m=r;A=m.vertices.length;m.__vertexArray=
+new Float32Array(A*3);m.__colorArray=new Float32Array(A*3);m.__sortArray=[];m.__webglParticleCount=A;r.__dirtyVertices=!0;r.__dirtyColors=!0}ca(n.__webglObjects,r,s)}else THREE.MarchingCubes!==undefined&&s instanceof THREE.MarchingCubes&&n.__webglObjectsImmediate.push({object:s,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}for(;f.__objectsRemoved.length;){s=f.__objectsRemoved[0];n=f;r=void 0;m=void 0;for(r=n.__webglObjects.length-1;r>=0;r--){m=n.__webglObjects[r].object;
+s==m&&n.__webglObjects.splice(r,1)}f.__objectsRemoved.splice(0,1)}s=0;for(n=f.__webglObjects.length;s<n;s++)Y(f.__webglObjects[s].object,f);s=0;for(n=f.__webglShadowVolumes.length;s<n;s++)Y(f.__webglShadowVolumes[s].object,f);s=0;for(n=f.__webglLensFlares.length;s<n;s++)Y(f.__webglLensFlares[s].object,f)};this.setFaceCulling=function(f,s){if(f){!s||s=="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.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==undefined?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==undefined?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==undefined?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==undefined?e.minFilter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};
+THREE.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==undefined?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==undefined?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==undefined?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==undefined?e.minFilter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==
+undefined?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==undefined?e.stencilBuffer:!0};

+ 2 - 2
examples/js/Stats.js

@@ -3,8 +3,8 @@ var Stats=function(){function w(d,K,n){var u,f,c;for(f=0;f<30;f++)for(u=0;u<73;u
 g:16,b:26},fg:{r:255,g:0,b:128}}};e=document.createElement("div");e.style.cursor="pointer";e.style.width="80px";e.style.opacity="0.9";e.style.zIndex="10001";e.addEventListener("click",function(){v++;v==x&&(v=0);m.style.display="none";h.style.display="none";j.style.display="none";switch(v){case 0:m.style.display="block";break;case 1:h.style.display="block";break;case 2:j.style.display="block"}},false);m=document.createElement("div");m.style.backgroundColor="rgb("+Math.floor(b.fps.bg.r/2)+","+Math.floor(b.fps.bg.g/
 2)+","+Math.floor(b.fps.bg.b/2)+")";m.style.padding="2px 0px 3px 0px";e.appendChild(m);g=document.createElement("div");g.style.fontFamily="Helvetica, Arial, sans-serif";g.style.textAlign="left";g.style.fontSize="9px";g.style.color="rgb("+b.fps.fg.r+","+b.fps.fg.g+","+b.fps.fg.b+")";g.style.margin="0px 0px 1px 3px";g.innerHTML='<span style="font-weight:bold">FPS</span>';m.appendChild(g);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";m.appendChild(a);
 p=a.getContext("2d");p.fillStyle="rgb("+b.fps.bg.r+","+b.fps.bg.g+","+b.fps.bg.b+")";p.fillRect(0,0,a.width,a.height);C=p.getImageData(0,0,a.width,a.height);h=document.createElement("div");h.style.backgroundColor="rgb("+Math.floor(b.ms.bg.r/2)+","+Math.floor(b.ms.bg.g/2)+","+Math.floor(b.ms.bg.b/2)+")";h.style.padding="2px 0px 3px 0px";h.style.display="none";e.appendChild(h);i=document.createElement("div");i.style.fontFamily="Helvetica, Arial, sans-serif";i.style.textAlign="left";i.style.fontSize=
-"9px";i.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='<span style="font-weight:bold">MS</span>';h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);r=a.getContext("2d");r.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";r.fillRect(0,0,a.width,a.height);F=r.getImageData(0,0,a.width,a.height);try{if(webkitPerformance&&webkitPerformance.memory.totalJSHeapSize)x=
+"9px";i.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='<span style="font-weight:bold">MS</span>';h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);r=a.getContext("2d");r.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";r.fillRect(0,0,a.width,a.height);F=r.getImageData(0,0,a.width,a.height);try{if(performance&&performance.memory&&performance.memory.totalJSHeapSize)x=
 3}catch(L){}j=document.createElement("div");j.style.backgroundColor="rgb("+Math.floor(b.mem.bg.r/2)+","+Math.floor(b.mem.bg.g/2)+","+Math.floor(b.mem.bg.b/2)+")";j.style.padding="2px 0px 3px 0px";j.style.display="none";e.appendChild(j);k=document.createElement("div");k.style.fontFamily="Helvetica, Arial, sans-serif";k.style.textAlign="left";k.style.fontSize="9px";k.style.color="rgb("+b.mem.fg.r+","+b.mem.fg.g+","+b.mem.fg.b+")";k.style.margin="0px 0px 1px 3px";k.innerHTML='<span style="font-weight:bold">MEM</span>';
 j.appendChild(k);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";j.appendChild(a);t=a.getContext("2d");t.fillStyle="#301010";t.fillRect(0,0,a.width,a.height);I=t.getImageData(0,0,a.width,a.height);return{domElement:e,update:function(){y++;l=(new Date).getTime();q=l-J;D=Math.min(D,q);E=Math.max(E,q);w(F.data,Math.min(30,30-q/200*30),"ms");i.innerHTML='<span style="font-weight:bold">'+q+" MS</span> ("+D+"-"+E+")";r.putImageData(F,0,0);J=l;if(l>
-z+1E3){o=Math.round(y*1E3/(l-z));A=Math.min(A,o);B=Math.max(B,o);w(C.data,Math.min(30,30-o/100*30),"fps");g.innerHTML='<span style="font-weight:bold">'+o+" FPS</span> ("+A+"-"+B+")";p.putImageData(C,0,0);if(x==3){s=webkitPerformance.memory.usedJSHeapSize*9.54E-7;G=Math.min(G,s);H=Math.max(H,s);w(I.data,Math.min(30,30-s/2),"mem");k.innerHTML='<span style="font-weight:bold">'+Math.round(s)+" MEM</span> ("+Math.round(G)+"-"+Math.round(H)+")";t.putImageData(I,0,0)}z=l;y=0}}}};
+z+1E3){o=Math.round(y*1E3/(l-z));A=Math.min(A,o);B=Math.max(B,o);w(C.data,Math.min(30,30-o/100*30),"fps");g.innerHTML='<span style="font-weight:bold">'+o+" FPS</span> ("+A+"-"+B+")";p.putImageData(C,0,0);if(x==3){s=performance.memory.usedJSHeapSize*9.54E-7;G=Math.min(G,s);H=Math.max(H,s);w(I.data,Math.min(30,30-s/2),"mem");k.innerHTML='<span style="font-weight:bold">'+Math.round(s)+" MEM</span> ("+Math.round(G)+"-"+Math.round(H)+")";t.putImageData(I,0,0)}z=l;y=0}}}};
 

+ 1 - 1
examples/obj/female02/Female02_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/female02/female02.obj
 //  vertices: 3274
-//  faces: 6233 
+//  faces: 6233
 //  materials: 6
 //
 //  Generated with OBJ -> Three.js converter

File diff suppressed because it is too large
+ 5 - 3
examples/obj/female02/Female02_slim.js


+ 1 - 1
examples/obj/lucy/Lucy100k_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/lucy/lucy100k.obj
 //  vertices: 50002
-//  faces: 100000 
+//  faces: 100000
 //  materials: 0
 //
 //  Generated with OBJ -> Three.js converter

File diff suppressed because it is too large
+ 5 - 3
examples/obj/lucy/Lucy100k_slim.js


+ 1 - 1
examples/obj/male02/Male02_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/male02/male02.obj
 //  vertices: 2746
-//  faces: 5004 
+//  faces: 5004
 //  materials: 5
 //
 //  Generated with OBJ -> Three.js converter

File diff suppressed because it is too large
+ 5 - 3
examples/obj/male02/Male02_slim.js


+ 1 - 1
examples/obj/ninja/NinjaLo_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/ninja/ninjaHead_Low.obj
 //  vertices: 4485
-//  faces: 4810 
+//  faces: 4810
 //  materials: 0
 //
 //  Generated with OBJ -> Three.js converter

+ 1 - 1
examples/obj/torus/Torus_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/torus/Torus.obj
 //  vertices: 576
-//  faces: 576 
+//  faces: 576
 //  materials: 1
 //
 //  Generated with OBJ -> Three.js converter

File diff suppressed because it is too large
+ 5 - 3
examples/obj/torus/Torus_slim.js


+ 1 - 1
examples/obj/walt/WaltHead_bin.js

@@ -1,6 +1,6 @@
 // Converted from: ../../examples/obj/walt/WaltHead.obj
 //  vertices: 8146
-//  faces: 16160 
+//  faces: 16160
 //  materials: 1
 //
 //  Generated with OBJ -> Three.js converter

File diff suppressed because it is too large
+ 5 - 3
examples/obj/walt/WaltHead_slim.js


+ 1 - 1
examples/webgl_materials_video.html

@@ -137,7 +137,7 @@
 
 					material = materials[ cube_count ];
 
-					material.program = material_base.program;
+					//material.program = material_base.program;
 
 					material.hue = i/xgrid;
 					material.saturation = j/ygrid;

+ 21 - 1
examples/webgl_panorama_equirectangular.html

@@ -72,6 +72,7 @@
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 				document.addEventListener( 'mouseup', onDocumentMouseUp, false );
 				document.addEventListener( 'mousewheel', onDocumentMouseWheel, false );
+				document.addEventListener( 'DOMMouseScroll', onDocumentMouseWheel, false);
 
 			}
 
@@ -107,7 +108,26 @@
 
 			function onDocumentMouseWheel( event ) {
 
-				fov -= event.wheelDeltaY * 0.05;
+				// WebKit
+
+				if ( event.wheelDeltaY ) {
+
+					fov -= event.wheelDeltaY * 0.05;
+
+				// Opera / Explorer 9
+
+				} else if ( event.wheelDelta ) {
+
+					fov -= event.wheelDelta * 0.05;
+
+				// Firefox
+
+				} else if ( event.detail ) {
+
+					fov += event.detail * 1.0;
+
+				}
+
 				camera.projectionMatrix = THREE.Matrix4.makePerspective( fov, window.innerWidth / window.innerHeight, 1, 1100 );
 				render();
 

+ 29 - 28
examples/webgl_postprocessing_dof.html

@@ -55,7 +55,7 @@
 				materials = [], objects = [],
 				singleMaterial, zmaterial = [],
 				parameters, i, j, k, h, color, x, y, z, s, n, nobjects,
-				material_depth, material_base, cubeMaterial;
+				material_depth, cubeMaterial;
 
 			var mouseX = 0, mouseY = 0;
 
@@ -79,13 +79,6 @@
 
 				scene = new THREE.Scene();
 
-				/*
-				var light = new THREE.DirectionalLight( 0xffffff );
-				light.position.set( 0, 0.5, 1 );
-				light.position.normalize();
-				scene.addLight( light );
-				*/
-
 				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, height );
 				container.appendChild( renderer.domElement );
@@ -103,7 +96,6 @@
 				var textureCube = ImageUtils.loadTextureCube( urls );
 
 				parameters = { color: 0xff1100, envMap: textureCube, shading: THREE.FlatShading };
-				//parameters = { color: 0xff1100, shading: THREE.FlatShading };
 				cubeMaterial = new THREE.MeshBasicMaterial( parameters );
 
 				singleMaterial = false;
@@ -111,12 +103,12 @@
 				if( singleMaterial ) zmaterial = [ cubeMaterial ];
 
 				//var geo = new Cube( 1, 1, 1 );
-				var geo = new Sphere( 1, 20, 10 );
 				//var geo = new Icosahedron( 2 );
+				var geo = new Sphere( 1, 20, 10 );
 
-				material_base = cubeMaterial;
-
-				renderer.initMaterial( material_base, scene.lights, scene.fog );
+				var start = new Date().getTime();
+				
+				renderer.initMaterial( cubeMaterial, scene.lights, scene.fog );
 
 				var xgrid = 14,
 					ygrid = 9,
@@ -133,13 +125,17 @@
 				for ( j = 0; j < ygrid; j++ )
 				for ( k = 0; k < zgrid; k++ ) {
 
-					materials[c] = new THREE.MeshBasicMaterial( parameters );
-					materials[c].program = material_base.program;
+					if ( singleMaterial ) {
 
-					if ( singleMaterial )
 						mesh = new THREE.Mesh( geo, zmaterial );
-					else
-						mesh = new THREE.Mesh( geo, materials[c] );
+
+					} else {
+
+						materials[ c ] = new THREE.MeshBasicMaterial( parameters );
+						mesh = new THREE.Mesh( geo, materials[ c ] );
+						renderer.initMaterial( materials[ c ], scene.lights, scene.fog, mesh );
+
+					}
 
 					x = 200 * ( i - xgrid/2 );
 					y = 200 * ( j - ygrid/2 );
@@ -158,6 +154,8 @@
 
 				}
 
+				//console.log("init time: ", new Date().getTime() - start );
+				
 				scene.matrixAutoUpdate = false;
 
 				initPostprocessing();
@@ -171,7 +169,7 @@
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
-				//container.appendChild( stats.domElement );
+				container.appendChild( stats.domElement );
 
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
@@ -283,14 +281,17 @@
 				camera.position.x += ( mouseX - camera.position.x ) * 0.036;
 				camera.position.y += ( - (mouseY) - camera.position.y ) * 0.036;
 
-				for( i = 0; i < nobjects; i++ ) {
+				if ( !singleMaterial ) {
 
-					h = ( 360 * ( i/nobjects + time ) % 360 ) / 360;
-					//materials[i].color.setHSV( h, 0.5 + 0.5 * ( i % 20 / 20 ), 1 );
-					materials[i].color.setHSV( h, 1, 1 );
+					for( i = 0; i < nobjects; i++ ) {
 
-				}
+						h = ( 360 * ( i/nobjects + time ) % 360 ) / 360;
+						//materials[ i ].color.setHSV( h, 0.5 + 0.5 * ( i % 20 / 20 ), 1 );
+						materials[ i ].color.setHSV( h, 1, 1 );
+
+					}
 
+				}
 
 				if ( postprocessing.enabled ) {
 
@@ -299,9 +300,9 @@
 					// Render scene into texture
 
 					if ( singleMaterial )
-						zmaterial[0] = cubeMaterial;
+						zmaterial[ 0 ] = cubeMaterial;
 					else
-						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ materials[i] ];
+						for( i = 0; i < nobjects; i++ ) objects[ i ].materials[ 0 ] = materials[ i ];
 
 
 					renderer.render( scene, camera, postprocessing.rtTextureColor, true );
@@ -309,9 +310,9 @@
 					// Render depth into texture
 
 					if ( singleMaterial )
-						zmaterial[0] = material_depth;
+						zmaterial[ 0 ] = material_depth;
 					else
-						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ material_depth ];
+						for( i = 0; i < nobjects; i++ ) objects[i].materials[ 0 ] = material_depth;
 
 					renderer.render( scene, camera, postprocessing.rtTextureDepth, true );
 

+ 1 - 1
examples/webgl_ribbons.html

@@ -129,7 +129,7 @@
 				for ( j = 0; j < ygrid; j++ ) {
 
 					materials[c] = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } );
-					materials[c].program = material_base.program;
+					//materials[c].program = material_base.program;
 
 					ribbon = new THREE.Ribbon( i % 2 ? geometry : geometry2, materials[c] );
 					ribbon.rotation.x = 0;

+ 3 - 1
examples/webgl_scene_test.html

@@ -304,7 +304,9 @@
 				}
 
 				$( "progress" ).style.display = "block";
-				SceneUtils.loadScene( "scenes/test_scene.js", callback_sync, callback_async, callback_progress );
+
+				var loader = new THREE.SceneLoader();
+				loader.load( "scenes/test_scene.js", callback_sync, callback_async, callback_progress );
 
 				$( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false );
 

+ 4 - 89
examples/webgl_scene_test_blender.html

@@ -148,95 +148,8 @@
 		</div>
 
 		<pre id="log"></pre>
-<!--
+
 		<script type="text/javascript" src="../build/Three.js"></script>
--->
-
-		<script type="text/javascript" src="../src/Three.js"></script>
-		<script type="text/javascript" src="../src/core/Color.js"></script>
-		<script type="text/javascript" src="../src/core/Vector2.js"></script>
-		<script type="text/javascript" src="../src/core/Vector3.js"></script>
-		<script type="text/javascript" src="../src/core/Vector4.js"></script>
-		<script type="text/javascript" src="../src/core/Ray.js"></script>
-		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
-		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
-		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
-		<script type="text/javascript" src="../src/core/Object3D.js"></script>
-		<script type="text/javascript" src="../src/core/Quaternion.js"></script>
-		<script type="text/javascript" src="../src/core/Vertex.js"></script>
-		<script type="text/javascript" src="../src/core/Face3.js"></script>
-		<script type="text/javascript" src="../src/core/Face4.js"></script>
-		<script type="text/javascript" src="../src/core/UV.js"></script>
-		<script type="text/javascript" src="../src/core/Geometry.js"></script>
-		<script type="text/javascript" src="../src/core/Spline.js"></script>
-		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
-		<script type="text/javascript" src="../src/animation/Animation.js"></script>
-		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
-		<script type="text/javascript" src="../src/lights/Light.js"></script>
-		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
-		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
-		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
-		<script type="text/javascript" src="../src/materials/Material.js"></script>
-		<script type="text/javascript" src="../src/materials/Mappings.js"></script>
-		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshLambertMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ShadowVolumeDynamicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/Texture.js"></script>
-		<script type="text/javascript" src="../src/materials/RenderTarget.js"></script>
-		<script type="text/javascript" src="../src/materials/Uniforms.js"></script>
-		<script type="text/javascript" src="../src/objects/Particle.js"></script>
-		<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
-		<script type="text/javascript" src="../src/objects/Line.js"></script>
-		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
-		<script type="text/javascript" src="../src/objects/Bone.js"></script>
-		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
-		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
-		<script type="text/javascript" src="../src/objects/Sound.js"></script>
-		<script type="text/javascript" src="../src/objects/LOD.js"></script>
-		<script type="text/javascript" src="../src/objects/ShadowVolume.js"></script>
-		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
-		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
-		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
-		<script type="text/javascript" src="../src/renderers/Projector.js"></script>
-		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
-		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableVertex.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
-		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/cameras/QuakeCamera.js"></script>
-		<script type="text/javascript" src="../src/extras/cameras/PathCamera.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Cube.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Cylinder.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Icosahedron.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Lathe.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Plane.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Sphere.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Torus.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
-		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
-		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
-		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 		
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
@@ -380,7 +293,9 @@
 				}
 
 				$( "progress" ).style.display = "block";
-				SceneUtils.loadScene( "obj/blenderscene/scene.js", callback_sync, callback_async, callback_progress );
+
+				var loader = new THREE.SceneLoader();
+				loader.load( "obj/blenderscene/scene.js", callback_sync, callback_async, callback_progress );
 
 				$( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false );
 

+ 3 - 1
examples/webgl_shader_lava.html

@@ -90,12 +90,13 @@
 
 		<script id="vertexShader" type="x-shader/x-vertex">
 
+			uniform vec2 uvScale;
 			varying vec2 vUv;
 
 			void main()
 			{
 
-				vUv = vec2( 3.0, 1.0 ) * uv;
+				vUv = uvScale * uv;
 				vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
 				gl_Position = projectionMatrix * mvPosition;
 
@@ -143,6 +144,7 @@
 					fogColor: 	{ type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
 					time: 		{ type: "f", value: 1.0 },
 					resolution: { type: "v2", value: new THREE.Vector2() },
+					uvScale: 	{ type: "v2", value: new THREE.Vector2( 3.0, 1.0 ) },
 					texture1: 	{ type: "t", value: 0, texture: ImageUtils.loadTexture( "textures/lava/cloud.png" ) },
 					texture2: 	{ type: "t", value: 1, texture: ImageUtils.loadTexture( "textures/lava/lavatile.jpg" ) }
 

+ 14 - 0
src/core/Edge.js

@@ -0,0 +1,14 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.Edge = function( v1, v2, vi1, vi2 ) {
+	
+	this.vertices = [ v1, v2 ]; 		// vertex references
+	this.vertexIndices = [ vi1, vi2 ];	// vertex indices
+	
+	this.faces = [];					// face references
+	this.faceIndices = [];				// face indices
+	
+};

+ 105 - 0
src/core/Geometry.js

@@ -14,10 +14,13 @@ THREE.Geometry = function () {
 
 	this.faces = [];
 
+	this.edges = [];
+
 	this.faceUvs = [[]];
 	this.faceVertexUvs = [[]];
 
 	this.morphTargets = [];
+	this.morphColors = [];
 
 	this.skinWeights = [];
 	this.skinIndices = [];
@@ -395,6 +398,108 @@ THREE.Geometry.prototype = {
 
 		this.boundingSphere = { radius: radius };
 
+	},
+
+	computeEdgeFaces: function () {
+
+		function edge_hash( a, b ) {
+
+			return Math.min( a, b ) + "_" + Math.max( a, b );
+
+		};
+
+		function addToMap( map, hash, i ) {
+
+			if ( map[ hash ] === undefined ) {
+
+				map[ hash ] = { "set": {}, "array": [] };
+				map[ hash ].set[ i ] = 1;
+				map[ hash ].array.push( i );
+
+			} else {
+
+				if( map[ hash ].set[ i ] === undefined ) {
+
+					map[ hash ].set[ i ] = 1;
+					map[ hash ].array.push( i );
+
+				}
+
+			}
+
+		};
+
+		var i, il, v1, v2, j, k,
+			face, faceIndices, faceIndex,
+			edge,
+			hash,
+			vfMap = {};
+
+		// construct vertex -> face map
+
+		for( i = 0, il = this.faces.length; i < il; i ++ ) {
+
+			face = this.faces[ i ];
+
+			if ( face instanceof THREE.Face3 ) {
+
+				hash = edge_hash( face.a, face.b );
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.b, face.c );
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.a, face.c );
+				addToMap( vfMap, hash, i );
+
+			} else if ( face instanceof THREE.Face4 ) {
+
+				// in WebGLRenderer quad is tesselated
+				// to triangles: a,b,d / b,c,d
+				// shared edge is: b,d
+
+				// should shared edge be included?
+				// comment out if not
+
+				hash = edge_hash( face.b, face.d ); 
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.a, face.b );
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.a, face.d );
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.b, face.c );
+				addToMap( vfMap, hash, i );
+
+				hash = edge_hash( face.c, face.d );
+				addToMap( vfMap, hash, i );
+
+			}
+
+		}
+
+		// extract faces
+
+		for( i = 0, il = this.edges.length; i < il; i ++ ) {
+
+			edge = this.edges[ i ];
+
+			v1 = edge.vertexIndices[ 0 ];
+			v2 = edge.vertexIndices[ 1 ];
+
+			edge.faceIndices = vfMap[ edge_hash( v1, v2 ) ].array;
+
+			for( j = 0; j < edge.faceIndices.length; j ++ ) {
+
+				faceIndex = edge.faceIndices[ j ];
+				edge.faces.push( this.faces[ faceIndex ] );
+
+			}
+
+		}
+
 	}
 
 };

+ 1 - 1
src/core/Ray.js

@@ -63,7 +63,7 @@ THREE.Ray.prototype = {
 			normal = object.matrixRotationWorld.multiplyVector3( face.normal.clone() );
 			dot = direction.dot( normal );
 
-			if ( dot < 0 ) { // Math.abs( dot ) > 0.0001
+			if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) { // Math.abs( dot ) > 0.0001
 
 				scalar = normal.dot( new THREE.Vector3().sub( a, origin ) ) / dot;
 				intersectPoint = origin.addSelf( direction.multiplyScalar( scalar ) );

+ 0 - 445
src/extras/SceneUtils.js

@@ -4,451 +4,6 @@
 
 var SceneUtils = {
 
-	loadScene : function( url, callback_sync, callback_async, callback_progress ) {
-
-		var worker = new Worker( url );
-		worker.postMessage( 0 );
-
-		var urlBase = THREE.Loader.prototype.extractUrlbase( url );
-		
-		worker.onmessage = function( event ) {
-
-			var dg, dm, dd, dl, dc, df, dt,
-				g, o, m, l, p, c, t, f, tt, pp,
-				geometry, material, camera, fog,
-				texture, images,
-				materials,
-				data, binLoader, jsonLoader,
-				counter_models, counter_textures,
-				total_models, total_textures,
-				result;
-
-			data = event.data;
-			binLoader = new THREE.BinaryLoader();
-			jsonLoader = new THREE.JSONLoader();
-
-			counter_models = 0;
-			counter_textures = 0;
-
-			result = {
-
-				scene: new THREE.Scene(),
-				geometries: {},
-				materials: {},
-				textures: {},
-				objects: {},
-				cameras: {},
-				lights: {},
-				fogs: {}
-
-			};
-
-			function get_url( source_url, url_type ) {
-				
-				if ( url_type == "relativeToHTML" ) {
-					
-					return source_url;
-					
-				} else {
-					
-					return urlBase + "/" + source_url;
-
-				}
-
-			};
-			
-			function handle_objects() {
-
-				for( dd in data.objects ) {
-
-					if ( !result.objects[ dd ] ) {
-
-						o = data.objects[ dd ];
-
-						geometry = result.geometries[ o.geometry ];
-
-						if ( geometry ) {
-
-							materials = [];
-							for( i = 0; i < o.materials.length; i++ ) {
-
-								materials[ i ] = result.materials[ o.materials[i] ];
-
-							}
-
-							p = o.position;
-							r = o.rotation;
-							q = o.quaternion;
-							s = o.scale;
-							
-							// turn off quaternions, for the moment
-							
-							q = 0;
-
-							if ( materials.length == 0 ) {
-								
-								materials[ 0 ] = new THREE.MeshFaceMaterial();
-								
-							}
-							
-							object = new THREE.Mesh( geometry, materials );
-							object.position.set( p[0], p[1], p[2] );
-							
-							if ( q ) {
-								
-								object.quaternion.set( q[0], q[1], q[2], q[3] );
-								object.useQuaternion = true;
-								
-							} else {
-
-								object.rotation.set( r[0], r[1], r[2] );
-								
-							}
-							
-							object.scale.set( s[0], s[1], s[2] );
-							object.visible = o.visible;
-
-							result.scene.addObject( object );
-
-							result.objects[ dd ] = object;
-
-						}
-
-					}
-
-				}
-
-			};
-
-			function handle_mesh( geo, id ) {
-
-				result.geometries[ id ] = geo;
-				handle_objects();
-
-			};
-
-			function create_callback( id ) {
-
-				return function( geo ) {
-
-					handle_mesh( geo, id );
-
-					counter_models -= 1;
-
-					async_callback_gate();
-
-				}
-
-			};
-
-			function async_callback_gate() {
-
-				var progress = {
-
-					total_models: total_models,
-					total_textures: total_textures,
-					loaded_models: total_models - counter_models,
-					loaded_textures: total_textures - counter_textures
-
-				};
-
-				callback_progress( progress, result );
-
-				if( counter_models == 0 && counter_textures == 0 ) {
-
-					callback_async( result );
-
-				}
-
-			};
-
-			var callback_texture = function( images ) {
-
-				counter_textures -= 1;
-				async_callback_gate();
-
-			};
-
-			// first go synchronous elements
-
-			// cameras
-
-			for( dc in data.cameras ) {
-
-				c = data.cameras[ dc ];
-
-				if ( c.type == "perspective" ) {
-
-					camera = new THREE.Camera( c.fov, c.aspect, c.near, c.far );
-
-				} else if ( c.type == "ortho" ) {
-
-					camera = new THREE.Camera();
-					camera.projectionMatrix = THREE.Matrix4.makeOrtho( c.left, c.right, c.top, c.bottom, c.near, c.far );
-
-				}
-
-				p = c.position;
-				t = c.target;
-				camera.position.set( p[0], p[1], p[2] );
-				camera.target.position.set( t[0], t[1], t[2] );
-
-				result.cameras[ dc ] = camera;
-
-			}
-
-			// lights
-
-			var hex, intensity;
-			
-			for( dl in data.lights ) {
-
-				l = data.lights[ dl ];
-
-				hex = ( l.color !== undefined ) ? l.color : 0xffffff;
-				intensity = ( l.intensity !== undefined ) ? l.intensity : 1;
-				
-				if ( l.type == "directional" ) {
-
-					p = l.direction;
-
-					light = new THREE.DirectionalLight( hex, intensity );
-					light.position.set( p[0], p[1], p[2] );
-					light.position.normalize();
-
-				} else if ( l.type == "point" ) {
-
-					p = l.position;
-
-					light = new THREE.PointLight( hex, intensity );
-					light.position.set( p[0], p[1], p[2] );
-
-				}
-
-				result.scene.addLight( light );
-
-				result.lights[ dl ] = light;
-
-			}
-
-			// fogs
-
-			for( df in data.fogs ) {
-
-				f = data.fogs[ df ];
-
-				if ( f.type == "linear" ) {
-
-					fog = new THREE.Fog( 0x000000, f.near, f.far );
-
-				} else if ( f.type == "exp2" ) {
-
-					fog = new THREE.FogExp2( 0x000000, f.density );
-
-				}
-
-				c = f.color;
-				fog.color.setRGB( c[0], c[1], c[2] );
-
-				result.fogs[ df ] = fog;
-
-			}
-
-			// defaults
-
-			if ( result.cameras && data.defaults.camera ) {
-
-				result.currentCamera = result.cameras[ data.defaults.camera ];
-
-			}
-
-			if ( result.fogs && data.defaults.fog ) {
-
-				result.scene.fog = result.fogs[ data.defaults.fog ];
-
-			}
-
-			c = data.defaults.bgcolor;
-			result.bgColor = new THREE.Color();
-			result.bgColor.setRGB( c[0], c[1], c[2] );
-
-			result.bgColorAlpha = data.defaults.bgalpha;
-
-			// now come potentially asynchronous elements
-
-			// geometries
-
-			// count how many models will be loaded asynchronously
-
-			for( dg in data.geometries ) {
-
-				g = data.geometries[ dg ];
-
-				if ( g.type == "bin_mesh" || g.type == "ascii_mesh" ) {
-
-					counter_models += 1;
-
-				}
-
-			}
-
-			total_models = counter_models;
-			
-			for( dg in data.geometries ) {
-
-				g = data.geometries[ dg ];
-
-				if ( g.type == "cube" ) {
-
-					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" ) {
-
-					geometry = new Plane( g.width, g.height, g.segmentsWidth, g.segmentsHeight );
-					result.geometries[ dg ] = geometry;
-
-				} else if ( g.type == "sphere" ) {
-
-					geometry = new Sphere( g.radius, g.segmentsWidth, g.segmentsHeight );
-					result.geometries[ dg ] = geometry;
-
-				} else if ( g.type == "cylinder" ) {
-
-					geometry = new Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
-					result.geometries[ dg ] = geometry;
-
-				} else if ( g.type == "torus" ) {
-
-					geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
-					result.geometries[ dg ] = geometry;
-
-				} else if ( g.type == "icosahedron" ) {
-
-					geometry = new Icosahedron( g.subdivisions );
-					result.geometries[ dg ] = geometry;
-
-				} else if ( g.type == "bin_mesh" ) {
-
-					binLoader.load( { model: get_url( g.url, data.urlBaseType ),
-									  callback: create_callback( dg )
-									} );
-
-				} else if ( g.type == "ascii_mesh" ) {
-
-					jsonLoader.load( { model: get_url( g.url, data.urlBaseType ),
-									   callback: create_callback( dg )
-									} );
-
-				}
-
-			}
-
-			// textures
-
-			// count how many textures will be loaded asynchronously
-
-			for( dt in data.textures ) {
-
-				tt = data.textures[ dt ];
-
-				if( tt.url instanceof Array ) {
-
-					counter_textures += tt.url.length;
-
-				} else {
-
-					counter_textures += 1;
-
-				}
-
-			}
-
-			total_textures = counter_textures;
-
-			for( dt in data.textures ) {
-
-				tt = data.textures[ dt ];
-
-				if ( tt.mapping != undefined && THREE[ tt.mapping ] != undefined  ) {
-
-					tt.mapping = new THREE[ tt.mapping ]();
-
-				}
-				
-				if( tt.url instanceof Array ) {
-				
-					var url_array = [];
-					
-					for( var i = 0; i < tt.url.length; i ++ ) {
-					
-						url_array[ i ] = get_url( tt.url[ i ], data.urlBaseType );
-						
-					}
-					
-					texture = ImageUtils.loadTextureCube( url_array, tt.mapping, callback_texture );
-
-				} else {
-					
-					texture = ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callback_texture );
-
-					if ( THREE[ tt.minFilter ] != undefined )
-						texture.minFilter = THREE[ tt.minFilter ];
-
-					if ( THREE[ tt.magFilter ] != undefined )
-						texture.magFilter = THREE[ tt.magFilter ];
-
-				}
-
-				result.textures[ dt ] = texture;
-
-			}
-
-			// materials
-
-			for( dm in data.materials ) {
-
-				m = data.materials[ dm ];
-
-				for( pp in m.parameters ) {
-
-					if ( pp == "envMap" || pp == "map" || pp == "lightMap" ) {
-
-						m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ];
-
-					} else if ( pp == "shading" ) {
-
-						m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
-
-					} else if ( pp == "blending" ) {
-
-						m.parameters[ pp ] = THREE[ m.parameters[ pp ] ] ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending;
-
-					} else if ( pp == "combine" ) {
-
-						m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation;
-
-					}
-
-				}
-
-				material = new THREE[ m.type ]( m.parameters );
-				result.materials[ dm ] = material;
-
-			}
-
-			// objects ( synchronous init of procedural primitives )
-
-			handle_objects();
-
-			// synchronous callback
-
-			callback_sync( result );
-
-		};
-
-	},
-
 	addMesh : function ( scene, geometry, scale, x, y, z, rx, ry, rz, material ) {
 
 		var mesh = new THREE.Mesh( geometry, material );

+ 44 - 23
src/extras/cameras/QuakeCamera.js

@@ -91,6 +91,7 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.moveBackward = false;
 	this.moveLeft = false;
 	this.moveRight = false;
+	this.freeze = false;
 
 	this.mouseDragOn = false;
 
@@ -159,6 +160,8 @@ THREE.QuakeCamera = function ( parameters ) {
 
 			case 39: /*right*/
 			case 68: /*D*/ this.moveRight = true; break;
+			
+			case 81: this.freeze = !this.freeze; break;
 
 		}
 
@@ -186,30 +189,48 @@ THREE.QuakeCamera = function ( parameters ) {
 
 	this.update = function() {
 
-		if ( this.heightSpeed ) {
-
-			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 ) );
-		if ( this.moveBackward ) this.translateZ( this.movementSpeed );
-		if ( this.moveLeft ) this.translateX( - this.movementSpeed );
-		if ( this.moveRight ) this.translateX( this.movementSpeed );
-
-		var actualLookSpeed = this.lookSpeed;
-
-		if ( !this.activeLook ) {
-
-			actualLookSpeed = 0;
+		if ( !this.freeze ) {
+			
 
+			if ( this.heightSpeed ) {
+	
+				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 ) );
+			if ( this.moveBackward ) this.translateZ( this.movementSpeed );
+			if ( this.moveLeft ) this.translateX( - this.movementSpeed );
+			if ( this.moveRight ) this.translateX( this.movementSpeed );
+	
+			var actualLookSpeed = this.lookSpeed;
+	
+			if ( !this.activeLook ) {
+	
+				actualLookSpeed = 0;
+	
+			}
+	
+			this.lon += this.mouseX * actualLookSpeed;
+			if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed;
+	
+			this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
+			this.phi = ( 90 - this.lat ) * Math.PI / 180;
+			this.theta = this.lon * Math.PI / 180;
+	
+			var targetPosition = this.target.position,
+				position = this.position;
+	
+			targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
+			targetPosition.y = position.y + 100 * Math.cos( this.phi );
+			targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
 		}
 
 		this.lon += this.mouseX * actualLookSpeed;

+ 55 - 5
src/extras/io/JSONLoader.js

@@ -53,9 +53,11 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 	init_skin();
 	init_morphing();
+	init_edges();
 
 	geometry.computeCentroids();
 	geometry.computeFaceNormals();
+	geometry.computeEdgeFaces();
 
 	function parse() {
 
@@ -94,6 +96,8 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 		normals = json.normals,
 		colors = json.colors,
 
+		scale = ( json.scale !== undefined ) ? json.scale : 1.0,
+		
 		nUvLayers = 0;
 
 		// disregard empty arrays
@@ -118,9 +122,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 			vertex = new THREE.Vertex();
 
-			vertex.position.x = vertices[ offset ++ ];
-			vertex.position.y = vertices[ offset ++ ];
-			vertex.position.z = vertices[ offset ++ ];
+			vertex.position.x = vertices[ offset ++ ] / scale;
+			vertex.position.y = vertices[ offset ++ ] / scale;
+			vertex.position.z = vertices[ offset ++ ] / scale;
 
 			geometry.vertices.push( vertex );
 
@@ -256,7 +260,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 			if ( hasFaceColor ) {
 
-				color = new THREE.Color( faces[ offset ++ ] );
+				colorIndex = faces[ offset ++ ];
+
+				color = new THREE.Color( colors[ colorIndex ] );
 				face.color = color;
 
 			}
@@ -324,7 +330,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 		if( json.morphTargets !== undefined ) {
 
-			var i, l, v, vl;
+			var i, l, v, vl, dstVertices, srcVertices;
 
 			for( i = 0, l = json.morphTargets.length; i < l; i++ ) {
 
@@ -344,6 +350,50 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 			} 
 
 		}
+		
+		if( json.morphColors !== undefined ) {
+
+			var i, l, c, cl, dstColors, srcColors, color;
+
+			for( i = 0, l = json.morphColors.length; i < l; i++ ) {
+
+				geometry.morphColors[ i ] = {};
+				geometry.morphColors[ i ].name = json.morphColors[ i ].name;
+				geometry.morphColors[ i ].colors = [];
+
+				dstColors = geometry.morphColors[ i ].colors;
+				srcColors = json.morphColors [ i ].colors;
+
+				for( c = 0, cl = srcColors.length; c < cl; c += 3 ) {
+
+					color = new THREE.Color( 0xffaa00 );
+					color.setRGB( srcColors[ v ], srcColors[ v + 1 ], srcColors[ v + 2 ] );
+					dstColors.push( color );
+
+				}
+
+			} 
+
+		}
+
+	};
+
+	function init_edges() {
+
+		if( json.edges !== undefined ) {
+
+			var i, il, v1, v2;
+
+			for ( i = 0; i < json.edges.length; i+= 2 ) {
+
+				v1 = json.edges[ i ];
+				v2 = json.edges[ i + 1 ];
+
+				geometry.edges.push( new THREE.Edge( geometry.vertices[ v1 ], geometry.vertices[ v2 ], v1, v2 ) );
+
+			}
+
+		}
 
 	};
 

+ 25 - 9
src/extras/io/Loader.js

@@ -120,14 +120,16 @@ THREE.Loader.prototype = {
 
 		}
 
-		var material, mtype, mpars, texture, color;
+		var material, mtype, mpars, texture, color, vertexColors;
 
 		// defaults
 
 		mtype = "MeshLambertMaterial";
 
-		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, vertexColors: m.vertexColors ? THREE.VertexColors : false, wireframe: m.wireframe };
-		
+		// vertexColors
+
+		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, wireframe: m.wireframe };
+
 		// parameters from model file
 
 		if ( m.shading ) {
@@ -136,27 +138,41 @@ THREE.Loader.prototype = {
 			else if ( m.shading == "Basic" ) mtype = "MeshBasicMaterial";
 
 		}
-		
+
 		if ( m.blending ) {
-			
+
 			if ( m.blending == "Additive" ) mpars.blending = THREE.AdditiveBlending;
 			else if ( m.blending == "Subtractive" ) mpars.blending = THREE.SubtractiveBlending;
 			else if ( m.blending == "Multiply" ) mpars.blending = THREE.MultiplyBlending;
 
 		}
-		
+
 		if ( m.transparent !== undefined ) {
-			
+
 			mpars.transparent = m.transparent;
 
 		}
 
 		if ( m.depthTest !== undefined ) {
-			
+
 			mpars.depthTest = m.depthTest;
 
 		}
-		
+
+		if ( m.vertexColors !== undefined ) {
+
+			if ( m.vertexColors == "face" ) {
+
+				mpars.vertexColors = THREE.FaceColors;
+
+			} else if ( m.vertexColors ) {
+
+				mpars.vertexColors = THREE.VertexColors;
+
+			}
+
+		}
+
 		if ( m.mapDiffuse && texture_path ) {
 
 			texture = document.createElement( 'canvas' );

+ 455 - 0
src/extras/io/SceneLoader.js

@@ -0,0 +1,455 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.SceneLoader = function ( ) {
+};
+
+THREE.SceneLoader.prototype = {
+
+	load : function( url, callback_sync, callback_async, callback_progress ) {
+
+		var worker = new Worker( url );
+		worker.postMessage( 0 );
+
+		var urlBase = THREE.Loader.prototype.extractUrlbase( url );
+		
+		worker.onmessage = function( event ) {
+
+			var dg, dm, dd, dl, dc, df, dt,
+				g, o, m, l, p, c, t, f, tt, pp,
+				geometry, material, camera, fog,
+				texture, images,
+				materials,
+				data, binLoader, jsonLoader,
+				counter_models, counter_textures,
+				total_models, total_textures,
+				result;
+
+			data = event.data;
+			binLoader = new THREE.BinaryLoader();
+			jsonLoader = new THREE.JSONLoader();
+
+			counter_models = 0;
+			counter_textures = 0;
+
+			result = {
+
+				scene: new THREE.Scene(),
+				geometries: {},
+				materials: {},
+				textures: {},
+				objects: {},
+				cameras: {},
+				lights: {},
+				fogs: {}
+
+			};
+
+			function get_url( source_url, url_type ) {
+				
+				if ( url_type == "relativeToHTML" ) {
+					
+					return source_url;
+					
+				} else {
+					
+					return urlBase + "/" + source_url;
+
+				}
+
+			};
+			
+			function handle_objects() {
+
+				for( dd in data.objects ) {
+
+					if ( !result.objects[ dd ] ) {
+
+						o = data.objects[ dd ];
+
+						geometry = result.geometries[ o.geometry ];
+
+						if ( geometry ) {
+
+							materials = [];
+							for( i = 0; i < o.materials.length; i++ ) {
+
+								materials[ i ] = result.materials[ o.materials[i] ];
+
+							}
+
+							p = o.position;
+							r = o.rotation;
+							q = o.quaternion;
+							s = o.scale;
+							
+							// turn off quaternions, for the moment
+							
+							q = 0;
+
+							if ( materials.length == 0 ) {
+								
+								materials[ 0 ] = new THREE.MeshFaceMaterial();
+								
+							}
+							
+							object = new THREE.Mesh( geometry, materials );
+							object.position.set( p[0], p[1], p[2] );
+							
+							if ( q ) {
+								
+								object.quaternion.set( q[0], q[1], q[2], q[3] );
+								object.useQuaternion = true;
+								
+							} else {
+
+								object.rotation.set( r[0], r[1], r[2] );
+								
+							}
+							
+							object.scale.set( s[0], s[1], s[2] );
+							object.visible = o.visible;
+
+							result.scene.addObject( object );
+
+							result.objects[ dd ] = object;
+
+						}
+
+					}
+
+				}
+
+			};
+
+			function handle_mesh( geo, id ) {
+
+				result.geometries[ id ] = geo;
+				handle_objects();
+
+			};
+
+			function create_callback( id ) {
+
+				return function( geo ) {
+
+					handle_mesh( geo, id );
+
+					counter_models -= 1;
+
+					async_callback_gate();
+
+				}
+
+			};
+
+			function async_callback_gate() {
+
+				var progress = {
+
+					total_models: total_models,
+					total_textures: total_textures,
+					loaded_models: total_models - counter_models,
+					loaded_textures: total_textures - counter_textures
+
+				};
+
+				callback_progress( progress, result );
+
+				if( counter_models == 0 && counter_textures == 0 ) {
+
+					callback_async( result );
+
+				}
+
+			};
+
+			var callback_texture = function( images ) {
+
+				counter_textures -= 1;
+				async_callback_gate();
+
+			};
+
+			// first go synchronous elements
+
+			// cameras
+
+			for( dc in data.cameras ) {
+
+				c = data.cameras[ dc ];
+
+				if ( c.type == "perspective" ) {
+
+					camera = new THREE.Camera( c.fov, c.aspect, c.near, c.far );
+
+				} else if ( c.type == "ortho" ) {
+
+					camera = new THREE.Camera();
+					camera.projectionMatrix = THREE.Matrix4.makeOrtho( c.left, c.right, c.top, c.bottom, c.near, c.far );
+
+				}
+
+				p = c.position;
+				t = c.target;
+				camera.position.set( p[0], p[1], p[2] );
+				camera.target.position.set( t[0], t[1], t[2] );
+
+				result.cameras[ dc ] = camera;
+
+			}
+
+			// lights
+
+			var hex, intensity;
+			
+			for( dl in data.lights ) {
+
+				l = data.lights[ dl ];
+
+				hex = ( l.color !== undefined ) ? l.color : 0xffffff;
+				intensity = ( l.intensity !== undefined ) ? l.intensity : 1;
+				
+				if ( l.type == "directional" ) {
+
+					p = l.direction;
+
+					light = new THREE.DirectionalLight( hex, intensity );
+					light.position.set( p[0], p[1], p[2] );
+					light.position.normalize();
+
+				} else if ( l.type == "point" ) {
+
+					p = l.position;
+
+					light = new THREE.PointLight( hex, intensity );
+					light.position.set( p[0], p[1], p[2] );
+
+				}
+
+				result.scene.addLight( light );
+
+				result.lights[ dl ] = light;
+
+			}
+
+			// fogs
+
+			for( df in data.fogs ) {
+
+				f = data.fogs[ df ];
+
+				if ( f.type == "linear" ) {
+
+					fog = new THREE.Fog( 0x000000, f.near, f.far );
+
+				} else if ( f.type == "exp2" ) {
+
+					fog = new THREE.FogExp2( 0x000000, f.density );
+
+				}
+
+				c = f.color;
+				fog.color.setRGB( c[0], c[1], c[2] );
+
+				result.fogs[ df ] = fog;
+
+			}
+
+			// defaults
+
+			if ( result.cameras && data.defaults.camera ) {
+
+				result.currentCamera = result.cameras[ data.defaults.camera ];
+
+			}
+
+			if ( result.fogs && data.defaults.fog ) {
+
+				result.scene.fog = result.fogs[ data.defaults.fog ];
+
+			}
+
+			c = data.defaults.bgcolor;
+			result.bgColor = new THREE.Color();
+			result.bgColor.setRGB( c[0], c[1], c[2] );
+
+			result.bgColorAlpha = data.defaults.bgalpha;
+
+			// now come potentially asynchronous elements
+
+			// geometries
+
+			// count how many models will be loaded asynchronously
+
+			for( dg in data.geometries ) {
+
+				g = data.geometries[ dg ];
+
+				if ( g.type == "bin_mesh" || g.type == "ascii_mesh" ) {
+
+					counter_models += 1;
+
+				}
+
+			}
+
+			total_models = counter_models;
+			
+			for( dg in data.geometries ) {
+
+				g = data.geometries[ dg ];
+
+				if ( g.type == "cube" ) {
+
+					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" ) {
+
+					geometry = new Plane( g.width, g.height, g.segmentsWidth, g.segmentsHeight );
+					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "sphere" ) {
+
+					geometry = new Sphere( g.radius, g.segmentsWidth, g.segmentsHeight );
+					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "cylinder" ) {
+
+					geometry = new Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
+					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "torus" ) {
+
+					geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
+					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "icosahedron" ) {
+
+					geometry = new Icosahedron( g.subdivisions );
+					result.geometries[ dg ] = geometry;
+
+				} else if ( g.type == "bin_mesh" ) {
+
+					binLoader.load( { model: get_url( g.url, data.urlBaseType ),
+									  callback: create_callback( dg )
+									} );
+
+				} else if ( g.type == "ascii_mesh" ) {
+
+					jsonLoader.load( { model: get_url( g.url, data.urlBaseType ),
+									   callback: create_callback( dg )
+									} );
+
+				}
+
+			}
+
+			// textures
+
+			// count how many textures will be loaded asynchronously
+
+			for( dt in data.textures ) {
+
+				tt = data.textures[ dt ];
+
+				if( tt.url instanceof Array ) {
+
+					counter_textures += tt.url.length;
+
+				} else {
+
+					counter_textures += 1;
+
+				}
+
+			}
+
+			total_textures = counter_textures;
+
+			for( dt in data.textures ) {
+
+				tt = data.textures[ dt ];
+
+				if ( tt.mapping != undefined && THREE[ tt.mapping ] != undefined  ) {
+
+					tt.mapping = new THREE[ tt.mapping ]();
+
+				}
+				
+				if( tt.url instanceof Array ) {
+				
+					var url_array = [];
+					
+					for( var i = 0; i < tt.url.length; i ++ ) {
+					
+						url_array[ i ] = get_url( tt.url[ i ], data.urlBaseType );
+						
+					}
+					
+					texture = ImageUtils.loadTextureCube( url_array, tt.mapping, callback_texture );
+
+				} else {
+					
+					texture = ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callback_texture );
+
+					if ( THREE[ tt.minFilter ] != undefined )
+						texture.minFilter = THREE[ tt.minFilter ];
+
+					if ( THREE[ tt.magFilter ] != undefined )
+						texture.magFilter = THREE[ tt.magFilter ];
+
+				}
+
+				result.textures[ dt ] = texture;
+
+			}
+
+			// materials
+
+			for( dm in data.materials ) {
+
+				m = data.materials[ dm ];
+
+				for( pp in m.parameters ) {
+
+					if ( pp == "envMap" || pp == "map" || pp == "lightMap" ) {
+
+						m.parameters[ pp ] = result.textures[ m.parameters[ pp ] ];
+
+					} else if ( pp == "shading" ) {
+
+						m.parameters[ pp ] = ( m.parameters[ pp ] == "flat" ) ? THREE.FlatShading : THREE.SmoothShading;
+
+					} else if ( pp == "blending" ) {
+
+						m.parameters[ pp ] = THREE[ m.parameters[ pp ] ] ? THREE[ m.parameters[ pp ] ] : THREE.NormalBlending;
+
+					} else if ( pp == "combine" ) {
+
+						m.parameters[ pp ] = ( m.parameters[ pp ] == "MixOperation" ) ? THREE.MixOperation : THREE.MultiplyOperation;
+
+					}
+
+				}
+
+				material = new THREE[ m.type ]( m.parameters );
+				result.materials[ dm ] = material;
+
+			}
+
+			// objects ( synchronous init of procedural primitives )
+
+			handle_objects();
+
+			// synchronous callback
+
+			callback_sync( result );
+
+		};
+
+	}
+
+};

+ 1 - 0
src/materials/MeshShaderMaterial.js

@@ -37,6 +37,7 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 	this.wireframe = parameters.wireframe !== undefined ? parameters.wireframe : false;
 	this.wireframeLinewidth = parameters.wireframeLinewidth !== undefined ? parameters.wireframeLinewidth : 1;
 
+	this.fog = parameters.fog !== undefined ? parameters.fog : false; // set to use scene fog
 	this.lights = parameters.lights !== undefined ? parameters.lights : false; // set to use scene lights
 	this.vertexColors = parameters.vertexColors !== undefined ? parameters.vertexColors : false; // set to use "color" attribute stream
 	this.skinning = parameters.skinning !== undefined ? parameters.skinning : false; // set to use skinning attribute streams

+ 3 - 1
src/objects/ShadowVolume.js

@@ -8,6 +8,7 @@ THREE.ShadowVolume = function( mesh, isStatic ) {
 	mesh.addChild( this );
 
 	this.calculateShadowVolumeGeometry( mesh.geometry );
+
 }
 
 THREE.ShadowVolume.prototype             = new THREE.Mesh();
@@ -39,7 +40,7 @@ THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function( originalG
 	var	fl               = originalFaces.length;
 	
 	var	originalFace, face, i, f, n, vertex, numVertices;
-	var indices = [ "a", "b", "c", "d" ];
+	var indices = [ "a", "b", "c", "d" ];
 
 
 	for( f = 0; f < fl; f++ ) {
@@ -56,6 +57,7 @@ THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function( originalG
 			
           	n = 3;
 			face = new THREE.Face3( numVertices, numVertices + 1, numVertices + 2 );
+
 		}
 
 		face.normal.copy( originalFace.normal );

+ 3 - 0
src/renderers/WebGLRenderTarget.js

@@ -17,5 +17,8 @@ THREE.WebGLRenderTarget = function ( width, height, options ) {
 
 	this.format = options.format !== undefined ? options.format : THREE.RGBFormat;
 	this.type = options.type !== undefined ? options.type : THREE.UnsignedByteType;
+	
+	this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;
+	this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
 
 };

+ 299 - 102
src/renderers/WebGLRenderer.js

@@ -105,10 +105,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_stencilShadow.faces    = new Uint16Array( 6 );
 		_stencilShadow.darkness = 0.5;
 
-		_stencilShadow.vertices[ 0 * 3 + 0 ] = -2; _stencilShadow.vertices[ 0 * 3 + 1 ] = -1; _stencilShadow.vertices[ 0 * 3 + 2 ] = -1;
-		_stencilShadow.vertices[ 1 * 3 + 0 ] =  2; _stencilShadow.vertices[ 1 * 3 + 1 ] = -1; _stencilShadow.vertices[ 1 * 3 + 2 ] = -1;
-		_stencilShadow.vertices[ 2 * 3 + 0 ] =  2; _stencilShadow.vertices[ 2 * 3 + 1 ] =  1; _stencilShadow.vertices[ 2 * 3 + 2 ] = -1;
-		_stencilShadow.vertices[ 3 * 3 + 0 ] = -2; _stencilShadow.vertices[ 3 * 3 + 1 ] =  1; _stencilShadow.vertices[ 3 * 3 + 2 ] = -1;
+		_stencilShadow.vertices[ 0 * 3 + 0 ] = -20; _stencilShadow.vertices[ 0 * 3 + 1 ] = -20; _stencilShadow.vertices[ 0 * 3 + 2 ] = -1;
+		_stencilShadow.vertices[ 1 * 3 + 0 ] =  20; _stencilShadow.vertices[ 1 * 3 + 1 ] = -20; _stencilShadow.vertices[ 1 * 3 + 2 ] = -1;
+		_stencilShadow.vertices[ 2 * 3 + 0 ] =  20; _stencilShadow.vertices[ 2 * 3 + 1 ] =  20; _stencilShadow.vertices[ 2 * 3 + 2 ] = -1;
+		_stencilShadow.vertices[ 3 * 3 + 0 ] = -20; _stencilShadow.vertices[ 3 * 3 + 1 ] =  20; _stencilShadow.vertices[ 3 * 3 + 2 ] = -1;
 
 		_stencilShadow.faces[ 0 ] = 0; _stencilShadow.faces[ 1 ] = 1; _stencilShadow.faces[ 2 ] = 2;
 		_stencilShadow.faces[ 3 ] = 0; _stencilShadow.faces[ 4 ] = 2; _stencilShadow.faces[ 5 ] = 3;
@@ -616,6 +616,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		offset_skin = 0,
 		offset_morphTarget = 0,
 		offset_custom = 0,
+		offset_customSrc = 0,
 
 		vertexArray = geometryGroup.__vertexArray,
 		uvArray = geometryGroup.__uvArray,
@@ -675,6 +676,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			for ( a in customAttributes ) {
 
 				customAttributes[ a ].offset = 0;
+				customAttributes[ a ].offsetSrc = 0;
 
 			}
 
@@ -739,27 +741,70 @@ THREE.WebGLRenderer = function ( parameters ) {
 						if ( customAttribute.needsUpdate ) {
 
 							offset_custom = customAttribute.offset;
+							offset_customSrc = customAttribute.offsetSrc;
 
 							if( customAttribute.size === 1 ) {
 
-								customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
-								customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
-								customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
+								if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
+									
+								} else if( customAttribute.boundTo === "faces" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
+
+									customAttribute.offsetSrc++;
+								
+								} else if( customAttribute.boundTo === "faceVertices" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc + 0 ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc + 1 ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 2 ];
+									
+									customAttribute.offsetSrc += 3;
+	
+								}
 
 								customAttribute.offset += 3;
 
 							} else {
 
-								v1 = customAttribute.value[ face.a ];
-								v2 = customAttribute.value[ face.b ];
-								v3 = customAttribute.value[ face.c ];
+								if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
+									
+									v1 = customAttribute.value[ face.a ];
+									v2 = customAttribute.value[ face.b ];
+									v3 = customAttribute.value[ face.c ];
+									
+								} else if( customAttribute.boundTo === "faces" ) {
+									
+									v1 = customAttribute.value[ offset_customSrc ];
+									v2 = customAttribute.value[ offset_customSrc ];
+									v3 = customAttribute.value[ offset_customSrc ];
+
+									customAttribute.offsetSrc++;
+									
+								} else if( customAttribute.boundTo === "faceVertices" ) {
+									
+									v1 = customAttribute.value[ offset_customSrc + 0 ];
+									v2 = customAttribute.value[ offset_customSrc + 1 ];
+									v3 = customAttribute.value[ offset_customSrc + 2 ];
+									
+									customAttribute.offsetSrc += 3;
+								}
+								
 
 								if( customAttribute.size === 2 ) {
 
 									customAttribute.array[ offset_custom + 0 ] = v1.x;
 									customAttribute.array[ offset_custom + 1 ] = v1.y;
+
 									customAttribute.array[ offset_custom + 2 ] = v2.x;
 									customAttribute.array[ offset_custom + 3 ] = v2.y;
+
 									customAttribute.array[ offset_custom + 4 ] = v3.x;
 									customAttribute.array[ offset_custom + 5 ] = v3.y;
 
@@ -767,15 +812,35 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 								} else if( customAttribute.size === 3 ) {
 
-									customAttribute.array[ offset_custom + 0 ] = v1.x;
-									customAttribute.array[ offset_custom + 1 ] = v1.y;
-									customAttribute.array[ offset_custom + 2 ] = v1.z;
-									customAttribute.array[ offset_custom + 3 ] = v2.x;
-									customAttribute.array[ offset_custom + 4 ] = v2.y;
-									customAttribute.array[ offset_custom + 5 ] = v2.z;
-									customAttribute.array[ offset_custom + 6 ] = v3.x;
-									customAttribute.array[ offset_custom + 7 ] = v3.y;
-									customAttribute.array[ offset_custom + 8 ] = v3.z;
+									if( customAttribute.type === "c" ) {
+										
+										customAttribute.array[ offset_custom + 0 ] = v1.r;
+										customAttribute.array[ offset_custom + 1 ] = v1.g;
+										customAttribute.array[ offset_custom + 2 ] = v1.b;
+
+										customAttribute.array[ offset_custom + 3 ] = v2.r;
+										customAttribute.array[ offset_custom + 4 ] = v2.g;
+										customAttribute.array[ offset_custom + 5 ] = v2.b;
+
+										customAttribute.array[ offset_custom + 6 ] = v3.r;
+										customAttribute.array[ offset_custom + 7 ] = v3.g;
+										customAttribute.array[ offset_custom + 8 ] = v3.b;
+										
+									} else {
+										
+										customAttribute.array[ offset_custom + 0 ] = v1.x;
+										customAttribute.array[ offset_custom + 1 ] = v1.y;
+										customAttribute.array[ offset_custom + 2 ] = v1.z;
+
+										customAttribute.array[ offset_custom + 3 ] = v2.x;
+										customAttribute.array[ offset_custom + 4 ] = v2.y;
+										customAttribute.array[ offset_custom + 5 ] = v2.z;
+
+										customAttribute.array[ offset_custom + 6 ] = v3.x;
+										customAttribute.array[ offset_custom + 7 ] = v3.y;
+										customAttribute.array[ offset_custom + 8 ] = v3.z;
+										
+									}
 
 									customAttribute.offset += 9;
 
@@ -785,10 +850,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 									customAttribute.array[ offset_custom + 1  ] = v1.y;
 									customAttribute.array[ offset_custom + 2  ] = v1.z;
 									customAttribute.array[ offset_custom + 3  ] = v1.w;
+
 									customAttribute.array[ offset_custom + 4  ] = v2.x;
 									customAttribute.array[ offset_custom + 5  ] = v2.y;
 									customAttribute.array[ offset_custom + 6  ] = v2.z;
 									customAttribute.array[ offset_custom + 7  ] = v2.w;
+
 									customAttribute.array[ offset_custom + 8  ] = v3.x;
 									customAttribute.array[ offset_custom + 9  ] = v3.y;
 									customAttribute.array[ offset_custom + 10 ] = v3.z;
@@ -1088,7 +1155,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					vertexArray[ offset + 7 ] = v3.y;
 					vertexArray[ offset + 8 ] = v3.z;
 
-					vertexArray[ offset + 9 ] = v4.x;
+					vertexArray[ offset + 9 ]  = v4.x;
 					vertexArray[ offset + 10 ] = v4.y;
 					vertexArray[ offset + 11 ] = v4.z;
 
@@ -1105,31 +1172,78 @@ THREE.WebGLRenderer = function ( parameters ) {
 						if ( customAttribute.needsUpdate ) {
 
 							offset_custom = customAttribute.offset;
+							offset_customSrc = customAttribute.offsetSrc;
 
 							if( customAttribute.size === 1 ) {
 
-								customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
-								customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
-								customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
-								customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.d ];
+								if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ face.a ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ face.b ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.c ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ face.d ];
+									
+								} else if( customAttribute.boundTo === "faces" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc ];
+
+									customAttribute.offsetSrc++;
+									
+								} else if( customAttribute.boundTo === "faceVertices" ) {
+									
+									customAttribute.array[ offset_custom + 0 ] = customAttribute.value[ offset_customSrc + 0 ];
+									customAttribute.array[ offset_custom + 1 ] = customAttribute.value[ offset_customSrc + 1 ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 2 ];
+									customAttribute.array[ offset_custom + 2 ] = customAttribute.value[ offset_customSrc + 3 ];
+									
+									customAttribute.offsetSrc += 4;
+								}
 
 								customAttribute.offset += 4;
 
 							} else {
 
-								v1 = customAttribute.value[ face.a ];
-								v2 = customAttribute.value[ face.b ];
-								v3 = customAttribute.value[ face.c ];
-								v4 = customAttribute.value[ face.d ];
+								if( customAttribute.boundTo === undefined || customAttribute.boundTo === "vertices" ) {
+									
+									v1 = customAttribute.value[ face.a ];
+									v2 = customAttribute.value[ face.b ];
+									v3 = customAttribute.value[ face.c ];
+									v4 = customAttribute.value[ face.d ];
+									
+								} else if( customAttribute.boundTo === "faces" ) {
+									
+									v1 = customAttribute.value[ offset_customSrc ];
+									v2 = customAttribute.value[ offset_customSrc ];
+									v3 = customAttribute.value[ offset_customSrc ];
+									v4 = customAttribute.value[ offset_customSrc ];
+
+									customAttribute.offsetSrc++;
+									
+								} else if( customAttribute.boundTo === "faceVertices" ) {
+									
+									v1 = customAttribute.value[ offset_customSrc + 0 ];
+									v2 = customAttribute.value[ offset_customSrc + 1 ];
+									v3 = customAttribute.value[ offset_customSrc + 2 ];
+									v4 = customAttribute.value[ offset_customSrc + 3 ];
+									
+									customAttribute.offsetSrc += 4;
+								}
+
 
 								if( customAttribute.size === 2 ) {
 
 									customAttribute.array[ offset_custom + 0 ] = v1.x;
 									customAttribute.array[ offset_custom + 1 ] = v1.y;
+
 									customAttribute.array[ offset_custom + 2 ] = v2.x;
 									customAttribute.array[ offset_custom + 3 ] = v2.y;
+
 									customAttribute.array[ offset_custom + 4 ] = v3.x;
 									customAttribute.array[ offset_custom + 5 ] = v3.y;
+
 									customAttribute.array[ offset_custom + 6 ] = v4.x;
 									customAttribute.array[ offset_custom + 7 ] = v4.y;
 
@@ -1137,18 +1251,43 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 								} else if( customAttribute.size === 3 ) {
 
-									customAttribute.array[ offset_custom + 0  ] = v1.x;
-									customAttribute.array[ offset_custom + 1  ] = v1.y;
-									customAttribute.array[ offset_custom + 2  ] = v1.z;
-									customAttribute.array[ offset_custom + 3  ] = v2.x;
-									customAttribute.array[ offset_custom + 4  ] = v2.y;
-									customAttribute.array[ offset_custom + 5  ] = v2.z;
-									customAttribute.array[ offset_custom + 6  ] = v3.x;
-									customAttribute.array[ offset_custom + 7  ] = v3.y;
-									customAttribute.array[ offset_custom + 8  ] = v3.z;
-									customAttribute.array[ offset_custom + 9  ] = v4.x;
-									customAttribute.array[ offset_custom + 10 ] = v4.y;
-									customAttribute.array[ offset_custom + 11 ] = v4.z;
+									if( customAttribute.type === "c" ) {
+										
+										customAttribute.array[ offset_custom + 0  ] = v1.r;
+										customAttribute.array[ offset_custom + 1  ] = v1.g;
+										customAttribute.array[ offset_custom + 2  ] = v1.b;
+
+										customAttribute.array[ offset_custom + 3  ] = v2.r;
+										customAttribute.array[ offset_custom + 4  ] = v2.g;
+										customAttribute.array[ offset_custom + 5  ] = v2.b;
+
+										customAttribute.array[ offset_custom + 6  ] = v3.r;
+										customAttribute.array[ offset_custom + 7  ] = v3.g;
+										customAttribute.array[ offset_custom + 8  ] = v3.b;
+
+										customAttribute.array[ offset_custom + 9  ] = v4.r;
+										customAttribute.array[ offset_custom + 10 ] = v4.g;
+										customAttribute.array[ offset_custom + 11 ] = v4.b;
+
+									} else {
+										
+										customAttribute.array[ offset_custom + 0  ] = v1.x;
+										customAttribute.array[ offset_custom + 1  ] = v1.y;
+										customAttribute.array[ offset_custom + 2  ] = v1.z;
+
+										customAttribute.array[ offset_custom + 3  ] = v2.x;
+										customAttribute.array[ offset_custom + 4  ] = v2.y;
+										customAttribute.array[ offset_custom + 5  ] = v2.z;
+
+										customAttribute.array[ offset_custom + 6  ] = v3.x;
+										customAttribute.array[ offset_custom + 7  ] = v3.y;
+										customAttribute.array[ offset_custom + 8  ] = v3.z;
+
+										customAttribute.array[ offset_custom + 9  ] = v4.x;
+										customAttribute.array[ offset_custom + 10 ] = v4.y;
+										customAttribute.array[ offset_custom + 11 ] = v4.z;
+										
+									}
 
 									customAttribute.offset += 12;
 
@@ -1158,14 +1297,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 									customAttribute.array[ offset_custom + 1  ] = v1.y;
 									customAttribute.array[ offset_custom + 2  ] = v1.z;
 									customAttribute.array[ offset_custom + 3  ] = v1.w;
+
 									customAttribute.array[ offset_custom + 4  ] = v2.x;
 									customAttribute.array[ offset_custom + 5  ] = v2.y;
 									customAttribute.array[ offset_custom + 6  ] = v2.z;
 									customAttribute.array[ offset_custom + 7  ] = v2.w;
+
 									customAttribute.array[ offset_custom + 8  ] = v3.x;
 									customAttribute.array[ offset_custom + 9  ] = v3.y;
 									customAttribute.array[ offset_custom + 10 ] = v3.z;
 									customAttribute.array[ offset_custom + 11 ] = v3.w;
+
 									customAttribute.array[ offset_custom + 12 ] = v4.x;
 									customAttribute.array[ offset_custom + 13 ] = v4.y;
 									customAttribute.array[ offset_custom + 14 ] = v4.z;
@@ -1321,8 +1463,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 					skinVertexBArray[ offset_skin + 10 ] = sb3.z;
 					skinVertexBArray[ offset_skin + 11 ] = 1;
 
-					skinVertexBArray[ offset_skin + 12 ]  = sb4.x;
-					skinVertexBArray[ offset_skin + 13 ]  = sb4.y;
+					skinVertexBArray[ offset_skin + 12 ] = sb4.x;
+					skinVertexBArray[ offset_skin + 13 ] = sb4.y;
 					skinVertexBArray[ offset_skin + 14 ] = sb4.z;
 					skinVertexBArray[ offset_skin + 15 ] = 1;
 
@@ -1385,8 +1527,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 					tangentArray[ offset_tangent + 6 ] = t2.z;
 					tangentArray[ offset_tangent + 7 ] = t2.w;
 
-					tangentArray[ offset_tangent + 8 ] = t3.x;
-					tangentArray[ offset_tangent + 9 ] = t3.y;
+					tangentArray[ offset_tangent + 8 ]  = t3.x;
+					tangentArray[ offset_tangent + 9 ]  = t3.y;
 					tangentArray[ offset_tangent + 10 ] = t3.z;
 					tangentArray[ offset_tangent + 11 ] = t3.w;
 
@@ -1914,39 +2056,45 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.initMaterial = function ( material, lights, fog, object ) {
 
-		var u, a, identifiers, i, parameters, maxLightCount, maxBones;
+		var u, a, identifiers, i, parameters, maxLightCount, maxBones, shaderID;
 
 		if ( material instanceof THREE.MeshDepthMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
+			shaderID = 'depth';
 
 		} else if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'shadowVolumeDynamic' ] );
+			shaderID = 'shadowVolumeDynamic';
 
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
+			shaderID = 'normal';
 
 		} else if ( material instanceof THREE.MeshBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			shaderID = 'basic';
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'lambert' ] );
+			shaderID = 'lambert';
 
 		} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'phong' ] );
+			shaderID = 'phong';
 
 		} else if ( material instanceof THREE.LineBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			shaderID = 'basic';
 
 		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'particle_basic' ] );
+			shaderID = 'particle_basic';
+
+		}
+
+		if ( shaderID ) {
+
+			setMaterialShaders( material, THREE.ShaderLib[ shaderID ] );
 
 		}
 
@@ -1958,53 +2106,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 		maxBones = allocateBones( object );
 
 		parameters = {
-			map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors,
+			map: !!material.map, envMap: !!material.envMap, lightMap: !!material.lightMap, 
+			vertexColors: material.vertexColors,
 			fog: fog, sizeAttenuation: material.sizeAttenuation,
 			skinning: material.skinning,
 			morphTargets: material.morphTargets,
+			maxMorphTargets: this.maxMorphTargets,
 			maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point,
 			maxBones: maxBones
 		};
 
-		material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters );
-
-		// load uniforms
-
-		identifiers = [
-			'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
-			'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
-		];
-
-
-		for ( u in material.uniforms ) {
-
-			identifiers.push(u);
-
-		}
-
-		cacheUniformLocations( material.program, identifiers );
-
-
-		// load attributes
-
-		identifiers = [
-			"position", "normal", "uv", "uv2", "tangent", "color",
-			"skinVertexA", "skinVertexB", "skinIndex", "skinWeight"
-		];
-
-		for ( i = 0; i < this.maxMorphTargets; i++ ) {
-
-			identifiers.push( "morphTarget" + i );
-
-		}
-
-		for ( a in material.attributes ) {
-
-			identifiers.push( a );
-
-		}
-
-		cacheAttributeLocations( material.program, identifiers );
+		material.program = buildProgram( shaderID, material.fragmentShader, material.vertexShader, material.uniforms, material.attributes, parameters );
 
 		var attributes = material.program.attributes;
 
@@ -2055,12 +2167,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget2 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget3 >= 0 ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget3 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget4 >= 0 ) {
@@ -2074,6 +2188,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget5 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget6 >= 0 ) {
@@ -2940,6 +3055,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.enable( _gl.POLYGON_OFFSET_FILL );
 		_gl.polygonOffset( 0.1, 1.0 );
 		_gl.enable( _gl.STENCIL_TEST );
+		_gl.enable( _gl.DEPTH_TEST );
 		_gl.depthMask( false );
 		_gl.colorMask( false, false, false, false );
 
@@ -3755,20 +3871,33 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function buildProgram( fragmentShader, vertexShader, parameters ) {
+	function buildProgram( shaderID, fragmentShader, vertexShader, uniforms, attributes, parameters ) {
 
 		var p, pl, program, code;
+		var chunks = [];
 
 		// Generate code
 
-		code = fragmentShader + "\n\n" + vertexShader + "\n\n";
+		if ( shaderID ) {
+
+			chunks.push( shaderID );
+
+		} else {
+
+			chunks.push( fragmentShader );
+			chunks.push( vertexShader );
+
+		}
 
 		for ( p in parameters ) {
 
-			code += p + ": " + parameters[ p ] + ",\n";
+			chunks.push( p );
+			chunks.push( parameters[ p ] );
 
 		}
 
+		code = chunks.join();
+
 		// Check if code has been already compiled
 
 		for ( p = 0, pl = _programs.length; p < pl; p ++ ) {
@@ -3776,11 +3905,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 			if ( _programs[ p ].code == code ) {
 
 				// console.log( "Code already compiled." /*: \n\n" + code*/ );
+
 				return _programs[ p ].program;
 
 			}
 
 		}
+		
+		//console.log( "building new program " );
 
 		//
 
@@ -3887,6 +4019,48 @@ THREE.WebGLRenderer = function ( parameters ) {
 		program.uniforms = {};
 		program.attributes = {};
 
+		var identifiers, u, a, i;
+
+		// cache uniform locations
+
+		identifiers = [
+
+			'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
+			'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
+
+		];
+
+		for ( u in uniforms ) {
+
+			identifiers.push( u );
+
+		}
+
+		cacheUniformLocations( program, identifiers );
+		
+		// cache attributes locations
+
+		identifiers = [
+
+			"position", "normal", "uv", "uv2", "tangent", "color",
+			"skinVertexA", "skinVertexB", "skinIndex", "skinWeight"
+
+		];
+
+		for ( i = 0; i < parameters.maxMorphTargets; i++ ) {
+
+			identifiers.push( "morphTarget" + i );
+
+		}
+
+		for ( a in attributes ) {
+
+			identifiers.push( a );
+
+		}
+
+		cacheAttributeLocations( program, identifiers );
+
 		_programs.push( { program: program, code: code } );
 
 		return program;
@@ -4130,14 +4304,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( renderTexture && !renderTexture.__webglFramebuffer ) {
 
+			if( renderTexture.depthBuffer === undefined ) renderTexture.depthBuffer = true;
+			if( renderTexture.stencilBuffer === undefined ) renderTexture.stencilBuffer = true;
+
 			renderTexture.__webglFramebuffer = _gl.createFramebuffer();
 			renderTexture.__webglRenderbuffer = _gl.createRenderbuffer();
 			renderTexture.__webglTexture = _gl.createTexture();
 
-			// Setup renderbuffer
-
-			_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
-			_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height );
 
 			// Setup texture
 
@@ -4148,11 +4321,35 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, paramThreeToGL( renderTexture.minFilter ) );
 			_gl.texImage2D( _gl.TEXTURE_2D, 0, paramThreeToGL( renderTexture.format ), renderTexture.width, renderTexture.height, 0, paramThreeToGL( renderTexture.format ), paramThreeToGL( renderTexture.type ), null );
 
-			// Setup framebuffer
+			// Setup render and frame buffer
 
+			_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
 			_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTexture.__webglFramebuffer );
+
 			_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D, renderTexture.__webglTexture, 0 );
-			_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
+			
+			if( renderTexture.depthBuffer && !renderTexture.stencilBuffer ) {
+				
+				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_COMPONENT16, renderTexture.width, renderTexture.height );
+				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
+		
+		/* For some reason this is not working. Defaulting to RGBA4.	
+			} else if( !renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
+			
+				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.STENCIL_INDEX8, renderTexture.width, renderTexture.height );
+				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
+			*/
+			} else if( renderTexture.depthBuffer && renderTexture.stencilBuffer ) {
+				
+				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTexture.width, renderTexture.height );
+				_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderTexture.__webglRenderbuffer );
+				
+			} else {
+				
+				_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.RGBA4, renderTexture.width, renderTexture.height );
+				
+			}
+			
 
 			// Release everything
 

+ 2 - 0
utils/build.py

@@ -29,6 +29,7 @@ COMMON_FILES = [
 'core/UV.js',
 'core/Geometry.js',
 'core/Spline.js',
+'core/Edge.js',
 'animation/AnimationHandler.js',
 'animation/Animation.js',
 'cameras/Camera.js',
@@ -102,6 +103,7 @@ EXTRAS_FILES = [
 'extras/io/Loader.js',
 'extras/io/JSONLoader.js',
 'extras/io/BinaryLoader.js',
+'extras/io/SceneLoader.js',
 'extras/objects/MarchingCubes.js'
 ]
 

+ 13 - 2
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py

@@ -124,10 +124,14 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
     filename_ext = ".js"
 
     option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True)
+    use_materials = BoolProperty(name="Materials", description="Export materials", default=True)
     use_normals = BoolProperty(name="Normals", description="Export normals", default=True)
     use_colors = BoolProperty(name="Colors", description="Export vertex colors", default=True)
     use_uv_coords = BoolProperty(name="UVs", description="Export texture coordinates", default=True)
-    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=True)
+    use_edges = BoolProperty(name="Edges", description="Export edges", default=False)
+    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=False)
+    option_truncate = BoolProperty(name="Truncate", description="Truncate decimals", default=False)
+    option_scale = FloatProperty(name="Scale", description="Scale data", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
 
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
     align_model = EnumProperty(name="Align model", description="Align model", items=align_types, default="None")
@@ -163,10 +167,17 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
         row = layout.row()
         row.prop(self.properties, "use_normals")
-        row = layout.row()
         row.prop(self.properties, "use_colors")
         row = layout.row()
         row.prop(self.properties, "use_uv_coords")
+        row.prop(self.properties, "use_materials")
+        row = layout.row()
+        row.prop(self.properties, "use_edges")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "option_truncate")
+        row.prop(self.properties, "option_scale")
 
 
 # ################################################################

+ 111 - 17
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py

@@ -201,6 +201,7 @@ TEMPLATE_FILE_ASCII = """\
  * uvs: %(nuv)d
  * colors: %(ncolor)d
  * materials: %(nmaterial)d
+ * edges: %(nedges)d
  *
  */
 
@@ -208,6 +209,8 @@ var model = {
 
     "version" : 2,
     
+    "scale" : %(scale)f,
+    
     "materials": [%(materials)s],
 
     "vertices": [%(vertices)s],
@@ -220,7 +223,9 @@ var model = {
 
     "uvs": [[%(uvs)s]],
 
-    "faces": [%(faces)s]
+    "faces": [%(faces)s],
+
+    "edges" : [%(edges)s]
 
 };
 
@@ -228,11 +233,13 @@ postMessage( model );
 """
 
 TEMPLATE_VERTEX = "%f,%f,%f"
+TEMPLATE_VERTEX_TRUNCATE = "%d,%d,%d"
 
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
 #TEMPLATE_C = "0x%06x"
 TEMPLATE_C = "%d"
+TEMPLATE_EDGE = "%d,%d"
 
 # #####################################################
 # Utils
@@ -391,8 +398,11 @@ def bottom(vertices):
 def hexcolor(c):
     return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
     
-def generate_vertex(v):
-    return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z)
+def generate_vertex(v, truncate):
+    if truncate:
+        return TEMPLATE_VERTEX_TRUNCATE % (v.co.x, v.co.y, v.co.z)
+    else:
+        return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z)
 
 def generate_normal(n):
     return TEMPLATE_N % (n[0], n[1], n[2])
@@ -403,6 +413,9 @@ def generate_vertex_color(c):
 def generate_uv(uv):
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
 
+def generate_edge(e):
+    return TEMPLATE_EDGE % (e.vertices[0], e.vertices[1])
+    
 # #####################################################
 # Model exporter - faces
 # #####################################################
@@ -415,7 +428,7 @@ def setBit(value, position, on):
         mask = ~(1 << position)
         return (value & mask)    
     
-def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz):
+def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, use_materials, flipyz):
     isTriangle = ( len(f.vertices) == 3 )
     
     if isTriangle:
@@ -423,7 +436,7 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
     else:
         nVertices = 4
         
-    hasMaterial = True # for the moment objects without materials get default material
+    hasMaterial = use_materials
     
     hasFaceUvs = False # not supported in Blender
     hasFaceVertexUvs = use_uv_coords
@@ -459,6 +472,7 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
     faceData.append(faceType)    
     
     # must clamp in case on polygons bigger than quads
+
     for i in range(nVertices):
         index = f.vertices[i]
         faceData.append(index)
@@ -736,7 +750,17 @@ def generate_materials_string(mesh, scene, use_colors, draw_type):
 # ASCII model generator
 # #####################################################
 
-def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, draw_type):
+def generate_ascii_model(mesh, scene, 
+                         use_normals, 
+                         use_colors, 
+                         use_uv_coords, 
+                         use_materials,
+                         use_edges,
+                         align_model, 
+                         flipyz, 
+                         option_truncate, 
+                         option_scale, 
+                         draw_type):
 
     vertices = mesh.vertices[:]    
 
@@ -751,8 +775,19 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     colors, ncolor = extract_vertex_colors(mesh, use_colors)
     uvs, nuv = extract_uvs(mesh, use_uv_coords)
 
-    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
+    materials_string = ""
+    nmaterial = 0
+    
+    edges_string = ""
+    nedges = 0
+    
+    if use_materials:
+        materials_string, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
     
+    if use_edges:
+        nedges = len(mesh.edges) 
+        edges_string  = ",".join(generate_edge(e) for e in mesh.edges)
+        
     text = TEMPLATE_FILE_ASCII % {
     "nvertex"   : len(mesh.vertices),
     "nface"     : len(mesh.faces),
@@ -760,16 +795,21 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     "nnormal"   : nnormal,
     "ncolor"    : ncolor,
     "nmaterial" : nmaterial,
+    "nedges"    : nedges,
+    
+    "scale" : option_scale,
 
     "uvs"           : generate_uvs(uvs, use_uv_coords),
     "normals"       : generate_normals(normals, use_normals),
     "colors"        : generate_vertex_colors(colors, use_colors),
 
-    "materials" : mstring,
+    "materials" : materials_string,
+
+    "vertices" : ",".join(generate_vertex(v, option_truncate) for v in vertices),
 
-    "vertices"      : ",".join(generate_vertex(v) for v in vertices),
+    "faces"    : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, use_materials, flipyz) for i, f in enumerate(mesh.faces)),
 
-    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz) for i, f in enumerate(mesh.faces))
+    "edges"    : edges_string
 
     }
 
@@ -780,13 +820,24 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
 # Model exporter - export single mesh
 # #####################################################
 
-def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, flipyz, export_single_model):
+def export_mesh(obj, scene, filepath, 
+                use_normals, 
+                use_colors, 
+                use_uv_coords, 
+                use_materials, 
+                use_edges, 
+                align_model, 
+                flipyz, 
+                option_truncate, 
+                option_scale, 
+                export_single_model):
+
     """Export single mesh"""
 
 
     # collapse modifiers into mesh
     
-    mesh = obj.create_mesh(scene, True, 'RENDER')        
+    mesh = obj.create_mesh(scene, True, 'RENDER')
 
     if not mesh:
         raise Exception("Error, could not get mesh data from object [%s]" % obj.name)
@@ -801,6 +852,8 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, al
     else:
         mesh.transform(X_ROT)
 
+    mesh.transform(mathutils.Matrix.Scale(option_scale, 4))
+
     mesh.calc_normals()
 
     faceUV = (len(mesh.uv_textures) > 0)
@@ -823,7 +876,18 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, al
         if not active_col_layer:
             use_colors = False
 
-    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, obj.draw_type)    
+    text = generate_ascii_model(mesh, scene, 
+                                use_normals, 
+                                use_colors, 
+                                use_uv_coords, 
+                                use_materials,
+                                use_edges,
+                                align_model, 
+                                flipyz, 
+                                option_truncate, 
+                                option_scale, 
+                                obj.draw_type)
+
     write_file(filepath, text)
 
     # remove temp mesh
@@ -924,7 +988,7 @@ def generate_objects(data):
                 group_string = generate_string_list(group_ids)
 
             castsShadow = generate_bool_property(obj.THREE_castsShadow)
-            meshCollider = generate_bool_property(obj.THREE_meshCollider)            
+            meshCollider = generate_bool_property(obj.THREE_meshCollider)
                 
             object_string = TEMPLATE_OBJECT % {
             "object_id"   : generate_string(object_id),
@@ -1250,7 +1314,17 @@ def export_scene(scene, filepath, flipyz):
 # Main
 # #####################################################
 
-def save(operator, context, filepath = "", option_flip_yz = True, use_normals = True, use_colors = True, use_uv_coords = True, align_model = 0, option_export_scene = True):
+def save(operator, context, filepath = "", 
+         option_flip_yz = True, 
+         use_normals = True, 
+         use_colors = True, 
+         use_uv_coords = True, 
+         use_materials = True, 
+         use_edges = False, 
+         align_model = 0, 
+         option_export_scene = False, 
+         option_truncate = False, 
+         option_scale = 1.0):
 
     filepath = ensure_extension(filepath, '.js')
 
@@ -1281,7 +1355,17 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
 
                 if name not in geo_set:
                     fname = generate_mesh_filename(name, filepath)
-                    export_mesh(obj, scene, fname, use_normals, use_colors, use_uv_coords, 0, option_flip_yz, False)
+                    export_mesh(obj, scene, fname, 
+                                use_normals, 
+                                use_colors, 
+                                use_uv_coords, 
+                                use_materials, 
+                                use_edges, 
+                                False, 
+                                option_flip_yz, 
+                                option_truncate, 
+                                option_scale, 
+                                False)
                     
                     geo_set.add(name)
 
@@ -1291,7 +1375,17 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
         if not obj:
             raise Exception("Error, Select 1 active object or select 'export scene'")
 
-        export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, option_flip_yz, True)
+        export_mesh(obj, scene, filepath, 
+                    use_normals, 
+                    use_colors, 
+                    use_uv_coords, 
+                    use_materials, 
+                    use_edges, 
+                    align_model, 
+                    option_flip_yz, 
+                    option_truncate, 
+                    option_scale, 
+                    True)
 
     
     return {'FINISHED'}

+ 28 - 3
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py

@@ -108,11 +108,12 @@ def create_materials(data, modelpath):
     
 def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate_normals):
 
-    faces   = face_data["faces"]
+    faces         = face_data["faces"]
     vertexNormals = face_data["vertexNormals"]
-    vertexColors = face_data["vertexColors"]
-    vertexUVs = face_data["vertexUVs"]
+    vertexColors  = face_data["vertexColors"]
+    vertexUVs     = face_data["vertexUVs"]
     faceMaterials = face_data["materials"]
+    faceColors    = face_data["faceColors"]
     
     edges = []
     
@@ -200,7 +201,29 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
                     face_colors[vi].r = r
                     face_colors[vi].g = g
                     face_colors[vi].b = b
+                    
+    elif face_data["hasFaceColors"]:
+
+        print("setting vertex colors from face colors")
+
+        me.vertex_colors.new("vertex_color_layer_0")
+        
+        for fi in range(len(faces)):
+
+            if faceColors[fi]:
+
+                r = faceColors[fi][0]
+                g = faceColors[fi][1]
+                b = faceColors[fi][2]
 
+                face_colors = me.vertex_colors[0].data[fi]
+                face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
+                
+                for vi in range(len(faces[fi])):
+                
+                    face_colors[vi].r = r
+                    face_colors[vi].g = g
+                    face_colors[vi].b = b
 
     # Handle uvs
     
@@ -284,6 +307,7 @@ def extract_faces(data):
     "hasVertexNormals"  : False,
     "hasVertexUVs"      : False,
     "hasVertexColors"   : False,
+    "hasFaceColors"     : False,
     "hasMaterials"      : False
     }
     
@@ -325,6 +349,7 @@ def extract_faces(data):
         result["hasVertexUVs"] = result["hasVertexUVs"] or hasFaceVertexUv
         result["hasVertexNormals"] = result["hasVertexNormals"] or hasFaceVertexNormal
         result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor
+        result["hasFaceColors"] = result["hasFaceColors"] or hasFaceColor
         result["hasMaterials"] = result["hasMaterials"] or hasMaterial
         
         # vertices

+ 370 - 76
utils/exporters/convert_obj_three.py

@@ -4,15 +4,28 @@
 How to use this converter
 -------------------------
 
-python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-a center|centerxz|top|bottom|none] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
+python convert_obj_three.py -i infile.obj -o outfile.js [-m "morphfiles*.obj"] [-c "morphcolors*.obj"] [-a center|centerxz|top|bottom|none] [-s smooth|flat] [-t ascii|binary] [-d invert|normal] [-b] [-e]
 
 Notes: 
+    - flags
+        -i infile.obj			input OBJ file
+        -o outfile.js			output JS file
+        -m "morphfiles*.obj"	morph OBJ files (can use wildcards, enclosed in quotes multiple patterns separate by space)
+        -c "morphcolors*.obj"	morph colors OBJ files (can use wildcards, enclosed in quotes multiple patterns separate by space)
+        -a center|centerxz|top|bottom|none model alignment
+        -s smooth|flat			smooth = export vertex normals, flat = no normals (face normals computed in loader)
+        -t ascii|binary			export ascii or binary format (ascii has more features, binary just supports vertices, faces, normals, uvs and materials)
+        -d invert|normal		invert transparency
+        -b						bake material colors into face colors
+        -e						export edges
 
     - by default:
         converted model will be centered (middle of bounding box goes to 0,0,0)
         use smooth shading (if there were vertex normals in the original model)
         will be in ASCII format
         original model is assumed to use non-inverted transparency / dissolve (0.0 fully transparent, 1.0 fully opaque)
+        no face colors baking
+        no edges export
  
     - binary conversion will create two files: 
         outfile.js  (materials)
@@ -62,10 +75,7 @@ Current limitations
     - for the moment, only diffuse color and texture are used 
       (will need to extend shaders / renderers / materials in Three)
      
-    - models can have more than 65,536 vertices,
-      but in most cases it will not work well with browsers,
-      which currently seem to have troubles with handling
-      large JS files
+    - models can have more than 65,536 vertices
        
     - texture coordinates can be wrong in canvas renderer
       (there is crude normalization, but it doesn't
@@ -137,6 +147,9 @@ SHADING = "smooth"      # smooth flat
 TYPE = "ascii"          # ascii binary
 TRANSPARENCY = "normal" # normal invert
 
+BAKE_COLORS = False
+EXPORT_EDGES = False
+
 # default colors for debugging (each material gets one distinct color): 
 # white, red, green, blue, yellow, cyan, magenta
 COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
@@ -147,10 +160,12 @@ COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
 TEMPLATE_FILE_ASCII = u"""\
 // Converted from: %(fname)s
 //  vertices: %(nvertex)d
-//  faces: %(nface)d 
-//  normals: %(nnormal)d 
-//  uvs: %(nuv)d 
+//  faces: %(nface)d
+//  normals: %(nnormal)d
+//  colors: %(ncolor)d
+//  uvs: %(nuv)d
 //  materials: %(nmaterial)d
+//  edges: %(nedge)d
 //
 //  Generated with OBJ -> Three.js converter
 //  http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_three.py
@@ -163,14 +178,20 @@ var model = {
     "materials": [%(materials)s],
 
     "vertices": [%(vertices)s],
-
+    
     "morphTargets": [%(morphTargets)s],
 
+    "morphColors": [%(morphColors)s],
+
     "normals": [%(normals)s],
 
+    "colors": [%(colors)s],
+
     "uvs": [[%(uvs)s]],
 
-    "faces": [%(faces)s]
+    "faces": [%(faces)s],
+
+    "edges" : [%(edges)s]
 
 };
 
@@ -180,7 +201,7 @@ postMessage( model );
 TEMPLATE_FILE_BIN = u"""\
 // Converted from: %(fname)s
 //  vertices: %(nvertex)d
-//  faces: %(nface)d 
+//  faces: %(nface)d
 //  materials: %(nmaterial)d
 //
 //  Generated with OBJ -> Three.js converter
@@ -204,8 +225,12 @@ TEMPLATE_VERTEX = "%f,%f,%f"
 
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
+TEMPLATE_COLOR = "%.3f,%.3f,%.3f"
+TEMPLATE_COLOR_DEC = "%d"
+TEMPLATE_EDGE = "%d,%d"
 
-TEMPLATE_MORPH = '\t{ "name": "%s", "vertices": [%s] }'
+TEMPLATE_MORPH_VERTICES = '\t{ "name": "%s", "vertices": [%s] }'
+TEMPLATE_MORPH_COLORS   = '\t{ "name": "%s", "colors": [%s] }'
 
 # #####################################################
 # Utils
@@ -329,6 +354,9 @@ def normalize(v):
         v[1] /= l
         v[2] /= l
 
+def veckey3(v):
+    return round(v[0], 6), round(v[1], 6), round(v[2], 6)
+
 # #####################################################
 # MTL parser
 # #####################################################
@@ -565,7 +593,7 @@ def parse_obj(fname):
     return faces, vertices, uvs, normals, materials, mtllib
     
 # #####################################################
-# Generator
+# Generator - faces
 # #####################################################
 def setBit(value, position, on):
     if on:
@@ -573,12 +601,9 @@ def setBit(value, position, on):
         return (value | mask)
     else:
         mask = ~(1 << position)
-        return (value & mask)
-    
-def generate_vertex(v):
-    return TEMPLATE_VERTEX % (v[0], v[1], v[2])
+        return (value & mask)    
     
-def generate_face(f):
+def generate_face(f, fc):
     isTriangle = ( len(f['vertex']) == 3 )
     
     if isTriangle:
@@ -594,7 +619,7 @@ def generate_face(f):
     hasFaceNormals = False # don't export any face normals (as they are computed in engine)
     hasFaceVertexNormals = ( len(f["normal"]) >= nVertices and SHADING == "smooth" )
     
-    hasFaceColors = False       # not supported in OBJ
+    hasFaceColors = BAKE_COLORS
     hasFaceVertexColors = False # not supported in OBJ
 
     faceType = 0
@@ -616,12 +641,15 @@ def generate_face(f):
     # material index
     # face uvs index
     # face vertex uvs indices
+    # face normal index
+    # face vertex normals indices
     # face color index
     # face vertex colors indices
     
     faceData.append(faceType)    
     
     # must clamp in case on polygons bigger than quads
+
     for i in xrange(nVertices):
         index = f['vertex'][i] - 1
         faceData.append(index)
@@ -637,22 +665,242 @@ def generate_face(f):
         for i in xrange(nVertices):
             index = f['normal'][i] - 1
             faceData.append(index)
+            
+    if hasFaceColors:
+        index = fc['material']
+        faceData.append(index)        
 
     return ",".join( map(str, faceData) )
 
+# #####################################################
+# Generator - chunks
+# #####################################################
+def hexcolor(c):
+    return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
+
+def generate_vertex(v):
+    return TEMPLATE_VERTEX % (v[0], v[1], v[2])
+
 def generate_normal(n):
     return TEMPLATE_N % (n[0], n[1], n[2])
 
 def generate_uv(uv):
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
 
+def generate_color_rgb(c):
+    return TEMPLATE_COLOR % (c[0], c[1], c[2])
+    
+def generate_color_decimal(c):
+    return TEMPLATE_COLOR_DEC % hexcolor(c)
+    
+def generate_edge(e):
+    return TEMPLATE_EDGE % (e[0], e[1])
+    
 # #####################################################
 # Morphs
 # #####################################################
-def generate_morph(name, vertices):
+def generate_morph_vertex(name, vertices):
     vertex_string = ",".join(generate_vertex(v) for v in vertices)
-    return TEMPLATE_MORPH % (name, vertex_string)
+    return TEMPLATE_MORPH_VERTICES % (name, vertex_string)
+    
+def generate_morph_color(name, colors):
+    color_string = ",".join(generate_color_rgb(c) for c in colors)
+    return TEMPLATE_MORPH_COLORS % (name, color_string)
+
+def extract_material_colors(materials, mtlfilename, basename):
+    """Extract diffuse colors from MTL materials
+    """
+
+    if not materials:
+        materials = { 'default': 0 }
+
+    mtl = create_materials(materials, mtlfilename, basename)
+    
+    mtlColorArraySrt = []
+    for m in mtl:
+        if m in materials:
+            index = materials[m]
+            color = mtl[m].get("colorDiffuse", [1,0,0])
+            mtlColorArraySrt.append([index, color])
+       
+    mtlColorArraySrt.sort()
+    mtlColorArray = [x[1] for x in mtlColorArraySrt]
+
+    return mtlColorArray
+
+def extract_face_colors(faces, material_colors):
+    """Extract colors from materials and assign them to faces
+    """
+    
+    faceColors = []
+
+    for face in faces:
+        material_index = face['material']
+        faceColors.append(material_colors[material_index])
+
+    return faceColors
+
+def generate_morph_targets(morphfiles, n_vertices, infile):
+    skipOriginalMorph = False
+    norminfile = os.path.normpath(infile)
+    
+    morphVertexData = []
+
+    for mfilepattern in morphfiles.split():
+
+        matches = glob.glob(mfilepattern)
+        matches.sort()
+
+        for path in matches:
+
+            normpath = os.path.normpath(path)
+
+            if normpath != norminfile or not skipOriginalMorph:
+
+                name = os.path.basename(normpath)
+                
+                morphFaces, morphVertices, morphUvs, morphNormals, morphMaterials, morphMtllib = parse_obj(normpath)
+                
+                n_morph_vertices = len(morphVertices)
+
+                if n_vertices != n_morph_vertices:
+
+                    print "WARNING: skipping morph [%s] with different number of vertices [%d] than the original model [%d]" % (name, n_morph_vertices, n_vertices)
+
+                else:
+                    
+                    if ALIGN == "center":
+                        center(morphVertices)
+                    elif ALIGN == "centerxz":
+                        centerxz(morphVertices)
+                    elif ALIGN == "bottom":
+                        bottom(morphVertices)
+                    elif ALIGN == "top":
+                        top(morphVertices)
+                        
+                    morphVertexData.append((get_name(name), morphVertices))
+                    print "adding [%s] with %d vertices" % (name, n_morph_vertices)
+    
+    morphTargets = ""
+    if len(morphVertexData):
+        morphTargets = "\n%s\n\t" % ",\n".join(generate_morph_vertex(name, vertices) for name, vertices in morphVertexData)
+
+    return morphTargets
+    
+def generate_morph_colors(colorfiles, n_vertices, n_faces):
+    morphColorData = []
+    colorFaces = []
+    materialColors = []
+    
+    for mfilepattern in colorfiles.split():
+
+        matches = glob.glob(mfilepattern)
+        matches.sort()
+        for path in matches:
+            normpath = os.path.normpath(path)
+            name = os.path.basename(normpath)
+
+            morphFaces, morphVertices, morphUvs, morphNormals, morphMaterials, morphMtllib = parse_obj(normpath)
+
+            n_morph_vertices = len(morphVertices)
+            n_morph_faces = len(morphFaces)
+
+            if n_vertices != n_morph_vertices:
+
+                print "WARNING: skipping morph color map [%s] with different number of vertices [%d] than the original model [%d]" % (name, n_morph_vertices, n_vertices)
+
+            elif n_faces != n_morph_faces:
+
+                print "WARNING: skipping morph color map [%s] with different number of faces [%d] than the original model [%d]" % (name, n_morph_faces, n_faces)
+
+            else:
+
+                morphMaterialColors = extract_material_colors(morphMaterials, morphMtllib, normpath)  
+                morphFaceColors = extract_face_colors(morphFaces, morphMaterialColors)
+                morphColorData.append((get_name(name), morphFaceColors))
+
+                # take first color map for baking into face colors
+
+                if len(colorFaces) == 0:
+                    colorFaces = morphFaces
+                    materialColors = morphMaterialColors
+
+                print "adding [%s] with %d face colors" % (name, len(morphFaceColors))
+
+    morphColors = ""
+    if len(morphColorData):
+        morphColors = "\n%s\n\t" % ",\n".join(generate_morph_color(name, colors) for name, colors in morphColorData)
+    
+    return morphColors, colorFaces, materialColors
+
+# #####################################################
+# Edges
+# #####################################################
+def edge_hash(a, b):
+    return "%d_%d" % (min(a, b), max(a, b))
+    
+def add_unique_edge(a, b, edge_set, edges):
+    h = edge_hash(a[0], b[0])
+    if h not in edge_set:
+        x = min(a[1], b[1])
+        y = max(a[1], b[1])
+        edges.append([x, y])
+        edge_set.add(h)
+    
+def compute_edges(faces, vertices):
+    edges = []
+    
+    # compute unique vertices
+
+    unique_vertices = {}
+    vertex_count = 0
+    
+    for i, v in enumerate(vertices):
+        key = veckey3(v)
+        if key not in unique_vertices:
+            unique_vertices[key] = [vertex_count, i]
+            vertex_count += 1
+
+    # find edges between unique vertices
+    
+    edge_set = set()    
+
+    for f in faces:
+        vertex_indices = f["vertex"]
+        unique_indices = []
+
+        for vi in vertex_indices:
+            v = vertices[vi - 1]
+            key = veckey3(v)
+            unique_indices.append(unique_vertices[key])
+        
+        if len(unique_indices) == 3:
+            a = unique_indices[0]
+            b = unique_indices[1]
+            c = unique_indices[2]
+            
+            add_unique_edge(a, b, edge_set, edges)
+            add_unique_edge(b, c, edge_set, edges)
+            add_unique_edge(a, c, edge_set, edges)
+
+        elif len(unique_indices) == 4:
+            a = unique_indices[0]
+            b = unique_indices[1]
+            c = unique_indices[2]
+            d = unique_indices[3]
+            
+            # this should be inside edge of quad, should it go in?
+            # add_unique_edge(b, d, edge_set, edges) 
+            
+            add_unique_edge(a, b, edge_set, edges)
+            add_unique_edge(a, d, edge_set, edges)
+            add_unique_edge(b, c, edge_set, edges)
+            add_unique_edge(c, d, edge_set, edges)
+
+    edges.sort()
     
+    return edges
+
 # #####################################################
 # Materials
 # #####################################################
@@ -675,6 +923,8 @@ def generate_color(i):
 def value2string(v):
     if type(v)==str and v[0:2] != "0x":
         return '"%s"' % v
+    elif type(v) == bool:
+        return str(v).lower()
     return str(v)
     
 def generate_materials(mtl, materials):
@@ -697,6 +947,9 @@ def generate_materials(mtl, materials):
             mtl[m]['DbgIndex'] = index
             mtl[m]['DbgColor'] = generate_color(index)
             
+            if BAKE_COLORS:
+                mtl[m]['vertexColors'] = "face"
+            
             mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
             mtl_string = "\t{\n%s\n\t}" % mtl_raw
             mtl_array.append([index, mtl_string])
@@ -717,34 +970,49 @@ def generate_mtl(materials):
         }
     return mtl
     
-def generate_materials_string(materials, mtllib):
+def generate_materials_string(materials, mtlfilename, basename):
     """Generate final materials string.
     """
 
-    random.seed(42) # to get well defined color order for materials
+    if not materials:
+        materials = { 'default': 0 }
+
+    mtl = create_materials(materials, mtlfilename, basename)
+    return generate_materials(mtl, materials)
+    
+def create_materials(materials, mtlfilename, basename):
+    """Parse MTL file and create mapping between its materials and OBJ materials.
+       Eventual edge cases are handled here (missing materials, missing MTL file).
+    """
+
+    random.seed(42) # to get well defined color order for debug colors
     
     # default materials with debug colors for when
     # there is no specified MTL / MTL loading failed,
     # or if there were no materials / null materials
-    if not materials:
-        materials = { 'default':0 }
+
     mtl = generate_mtl(materials)
     
-    if mtllib:
+    if mtlfilename:
+
         # create full pathname for MTL (included from OBJ)
-        path = os.path.dirname(infile)
-        fname = os.path.join(path, mtllib)
+
+        path = os.path.dirname(basename)
+        fname = os.path.join(path, mtlfilename)
         
         if file_exists(fname):
+
             # override default materials with real ones from MTL
             # (where they exist, otherwise keep defaults)
+
             mtl.update(parse_mtl(fname))
         
         else:
+
             print "Couldn't find [%s]" % fname
-    
-    return generate_materials(mtl, materials)
-    
+            
+    return mtl
+
 # #####################################################
 # Faces
 # #####################################################
@@ -809,7 +1077,7 @@ def sort_faces(faces):
 # #####################################################
 # API - ASCII converter
 # #####################################################
-def convert_ascii(infile, morphfiles, outfile):
+def convert_ascii(infile, morphfiles, colorfiles, outfile):
     """Convert infile.obj to outfile.js
     
     Here is where everything happens. If you need to automate conversions,
@@ -819,9 +1087,16 @@ def convert_ascii(infile, morphfiles, outfile):
     if not file_exists(infile):
         print "Couldn't find [%s]" % infile
         return
-        
+       
+    # parse OBJ / MTL files
+
     faces, vertices, uvs, normals, materials, mtllib = parse_obj(infile)
-    
+
+    n_vertices = len(vertices)
+    n_faces = len(faces)
+
+    # align model
+
     if ALIGN == "center":
         center(vertices)
     elif ALIGN == "centerxz":
@@ -831,48 +1106,47 @@ def convert_ascii(infile, morphfiles, outfile):
     elif ALIGN == "top":
         top(vertices)
     
-    n_vertices = len(vertices)
-    
+    # generate normals string
+
     nnormal = 0
     normals_string = ""
     if SHADING == "smooth":
         normals_string = ",".join(generate_normal(n) for n in normals)
         nnormal = len(normals)
     
-    skipOriginalMorph = False
-    norminfile = os.path.normpath(infile)
+    # extract morph vertices
     
-    morphData = []
-    for mfilepattern in morphfiles.split():
-        matches = glob.glob(mfilepattern)
-        matches.sort()
-        for path in matches:
-            normpath = os.path.normpath(path)
-            if normpath != norminfile or not skipOriginalMorph:
-                name = os.path.basename(normpath)
-                
-                morphFaces, morphVertices, morphUvs, morphNormals, morphMaterials, morphMtllib = parse_obj(normpath)
-                
-                n_morph_vertices = len(morphVertices)
-                if n_vertices != n_morph_vertices:
-                    print "WARNING: skipping morph [%s] with different number of vertices [%d] than the original model [%d]" % (name, n_morph_vertices, n_vertices)
-                else:                    
-                    if ALIGN == "center":
-                        center(morphVertices)
-                    elif ALIGN == "centerxz":
-                        centerxz(morphVertices)
-                    elif ALIGN == "bottom":
-                        bottom(morphVertices)
-                    elif ALIGN == "top":
-                        top(morphVertices)
-                        
-                    morphData.append((get_name(name), morphVertices ))
-                    print "adding [%s] with %d vertices" % (name, len(morphVertices))
+    morphTargets = generate_morph_targets(morphfiles, n_vertices, infile)
     
-    morphTargets = ""
-    if len(morphData):
-        morphTargets = "\n%s\n\t" % ",\n".join(generate_morph(name, vertices) for name, vertices in morphData)
+    # extract morph colors
+
+    morphColors, colorFaces, materialColors = generate_morph_colors(colorfiles, n_vertices, n_faces)    
+
+    # generate colors string
+
+    ncolor = 0
+    colors_string = ""
+
+    if len(colorFaces) < len(faces):
+        colorFaces = faces
+        materialColors = extract_material_colors(materials, mtllib, infile)
+    
+    if BAKE_COLORS:
+        colors_string = ",".join(generate_color_decimal(c) for c in materialColors)
+        ncolor = len(materialColors)
+        
+    # generate edges string
+    
+    nedge = 0
+    edges_string = ""
     
+    if EXPORT_EDGES:
+        edges = compute_edges(faces, vertices)
+        nedge = len(edges) 
+        edges_string  = ",".join(generate_edge(e) for e in edges)
+        
+    # generate ascii model string
+
     text = TEMPLATE_FILE_ASCII % {
     "name"      : get_name(outfile),
     "fname"     : infile,
@@ -880,17 +1154,23 @@ def convert_ascii(infile, morphfiles, outfile):
     "nface"     : len(faces),
     "nuv"       : len(uvs),
     "nnormal"   : nnormal,
+    "ncolor"    : ncolor,
     "nmaterial" : len(materials),
+    "nedge"     : nedge,
 
-    "materials" : generate_materials_string(materials, mtllib),
+    "materials" : generate_materials_string(materials, mtllib, infile),
 
     "normals"       : normals_string,
+    "colors"        : colors_string,
     "uvs"           : ",".join(generate_uv(uv) for uv in uvs),
     "vertices"      : ",".join(generate_vertex(v) for v in vertices),
     
     "morphTargets"  : morphTargets,
+    "morphColors"   : morphColors,
     
-    "faces"     : ",".join(generate_face(f) for f in faces)
+    "faces"     : ",".join(generate_face(f, fc) for f, fc in zip(faces, colorFaces)),
+        
+    "edges"    : edges_string
     }
     
     out = open(outfile, "w")
@@ -898,7 +1178,7 @@ def convert_ascii(infile, morphfiles, outfile):
     out.close()
     
     print "%d vertices, %d faces, %d materials" % (len(vertices), len(faces), len(materials))
-        
+
     
 # #############################################################################
 # API - Binary converter
@@ -933,7 +1213,7 @@ def convert_binary(infile, outfile):
     text = TEMPLATE_FILE_BIN % {
     "name"       : get_name(outfile),
     
-    "materials" : generate_materials_string(materials, mtllib),
+    "materials" : generate_materials_string(materials, mtllib, infile),
     "buffers"   : binfile,
     
     "fname"     : infile,
@@ -1216,7 +1496,7 @@ def convert_binary(infile, outfile):
 # Helpers
 # #############################################################################
 def usage():
-    print "Usage: %s -i filename.obj -o filename.js [-m morphfiles*.obj] [-a center|top|bottom] [-s flat|smooth] [-t binary|ascii] [-d invert|normal]" % os.path.basename(sys.argv[0])
+    print "Usage: %s -i filename.obj -o filename.js [-m morphfiles*.obj] [-c morphcolors*.obj] [-a center|top|bottom] [-s flat|smooth] [-t binary|ascii] [-d invert|normal]" % os.path.basename(sys.argv[0])
         
 # #####################################################
 # Main
@@ -1225,7 +1505,7 @@ if __name__ == "__main__":
     
     # get parameters from the command line
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "hi:m:o:a:s:t:d:", ["help", "input=", "morphs=", "output=", "align=", "shading=", "type=", "dissolve="])
+        opts, args = getopt.getopt(sys.argv[1:], "hbei:m:c:b:o:a:s:t:d:", ["help", "bakecolors", "edges", "input=", "morphs=", "colors=", "output=", "align=", "shading=", "type=", "dissolve="])
     
     except getopt.GetoptError:
         usage()
@@ -1233,6 +1513,7 @@ if __name__ == "__main__":
         
     infile = outfile = ""
     morphfiles = ""
+    colorfiles = ""
     
     for o, a in opts:
         if o in ("-h", "--help"):
@@ -1245,6 +1526,9 @@ if __name__ == "__main__":
         elif o in ("-m", "--morphs"):
             morphfiles = a
 
+        elif o in ("-c", "--colors"):
+            colorfiles = a
+
         elif o in ("-o", "--output"):
             outfile = a
 
@@ -1264,16 +1548,26 @@ if __name__ == "__main__":
             if a in ("normal", "invert"):
                 TRANSPARENCY = a
 
+        elif o in ("-b", "--bakecolors"):
+            BAKE_COLORS = True
+
+        elif o in ("-e", "--edges"):
+            EXPORT_EDGES = True
+
     if infile == "" or outfile == "":
         usage()
         sys.exit(2)
     
     print "Converting [%s] into [%s] ..." % (infile, outfile)
+
     if morphfiles:
-        print "Morphs [%s]" % morphfiles    
-    
+        print "Morphs [%s]" % morphfiles
+
+    if colorfiles:
+        print "Colors [%s]" % colorfiles
+
     if TYPE == "ascii":
-        convert_ascii(infile, morphfiles, outfile)
+        convert_ascii(infile, morphfiles, colorfiles, outfile)
     elif TYPE == "binary":
         convert_binary(infile, outfile)
     

Some files were not shown because too many files changed in this diff