浏览代码

Synced with mrdoob's branch.

alteredq 14 年之前
父节点
当前提交
91b9539e02
共有 50 个文件被更改,包括 1213 次插入819 次删除
  1. 160 156
      build/Three.js
  2. 161 157
      build/ThreeDebug.js
  3. 146 142
      build/ThreeExtras.js
  4. 1 1
      examples/camera_orthographic.html
  5. 1 1
      examples/geometry_birds.html
  6. 1 1
      examples/geometry_cube.html
  7. 3 3
      examples/geometry_minecraft_ao.html
  8. 2 2
      examples/geometry_terrain_fog_gl.html
  9. 1 1
      examples/interactive_cubes.html
  10. 3 3
      examples/interactive_voxelpainter.html
  11. 14 12
      examples/materials.html
  12. 1 1
      examples/materials_depth.html
  13. 2 2
      examples/materials_gl.html
  14. 233 0
      examples/materials_normalmap2.html
  15. 二进制
      examples/obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg
  16. 24 0
      examples/obj/leeperrysmith/LeePerrySmith.js
  17. 二进制
      examples/obj/leeperrysmith/Map-COL.jpg
  18. 43 14
      examples/webglrenderer2_sandbox.html
  19. 14 1
      src/cameras/Camera.js
  20. 3 3
      src/core/Face3.js
  21. 3 3
      src/core/Face4.js
  22. 17 17
      src/core/Geometry.js
  23. 1 1
      src/core/Vertex.js
  24. 1 1
      src/extras/GeometryUtils.js
  25. 3 3
      src/extras/ShaderUtils.js
  26. 7 3
      src/materials/LineBasicMaterial.js
  27. 11 3
      src/materials/MeshBasicMaterial.js
  28. 6 13
      src/materials/MeshDepthMaterial.js
  29. 6 2
      src/materials/MeshFaceMaterial.js
  30. 10 2
      src/materials/MeshLambertMaterial.js
  31. 8 5
      src/materials/MeshNormalMaterial.js
  32. 11 3
      src/materials/MeshPhongMaterial.js
  33. 7 4
      src/materials/MeshShaderMaterial.js
  34. 6 2
      src/materials/ParticleBasicMaterial.js
  35. 6 2
      src/materials/ParticleCircleMaterial.js
  36. 7 2
      src/materials/ParticleDOMMaterial.js
  37. 6 2
      src/materials/Texture.js
  38. 2 2
      src/objects/Line.js
  39. 3 32
      src/objects/Mesh.js
  40. 8 4
      src/objects/Object3D.js
  41. 3 2
      src/objects/Particle.js
  42. 28 16
      src/renderers/CanvasRenderer.js
  43. 15 17
      src/renderers/Projector.js
  44. 12 12
      src/renderers/SVGRenderer.js
  45. 70 61
      src/renderers/WebGLRenderer.js
  46. 136 99
      src/renderers/WebGLRenderer2.js
  47. 2 2
      src/renderers/renderables/RenderableFace3.js
  48. 1 1
      src/renderers/renderables/RenderableLine.js
  49. 1 1
      src/renderers/renderables/RenderableParticle.js
  50. 3 2
      src/scenes/Fog.js

+ 160 - 156
build/Three.js

@@ -1,183 +1,187 @@
 // Three.js r31 - http://github.com/mrdoob/three.js
 // Three.js r31 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,g){this.r=a;this.g=b;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)+
+THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,g){this.x=a||0;this.y=b||0;this.z=g||0};
-THREE.Vector3.prototype={set:function(a,b,g){this.x=a;this.y=b;this.z=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,g=this.y,d=this.z;this.x=g*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-g*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
-a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+g*g+a*a)},distanceToSquared:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return b*b+g*g+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0};
+THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
+a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
 Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
 Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
-THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1};
-THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1};
+THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"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=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,h=[];a=0;for(b=d.length;a<b;a++){g=d[a];if(g instanceof THREE.Mesh)h=h.concat(this.intersectObject(g))}h.sort(function(i,p){return i.distance-p.distance});return h},intersectObject:function(a){function b(M,s,Q,E){E=E.clone().subSelf(s);Q=Q.clone().subSelf(s);var L=M.clone().subSelf(s);M=E.dot(E);s=E.dot(Q);E=E.dot(L);var e=Q.dot(Q);Q=Q.dot(L);L=1/(M*e-s*s);e=(e*E-s*Q)*L;M=(M*Q-s*E)*L;return e>0&&M>0&&e+M<1}var g,d,h,i,p,m,o,c,D,C,
-x,w=a.geometry,K=w.vertices,P=[];g=0;for(d=w.faces.length;g<d;g++){h=w.faces[g];C=this.origin.clone();x=this.direction.clone();i=a.matrix.multiplyVector3(K[h.a].position.clone());p=a.matrix.multiplyVector3(K[h.b].position.clone());m=a.matrix.multiplyVector3(K[h.c].position.clone());o=h instanceof THREE.Face4?a.matrix.multiplyVector3(K[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());D=x.dot(c);if(D<0){c=c.dot((new THREE.Vector3).sub(i,C))/D;C=C.addSelf(x.multiplyScalar(c));
-if(h instanceof THREE.Face3){if(b(C,i,p,m)){h={distance:this.origin.distanceTo(C),point:C,face:h,object:a};P.push(h)}}else if(h instanceof THREE.Face4)if(b(C,i,p,o)||b(C,p,m,o)){h={distance:this.origin.distanceTo(C),point:C,face:h,object:a};P.push(h)}}}return P}};
-THREE.Rectangle=function(){function a(){i=d-b;p=h-g}var b,g,d,h,i,p,m=true;this.getX=function(){return b};this.getY=function(){return g};this.getWidth=function(){return i};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return g};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(o,c,D,C){m=false;b=o;g=c;d=D;h=C;a()};this.addPoint=function(o,c){if(m){m=false;b=o;g=c;d=o;h=c}else{b=b<o?b:o;g=g<c?g:c;d=d>o?d:o;h=h>c?
-h:c}a()};this.add3Points=function(o,c,D,C,x,w){if(m){m=false;b=o<D?o<x?o:x:D<x?D:x;g=c<C?c<w?c:w:C<w?C:w;d=o>D?o>x?o:x:D>x?D:x;h=c>C?c>w?c:w:C>w?C:w}else{b=o<D?o<x?o<b?o:b:x<b?x:b:D<x?D<b?D:b:x<b?x:b;g=c<C?c<w?c<g?c:g:w<g?w:g:C<w?C<g?C:g:w<g?w:g;d=o>D?o>x?o>d?o:d:x>d?x:d:D>x?D>d?D:d:x>d?x:d;h=c>C?c>w?c>h?c:h:w>h?w:h:C>w?C>h?C:h:w>h?w:h}a()};this.addRectangle=function(o){if(m){m=false;b=o.getLeft();g=o.getTop();d=o.getRight();h=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();g=g<o.getTop()?g:o.getTop();
-d=d>o.getRight()?d:o.getRight();h=h>o.getBottom()?h:o.getBottom()}a()};this.inflate=function(o){b-=o;g-=o;d+=o;h+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();g=g>o.getTop()?g:o.getTop();d=d<o.getRight()?d:o.getRight();h=h<o.getBottom()?h:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(h,o.getBottom())-Math.max(g,o.getTop())>=0};this.empty=function(){m=true;h=d=g=b=0;a()};this.isEmpty=function(){return m};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+h+", width: "+i+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
-THREE.Matrix4=function(a,b,g,d,h,i,p,m,o,c,D,C,x,w,K,P){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=h||0;this.n22=i||1;this.n23=p||0;this.n24=m||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=C||0;this.n41=x||0;this.n42=w||0;this.n43=K||0;this.n44=P||1};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,h,i,p,m,o,c,D,C,x,w,K,P){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=h;this.n22=i;this.n23=p;this.n24=m;this.n31=o;this.n32=c;this.n33=D;this.n34=C;this.n41=x;this.n42=w;this.n43=K;this.n44=P;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,b).normalize();d.cross(g,i).normalize();h.cross(i,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=i.x;
-this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,h=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24*
-h;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var g=a.n11,d=a.n12,h=a.n13,i=a.n14,p=a.n21,m=a.n22,o=a.n23,c=a.n24,D=a.n31,C=a.n32,
-x=a.n33,w=a.n34,K=a.n41,P=a.n42,M=a.n43,s=a.n44,Q=b.n11,E=b.n12,L=b.n13,e=b.n14,l=b.n21,k=b.n22,f=b.n23,n=b.n24,j=b.n31,r=b.n32,q=b.n33,u=b.n34,v=b.n41,N=b.n42,G=b.n43,F=b.n44;this.n11=g*Q+d*l+h*j+i*v;this.n12=g*E+d*k+h*r+i*N;this.n13=g*L+d*f+h*q+i*G;this.n14=g*e+d*n+h*u+i*F;this.n21=p*Q+m*l+o*j+c*v;this.n22=p*E+m*k+o*r+c*N;this.n23=p*L+m*f+o*q+c*G;this.n24=p*e+m*n+o*u+c*F;this.n31=D*Q+C*l+x*j+w*v;this.n32=D*E+C*k+x*r+w*N;this.n33=D*L+C*f+x*q+w*G;this.n34=D*e+C*n+x*u+w*F;this.n41=K*Q+P*l+M*j+s*v;
-this.n42=K*E+P*k+M*r+s*N;this.n43=K*L+P*f+M*q+s*G;this.n44=K*e+P*n+M*u+s*F;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,h=this.n14,i=this.n21,p=this.n22,m=this.n23,o=this.n24,c=this.n31,D=this.n32,C=this.n33,x=this.n34,w=this.n41,K=this.n42,P=this.n43,M=this.n44,s=a.n11,Q=a.n21,E=a.n31,L=a.n41,e=a.n12,l=a.n22,k=a.n32,f=a.n42,n=a.n13,j=a.n23,r=a.n33,q=a.n43,u=a.n14,v=a.n24,N=a.n34;a=a.n44;this.n11=b*s+g*Q+d*E+h*L;this.n12=b*e+g*l+d*k+h*f;this.n13=b*n+g*j+d*r+h*q;this.n14=
-b*u+g*v+d*N+h*a;this.n21=i*s+p*Q+m*E+o*L;this.n22=i*e+p*l+m*k+o*f;this.n23=i*n+p*j+m*r+o*q;this.n24=i*u+p*v+m*N+o*a;this.n31=c*s+D*Q+C*E+x*L;this.n32=c*e+D*l+C*k+x*f;this.n33=c*n+D*j+C*r+x*q;this.n34=c*u+D*v+C*N+x*a;this.n41=w*s+K*Q+P*E+M*L;this.n42=w*e+K*l+P*k+M*f;this.n43=w*n+K*j+P*r+M*q;this.n44=w*u+K*v+P*N+M*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*=
+THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,h=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)h=h.concat(this.intersectObject(f))}h.sort(function(i,p){return i.distance-p.distance});return h},intersectObject:function(a){function b(O,q,R,E){E=E.clone().subSelf(q);R=R.clone().subSelf(q);var J=O.clone().subSelf(q);O=E.dot(E);q=E.dot(R);E=E.dot(J);var e=R.dot(R);R=R.dot(J);J=1/(O*e-q*q);e=(e*E-q*R)*J;O=(O*R-q*E)*J;return e>0&&O>0&&e+O<1}var f,d,h,i,p,m,o,c,D,F,
+w,u=a.geometry,I=u.vertices,Q=[];f=0;for(d=u.faces.length;f<d;f++){h=u.faces[f];F=this.origin.clone();w=this.direction.clone();i=a.matrix.multiplyVector3(I[h.a].position.clone());p=a.matrix.multiplyVector3(I[h.b].position.clone());m=a.matrix.multiplyVector3(I[h.c].position.clone());o=h instanceof THREE.Face4?a.matrix.multiplyVector3(I[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());D=w.dot(c);if(D<0){c=c.dot((new THREE.Vector3).sub(i,F))/D;F=F.addSelf(w.multiplyScalar(c));
+if(h instanceof THREE.Face3){if(b(F,i,p,m)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};Q.push(h)}}else if(h instanceof THREE.Face4)if(b(F,i,p,o)||b(F,p,m,o)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};Q.push(h)}}}return Q}};
+THREE.Rectangle=function(){function a(){i=d-b;p=h-f}var b,f,d,h,i,p,m=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return i};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(o,c,D,F){m=false;b=o;f=c;d=D;h=F;a()};this.addPoint=function(o,c){if(m){m=false;b=o;f=c;d=o;h=c}else{b=b<o?b:o;f=f<c?f:c;d=d>o?d:o;h=h>c?
+h:c}a()};this.add3Points=function(o,c,D,F,w,u){if(m){m=false;b=o<D?o<w?o:w:D<w?D:w;f=c<F?c<u?c:u:F<u?F:u;d=o>D?o>w?o:w:D>w?D:w;h=c>F?c>u?c:u:F>u?F:u}else{b=o<D?o<w?o<b?o:b:w<b?w:b:D<w?D<b?D:b:w<b?w:b;f=c<F?c<u?c<f?c:f:u<f?u:f:F<u?F<f?F:f:u<f?u:f;d=o>D?o>w?o>d?o:d:w>d?w:d:D>w?D>d?D:d:w>d?w:d;h=c>F?c>u?c>h?c:h:u>h?u:h:F>u?F>h?F:h:u>h?u:h}a()};this.addRectangle=function(o){if(m){m=false;b=o.getLeft();f=o.getTop();d=o.getRight();h=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();f=f<o.getTop()?f:o.getTop();
+d=d>o.getRight()?d:o.getRight();h=h>o.getBottom()?h:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;h+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d<o.getRight()?d:o.getRight();h=h<o.getBottom()?h:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(h,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){m=true;h=d=f=b=0;a()};this.isEmpty=function(){return m};this.toString=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+h+", width: "+i+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
+THREE.Matrix4=function(a,b,f,d,h,i,p,m,o,c,D,F,w,u,I,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=h||0;this.n22=i||1;this.n23=p||0;this.n24=m||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=F||0;this.n41=w||0;this.n42=u||0;this.n43=I||0;this.n44=Q||1};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,d,h,i,p,m,o,c,D,F,w,u,I,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=h;this.n22=i;this.n23=p;this.n24=m;this.n31=o;this.n32=c;this.n33=D;this.n34=F;this.n41=w;this.n42=u;this.n43=I;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var d=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,b).normalize();d.cross(f,i).normalize();h.cross(i,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=i.x;
+this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,h=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
+h;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,h=a.n13,i=a.n14,p=a.n21,m=a.n22,o=a.n23,c=a.n24,D=a.n31,F=a.n32,
+w=a.n33,u=a.n34,I=a.n41,Q=a.n42,O=a.n43,q=a.n44,R=b.n11,E=b.n12,J=b.n13,e=b.n14,l=b.n21,j=b.n22,g=b.n23,n=b.n24,k=b.n31,r=b.n32,x=b.n33,v=b.n34,z=b.n41,U=b.n42,s=b.n43,L=b.n44;this.n11=f*R+d*l+h*k+i*z;this.n12=f*E+d*j+h*r+i*U;this.n13=f*J+d*g+h*x+i*s;this.n14=f*e+d*n+h*v+i*L;this.n21=p*R+m*l+o*k+c*z;this.n22=p*E+m*j+o*r+c*U;this.n23=p*J+m*g+o*x+c*s;this.n24=p*e+m*n+o*v+c*L;this.n31=D*R+F*l+w*k+u*z;this.n32=D*E+F*j+w*r+u*U;this.n33=D*J+F*g+w*x+u*s;this.n34=D*e+F*n+w*v+u*L;this.n41=I*R+Q*l+O*k+q*z;
+this.n42=I*E+Q*j+O*r+q*U;this.n43=I*J+Q*g+O*x+q*s;this.n44=I*e+Q*n+O*v+q*L;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,h=this.n14,i=this.n21,p=this.n22,m=this.n23,o=this.n24,c=this.n31,D=this.n32,F=this.n33,w=this.n34,u=this.n41,I=this.n42,Q=this.n43,O=this.n44,q=a.n11,R=a.n21,E=a.n31,J=a.n41,e=a.n12,l=a.n22,j=a.n32,g=a.n42,n=a.n13,k=a.n23,r=a.n33,x=a.n43,v=a.n14,z=a.n24,U=a.n34;a=a.n44;this.n11=b*q+f*R+d*E+h*J;this.n12=b*e+f*l+d*j+h*g;this.n13=b*n+f*k+d*r+h*x;this.n14=
+b*v+f*z+d*U+h*a;this.n21=i*q+p*R+m*E+o*J;this.n22=i*e+p*l+m*j+o*g;this.n23=i*n+p*k+m*r+o*x;this.n24=i*v+p*z+m*U+o*a;this.n31=c*q+D*R+F*E+w*J;this.n32=c*e+D*l+F*j+w*g;this.n33=c*n+D*k+F*r+w*x;this.n34=c*v+D*z+F*U+w*a;this.n41=u*q+I*R+Q*E+O*J;this.n42=u*e+I*l+Q*j+O*g;this.n43=u*n+I*k+Q*r+O*x;this.n44=u*v+I*z+Q*U+O*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
 a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
-this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var h=b[g];b[g]=b[d];
+this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,d){var h=b[f];b[f]=b[d];
 b[d]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
 b[d]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
-this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d};
-THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),i=1-d,p=a.x,m=a.y,o=a.z;g.n11=i*p*p+d;g.n12=i*p*m-h*o;g.n13=i*p*o+h*m;g.n21=i*p*m+h*o;g.n22=i*m*m+d;g.n23=i*m*o-h*p;g.n31=i*p*o-h*m;g.n32=i*m*o+h*p;g.n33=i*o*o+d;return g};
+this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
+THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),i=1-d,p=a.x,m=a.y,o=a.z;f.n11=i*p*p+d;f.n12=i*p*m-h*o;f.n13=i*p*o+h*m;f.n21=i*p*m+h*o;f.n22=i*m*m+d;f.n23=i*m*o-h*p;f.n31=i*p*o-h*m;f.n32=i*m*o+h*p;f.n33=i*o*o+d;return f};
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],m=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*i+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*i;a.m[4]=b*p;a.m[5]=b*m;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a};
-THREE.Matrix4.makeFrustum=function(a,b,g,d,h,i){var p,m,o;p=new THREE.Matrix4;m=2*h/(b-a);o=2*h/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(i+h)/(i-h);h=-2*i*h/(i-h);p.n11=m;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=g;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,g,d){var h;a=g*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,g,d)};
-THREE.Matrix4.makeOrtho=function(a,b,g,d,h,i){var p,m,o,c;p=new THREE.Matrix4;m=b-a;o=g-d;c=i-h;a=(b+a)/m;g=(g+d)/o;h=(i+h)/c;p.n11=2/m;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-g;p.n31=0;p.n32=0;p.n33=-2/c;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],m=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*i+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*i;a.m[4]=b*p;a.m[5]=b*m;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a};
+THREE.Matrix4.makeFrustum=function(a,b,f,d,h,i){var p,m,o;p=new THREE.Matrix4;m=2*h/(b-a);o=2*h/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(i+h)/(i-h);h=-2*i*h/(i-h);p.n11=m;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var h;a=f*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,f,d)};
+THREE.Matrix4.makeOrtho=function(a,b,f,d,h,i){var p,m,o,c;p=new THREE.Matrix4;m=b-a;o=f-d;c=i-h;a=(b+a)/m;f=(f+d)/o;h=(i+h)/c;p.n11=2/m;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/c;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,b,g,d,h){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,b,g,d,h,i){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
+THREE.Face3=function(a,b,f,d,h){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,b,f,d,h,i){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=i instanceof Array?i:[i]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
-THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a<b;a++){g=this.faces[a];g.centroid.set(0,0,0);if(g instanceof THREE.Face3){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);g.centroid.divideScalar(3)}else if(g instanceof THREE.Face4){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);
-g.centroid.addSelf(this.vertices[g.d].position);g.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,g,d,h,i,p,m=new THREE.Vector3,o=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){i=this.vertices[d];i.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){i=this.faces[d];if(a&&i.vertexNormals.length){m.set(0,0,0);b=0;for(g=i.normal.length;b<g;b++)m.addSelf(i.vertexNormals[b]);m.divideScalar(3)}else{b=this.vertices[i.a];g=this.vertices[i.b];p=this.vertices[i.c];m.sub(p.position,
-g.position);o.sub(b.position,g.position);m.crossSelf(o)}m.isZero()||m.normalize();i.normal.copy(m)}},computeVertexNormals:function(){var a,b=[],g,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(u,v,N,G){i=u.vertices[v].position;p=u.vertices[N].position;
-m=u.vertices[G].position;o=h[0];c=h[1];D=h[2];C=p.x-i.x;x=m.x-i.x;w=p.y-i.y;K=m.y-i.y;P=p.z-i.z;M=m.z-i.z;s=c.u-o.u;Q=D.u-o.u;E=c.v-o.v;L=D.v-o.v;e=1/(s*L-Q*E);n.set((L*C-E*x)*e,(L*w-E*K)*e,(L*P-E*M)*e);j.set((s*x-Q*C)*e,(s*K-Q*w)*e,(s*M-Q*P)*e);k[v].addSelf(n);k[N].addSelf(n);k[G].addSelf(n);f[v].addSelf(j);f[N].addSelf(j);f[G].addSelf(j)}var b,g,d,h,i,p,m,o,c,D,C,x,w,K,P,M,s,Q,E,L,e,l,k=[],f=[],n=new THREE.Vector3,j=new THREE.Vector3,r=new THREE.Vector3,q=new THREE.Vector3;l=new THREE.Vector3;b=
-0;for(g=this.vertices.length;b<g;b++){k[b]=new THREE.Vector3;f[b]=new THREE.Vector3}b=0;for(g=this.faces.length;b<g;b++){d=this.faces[b];h=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
-this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(g=this.vertices.length;b<g;b++){l.copy(this.vertices[b].normal);d=k[b];r.copy(d);r.subSelf(l.multiplyScalar(l.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(f[b]);d=test<0?-1:1;this.vertices[b].tangent.set(r.x,r.y,r.z,d)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.bbox={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,g=this.vertices.length;b<g;b++){a=this.vertices[b];if(a.position.x<this.bbox.x[0])this.bbox.x[0]=a.position.x;else if(a.position.x>this.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.y<this.bbox.y[0])this.bbox.y[0]=a.position.y;else if(a.position.y>this.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z<this.bbox.z[0])this.bbox.z[0]=a.position.z;else if(a.position.z>
-this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,g=this.vertices.length;b<g;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(D){var C=[];b=0;for(g=D.length;b<g;b++)D[b]==undefined?C.push("undefined"):C.push(D[b].toString());return C.join("_")}var b,g,d,h,i,p,m,o,c={};d=0;for(h=this.faces.length;d<h;d++){i=this.faces[d];p=
-i.material;m=a(p);if(c[m]==undefined)c[m]={hash:m,counter:0};o=c[m].hash+"_"+c[m].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:p,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[o].vertices+i>65535){c[m].counter+=1;o=c[m].hash+"_"+c[m].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:p,vertices:0}}this.geometryChunks[o].faces.push(d);this.geometryChunks[o].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
-this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
-this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
-THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
-THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
-this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
-THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
-a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
-THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
-a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
-this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
-THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
-"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
-a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
-a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
-this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
-THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
-this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,h,i,p,m=new THREE.Vector3,o=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){i=this.vertices[d];i.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){i=this.faces[d];if(a&&i.vertexNormals.length){m.set(0,0,0);b=0;for(f=i.normal.length;b<f;b++)m.addSelf(i.vertexNormals[b]);m.divideScalar(3)}else{b=this.vertices[i.a];f=this.vertices[i.b];p=this.vertices[i.c];m.sub(p.position,
+f.position);o.sub(b.position,f.position);m.crossSelf(o)}m.isZero()||m.normalize();i.normal.copy(m)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(v,z,U,s){i=v.vertices[z].position;p=v.vertices[U].position;
+m=v.vertices[s].position;o=h[0];c=h[1];D=h[2];F=p.x-i.x;w=m.x-i.x;u=p.y-i.y;I=m.y-i.y;Q=p.z-i.z;O=m.z-i.z;q=c.u-o.u;R=D.u-o.u;E=c.v-o.v;J=D.v-o.v;e=1/(q*J-R*E);n.set((J*F-E*w)*e,(J*u-E*I)*e,(J*Q-E*O)*e);k.set((q*w-R*F)*e,(q*I-R*u)*e,(q*O-R*Q)*e);j[z].addSelf(n);j[U].addSelf(n);j[s].addSelf(n);g[z].addSelf(k);g[U].addSelf(k);g[s].addSelf(k)}var b,f,d,h,i,p,m,o,c,D,F,w,u,I,Q,O,q,R,E,J,e,l,j=[],g=[],n=new THREE.Vector3,k=new THREE.Vector3,r=new THREE.Vector3,x=new THREE.Vector3;l=new THREE.Vector3;b=
+0;for(f=this.vertices.length;b<f;b++){j[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];h=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
+this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){l.copy(this.vertices[b].normal);d=j[b];r.copy(d);r.subSelf(l.multiplyScalar(l.dot(d))).normalize();x.cross(this.vertices[b].normal,d);test=x.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(r.x,r.y,r.z,d)}this.hasTangents=true},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,f=this.vertices.length;b<f;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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(c){var D=[];b=0;for(f=c.length;b<f;b++)c[b]==undefined?D.push("undefined"):D.push(c[b].toString());return D.join("_")}
+var b,f,d,h,i,p,m,o={};d=0;for(h=this.faces.length;d<h;d++){i=this.faces[d];materials=i.materials;p=a(materials);if(o[p]==undefined)o[p]={hash:p,counter:0};m=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:materials,vertices:0};i=i instanceof THREE.Face3?3:4;if(this.geometryChunks[m].vertices+i>65535){o[p].counter+=1;m=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[m]==undefined)this.geometryChunks[m]={faces:[],materials:materials,vertices:0}}this.geometryChunks[m].faces.push(d);
+this.geometryChunks[m].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
+this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix();this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
+THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
+THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
+THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
+THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
+this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;
+THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}};
+THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
+THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
+undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
+THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
+undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
+THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
+this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
+a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
+undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
+THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
+THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
 THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
 THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
-undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
-"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
-THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
-THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
-THREE.Texture=function(a,b,g,d,h,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
-this.min_filter+"<br/>)"}};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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
-THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
+THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
+THREE.Texture=function(a,b,f,d,h,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=i!==undefined?i:THREE.LinearMipMapLinearFilter};
+THREE.Texture.prototype={toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
-THREE.Fog=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(k,f){return f.z-k.z}function b(k,f){var n=0,j=1,r=k.z+k.w,q=f.z+f.w,u=-k.z+k.w,v=-f.z+f.w;if(r>=0&&q>=0&&u>=0&&v>=0)return true;else if(r<0&&q<0||u<0&&v<0)return false;else{if(r<0)n=Math.max(n,r/(r-q));else if(q<0)j=Math.min(j,r/(r-q));if(u<0)n=Math.max(n,u/(u-v));else if(v<0)j=Math.min(j,u/(u-v));if(j<n)return false;else{k.lerpSelf(f,n);f.lerpSelf(k,1-j);return true}}}var g,d,h=[],i,p,m,o=[],c,D,C=[],x,w,K=[],P=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
-Q=new THREE.Matrix4,E=[],L=new THREE.Vector4,e=new THREE.Vector4,l;this.projectObjects=function(k,f,n){var j=[],r,q;d=0;s.multiply(f.projectionMatrix,f.matrix);E[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);E[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);E[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);E[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);E[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
-s.n33,s.n44-s.n34);E[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);f=0;for(r=E.length;f<r;f++){q=E[f];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}r=k.objects;k=0;for(f=r.length;k<f;k++){q=r[k];var u;if(!(u=!q.visible)){if(u=q instanceof THREE.Mesh){a:{u=void 0;for(var v=q.position,N=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),G=0;G<6;G++){u=E[G].x*v.x+E[G].y*v.y+E[G].z*v.z+E[G].w;if(u<=N){u=false;break a}}u=true}u=!u}u=u}if(!u){g=
-h[d]=h[d]||new THREE.RenderableObject;P.copy(q.position);s.multiplyVector3(P);g.object=q;g.z=P.z;j.push(g);d++}}n&&j.sort(a);return j};this.projectScene=function(k,f,n){var j=[],r,q,u,v,N,G,F,A,W,T,V,z,t,H,R,I;m=D=w=0;f.autoUpdateMatrix&&f.updateMatrix();s.multiply(f.projectionMatrix,f.matrix);G=this.projectObjects(k,f,true);k=0;for(r=G.length;k<r;k++){F=G[k].object;if(F.visible){F.autoUpdateMatrix&&F.updateMatrix();A=F.matrix;W=F.rotationMatrix;T=F.material;V=F.overdraw;if(F instanceof THREE.Mesh){z=
-F.geometry;t=z.vertices;q=0;for(u=t.length;q<u;q++){H=t[q];H.positionWorld.copy(H.position);A.multiplyVector3(H.positionWorld);v=H.positionScreen;v.copy(H.positionWorld);s.multiplyVector4(v);v.multiplyScalar(1/v.w);H.__visible=v.z>0&&v.z<1}z=z.faces;q=0;for(u=z.length;q<u;q++){H=z[q];if(H instanceof THREE.Face3){v=t[H.a];N=t[H.b];R=t[H.c];if(v.__visible&&N.__visible&&R.__visible)if(F.doubleSided||F.flipSided!=(R.positionScreen.x-v.positionScreen.x)*(N.positionScreen.y-v.positionScreen.y)-(R.positionScreen.y-
-v.positionScreen.y)*(N.positionScreen.x-v.positionScreen.x)<0){i=o[m]=o[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(v.positionWorld);i.v2.positionWorld.copy(N.positionWorld);i.v3.positionWorld.copy(R.positionWorld);i.v1.positionScreen.copy(v.positionScreen);i.v2.positionScreen.copy(N.positionScreen);i.v3.positionScreen.copy(R.positionScreen);i.normalWorld.copy(H.normal);W.multiplyVector3(i.normalWorld);i.centroidWorld.copy(H.centroid);A.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);
-s.multiplyVector3(i.centroidScreen);R=H.vertexNormals;l=i.vertexNormalsWorld;v=0;for(N=R.length;v<N;v++){I=l[v]=l[v]||new THREE.Vector3;I.copy(R[v]);W.multiplyVector3(I)}i.z=i.centroidScreen.z;i.meshMaterial=T;i.faceMaterial=H.material;i.overdraw=V;if(F.geometry.uvs[q]){i.uvs[0]=F.geometry.uvs[q][0];i.uvs[1]=F.geometry.uvs[q][1];i.uvs[2]=F.geometry.uvs[q][2]}j.push(i);m++}}else if(H instanceof THREE.Face4){v=t[H.a];N=t[H.b];R=t[H.c];I=t[H.d];if(v.__visible&&N.__visible&&R.__visible&&I.__visible)if(F.doubleSided||
-F.flipSided!=((I.positionScreen.x-v.positionScreen.x)*(N.positionScreen.y-v.positionScreen.y)-(I.positionScreen.y-v.positionScreen.y)*(N.positionScreen.x-v.positionScreen.x)<0||(N.positionScreen.x-R.positionScreen.x)*(I.positionScreen.y-R.positionScreen.y)-(N.positionScreen.y-R.positionScreen.y)*(I.positionScreen.x-R.positionScreen.x)<0)){i=o[m]=o[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(v.positionWorld);i.v2.positionWorld.copy(N.positionWorld);i.v3.positionWorld.copy(I.positionWorld);
-i.v1.positionScreen.copy(v.positionScreen);i.v2.positionScreen.copy(N.positionScreen);i.v3.positionScreen.copy(I.positionScreen);i.normalWorld.copy(H.normal);W.multiplyVector3(i.normalWorld);i.centroidWorld.copy(H.centroid);A.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);s.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterial=T;i.faceMaterial=H.material;i.overdraw=V;if(F.geometry.uvs[q]){i.uvs[0]=F.geometry.uvs[q][0];i.uvs[1]=F.geometry.uvs[q][1];i.uvs[2]=
-F.geometry.uvs[q][3]}j.push(i);m++;p=o[m]=o[m]||new THREE.RenderableFace3;p.v1.positionWorld.copy(N.positionWorld);p.v2.positionWorld.copy(R.positionWorld);p.v3.positionWorld.copy(I.positionWorld);p.v1.positionScreen.copy(N.positionScreen);p.v2.positionScreen.copy(R.positionScreen);p.v3.positionScreen.copy(I.positionScreen);p.normalWorld.copy(i.normalWorld);p.centroidWorld.copy(i.centroidWorld);p.centroidScreen.copy(i.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterial=T;p.faceMaterial=H.material;
-p.overdraw=V;if(F.geometry.uvs[q]){p.uvs[0]=F.geometry.uvs[q][1];p.uvs[1]=F.geometry.uvs[q][2];p.uvs[2]=F.geometry.uvs[q][3]}j.push(p);m++}}}}else if(F instanceof THREE.Line){Q.multiply(s,A);t=F.geometry.vertices;H=t[0];H.positionScreen.copy(H.position);Q.multiplyVector4(H.positionScreen);q=1;for(u=t.length;q<u;q++){v=t[q];v.positionScreen.copy(v.position);Q.multiplyVector4(v.positionScreen);N=t[q-1];L.copy(v.positionScreen);e.copy(N.positionScreen);if(b(L,e)){L.multiplyScalar(1/L.w);e.multiplyScalar(1/
-e.w);c=C[D]=C[D]||new THREE.RenderableLine;c.v1.positionScreen.copy(L);c.v2.positionScreen.copy(e);c.z=Math.max(L.z,e.z);c.material=F.material;j.push(c);D++}}}else if(F instanceof THREE.Particle){M.set(F.position.x,F.position.y,F.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){x=K[w]=K[w]||new THREE.RenderableParticle;x.x=M.x/M.w;x.y=M.y/M.w;x.z=M.z;x.rotation=F.rotation.z;x.scale.x=F.scale.x*Math.abs(x.x-(M.x+f.projectionMatrix.n11)/(M.w+f.projectionMatrix.n14));x.scale.y=F.scale.y*
-Math.abs(x.y-(M.y+f.projectionMatrix.n22)/(M.w+f.projectionMatrix.n24));x.material=F.material;j.push(x);w++}}}}n&&j.sort(a);return j};this.unprojectVector=function(k,f){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(f.matrix),THREE.Matrix4.makeInvert(f.projectionMatrix));n.multiplyVector3(k);return k}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,h,i;this.domElement=document.createElement("div");this.setSize=function(p,m){g=p;d=m;h=g/2;i=d/2};this.render=function(p,m){var o,c,D,C,x,w,K,P;a=b.projectScene(p,m);o=0;for(c=a.length;o<c;o++){x=a[o];if(x instanceof THREE.RenderableParticle){K=x.x*h+h;P=x.y*i+i;D=0;for(C=x.material.length;D<C;D++){w=x.material[D];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=K+"px";w.style.top=P+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,g=document.createElement("canvas"),d,h,i,p,m=g.getContext("2d"),o=1,c=0,D=null,C=null,x=1,w,K,P,M,s,Q,E,L,e,l=new THREE.Color,k=new THREE.Color,f=new THREE.Color,n=new THREE.Color,j=new THREE.Color,r,q,u,v,N,G,F,A,W,T,V=new THREE.Rectangle,z=new THREE.Rectangle,t=new THREE.Rectangle,H=false,R=new THREE.Color,I=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,Y=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ua){d=ga;h=ua;i=d/2;p=h/2;g.width=d;g.height=h;V.set(-i,-p,i,p)};this.clear=function(){if(!z.isEmpty()){z.inflate(1);z.minSelf(V);m.clearRect(z.getX(),
-z.getY(),z.getWidth(),z.getHeight());z.empty()}};this.render=function(ga,ua){function Ka(y){var S,O,B,J=y.lights;I.setRGB(0,0,0);U.setRGB(0,0,0);aa.setRGB(0,0,0);y=0;for(S=J.length;y<S;y++){O=J[y];B=O.color;if(O instanceof THREE.AmbientLight){I.r+=B.r;I.g+=B.g;I.b+=B.b}else if(O instanceof THREE.DirectionalLight){U.r+=B.r;U.g+=B.g;U.b+=B.b}else if(O instanceof THREE.PointLight){aa.r+=B.r;aa.g+=B.g;aa.b+=B.b}}}function va(y,S,O,B){var J,X,$,ba,ca=y.lights;y=0;for(J=ca.length;y<J;y++){X=ca[y];$=X.color;
-ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=O.dot(X.position)*ba;if(X>0){B.r+=$.r*X;B.g+=$.g*X;B.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,S);Y.normalize();X=O.dot(Y)*ba;if(X>0){B.r+=$.r*X;B.g+=$.g*X;B.b+=$.b*X}}}}function La(y,S,O){if(O.opacity!=0){Ba(O.opacity);wa(O.blending);var B,J,X,$,ba,ca;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){$=O.map;ba=$.width>>1;ca=$.height>>1;J=S.scale.x*i;X=S.scale.y*p;O=J*ba;B=X*ca;t.set(y.x-O,y.y-B,y.x+O,y.y+B);if(V.instersects(t)){m.save();
-m.translate(y.x,y.y);m.rotate(-S.rotation);m.scale(J,-X);m.translate(-ba,-ca);m.drawImage($,0,0);m.restore()}}}else if(O instanceof THREE.ParticleCircleMaterial){if(H){R.r=I.r+U.r+aa.r;R.g=I.g+U.g+aa.g;R.b=I.b+U.b+aa.b;l.r=O.color.r*R.r;l.g=O.color.g*R.g;l.b=O.color.b*R.b;l.updateStyleString()}else l.__styleString=O.color.__styleString;O=S.scale.x*i;B=S.scale.y*p;t.set(y.x-O,y.y-B,y.x+O,y.y+B);if(V.instersects(t)){J=l.__styleString;if(C!=J)m.fillStyle=C=J;m.save();m.translate(y.x,y.y);m.rotate(-S.rotation);
-m.scale(O,B);m.beginPath();m.arc(0,0,1,0,Ja,true);m.closePath();m.fill();m.restore()}}}}function Ma(y,S,O,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);m.beginPath();m.moveTo(y.positionScreen.x,y.positionScreen.y);m.lineTo(S.positionScreen.x,S.positionScreen.y);m.closePath();if(B instanceof THREE.LineBasicMaterial){l.__styleString=B.color.__styleString;y=B.linewidth;if(x!=y)m.lineWidth=x=y;y=l.__styleString;if(D!=y)m.strokeStyle=D=y;m.stroke();t.inflate(B.linewidth*2)}}}function Fa(y,S,O,B,J,X){if(J.opacity!=
-0){Ba(J.opacity);wa(J.blending);M=y.positionScreen.x;s=y.positionScreen.y;Q=S.positionScreen.x;E=S.positionScreen.y;L=O.positionScreen.x;e=O.positionScreen.y;m.beginPath();m.moveTo(M,s);m.lineTo(Q,E);m.lineTo(L,e);m.lineTo(M,s);m.closePath();if(J instanceof THREE.MeshBasicMaterial)if(J.map)J.map.image.loaded&&J.map.mapping instanceof THREE.UVMapping&&qa(M,s,Q,E,L,e,J.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(J.env_map){if(J.env_map.image.loaded)if(J.env_map.mapping instanceof
-THREE.SphericalReflectionMapping){y=ua.matrix;Y.copy(B.vertexNormalsWorld[0]);N=(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;G=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);F=(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;A=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);W=(Y.x*y.n11+Y.y*y.n12+Y.z*y.n13)*0.5+0.5;T=-(Y.x*y.n21+Y.y*y.n22+Y.z*y.n23)*0.5+0.5;qa(M,s,Q,E,L,e,J.env_map.image,N,G,F,A,W,T)}}else J.wireframe?xa(J.color.__styleString,J.wireframe_linewidth):
-ya(J.color.__styleString);else if(J instanceof THREE.MeshLambertMaterial){if(J.map&&!J.wireframe){J.map.mapping instanceof THREE.UVMapping&&qa(M,s,Q,E,L,e,J.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(H)if(!J.wireframe&&J.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){k.r=f.r=n.r=I.r;k.g=f.g=n.g=I.g;k.b=f.b=n.b=I.b;va(X,B.v1.positionWorld,B.vertexNormalsWorld[0],k);va(X,B.v2.positionWorld,B.vertexNormalsWorld[1],f);va(X,
-B.v3.positionWorld,B.vertexNormalsWorld[2],n);j.r=(f.r+n.r)*0.5;j.g=(f.g+n.g)*0.5;j.b=(f.b+n.b)*0.5;v=Ga(k,f,n,j);qa(M,s,Q,E,L,e,v,0,0,1,0,0,1)}else{R.r=I.r;R.g=I.g;R.b=I.b;va(X,B.centroidWorld,B.normalWorld,R);l.r=J.color.r*R.r;l.g=J.color.g*R.g;l.b=J.color.b*R.b;l.updateStyleString();J.wireframe?xa(l.__styleString,J.wireframe_linewidth):ya(l.__styleString)}else J.wireframe?xa(J.color.__styleString,J.wireframe_linewidth):ya(J.color.__styleString)}else if(J instanceof THREE.MeshDepthMaterial){r=J.__2near;
-q=J.__farPlusNear;u=J.__farMinusNear;k.r=k.g=k.b=1-r/(q-y.positionScreen.z*u);f.r=f.g=f.b=1-r/(q-S.positionScreen.z*u);n.r=n.g=n.b=1-r/(q-O.positionScreen.z*u);j.r=(f.r+n.r)*0.5;j.g=(f.g+n.g)*0.5;j.b=(f.b+n.b)*0.5;v=Ga(k,f,n,j);qa(M,s,Q,E,L,e,v,0,0,1,0,0,1)}else if(J instanceof THREE.MeshNormalMaterial){l.r=Ca(B.normalWorld.x);l.g=Ca(B.normalWorld.y);l.b=Ca(B.normalWorld.z);l.updateStyleString();J.wireframe?xa(l.__styleString,J.wireframe_linewidth):ya(l.__styleString)}}}function xa(y,S){if(D!=y)m.strokeStyle=
-D=y;if(x!=S)m.lineWidth=x=S;m.stroke();t.inflate(S*2)}function ya(y){if(C!=y)m.fillStyle=C=y;m.fill()}function qa(y,S,O,B,J,X,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;O-=y;B-=S;J-=y;X-=S;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=(ra*O-ea*J)*ja;ea=(ra*B-ea*X)*ja;O=(ha*J-ia*O)*ja;B=(ha*X-ia*B)*ja;y=y-ka*ba-O*ca;S=S-ea*ba-B*ca;m.save();m.transform(ka,ea,O,B,y,S);m.clip();m.drawImage($,0,0);m.restore()}function Ba(y){if(o!=y)m.globalAlpha=
-o=y}function wa(y){if(c!=y){switch(y){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}c=y}}function Ga(y,S,O,B){var J=~~(y.r*255),X=~~(y.g*255);y=~~(y.b*255);var $=~~(S.r*255),ba=~~(S.g*255);S=~~(S.b*255);var ca=~~(O.r*255),ha=~~(O.g*255);O=~~(O.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=J<0?0:J>255?255:J;da[1]=X<0?0:X>
-255?255:X;da[2]=y<0?0:y>255?255:y;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=S<0?0:S>255?255:S;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=O<0?0:O>255?255:O;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;oa.putImageData(Aa,0,0);ta.drawImage(na,0,0);return pa}function Ca(y){y=(y+1)*0.5;return y<0?0:y>1?1:y}function Da(y,S){var O=S.x-y.x,B=S.y-y.y,J=1/Math.sqrt(O*O+B*B);O*=J;B*=J;S.x+=O;S.y+=B;y.x-=O;y.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;
-m.setTransform(1,0,0,-1,i,p);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);(H=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];t.empty();if(Z instanceof THREE.RenderableParticle){w=Z;w.x*=i;w.y*=p;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(w,Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){w=Z.v1;K=Z.v2;w.positionScreen.x*=i;w.positionScreen.y*=p;K.positionScreen.x*=i;K.positionScreen.y*=p;t.addPoint(w.positionScreen.x,w.positionScreen.y);
-t.addPoint(K.positionScreen.x,K.positionScreen.y);if(V.instersects(t)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(w,K,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){w=Z.v1;K=Z.v2;P=Z.v3;w.positionScreen.x*=i;w.positionScreen.y*=p;K.positionScreen.x*=i;K.positionScreen.y*=p;P.positionScreen.x*=i;P.positionScreen.y*=p;if(Z.overdraw){Da(w.positionScreen,K.positionScreen);Da(K.positionScreen,P.positionScreen);Da(P.positionScreen,w.positionScreen)}t.add3Points(w.positionScreen.x,w.positionScreen.y,
-K.positionScreen.x,K.positionScreen.y,P.positionScreen.x,P.positionScreen.y);if(V.instersects(t)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(w,K,P,Z,sa,ga)}else Fa(w,K,P,Z,sa,ga)}}}z.addRectangle(t)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(A,W,T){var V,z,t,H;V=0;for(z=A.lights.length;V<z;V++){t=A.lights[V];if(t instanceof THREE.DirectionalLight){H=W.normalWorld.dot(t.position)*t.intensity;if(H>0){T.r+=t.color.r*H;T.g+=t.color.g*H;T.b+=t.color.b*H}}else if(t instanceof THREE.PointLight){n.sub(t.position,W.centroidWorld);n.normalize();H=W.normalWorld.dot(n)*t.intensity;if(H>0){T.r+=t.color.r*H;T.g+=t.color.g*H;T.b+=t.color.b*H}}}}function b(A,W,T,V,z,t){u=d(v++);u.setAttribute("d","M "+A.positionScreen.x+
-" "+A.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)E.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(Q){L.r=e.r;L.g=e.g;L.b=e.b;a(t,V,L);E.r=z.color.r*L.r;E.g=z.color.g*L.g;E.b=z.color.b*L.b;E.updateStyleString()}else E.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){f=1-z.__2near/(z.__farPlusNear-V.z*z.__farMinusNear);
-E.setRGB(f,f,f)}else z instanceof THREE.MeshNormalMaterial&&E.setRGB(h(V.normalWorld.x),h(V.normalWorld.y),h(V.normalWorld.z));z.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+z.opacity);m.appendChild(u)}function g(A,W,T,V,z,t,H){u=d(v++);u.setAttribute("d",
-"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)E.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(Q){L.r=e.r;L.g=e.g;L.b=e.b;a(H,z,L);E.r=t.color.r*L.r;E.g=t.color.g*L.g;E.b=t.color.b*L.b;E.updateStyleString()}else E.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){f=
-1-t.__2near/(t.__farPlusNear-z.z*t.__farMinusNear);E.setRGB(f,f,f)}else t instanceof THREE.MeshNormalMaterial&&E.setRGB(h(z.normalWorld.x),h(z.normalWorld.y),h(z.normalWorld.z));t.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+t.opacity);m.appendChild(u)}
-function d(A){if(j[A]==null){j[A]=document.createElementNS("http://www.w3.org/2000/svg","path");F==0&&j[A].setAttribute("shape-rendering","crispEdges");return j[A]}return j[A]}function h(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var i=null,p=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,C,x,w,K,P,M=new THREE.Rectangle,s=new THREE.Rectangle,Q=false,E=new THREE.Color(16777215),L=new THREE.Color(16777215),e=new THREE.Color(0),l=new THREE.Color(0),
-k=new THREE.Color(0),f,n=new THREE.Vector3,j=[],r=[],q=[],u,v,N,G,F=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(A){switch(A){case "high":F=1;break;case "low":F=0}};this.setSize=function(A,W){o=A;c=W;D=o/2;C=c/2;m.setAttribute("viewBox",-D+" "+-C+" "+o+" "+c);m.setAttribute("width",o);m.setAttribute("height",c);M.set(-D,-C,D,C)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(A,W){var T,V,
-z,t,H,R,I,U;this.autoClear&&this.clear();i=p.projectScene(A,W,this.sortElements);G=N=v=0;if(Q=A.lights.length>0){I=A.lights;e.setRGB(0,0,0);l.setRGB(0,0,0);k.setRGB(0,0,0);T=0;for(V=I.length;T<V;T++){z=I[T];t=z.color;if(z instanceof THREE.AmbientLight){e.r+=t.r;e.g+=t.g;e.b+=t.b}else if(z instanceof THREE.DirectionalLight){l.r+=t.r;l.g+=t.g;l.b+=t.b}else if(z instanceof THREE.PointLight){k.r+=t.r;k.g+=t.g;k.b+=t.b}}}T=0;for(V=i.length;T<V;T++){I=i[T];s.empty();if(I instanceof THREE.RenderableParticle){x=
-I;x.x*=D;x.y*=-C;z=0;for(t=I.material.length;z<t;z++)if(U=I.material[z]){H=x;R=I;U=U;var aa=N++;if(r[aa]==null){r[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");F==0&&r[aa].setAttribute("shape-rendering","crispEdges")}u=r[aa];u.setAttribute("cx",H.x);u.setAttribute("cy",H.y);u.setAttribute("r",R.scale.x*D);if(U instanceof THREE.ParticleCircleMaterial){if(Q){L.r=e.r+l.r+k.r;L.g=e.g+l.g+k.g;L.b=e.b+l.b+k.b;E.r=U.color.r*L.r;E.g=U.color.g*L.g;E.b=U.color.b*L.b;E.updateStyleString()}else E=
-U.color;u.setAttribute("style","fill: "+E.__styleString)}m.appendChild(u)}}else if(I instanceof THREE.RenderableLine){x=I.v1;w=I.v2;x.positionScreen.x*=D;x.positionScreen.y*=-C;w.positionScreen.x*=D;w.positionScreen.y*=-C;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(w.positionScreen.x,w.positionScreen.y);if(M.instersects(s)){z=0;for(t=I.material.length;z<t;)if(U=I.material[z++]){H=x;R=w;U=U;aa=G++;if(q[aa]==null){q[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");
-F==0&&q[aa].setAttribute("shape-rendering","crispEdges")}u=q[aa];u.setAttribute("x1",H.positionScreen.x);u.setAttribute("y1",H.positionScreen.y);u.setAttribute("x2",R.positionScreen.x);u.setAttribute("y2",R.positionScreen.y);if(U instanceof THREE.LineBasicMaterial){E.__styleString=U.color.__styleString;u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+U.linewidth+"; stroke-opacity: "+U.opacity+"; stroke-linecap: "+U.linecap+"; stroke-linejoin: "+U.linejoin);m.appendChild(u)}}}}else if(I instanceof
-THREE.RenderableFace3){x=I.v1;w=I.v2;K=I.v3;x.positionScreen.x*=D;x.positionScreen.y*=-C;w.positionScreen.x*=D;w.positionScreen.y*=-C;K.positionScreen.x*=D;K.positionScreen.y*=-C;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){z=0;for(t=I.meshMaterial.length;z<t;){U=I.meshMaterial[z++];if(U instanceof THREE.MeshFaceMaterial){H=0;for(R=I.faceMaterial.length;H<R;)(U=I.faceMaterial[H++])&&
-b(x,w,K,I,U,A)}else U&&b(x,w,K,I,U,A)}}}else if(I instanceof THREE.RenderableFace4){x=I.v1;w=I.v2;K=I.v3;P=I.v4;x.positionScreen.x*=D;x.positionScreen.y*=-C;w.positionScreen.x*=D;w.positionScreen.y*=-C;K.positionScreen.x*=D;K.positionScreen.y*=-C;P.positionScreen.x*=D;P.positionScreen.y*=-C;s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(w.positionScreen.x,w.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);s.addPoint(P.positionScreen.x,P.positionScreen.y);if(M.instersects(s)){z=
-0;for(t=I.meshMaterial.length;z<t;){U=I.meshMaterial[z++];if(U instanceof THREE.MeshFaceMaterial){H=0;for(R=I.faceMaterial.length;H<R;)(U=I.faceMaterial[H++])&&g(x,w,K,P,I,U,A)}else U&&g(x,w,K,P,I,U,A)}}}}}};
-THREE.WebGLRenderer=function(a){function b(e,l,k){var f=c.createProgram();k=["#ifdef GL_ES\nprecision highp float;\n#endif",k?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
-c.attachShader(f,p("fragment",k+e));c.attachShader(f,p("vertex",n+l));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,l){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
-c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
+THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};
+THREE.Projector=function(){function a(j,g){return g.z-j.z}function b(j,g){var n=0,k=1,r=j.z+j.w,x=g.z+g.w,v=-j.z+j.w,z=-g.z+g.w;if(r>=0&&x>=0&&v>=0&&z>=0)return true;else if(r<0&&x<0||v<0&&z<0)return false;else{if(r<0)n=Math.max(n,r/(r-x));else if(x<0)k=Math.min(k,r/(r-x));if(v<0)n=Math.max(n,v/(v-z));else if(z<0)k=Math.min(k,v/(v-z));if(k<n)return false;else{j.lerpSelf(g,n);g.lerpSelf(j,1-k);return true}}}var f,d,h=[],i,p,m,o=[],c,D,F=[],w,u,I=[],Q=new THREE.Vector4,O=new THREE.Vector4,q=new THREE.Matrix4,
+R=new THREE.Matrix4,E=[],J=new THREE.Vector4,e=new THREE.Vector4,l;this.projectObjects=function(j,g,n){var k=[],r,x;d=0;q.multiply(g.projectionMatrix,g.matrix);E[0]=new THREE.Vector4(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);E[1]=new THREE.Vector4(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);E[2]=new THREE.Vector4(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);E[3]=new THREE.Vector4(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);E[4]=new THREE.Vector4(q.n41-q.n31,q.n42-q.n32,q.n43-
+q.n33,q.n44-q.n34);E[5]=new THREE.Vector4(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);g=0;for(r=E.length;g<r;g++){x=E[g];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}r=j.objects;j=0;for(g=r.length;j<g;j++){x=r[j];var v;if(!(v=!x.visible)){if(v=x instanceof THREE.Mesh){a:{v=void 0;for(var z=x.position,U=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),s=0;s<6;s++){v=E[s].x*z.x+E[s].y*z.y+E[s].z*z.z+E[s].w;if(v<=U){v=false;break a}}v=true}v=!v}v=v}if(!v){f=
+h[d]=h[d]||new THREE.RenderableObject;Q.copy(x.position);q.multiplyVector3(Q);f.object=x;f.z=Q.z;k.push(f);d++}}n&&k.sort(a);return k};this.projectScene=function(j,g,n){var k=[],r=g.near,x=g.far,v,z,U,s,L,C,H,T,W,y,A,P,V,G,M,Y;m=D=u=0;g.autoUpdateMatrix&&g.updateMatrix();q.multiply(g.projectionMatrix,g.matrix);C=this.projectObjects(j,g,true);j=0;for(v=C.length;j<v;j++){H=C[j].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();T=H.matrix;W=H.rotationMatrix;y=H.materials;A=H.overdraw;if(H instanceof
+THREE.Mesh){P=H.geometry;V=P.vertices;z=0;for(U=V.length;z<U;z++){G=V[z];G.positionWorld.copy(G.position);T.multiplyVector3(G.positionWorld);s=G.positionScreen;s.copy(G.positionWorld);q.multiplyVector4(s);s.x/=s.w;s.y/=s.w;G.__visible=s.z>r&&s.z<x}P=P.faces;z=0;for(U=P.length;z<U;z++){G=P[z];if(G instanceof THREE.Face3){s=V[G.a];L=V[G.b];M=V[G.c];if(s.__visible&&L.__visible&&M.__visible)if(H.doubleSided||H.flipSided!=(M.positionScreen.x-s.positionScreen.x)*(L.positionScreen.y-s.positionScreen.y)-
+(M.positionScreen.y-s.positionScreen.y)*(L.positionScreen.x-s.positionScreen.x)<0){i=o[m]=o[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(s.positionWorld);i.v2.positionWorld.copy(L.positionWorld);i.v3.positionWorld.copy(M.positionWorld);i.v1.positionScreen.copy(s.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(M.positionScreen);i.normalWorld.copy(G.normal);W.multiplyVector3(i.normalWorld);i.centroidWorld.copy(G.centroid);T.multiplyVector3(i.centroidWorld);
+i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);M=G.vertexNormals;l=i.vertexNormalsWorld;s=0;for(L=M.length;s<L;s++){Y=l[s]=l[s]||new THREE.Vector3;Y.copy(M[s]);W.multiplyVector3(Y)}i.z=i.centroidScreen.z;i.meshMaterials=y;i.faceMaterials=G.materials;i.overdraw=A;if(H.geometry.uvs[z]){i.uvs[0]=H.geometry.uvs[z][0];i.uvs[1]=H.geometry.uvs[z][1];i.uvs[2]=H.geometry.uvs[z][2]}k.push(i);m++}}else if(G instanceof THREE.Face4){s=V[G.a];L=V[G.b];M=V[G.c];Y=V[G.d];if(s.__visible&&
+L.__visible&&M.__visible&&Y.__visible)if(H.doubleSided||H.flipSided!=((Y.positionScreen.x-s.positionScreen.x)*(L.positionScreen.y-s.positionScreen.y)-(Y.positionScreen.y-s.positionScreen.y)*(L.positionScreen.x-s.positionScreen.x)<0||(L.positionScreen.x-M.positionScreen.x)*(Y.positionScreen.y-M.positionScreen.y)-(L.positionScreen.y-M.positionScreen.y)*(Y.positionScreen.x-M.positionScreen.x)<0)){i=o[m]=o[m]||new THREE.RenderableFace3;i.v1.positionWorld.copy(s.positionWorld);i.v2.positionWorld.copy(L.positionWorld);
+i.v3.positionWorld.copy(Y.positionWorld);i.v1.positionScreen.copy(s.positionScreen);i.v2.positionScreen.copy(L.positionScreen);i.v3.positionScreen.copy(Y.positionScreen);i.normalWorld.copy(G.normal);W.multiplyVector3(i.normalWorld);i.centroidWorld.copy(G.centroid);T.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);q.multiplyVector3(i.centroidScreen);i.z=i.centroidScreen.z;i.meshMaterials=y;i.faceMaterials=G.materials;i.overdraw=A;if(H.geometry.uvs[z]){i.uvs[0]=H.geometry.uvs[z][0];
+i.uvs[1]=H.geometry.uvs[z][1];i.uvs[2]=H.geometry.uvs[z][3]}k.push(i);m++;p=o[m]=o[m]||new THREE.RenderableFace3;p.v1.positionWorld.copy(L.positionWorld);p.v2.positionWorld.copy(M.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(L.positionScreen);p.v2.positionScreen.copy(M.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(i.normalWorld);p.centroidWorld.copy(i.centroidWorld);p.centroidScreen.copy(i.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+y;p.faceMaterials=G.materials;p.overdraw=A;if(H.geometry.uvs[z]){p.uvs[0]=H.geometry.uvs[z][1];p.uvs[1]=H.geometry.uvs[z][2];p.uvs[2]=H.geometry.uvs[z][3]}k.push(p);m++}}}}else if(H instanceof THREE.Line){R.multiply(q,T);V=H.geometry.vertices;G=V[0];G.positionScreen.copy(G.position);R.multiplyVector4(G.positionScreen);z=1;for(U=V.length;z<U;z++){s=V[z];s.positionScreen.copy(s.position);R.multiplyVector4(s.positionScreen);L=V[z-1];J.copy(s.positionScreen);e.copy(L.positionScreen);if(b(J,e)){J.multiplyScalar(1/
+J.w);e.multiplyScalar(1/e.w);c=F[D]=F[D]||new THREE.RenderableLine;c.v1.positionScreen.copy(J);c.v2.positionScreen.copy(e);c.z=Math.max(J.z,e.z);c.materials=H.materials;k.push(c);D++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);q.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){w=I[u]=I[u]||new THREE.RenderableParticle;w.x=O.x/O.w;w.y=O.y/O.w;w.z=O.z;w.rotation=H.rotation.z;w.scale.x=H.scale.x*Math.abs(w.x-(O.x+g.projectionMatrix.n11)/(O.w+g.projectionMatrix.n14));
+w.scale.y=H.scale.y*Math.abs(w.y-(O.y+g.projectionMatrix.n22)/(O.w+g.projectionMatrix.n24));w.materials=H.materials;k.push(w);u++}}}}n&&k.sort(a);return k};this.unprojectVector=function(j,g){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));n.multiplyVector3(j);return j}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,h,i;this.domElement=document.createElement("div");this.setSize=function(p,m){f=p;d=m;h=f/2;i=d/2};this.render=function(p,m){var o,c,D,F,w,u,I,Q;a=b.projectScene(p,m);o=0;for(c=a.length;o<c;o++){w=a[o];if(w instanceof THREE.RenderableParticle){I=w.x*h+h;Q=w.y*i+i;D=0;for(F=w.material.length;D<F;D++){u=w.material[D];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=I+"px";u.style.top=Q+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,h,i,p,m=f.getContext("2d"),o=1,c=0,D=null,F=null,w=1,u,I,Q,O,q,R,E,J,e,l=new THREE.Color,j=new THREE.Color,g=new THREE.Color,n=new THREE.Color,k=new THREE.Color,r,x,v,z,U,s,L,C,H,T=new THREE.Rectangle,W=new THREE.Rectangle,y=new THREE.Rectangle,A=false,P=new THREE.Color,V=new THREE.Color,G=new THREE.Color,M=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=16;oa=document.createElement("canvas");
+oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Aa=pa.getImageData(0,0,2,2);da=Aa.data;qa=document.createElement("canvas");qa.width=qa.height=la;ua=qa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ma){d=ga;h=ma;i=d/2;p=h/2;f.width=d;f.height=h;T.set(-i,-p,i,p)};this.clear=function(){if(!W.isEmpty()){W.inflate(1);W.minSelf(T);m.clearRect(W.getX(),
+W.getY(),W.getWidth(),W.getHeight());W.empty()}};this.render=function(ga,ma){function Ka(t){var S,N,B,K=t.lights;V.setRGB(0,0,0);G.setRGB(0,0,0);M.setRGB(0,0,0);t=0;for(S=K.length;t<S;t++){N=K[t];B=N.color;if(N instanceof THREE.AmbientLight){V.r+=B.r;V.g+=B.g;V.b+=B.b}else if(N instanceof THREE.DirectionalLight){G.r+=B.r;G.g+=B.g;G.b+=B.b}else if(N instanceof THREE.PointLight){M.r+=B.r;M.g+=B.g;M.b+=B.b}}}function va(t,S,N,B){var K,X,aa,ba,ca=t.lights;t=0;for(K=ca.length;t<K;t++){X=ca[t];aa=X.color;
+ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=N.dot(X.position)*ba;if(X>0){B.r+=aa.r*X;B.g+=aa.g*X;B.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,S);Z.normalize();X=N.dot(Z)*ba;if(X>0){B.r+=aa.r*X;B.g+=aa.g*X;B.b+=aa.b*X}}}}function La(t,S,N){if(N.opacity!=0){Ba(N.opacity);wa(N.blending);var B,K,X,aa,ba,ca;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ba=aa.width>>1;ca=aa.height>>1;K=S.scale.x*i;X=S.scale.y*p;N=K*ba;B=X*ca;y.set(t.x-N,t.y-B,t.x+N,
+t.y+B);if(T.instersects(y)){m.save();m.translate(t.x,t.y);m.rotate(-S.rotation);m.scale(K,-X);m.translate(-ba,-ca);m.drawImage(aa,0,0);m.restore()}}}else if(N instanceof THREE.ParticleCircleMaterial){if(A){P.r=V.r+G.r+M.r;P.g=V.g+G.g+M.g;P.b=V.b+G.b+M.b;l.r=N.color.r*P.r;l.g=N.color.g*P.g;l.b=N.color.b*P.b;l.updateStyleString()}else l.__styleString=N.color.__styleString;N=S.scale.x*i;B=S.scale.y*p;y.set(t.x-N,t.y-B,t.x+N,t.y+B);if(T.instersects(y)){K=l.__styleString;if(F!=K)m.fillStyle=F=K;m.save();
+m.translate(t.x,t.y);m.rotate(-S.rotation);m.scale(N,B);m.beginPath();m.arc(0,0,1,0,Y,true);m.closePath();m.fill();m.restore()}}}}function Ma(t,S,N,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);m.beginPath();m.moveTo(t.positionScreen.x,t.positionScreen.y);m.lineTo(S.positionScreen.x,S.positionScreen.y);m.closePath();if(B instanceof THREE.LineBasicMaterial){l.__styleString=B.color.__styleString;t=B.linewidth;if(w!=t)m.lineWidth=w=t;t=l.__styleString;if(D!=t)m.strokeStyle=D=t;m.stroke();y.inflate(B.linewidth*
+2)}}}function Ga(t,S,N,B,K,X){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);O=t.positionScreen.x;q=t.positionScreen.y;R=S.positionScreen.x;E=S.positionScreen.y;J=N.positionScreen.x;e=N.positionScreen.y;m.beginPath();m.moveTo(O,q);m.lineTo(R,E);m.lineTo(J,e);m.lineTo(O,q);m.closePath();if(K instanceof THREE.MeshBasicMaterial)if(K.map)K.map.image.loaded&&K.map.mapping instanceof THREE.UVMapping&&ra(O,q,R,E,J,e,K.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(K.env_map){if(K.env_map.image.loaded)if(K.env_map.mapping instanceof
+THREE.SphericalReflectionMapping){t=ma.matrix;Z.copy(B.vertexNormalsWorld[0]);z=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;U=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(B.vertexNormalsWorld[1]);s=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;L=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;Z.copy(B.vertexNormalsWorld[2]);C=(Z.x*t.n11+Z.y*t.n12+Z.z*t.n13)*0.5+0.5;H=-(Z.x*t.n21+Z.y*t.n22+Z.z*t.n23)*0.5+0.5;ra(O,q,R,E,J,e,K.env_map.image,z,U,s,L,C,H)}}else K.wireframe?xa(K.color.__styleString,K.wireframe_linewidth):
+ya(K.color.__styleString);else if(K instanceof THREE.MeshLambertMaterial){if(K.map&&!K.wireframe){K.map.mapping instanceof THREE.UVMapping&&ra(O,q,R,E,J,e,K.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(A)if(!K.wireframe&&K.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){j.r=g.r=n.r=V.r;j.g=g.g=n.g=V.g;j.b=g.b=n.b=V.b;va(X,B.v1.positionWorld,B.vertexNormalsWorld[0],j);va(X,B.v2.positionWorld,B.vertexNormalsWorld[1],g);va(X,
+B.v3.positionWorld,B.vertexNormalsWorld[2],n);k.r=(g.r+n.r)*0.5;k.g=(g.g+n.g)*0.5;k.b=(g.b+n.b)*0.5;v=Ha(j,g,n,k);ra(O,q,R,E,J,e,v,0,0,1,0,0,1)}else{P.r=V.r;P.g=V.g;P.b=V.b;va(X,B.centroidWorld,B.normalWorld,P);l.r=K.color.r*P.r;l.g=K.color.g*P.g;l.b=K.color.b*P.b;l.updateStyleString();K.wireframe?xa(l.__styleString,K.wireframe_linewidth):ya(l.__styleString)}else K.wireframe?xa(K.color.__styleString,K.wireframe_linewidth):ya(K.color.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){r=ma.near;
+x=ma.far;j.r=j.g=j.b=1-Ca(t.positionScreen.z,r,x);g.r=g.g=g.b=1-Ca(S.positionScreen.z,r,x);n.r=n.g=n.b=1-Ca(N.positionScreen.z,r,x);k.r=(g.r+n.r)*0.5;k.g=(g.g+n.g)*0.5;k.b=(g.b+n.b)*0.5;v=Ha(j,g,n,k);ra(O,q,R,E,J,e,v,0,0,1,0,0,1)}else if(K instanceof THREE.MeshNormalMaterial){l.r=Da(B.normalWorld.x);l.g=Da(B.normalWorld.y);l.b=Da(B.normalWorld.z);l.updateStyleString();K.wireframe?xa(l.__styleString,K.wireframe_linewidth):ya(l.__styleString)}}}function xa(t,S){if(D!=t)m.strokeStyle=D=t;if(w!=S)m.lineWidth=
+w=S;m.stroke();y.inflate(S*2)}function ya(t){if(F!=t)m.fillStyle=F=t;m.fill()}function ra(t,S,N,B,K,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;N-=t;B-=S;K-=t;X-=S;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*N-ea*K)*ja;ea=(sa*B-ea*X)*ja;N=(ha*K-ia*N)*ja;B=(ha*X-ia*B)*ja;t=t-ka*ba-N*ca;S=S-ea*ba-B*ca;m.save();m.transform(ka,ea,N,B,t,S);m.clip();m.drawImage(aa,0,0);m.restore()}function Ba(t){if(o!=t)m.globalAlpha=o=t}function wa(t){if(c!=
+t){switch(t){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}c=t}}function Ha(t,S,N,B){var K=~~(t.r*255),X=~~(t.g*255);t=~~(t.b*255);var aa=~~(S.r*255),ba=~~(S.g*255);S=~~(S.b*255);var ca=~~(N.r*255),ha=~~(N.g*255);N=~~(N.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=K<0?0:K>255?255:K;da[1]=X<0?0:X>255?255:X;da[2]=t<0?0:t>
+255?255:t;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=S<0?0:S>255?255:S;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=N<0?0:N>255?255:N;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(t,S,N){t=(t-S)/(N-S);return t*t*(3-2*t)}function Da(t){t=(t+1)*0.5;return t<0?0:t>1?1:t}function Ea(t,S){var N=S.x-t.x,B=S.y-t.y,K=1/Math.sqrt(N*N+B*B);N*=K;B*=K;S.x+=N;S.y+=B;t.x-=N;t.y-=
+B}var za,Ia,$,fa,na,Fa,Ja,ta;m.setTransform(1,0,0,-1,i,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);(A=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];y.empty();if($ instanceof THREE.RenderableParticle){u=$;u.x*=i;u.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(u,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=i;u.positionScreen.y*=p;I.positionScreen.x*=i;I.positionScreen.y*=p;y.addPoint(u.positionScreen.x,
+u.positionScreen.y);y.addPoint(I.positionScreen.x,I.positionScreen.y);if(T.instersects(y)){fa=0;for(na=$.materials.length;fa<na;)Ma(u,I,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=$.v2;Q=$.v3;u.positionScreen.x*=i;u.positionScreen.y*=p;I.positionScreen.x*=i;I.positionScreen.y*=p;Q.positionScreen.x*=i;Q.positionScreen.y*=p;if($.overdraw){Ea(u.positionScreen,I.positionScreen);Ea(I.positionScreen,Q.positionScreen);Ea(Q.positionScreen,u.positionScreen)}y.add3Points(u.positionScreen.x,
+u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,Q.positionScreen.x,Q.positionScreen.y);if(T.instersects(y)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(u,I,Q,$,ta,ga)}else Ga(u,I,Q,$,ta,ga)}}}W.addRectangle(y)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(C,H,T){var W,y,A,P;W=0;for(y=C.lights.length;W<y;W++){A=C.lights[W];if(A instanceof THREE.DirectionalLight){P=H.normalWorld.dot(A.position)*A.intensity;if(P>0){T.r+=A.color.r*P;T.g+=A.color.g*P;T.b+=A.color.b*P}}else if(A instanceof THREE.PointLight){n.sub(A.position,H.centroidWorld);n.normalize();P=H.normalWorld.dot(n)*A.intensity;if(P>0){T.r+=A.color.r*P;T.g+=A.color.g*P;T.b+=A.color.b*P}}}}function b(C,H,T,W,y,A){v=d(z++);v.setAttribute("d","M "+C.positionScreen.x+
+" "+C.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(R){J.r=e.r;J.g=e.g;J.b=e.b;a(A,W,J);E.r=y.color.r*J.r;E.g=y.color.g*J.g;E.b=y.color.b*J.b;E.updateStyleString()}else E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){g=1-y.__2near/(y.__farPlusNear-W.z*y.__farMinusNear);
+E.setRGB(g,g,g)}else y instanceof THREE.MeshNormalMaterial&&E.setRGB(h(W.normalWorld.x),h(W.normalWorld.y),h(W.normalWorld.z));y.wireframe?v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):v.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+y.opacity);m.appendChild(v)}function f(C,H,T,W,y,A,P){v=d(z++);v.setAttribute("d",
+"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)E.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(R){J.r=e.r;J.g=e.g;J.b=e.b;a(P,y,J);E.r=A.color.r*J.r;E.g=A.color.g*J.g;E.b=A.color.b*J.b;E.updateStyleString()}else E.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){g=
+1-A.__2near/(A.__farPlusNear-y.z*A.__farMinusNear);E.setRGB(g,g,g)}else A instanceof THREE.MeshNormalMaterial&&E.setRGB(h(y.normalWorld.x),h(y.normalWorld.y),h(y.normalWorld.z));A.wireframe?v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):v.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+A.opacity);m.appendChild(v)}
+function d(C){if(k[C]==null){k[C]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&k[C].setAttribute("shape-rendering","crispEdges");return k[C]}return k[C]}function h(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var i=null,p=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,F,w,u,I,Q,O=new THREE.Rectangle,q=new THREE.Rectangle,R=false,E=new THREE.Color(16777215),J=new THREE.Color(16777215),e=new THREE.Color(0),l=new THREE.Color(0),
+j=new THREE.Color(0),g,n=new THREE.Vector3,k=[],r=[],x=[],v,z,U,s,L=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(C){switch(C){case "high":L=1;break;case "low":L=0}};this.setSize=function(C,H){o=C;c=H;D=o/2;F=c/2;m.setAttribute("viewBox",-D+" "+-F+" "+o+" "+c);m.setAttribute("width",o);m.setAttribute("height",c);O.set(-D,-F,D,F)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(C,H){var T,W,
+y,A,P,V,G,M;this.autoClear&&this.clear();i=p.projectScene(C,H,this.sortElements);s=U=z=0;if(R=C.lights.length>0){G=C.lights;e.setRGB(0,0,0);l.setRGB(0,0,0);j.setRGB(0,0,0);T=0;for(W=G.length;T<W;T++){y=G[T];A=y.color;if(y instanceof THREE.AmbientLight){e.r+=A.r;e.g+=A.g;e.b+=A.b}else if(y instanceof THREE.DirectionalLight){l.r+=A.r;l.g+=A.g;l.b+=A.b}else if(y instanceof THREE.PointLight){j.r+=A.r;j.g+=A.g;j.b+=A.b}}}T=0;for(W=i.length;T<W;T++){G=i[T];q.empty();if(G instanceof THREE.RenderableParticle){w=
+G;w.x*=D;w.y*=-F;y=0;for(A=G.materials.length;y<A;y++)if(M=G.materials[y]){P=w;V=G;M=M;var Y=U++;if(r[Y]==null){r[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&r[Y].setAttribute("shape-rendering","crispEdges")}v=r[Y];v.setAttribute("cx",P.x);v.setAttribute("cy",P.y);v.setAttribute("r",V.scale.x*D);if(M instanceof THREE.ParticleCircleMaterial){if(R){J.r=e.r+l.r+j.r;J.g=e.g+l.g+j.g;J.b=e.b+l.b+j.b;E.r=M.color.r*J.r;E.g=M.color.g*J.g;E.b=M.color.b*J.b;E.updateStyleString()}else E=
+M.color;v.setAttribute("style","fill: "+E.__styleString)}m.appendChild(v)}}else if(G instanceof THREE.RenderableLine){w=G.v1;u=G.v2;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(u.positionScreen.x,u.positionScreen.y);if(O.instersects(q)){y=0;for(A=G.materials.length;y<A;)if(M=G.materials[y++]){P=w;V=u;M=M;Y=s++;if(x[Y]==null){x[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
+0&&x[Y].setAttribute("shape-rendering","crispEdges")}v=x[Y];v.setAttribute("x1",P.positionScreen.x);v.setAttribute("y1",P.positionScreen.y);v.setAttribute("x2",V.positionScreen.x);v.setAttribute("y2",V.positionScreen.y);if(M instanceof THREE.LineBasicMaterial){E.__styleString=M.color.__styleString;v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+M.linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.linecap+"; stroke-linejoin: "+M.linejoin);m.appendChild(v)}}}}else if(G instanceof
+THREE.RenderableFace3){w=G.v1;u=G.v2;I=G.v3;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;I.positionScreen.x*=D;I.positionScreen.y*=-F;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(u.positionScreen.x,u.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);if(O.instersects(q)){y=0;for(A=G.meshMaterials.length;y<A;){M=G.meshMaterials[y++];if(M instanceof THREE.MeshFaceMaterial){P=0;for(V=G.faceMaterials.length;P<V;)(M=G.faceMaterials[P++])&&
+b(w,u,I,G,M,C)}else M&&b(w,u,I,G,M,C)}}}else if(G instanceof THREE.RenderableFace4){w=G.v1;u=G.v2;I=G.v3;Q=G.v4;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;I.positionScreen.x*=D;I.positionScreen.y*=-F;Q.positionScreen.x*=D;Q.positionScreen.y*=-F;q.addPoint(w.positionScreen.x,w.positionScreen.y);q.addPoint(u.positionScreen.x,u.positionScreen.y);q.addPoint(I.positionScreen.x,I.positionScreen.y);q.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(q)){y=
+0;for(A=G.meshMaterials.length;y<A;){M=G.meshMaterials[y++];if(M instanceof THREE.MeshFaceMaterial){P=0;for(V=G.faceMaterials.length;P<V;)(M=G.faceMaterials[P++])&&f(w,u,I,Q,G,M,C)}else M&&f(w,u,I,Q,G,M,C)}}}}}};
+THREE.WebGLRenderer=function(a){function b(e,l,j){var g=c.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif",j?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
+c.attachShader(g,p("fragment",j+e));c.attachShader(g,p("vertex",n+l));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(e,l){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
+c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var j=0;j<6;++j)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[j]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
 l);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function d(e,l){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,m(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,m(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,m(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
 l);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function d(e,l){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,m(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,m(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,m(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
-m(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function h(e,l){var k,f,n;k=0;for(f=l.length;k<f;k++){n=l[k];e.uniforms[n]=c.getUniformLocation(e,n)}}function i(e,l){var k,f,n;k=0;for(f=l.length;k<f;k++){n=l[k];e.attributes[n]=c.getAttribLocation(e,n)}}function p(e,l){var k;if(e=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")k=c.createShader(c.VERTEX_SHADER);c.shaderSource(k,
-l);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function m(e){switch(e){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}return 0}var o=document.createElement("canvas"),c,D,C,x=new THREE.Matrix4,w,K=new Float32Array(16),P=new Float32Array(16),M=new Float32Array(16),s=new Float32Array(9),Q=new Float32Array(16),E=function(e,l){if(e){var k,f,n,j=pointLights=maxDirLights=maxPointLights=0;k=0;for(f=e.lights.length;k<f;k++){n=e.lights[k];n instanceof THREE.DirectionalLight&&j++;n instanceof
-THREE.PointLight&&pointLights++}if(pointLights+j<=l){maxDirLights=j;maxPointLights=pointLights}else{maxDirLights=Math.ceil(l*j/(pointLights+j));maxPointLights=l-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:l-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=o;this.autoClear=true;
-(function(e,l,k){try{c=o.getContext("experimental-webgl",{antialias:e})}catch(f){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(l.r,l.g,l.b,k)})(antialias,clearColor,clearAlpha);D=C=function(e,l,k){var f=[e?"#define MAX_DIR_LIGHTS "+e:"",l?"#define MAX_POINT_LIGHTS "+
+m(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function h(e,l){var j,g,n;j=0;for(g=l.length;j<g;j++){n=l[j];e.uniforms[n]=c.getUniformLocation(e,n)}}function i(e,l){var j,g,n;j=0;for(g=l.length;j<g;j++){n=l[j];e.attributes[n]=c.getAttribLocation(e,n)}}function p(e,l){var j;if(e=="fragment")j=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")j=c.createShader(c.VERTEX_SHADER);c.shaderSource(j,
+l);c.compileShader(j);if(!c.getShaderParameter(j,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(j));return null}return j}function m(e){switch(e){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}return 0}var o=document.createElement("canvas"),c,D,F,w=new THREE.Matrix4,u,I=new Float32Array(16),Q=new Float32Array(16),O=new Float32Array(16),q=new Float32Array(9),R=new Float32Array(16),E=function(e,l){if(e){var j,g,n,k=pointLights=maxDirLights=maxPointLights=0;j=0;for(g=e.lights.length;j<g;j++){n=e.lights[j];n instanceof THREE.DirectionalLight&&k++;n instanceof
+THREE.PointLight&&pointLights++}if(pointLights+k<=l){maxDirLights=k;maxPointLights=pointLights}else{maxDirLights=Math.ceil(l*k/(pointLights+k));maxPointLights=l-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:l-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=o;this.autoClear=true;
+(function(e,l,j){try{c=o.getContext("experimental-webgl",{antialias:e})}catch(g){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(l.r,l.g,l.b,j)})(antialias,clearColor,clearAlpha);D=F=function(e,l,j){var g=[e?"#define MAX_DIR_LIGHTS "+e:"",l?"#define MAX_POINT_LIGHTS "+
 l:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",l?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",l?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
 l:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",l?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",l?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
 "","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 "","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",l?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",l?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 "",l?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",l?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",l?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
 "",l?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",l?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",l?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
-n=[e?"#define MAX_DIR_LIGHTS "+e:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogDensity;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
+n=[e?"#define MAX_DIR_LIGHTS "+e:"",l?"#define MAX_POINT_LIGHTS "+l:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
 e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
 e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",l?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
 l?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",l?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",l?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",l?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",l?"float pointSpecularWeight = 0.0;":"",l?"if ( pointDotNormalHalf >= 0.0 )":
 l?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",l?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",l?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",l?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",l?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",l?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",l?"float pointSpecularWeight = 0.0;":"",l?"if ( pointDotNormalHalf >= 0.0 )":
 "",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse  += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",e?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
 "",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse  += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",e?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
 "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse  += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;":
 "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse  += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;":
-"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nconst float LOG2 = 1.442695;\nfloat z = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );\nfogFactor = clamp( fogFactor, 0.0, 1.0 );\ngl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );\n#endif\n}"].join("\n");
-f=b(n,f,k);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);k&&h(f,["fogColor","fogDensity"]);e&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&h(f,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);i(f,["position","normal","uv"]);return f}(E.directional,E.point,fog);this.setSize=function(e,l){o.width=e;o.height=l;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,l){c.clearColor(e.r,e.g,e.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};
-this.setupLights=function(e,l){var k,f,n,j,r,q=[],u=[],v=[];j=[];r=[];c.uniform1i(e.uniforms.enableLighting,l.length);k=0;for(f=l.length;k<f;k++){n=l[k];if(n instanceof THREE.AmbientLight)q.push(n);else if(n instanceof THREE.DirectionalLight)v.push(n);else n instanceof THREE.PointLight&&u.push(n)}k=n=j=r=0;for(f=q.length;k<f;k++){n+=q[k].color.r;j+=q[k].color.g;r+=q[k].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,j,r);j=[];r=[];k=0;for(f=v.length;k<f;k++){n=v[k];j.push(n.color.r*n.intensity);
-j.push(n.color.g*n.intensity);j.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(v.length){c.uniform1i(e.uniforms.directionalLightNumber,v.length);c.uniform3fv(e.uniforms.directionalLightDirection,r);c.uniform3fv(e.uniforms.directionalLightColor,j)}j=[];r=[];k=0;for(f=u.length;k<f;k++){n=u[k];j.push(n.color.r*n.intensity);j.push(n.color.g*n.intensity);j.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(u.length){c.uniform1i(e.uniforms.pointLightNumber,
-u.length);c.uniform3fv(e.uniforms.pointLightPosition,r);c.uniform3fv(e.uniforms.pointLightColor,j)}};this.createBuffers=function(e,l){var k,f,n,j,r,q,u,v,N,G=[],F=[],A=[],W=[],T=[],V=[],z=0,t=e.geometry.geometryChunks[l],H;n=false;k=0;for(f=e.material.length;k<f;k++){meshMaterial=e.material[k];if(meshMaterial instanceof THREE.MeshFaceMaterial){r=0;for(H=t.material.length;r<H;r++)if(t.material[r]&&t.material[r].shading!=undefined&&t.material[r].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
-meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}H=n;k=0;for(f=t.faces.length;k<f;k++){n=t.faces[k];j=e.geometry.faces[n];r=j.vertexNormals;faceNormal=j.normal;n=e.geometry.uvs[n];if(j instanceof THREE.Face3){q=e.geometry.vertices[j.a].position;u=e.geometry.vertices[j.b].position;v=e.geometry.vertices[j.c].position;A.push(q.x,q.y,q.z);A.push(u.x,u.y,u.z);A.push(v.x,v.y,v.z);if(e.geometry.hasTangents){q=e.geometry.vertices[j.a].tangent;u=e.geometry.vertices[j.b].tangent;
-v=e.geometry.vertices[j.c].tangent;T.push(q.x,q.y,q.z,q.w);T.push(u.x,u.y,u.z,u.w);T.push(v.x,v.y,v.z,v.w)}if(r.length==3&&H)for(j=0;j<3;j++)W.push(r[j].x,r[j].y,r[j].z);else for(j=0;j<3;j++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(j=0;j<3;j++)V.push(n[j].u,n[j].v);G.push(z,z+1,z+2);F.push(z,z+1);F.push(z,z+2);F.push(z+1,z+2);z+=3}else if(j instanceof THREE.Face4){q=e.geometry.vertices[j.a].position;u=e.geometry.vertices[j.b].position;v=e.geometry.vertices[j.c].position;N=e.geometry.vertices[j.d].position;
-A.push(q.x,q.y,q.z);A.push(u.x,u.y,u.z);A.push(v.x,v.y,v.z);A.push(N.x,N.y,N.z);if(e.geometry.hasTangents){q=e.geometry.vertices[j.a].tangent;u=e.geometry.vertices[j.b].tangent;v=e.geometry.vertices[j.c].tangent;j=e.geometry.vertices[j.d].tangent;T.push(q.x,q.y,q.z,q.w);T.push(u.x,u.y,u.z,u.w);T.push(v.x,v.y,v.z,v.w);T.push(j.x,j.y,j.z,j.w)}if(r.length==4&&H)for(j=0;j<4;j++)W.push(r[j].x,r[j].y,r[j].z);else for(j=0;j<4;j++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(j=0;j<4;j++)V.push(n[j].u,
-n[j].v);G.push(z,z+1,z+2);G.push(z,z+2,z+3);F.push(z,z+1);F.push(z,z+2);F.push(z,z+3);F.push(z+1,z+2);F.push(z+2,z+3);z+=4}}if(A.length){t.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(A),c.STATIC_DRAW);t.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW);if(e.geometry.hasTangents){t.__webGLTangentBuffer=c.createBuffer();
-c.bindBuffer(c.ARRAY_BUFFER,t.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}if(V.length>0){t.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}t.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);t.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-t.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);t.__webGLFaceCount=G.length;t.__webGLLineCount=F.length}};this.renderBuffer=function(e,l,k,f,n){var j,r,q,u,v,N,G,F,A;if(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshDepthMaterial||f instanceof THREE.MeshNormalMaterial){if(!f.program){if(f instanceof THREE.MeshDepthMaterial){G=L.depth;f.fragment_shader=G.fragment_shader;f.vertex_shader=G.vertex_shader;f.uniforms=G.uniforms;f.uniforms.mNear.value=
-f.near;f.uniforms.mFar.value=f.far}else if(f instanceof THREE.MeshNormalMaterial){G=L.normal;f.fragment_shader=G.fragment_shader;f.vertex_shader=G.vertex_shader;f.uniforms=G.uniforms}f.program=b(f.fragment_shader,f.vertex_shader,null);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(A in f.uniforms)G.push(A);h(f.program,G);i(f.program,["position","normal","uv","tangent"])}A=f.program}else A=C;if(A!=D){c.useProgram(A);D=A}A==C&&this.setupLights(A,
-l);this.loadCamera(A,e);this.loadMatrices(A);if(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshDepthMaterial||f instanceof THREE.MeshNormalMaterial){q=f.wireframe;u=f.wireframe_linewidth;e=A;l=f.uniforms;var W;for(j in l){F=l[j].type;G=l[j].value;W=e.uniforms[j];if(F=="i")c.uniform1i(W,G);else if(F=="f")c.uniform1f(W,G);else if(F=="v3")c.uniform3f(W,G.x,G.y,G.z);else if(F=="c")c.uniform3f(W,G.r,G.g,G.b);else if(F=="t"){c.uniform1i(W,G);if(F=l[j].texture)F.image instanceof Array&&F.image.length==
-6?g(F,G):d(F,G)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;r=f.opacity;q=f.wireframe;u=f.wireframe_linewidth;v=f.map;N=f.env_map;l=f.combine==THREE.MixOperation;e=f.reflectivity;F=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;G=f.refraction_ratio;c.uniform4f(A.uniforms.mColor,j.r*r,j.g*r,j.b*r,r);c.uniform1i(A.uniforms.mixEnvMap,l);c.uniform1f(A.uniforms.mReflectivity,e);c.uniform1i(A.uniforms.useRefract,
-F);c.uniform1f(A.uniforms.mRefractionRatio,G);if(k){c.uniform1f(A.uniforms.fogDensity,k.density);c.uniform3f(A.uniforms.fogColor,k.color.r,k.color.g,k.color.b)}}if(f instanceof THREE.MeshPhongMaterial){k=f.ambient;j=f.specular;f=f.shininess;c.uniform4f(A.uniforms.mAmbient,k.r,k.g,k.b,r);c.uniform4f(A.uniforms.mSpecular,j.r,j.g,j.b,r);c.uniform1f(A.uniforms.mShininess,f);c.uniform1i(A.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(A.uniforms.material,1);else f instanceof
-THREE.MeshBasicMaterial&&c.uniform1i(A.uniforms.material,0);if(v){d(v,0);c.uniform1i(A.uniforms.tMap,0);c.uniform1i(A.uniforms.enableMap,1)}else c.uniform1i(A.uniforms.enableMap,0);if(N){g(N,1);c.uniform1i(A.uniforms.tCube,1);c.uniform1i(A.uniforms.enableCubeMap,1)}else c.uniform1i(A.uniforms.enableCubeMap,0);r=A.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.position);if(r.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,
-n.__webGLNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.normal)}if(r.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(r.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.tangent)}if(r.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(r.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.uv)}else c.disableVertexAttribArray(r.uv);if(q){c.lineWidth(u);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,l,k,f,n,j,r){var q,u,v,N,G;v=0;for(N=f.material.length;v<N;v++){q=f.material[v];if(q instanceof THREE.MeshFaceMaterial){q=0;for(u=n.material.length;q<u;q++)if((G=n.material[q])&&G.blending==j&&G.opacity<1==r){this.setBlending(G.blending);this.renderBuffer(e,l,k,
-G,n)}}else if((G=q)&&G.blending==j&&G.opacity<1==r){this.setBlending(G.blending);this.renderBuffer(e,l,k,G,n)}}};this.render=function(e,l){var k,f,n,j,r=e.lights,q=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();K.set(l.matrix.flatten());M.set(l.projectionMatrix.flatten());k=0;for(f=e.__webGLObjects.length;k<f;k++){n=e.__webGLObjects[k];j=n.object;n=n.buffer;if(j.visible){this.setupMatrices(j,l);this.renderPass(l,r,q,j,n,THREE.NormalBlending,false)}}k=
-0;for(f=e.__webGLObjects.length;k<f;k++){n=e.__webGLObjects[k];j=n.object;n=n.buffer;if(j.visible){this.setupMatrices(j,l);this.renderPass(l,r,q,j,n,THREE.AdditiveBlending,false);this.renderPass(l,r,q,j,n,THREE.SubtractiveBlending,false);this.renderPass(l,r,q,j,n,THREE.AdditiveBlending,true);this.renderPass(l,r,q,j,n,THREE.SubtractiveBlending,true);this.renderPass(l,r,q,j,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var l,k,f,n,j,r;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap=
-{}}l=0;for(k=e.objects.length;l<k;l++){f=e.objects[l];if(e.__webGLObjectsMap[f.id]==undefined)e.__webGLObjectsMap[f.id]={};r=e.__webGLObjectsMap[f.id];if(f instanceof THREE.Mesh)for(j in f.geometry.geometryChunks){n=f.geometry.geometryChunks[j];n.__webGLVertexBuffer||this.createBuffers(f,j);if(r[j]==undefined){n={buffer:n,object:f};e.__webGLObjects.push(n);r[j]=1}}}};this.removeObject=function(e,l){var k,f;for(k=e.__webGLObjects.length-1;k>=0;k--){f=e.__webGLObjects[k].object;l==f&&e.__webGLObjects.splice(k,
-1)}};this.setupMatrices=function(e,l){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(l.matrix,e.matrix);P.set(x.flatten());w=THREE.Matrix4.makeInvert3x3(x).transpose();s.set(w.m);Q.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,K);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,s);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,Q)};
-this.loadCamera=function(e,l){c.uniform3f(e.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,l){if(e){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
-else e=="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};var L={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
+"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
+g=b(n,g,j);c.useProgram(g);h(g,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);j&&h(g,["fogColor","fogNear","fogFar"]);e&&h(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&h(g,["pointLightNumber","pointLightColor",
+"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);i(g,["position","normal","uv"]);return g}(E.directional,E.point,fog);this.setSize=function(e,l){o.width=e;o.height=l;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,l){var j=new THREE.Color(e);c.clearColor(j.r,j.g,j.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
+c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,l){var j,g,n,k,r,x=[],v=[],z=[];k=[];r=[];c.uniform1i(e.uniforms.enableLighting,l.length);j=0;for(g=l.length;j<g;j++){n=l[j];if(n instanceof THREE.AmbientLight)x.push(n);else if(n instanceof THREE.DirectionalLight)z.push(n);else n instanceof THREE.PointLight&&v.push(n)}j=n=k=r=0;for(g=x.length;j<g;j++){n+=x[j].color.r;k+=x[j].color.g;r+=x[j].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,k,r);k=[];r=[];j=0;for(g=z.length;j<g;j++){n=z[j];k.push(n.color.r*
+n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(z.length){c.uniform1i(e.uniforms.directionalLightNumber,z.length);c.uniform3fv(e.uniforms.directionalLightDirection,r);c.uniform3fv(e.uniforms.directionalLightColor,k)}k=[];r=[];j=0;for(g=v.length;j<g;j++){n=v[j];k.push(n.color.r*n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(v.length){c.uniform1i(e.uniforms.pointLightNumber,
+v.length);c.uniform3fv(e.uniforms.pointLightPosition,r);c.uniform3fv(e.uniforms.pointLightColor,k)}};this.createBuffers=function(e,l){var j,g,n,k,r,x,v,z,U,s=[],L=[],C=[],H=[],T=[],W=[],y=0,A=e.geometry.geometryChunks[l],P;n=false;j=0;for(g=e.materials.length;j<g;j++){meshMaterial=e.materials[j];if(meshMaterial instanceof THREE.MeshFaceMaterial){r=0;for(P=A.materials.length;r<P;r++)if(A.materials[r]&&A.materials[r].shading!=undefined&&A.materials[r].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
+meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}P=n;j=0;for(g=A.faces.length;j<g;j++){n=A.faces[j];k=e.geometry.faces[n];r=k.vertexNormals;faceNormal=k.normal;n=e.geometry.uvs[n];if(k instanceof THREE.Face3){x=e.geometry.vertices[k.a].position;v=e.geometry.vertices[k.b].position;z=e.geometry.vertices[k.c].position;C.push(x.x,x.y,x.z);C.push(v.x,v.y,v.z);C.push(z.x,z.y,z.z);if(e.geometry.hasTangents){x=e.geometry.vertices[k.a].tangent;v=e.geometry.vertices[k.b].tangent;
+z=e.geometry.vertices[k.c].tangent;T.push(x.x,x.y,x.z,x.w);T.push(v.x,v.y,v.z,v.w);T.push(z.x,z.y,z.z,z.w)}if(r.length==3&&P)for(k=0;k<3;k++)H.push(r[k].x,r[k].y,r[k].z);else for(k=0;k<3;k++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<3;k++)W.push(n[k].u,n[k].v);s.push(y,y+1,y+2);L.push(y,y+1);L.push(y,y+2);L.push(y+1,y+2);y+=3}else if(k instanceof THREE.Face4){x=e.geometry.vertices[k.a].position;v=e.geometry.vertices[k.b].position;z=e.geometry.vertices[k.c].position;U=e.geometry.vertices[k.d].position;
+C.push(x.x,x.y,x.z);C.push(v.x,v.y,v.z);C.push(z.x,z.y,z.z);C.push(U.x,U.y,U.z);if(e.geometry.hasTangents){x=e.geometry.vertices[k.a].tangent;v=e.geometry.vertices[k.b].tangent;z=e.geometry.vertices[k.c].tangent;k=e.geometry.vertices[k.d].tangent;T.push(x.x,x.y,x.z,x.w);T.push(v.x,v.y,v.z,v.w);T.push(z.x,z.y,z.z,z.w);T.push(k.x,k.y,k.z,k.w)}if(r.length==4&&P)for(k=0;k<4;k++)H.push(r[k].x,r[k].y,r[k].z);else for(k=0;k<4;k++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<4;k++)W.push(n[k].u,
+n[k].v);s.push(y,y+1,y+2);s.push(y,y+2,y+3);L.push(y,y+1);L.push(y,y+2);L.push(y,y+3);L.push(y+1,y+2);L.push(y+2,y+3);y+=4}}if(C.length){A.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);A.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);if(e.geometry.hasTangents){A.__webGLTangentBuffer=c.createBuffer();
+c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}if(W.length>0){A.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW)}A.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(s),c.STATIC_DRAW);A.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+A.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(L),c.STATIC_DRAW);A.__webGLFaceCount=s.length;A.__webGLLineCount=L.length}};this.renderBuffer=function(e,l,j,g,n){var k,r,x,v,z,U,s,L,C;if(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshDepthMaterial||g instanceof THREE.MeshNormalMaterial){if(!g.program){if(g instanceof THREE.MeshDepthMaterial){s=J.depth;g.fragment_shader=s.fragment_shader;g.vertex_shader=s.vertex_shader;g.uniforms=s.uniforms;g.uniforms.mNear.value=
+e.near;g.uniforms.mFar.value=e.far}else if(g instanceof THREE.MeshNormalMaterial){s=J.normal;g.fragment_shader=s.fragment_shader;g.vertex_shader=s.vertex_shader;g.uniforms=s.uniforms}g.program=b(g.fragment_shader,g.vertex_shader,null);s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in g.uniforms)s.push(C);h(g.program,s);i(g.program,["position","normal","uv","tangent"])}C=g.program}else C=F;if(C!=D){c.useProgram(C);D=C}C==F&&this.setupLights(C,
+l);this.loadCamera(C,e);this.loadMatrices(C);if(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshDepthMaterial||g instanceof THREE.MeshNormalMaterial){x=g.wireframe;v=g.wireframe_linewidth;e=C;l=g.uniforms;var H;for(k in l){L=l[k].type;s=l[k].value;H=e.uniforms[k];if(L=="i")c.uniform1i(H,s);else if(L=="f")c.uniform1f(H,s);else if(L=="v3")c.uniform3f(H,s.x,s.y,s.z);else if(L=="c")c.uniform3f(H,s.r,s.g,s.b);else if(L=="t"){c.uniform1i(H,s);if(L=l[k].texture)L.image instanceof Array&&L.image.length==
+6?f(L,s):d(L,s)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){k=g.color;r=g.opacity;x=g.wireframe;v=g.wireframe_linewidth;z=g.map;U=g.env_map;l=g.combine==THREE.MixOperation;e=g.reflectivity;L=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;s=g.refraction_ratio;c.uniform4f(C.uniforms.mColor,k.r*r,k.g*r,k.b*r,r);c.uniform1i(C.uniforms.mixEnvMap,l);c.uniform1f(C.uniforms.mReflectivity,e);c.uniform1i(C.uniforms.useRefract,
+L);c.uniform1f(C.uniforms.mRefractionRatio,s);if(j){c.uniform1f(C.uniforms.fogNear,j.near);c.uniform1f(C.uniforms.fogFar,j.far);c.uniform3f(C.uniforms.fogColor,j.color.r,j.color.g,j.color.b)}}if(g instanceof THREE.MeshPhongMaterial){j=g.ambient;k=g.specular;g=g.shininess;c.uniform4f(C.uniforms.mAmbient,j.r,j.g,j.b,r);c.uniform4f(C.uniforms.mSpecular,k.r,k.g,k.b,r);c.uniform1f(C.uniforms.mShininess,g);c.uniform1i(C.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,
+1);else g instanceof THREE.MeshBasicMaterial&&c.uniform1i(C.uniforms.material,0);if(z){d(z,0);c.uniform1i(C.uniforms.tMap,0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap,0);if(U){f(U,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);r=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.position);if(r.normal>=
+0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.normal)}if(r.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(r.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.tangent)}if(r.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(r.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.uv)}else c.disableVertexAttribArray(r.uv);if(x){c.lineWidth(v);
+c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,l,j,g,n,k,r){var x,v,z,U,s;z=0;for(U=g.materials.length;z<U;z++){x=g.materials[z];if(x instanceof THREE.MeshFaceMaterial){x=0;for(v=n.materials.length;x<v;x++)if((s=n.materials[x])&&s.blending==k&&s.opacity<1==r){this.setBlending(s.blending);
+this.renderBuffer(e,l,j,s,n)}}else if((s=x)&&s.blending==k&&s.opacity<1==r){this.setBlending(s.blending);this.renderBuffer(e,l,j,s,n)}}};this.render=function(e,l){var j,g,n,k,r=e.lights,x=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();l.autoUpdateMatrix&&l.updateMatrix();I.set(l.matrix.flatten());O.set(l.projectionMatrix.flatten());j=0;for(g=e.__webGLObjects.length;j<g;j++){n=e.__webGLObjects[j];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,l);this.renderPass(l,r,x,k,n,THREE.NormalBlending,
+false)}}j=0;for(g=e.__webGLObjects.length;j<g;j++){n=e.__webGLObjects[j];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,l);this.renderPass(l,r,x,k,n,THREE.AdditiveBlending,false);this.renderPass(l,r,x,k,n,THREE.SubtractiveBlending,false);this.renderPass(l,r,x,k,n,THREE.AdditiveBlending,true);this.renderPass(l,r,x,k,n,THREE.SubtractiveBlending,true);this.renderPass(l,r,x,k,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var l,j,g,n,k,r;if(!e.__webGLObjects){e.__webGLObjects=
+[];e.__webGLObjectsMap={}}l=0;for(j=e.objects.length;l<j;l++){g=e.objects[l];if(e.__webGLObjectsMap[g.id]==undefined)e.__webGLObjectsMap[g.id]={};r=e.__webGLObjectsMap[g.id];if(g instanceof THREE.Mesh)for(k in g.geometry.geometryChunks){n=g.geometry.geometryChunks[k];n.__webGLVertexBuffer||this.createBuffers(g,k);if(r[k]==undefined){n={buffer:n,object:g};e.__webGLObjects.push(n);r[k]=1}}}};this.removeObject=function(e,l){var j,g;for(j=e.__webGLObjects.length-1;j>=0;j--){g=e.__webGLObjects[j].object;
+l==g&&e.__webGLObjects.splice(j,1)}};this.setupMatrices=function(e,l){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(l.matrix,e.matrix);Q.set(w.flatten());u=THREE.Matrix4.makeInvert3x3(w).transpose();q.set(u.m);R.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,I);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,O);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,q);c.uniformMatrix4fv(e.uniforms.objectMatrix,
+false,R)};this.loadCamera=function(e,l){c.uniform3f(e.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,l){if(e){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
+else e=="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};var J={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
 vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
 vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
-THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};
-THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
+THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};
+THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};

+ 161 - 157
build/ThreeDebug.js

@@ -1,184 +1,188 @@
 // ThreeDebug.js r31 - http://github.com/mrdoob/three.js
 // ThreeDebug.js r31 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
 var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)};
-THREE.Color.prototype={setRGB:function(a,b,g){this.r=a;this.g=b;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)+
+THREE.Color.prototype={setRGB:function(a,b,f){this.r=a;this.g=b;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 ","+~~(this.g*255)+","+~~(this.b*255)+")"},toString:function(){return"THREE.Color ( r: "+this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,g){this.x=a||0;this.y=b||0;this.z=g||0};
-THREE.Vector3.prototype={set:function(a,b,g){this.x=a;this.y=b;this.z=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,g=this.y,d=this.z;this.x=g*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-g*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
-a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+g*g+a*a)},distanceToSquared:function(a){var b=this.x-a.x,g=this.y-a.y;a=this.z-a.z;return b*b+g*g+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0};
+THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
+cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,f=this.y,d=this.z;this.x=f*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-f*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=
+a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=
 Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
 Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};
-THREE.Vector4=function(a,b,g,d){this.x=a||0;this.y=b||0;this.z=g||0;this.w=d||1};
-THREE.Vector4.prototype={set:function(a,b,g,d){this.x=a;this.y=b;this.z=g;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
+THREE.Vector4=function(a,b,f,d){this.x=a||0;this.y=b||0;this.z=f||0;this.w=d||1};
+THREE.Vector4.prototype={set:function(a,b,f,d){this.x=a;this.y=b;this.z=f;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"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=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,g,d=a.objects,h=[];a=0;for(b=d.length;a<b;a++){g=d[a];if(g instanceof THREE.Mesh)h=h.concat(this.intersectObject(g))}h.sort(function(j,p){return j.distance-p.distance});return h},intersectObject:function(a){function b(M,s,Q,E){E=E.clone().subSelf(s);Q=Q.clone().subSelf(s);var L=M.clone().subSelf(s);M=E.dot(E);s=E.dot(Q);E=E.dot(L);var e=Q.dot(Q);Q=Q.dot(L);L=1/(M*e-s*s);e=(e*E-s*Q)*L;M=(M*Q-s*E)*L;return e>0&&M>0&&e+M<1}var g,d,h,j,p,i,o,c,D,C,
-y,x=a.geometry,K=x.vertices,P=[];g=0;for(d=x.faces.length;g<d;g++){h=x.faces[g];C=this.origin.clone();y=this.direction.clone();j=a.matrix.multiplyVector3(K[h.a].position.clone());p=a.matrix.multiplyVector3(K[h.b].position.clone());i=a.matrix.multiplyVector3(K[h.c].position.clone());o=h instanceof THREE.Face4?a.matrix.multiplyVector3(K[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());D=y.dot(c);if(D<0){c=c.dot((new THREE.Vector3).sub(j,C))/D;C=C.addSelf(y.multiplyScalar(c));
-if(h instanceof THREE.Face3){if(b(C,j,p,i)){h={distance:this.origin.distanceTo(C),point:C,face:h,object:a};P.push(h)}}else if(h instanceof THREE.Face4)if(b(C,j,p,o)||b(C,p,i,o)){h={distance:this.origin.distanceTo(C),point:C,face:h,object:a};P.push(h)}}}return P}};
-THREE.Rectangle=function(){function a(){j=d-b;p=h-g}var b,g,d,h,j,p,i=true;this.getX=function(){return b};this.getY=function(){return g};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return g};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(o,c,D,C){i=false;b=o;g=c;d=D;h=C;a()};this.addPoint=function(o,c){if(i){i=false;b=o;g=c;d=o;h=c}else{b=b<o?b:o;g=g<c?g:c;d=d>o?d:o;h=h>c?
-h:c}a()};this.add3Points=function(o,c,D,C,y,x){if(i){i=false;b=o<D?o<y?o:y:D<y?D:y;g=c<C?c<x?c:x:C<x?C:x;d=o>D?o>y?o:y:D>y?D:y;h=c>C?c>x?c:x:C>x?C:x}else{b=o<D?o<y?o<b?o:b:y<b?y:b:D<y?D<b?D:b:y<b?y:b;g=c<C?c<x?c<g?c:g:x<g?x:g:C<x?C<g?C:g:x<g?x:g;d=o>D?o>y?o>d?o:d:y>d?y:d:D>y?D>d?D:d:y>d?y:d;h=c>C?c>x?c>h?c:h:x>h?x:h:C>x?C>h?C:h:x>h?x:h}a()};this.addRectangle=function(o){if(i){i=false;b=o.getLeft();g=o.getTop();d=o.getRight();h=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();g=g<o.getTop()?g:o.getTop();
-d=d>o.getRight()?d:o.getRight();h=h>o.getBottom()?h:o.getBottom()}a()};this.inflate=function(o){b-=o;g-=o;d+=o;h+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();g=g>o.getTop()?g:o.getTop();d=d<o.getRight()?d:o.getRight();h=h<o.getBottom()?h:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(h,o.getBottom())-Math.max(g,o.getTop())>=0};this.empty=function(){i=true;h=d=g=b=0;a()};this.isEmpty=function(){return i};this.toString=
-function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+g+", bottom: "+h+", width: "+j+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
-THREE.Matrix4=function(a,b,g,d,h,j,p,i,o,c,D,C,y,x,K,P){this.n11=a||1;this.n12=b||0;this.n13=g||0;this.n14=d||0;this.n21=h||0;this.n22=j||1;this.n23=p||0;this.n24=i||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=C||0;this.n41=y||0;this.n42=x||0;this.n43=K||0;this.n44=P||1};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,g,d,h,j,p,i,o,c,D,C,y,x,K,P){this.n11=a;this.n12=b;this.n13=g;this.n14=d;this.n21=h;this.n22=j;this.n23=p;this.n24=i;this.n31=o;this.n32=c;this.n33=D;this.n34=C;this.n41=y;this.n42=x;this.n43=K;this.n44=P;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,g){var d=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(g,j).normalize();h.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=j.x;
-this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,g=a.y,d=a.z,h=1/(this.n41*b+this.n42*g+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*g+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*g+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*g+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,g=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*g+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*g+this.n23*d+this.n24*
-h;a.z=this.n31*b+this.n32*g+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*g+this.n43*d+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var g=a.n11,d=a.n12,h=a.n13,j=a.n14,p=a.n21,i=a.n22,o=a.n23,c=a.n24,D=a.n31,C=a.n32,
-y=a.n33,x=a.n34,K=a.n41,P=a.n42,M=a.n43,s=a.n44,Q=b.n11,E=b.n12,L=b.n13,e=b.n14,m=b.n21,l=b.n22,f=b.n23,n=b.n24,k=b.n31,r=b.n32,q=b.n33,u=b.n34,w=b.n41,N=b.n42,G=b.n43,F=b.n44;this.n11=g*Q+d*m+h*k+j*w;this.n12=g*E+d*l+h*r+j*N;this.n13=g*L+d*f+h*q+j*G;this.n14=g*e+d*n+h*u+j*F;this.n21=p*Q+i*m+o*k+c*w;this.n22=p*E+i*l+o*r+c*N;this.n23=p*L+i*f+o*q+c*G;this.n24=p*e+i*n+o*u+c*F;this.n31=D*Q+C*m+y*k+x*w;this.n32=D*E+C*l+y*r+x*N;this.n33=D*L+C*f+y*q+x*G;this.n34=D*e+C*n+y*u+x*F;this.n41=K*Q+P*m+M*k+s*w;
-this.n42=K*E+P*l+M*r+s*N;this.n43=K*L+P*f+M*q+s*G;this.n44=K*e+P*n+M*u+s*F;return this},multiplySelf:function(a){var b=this.n11,g=this.n12,d=this.n13,h=this.n14,j=this.n21,p=this.n22,i=this.n23,o=this.n24,c=this.n31,D=this.n32,C=this.n33,y=this.n34,x=this.n41,K=this.n42,P=this.n43,M=this.n44,s=a.n11,Q=a.n21,E=a.n31,L=a.n41,e=a.n12,m=a.n22,l=a.n32,f=a.n42,n=a.n13,k=a.n23,r=a.n33,q=a.n43,u=a.n14,w=a.n24,N=a.n34;a=a.n44;this.n11=b*s+g*Q+d*E+h*L;this.n12=b*e+g*m+d*l+h*f;this.n13=b*n+g*k+d*r+h*q;this.n14=
-b*u+g*w+d*N+h*a;this.n21=j*s+p*Q+i*E+o*L;this.n22=j*e+p*m+i*l+o*f;this.n23=j*n+p*k+i*r+o*q;this.n24=j*u+p*w+i*N+o*a;this.n31=c*s+D*Q+C*E+y*L;this.n32=c*e+D*m+C*l+y*f;this.n33=c*n+D*k+C*r+y*q;this.n34=c*u+D*w+C*N+y*a;this.n41=x*s+K*Q+P*E+M*L;this.n42=x*e+K*m+P*l+M*f;this.n43=x*n+K*k+P*r+M*q;this.n44=x*u+K*w+P*N+M*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*=
+THREE.Ray.prototype={intersectScene:function(a){var b,f,d=a.objects,h=[];a=0;for(b=d.length;a<b;a++){f=d[a];if(f instanceof THREE.Mesh)h=h.concat(this.intersectObject(f))}h.sort(function(j,p){return j.distance-p.distance});return h},intersectObject:function(a){function b(O,r,S,E){E=E.clone().subSelf(r);S=S.clone().subSelf(r);var J=O.clone().subSelf(r);O=E.dot(E);r=E.dot(S);E=E.dot(J);var e=S.dot(S);S=S.dot(J);J=1/(O*e-r*r);e=(e*E-r*S)*J;O=(O*S-r*E)*J;return e>0&&O>0&&e+O<1}var f,d,h,j,p,i,o,c,D,F,
+w,u=a.geometry,I=u.vertices,Q=[];f=0;for(d=u.faces.length;f<d;f++){h=u.faces[f];F=this.origin.clone();w=this.direction.clone();j=a.matrix.multiplyVector3(I[h.a].position.clone());p=a.matrix.multiplyVector3(I[h.b].position.clone());i=a.matrix.multiplyVector3(I[h.c].position.clone());o=h instanceof THREE.Face4?a.matrix.multiplyVector3(I[h.d].position.clone()):null;c=a.rotationMatrix.multiplyVector3(h.normal.clone());D=w.dot(c);if(D<0){c=c.dot((new THREE.Vector3).sub(j,F))/D;F=F.addSelf(w.multiplyScalar(c));
+if(h instanceof THREE.Face3){if(b(F,j,p,i)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};Q.push(h)}}else if(h instanceof THREE.Face4)if(b(F,j,p,o)||b(F,p,i,o)){h={distance:this.origin.distanceTo(F),point:F,face:h,object:a};Q.push(h)}}}return Q}};
+THREE.Rectangle=function(){function a(){j=d-b;p=h-f}var b,f,d,h,j,p,i=true;this.getX=function(){return b};this.getY=function(){return f};this.getWidth=function(){return j};this.getHeight=function(){return p};this.getLeft=function(){return b};this.getTop=function(){return f};this.getRight=function(){return d};this.getBottom=function(){return h};this.set=function(o,c,D,F){i=false;b=o;f=c;d=D;h=F;a()};this.addPoint=function(o,c){if(i){i=false;b=o;f=c;d=o;h=c}else{b=b<o?b:o;f=f<c?f:c;d=d>o?d:o;h=h>c?
+h:c}a()};this.add3Points=function(o,c,D,F,w,u){if(i){i=false;b=o<D?o<w?o:w:D<w?D:w;f=c<F?c<u?c:u:F<u?F:u;d=o>D?o>w?o:w:D>w?D:w;h=c>F?c>u?c:u:F>u?F:u}else{b=o<D?o<w?o<b?o:b:w<b?w:b:D<w?D<b?D:b:w<b?w:b;f=c<F?c<u?c<f?c:f:u<f?u:f:F<u?F<f?F:f:u<f?u:f;d=o>D?o>w?o>d?o:d:w>d?w:d:D>w?D>d?D:d:w>d?w:d;h=c>F?c>u?c>h?c:h:u>h?u:h:F>u?F>h?F:h:u>h?u:h}a()};this.addRectangle=function(o){if(i){i=false;b=o.getLeft();f=o.getTop();d=o.getRight();h=o.getBottom()}else{b=b<o.getLeft()?b:o.getLeft();f=f<o.getTop()?f:o.getTop();
+d=d>o.getRight()?d:o.getRight();h=h>o.getBottom()?h:o.getBottom()}a()};this.inflate=function(o){b-=o;f-=o;d+=o;h+=o;a()};this.minSelf=function(o){b=b>o.getLeft()?b:o.getLeft();f=f>o.getTop()?f:o.getTop();d=d<o.getRight()?d:o.getRight();h=h<o.getBottom()?h:o.getBottom();a()};this.instersects=function(o){return Math.min(d,o.getRight())-Math.max(b,o.getLeft())>=0&&Math.min(h,o.getBottom())-Math.max(f,o.getTop())>=0};this.empty=function(){i=true;h=d=f=b=0;a()};this.isEmpty=function(){return i};this.toString=
+function(){return"THREE.Rectangle ( left: "+b+", right: "+d+", top: "+f+", bottom: "+h+", width: "+j+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}};
+THREE.Matrix4=function(a,b,f,d,h,j,p,i,o,c,D,F,w,u,I,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=d||0;this.n21=h||0;this.n22=j||1;this.n23=p||0;this.n24=i||0;this.n31=o||0;this.n32=c||0;this.n33=D||1;this.n34=F||0;this.n41=w||0;this.n42=u||0;this.n43=I||0;this.n44=Q||1};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,f,d,h,j,p,i,o,c,D,F,w,u,I,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=d;this.n21=h;this.n22=j;this.n23=p;this.n24=i;this.n31=o;this.n32=c;this.n33=D;this.n34=F;this.n41=w;this.n42=u;this.n43=I;this.n44=Q;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,f){var d=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();d.cross(f,j).normalize();h.cross(j,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=j.x;
+this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,d=a.z,h=1/(this.n41*b+this.n42*f+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*d+this.n14)*h;a.y=(this.n21*b+this.n22*f+this.n23*d+this.n24)*h;a.z=(this.n31*b+this.n32*f+this.n33*d+this.n34)*h;return a},multiplyVector4:function(a){var b=a.x,f=a.y,d=a.z,h=a.w;a.x=this.n11*b+this.n12*f+this.n13*d+this.n14*h;a.y=this.n21*b+this.n22*f+this.n23*d+this.n24*
+h;a.z=this.n31*b+this.n32*f+this.n33*d+this.n34*h;a.w=this.n41*b+this.n42*f+this.n43*d+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var f=a.n11,d=a.n12,h=a.n13,j=a.n14,p=a.n21,i=a.n22,o=a.n23,c=a.n24,D=a.n31,F=a.n32,
+w=a.n33,u=a.n34,I=a.n41,Q=a.n42,O=a.n43,r=a.n44,S=b.n11,E=b.n12,J=b.n13,e=b.n14,m=b.n21,k=b.n22,g=b.n23,n=b.n24,l=b.n31,s=b.n32,x=b.n33,v=b.n34,z=b.n41,V=b.n42,t=b.n43,L=b.n44;this.n11=f*S+d*m+h*l+j*z;this.n12=f*E+d*k+h*s+j*V;this.n13=f*J+d*g+h*x+j*t;this.n14=f*e+d*n+h*v+j*L;this.n21=p*S+i*m+o*l+c*z;this.n22=p*E+i*k+o*s+c*V;this.n23=p*J+i*g+o*x+c*t;this.n24=p*e+i*n+o*v+c*L;this.n31=D*S+F*m+w*l+u*z;this.n32=D*E+F*k+w*s+u*V;this.n33=D*J+F*g+w*x+u*t;this.n34=D*e+F*n+w*v+u*L;this.n41=I*S+Q*m+O*l+r*z;
+this.n42=I*E+Q*k+O*s+r*V;this.n43=I*J+Q*g+O*x+r*t;this.n44=I*e+Q*n+O*v+r*L;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,d=this.n13,h=this.n14,j=this.n21,p=this.n22,i=this.n23,o=this.n24,c=this.n31,D=this.n32,F=this.n33,w=this.n34,u=this.n41,I=this.n42,Q=this.n43,O=this.n44,r=a.n11,S=a.n21,E=a.n31,J=a.n41,e=a.n12,m=a.n22,k=a.n32,g=a.n42,n=a.n13,l=a.n23,s=a.n33,x=a.n43,v=a.n14,z=a.n24,V=a.n34;a=a.n44;this.n11=b*r+f*S+d*E+h*J;this.n12=b*e+f*m+d*k+h*g;this.n13=b*n+f*l+d*s+h*x;this.n14=
+b*v+f*z+d*V+h*a;this.n21=j*r+p*S+i*E+o*J;this.n22=j*e+p*m+i*k+o*g;this.n23=j*n+p*l+i*s+o*x;this.n24=j*v+p*z+i*V+o*a;this.n31=c*r+D*S+F*E+w*J;this.n32=c*e+D*m+F*k+w*g;this.n33=c*n+D*l+F*s+w*x;this.n34=c*v+D*z+F*V+w*a;this.n41=u*r+I*S+Q*E+O*J;this.n42=u*e+I*m+Q*k+O*g;this.n43=u*n+I*l+Q*s+O*x;this.n44=u*v+I*z+Q*V+O*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(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
 a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
-this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,g,d){var h=b[g];b[g]=b[d];
+this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,d){var h=b[f];b[f]=b[d];
 b[d]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
 b[d]=h}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
-this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=g;return d};
-THREE.Matrix4.scaleMatrix=function(a,b,g){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=g;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
-THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var g=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),j=1-d,p=a.x,i=a.y,o=a.z;g.n11=j*p*p+d;g.n12=j*p*i-h*o;g.n13=j*p*o+h*i;g.n21=j*p*i+h*o;g.n22=j*i*i+d;g.n23=j*i*o-h*p;g.n31=j*p*o-h*i;g.n32=j*i*o+h*p;g.n33=j*o*o+d;return g};
+this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n14=a;d.n24=b;d.n34=f;return d};
+THREE.Matrix4.scaleMatrix=function(a,b,f){var d=new THREE.Matrix4;d.n11=a;d.n22=b;d.n33=f;return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b};
+THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,d=Math.cos(b),h=Math.sin(b),j=1-d,p=a.x,i=a.y,o=a.z;f.n11=j*p*p+d;f.n12=j*p*i-h*o;f.n13=j*p*o+h*i;f.n21=j*p*i+h*o;f.n22=j*i*i+d;f.n23=j*i*o-h*p;f.n31=j*p*o-h*i;f.n32=j*i*o+h*p;f.n33=j*o*o+d;return f};
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22*
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
 a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var g=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],i=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*g+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*g;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*i;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a};
-THREE.Matrix4.makeFrustum=function(a,b,g,d,h,j){var p,i,o;p=new THREE.Matrix4;i=2*h/(b-a);o=2*h/(d-g);a=(b+a)/(b-a);g=(d+g)/(d-g);d=-(j+h)/(j-h);h=-2*j*h/(j-h);p.n11=i;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=g;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,g,d){var h;a=g*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,g,d)};
-THREE.Matrix4.makeOrtho=function(a,b,g,d,h,j){var p,i,o,c;p=new THREE.Matrix4;i=b-a;o=g-d;c=j-h;a=(b+a)/i;g=(g+d)/o;h=(j+h)/c;p.n11=2/i;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-g;p.n31=0;p.n32=0;p.n33=-2/c;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],d=-b[10]*b[1]+b[2]*b[9],h=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],i=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*d;a.m[2]=b*h;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*i;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*D;return a};
+THREE.Matrix4.makeFrustum=function(a,b,f,d,h,j){var p,i,o;p=new THREE.Matrix4;i=2*h/(b-a);o=2*h/(d-f);a=(b+a)/(b-a);f=(d+f)/(d-f);d=-(j+h)/(j-h);h=-2*j*h/(j-h);p.n11=i;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=o;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=d;p.n34=h;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,d){var h;a=f*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,f,d)};
+THREE.Matrix4.makeOrtho=function(a,b,f,d,h,j){var p,i,o,c;p=new THREE.Matrix4;i=b-a;o=f-d;c=j-h;a=(b+a)/i;f=(f+d)/o;h=(j+h)/c;p.n11=2/i;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/o;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/c;p.n34=-h;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
-THREE.Face3=function(a,b,g,d,h){this.a=a;this.b=b;this.c=g;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.material=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
-THREE.Face4=function(a,b,g,d,h,j){this.a=a;this.b=b;this.c=g;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
+THREE.Face3=function(a,b,f,d,h){this.a=a;this.b=b;this.c=f;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
+THREE.Face4=function(a,b,f,d,h,j){this.a=a;this.b=b;this.c=f;this.d=d;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false};
-THREE.Geometry.prototype={computeCentroids:function(){var a,b,g;a=0;for(b=this.faces.length;a<b;a++){g=this.faces[a];g.centroid.set(0,0,0);if(g instanceof THREE.Face3){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);g.centroid.divideScalar(3)}else if(g instanceof THREE.Face4){g.centroid.addSelf(this.vertices[g.a].position);g.centroid.addSelf(this.vertices[g.b].position);g.centroid.addSelf(this.vertices[g.c].position);
-g.centroid.addSelf(this.vertices[g.d].position);g.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,g,d,h,j,p,i=new THREE.Vector3,o=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){j=this.vertices[d];j.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){j=this.faces[d];if(a&&j.vertexNormals.length){i.set(0,0,0);b=0;for(g=j.normal.length;b<g;b++)i.addSelf(j.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[j.a];g=this.vertices[j.b];p=this.vertices[j.c];i.sub(p.position,
-g.position);o.sub(b.position,g.position);i.crossSelf(o)}i.isZero()||i.normalize();j.normal.copy(i)}},computeVertexNormals:function(){var a,b=[],g,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
-0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(g=this.faces.length;a<g;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(u,w,N,G){j=u.vertices[w].position;p=u.vertices[N].position;
-i=u.vertices[G].position;o=h[0];c=h[1];D=h[2];C=p.x-j.x;y=i.x-j.x;x=p.y-j.y;K=i.y-j.y;P=p.z-j.z;M=i.z-j.z;s=c.u-o.u;Q=D.u-o.u;E=c.v-o.v;L=D.v-o.v;e=1/(s*L-Q*E);n.set((L*C-E*y)*e,(L*x-E*K)*e,(L*P-E*M)*e);k.set((s*y-Q*C)*e,(s*K-Q*x)*e,(s*M-Q*P)*e);l[w].addSelf(n);l[N].addSelf(n);l[G].addSelf(n);f[w].addSelf(k);f[N].addSelf(k);f[G].addSelf(k)}var b,g,d,h,j,p,i,o,c,D,C,y,x,K,P,M,s,Q,E,L,e,m,l=[],f=[],n=new THREE.Vector3,k=new THREE.Vector3,r=new THREE.Vector3,q=new THREE.Vector3;m=new THREE.Vector3;b=
-0;for(g=this.vertices.length;b<g;b++){l[b]=new THREE.Vector3;f[b]=new THREE.Vector3}b=0;for(g=this.faces.length;b<g;b++){d=this.faces[b];h=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
-this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(g=this.vertices.length;b<g;b++){m.copy(this.vertices[b].normal);d=l[b];r.copy(d);r.subSelf(m.multiplyScalar(m.dot(d))).normalize();q.cross(this.vertices[b].normal,d);test=q.dot(f[b]);d=test<0?-1:1;this.vertices[b].tangent.set(r.x,r.y,r.z,d)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.bbox={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,g=this.vertices.length;b<g;b++){a=this.vertices[b];if(a.position.x<this.bbox.x[0])this.bbox.x[0]=a.position.x;else if(a.position.x>this.bbox.x[1])this.bbox.x[1]=a.position.x;if(a.position.y<this.bbox.y[0])this.bbox.y[0]=a.position.y;else if(a.position.y>this.bbox.y[1])this.bbox.y[1]=a.position.y;if(a.position.z<this.bbox.z[0])this.bbox.z[0]=a.position.z;else if(a.position.z>
-this.bbox.z[1])this.bbox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,g=this.vertices.length;b<g;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(D){var C=[];b=0;for(g=D.length;b<g;b++)D[b]==undefined?C.push("undefined"):C.push(D[b].toString());return C.join("_")}var b,g,d,h,j,p,i,o,c={};d=0;for(h=this.faces.length;d<h;d++){j=this.faces[d];p=
-j.material;i=a(p);if(c[i]==undefined)c[i]={hash:i,counter:0};o=c[i].hash+"_"+c[i].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:p,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[o].vertices+j>65535){c[i].counter+=1;o=c[i].hash+"_"+c[i].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:p,vertices:0}}this.geometryChunks[o].faces.push(d);this.geometryChunks[o].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+
-this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
-THREE.Camera=function(a,b,g,d){this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,g,d);this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
-this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
-THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
-THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);
-this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};
-THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
-THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
-THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}this.toString=function(){return"THREE.LineBasicMaterial (<br/>color: "+
-this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
-THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
-a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
-THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
-a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=
-a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+
-this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
-THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap=
-"round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
-a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=
-a.wireframe_linejoin}this.toString=function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
-this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>"+ +")"}};THREE.MeshPhongMaterialCounter={value:0};
-THREE.MeshDepthMaterial=function(a){this.near=1;this.far=1E3;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.near!==undefined)this.near=a.near;if(a.far!==undefined)this.far=a.far;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.__2near=2*this.near;this.__farPlusNear=this.far+this.near;this.__farMinusNear=
-this.far-this.near;this.toString=function(){return"THREE.MeshDepthMaterial"}};THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){this.toString=function(){return"THREE.MeshFaceMaterial"}};
+THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;a=0;for(b=this.faces.length;a<b;a++){f=this.faces[a];f.centroid.set(0,0,0);if(f instanceof THREE.Face3){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);f.centroid.divideScalar(3)}else if(f instanceof THREE.Face4){f.centroid.addSelf(this.vertices[f.a].position);f.centroid.addSelf(this.vertices[f.b].position);f.centroid.addSelf(this.vertices[f.c].position);
+f.centroid.addSelf(this.vertices[f.d].position);f.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,f,d,h,j,p,i=new THREE.Vector3,o=new THREE.Vector3;d=0;for(h=this.vertices.length;d<h;d++){j=this.vertices[d];j.normal.set(0,0,0)}d=0;for(h=this.faces.length;d<h;d++){j=this.faces[d];if(a&&j.vertexNormals.length){i.set(0,0,0);b=0;for(f=j.normal.length;b<f;b++)i.addSelf(j.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[j.a];f=this.vertices[j.b];p=this.vertices[j.c];i.sub(p.position,
+f.position);o.sub(b.position,f.position);i.crossSelf(o)}i.isZero()||i.normalize();j.normal.copy(i)}},computeVertexNormals:function(){var a,b=[],f,d;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){b[d.a].addSelf(d.normal);b[d.b].addSelf(d.normal);b[d.c].addSelf(d.normal);b[d.d].addSelf(d.normal)}}a=
+0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(f=this.faces.length;a<f;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone()}else if(d instanceof THREE.Face4){d.vertexNormals[0]=b[d.a].clone();d.vertexNormals[1]=b[d.b].clone();d.vertexNormals[2]=b[d.c].clone();d.vertexNormals[3]=b[d.d].clone()}}},computeTangents:function(){function a(v,z,V,t){j=v.vertices[z].position;p=v.vertices[V].position;
+i=v.vertices[t].position;o=h[0];c=h[1];D=h[2];F=p.x-j.x;w=i.x-j.x;u=p.y-j.y;I=i.y-j.y;Q=p.z-j.z;O=i.z-j.z;r=c.u-o.u;S=D.u-o.u;E=c.v-o.v;J=D.v-o.v;e=1/(r*J-S*E);n.set((J*F-E*w)*e,(J*u-E*I)*e,(J*Q-E*O)*e);l.set((r*w-S*F)*e,(r*I-S*u)*e,(r*O-S*Q)*e);k[z].addSelf(n);k[V].addSelf(n);k[t].addSelf(n);g[z].addSelf(l);g[V].addSelf(l);g[t].addSelf(l)}var b,f,d,h,j,p,i,o,c,D,F,w,u,I,Q,O,r,S,E,J,e,m,k=[],g=[],n=new THREE.Vector3,l=new THREE.Vector3,s=new THREE.Vector3,x=new THREE.Vector3;m=new THREE.Vector3;b=
+0;for(f=this.vertices.length;b<f;b++){k[b]=new THREE.Vector3;g[b]=new THREE.Vector3}b=0;for(f=this.faces.length;b<f;b++){d=this.faces[b];h=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);
+this.vertices[d.c].normal.copy(d.vertexNormals[2]);this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(f=this.vertices.length;b<f;b++){m.copy(this.vertices[b].normal);d=k[b];s.copy(d);s.subSelf(m.multiplyScalar(m.dot(d))).normalize();x.cross(this.vertices[b].normal,d);test=x.dot(g[b]);d=test<0?-1:1;this.vertices[b].tangent.set(s.x,s.y,s.z,d)}this.hasTangents=true},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,f=this.vertices.length;b<f;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,f=this.vertices.length;b<f;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(c){var D=[];b=0;for(f=c.length;b<f;b++)c[b]==undefined?D.push("undefined"):D.push(c[b].toString());return D.join("_")}
+var b,f,d,h,j,p,i,o={};d=0;for(h=this.faces.length;d<h;d++){j=this.faces[d];materials=j.materials;p=a(materials);if(o[p]==undefined)o[p]={hash:p,counter:0};i=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:materials,vertices:0};j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+j>65535){o[p].counter+=1;i=o[p].hash+"_"+o[p].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:materials,vertices:0}}this.geometryChunks[i].faces.push(d);
+this.geometryChunks[i].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
+THREE.Camera=function(a,b,f,d){this.fov=a;this.aspect=b;this.near=f;this.far=d;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=null;this.autoUpdateMatrix=true;this.translateX=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);h.cross(h.clone(),this.up);this.position.addSelf(h);this.target.position.addSelf(h)};this.translateZ=function(h){h=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(h);
+this.position.subSelf(h);this.target.position.subSelf(h)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix();this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)};
+THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
+THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight;
+THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true};
+THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);
+this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;
+THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}};
+THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>linewidth: "+this.linewidth+"<br/>linecap: "+this.linecap+"<br/>linejoin: "+this.linejoin+"<br/>)"}};
+THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
+undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshBasicMaterial.prototype={toString:function(){return"THREE.MeshBasicMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+
+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshBasicMaterialCounter={value:0};
+THREE.MeshLambertMaterial=function(a){this.id=THREE.MeshLambertMaterialCounter.value++;this.color=new THREE.Color(16777215);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=
+a.map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==
+undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshLambertMaterial.prototype={toString:function(){return"THREE.MeshLambertMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+
+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/> )"}};THREE.MeshLambertMaterialCounter={value:0};
+THREE.MeshPhongMaterial=function(a){this.id=THREE.MeshPhongMaterialCounter.value++;this.color=new THREE.Color(16777215);this.ambient=new THREE.Color(328965);this.specular=new THREE.Color(1118481);this.shininess=30;this.env_map=this.specular_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.fog=true;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=
+this.wireframe_linecap="round";if(a){if(a.color!==undefined)this.color=new THREE.Color(a.color);if(a.ambient!==undefined)this.ambient=new THREE.Color(a.ambient);if(a.specular!==undefined)this.specular=new THREE.Color(a.specular);if(a.shininess!==undefined)this.shininess=a.shininess;if(a.map!==undefined)this.map=a.map;if(a.specular_map!==undefined)this.specular_map=a.specular_map;if(a.env_map!==undefined)this.env_map=a.env_map;if(a.combine!==undefined)this.combine=a.combine;if(a.reflectivity!==undefined)this.reflectivity=
+a.reflectivity;if(a.refraction_ratio!==undefined)this.refraction_ratio=a.refraction_ratio;if(a.fog!==undefined)this.fog=a.fog;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==
+undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshPhongMaterial.prototype={toString:function(){return"THREE.MeshPhongMaterial (<br/>id: "+this.id+"<br/>color: "+this.color+"<br/>ambient: "+this.ambient+"<br/>specular: "+this.specular+"<br/>shininess: "+this.shininess+"<br/>map: "+this.map+"<br/>specular_map: "+this.specular_map+"<br/>env_map: "+this.env_map+"<br/>combine: "+this.combine+"<br/>reflectivity: "+this.reflectivity+"<br/>refraction_ratio: "+this.refraction_ratio+"<br/>opacity: "+this.opacity+"<br/>shading: "+this.shading+"<br/>wireframe: "+
+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshPhongMaterialCounter={value:0};
+THREE.MeshDepthMaterial=function(a){this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshDepthMaterial.prototype={toString:function(){return"THREE.MeshDepthMaterial"}};
+THREE.MeshNormalMaterial=function(a){this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;if(a){if(a.opacity!==undefined)this.opacity=a.opacity;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending}};THREE.MeshNormalMaterial.prototype={toString:function(){return"THREE.MeshNormalMaterial"}};THREE.MeshFaceMaterial=function(){};THREE.MeshFaceMaterial.prototype={toString:function(){return"THREE.MeshFaceMaterial"}};
 THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
 THREE.MeshShaderMaterial=function(a){this.id=THREE.MeshShaderMaterialCounter.value++;this.vertex_shader=this.fragment_shader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){if(a.fragment_shader!==undefined)this.fragment_shader=a.fragment_shader;if(a.vertex_shader!==undefined)this.vertex_shader=a.vertex_shader;if(a.uniforms!==
-undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}this.toString=function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+
-"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
-THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+
-this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};
-THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
-THREE.Texture=function(a,b,g,d,h,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=g!==undefined?g:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+
-this.min_filter+"<br/>)"}};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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
-THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undefined)this.blending=a.blending;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframe_linewidth!==undefined)this.wireframe_linewidth=a.wireframe_linewidth;if(a.wireframe_linecap!==undefined)this.wireframe_linecap=a.wireframe_linecap;if(a.wireframe_linejoin!==undefined)this.wireframe_linejoin=a.wireframe_linejoin}};
+THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderMaterial (<br/>id: "+this.id+"<br/>blending: "+this.blending+"<br/>wireframe: "+this.wireframe+"<br/>wireframe_linewidth: "+this.wireframe_linewidth+"<br/>wireframe_linecap: "+this.wireframe_linecap+"<br/>wireframe_linejoin: "+this.wireframe_linejoin+"<br/>)"}};THREE.MeshShaderMaterialCounter={value:0};
+THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (<br/>color: "+this.color+"<br/>map: "+this.map+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (<br/>color: "+this.color+"<br/>opacity: "+this.opacity+"<br/>blending: "+this.blending+"<br/>)"}};THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};
+THREE.Texture=function(a,b,f,d,h,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=d!==undefined?d:THREE.ClampToEdgeWrapping;this.mag_filter=h!==undefined?h:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter};
+THREE.Texture.prototype={toString:function(){return"THREE.Texture (<br/>image: "+this.image+"<br/>wrap_s: "+this.wrap_s+"<br/>wrap_t: "+this.wrap_t+"<br/>mag_filter: "+this.mag_filter+"<br/>min_filter: "+this.min_filter+"<br/>)"}};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.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
-THREE.Fog=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(l,f){return f.z-l.z}function b(l,f){var n=0,k=1,r=l.z+l.w,q=f.z+f.w,u=-l.z+l.w,w=-f.z+f.w;if(r>=0&&q>=0&&u>=0&&w>=0)return true;else if(r<0&&q<0||u<0&&w<0)return false;else{if(r<0)n=Math.max(n,r/(r-q));else if(q<0)k=Math.min(k,r/(r-q));if(u<0)n=Math.max(n,u/(u-w));else if(w<0)k=Math.min(k,u/(u-w));if(k<n)return false;else{l.lerpSelf(f,n);f.lerpSelf(l,1-k);return true}}}var g,d,h=[],j,p,i,o=[],c,D,C=[],y,x,K=[],P=new THREE.Vector4,M=new THREE.Vector4,s=new THREE.Matrix4,
-Q=new THREE.Matrix4,E=[],L=new THREE.Vector4,e=new THREE.Vector4,m;this.projectObjects=function(l,f,n){var k=[],r,q;d=0;s.multiply(f.projectionMatrix,f.matrix);E[0]=new THREE.Vector4(s.n41-s.n11,s.n42-s.n12,s.n43-s.n13,s.n44-s.n14);E[1]=new THREE.Vector4(s.n41+s.n11,s.n42+s.n12,s.n43+s.n13,s.n44+s.n14);E[2]=new THREE.Vector4(s.n41+s.n21,s.n42+s.n22,s.n43+s.n23,s.n44+s.n24);E[3]=new THREE.Vector4(s.n41-s.n21,s.n42-s.n22,s.n43-s.n23,s.n44-s.n24);E[4]=new THREE.Vector4(s.n41-s.n31,s.n42-s.n32,s.n43-
-s.n33,s.n44-s.n34);E[5]=new THREE.Vector4(s.n41+s.n31,s.n42+s.n32,s.n43+s.n33,s.n44+s.n34);f=0;for(r=E.length;f<r;f++){q=E[f];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}r=l.objects;l=0;for(f=r.length;l<f;l++){q=r[l];var u;if(!(u=!q.visible)){if(u=q instanceof THREE.Mesh){a:{u=void 0;for(var w=q.position,N=-q.geometry.boundingSphere.radius*Math.max(q.scale.x,Math.max(q.scale.y,q.scale.z)),G=0;G<6;G++){u=E[G].x*w.x+E[G].y*w.y+E[G].z*w.z+E[G].w;if(u<=N){u=false;break a}}u=true}u=!u}u=u}if(!u){g=
-h[d]=h[d]||new THREE.RenderableObject;P.copy(q.position);s.multiplyVector3(P);g.object=q;g.z=P.z;k.push(g);d++}}n&&k.sort(a);return k};this.projectScene=function(l,f,n){var k=[],r,q,u,w,N,G,F,A,W,U,T,z,t,H,R,I;i=D=x=0;f.autoUpdateMatrix&&f.updateMatrix();s.multiply(f.projectionMatrix,f.matrix);G=this.projectObjects(l,f,true);l=0;for(r=G.length;l<r;l++){F=G[l].object;if(F.visible){F.autoUpdateMatrix&&F.updateMatrix();A=F.matrix;W=F.rotationMatrix;U=F.material;T=F.overdraw;if(F instanceof THREE.Mesh){z=
-F.geometry;t=z.vertices;q=0;for(u=t.length;q<u;q++){H=t[q];H.positionWorld.copy(H.position);A.multiplyVector3(H.positionWorld);w=H.positionScreen;w.copy(H.positionWorld);s.multiplyVector4(w);w.multiplyScalar(1/w.w);H.__visible=w.z>0&&w.z<1}z=z.faces;q=0;for(u=z.length;q<u;q++){H=z[q];if(H instanceof THREE.Face3){w=t[H.a];N=t[H.b];R=t[H.c];if(w.__visible&&N.__visible&&R.__visible)if(F.doubleSided||F.flipSided!=(R.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(R.positionScreen.y-
-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0){j=o[i]=o[i]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(N.positionWorld);j.v3.positionWorld.copy(R.positionWorld);j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(N.positionScreen);j.v3.positionScreen.copy(R.positionScreen);j.normalWorld.copy(H.normal);W.multiplyVector3(j.normalWorld);j.centroidWorld.copy(H.centroid);A.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);
-s.multiplyVector3(j.centroidScreen);R=H.vertexNormals;m=j.vertexNormalsWorld;w=0;for(N=R.length;w<N;w++){I=m[w]=m[w]||new THREE.Vector3;I.copy(R[w]);W.multiplyVector3(I)}j.z=j.centroidScreen.z;j.meshMaterial=U;j.faceMaterial=H.material;j.overdraw=T;if(F.geometry.uvs[q]){j.uvs[0]=F.geometry.uvs[q][0];j.uvs[1]=F.geometry.uvs[q][1];j.uvs[2]=F.geometry.uvs[q][2]}k.push(j);i++}}else if(H instanceof THREE.Face4){w=t[H.a];N=t[H.b];R=t[H.c];I=t[H.d];if(w.__visible&&N.__visible&&R.__visible&&I.__visible)if(F.doubleSided||
-F.flipSided!=((I.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(I.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0||(N.positionScreen.x-R.positionScreen.x)*(I.positionScreen.y-R.positionScreen.y)-(N.positionScreen.y-R.positionScreen.y)*(I.positionScreen.x-R.positionScreen.x)<0)){j=o[i]=o[i]||new THREE.RenderableFace3;j.v1.positionWorld.copy(w.positionWorld);j.v2.positionWorld.copy(N.positionWorld);j.v3.positionWorld.copy(I.positionWorld);
-j.v1.positionScreen.copy(w.positionScreen);j.v2.positionScreen.copy(N.positionScreen);j.v3.positionScreen.copy(I.positionScreen);j.normalWorld.copy(H.normal);W.multiplyVector3(j.normalWorld);j.centroidWorld.copy(H.centroid);A.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);s.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterial=U;j.faceMaterial=H.material;j.overdraw=T;if(F.geometry.uvs[q]){j.uvs[0]=F.geometry.uvs[q][0];j.uvs[1]=F.geometry.uvs[q][1];j.uvs[2]=
-F.geometry.uvs[q][3]}k.push(j);i++;p=o[i]=o[i]||new THREE.RenderableFace3;p.v1.positionWorld.copy(N.positionWorld);p.v2.positionWorld.copy(R.positionWorld);p.v3.positionWorld.copy(I.positionWorld);p.v1.positionScreen.copy(N.positionScreen);p.v2.positionScreen.copy(R.positionScreen);p.v3.positionScreen.copy(I.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterial=U;p.faceMaterial=H.material;
-p.overdraw=T;if(F.geometry.uvs[q]){p.uvs[0]=F.geometry.uvs[q][1];p.uvs[1]=F.geometry.uvs[q][2];p.uvs[2]=F.geometry.uvs[q][3]}k.push(p);i++}}}}else if(F instanceof THREE.Line){Q.multiply(s,A);t=F.geometry.vertices;H=t[0];H.positionScreen.copy(H.position);Q.multiplyVector4(H.positionScreen);q=1;for(u=t.length;q<u;q++){w=t[q];w.positionScreen.copy(w.position);Q.multiplyVector4(w.positionScreen);N=t[q-1];L.copy(w.positionScreen);e.copy(N.positionScreen);if(b(L,e)){L.multiplyScalar(1/L.w);e.multiplyScalar(1/
-e.w);c=C[D]=C[D]||new THREE.RenderableLine;c.v1.positionScreen.copy(L);c.v2.positionScreen.copy(e);c.z=Math.max(L.z,e.z);c.material=F.material;k.push(c);D++}}}else if(F instanceof THREE.Particle){M.set(F.position.x,F.position.y,F.position.z,1);s.multiplyVector4(M);M.z/=M.w;if(M.z>0&&M.z<1){y=K[x]=K[x]||new THREE.RenderableParticle;y.x=M.x/M.w;y.y=M.y/M.w;y.z=M.z;y.rotation=F.rotation.z;y.scale.x=F.scale.x*Math.abs(y.x-(M.x+f.projectionMatrix.n11)/(M.w+f.projectionMatrix.n14));y.scale.y=F.scale.y*
-Math.abs(y.y-(M.y+f.projectionMatrix.n22)/(M.w+f.projectionMatrix.n24));y.material=F.material;k.push(y);x++}}}}n&&k.sort(a);return k};this.unprojectVector=function(l,f){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(f.matrix),THREE.Matrix4.makeInvert(f.projectionMatrix));n.multiplyVector3(l);return l}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,g,d,h,j;this.domElement=document.createElement("div");this.setSize=function(p,i){g=p;d=i;h=g/2;j=d/2};this.render=function(p,i){var o,c,D,C,y,x,K,P;a=b.projectScene(p,i);o=0;for(c=a.length;o<c;o++){y=a[o];if(y instanceof THREE.RenderableParticle){K=y.x*h+h;P=y.y*j+j;D=0;for(C=y.material.length;D<C;D++){x=y.material[D];if(x instanceof THREE.ParticleDOMMaterial){x=x.domElement;x.style.left=K+"px";x.style.top=P+"px"}}}}}};
-THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,g=document.createElement("canvas"),d,h,j,p,i=g.getContext("2d"),o=1,c=0,D=null,C=null,y=1,x,K,P,M,s,Q,E,L,e,m=new THREE.Color,l=new THREE.Color,f=new THREE.Color,n=new THREE.Color,k=new THREE.Color,r,q,u,w,N,G,F,A,W,U,T=new THREE.Rectangle,z=new THREE.Rectangle,t=new THREE.Rectangle,H=false,R=new THREE.Color,I=new THREE.Color,V=new THREE.Color,aa=new THREE.Color,Ja=Math.PI*2,Y=new THREE.Vector3,na,oa,Aa,da,pa,ta,la=16;na=document.createElement("canvas");
-na.width=na.height=2;oa=na.getContext("2d");oa.fillStyle="rgba(0,0,0,1)";oa.fillRect(0,0,2,2);Aa=oa.getImageData(0,0,2,2);da=Aa.data;pa=document.createElement("canvas");pa.width=pa.height=la;ta=pa.getContext("2d");ta.translate(-la/2,-la/2);ta.scale(la,la);la--;this.domElement=g;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ua){d=ga;h=ua;j=d/2;p=h/2;g.width=d;g.height=h;T.set(-j,-p,j,p)};this.clear=function(){if(!z.isEmpty()){z.inflate(1);z.minSelf(T);i.clearRect(z.getX(),
-z.getY(),z.getWidth(),z.getHeight());z.empty()}};this.render=function(ga,ua){function Ka(v){var S,O,B,J=v.lights;I.setRGB(0,0,0);V.setRGB(0,0,0);aa.setRGB(0,0,0);v=0;for(S=J.length;v<S;v++){O=J[v];B=O.color;if(O instanceof THREE.AmbientLight){I.r+=B.r;I.g+=B.g;I.b+=B.b}else if(O instanceof THREE.DirectionalLight){V.r+=B.r;V.g+=B.g;V.b+=B.b}else if(O instanceof THREE.PointLight){aa.r+=B.r;aa.g+=B.g;aa.b+=B.b}}}function va(v,S,O,B){var J,X,$,ba,ca=v.lights;v=0;for(J=ca.length;v<J;v++){X=ca[v];$=X.color;
-ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=O.dot(X.position)*ba;if(X>0){B.r+=$.r*X;B.g+=$.g*X;B.b+=$.b*X}}else if(X instanceof THREE.PointLight){Y.sub(X.position,S);Y.normalize();X=O.dot(Y)*ba;if(X>0){B.r+=$.r*X;B.g+=$.g*X;B.b+=$.b*X}}}}function La(v,S,O){if(O.opacity!=0){Ba(O.opacity);wa(O.blending);var B,J,X,$,ba,ca;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){$=O.map;ba=$.width>>1;ca=$.height>>1;J=S.scale.x*j;X=S.scale.y*p;O=J*ba;B=X*ca;t.set(v.x-O,v.y-B,v.x+O,v.y+B);if(!T.instersects(t))return;
-i.save();i.translate(v.x,v.y);i.rotate(-S.rotation);i.scale(J,-X);i.translate(-ba,-ca);i.drawImage($,0,0);i.restore()}i.beginPath();i.moveTo(v.x-10,v.y);i.lineTo(v.x+10,v.y);i.moveTo(v.x,v.y-10);i.lineTo(v.x,v.y+10);i.closePath();i.strokeStyle="rgb(255,255,0)";i.stroke()}else if(O instanceof THREE.ParticleCircleMaterial){if(H){R.r=I.r+V.r+aa.r;R.g=I.g+V.g+aa.g;R.b=I.b+V.b+aa.b;m.r=O.color.r*R.r;m.g=O.color.g*R.g;m.b=O.color.b*R.b;m.updateStyleString()}else m.__styleString=O.color.__styleString;O=
-S.scale.x*j;B=S.scale.y*p;t.set(v.x-O,v.y-B,v.x+O,v.y+B);if(T.instersects(t)){J=m.__styleString;if(C!=J)i.fillStyle=C=J;i.save();i.translate(v.x,v.y);i.rotate(-S.rotation);i.scale(O,B);i.beginPath();i.arc(0,0,1,0,Ja,true);i.closePath();i.fill();i.restore()}}}}function Ma(v,S,O,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);i.beginPath();i.moveTo(v.positionScreen.x,v.positionScreen.y);i.lineTo(S.positionScreen.x,S.positionScreen.y);i.closePath();if(B instanceof THREE.LineBasicMaterial){m.__styleString=
-B.color.__styleString;v=B.linewidth;if(y!=v)i.lineWidth=y=v;v=m.__styleString;if(D!=v)i.strokeStyle=D=v;i.stroke();t.inflate(B.linewidth*2)}}}function Fa(v,S,O,B,J,X){if(J.opacity!=0){Ba(J.opacity);wa(J.blending);M=v.positionScreen.x;s=v.positionScreen.y;Q=S.positionScreen.x;E=S.positionScreen.y;L=O.positionScreen.x;e=O.positionScreen.y;i.beginPath();i.moveTo(M,s);i.lineTo(Q,E);i.lineTo(L,e);i.lineTo(M,s);i.closePath();if(J instanceof THREE.MeshBasicMaterial)if(J.map)J.map.image.loaded&&J.map.mapping instanceof
-THREE.UVMapping&&qa(M,s,Q,E,L,e,J.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(J.env_map){if(J.env_map.image.loaded)if(J.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=ua.matrix;Y.copy(B.vertexNormalsWorld[0]);N=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;G=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);F=(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;A=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);W=
-(Y.x*v.n11+Y.y*v.n12+Y.z*v.n13)*0.5+0.5;U=-(Y.x*v.n21+Y.y*v.n22+Y.z*v.n23)*0.5+0.5;qa(M,s,Q,E,L,e,J.env_map.image,N,G,F,A,W,U)}}else J.wireframe?xa(J.color.__styleString,J.wireframe_linewidth):ya(J.color.__styleString);else if(J instanceof THREE.MeshLambertMaterial){if(J.map&&!J.wireframe){J.map.mapping instanceof THREE.UVMapping&&qa(M,s,Q,E,L,e,J.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(H)if(!J.wireframe&&J.shading==THREE.SmoothShading&&
-B.vertexNormalsWorld.length==3){l.r=f.r=n.r=I.r;l.g=f.g=n.g=I.g;l.b=f.b=n.b=I.b;va(X,B.v1.positionWorld,B.vertexNormalsWorld[0],l);va(X,B.v2.positionWorld,B.vertexNormalsWorld[1],f);va(X,B.v3.positionWorld,B.vertexNormalsWorld[2],n);k.r=(f.r+n.r)*0.5;k.g=(f.g+n.g)*0.5;k.b=(f.b+n.b)*0.5;w=Ga(l,f,n,k);qa(M,s,Q,E,L,e,w,0,0,1,0,0,1)}else{R.r=I.r;R.g=I.g;R.b=I.b;va(X,B.centroidWorld,B.normalWorld,R);m.r=J.color.r*R.r;m.g=J.color.g*R.g;m.b=J.color.b*R.b;m.updateStyleString();J.wireframe?xa(m.__styleString,
-J.wireframe_linewidth):ya(m.__styleString)}else J.wireframe?xa(J.color.__styleString,J.wireframe_linewidth):ya(J.color.__styleString)}else if(J instanceof THREE.MeshDepthMaterial){r=J.__2near;q=J.__farPlusNear;u=J.__farMinusNear;l.r=l.g=l.b=1-r/(q-v.positionScreen.z*u);f.r=f.g=f.b=1-r/(q-S.positionScreen.z*u);n.r=n.g=n.b=1-r/(q-O.positionScreen.z*u);k.r=(f.r+n.r)*0.5;k.g=(f.g+n.g)*0.5;k.b=(f.b+n.b)*0.5;w=Ga(l,f,n,k);qa(M,s,Q,E,L,e,w,0,0,1,0,0,1)}else if(J instanceof THREE.MeshNormalMaterial){m.r=
-Ca(B.normalWorld.x);m.g=Ca(B.normalWorld.y);m.b=Ca(B.normalWorld.z);m.updateStyleString();J.wireframe?xa(m.__styleString,J.wireframe_linewidth):ya(m.__styleString)}}}function xa(v,S){if(D!=v)i.strokeStyle=D=v;if(y!=S)i.lineWidth=y=S;i.stroke();t.inflate(S*2)}function ya(v){if(C!=v)i.fillStyle=C=v;i.fill()}function qa(v,S,O,B,J,X,$,ba,ca,ha,ea,ia,ra){var ka,ja;ka=$.width-1;ja=$.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;ra*=ja;O-=v;B-=S;J-=v;X-=S;ha-=ba;ea-=ca;ia-=ba;ra-=ca;ja=1/(ha*ra-ia*ea);ka=
-(ra*O-ea*J)*ja;ea=(ra*B-ea*X)*ja;O=(ha*J-ia*O)*ja;B=(ha*X-ia*B)*ja;v=v-ka*ba-O*ca;S=S-ea*ba-B*ca;i.save();i.transform(ka,ea,O,B,v,S);i.clip();i.drawImage($,0,0);i.restore()}function Ba(v){if(o!=v)i.globalAlpha=o=v}function wa(v){if(c!=v){switch(v){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}c=v}}function Ga(v,S,O,B){var J=~~(v.r*255),
-X=~~(v.g*255);v=~~(v.b*255);var $=~~(S.r*255),ba=~~(S.g*255);S=~~(S.b*255);var ca=~~(O.r*255),ha=~~(O.g*255);O=~~(O.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=J<0?0:J>255?255:J;da[1]=X<0?0:X>255?255:X;da[2]=v<0?0:v>255?255:v;da[4]=$<0?0:$>255?255:$;da[5]=ba<0?0:ba>255?255:ba;da[6]=S<0?0:S>255?255:S;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=O<0?0:O>255?255:O;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;oa.putImageData(Aa,0,0);
-ta.drawImage(na,0,0);return pa}function Ca(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Da(v,S){var O=S.x-v.x,B=S.y-v.y,J=1/Math.sqrt(O*O+B*B);O*=J;B*=J;S.x+=O;S.y+=B;v.x-=O;v.y-=B}var za,Ha,Z,fa,ma,Ea,Ia,sa;i.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ga,ua,this.sortElements);i.fillStyle="rgba(0, 255, 255, 0.5)";i.fillRect(T.getX(),T.getY(),T.getWidth(),T.getHeight());(H=ga.lights.length>0)&&Ka(ga);za=0;for(Ha=a.length;za<Ha;za++){Z=a[za];t.empty();if(Z instanceof THREE.RenderableParticle){x=
-Z;x.x*=j;x.y*=p;fa=0;for(ma=Z.material.length;fa<ma;fa++)La(x,Z,Z.material[fa],ga)}else if(Z instanceof THREE.RenderableLine){x=Z.v1;K=Z.v2;x.positionScreen.x*=j;x.positionScreen.y*=p;K.positionScreen.x*=j;K.positionScreen.y*=p;t.addPoint(x.positionScreen.x,x.positionScreen.y);t.addPoint(K.positionScreen.x,K.positionScreen.y);if(T.instersects(t)){fa=0;for(ma=Z.material.length;fa<ma;)Ma(x,K,Z,Z.material[fa++],ga)}}else if(Z instanceof THREE.RenderableFace3){x=Z.v1;K=Z.v2;P=Z.v3;x.positionScreen.x*=
-j;x.positionScreen.y*=p;K.positionScreen.x*=j;K.positionScreen.y*=p;P.positionScreen.x*=j;P.positionScreen.y*=p;if(Z.overdraw){Da(x.positionScreen,K.positionScreen);Da(K.positionScreen,P.positionScreen);Da(P.positionScreen,x.positionScreen)}t.add3Points(x.positionScreen.x,x.positionScreen.y,K.positionScreen.x,K.positionScreen.y,P.positionScreen.x,P.positionScreen.y);if(T.instersects(t)){fa=0;for(ma=Z.meshMaterial.length;fa<ma;){sa=Z.meshMaterial[fa++];if(sa instanceof THREE.MeshFaceMaterial){Ea=0;
-for(Ia=Z.faceMaterial.length;Ea<Ia;)(sa=Z.faceMaterial[Ea++])&&Fa(x,K,P,Z,sa,ga)}else Fa(x,K,P,Z,sa,ga)}}}z.addRectangle(t)}i.lineWidth=1;i.strokeStyle="rgba( 255, 0, 0, 0.5 )";i.strokeRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());i.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(A,W,U){var T,z,t,H;T=0;for(z=A.lights.length;T<z;T++){t=A.lights[T];if(t instanceof THREE.DirectionalLight){H=W.normalWorld.dot(t.position)*t.intensity;if(H>0){U.r+=t.color.r*H;U.g+=t.color.g*H;U.b+=t.color.b*H}}else if(t instanceof THREE.PointLight){n.sub(t.position,W.centroidWorld);n.normalize();H=W.normalWorld.dot(n)*t.intensity;if(H>0){U.r+=t.color.r*H;U.g+=t.color.g*H;U.b+=t.color.b*H}}}}function b(A,W,U,T,z,t){u=d(w++);u.setAttribute("d","M "+A.positionScreen.x+
-" "+A.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)E.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(Q){L.r=e.r;L.g=e.g;L.b=e.b;a(t,T,L);E.r=z.color.r*L.r;E.g=z.color.g*L.g;E.b=z.color.b*L.b;E.updateStyleString()}else E.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){f=1-z.__2near/(z.__farPlusNear-T.z*z.__farMinusNear);
-E.setRGB(f,f,f)}else z instanceof THREE.MeshNormalMaterial&&E.setRGB(h(T.normalWorld.x),h(T.normalWorld.y),h(T.normalWorld.z));z.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+z.opacity);i.appendChild(u)}function g(A,W,U,T,z,t,H){u=d(w++);u.setAttribute("d",
-"M "+A.positionScreen.x+" "+A.positionScreen.y+" L "+W.positionScreen.x+" "+W.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)E.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(Q){L.r=e.r;L.g=e.g;L.b=e.b;a(H,z,L);E.r=t.color.r*L.r;E.g=t.color.g*L.g;E.b=t.color.b*L.b;E.updateStyleString()}else E.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){f=
-1-t.__2near/(t.__farPlusNear-z.z*t.__farMinusNear);E.setRGB(f,f,f)}else t instanceof THREE.MeshNormalMaterial&&E.setRGB(h(z.normalWorld.x),h(z.normalWorld.y),h(z.normalWorld.z));t.wireframe?u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):u.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+t.opacity);i.appendChild(u)}
-function d(A){if(k[A]==null){k[A]=document.createElementNS("http://www.w3.org/2000/svg","path");F==0&&k[A].setAttribute("shape-rendering","crispEdges");return k[A]}return k[A]}function h(A){return A<0?Math.min((1+A)*0.5,0.5):0.5+Math.min(A*0.5,0.5)}var j=null,p=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,C,y,x,K,P,M=new THREE.Rectangle,s=new THREE.Rectangle,Q=false,E=new THREE.Color(16777215),L=new THREE.Color(16777215),e=new THREE.Color(0),m=new THREE.Color(0),
-l=new THREE.Color(0),f,n=new THREE.Vector3,k=[],r=[],q=[],u,w,N,G,F=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(A){switch(A){case "high":F=1;break;case "low":F=0}};this.setSize=function(A,W){o=A;c=W;D=o/2;C=c/2;i.setAttribute("viewBox",-D+" "+-C+" "+o+" "+c);i.setAttribute("width",o);i.setAttribute("height",c);M.set(-D,-C,D,C)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(A,W){var U,T,
-z,t,H,R,I,V;this.autoClear&&this.clear();j=p.projectScene(A,W,this.sortElements);G=N=w=0;if(Q=A.lights.length>0){I=A.lights;e.setRGB(0,0,0);m.setRGB(0,0,0);l.setRGB(0,0,0);U=0;for(T=I.length;U<T;U++){z=I[U];t=z.color;if(z instanceof THREE.AmbientLight){e.r+=t.r;e.g+=t.g;e.b+=t.b}else if(z instanceof THREE.DirectionalLight){m.r+=t.r;m.g+=t.g;m.b+=t.b}else if(z instanceof THREE.PointLight){l.r+=t.r;l.g+=t.g;l.b+=t.b}}}U=0;for(T=j.length;U<T;U++){I=j[U];s.empty();if(I instanceof THREE.RenderableParticle){y=
-I;y.x*=D;y.y*=-C;z=0;for(t=I.material.length;z<t;z++)if(V=I.material[z]){H=y;R=I;V=V;var aa=N++;if(r[aa]==null){r[aa]=document.createElementNS("http://www.w3.org/2000/svg","circle");F==0&&r[aa].setAttribute("shape-rendering","crispEdges")}u=r[aa];u.setAttribute("cx",H.x);u.setAttribute("cy",H.y);u.setAttribute("r",R.scale.x*D);if(V instanceof THREE.ParticleCircleMaterial){if(Q){L.r=e.r+m.r+l.r;L.g=e.g+m.g+l.g;L.b=e.b+m.b+l.b;E.r=V.color.r*L.r;E.g=V.color.g*L.g;E.b=V.color.b*L.b;E.updateStyleString()}else E=
-V.color;u.setAttribute("style","fill: "+E.__styleString)}i.appendChild(u)}}else if(I instanceof THREE.RenderableLine){y=I.v1;x=I.v2;y.positionScreen.x*=D;y.positionScreen.y*=-C;x.positionScreen.x*=D;x.positionScreen.y*=-C;s.addPoint(y.positionScreen.x,y.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);if(M.instersects(s)){z=0;for(t=I.material.length;z<t;)if(V=I.material[z++]){H=y;R=x;V=V;aa=G++;if(q[aa]==null){q[aa]=document.createElementNS("http://www.w3.org/2000/svg","line");
-F==0&&q[aa].setAttribute("shape-rendering","crispEdges")}u=q[aa];u.setAttribute("x1",H.positionScreen.x);u.setAttribute("y1",H.positionScreen.y);u.setAttribute("x2",R.positionScreen.x);u.setAttribute("y2",R.positionScreen.y);if(V instanceof THREE.LineBasicMaterial){E.__styleString=V.color.__styleString;u.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+V.linewidth+"; stroke-opacity: "+V.opacity+"; stroke-linecap: "+V.linecap+"; stroke-linejoin: "+V.linejoin);i.appendChild(u)}}}}else if(I instanceof
-THREE.RenderableFace3){y=I.v1;x=I.v2;K=I.v3;y.positionScreen.x*=D;y.positionScreen.y*=-C;x.positionScreen.x*=D;x.positionScreen.y*=-C;K.positionScreen.x*=D;K.positionScreen.y*=-C;s.addPoint(y.positionScreen.x,y.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);if(M.instersects(s)){z=0;for(t=I.meshMaterial.length;z<t;){V=I.meshMaterial[z++];if(V instanceof THREE.MeshFaceMaterial){H=0;for(R=I.faceMaterial.length;H<R;)(V=I.faceMaterial[H++])&&
-b(y,x,K,I,V,A)}else V&&b(y,x,K,I,V,A)}}}else if(I instanceof THREE.RenderableFace4){y=I.v1;x=I.v2;K=I.v3;P=I.v4;y.positionScreen.x*=D;y.positionScreen.y*=-C;x.positionScreen.x*=D;x.positionScreen.y*=-C;K.positionScreen.x*=D;K.positionScreen.y*=-C;P.positionScreen.x*=D;P.positionScreen.y*=-C;s.addPoint(y.positionScreen.x,y.positionScreen.y);s.addPoint(x.positionScreen.x,x.positionScreen.y);s.addPoint(K.positionScreen.x,K.positionScreen.y);s.addPoint(P.positionScreen.x,P.positionScreen.y);if(M.instersects(s)){z=
-0;for(t=I.meshMaterial.length;z<t;){V=I.meshMaterial[z++];if(V instanceof THREE.MeshFaceMaterial){H=0;for(R=I.faceMaterial.length;H<R;)(V=I.faceMaterial[H++])&&g(y,x,K,P,I,V,A)}else V&&g(y,x,K,P,I,V,A)}}}}}};
-THREE.WebGLRenderer=function(a){function b(e,m,l){var f=c.createProgram();l=["#ifdef GL_ES\nprecision highp float;\n#endif",l?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
-c.attachShader(f,p("fragment",l+e));c.attachShader(f,p("vertex",n+m));c.linkProgram(f);c.getProgramParameter(f,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(f,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");f.uniforms={};f.attributes={};return f}function g(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
-c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var l=0;l<6;++l)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[l]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
+THREE.Fog=function(a,b,f){this.color=new THREE.Color(a);this.near=b||1;this.far=f||1E3};
+THREE.Projector=function(){function a(k,g){return g.z-k.z}function b(k,g){var n=0,l=1,s=k.z+k.w,x=g.z+g.w,v=-k.z+k.w,z=-g.z+g.w;if(s>=0&&x>=0&&v>=0&&z>=0)return true;else if(s<0&&x<0||v<0&&z<0)return false;else{if(s<0)n=Math.max(n,s/(s-x));else if(x<0)l=Math.min(l,s/(s-x));if(v<0)n=Math.max(n,v/(v-z));else if(z<0)l=Math.min(l,v/(v-z));if(l<n)return false;else{k.lerpSelf(g,n);g.lerpSelf(k,1-l);return true}}}var f,d,h=[],j,p,i,o=[],c,D,F=[],w,u,I=[],Q=new THREE.Vector4,O=new THREE.Vector4,r=new THREE.Matrix4,
+S=new THREE.Matrix4,E=[],J=new THREE.Vector4,e=new THREE.Vector4,m;this.projectObjects=function(k,g,n){var l=[],s,x;d=0;r.multiply(g.projectionMatrix,g.matrix);E[0]=new THREE.Vector4(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);E[1]=new THREE.Vector4(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);E[2]=new THREE.Vector4(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);E[3]=new THREE.Vector4(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);E[4]=new THREE.Vector4(r.n41-r.n31,r.n42-r.n32,r.n43-
+r.n33,r.n44-r.n34);E[5]=new THREE.Vector4(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);g=0;for(s=E.length;g<s;g++){x=E[g];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}s=k.objects;k=0;for(g=s.length;k<g;k++){x=s[k];var v;if(!(v=!x.visible)){if(v=x instanceof THREE.Mesh){a:{v=void 0;for(var z=x.position,V=-x.geometry.boundingSphere.radius*Math.max(x.scale.x,Math.max(x.scale.y,x.scale.z)),t=0;t<6;t++){v=E[t].x*z.x+E[t].y*z.y+E[t].z*z.z+E[t].w;if(v<=V){v=false;break a}}v=true}v=!v}v=v}if(!v){f=
+h[d]=h[d]||new THREE.RenderableObject;Q.copy(x.position);r.multiplyVector3(Q);f.object=x;f.z=Q.z;l.push(f);d++}}n&&l.sort(a);return l};this.projectScene=function(k,g,n){var l=[],s=g.near,x=g.far,v,z,V,t,L,C,H,R,U,y,A,P,W,G,M,Y;i=D=u=0;g.autoUpdateMatrix&&g.updateMatrix();r.multiply(g.projectionMatrix,g.matrix);C=this.projectObjects(k,g,true);k=0;for(v=C.length;k<v;k++){H=C[k].object;if(H.visible){H.autoUpdateMatrix&&H.updateMatrix();R=H.matrix;U=H.rotationMatrix;y=H.materials;A=H.overdraw;if(H instanceof
+THREE.Mesh){P=H.geometry;W=P.vertices;z=0;for(V=W.length;z<V;z++){G=W[z];G.positionWorld.copy(G.position);R.multiplyVector3(G.positionWorld);t=G.positionScreen;t.copy(G.positionWorld);r.multiplyVector4(t);t.x/=t.w;t.y/=t.w;G.__visible=t.z>s&&t.z<x}P=P.faces;z=0;for(V=P.length;z<V;z++){G=P[z];if(G instanceof THREE.Face3){t=W[G.a];L=W[G.b];M=W[G.c];if(t.__visible&&L.__visible&&M.__visible)if(H.doubleSided||H.flipSided!=(M.positionScreen.x-t.positionScreen.x)*(L.positionScreen.y-t.positionScreen.y)-
+(M.positionScreen.y-t.positionScreen.y)*(L.positionScreen.x-t.positionScreen.x)<0){j=o[i]=o[i]||new THREE.RenderableFace3;j.v1.positionWorld.copy(t.positionWorld);j.v2.positionWorld.copy(L.positionWorld);j.v3.positionWorld.copy(M.positionWorld);j.v1.positionScreen.copy(t.positionScreen);j.v2.positionScreen.copy(L.positionScreen);j.v3.positionScreen.copy(M.positionScreen);j.normalWorld.copy(G.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(G.centroid);R.multiplyVector3(j.centroidWorld);
+j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);M=G.vertexNormals;m=j.vertexNormalsWorld;t=0;for(L=M.length;t<L;t++){Y=m[t]=m[t]||new THREE.Vector3;Y.copy(M[t]);U.multiplyVector3(Y)}j.z=j.centroidScreen.z;j.meshMaterials=y;j.faceMaterials=G.materials;j.overdraw=A;if(H.geometry.uvs[z]){j.uvs[0]=H.geometry.uvs[z][0];j.uvs[1]=H.geometry.uvs[z][1];j.uvs[2]=H.geometry.uvs[z][2]}l.push(j);i++}}else if(G instanceof THREE.Face4){t=W[G.a];L=W[G.b];M=W[G.c];Y=W[G.d];if(t.__visible&&
+L.__visible&&M.__visible&&Y.__visible)if(H.doubleSided||H.flipSided!=((Y.positionScreen.x-t.positionScreen.x)*(L.positionScreen.y-t.positionScreen.y)-(Y.positionScreen.y-t.positionScreen.y)*(L.positionScreen.x-t.positionScreen.x)<0||(L.positionScreen.x-M.positionScreen.x)*(Y.positionScreen.y-M.positionScreen.y)-(L.positionScreen.y-M.positionScreen.y)*(Y.positionScreen.x-M.positionScreen.x)<0)){j=o[i]=o[i]||new THREE.RenderableFace3;j.v1.positionWorld.copy(t.positionWorld);j.v2.positionWorld.copy(L.positionWorld);
+j.v3.positionWorld.copy(Y.positionWorld);j.v1.positionScreen.copy(t.positionScreen);j.v2.positionScreen.copy(L.positionScreen);j.v3.positionScreen.copy(Y.positionScreen);j.normalWorld.copy(G.normal);U.multiplyVector3(j.normalWorld);j.centroidWorld.copy(G.centroid);R.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);r.multiplyVector3(j.centroidScreen);j.z=j.centroidScreen.z;j.meshMaterials=y;j.faceMaterials=G.materials;j.overdraw=A;if(H.geometry.uvs[z]){j.uvs[0]=H.geometry.uvs[z][0];
+j.uvs[1]=H.geometry.uvs[z][1];j.uvs[2]=H.geometry.uvs[z][3]}l.push(j);i++;p=o[i]=o[i]||new THREE.RenderableFace3;p.v1.positionWorld.copy(L.positionWorld);p.v2.positionWorld.copy(M.positionWorld);p.v3.positionWorld.copy(Y.positionWorld);p.v1.positionScreen.copy(L.positionScreen);p.v2.positionScreen.copy(M.positionScreen);p.v3.positionScreen.copy(Y.positionScreen);p.normalWorld.copy(j.normalWorld);p.centroidWorld.copy(j.centroidWorld);p.centroidScreen.copy(j.centroidScreen);p.z=p.centroidScreen.z;p.meshMaterials=
+y;p.faceMaterials=G.materials;p.overdraw=A;if(H.geometry.uvs[z]){p.uvs[0]=H.geometry.uvs[z][1];p.uvs[1]=H.geometry.uvs[z][2];p.uvs[2]=H.geometry.uvs[z][3]}l.push(p);i++}}}}else if(H instanceof THREE.Line){S.multiply(r,R);W=H.geometry.vertices;G=W[0];G.positionScreen.copy(G.position);S.multiplyVector4(G.positionScreen);z=1;for(V=W.length;z<V;z++){t=W[z];t.positionScreen.copy(t.position);S.multiplyVector4(t.positionScreen);L=W[z-1];J.copy(t.positionScreen);e.copy(L.positionScreen);if(b(J,e)){J.multiplyScalar(1/
+J.w);e.multiplyScalar(1/e.w);c=F[D]=F[D]||new THREE.RenderableLine;c.v1.positionScreen.copy(J);c.v2.positionScreen.copy(e);c.z=Math.max(J.z,e.z);c.materials=H.materials;l.push(c);D++}}}else if(H instanceof THREE.Particle){O.set(H.position.x,H.position.y,H.position.z,1);r.multiplyVector4(O);O.z/=O.w;if(O.z>0&&O.z<1){w=I[u]=I[u]||new THREE.RenderableParticle;w.x=O.x/O.w;w.y=O.y/O.w;w.z=O.z;w.rotation=H.rotation.z;w.scale.x=H.scale.x*Math.abs(w.x-(O.x+g.projectionMatrix.n11)/(O.w+g.projectionMatrix.n14));
+w.scale.y=H.scale.y*Math.abs(w.y-(O.y+g.projectionMatrix.n22)/(O.w+g.projectionMatrix.n24));w.materials=H.materials;l.push(w);u++}}}}n&&l.sort(a);return l};this.unprojectVector=function(k,g){var n=new THREE.Matrix4;n.multiply(THREE.Matrix4.makeInvert(g.matrix),THREE.Matrix4.makeInvert(g.projectionMatrix));n.multiplyVector3(k);return k}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,d,h,j;this.domElement=document.createElement("div");this.setSize=function(p,i){f=p;d=i;h=f/2;j=d/2};this.render=function(p,i){var o,c,D,F,w,u,I,Q;a=b.projectScene(p,i);o=0;for(c=a.length;o<c;o++){w=a[o];if(w instanceof THREE.RenderableParticle){I=w.x*h+h;Q=w.y*j+j;D=0;for(F=w.material.length;D<F;D++){u=w.material[D];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=I+"px";u.style.top=Q+"px"}}}}}};
+THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,f=document.createElement("canvas"),d,h,j,p,i=f.getContext("2d"),o=1,c=0,D=null,F=null,w=1,u,I,Q,O,r,S,E,J,e,m=new THREE.Color,k=new THREE.Color,g=new THREE.Color,n=new THREE.Color,l=new THREE.Color,s,x,v,z,V,t,L,C,H,R=new THREE.Rectangle,U=new THREE.Rectangle,y=new THREE.Rectangle,A=false,P=new THREE.Color,W=new THREE.Color,G=new THREE.Color,M=new THREE.Color,Y=Math.PI*2,Z=new THREE.Vector3,oa,pa,Aa,da,qa,ua,la=16;oa=document.createElement("canvas");
+oa.width=oa.height=2;pa=oa.getContext("2d");pa.fillStyle="rgba(0,0,0,1)";pa.fillRect(0,0,2,2);Aa=pa.getImageData(0,0,2,2);da=Aa.data;qa=document.createElement("canvas");qa.width=qa.height=la;ua=qa.getContext("2d");ua.translate(-la/2,-la/2);ua.scale(la,la);la--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ga,ma){d=ga;h=ma;j=d/2;p=h/2;f.width=d;f.height=h;R.set(-j,-p,j,p)};this.clear=function(){if(!U.isEmpty()){U.inflate(1);U.minSelf(R);i.clearRect(U.getX(),
+U.getY(),U.getWidth(),U.getHeight());U.empty()}};this.render=function(ga,ma){function Ka(q){var T,N,B,K=q.lights;W.setRGB(0,0,0);G.setRGB(0,0,0);M.setRGB(0,0,0);q=0;for(T=K.length;q<T;q++){N=K[q];B=N.color;if(N instanceof THREE.AmbientLight){W.r+=B.r;W.g+=B.g;W.b+=B.b}else if(N instanceof THREE.DirectionalLight){G.r+=B.r;G.g+=B.g;G.b+=B.b}else if(N instanceof THREE.PointLight){M.r+=B.r;M.g+=B.g;M.b+=B.b}}}function va(q,T,N,B){var K,X,aa,ba,ca=q.lights;q=0;for(K=ca.length;q<K;q++){X=ca[q];aa=X.color;
+ba=X.intensity;if(X instanceof THREE.DirectionalLight){X=N.dot(X.position)*ba;if(X>0){B.r+=aa.r*X;B.g+=aa.g*X;B.b+=aa.b*X}}else if(X instanceof THREE.PointLight){Z.sub(X.position,T);Z.normalize();X=N.dot(Z)*ba;if(X>0){B.r+=aa.r*X;B.g+=aa.g*X;B.b+=aa.b*X}}}}function La(q,T,N){if(N.opacity!=0){Ba(N.opacity);wa(N.blending);var B,K,X,aa,ba,ca;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ba=aa.width>>1;ca=aa.height>>1;K=T.scale.x*j;X=T.scale.y*p;N=K*ba;B=X*ca;y.set(q.x-N,q.y-B,q.x+N,
+q.y+B);if(!R.instersects(y))return;i.save();i.translate(q.x,q.y);i.rotate(-T.rotation);i.scale(K,-X);i.translate(-ba,-ca);i.drawImage(aa,0,0);i.restore()}i.beginPath();i.moveTo(q.x-10,q.y);i.lineTo(q.x+10,q.y);i.moveTo(q.x,q.y-10);i.lineTo(q.x,q.y+10);i.closePath();i.strokeStyle="rgb(255,255,0)";i.stroke()}else if(N instanceof THREE.ParticleCircleMaterial){if(A){P.r=W.r+G.r+M.r;P.g=W.g+G.g+M.g;P.b=W.b+G.b+M.b;m.r=N.color.r*P.r;m.g=N.color.g*P.g;m.b=N.color.b*P.b;m.updateStyleString()}else m.__styleString=
+N.color.__styleString;N=T.scale.x*j;B=T.scale.y*p;y.set(q.x-N,q.y-B,q.x+N,q.y+B);if(R.instersects(y)){K=m.__styleString;if(F!=K)i.fillStyle=F=K;i.save();i.translate(q.x,q.y);i.rotate(-T.rotation);i.scale(N,B);i.beginPath();i.arc(0,0,1,0,Y,true);i.closePath();i.fill();i.restore()}}}}function Ma(q,T,N,B){if(B.opacity!=0){Ba(B.opacity);wa(B.blending);i.beginPath();i.moveTo(q.positionScreen.x,q.positionScreen.y);i.lineTo(T.positionScreen.x,T.positionScreen.y);i.closePath();if(B instanceof THREE.LineBasicMaterial){m.__styleString=
+B.color.__styleString;q=B.linewidth;if(w!=q)i.lineWidth=w=q;q=m.__styleString;if(D!=q)i.strokeStyle=D=q;i.stroke();y.inflate(B.linewidth*2)}}}function Ga(q,T,N,B,K,X){if(K.opacity!=0){Ba(K.opacity);wa(K.blending);O=q.positionScreen.x;r=q.positionScreen.y;S=T.positionScreen.x;E=T.positionScreen.y;J=N.positionScreen.x;e=N.positionScreen.y;i.beginPath();i.moveTo(O,r);i.lineTo(S,E);i.lineTo(J,e);i.lineTo(O,r);i.closePath();if(K instanceof THREE.MeshBasicMaterial)if(K.map)K.map.image.loaded&&K.map.mapping instanceof
+THREE.UVMapping&&ra(O,r,S,E,J,e,K.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(K.env_map){if(K.env_map.image.loaded)if(K.env_map.mapping instanceof THREE.SphericalReflectionMapping){q=ma.matrix;Z.copy(B.vertexNormalsWorld[0]);z=(Z.x*q.n11+Z.y*q.n12+Z.z*q.n13)*0.5+0.5;V=-(Z.x*q.n21+Z.y*q.n22+Z.z*q.n23)*0.5+0.5;Z.copy(B.vertexNormalsWorld[1]);t=(Z.x*q.n11+Z.y*q.n12+Z.z*q.n13)*0.5+0.5;L=-(Z.x*q.n21+Z.y*q.n22+Z.z*q.n23)*0.5+0.5;Z.copy(B.vertexNormalsWorld[2]);C=
+(Z.x*q.n11+Z.y*q.n12+Z.z*q.n13)*0.5+0.5;H=-(Z.x*q.n21+Z.y*q.n22+Z.z*q.n23)*0.5+0.5;ra(O,r,S,E,J,e,K.env_map.image,z,V,t,L,C,H)}}else K.wireframe?xa(K.color.__styleString,K.wireframe_linewidth):ya(K.color.__styleString);else if(K instanceof THREE.MeshLambertMaterial){if(K.map&&!K.wireframe){K.map.mapping instanceof THREE.UVMapping&&ra(O,r,S,E,J,e,K.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);wa(THREE.SubtractiveBlending)}if(A)if(!K.wireframe&&K.shading==THREE.SmoothShading&&
+B.vertexNormalsWorld.length==3){k.r=g.r=n.r=W.r;k.g=g.g=n.g=W.g;k.b=g.b=n.b=W.b;va(X,B.v1.positionWorld,B.vertexNormalsWorld[0],k);va(X,B.v2.positionWorld,B.vertexNormalsWorld[1],g);va(X,B.v3.positionWorld,B.vertexNormalsWorld[2],n);l.r=(g.r+n.r)*0.5;l.g=(g.g+n.g)*0.5;l.b=(g.b+n.b)*0.5;v=Ha(k,g,n,l);ra(O,r,S,E,J,e,v,0,0,1,0,0,1)}else{P.r=W.r;P.g=W.g;P.b=W.b;va(X,B.centroidWorld,B.normalWorld,P);m.r=K.color.r*P.r;m.g=K.color.g*P.g;m.b=K.color.b*P.b;m.updateStyleString();K.wireframe?xa(m.__styleString,
+K.wireframe_linewidth):ya(m.__styleString)}else K.wireframe?xa(K.color.__styleString,K.wireframe_linewidth):ya(K.color.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){s=ma.near;x=ma.far;k.r=k.g=k.b=1-Ca(q.positionScreen.z,s,x);g.r=g.g=g.b=1-Ca(T.positionScreen.z,s,x);n.r=n.g=n.b=1-Ca(N.positionScreen.z,s,x);l.r=(g.r+n.r)*0.5;l.g=(g.g+n.g)*0.5;l.b=(g.b+n.b)*0.5;v=Ha(k,g,n,l);ra(O,r,S,E,J,e,v,0,0,1,0,0,1)}else if(K instanceof THREE.MeshNormalMaterial){m.r=Da(B.normalWorld.x);m.g=Da(B.normalWorld.y);
+m.b=Da(B.normalWorld.z);m.updateStyleString();K.wireframe?xa(m.__styleString,K.wireframe_linewidth):ya(m.__styleString)}}}function xa(q,T){if(D!=q)i.strokeStyle=D=q;if(w!=T)i.lineWidth=w=T;i.stroke();y.inflate(T*2)}function ya(q){if(F!=q)i.fillStyle=F=q;i.fill()}function ra(q,T,N,B,K,X,aa,ba,ca,ha,ea,ia,sa){var ka,ja;ka=aa.width-1;ja=aa.height-1;ba*=ka;ca*=ja;ha*=ka;ea*=ja;ia*=ka;sa*=ja;N-=q;B-=T;K-=q;X-=T;ha-=ba;ea-=ca;ia-=ba;sa-=ca;ja=1/(ha*sa-ia*ea);ka=(sa*N-ea*K)*ja;ea=(sa*B-ea*X)*ja;N=(ha*K-
+ia*N)*ja;B=(ha*X-ia*B)*ja;q=q-ka*ba-N*ca;T=T-ea*ba-B*ca;i.save();i.transform(ka,ea,N,B,q,T);i.clip();i.drawImage(aa,0,0);i.restore()}function Ba(q){if(o!=q)i.globalAlpha=o=q}function wa(q){if(c!=q){switch(q){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}c=q}}function Ha(q,T,N,B){var K=~~(q.r*255),X=~~(q.g*255);q=~~(q.b*255);var aa=~~(T.r*
+255),ba=~~(T.g*255);T=~~(T.b*255);var ca=~~(N.r*255),ha=~~(N.g*255);N=~~(N.b*255);var ea=~~(B.r*255),ia=~~(B.g*255);B=~~(B.b*255);da[0]=K<0?0:K>255?255:K;da[1]=X<0?0:X>255?255:X;da[2]=q<0?0:q>255?255:q;da[4]=aa<0?0:aa>255?255:aa;da[5]=ba<0?0:ba>255?255:ba;da[6]=T<0?0:T>255?255:T;da[8]=ca<0?0:ca>255?255:ca;da[9]=ha<0?0:ha>255?255:ha;da[10]=N<0?0:N>255?255:N;da[12]=ea<0?0:ea>255?255:ea;da[13]=ia<0?0:ia>255?255:ia;da[14]=B<0?0:B>255?255:B;pa.putImageData(Aa,0,0);ua.drawImage(oa,0,0);return qa}function Ca(q,
+T,N){q=(q-T)/(N-T);return q*q*(3-2*q)}function Da(q){q=(q+1)*0.5;return q<0?0:q>1?1:q}function Ea(q,T){var N=T.x-q.x,B=T.y-q.y,K=1/Math.sqrt(N*N+B*B);N*=K;B*=K;T.x+=N;T.y+=B;q.x-=N;q.y-=B}var za,Ia,$,fa,na,Fa,Ja,ta;i.setTransform(1,0,0,-1,j,p);this.autoClear&&this.clear();a=b.projectScene(ga,ma,this.sortElements);i.fillStyle="rgba( 0, 255, 255, 0.5 )";i.fillRect(R.getX(),R.getY(),R.getWidth(),R.getHeight());(A=ga.lights.length>0)&&Ka(ga);za=0;for(Ia=a.length;za<Ia;za++){$=a[za];y.empty();if($ instanceof
+THREE.RenderableParticle){u=$;u.x*=j;u.y*=p;fa=0;for(na=$.materials.length;fa<na;fa++)La(u,$,$.materials[fa],ga)}else if($ instanceof THREE.RenderableLine){u=$.v1;I=$.v2;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;y.addPoint(u.positionScreen.x,u.positionScreen.y);y.addPoint(I.positionScreen.x,I.positionScreen.y);if(R.instersects(y)){fa=0;for(na=$.materials.length;fa<na;)Ma(u,I,$,$.materials[fa++],ga)}}else if($ instanceof THREE.RenderableFace3){u=$.v1;I=
+$.v2;Q=$.v3;u.positionScreen.x*=j;u.positionScreen.y*=p;I.positionScreen.x*=j;I.positionScreen.y*=p;Q.positionScreen.x*=j;Q.positionScreen.y*=p;if($.overdraw){Ea(u.positionScreen,I.positionScreen);Ea(I.positionScreen,Q.positionScreen);Ea(Q.positionScreen,u.positionScreen)}y.add3Points(u.positionScreen.x,u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,Q.positionScreen.x,Q.positionScreen.y);if(R.instersects(y)){fa=0;for(na=$.meshMaterials.length;fa<na;){ta=$.meshMaterials[fa++];if(ta instanceof
+THREE.MeshFaceMaterial){Fa=0;for(Ja=$.faceMaterials.length;Fa<Ja;)(ta=$.faceMaterials[Fa++])&&Ga(u,I,Q,$,ta,ga)}else Ga(u,I,Q,$,ta,ga)}}}U.addRectangle(y)}i.lineWidth=1;i.strokeStyle="rgba( 255, 0, 0, 0.5 )";i.strokeRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());i.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(C,H,R){var U,y,A,P;U=0;for(y=C.lights.length;U<y;U++){A=C.lights[U];if(A instanceof THREE.DirectionalLight){P=H.normalWorld.dot(A.position)*A.intensity;if(P>0){R.r+=A.color.r*P;R.g+=A.color.g*P;R.b+=A.color.b*P}}else if(A instanceof THREE.PointLight){n.sub(A.position,H.centroidWorld);n.normalize();P=H.normalWorld.dot(n)*A.intensity;if(P>0){R.r+=A.color.r*P;R.g+=A.color.g*P;R.b+=A.color.b*P}}}}function b(C,H,R,U,y,A){v=d(z++);v.setAttribute("d","M "+C.positionScreen.x+
+" "+C.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(S){J.r=e.r;J.g=e.g;J.b=e.b;a(A,U,J);E.r=y.color.r*J.r;E.g=y.color.g*J.g;E.b=y.color.b*J.b;E.updateStyleString()}else E.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){g=1-y.__2near/(y.__farPlusNear-U.z*y.__farMinusNear);
+E.setRGB(g,g,g)}else y instanceof THREE.MeshNormalMaterial&&E.setRGB(h(U.normalWorld.x),h(U.normalWorld.y),h(U.normalWorld.z));y.wireframe?v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):v.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+y.opacity);i.appendChild(v)}function f(C,H,R,U,y,A,P){v=d(z++);v.setAttribute("d",
+"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)E.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(S){J.r=e.r;J.g=e.g;J.b=e.b;a(P,y,J);E.r=A.color.r*J.r;E.g=A.color.g*J.g;E.b=A.color.b*J.b;E.updateStyleString()}else E.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){g=
+1-A.__2near/(A.__farPlusNear-y.z*A.__farMinusNear);E.setRGB(g,g,g)}else A instanceof THREE.MeshNormalMaterial&&E.setRGB(h(y.normalWorld.x),h(y.normalWorld.y),h(y.normalWorld.z));A.wireframe?v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):v.setAttribute("style","fill: "+E.__styleString+"; fill-opacity: "+A.opacity);i.appendChild(v)}
+function d(C){if(l[C]==null){l[C]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&l[C].setAttribute("shape-rendering","crispEdges");return l[C]}return l[C]}function h(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var j=null,p=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,D,F,w,u,I,Q,O=new THREE.Rectangle,r=new THREE.Rectangle,S=false,E=new THREE.Color(16777215),J=new THREE.Color(16777215),e=new THREE.Color(0),m=new THREE.Color(0),
+k=new THREE.Color(0),g,n=new THREE.Vector3,l=[],s=[],x=[],v,z,V,t,L=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(C){switch(C){case "high":L=1;break;case "low":L=0}};this.setSize=function(C,H){o=C;c=H;D=o/2;F=c/2;i.setAttribute("viewBox",-D+" "+-F+" "+o+" "+c);i.setAttribute("width",o);i.setAttribute("height",c);O.set(-D,-F,D,F)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(C,H){var R,U,
+y,A,P,W,G,M;this.autoClear&&this.clear();j=p.projectScene(C,H,this.sortElements);t=V=z=0;if(S=C.lights.length>0){G=C.lights;e.setRGB(0,0,0);m.setRGB(0,0,0);k.setRGB(0,0,0);R=0;for(U=G.length;R<U;R++){y=G[R];A=y.color;if(y instanceof THREE.AmbientLight){e.r+=A.r;e.g+=A.g;e.b+=A.b}else if(y instanceof THREE.DirectionalLight){m.r+=A.r;m.g+=A.g;m.b+=A.b}else if(y instanceof THREE.PointLight){k.r+=A.r;k.g+=A.g;k.b+=A.b}}}R=0;for(U=j.length;R<U;R++){G=j[R];r.empty();if(G instanceof THREE.RenderableParticle){w=
+G;w.x*=D;w.y*=-F;y=0;for(A=G.materials.length;y<A;y++)if(M=G.materials[y]){P=w;W=G;M=M;var Y=V++;if(s[Y]==null){s[Y]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&s[Y].setAttribute("shape-rendering","crispEdges")}v=s[Y];v.setAttribute("cx",P.x);v.setAttribute("cy",P.y);v.setAttribute("r",W.scale.x*D);if(M instanceof THREE.ParticleCircleMaterial){if(S){J.r=e.r+m.r+k.r;J.g=e.g+m.g+k.g;J.b=e.b+m.b+k.b;E.r=M.color.r*J.r;E.g=M.color.g*J.g;E.b=M.color.b*J.b;E.updateStyleString()}else E=
+M.color;v.setAttribute("style","fill: "+E.__styleString)}i.appendChild(v)}}else if(G instanceof THREE.RenderableLine){w=G.v1;u=G.v2;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);if(O.instersects(r)){y=0;for(A=G.materials.length;y<A;)if(M=G.materials[y++]){P=w;W=u;M=M;Y=t++;if(x[Y]==null){x[Y]=document.createElementNS("http://www.w3.org/2000/svg","line");L==
+0&&x[Y].setAttribute("shape-rendering","crispEdges")}v=x[Y];v.setAttribute("x1",P.positionScreen.x);v.setAttribute("y1",P.positionScreen.y);v.setAttribute("x2",W.positionScreen.x);v.setAttribute("y2",W.positionScreen.y);if(M instanceof THREE.LineBasicMaterial){E.__styleString=M.color.__styleString;v.setAttribute("style","fill: none; stroke: "+E.__styleString+"; stroke-width: "+M.linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.linecap+"; stroke-linejoin: "+M.linejoin);i.appendChild(v)}}}}else if(G instanceof
+THREE.RenderableFace3){w=G.v1;u=G.v2;I=G.v3;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;I.positionScreen.x*=D;I.positionScreen.y*=-F;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);if(O.instersects(r)){y=0;for(A=G.meshMaterials.length;y<A;){M=G.meshMaterials[y++];if(M instanceof THREE.MeshFaceMaterial){P=0;for(W=G.faceMaterials.length;P<W;)(M=G.faceMaterials[P++])&&
+b(w,u,I,G,M,C)}else M&&b(w,u,I,G,M,C)}}}else if(G instanceof THREE.RenderableFace4){w=G.v1;u=G.v2;I=G.v3;Q=G.v4;w.positionScreen.x*=D;w.positionScreen.y*=-F;u.positionScreen.x*=D;u.positionScreen.y*=-F;I.positionScreen.x*=D;I.positionScreen.y*=-F;Q.positionScreen.x*=D;Q.positionScreen.y*=-F;r.addPoint(w.positionScreen.x,w.positionScreen.y);r.addPoint(u.positionScreen.x,u.positionScreen.y);r.addPoint(I.positionScreen.x,I.positionScreen.y);r.addPoint(Q.positionScreen.x,Q.positionScreen.y);if(O.instersects(r)){y=
+0;for(A=G.meshMaterials.length;y<A;){M=G.meshMaterials[y++];if(M instanceof THREE.MeshFaceMaterial){P=0;for(W=G.faceMaterials.length;P<W;)(M=G.faceMaterials[P++])&&f(w,u,I,Q,G,M,C)}else M&&f(w,u,I,Q,G,M,C)}}}}}};
+THREE.WebGLRenderer=function(a){function b(e,m,k){var g=c.createProgram();k=["#ifdef GL_ES\nprecision highp float;\n#endif",k?"#define USE_FOG":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");var n=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");
+c.attachShader(g,p("fragment",k+e));c.attachShader(g,p("vertex",n+m));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function f(e,m){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube);
+c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var k=0;k<6;++k)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[k]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+
 m);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,i(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,i(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,i(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
 m);c.bindTexture(c.TEXTURE_CUBE_MAP,e.image.__webGLTextureCube)}}function d(e,m){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,i(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,i(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,i(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,
-i(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function h(e,m){var l,f,n;l=0;for(f=m.length;l<f;l++){n=m[l];e.uniforms[n]=c.getUniformLocation(e,n)}}function j(e,m){var l,f,n;l=0;for(f=m.length;l<f;l++){n=m[l];e.attributes[n]=c.getAttribLocation(e,n)}}function p(e,m){var l;if(e=="fragment")l=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")l=c.createShader(c.VERTEX_SHADER);c.shaderSource(l,
-m);c.compileShader(l);if(!c.getShaderParameter(l,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(l));return null}return l}function i(e){switch(e){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}return 0}var o=document.createElement("canvas"),c,D,C,y=new THREE.Matrix4,x,K=new Float32Array(16),P=new Float32Array(16),M=new Float32Array(16),s=new Float32Array(9),Q=new Float32Array(16),E=function(e,m){if(e){var l,f,n,k=pointLights=maxDirLights=maxPointLights=0;l=0;for(f=e.lights.length;l<f;l++){n=e.lights[l];n instanceof THREE.DirectionalLight&&k++;n instanceof
-THREE.PointLight&&pointLights++}if(pointLights+k<=m){maxDirLights=k;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*k/(pointLights+k));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=o;this.autoClear=true;
-(function(e,m,l){try{c=o.getContext("experimental-webgl",{antialias:e})}catch(f){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(m.r,m.g,m.b,l)})(antialias,clearColor,clearAlpha);D=C=function(e,m,l){var f=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+
+i(e.min_filter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function h(e,m){var k,g,n;k=0;for(g=m.length;k<g;k++){n=m[k];e.uniforms[n]=c.getUniformLocation(e,n)}}function j(e,m){var k,g,n;k=0;for(g=m.length;k<g;k++){n=m[k];e.attributes[n]=c.getAttribLocation(e,n)}}function p(e,m){var k;if(e=="fragment")k=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")k=c.createShader(c.VERTEX_SHADER);c.shaderSource(k,
+m);c.compileShader(k);if(!c.getShaderParameter(k,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(k));return null}return k}function i(e){switch(e){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}return 0}var o=document.createElement("canvas"),c,D,F,w=new THREE.Matrix4,u,I=new Float32Array(16),Q=new Float32Array(16),O=new Float32Array(16),r=new Float32Array(9),S=new Float32Array(16),E=function(e,m){if(e){var k,g,n,l=pointLights=maxDirLights=maxPointLights=0;k=0;for(g=e.lights.length;k<g;k++){n=e.lights[k];n instanceof THREE.DirectionalLight&&l++;n instanceof
+THREE.PointLight&&pointLights++}if(pointLights+l<=m){maxDirLights=l;maxPointLights=pointLights}else{maxDirLights=Math.ceil(m*l/(pointLights+l));maxPointLights=m-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:m-1}}(a.scene,4);fog=a.scene?a.scene.fog:null;antialias=a.antialias!=undefined?a.antialias:true;clearColor=a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0);clearAlpha=a.clearAlpha?a.clearAlpha:0;this.domElement=o;this.autoClear=true;
+(function(e,m,k){try{c=o.getContext("experimental-webgl",{antialias:e})}catch(g){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(m.r,m.g,m.b,k)})(antialias,clearColor,clearAlpha);D=F=function(e,m,k){var g=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+
 m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
 m:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",e?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"",m?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",m?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":
 "","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 "","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
 e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",e?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",e?"}":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",m?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
 "",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
 "",m?"float pointLightWeighting = max( dot( transformedNormal, vPointLightVector[ i ] ), 0.0 );":"",m?"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;":"",m?"}":"","}\nvNormal = transformedNormal;\nvUv = uv;\nif ( useRefract ) {\nvReflect = refract( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz), mRefractionRatio );\n} else {\nvReflect = reflect( normalize(mPosition.xyz - cameraPosition), normalize(nWorld.xyz) );\n}\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n"),
-n=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogDensity;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
+n=[e?"#define MAX_DIR_LIGHTS "+e:"",m?"#define MAX_POINT_LIGHTS "+m:"","uniform int material;\nuniform bool enableMap;\nuniform bool enableCubeMap;\nuniform bool mixEnvMap;\nuniform samplerCube tCube;\nuniform float mReflectivity;\nuniform sampler2D tMap;\nuniform vec4 mColor;\nuniform float mOpacity;\nuniform vec4 mAmbient;\nuniform vec4 mSpecular;\nuniform float mShininess;\n#ifdef USE_FOG\nuniform vec3 fogColor;\nuniform float fogNear;\nuniform float fogFar;\n#endif\nuniform int pointLightNumber;\nuniform int directionalLightNumber;",
 e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
 e?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",m?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nvoid main() {\nvec4 mapColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nvec4 cubeColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nif ( enableMap ) {\nmapColor = texture2D( tMap, vUv );\n}\nif ( enableCubeMap ) {\ncubeColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\n}\nif ( material == 2 ) { \nvec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );",
 m?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",m?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",m?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",m?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",m?"float pointSpecularWeight = 0.0;":"",m?"if ( pointDotNormalHalf >= 0.0 )":
 m?"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",m?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",m?"vec3 pointVector = normalize( vPointLightVector[ i ] );":"",m?"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );":"",m?"float pointDotNormalHalf = dot( normal, pointHalfVector );":"",m?"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );":"",m?"float pointSpecularWeight = 0.0;":"",m?"if ( pointDotNormalHalf >= 0.0 )":
 "",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse  += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
 "",m?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",m?"pointDiffuse  += mColor * pointDiffuseWeight;":"",m?"pointSpecular += mSpecular * pointSpecularWeight;":"",m?"}":"",e?"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );":
 "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse  += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;":
 "",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse  += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",m?"totalLight += pointDiffuse + pointSpecular;":
-"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nconst float LOG2 = 1.442695;\nfloat z = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );\nfogFactor = clamp( fogFactor, 0.0, 1.0 );\ngl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );\n#endif\n}"].join("\n");
-f=b(n,f,l);c.useProgram(f);h(f,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);l&&h(f,["fogColor","fogDensity"]);e&&h(f,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&h(f,["pointLightNumber","pointLightColor",
-"pointLightPosition"]);c.uniform1i(f.uniforms.enableMap,0);c.uniform1i(f.uniforms.tMap,0);c.uniform1i(f.uniforms.enableCubeMap,0);c.uniform1i(f.uniforms.tCube,1);c.uniform1i(f.uniforms.mixEnvMap,0);c.uniform1i(f.uniforms.useRefract,0);j(f,["position","normal","uv"]);return f}(E.directional,E.point,fog);this.setSize=function(e,m){o.width=e;o.height=m;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,m){var l=new THREE.Color(e);c.clearColor(l.r,l.g,l.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
-c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var l,f,n,k,r,q=[],u=[],w=[];k=[];r=[];c.uniform1i(e.uniforms.enableLighting,m.length);l=0;for(f=m.length;l<f;l++){n=m[l];if(n instanceof THREE.AmbientLight)q.push(n);else if(n instanceof THREE.DirectionalLight)w.push(n);else n instanceof THREE.PointLight&&u.push(n)}l=n=k=r=0;for(f=q.length;l<f;l++){n+=q[l].color.r;k+=q[l].color.g;r+=q[l].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,k,r);k=[];r=[];l=0;for(f=w.length;l<f;l++){n=w[l];k.push(n.color.r*
-n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(w.length){c.uniform1i(e.uniforms.directionalLightNumber,w.length);c.uniform3fv(e.uniforms.directionalLightDirection,r);c.uniform3fv(e.uniforms.directionalLightColor,k)}k=[];r=[];l=0;for(f=u.length;l<f;l++){n=u[l];k.push(n.color.r*n.intensity);k.push(n.color.g*n.intensity);k.push(n.color.b*n.intensity);r.push(n.position.x);r.push(n.position.y);r.push(n.position.z)}if(u.length){c.uniform1i(e.uniforms.pointLightNumber,
-u.length);c.uniform3fv(e.uniforms.pointLightPosition,r);c.uniform3fv(e.uniforms.pointLightColor,k)}};this.createBuffers=function(e,m){var l,f,n,k,r,q,u,w,N,G=[],F=[],A=[],W=[],U=[],T=[],z=0,t=e.geometry.geometryChunks[m],H;n=false;l=0;for(f=e.material.length;l<f;l++){meshMaterial=e.material[l];if(meshMaterial instanceof THREE.MeshFaceMaterial){r=0;for(H=t.material.length;r<H;r++)if(t.material[r]&&t.material[r].shading!=undefined&&t.material[r].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
-meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}H=n;l=0;for(f=t.faces.length;l<f;l++){n=t.faces[l];k=e.geometry.faces[n];r=k.vertexNormals;faceNormal=k.normal;n=e.geometry.uvs[n];if(k instanceof THREE.Face3){q=e.geometry.vertices[k.a].position;u=e.geometry.vertices[k.b].position;w=e.geometry.vertices[k.c].position;A.push(q.x,q.y,q.z);A.push(u.x,u.y,u.z);A.push(w.x,w.y,w.z);if(e.geometry.hasTangents){q=e.geometry.vertices[k.a].tangent;u=e.geometry.vertices[k.b].tangent;
-w=e.geometry.vertices[k.c].tangent;U.push(q.x,q.y,q.z,q.w);U.push(u.x,u.y,u.z,u.w);U.push(w.x,w.y,w.z,w.w)}if(r.length==3&&H)for(k=0;k<3;k++)W.push(r[k].x,r[k].y,r[k].z);else for(k=0;k<3;k++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<3;k++)T.push(n[k].u,n[k].v);G.push(z,z+1,z+2);F.push(z,z+1);F.push(z,z+2);F.push(z+1,z+2);z+=3}else if(k instanceof THREE.Face4){q=e.geometry.vertices[k.a].position;u=e.geometry.vertices[k.b].position;w=e.geometry.vertices[k.c].position;N=e.geometry.vertices[k.d].position;
-A.push(q.x,q.y,q.z);A.push(u.x,u.y,u.z);A.push(w.x,w.y,w.z);A.push(N.x,N.y,N.z);if(e.geometry.hasTangents){q=e.geometry.vertices[k.a].tangent;u=e.geometry.vertices[k.b].tangent;w=e.geometry.vertices[k.c].tangent;k=e.geometry.vertices[k.d].tangent;U.push(q.x,q.y,q.z,q.w);U.push(u.x,u.y,u.z,u.w);U.push(w.x,w.y,w.z,w.w);U.push(k.x,k.y,k.z,k.w)}if(r.length==4&&H)for(k=0;k<4;k++)W.push(r[k].x,r[k].y,r[k].z);else for(k=0;k<4;k++)W.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(k=0;k<4;k++)T.push(n[k].u,
-n[k].v);G.push(z,z+1,z+2);G.push(z,z+2,z+3);F.push(z,z+1);F.push(z,z+2);F.push(z,z+3);F.push(z+1,z+2);F.push(z+2,z+3);z+=4}}if(A.length){t.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(A),c.STATIC_DRAW);t.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(W),c.STATIC_DRAW);if(e.geometry.hasTangents){t.__webGLTangentBuffer=c.createBuffer();
-c.bindBuffer(c.ARRAY_BUFFER,t.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}if(T.length>0){t.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,t.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW)}t.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);t.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-t.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(F),c.STATIC_DRAW);t.__webGLFaceCount=G.length;t.__webGLLineCount=F.length}};this.renderBuffer=function(e,m,l,f,n){var k,r,q,u,w,N,G,F,A;if(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshDepthMaterial||f instanceof THREE.MeshNormalMaterial){if(!f.program){if(f instanceof THREE.MeshDepthMaterial){G=L.depth;f.fragment_shader=G.fragment_shader;f.vertex_shader=G.vertex_shader;f.uniforms=G.uniforms;f.uniforms.mNear.value=
-f.near;f.uniforms.mFar.value=f.far}else if(f instanceof THREE.MeshNormalMaterial){G=L.normal;f.fragment_shader=G.fragment_shader;f.vertex_shader=G.vertex_shader;f.uniforms=G.uniforms}f.program=b(f.fragment_shader,f.vertex_shader,null);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(A in f.uniforms)G.push(A);h(f.program,G);j(f.program,["position","normal","uv","tangent"])}A=f.program}else A=C;if(A!=D){c.useProgram(A);D=A}A==C&&this.setupLights(A,
-m);this.loadCamera(A,e);this.loadMatrices(A);if(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshDepthMaterial||f instanceof THREE.MeshNormalMaterial){q=f.wireframe;u=f.wireframe_linewidth;e=A;m=f.uniforms;var W;for(k in m){F=m[k].type;G=m[k].value;W=e.uniforms[k];if(F=="i")c.uniform1i(W,G);else if(F=="f")c.uniform1f(W,G);else if(F=="v3")c.uniform3f(W,G.x,G.y,G.z);else if(F=="c")c.uniform3f(W,G.r,G.g,G.b);else if(F=="t"){c.uniform1i(W,G);if(F=m[k].texture)F.image instanceof Array&&F.image.length==
-6?g(F,G):d(F,G)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){k=f.color;r=f.opacity;q=f.wireframe;u=f.wireframe_linewidth;w=f.map;N=f.env_map;m=f.combine==THREE.MixOperation;e=f.reflectivity;F=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;G=f.refraction_ratio;c.uniform4f(A.uniforms.mColor,k.r*r,k.g*r,k.b*r,r);c.uniform1i(A.uniforms.mixEnvMap,m);c.uniform1f(A.uniforms.mReflectivity,e);c.uniform1i(A.uniforms.useRefract,
-F);c.uniform1f(A.uniforms.mRefractionRatio,G);if(l){c.uniform1f(A.uniforms.fogDensity,l.density);c.uniform3f(A.uniforms.fogColor,l.color.r,l.color.g,l.color.b)}}if(f instanceof THREE.MeshPhongMaterial){l=f.ambient;k=f.specular;f=f.shininess;c.uniform4f(A.uniforms.mAmbient,l.r,l.g,l.b,r);c.uniform4f(A.uniforms.mSpecular,k.r,k.g,k.b,r);c.uniform1f(A.uniforms.mShininess,f);c.uniform1i(A.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(A.uniforms.material,1);else f instanceof
-THREE.MeshBasicMaterial&&c.uniform1i(A.uniforms.material,0);if(w){d(w,0);c.uniform1i(A.uniforms.tMap,0);c.uniform1i(A.uniforms.enableMap,1)}else c.uniform1i(A.uniforms.enableMap,0);if(N){g(N,1);c.uniform1i(A.uniforms.tCube,1);c.uniform1i(A.uniforms.enableCubeMap,1)}else c.uniform1i(A.uniforms.enableCubeMap,0);r=A.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.position);if(r.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,
-n.__webGLNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.normal)}if(r.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(r.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.tangent)}if(r.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(r.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(r.uv)}else c.disableVertexAttribArray(r.uv);if(q){c.lineWidth(u);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
-n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,m,l,f,n,k,r){var q,u,w,N,G;w=0;for(N=f.material.length;w<N;w++){q=f.material[w];if(q instanceof THREE.MeshFaceMaterial){q=0;for(u=n.material.length;q<u;q++)if((G=n.material[q])&&G.blending==k&&G.opacity<1==r){this.setBlending(G.blending);this.renderBuffer(e,m,l,
-G,n)}}else if((G=q)&&G.blending==k&&G.opacity<1==r){this.setBlending(G.blending);this.renderBuffer(e,m,l,G,n)}}};this.render=function(e,m){var l,f,n,k,r=e.lights,q=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();K.set(m.matrix.flatten());M.set(m.projectionMatrix.flatten());l=0;for(f=e.__webGLObjects.length;l<f;l++){n=e.__webGLObjects[l];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,m);this.renderPass(m,r,q,k,n,THREE.NormalBlending,false)}}l=
-0;for(f=e.__webGLObjects.length;l<f;l++){n=e.__webGLObjects[l];k=n.object;n=n.buffer;if(k.visible){this.setupMatrices(k,m);this.renderPass(m,r,q,k,n,THREE.AdditiveBlending,false);this.renderPass(m,r,q,k,n,THREE.SubtractiveBlending,false);this.renderPass(m,r,q,k,n,THREE.AdditiveBlending,true);this.renderPass(m,r,q,k,n,THREE.SubtractiveBlending,true);this.renderPass(m,r,q,k,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,l,f,n,k,r;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap=
-{}}m=0;for(l=e.objects.length;m<l;m++){f=e.objects[m];if(e.__webGLObjectsMap[f.id]==undefined)e.__webGLObjectsMap[f.id]={};r=e.__webGLObjectsMap[f.id];if(f instanceof THREE.Mesh)for(k in f.geometry.geometryChunks){n=f.geometry.geometryChunks[k];n.__webGLVertexBuffer||this.createBuffers(f,k);if(r[k]==undefined){n={buffer:n,object:f};e.__webGLObjects.push(n);r[k]=1}}}};this.removeObject=function(e,m){var l,f;for(l=e.__webGLObjects.length-1;l>=0;l--){f=e.__webGLObjects[l].object;m==f&&e.__webGLObjects.splice(l,
-1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();y.multiply(m.matrix,e.matrix);P.set(y.flatten());x=THREE.Matrix4.makeInvert3x3(y).transpose();s.set(x.m);Q.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,K);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,P);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,s);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,Q)};
-this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
-else e=="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};var L={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
+"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );\n#endif\n}"].join("\n");
+g=b(n,g,k);c.useProgram(g);h(g,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract"]);k&&h(g,["fogColor","fogNear","fogFar"]);e&&h(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);m&&h(g,["pointLightNumber","pointLightColor",
+"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);j(g,["position","normal","uv"]);return g}(E.directional,E.point,fog);this.setSize=function(e,m){o.width=e;o.height=m;c.viewport(0,0,o.width,o.height)};this.setClearColor=function(e,m){var k=new THREE.Color(e);c.clearColor(k.r,k.g,k.b,m)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
+c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,m){var k,g,n,l,s,x=[],v=[],z=[];l=[];s=[];c.uniform1i(e.uniforms.enableLighting,m.length);k=0;for(g=m.length;k<g;k++){n=m[k];if(n instanceof THREE.AmbientLight)x.push(n);else if(n instanceof THREE.DirectionalLight)z.push(n);else n instanceof THREE.PointLight&&v.push(n)}k=n=l=s=0;for(g=x.length;k<g;k++){n+=x[k].color.r;l+=x[k].color.g;s+=x[k].color.b}c.uniform3f(e.uniforms.ambientLightColor,n,l,s);l=[];s=[];k=0;for(g=z.length;k<g;k++){n=z[k];l.push(n.color.r*
+n.intensity);l.push(n.color.g*n.intensity);l.push(n.color.b*n.intensity);s.push(n.position.x);s.push(n.position.y);s.push(n.position.z)}if(z.length){c.uniform1i(e.uniforms.directionalLightNumber,z.length);c.uniform3fv(e.uniforms.directionalLightDirection,s);c.uniform3fv(e.uniforms.directionalLightColor,l)}l=[];s=[];k=0;for(g=v.length;k<g;k++){n=v[k];l.push(n.color.r*n.intensity);l.push(n.color.g*n.intensity);l.push(n.color.b*n.intensity);s.push(n.position.x);s.push(n.position.y);s.push(n.position.z)}if(v.length){c.uniform1i(e.uniforms.pointLightNumber,
+v.length);c.uniform3fv(e.uniforms.pointLightPosition,s);c.uniform3fv(e.uniforms.pointLightColor,l)}};this.createBuffers=function(e,m){var k,g,n,l,s,x,v,z,V,t=[],L=[],C=[],H=[],R=[],U=[],y=0,A=e.geometry.geometryChunks[m],P;n=false;k=0;for(g=e.materials.length;k<g;k++){meshMaterial=e.materials[k];if(meshMaterial instanceof THREE.MeshFaceMaterial){s=0;for(P=A.materials.length;s<P;s++)if(A.materials[s]&&A.materials[s].shading!=undefined&&A.materials[s].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&
+meshMaterial.shading!=undefined&&meshMaterial.shading==THREE.SmoothShading){n=true;break}if(n)break}P=n;k=0;for(g=A.faces.length;k<g;k++){n=A.faces[k];l=e.geometry.faces[n];s=l.vertexNormals;faceNormal=l.normal;n=e.geometry.uvs[n];if(l instanceof THREE.Face3){x=e.geometry.vertices[l.a].position;v=e.geometry.vertices[l.b].position;z=e.geometry.vertices[l.c].position;C.push(x.x,x.y,x.z);C.push(v.x,v.y,v.z);C.push(z.x,z.y,z.z);if(e.geometry.hasTangents){x=e.geometry.vertices[l.a].tangent;v=e.geometry.vertices[l.b].tangent;
+z=e.geometry.vertices[l.c].tangent;R.push(x.x,x.y,x.z,x.w);R.push(v.x,v.y,v.z,v.w);R.push(z.x,z.y,z.z,z.w)}if(s.length==3&&P)for(l=0;l<3;l++)H.push(s[l].x,s[l].y,s[l].z);else for(l=0;l<3;l++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(l=0;l<3;l++)U.push(n[l].u,n[l].v);t.push(y,y+1,y+2);L.push(y,y+1);L.push(y,y+2);L.push(y+1,y+2);y+=3}else if(l instanceof THREE.Face4){x=e.geometry.vertices[l.a].position;v=e.geometry.vertices[l.b].position;z=e.geometry.vertices[l.c].position;V=e.geometry.vertices[l.d].position;
+C.push(x.x,x.y,x.z);C.push(v.x,v.y,v.z);C.push(z.x,z.y,z.z);C.push(V.x,V.y,V.z);if(e.geometry.hasTangents){x=e.geometry.vertices[l.a].tangent;v=e.geometry.vertices[l.b].tangent;z=e.geometry.vertices[l.c].tangent;l=e.geometry.vertices[l.d].tangent;R.push(x.x,x.y,x.z,x.w);R.push(v.x,v.y,v.z,v.w);R.push(z.x,z.y,z.z,z.w);R.push(l.x,l.y,l.z,l.w)}if(s.length==4&&P)for(l=0;l<4;l++)H.push(s[l].x,s[l].y,s[l].z);else for(l=0;l<4;l++)H.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(l=0;l<4;l++)U.push(n[l].u,
+n[l].v);t.push(y,y+1,y+2);t.push(y,y+2,y+3);L.push(y,y+1);L.push(y,y+2);L.push(y,y+3);L.push(y+1,y+2);L.push(y+2,y+3);y+=4}}if(C.length){A.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);A.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(H),c.STATIC_DRAW);if(e.geometry.hasTangents){A.__webGLTangentBuffer=c.createBuffer();
+c.bindBuffer(c.ARRAY_BUFFER,A.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(R),c.STATIC_DRAW)}if(U.length>0){A.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,A.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}A.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);A.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+A.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(L),c.STATIC_DRAW);A.__webGLFaceCount=t.length;A.__webGLLineCount=L.length}};this.renderBuffer=function(e,m,k,g,n){var l,s,x,v,z,V,t,L,C;if(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshDepthMaterial||g instanceof THREE.MeshNormalMaterial){if(!g.program){if(g instanceof THREE.MeshDepthMaterial){t=J.depth;g.fragment_shader=t.fragment_shader;g.vertex_shader=t.vertex_shader;g.uniforms=t.uniforms;g.uniforms.mNear.value=
+e.near;g.uniforms.mFar.value=e.far}else if(g instanceof THREE.MeshNormalMaterial){t=J.normal;g.fragment_shader=t.fragment_shader;g.vertex_shader=t.vertex_shader;g.uniforms=t.uniforms}g.program=b(g.fragment_shader,g.vertex_shader,null);t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(C in g.uniforms)t.push(C);h(g.program,t);j(g.program,["position","normal","uv","tangent"])}C=g.program}else C=F;if(C!=D){c.useProgram(C);D=C}C==F&&this.setupLights(C,
+m);this.loadCamera(C,e);this.loadMatrices(C);if(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshDepthMaterial||g instanceof THREE.MeshNormalMaterial){x=g.wireframe;v=g.wireframe_linewidth;e=C;m=g.uniforms;var H;for(l in m){L=m[l].type;t=m[l].value;H=e.uniforms[l];if(L=="i")c.uniform1i(H,t);else if(L=="f")c.uniform1f(H,t);else if(L=="v3")c.uniform3f(H,t.x,t.y,t.z);else if(L=="c")c.uniform3f(H,t.r,t.g,t.b);else if(L=="t"){c.uniform1i(H,t);if(L=m[l].texture)L.image instanceof Array&&L.image.length==
+6?f(L,t):d(L,t)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){l=g.color;s=g.opacity;x=g.wireframe;v=g.wireframe_linewidth;z=g.map;V=g.env_map;m=g.combine==THREE.MixOperation;e=g.reflectivity;L=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;t=g.refraction_ratio;c.uniform4f(C.uniforms.mColor,l.r*s,l.g*s,l.b*s,s);c.uniform1i(C.uniforms.mixEnvMap,m);c.uniform1f(C.uniforms.mReflectivity,e);c.uniform1i(C.uniforms.useRefract,
+L);c.uniform1f(C.uniforms.mRefractionRatio,t);if(k){c.uniform1f(C.uniforms.fogNear,k.near);c.uniform1f(C.uniforms.fogFar,k.far);c.uniform3f(C.uniforms.fogColor,k.color.r,k.color.g,k.color.b)}}if(g instanceof THREE.MeshPhongMaterial){k=g.ambient;l=g.specular;g=g.shininess;c.uniform4f(C.uniforms.mAmbient,k.r,k.g,k.b,s);c.uniform4f(C.uniforms.mSpecular,l.r,l.g,l.b,s);c.uniform1f(C.uniforms.mShininess,g);c.uniform1i(C.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(C.uniforms.material,
+1);else g instanceof THREE.MeshBasicMaterial&&c.uniform1i(C.uniforms.material,0);if(z){d(z,0);c.uniform1i(C.uniforms.tMap,0);c.uniform1i(C.uniforms.enableMap,1)}else c.uniform1i(C.uniforms.enableMap,0);if(V){f(V,1);c.uniform1i(C.uniforms.tCube,1);c.uniform1i(C.uniforms.enableCubeMap,1)}else c.uniform1i(C.uniforms.enableCubeMap,0);s=C.attributes;c.bindBuffer(c.ARRAY_BUFFER,n.__webGLVertexBuffer);c.vertexAttribPointer(s.position,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(s.position);if(s.normal>=
+0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer);c.vertexAttribPointer(s.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(s.normal)}if(s.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(s.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(s.tangent)}if(s.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(s.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(s.uv)}else c.disableVertexAttribArray(s.uv);if(x){c.lineWidth(v);
+c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(c.LINES,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(e,m,k,g,n,l,s){var x,v,z,V,t;z=0;for(V=g.materials.length;z<V;z++){x=g.materials[z];if(x instanceof THREE.MeshFaceMaterial){x=0;for(v=n.materials.length;x<v;x++)if((t=n.materials[x])&&t.blending==l&&t.opacity<1==s){this.setBlending(t.blending);
+this.renderBuffer(e,m,k,t,n)}}else if((t=x)&&t.blending==l&&t.opacity<1==s){this.setBlending(t.blending);this.renderBuffer(e,m,k,t,n)}}};this.render=function(e,m){var k,g,n,l,s=e.lights,x=e.fog;this.initWebGLObjects(e);this.autoClear&&this.clear();m.autoUpdateMatrix&&m.updateMatrix();I.set(m.matrix.flatten());O.set(m.projectionMatrix.flatten());k=0;for(g=e.__webGLObjects.length;k<g;k++){n=e.__webGLObjects[k];l=n.object;n=n.buffer;if(l.visible){this.setupMatrices(l,m);this.renderPass(m,s,x,l,n,THREE.NormalBlending,
+false)}}k=0;for(g=e.__webGLObjects.length;k<g;k++){n=e.__webGLObjects[k];l=n.object;n=n.buffer;if(l.visible){this.setupMatrices(l,m);this.renderPass(m,s,x,l,n,THREE.AdditiveBlending,false);this.renderPass(m,s,x,l,n,THREE.SubtractiveBlending,false);this.renderPass(m,s,x,l,n,THREE.AdditiveBlending,true);this.renderPass(m,s,x,l,n,THREE.SubtractiveBlending,true);this.renderPass(m,s,x,l,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(e){var m,k,g,n,l,s;if(!e.__webGLObjects){e.__webGLObjects=
+[];e.__webGLObjectsMap={}}m=0;for(k=e.objects.length;m<k;m++){g=e.objects[m];if(e.__webGLObjectsMap[g.id]==undefined)e.__webGLObjectsMap[g.id]={};s=e.__webGLObjectsMap[g.id];if(g instanceof THREE.Mesh)for(l in g.geometry.geometryChunks){n=g.geometry.geometryChunks[l];n.__webGLVertexBuffer||this.createBuffers(g,l);if(s[l]==undefined){n={buffer:n,object:g};e.__webGLObjects.push(n);s[l]=1}}}};this.removeObject=function(e,m){var k,g;for(k=e.__webGLObjects.length-1;k>=0;k--){g=e.__webGLObjects[k].object;
+m==g&&e.__webGLObjects.splice(k,1)}};this.setupMatrices=function(e,m){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(m.matrix,e.matrix);Q.set(w.flatten());u=THREE.Matrix4.makeInvert3x3(w).transpose();r.set(u.m);S.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,I);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,Q);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,O);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,r);c.uniformMatrix4fv(e.uniforms.objectMatrix,
+false,S)};this.loadCamera=function(e,m){c.uniform3f(e.uniforms.cameraPosition,m.position.x,m.position.y,m.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(e,m){if(e){!m||m=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);
+else e=="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};var J={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3}},fragment_shader:"uniform float mNear;\nuniform float mFar;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), 1.0 );\n}",
 vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
 vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{},fragment_shader:"varying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );\n}",vertex_shader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"}}};
-THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};
-THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null};
+THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]};
+THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};

文件差异内容过多而无法显示
+ 146 - 142
build/ThreeExtras.js


+ 1 - 1
examples/camera_orthographic.html

@@ -41,7 +41,7 @@
 				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - orthographic view';
 				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - orthographic view';
 				container.appendChild( info );
 				container.appendChild( info );
 
 
-				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera = new THREE.Camera( 45, window.innerWidth / window.innerHeight, - 2000, 1000 );
 				camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 1000 );
 				camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, - 2000, 1000 );
 				camera.position.x = 200;
 				camera.position.x = 200;
 				camera.position.y = 100;
 				camera.position.y = 100;

+ 1 - 1
examples/geometry_birds.html

@@ -407,7 +407,7 @@
 
 
 					bird = birds[ i ];
 					bird = birds[ i ];
 
 
-					color = bird.material[0].color;
+					color = bird.materials[ 0 ].color;
 					color.r = color.g = color.b = ( 500 - bird.position.z ) / 1000;
 					color.r = color.g = color.b = ( 500 - bird.position.z ) / 1000;
 					color.updateStyleString();
 					color.updateStyleString();
 
 

+ 1 - 1
examples/geometry_cube.html

@@ -54,7 +54,7 @@
 				info.innerHTML = 'Drag to spin the cube';
 				info.innerHTML = 'Drag to spin the cube';
 				container.appendChild( info );
 				container.appendChild( info );
 
 
-				camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
 				camera.position.y = 150;
 				camera.position.y = 150;
 				camera.position.z = 500;
 				camera.position.z = 500;
 				camera.target.position.y = 150;
 				camera.target.position.y = 150;

+ 3 - 3
examples/geometry_minecraft_ao.html

@@ -110,15 +110,15 @@
 
 
 				container = document.getElementById( 'container' );
 				container = document.getElementById( 'container' );
 
 
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 20000 );
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 7500 );
 				camera.target.position.z = - 100;
 				camera.target.position.z = - 100;
 
 
 				camera.position.y = getY( worldHalfWidth, worldHalfDepth ) * 100 + 100;
 				camera.position.y = getY( worldHalfWidth, worldHalfDepth ) * 100 + 100;
 				camera.target.position.y = camera.position.y;
 				camera.target.position.y = camera.position.y;
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
-				scene.fog = new THREE.Fog( 0xffffff, 0.00025 );
-				
+				scene.fog = new THREE.Fog( 0xffffff, 1, 7500 );
+
 				var debug_texture = false,
 				var debug_texture = false,
 					debug_numbers = false,
 					debug_numbers = false,
 					debug_corner_colors = false,
 					debug_corner_colors = false,

+ 2 - 2
examples/geometry_terrain_fog_gl.html

@@ -69,11 +69,11 @@
 
 
 				container = document.getElementById( 'container' );
 				container = document.getElementById( 'container' );
 
 
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 20000 );
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 750 );
 				camera.target.position.z = - 100;
 				camera.target.position.z = - 100;
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
-				scene.fog = new THREE.Fog( 0xefd1b5, 0.0025 );
+				scene.fog = new THREE.Fog( 0xefd1b5, 1, 750 );
 
 
 				data = generateHeight( worldWidth, worldDepth );
 				data = generateHeight( worldWidth, worldDepth );
 
 

+ 1 - 1
examples/interactive_cubes.html

@@ -93,7 +93,7 @@
 
 
 				if ( intersects.length > 0 ) {
 				if ( intersects.length > 0 ) {
 
 
-					intersects[ 0 ].object.material[ 0 ].color.setHex( Math.random() * 0xffffff | 0x80000000 );
+					intersects[ 0 ].object.materials[ 0 ].color.setHex( Math.random() * 0xffffff );
 
 
 					var particle = new THREE.Particle( new THREE.ParticleCircleMaterial( { color: 0x000000 } ) );
 					var particle = new THREE.Particle( new THREE.ParticleCircleMaterial( { color: 0x000000 } ) );
 					particle.position = intersects[ 0 ].point;
 					particle.position = intersects[ 0 ].point;

+ 3 - 3
examples/interactive_voxelpainter.html

@@ -205,14 +205,14 @@
 
 
 					if ( intersects[ 0 ].face != rollOveredFace ) {
 					if ( intersects[ 0 ].face != rollOveredFace ) {
 
 
-						if ( rollOveredFace ) rollOveredFace.material = [];
+						if ( rollOveredFace ) rollOveredFace.materials = [];
 						rollOveredFace = intersects[ 0 ].face;
 						rollOveredFace = intersects[ 0 ].face;
-						rollOveredFace.material = [ new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5 } ) ];
+						rollOveredFace.materials = [ new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5 } ) ];
 					}
 					}
 
 
 				} else if ( rollOveredFace ) {
 				} else if ( rollOveredFace ) {
 
 
-					 rollOveredFace.material = [];
+					 rollOveredFace.materials = [];
 					 rollOveredFace = null;
 					 rollOveredFace = null;
 
 
 				}
 				}

+ 14 - 12
examples/materials.html

@@ -29,6 +29,7 @@
 			var particleLight, pointLight;
 			var particleLight, pointLight;
 
 
 			init();
 			init();
+			// loop();
 			setInterval( loop, 1000 / 60 );
 			setInterval( loop, 1000 / 60 );
 
 
 			function init() {
 			function init() {
@@ -69,18 +70,19 @@
 
 
 				var geometry = new Sphere( 100, 14, 7, false );
 				var geometry = new Sphere( 100, 14, 7, false );
 
 
-				var materials = [];
-				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true } );
-				//materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ), overdraw: false, doubleSided: true } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
-				// materials.push( { material: new THREE.MeshPhongMaterial( { ambient: 0x030383, color: 0xf55555, specular: 0x66f6f6, shininess: 10, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
-				materials.push( { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false } );
-				materials.push( { material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } );
+				var materials = [
+
+					{ material: new THREE.MeshBasicMaterial( { color: 0x00ffff, wireframe: true } ), overdraw: false, doubleSided: true },
+					{ material: new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.AdditiveBlending } ), overdraw: false, doubleSided: true },
+					{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false },
+					{ material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
+					{ material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false },
+					{ material: new THREE.MeshBasicMaterial( { env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false }
+
+				];
 
 
 				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
 				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
 
 

+ 1 - 1
examples/materials_depth.html

@@ -73,7 +73,7 @@
 
 
 				// Plane
 				// Plane
 
 
-				var material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } );
+				var material = new THREE.MeshDepthMaterial();
 
 
 				plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
 				plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material );
 				plane.rotation.x = - 90 * ( Math.PI / 180 );
 				plane.rotation.x = - 90 * ( Math.PI / 180 );

+ 2 - 2
examples/materials_gl.html

@@ -16,7 +16,7 @@
 	<body>
 	<body>
 
 
 		<pre id="log"></pre>
 		<pre id="log"></pre>
-		
+
 		<script type="text/javascript" src="../build/ThreeExtras.js"></script>
 		<script type="text/javascript" src="../build/ThreeExtras.js"></script>
 
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -78,7 +78,7 @@
 				materials.push( { material: new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ), overdraw: false, doubleSided: true } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ), overdraw: false, doubleSided: true } );
 
 
-				materials.push( { material: new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ), overdraw: true, doubleSided: false } );
+				materials.push( { material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshBasicMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshLambertMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 				materials.push( { material: new THREE.MeshLambertMaterial( { map: generatedTexture } ), overdraw: true, doubleSided: false } );
 
 

+ 233 - 0
examples/materials_normalmap2.html

@@ -0,0 +1,233 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js - webgl normal map</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				background:#000;
+				color:#fff;
+				padding:0;
+				margin:0;
+				font-weight: bold;
+				overflow:hidden;
+			}
+
+			a {	color: #ffffff;	}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				color: #ffffff;
+				padding: 5px;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+				z-index:1000;
+			}
+
+			#oldie {
+				font-family:monospace;
+				font-size:13px;
+
+				text-align:center;
+				background:rgb(200,100,0);
+				color:#fff;
+				padding:1em;
+
+				width:475px;
+				margin:5em auto 0;
+
+				border:solid 2px #fff;
+				border-radius:10px;
+
+				display:none;
+			}
+
+			#vt { display:none }
+			#vt, #vt a { color:orange; }
+			.code { }
+
+			#log { position:absolute; top:50px; text-align:left; display:block; z-index:100 }
+		</style>
+	</head>
+
+	<body>
+		<pre id="log"></pre>
+
+		<div id="info">
+			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl normalmap demo.
+			<a href="http://www.ir-ltd.net/infinite-3d-head-scan-released/" target="_blank">Lee Perry-Smith</a> head.
+
+			<div id="vt">displacement mapping needs vertex textures (GPU with Shader Model 3.0)<br/>
+			on Windows use <span class="code">Chrome --use-gl=desktop</span> or Firefox 4<br/>
+			please star this <a href="http://code.google.com/p/chromium/issues/detail?id=52497">Chrome issue</a> to get ANGLE support
+			</div>
+		</div>
+
+		<center>
+		<div id="oldie">
+			Sorry, your browser doesn't support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation">WebGL</a>
+			and <a href="http://www.whatwg.org/specs/web-workers/current-work/">Web Workers</a>.<br/>
+			<br/>
+			Please try in
+			<a href="http://www.chromium.org/getting-involved/dev-channel">Chrome 9+</a> /
+			<a href="http://www.mozilla.com/en-US/firefox/all-beta.html">Firefox 4+</a> /
+			<a href="http://nightly.webkit.org/">Safari OSX 10.6+</a>
+		</div>
+		</center>
+
+		<script type="text/javascript" src="../build/ThreeExtras.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			if ( !is_browser_compatible() ) {
+
+				document.getElementById( "oldie" ).style.display = "block";
+
+			}
+
+			var statsEnabled = true;
+
+			var container, stats, loader;
+
+			var camera, scene, webglRenderer;
+
+			var mesh, zmesh, lightMesh, geometry;
+			var mesh1;
+
+			var directionalLight, pointLight, ambientLight;
+
+			var mouseX = 0;
+			var mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			var r = 0.0;
+
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			init();
+			setInterval( loop, 1000 / 60 );
+
+			function init() {
+
+				container = document.createElement('div');
+				document.body.appendChild(container);
+
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera.position.z = 800;
+
+				scene = new THREE.Scene();
+
+				// LIGHTS
+
+				ambientLight = new THREE.AmbientLight( 0x222233 );
+				scene.addLight( ambientLight );
+
+				pointLight = new THREE.PointLight( 0xffffAA, 0.5 );
+				pointLight.position.z = 10000;
+				scene.addLight( pointLight );
+
+				directionalLight = new THREE.DirectionalLight( 0xffff88 );
+				directionalLight.position.x = 1;
+				directionalLight.position.y = 1;
+				directionalLight.position.z = 0.5;
+				directionalLight.position.normalize();
+				scene.addLight( directionalLight );
+
+				// light representation
+
+				var sphere = new Sphere( 100, 16, 8, 1 );
+				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) );
+				lightMesh.position = pointLight.position;
+				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
+				scene.addObject(lightMesh);
+
+				var material = new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" ) } );
+
+				loader = new THREE.Loader( true );
+				document.body.appendChild( loader.statusDomElement );
+
+				loader.loadAscii( "obj/leeperrysmith/LeePerrySmith.js", function( geometry ) { createScene( geometry, 100, material ) }, "obj/leeperrysmith" );
+
+				webglRenderer = new THREE.WebGLRenderer( scene );
+				webglRenderer.setSize( window.innerWidth, window.innerHeight );
+				container.appendChild( webglRenderer.domElement );
+
+				if ( statsEnabled ) {
+
+					stats = new Stats();
+					stats.domElement.style.position = 'absolute';
+					stats.domElement.style.top = '0px';
+					stats.domElement.style.zIndex = 100;
+					container.appendChild( stats.domElement );
+
+				}
+
+			}
+
+			function createScene( geometry, scale, material ) {
+
+				geometry.computeTangents();
+
+				mesh1 = SceneUtils.addMesh( scene, geometry, scale, 0, - 50, 0, 0, 0, 0, material );
+
+				loader.statusDomElement.style.display = "none";
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX ) * 10;
+				mouseY = ( event.clientY - windowHalfY ) * 10;
+
+			}
+
+			function loop() {
+
+				var ry = mouseX * 0.0003, rx = mouseY * 0.0003;
+
+				if( mesh1 ) {
+
+					mesh1.rotation.y = ry;
+					mesh1.rotation.x = rx;
+
+				}
+
+				lightMesh.position.x = 2500 * Math.cos( r );
+				lightMesh.position.z = 2500 * Math.sin( r );
+
+				r += 0.01;
+
+				webglRenderer.render( scene, camera );
+
+				if ( statsEnabled ) stats.update();
+
+			}
+
+			function log( text ) {
+
+				var e = document.getElementById("log");
+				e.innerHTML = text + "<br/>" + e.innerHTML;
+
+			}
+
+			function is_browser_compatible() {
+
+				// WebGL support
+
+				try { var test = new Float32Array(1); } catch(e) { return false; }
+
+				// Web workers
+
+				return !!window.Worker;
+
+			}
+
+		</script>
+
+	</body>
+</html>

二进制
examples/obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg


文件差异内容过多而无法显示
+ 24 - 0
examples/obj/leeperrysmith/LeePerrySmith.js


二进制
examples/obj/leeperrysmith/Map-COL.jpg


+ 43 - 14
examples/webglrenderer2_sandbox.html

@@ -96,6 +96,7 @@
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 
 
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
 		<script type="text/javascript" src="../src/extras/primitives/Sphere.js"></script>
+		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
 		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
 
 
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -127,49 +128,74 @@
 				container = document.createElement( 'div' );
 				container = document.createElement( 'div' );
 				document.body.appendChild( container );
 				document.body.appendChild( container );
 
 
-				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 100000 );
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
 				camera.position.z = 3200;
 				camera.position.z = 3200;
 
 
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
-				scene.fog = new THREE.Fog( 0xffffff, 0.00025 );
+				scene.fog = new THREE.Fog( 0xffffff, 1, 10000 );
 
 
-				var geometry = new Sphere( 100, 32, 16 );
+				var geometry = new Sphere( 50, 32, 16 );
 
 
 				var uniforms = ShaderUtils.lib[ 'basic' ].uniforms;
 				var uniforms = ShaderUtils.lib[ 'basic' ].uniforms;
 				var vertex_shader = ShaderUtils.lib[ 'basic' ].vertex_shader;
 				var vertex_shader = ShaderUtils.lib[ 'basic' ].vertex_shader;
 				var fragment_shader = ShaderUtils.lib[ 'basic' ].fragment_shader;
 				var fragment_shader = ShaderUtils.lib[ 'basic' ].fragment_shader;
 
 
-				var generatedTexture = new THREE.Texture( generateTexture() );
+				var texture = new THREE.Texture( generateTexture( 0, 0.5, 1 ), new THREE.UVMapping() );
+				var texture2 = new THREE.Texture( generateTexture( 0, 1, 0 ), new THREE.SphericalReflectionMapping() );
 
 
 				var materials = [
 				var materials = [
 
 
+					new THREE.MeshNormalMaterial(),
+					new THREE.MeshDepthMaterial(),
+					new THREE.MeshBasicMaterial( { color: 0x0066ff, blending: THREE.AdditiveBlending } ),
+					new THREE.MeshBasicMaterial( { map: texture, fog: false } ),
+					new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
+					new THREE.MeshBasicMaterial( { map: texture2, env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ),
+					new THREE.MeshShaderMaterial( { uniforms: uniforms, vertex_shader: vertex_shader, fragment_shader: fragment_shader } )
+
+					/*
 					new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.FlatShading } ),
 					new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.FlatShading } ),
 					new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.FlatShading } ),
 					new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.FlatShading } ),
-					new THREE.MeshNormalMaterial(),
-					new THREE.MeshBasicMaterial( { color: 0x665500, blending: THREE.AdditiveBlending } ),
 					new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ),
 					new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ),
 					new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading } ),
 					new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.SmoothShading } ),
 					new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ),
 					new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ),
 					new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ),
 					new THREE.MeshBasicMaterial( { color: 0xffaa00, wireframe: true } ),
-					new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ),
-					new THREE.MeshBasicMaterial( { map: generatedTexture } ),
-					new THREE.MeshLambertMaterial( { map: generatedTexture } ),
+					new THREE.MeshBasicMaterial( { map: texture, fog: false } ),
+					new THREE.MeshBasicMaterial( { env_map: texture2, fog: false } ),
+					new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
+					new THREE.MeshLambertMaterial( { map: texture2, env_map: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ),
 					new THREE.MeshShaderMaterial( { uniforms: uniforms, vertex_shader: vertex_shader, fragment_shader: fragment_shader } )
 					new THREE.MeshShaderMaterial( { uniforms: uniforms, vertex_shader: vertex_shader, fragment_shader: fragment_shader } )
+					*/
 
 
 				];
 				];
 
 
-				for ( var i = 0; i < 1000; i ++ ) {
+				for ( var i = 0, l = geometry.faces.length; i < l; i ++ ) {
+
+					var face = geometry.faces[ i ];
+					if ( Math.random() > 0.5 ) face.material = [ materials[ Math.floor( Math.random() * materials.length ) ] ];
+
+				}
+
+				materials.push( new THREE.MeshFaceMaterial() );
+
+				// materials = [ new THREE.MeshBasicMaterial( { map: texture, env_map: texture2 } ) ];
+
+				for ( var i = 0; i < 5000; i ++ ) {
 
 
 					var mesh = new THREE.Mesh( geometry, materials[ Math.floor( Math.random() * materials.length ) ] );
 					var mesh = new THREE.Mesh( geometry, materials[ Math.floor( Math.random() * materials.length ) ] );
 					mesh.position.x = Math.random() * 10000 - 5000;
 					mesh.position.x = Math.random() * 10000 - 5000;
 					mesh.position.y = Math.random() * 10000 - 5000;
 					mesh.position.y = Math.random() * 10000 - 5000;
 					mesh.position.z = Math.random() * 10000 - 5000;
 					mesh.position.z = Math.random() * 10000 - 5000;
+					mesh.rotation.x = Math.random() * 360 * ( Math.PI / 180 );
+					mesh.rotation.y = Math.random() * 360 * ( Math.PI / 180 );
 					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 4 + 1;
 					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 4 + 1;
+					mesh.updateMatrix();
+					mesh.autoUpdateMatrix = false;
 					scene.addObject( mesh );
 					scene.addObject( mesh );
 
 
 				}
 				}
 
 
-				renderer = new THREE.WebGLRenderer2();
+				renderer = new THREE.WebGLRenderer2( false );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				// renderer.sortObjects = false;
 				// renderer.sortObjects = false;
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
@@ -186,7 +212,7 @@
 
 
 			}
 			}
 
 
-			function generateTexture() {
+			function generateTexture( r, g, b ) {
 
 
 				var canvas = document.createElement( 'canvas' );
 				var canvas = document.createElement( 'canvas' );
 				canvas.loaded = true;
 				canvas.loaded = true;
@@ -196,14 +222,17 @@
 				var context = canvas.getContext( '2d' );
 				var context = canvas.getContext( '2d' );
 				var image = context.getImageData( 0, 0, 256, 256 );
 				var image = context.getImageData( 0, 0, 256, 256 );
 
 
-				var x = 0, y = 0;
+				var x = 0, y = 0, p;
 
 
 				for ( var i = 0, j = 0, l = image.data.length; i < l; i += 4, j ++ ) {
 				for ( var i = 0, j = 0, l = image.data.length; i < l; i += 4, j ++ ) {
 
 
 					x = j % 256;
 					x = j % 256;
 					y = x == 0 ? y + 1 : y;
 					y = x == 0 ? y + 1 : y;
+					p = Math.floor( x ^ y );
 
 
-					image.data[ i + 2 ] = Math.floor( x ^ y );
+					image.data[ i ] = ~~ p * r;
+					image.data[ i + 1 ] = ~~ p * g;
+					image.data[ i + 2 ] = ~~ p * b;
 					image.data[ i + 3 ] = 255;
 					image.data[ i + 3 ] = 255;
 
 
 				}
 				}

+ 14 - 1
src/cameras/Camera.js

@@ -4,13 +4,18 @@
 
 
 THREE.Camera = function ( fov, aspect, near, far ) {
 THREE.Camera = function ( fov, aspect, near, far ) {
 
 
+	this.fov = fov;
+	this.aspect = aspect;
+	this.near = near;
+	this.far = far;
+
 	this.position = new THREE.Vector3();
 	this.position = new THREE.Vector3();
 	this.target = { position: new THREE.Vector3() };
 	this.target = { position: new THREE.Vector3() };
 
 
 	this.up = new THREE.Vector3( 0, 1, 0 );
 	this.up = new THREE.Vector3( 0, 1, 0 );
 
 
 	this.matrix = new THREE.Matrix4();
 	this.matrix = new THREE.Matrix4();
-	this.projectionMatrix = THREE.Matrix4.makePerspective( fov, aspect, near, far );
+	this.projectionMatrix = null;
 
 
 	this.autoUpdateMatrix = true;
 	this.autoUpdateMatrix = true;
 
 
@@ -45,6 +50,14 @@ THREE.Camera = function ( fov, aspect, near, far ) {
 
 
 	};
 	};
 
 
+	this.updateProjectionMatrix = function () {
+
+		this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far );
+
+	};
+
+	this.updateProjectionMatrix();
+
 	this.toString = function () {
 	this.toString = function () {
 
 
 		return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';
 		return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )';

+ 3 - 3
src/core/Face3.js

@@ -2,7 +2,7 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Face3 = function ( a, b, c, normal, material ) {
+THREE.Face3 = function ( a, b, c, normal, materials ) {
 
 
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
@@ -12,7 +12,7 @@ THREE.Face3 = function ( a, b, c, normal, material ) {
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
 	this.vertexNormals = normal instanceof Array ? normal : [];
 	this.vertexNormals = normal instanceof Array ? normal : [];
 
 
-	this.material = material instanceof Array ? material : [ material ];
+	this.materials = materials instanceof Array ? materials : [ materials ];
 
 
 };
 };
 
 
@@ -24,4 +24,4 @@ THREE.Face3.prototype = {
 
 
 	}
 	}
 
 
-}
+};

+ 3 - 3
src/core/Face4.js

@@ -2,7 +2,7 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Face4 = function ( a, b, c, d, normal, material ) {
+THREE.Face4 = function ( a, b, c, d, normal, materials ) {
 
 
 	this.a = a;
 	this.a = a;
 	this.b = b;
 	this.b = b;
@@ -13,7 +13,7 @@ THREE.Face4 = function ( a, b, c, d, normal, material ) {
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
 	this.vertexNormals = normal instanceof Array ? normal : [];
 	this.vertexNormals = normal instanceof Array ? normal : [];
 
 
-	this.material = material instanceof Array ? material : [ material ];
+	this.materials = materials instanceof Array ? materials : [ materials ];
 
 
 };
 };
 
 
@@ -26,4 +26,4 @@ THREE.Face4.prototype = {
 
 
 	}
 	}
 
 
-}
+};

+ 17 - 17
src/core/Geometry.js

@@ -293,7 +293,7 @@ THREE.Geometry.prototype = {
 
 
 		if ( this.vertices.length > 0 ) {
 		if ( this.vertices.length > 0 ) {
 
 
-			this.bbox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
+			this.boundingBox = { 'x': [ this.vertices[ 0 ].position.x, this.vertices[ 0 ].position.x ],
 			'y': [ this.vertices[ 0 ].position.y, this.vertices[ 0 ].position.y ],
 			'y': [ this.vertices[ 0 ].position.y, this.vertices[ 0 ].position.y ],
 			'z': [ this.vertices[ 0 ].position.z, this.vertices[ 0 ].position.z ] };
 			'z': [ this.vertices[ 0 ].position.z, this.vertices[ 0 ].position.z ] };
 
 
@@ -301,33 +301,33 @@ THREE.Geometry.prototype = {
 
 
 				vertex = this.vertices[ v ];
 				vertex = this.vertices[ v ];
 
 
-				if ( vertex.position.x < this.bbox.x[ 0 ] ) {
+				if ( vertex.position.x < this.boundingBox.x[ 0 ] ) {
 
 
-					this.bbox.x[ 0 ] = vertex.position.x;
+					this.boundingBox.x[ 0 ] = vertex.position.x;
 
 
-				} else if ( vertex.position.x > this.bbox.x[ 1 ] ) {
+				} else if ( vertex.position.x > this.boundingBox.x[ 1 ] ) {
 
 
-					this.bbox.x[ 1 ] = vertex.position.x;
+					this.boundingBox.x[ 1 ] = vertex.position.x;
 
 
 				}
 				}
 
 
-				if ( vertex.position.y < this.bbox.y[ 0 ] ) {
+				if ( vertex.position.y < this.boundingBox.y[ 0 ] ) {
 
 
-					this.bbox.y[ 0 ] = vertex.position.y;
+					this.boundingBox.y[ 0 ] = vertex.position.y;
 
 
-				} else if ( vertex.position.y > this.bbox.y[ 1 ] ) {
+				} else if ( vertex.position.y > this.boundingBox.y[ 1 ] ) {
 
 
-					this.bbox.y[ 1 ] = vertex.position.y;
+					this.boundingBox.y[ 1 ] = vertex.position.y;
 
 
 				}
 				}
 
 
-				if ( vertex.position.z < this.bbox.z[ 0 ] ) {
+				if ( vertex.position.z < this.boundingBox.z[ 0 ] ) {
 
 
-					this.bbox.z[ 0 ] = vertex.position.z;
+					this.boundingBox.z[ 0 ] = vertex.position.z;
 
 
-				} else if ( vertex.position.z > this.bbox.z[ 1 ] ) {
+				} else if ( vertex.position.z > this.boundingBox.z[ 1 ] ) {
 
 
-					this.bbox.z[ 1 ] = vertex.position.z;
+					this.boundingBox.z[ 1 ] = vertex.position.z;
 
 
 				}
 				}
 
 
@@ -385,9 +385,9 @@ THREE.Geometry.prototype = {
 		for ( f = 0, fl = this.faces.length; f < fl; f++ ) {
 		for ( f = 0, fl = this.faces.length; f < fl; f++ ) {
 
 
 			face = this.faces[ f ];
 			face = this.faces[ f ];
-			material = face.material;
+			materials = face.materials;
 
 
-			mhash = materialHash( material );
+			mhash = materialHash( materials );
 
 
 			if ( hash_map[ mhash ] == undefined ) {
 			if ( hash_map[ mhash ] == undefined ) {
 
 
@@ -399,7 +399,7 @@ THREE.Geometry.prototype = {
 
 
 			if ( this.geometryChunks[ ghash ] == undefined ) {
 			if ( this.geometryChunks[ ghash ] == undefined ) {
 
 
-				this.geometryChunks[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
+				this.geometryChunks[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
 
 
 			}
 			}
 
 
@@ -412,7 +412,7 @@ THREE.Geometry.prototype = {
 
 
 				if ( this.geometryChunks[ ghash ] == undefined ) {
 				if ( this.geometryChunks[ ghash ] == undefined ) {
 
 
-					this.geometryChunks[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 };
+					this.geometryChunks[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
 
 
 				}
 				}
 
 

+ 1 - 1
src/core/Vertex.js

@@ -13,7 +13,7 @@ THREE.Vertex = function ( position, normal ) {
 	this.normalScreen = new THREE.Vector3();
 	this.normalScreen = new THREE.Vector3();
 
 
 	this.tangent = new THREE.Vector4();
 	this.tangent = new THREE.Vector4();
-	
+
 	this.__visible = true;
 	this.__visible = true;
 
 
 }
 }

+ 1 - 1
src/extras/GeometryUtils.js

@@ -53,7 +53,7 @@ var GeometryUtils = {
 
 
 			}
 			}
 
 
-			faceCopy.material = face.material.slice();
+			faceCopy.materials = face.materials.slice();
 
 
 			faces1.push( faceCopy );
 			faces1.push( faceCopy );
 
 

+ 3 - 3
src/extras/ShaderUtils.js

@@ -373,7 +373,7 @@ var ShaderUtils = {
 			].join("\n")
 			].join("\n")
 
 
 		},
 		},
-		
+
 		'cube': {
 		'cube': {
 
 
 			uniforms: { "tCube": { type: "t", value: 1, texture: null } },
 			uniforms: { "tCube": { type: "t", value: 1, texture: null } },
@@ -383,7 +383,7 @@ var ShaderUtils = {
 				"varying vec3 vViewPosition;",
 				"varying vec3 vViewPosition;",
 
 
 				"void main() {",
 				"void main() {",
-			
+
 					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
 					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
 					"vViewPosition = cameraPosition - mPosition.xyz;",
 					"vViewPosition = cameraPosition - mPosition.xyz;",
 
 
@@ -402,7 +402,7 @@ var ShaderUtils = {
 				"void main() {",
 				"void main() {",
 
 
 					"vec3 wPos = cameraPosition - vViewPosition;",
 					"vec3 wPos = cameraPosition - vViewPosition;",
-					"gl_FragColor = textureCube( tCube, vec3( -wPos.x, wPos.yz ) );",
+					"gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );",
 
 
 				"}"
 				"}"
 
 

+ 7 - 3
src/materials/LineBasicMaterial.js

@@ -28,7 +28,11 @@ THREE.LineBasicMaterial = function ( parameters ) {
 		if ( parameters.linejoin !== undefined ) this.linejoin = parameters.linejoin;
 		if ( parameters.linejoin !== undefined ) this.linejoin = parameters.linejoin;
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.LineBasicMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.LineBasicMaterial (<br/>' +
 		return 'THREE.LineBasicMaterial (<br/>' +
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
@@ -39,6 +43,6 @@ THREE.LineBasicMaterial = function ( parameters ) {
 			'linejoin: ' + this.linejoin +'<br/>' +
 			'linejoin: ' + this.linejoin +'<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
-};
+}

+ 11 - 3
src/materials/MeshBasicMaterial.js

@@ -31,6 +31,8 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 	this.reflectivity = 1;
 	this.reflectivity = 1;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
+	this.fog = true;
+
 	this.opacity = 1;
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
@@ -50,6 +52,8 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 
 
+		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
+
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
@@ -61,7 +65,11 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.MeshBasicMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshBasicMaterial (<br/>' +
 		return 'THREE.MeshBasicMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
@@ -82,8 +90,8 @@ THREE.MeshBasicMaterial = function ( parameters ) {
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
-}
+};
 
 
 THREE.MeshBasicMaterialCounter = { value: 0 };
 THREE.MeshBasicMaterialCounter = { value: 0 };

+ 6 - 13
src/materials/MeshDepthMaterial.js

@@ -2,8 +2,6 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  *
  *
  * parameters = {
  * parameters = {
- *  near: <float>,
- *  far: <float>,
  *  opacity: <float>,
  *  opacity: <float>,
  *  blending: THREE.NormalBlending
  *  blending: THREE.NormalBlending
  * } 
  * } 
@@ -11,9 +9,6 @@
 
 
 THREE.MeshDepthMaterial = function ( parameters ) {
 THREE.MeshDepthMaterial = function ( parameters ) {
 
 
-	this.near = 1;
-	this.far = 1000;
-	
 	this.opacity = 1;
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
@@ -25,21 +20,19 @@ THREE.MeshDepthMaterial = function ( parameters ) {
 
 
 	if ( parameters ) {
 	if ( parameters ) {
 
 
-		if ( parameters.near !== undefined ) this.near = parameters.near;
-		if ( parameters.far !== undefined ) this.far = parameters.far;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 
 
 	}
 	}
 
 
-	this.__2near = 2 * this.near;
-	this.__farPlusNear = this.far + this.near;
-	this.__farMinusNear = this.far - this.near;
+};
 
 
-	this.toString = function () {
+THREE.MeshDepthMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshDepthMaterial';
 		return 'THREE.MeshDepthMaterial';
 
 
-	};
+	}
 
 
-}
+};

+ 6 - 2
src/materials/MeshFaceMaterial.js

@@ -4,10 +4,14 @@
 
 
 THREE.MeshFaceMaterial = function () {
 THREE.MeshFaceMaterial = function () {
 
 
-	this.toString = function () {
+};
+
+THREE.MeshFaceMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshFaceMaterial';
 		return 'THREE.MeshFaceMaterial';
 
 
-	};
+	}
 
 
 };
 };

+ 10 - 2
src/materials/MeshLambertMaterial.js

@@ -31,6 +31,8 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 	this.reflectivity = 1;
 	this.reflectivity = 1;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
+	this.fog = true;
+
 	this.opacity = 1;
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
@@ -50,6 +52,8 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 
 
+		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
+
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
@@ -61,7 +65,11 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.MeshLambertMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshLambertMaterial (<br/>' +
 		return 'THREE.MeshLambertMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
@@ -83,7 +91,7 @@ THREE.MeshLambertMaterial = function ( parameters ) {
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			' )';
 			' )';
 
 
-	};
+	}
 
 
 };
 };
 
 

+ 8 - 5
src/materials/MeshNormalMaterial.js

@@ -14,19 +14,22 @@ THREE.MeshNormalMaterial = function ( parameters ) {
 	this.shading = THREE.FlatShading;
 	this.shading = THREE.FlatShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
 
 
-
 	if ( parameters ) {
 	if ( parameters ) {
 
 
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity  = parameters.opacity;
-        if ( parameters.shading !== undefined ) this.shading  = parameters.shading;
+		if ( parameters.shading !== undefined ) this.shading  = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.MeshNormalMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshNormalMaterial';
 		return 'THREE.MeshNormalMaterial';
 
 
-	};
+	}
 
 
-}
+};

+ 11 - 3
src/materials/MeshPhongMaterial.js

@@ -41,6 +41,8 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 	this.reflectivity = 1;
 	this.reflectivity = 1;
 	this.refraction_ratio = 0.98;
 	this.refraction_ratio = 0.98;
 
 
+	this.fog = true;
+
 	this.opacity = 1;
 	this.opacity = 1;
 	this.shading = THREE.SmoothShading;
 	this.shading = THREE.SmoothShading;
 	this.blending = THREE.NormalBlending;
 	this.blending = THREE.NormalBlending;
@@ -65,6 +67,8 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.reflectivity !== undefined ) this.reflectivity  = parameters.reflectivity;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 		if ( parameters.refraction_ratio !== undefined ) this.refraction_ratio  = parameters.refraction_ratio;
 
 
+		if ( parameters.fog !== undefined ) this.fog  = parameters.fog;
+
 		if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
 		if ( parameters.opacity !== undefined ) this.opacity = parameters.opacity;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.shading !== undefined ) this.shading = parameters.shading;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
@@ -76,7 +80,11 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.MeshPhongMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshPhongMaterial (<br/>' +
 		return 'THREE.MeshPhongMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
@@ -100,9 +108,9 @@ THREE.MeshPhongMaterial = function ( parameters ) {
 			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
 			'wireframe_linewidth: ' + this.wireframe_linewidth + '<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linecap: ' + this.wireframe_linecap +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
-			+ ')';
+			')';
 
 
-	};
+	}
 
 
 };
 };
 
 

+ 7 - 4
src/materials/MeshShaderMaterial.js

@@ -5,7 +5,6 @@
  *  fragment_shader: <string>,
  *  fragment_shader: <string>,
  *  vertex_shader: <string>,
  *  vertex_shader: <string>,
  *  uniforms: { "parameter1": { type: "f", value: 1.0 }, "parameter2": { type: "i" value2: 2 } },
  *  uniforms: { "parameter1": { type: "f", value: 1.0 }, "parameter2": { type: "i" value2: 2 } },
- 
  *  shading: THREE.SmoothShading,
  *  shading: THREE.SmoothShading,
  *  blending: THREE.NormalBlending,
  *  blending: THREE.NormalBlending,
  *  wireframe: <boolean>,
  *  wireframe: <boolean>,
@@ -47,7 +46,11 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.MeshShaderMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.MeshShaderMaterial (<br/>' +
 		return 'THREE.MeshShaderMaterial (<br/>' +
 			'id: ' + this.id + '<br/>' +
 			'id: ' + this.id + '<br/>' +
@@ -59,8 +62,8 @@ THREE.MeshShaderMaterial = function ( parameters ) {
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			'wireframe_linejoin: ' + this.wireframe_linejoin +'<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
-}
+};
 
 
 THREE.MeshShaderMaterialCounter = { value: 0 };
 THREE.MeshShaderMaterialCounter = { value: 0 };

+ 6 - 2
src/materials/ParticleBasicMaterial.js

@@ -27,7 +27,11 @@ THREE.ParticleBasicMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.ParticleBasicMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.ParticleBasicMaterial (<br/>' +
 		return 'THREE.ParticleBasicMaterial (<br/>' +
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
@@ -36,6 +40,6 @@ THREE.ParticleBasicMaterial = function ( parameters ) {
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
 };
 };

+ 6 - 2
src/materials/ParticleCircleMaterial.js

@@ -22,7 +22,11 @@ THREE.ParticleCircleMaterial = function ( parameters ) {
 
 
 	}
 	}
 
 
-	this.toString = function () {
+};
+
+THREE.ParticleCircleMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.ParticleCircleMaterial (<br/>' +
 		return 'THREE.ParticleCircleMaterial (<br/>' +
 			'color: ' + this.color + '<br/>' +
 			'color: ' + this.color + '<br/>' +
@@ -30,6 +34,6 @@ THREE.ParticleCircleMaterial = function ( parameters ) {
 			'blending: ' + this.blending + '<br/>' +
 			'blending: ' + this.blending + '<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
 };
 };

+ 7 - 2
src/materials/ParticleDOMMaterial.js

@@ -6,10 +6,15 @@ THREE.ParticleDOMMaterial = function ( domElement ) {
 
 
 	this.domElement = domElement;
 	this.domElement = domElement;
 
 
-	this.toString = function () {
+};
+
+
+THREE.ParticleDOMMaterial.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.ParticleDOMMaterial ( domElement: ' + this.domElement + ' )';
 		return 'THREE.ParticleDOMMaterial ( domElement: ' + this.domElement + ' )';
 
 
-	};
+	}
 
 
 };
 };

+ 6 - 2
src/materials/Texture.js

@@ -15,7 +15,11 @@ THREE.Texture = function ( image, mapping, wrap_s, wrap_t, mag_filter, min_filte
 	this.mag_filter = mag_filter !== undefined ? mag_filter : THREE.LinearFilter;
 	this.mag_filter = mag_filter !== undefined ? mag_filter : THREE.LinearFilter;
 	this.min_filter = min_filter !== undefined ? min_filter : THREE.LinearMipMapLinearFilter;
 	this.min_filter = min_filter !== undefined ? min_filter : THREE.LinearMipMapLinearFilter;
 
 
-	this.toString = function () {
+};
+
+THREE.Texture.prototype = {
+
+	toString: function () {
 
 
 		return 'THREE.Texture (<br/>' +
 		return 'THREE.Texture (<br/>' +
 			'image: ' + this.image + '<br/>' +
 			'image: ' + this.image + '<br/>' +
@@ -25,7 +29,7 @@ THREE.Texture = function ( image, mapping, wrap_s, wrap_t, mag_filter, min_filte
 			'min_filter: ' + this.min_filter + '<br/>' +
 			'min_filter: ' + this.min_filter + '<br/>' +
 			')';
 			')';
 
 
-	};
+	}
 
 
 };
 };
 
 

+ 2 - 2
src/objects/Line.js

@@ -2,12 +2,12 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Line = function ( geometry, material ) {
+THREE.Line = function ( geometry, materials ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
 
 
 	this.geometry = geometry;
 	this.geometry = geometry;
-	this.material = material instanceof Array ? material : [ material ];
+	this.materials = materials instanceof Array ? materials : [ materials ];
 
 
 };
 };
 
 

+ 3 - 32
src/objects/Mesh.js

@@ -3,50 +3,21 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.Mesh = function ( geometry, material/*, normUVs*/ ) {
+THREE.Mesh = function ( geometry, materials ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
 
 
 	this.geometry = geometry;
 	this.geometry = geometry;
-	this.material = material instanceof Array ? material : [ material ];
+	this.materials = materials instanceof Array ? materials : [ materials ];
 
 
 	this.flipSided = false;
 	this.flipSided = false;
 	this.doubleSided = false;
 	this.doubleSided = false;
 
 
-	this.overdraw = false;
+	this.overdraw = false; // TODO: Move to material?
 
 
-	// if ( normUVs ) this.normalizeUVs();
-
-	// this.geometry.boundingBox ||this.geometry.computeBoundingBox();
 	this.geometry.boundingSphere || this.geometry.computeBoundingSphere();
 	this.geometry.boundingSphere || this.geometry.computeBoundingSphere();
 
 
 };
 };
 
 
 THREE.Mesh.prototype = new THREE.Object3D();
 THREE.Mesh.prototype = new THREE.Object3D();
 THREE.Mesh.prototype.constructor = THREE.Mesh;
 THREE.Mesh.prototype.constructor = THREE.Mesh;
-
-/*
-TODO: This doesn't completely fix the issue. Needs to be handled directly in the CanvasRenderer
-
-THREE.Mesh.prototype.normalizeUVs = function () {
-
-	var i, il, j, jl, uvs;
-
-	for ( i = 0, il = this.geometry.uvs.length; i < il; i++ ) {
-
-		uvs = this.geometry.uvs[ i ];
-
-		for ( j = 0, jl = uvs.length; j < jl; j++ ) {
-
-			// texture repeat
-			// (WebGL does this by default but canvas renderer needs to do it explicitly)
-
-			if( uvs[ j ].u != 1.0 ) uvs[ j ].u = uvs[ j ].u - Math.floor( uvs[ j ].u );
-			if( uvs[ j ].v != 1.0 ) uvs[ j ].v = uvs[ j ].v - Math.floor( uvs[ j ].v );
-
-		}
-
-	}
-
-};
-*/

+ 8 - 4
src/objects/Object3D.js

@@ -2,7 +2,7 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Object3D = function ( material ) {
+THREE.Object3D = function () {
 
 
 	this.id = THREE.Object3DCounter.value ++;
 	this.id = THREE.Object3DCounter.value ++;
 
 
@@ -17,10 +17,14 @@ THREE.Object3D = function ( material ) {
 
 
 	this.screen = new THREE.Vector3();
 	this.screen = new THREE.Vector3();
 
 
-	this.visible = true;
 	this.autoUpdateMatrix = true;
 	this.autoUpdateMatrix = true;
+	this.visible = true;
+
+};
+
+THREE.Object3D.prototype = {
 
 
-	this.updateMatrix = function () {
+	updateMatrix: function () {
 
 
 		this.matrixPosition = THREE.Matrix4.translationMatrix( this.position.x, this.position.y, this.position.z );
 		this.matrixPosition = THREE.Matrix4.translationMatrix( this.position.x, this.position.y, this.position.z );
 
 
@@ -34,7 +38,7 @@ THREE.Object3D = function ( material ) {
 		this.matrix.multiplySelf( this.rotationMatrix );
 		this.matrix.multiplySelf( this.rotationMatrix );
 		this.matrix.multiplySelf( this.scaleMatrix );
 		this.matrix.multiplySelf( this.scaleMatrix );
 
 
-	};
+	}
 
 
 };
 };
 
 

+ 3 - 2
src/objects/Particle.js

@@ -2,11 +2,12 @@
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  */
  */
 
 
-THREE.Particle = function ( material ) {
+THREE.Particle = function ( materials ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
 
 
-	this.material = material instanceof Array ? material : [ material ];
+	this.materials = materials instanceof Array ? materials : [ materials ];
+
 	this.autoUpdateMatrix = false;
 	this.autoUpdateMatrix = false;
 
 
 };
 };

+ 28 - 16
src/renderers/CanvasRenderer.js

@@ -25,7 +25,8 @@ THREE.CanvasRenderer = function () {
 	_color2 = new THREE.Color(),
 	_color2 = new THREE.Color(),
 	_color3 = new THREE.Color(),
 	_color3 = new THREE.Color(),
 	_color4 = new THREE.Color(),
 	_color4 = new THREE.Color(),
-	_2near, _farPlusNear, _farMinusNear,
+
+	_near, _far,
 
 
 	_bitmap,
 	_bitmap,
 	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
 	_uv1x, _uv1y, _uv2x, _uv2y, _uv3x, _uv3y,
@@ -110,7 +111,7 @@ THREE.CanvasRenderer = function () {
 		_renderList = _projector.projectScene( scene, camera, this.sortElements );
 		_renderList = _projector.projectScene( scene, camera, this.sortElements );
 
 
 		/* DEBUG
 		/* DEBUG
-		_context.fillStyle = 'rgba(0, 255, 255, 0.5)';
+		_context.fillStyle = 'rgba( 0, 255, 255, 0.5 )';
 		_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
 		_context.fillRect( _clipRect.getX(), _clipRect.getY(), _clipRect.getWidth(), _clipRect.getHeight() );
 		*/
 		*/
 
 
@@ -133,9 +134,9 @@ THREE.CanvasRenderer = function () {
 				_v1 = element;
 				_v1 = element;
 				_v1.x *= _canvasWidthHalf; _v1.y *= _canvasHeightHalf;
 				_v1.x *= _canvasWidthHalf; _v1.y *= _canvasHeightHalf;
 
 
-				for ( m = 0, ml = element.material.length; m < ml; m++ ) {
+				for ( m = 0, ml = element.materials.length; m < ml; m++ ) {
 
 
-					renderParticle( _v1, element, element.material[ m ], scene );
+					renderParticle( _v1, element, element.materials[ m ], scene );
 
 
 				}
 				}
 
 
@@ -151,11 +152,11 @@ THREE.CanvasRenderer = function () {
 
 
 				if ( _clipRect.instersects( _bboxRect ) ) {
 				if ( _clipRect.instersects( _bboxRect ) ) {
 
 
-					m = 0; ml = element.material.length;
+					m = 0; ml = element.materials.length;
 
 
 					while ( m < ml ) {
 					while ( m < ml ) {
 
 
-						renderLine( _v1, _v2, element, element.material[ m ++ ], scene );
+						renderLine( _v1, _v2, element, element.materials[ m ++ ], scene );
 
 
 					}
 					}
 
 
@@ -184,19 +185,19 @@ THREE.CanvasRenderer = function () {
 
 
 				if ( _clipRect.instersects( _bboxRect ) ) {
 				if ( _clipRect.instersects( _bboxRect ) ) {
 
 
-					m = 0; ml = element.meshMaterial.length;
+					m = 0; ml = element.meshMaterials.length;
 
 
 					while ( m < ml ) {
 					while ( m < ml ) {
 
 
-						material = element.meshMaterial[ m ++ ];
+						material = element.meshMaterials[ m ++ ];
 
 
 						if ( material instanceof THREE.MeshFaceMaterial ) {
 						if ( material instanceof THREE.MeshFaceMaterial ) {
 
 
-							fm = 0; fml = element.faceMaterial.length;
+							fm = 0; fml = element.faceMaterials.length;
 
 
 							while ( fm < fml ) {
 							while ( fm < fml ) {
 
 
-								material = element.faceMaterial[ fm ++ ];
+								material = element.faceMaterials[ fm ++ ];
 								material && renderFace3( _v1, _v2, _v3, element, material, scene );
 								material && renderFace3( _v1, _v2, _v3, element, material, scene );
 
 
 							}
 							}
@@ -575,13 +576,12 @@ THREE.CanvasRenderer = function () {
 				_color.setRGB( _w, _w, _w );
 				_color.setRGB( _w, _w, _w );
 				*/
 				*/
 
 
-				_2near = material.__2near;
-				_farPlusNear = material.__farPlusNear;
-				_farMinusNear = material.__farMinusNear;
+				_near = camera.near;
+				_far = camera.far;
 
 
-				_color1.r = _color1.g = _color1.b = 1 - ( _2near / ( _farPlusNear - v1.positionScreen.z * _farMinusNear ) );
-				_color2.r = _color2.g = _color2.b = 1 - ( _2near / ( _farPlusNear - v2.positionScreen.z * _farMinusNear ) );
-				_color3.r = _color3.g = _color3.b = 1 - ( _2near / ( _farPlusNear - v3.positionScreen.z * _farMinusNear ) );
+				_color1.r = _color1.g = _color1.b = 1 - smoothstep( v1.positionScreen.z, _near, _far );
+				_color2.r = _color2.g = _color2.b = 1 - smoothstep( v2.positionScreen.z, _near, _far );
+				_color3.r = _color3.g = _color3.b = 1 - smoothstep( v3.positionScreen.z, _near, _far );
 
 
 				_color4.r = ( _color2.r + _color3.r ) * 0.5;
 				_color4.r = ( _color2.r + _color3.r ) * 0.5;
 				_color4.g = ( _color2.g + _color3.g ) * 0.5;
 				_color4.g = ( _color2.g + _color3.g ) * 0.5;
@@ -789,6 +789,18 @@ THREE.CanvasRenderer = function () {
 
 
 		}
 		}
 
 
+		function smoothstep( value, min, max ) {
+
+			/*
+			if ( value <= min ) return 0;
+			if ( value >= max ) return 1;
+			*/
+
+			var x = ( value - min ) / ( max - min );
+			return x * x * ( 3 - 2 * x );
+
+		}
+
 		function normalToComponent( normal ) {
 		function normalToComponent( normal ) {
 
 
 			var component = ( normal + 1 ) * 0.5;
 			var component = ( normal + 1 ) * 0.5;

+ 15 - 17
src/renderers/Projector.js

@@ -64,9 +64,9 @@ THREE.Projector = function() {
 
 
 	this.projectScene = function ( scene, camera, sort ) {
 	this.projectScene = function ( scene, camera, sort ) {
 
 
-		var renderList = [],
+		var renderList = [], near = camera.near, far = camera.far,
 		o, ol, v, vl, f, fl, n, nl, objects, object,
 		o, ol, v, vl, f, fl, n, nl, objects, object,
-		objectMatrix, objectRotationMatrix, objectMaterial, objectOverdraw,
+		objectMatrix, objectRotationMatrix, objectMaterials, objectOverdraw,
 		geometry, vertices, vertex, vertexPositionScreen,
 		geometry, vertices, vertex, vertexPositionScreen,
 		faces, face, faceVertexNormals, normal, v1, v2, v3, v4;
 		faces, face, faceVertexNormals, normal, v1, v2, v3, v4;
 
 
@@ -88,7 +88,7 @@ THREE.Projector = function() {
 
 
 			objectMatrix = object.matrix;
 			objectMatrix = object.matrix;
 			objectRotationMatrix = object.rotationMatrix;
 			objectRotationMatrix = object.rotationMatrix;
-			objectMaterial = object.material;
+			objectMaterials = object.materials;
 			objectOverdraw = object.overdraw;
 			objectOverdraw = object.overdraw;
 
 
 			if ( object instanceof THREE.Mesh ) {
 			if ( object instanceof THREE.Mesh ) {
@@ -99,7 +99,7 @@ THREE.Projector = function() {
 
 
 				vertices = geometry.vertices;
 				vertices = geometry.vertices;
 
 
-				for ( v = 0, vl = vertices.length; v < vl; v++ ) {
+				for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
 
 
 					vertex = vertices[ v ];
 					vertex = vertices[ v ];
 
 
@@ -110,12 +110,10 @@ THREE.Projector = function() {
 					vertexPositionScreen.copy( vertex.positionWorld );
 					vertexPositionScreen.copy( vertex.positionWorld );
 					_projScreenMatrix.multiplyVector4( vertexPositionScreen );
 					_projScreenMatrix.multiplyVector4( vertexPositionScreen );
 
 
-					// Perform the perspective divide. TODO: This should be be performend 
-					// post clipping (imagine if the vertex lies at the same location as 
-					// the camera, causing a divide by w = 0).
-					vertexPositionScreen.multiplyScalar( 1 / vertexPositionScreen.w );
+					vertexPositionScreen.x /= vertexPositionScreen.w;
+					vertexPositionScreen.y /= vertexPositionScreen.w;
 
 
-					vertex.__visible = vertexPositionScreen.z > 0 && vertexPositionScreen.z < 1;
+					vertex.__visible = vertexPositionScreen.z > near && vertexPositionScreen.z < far;
 
 
 				}
 				}
 
 
@@ -169,8 +167,8 @@ THREE.Projector = function() {
 
 
 								_face3.z = _face3.centroidScreen.z;
 								_face3.z = _face3.centroidScreen.z;
 
 
-								_face3.meshMaterial = objectMaterial;
-								_face3.faceMaterial = face.material;
+								_face3.meshMaterials = objectMaterials;
+								_face3.faceMaterials = face.materials;
 								_face3.overdraw = objectOverdraw;
 								_face3.overdraw = objectOverdraw;
 
 
 								if ( object.geometry.uvs[ f ] ) {
 								if ( object.geometry.uvs[ f ] ) {
@@ -224,8 +222,8 @@ THREE.Projector = function() {
 
 
 								_face3.z = _face3.centroidScreen.z;
 								_face3.z = _face3.centroidScreen.z;
 
 
-								_face3.meshMaterial = objectMaterial;
-								_face3.faceMaterial = face.material;
+								_face3.meshMaterials = objectMaterials;
+								_face3.faceMaterials = face.materials;
 								_face3.overdraw = objectOverdraw;
 								_face3.overdraw = objectOverdraw;
 
 
 								if ( object.geometry.uvs[ f ] ) {
 								if ( object.geometry.uvs[ f ] ) {
@@ -260,8 +258,8 @@ THREE.Projector = function() {
 
 
 								_face32.z = _face32.centroidScreen.z;
 								_face32.z = _face32.centroidScreen.z;
 
 
-								_face32.meshMaterial = objectMaterial;
-								_face32.faceMaterial = face.material;
+								_face32.meshMaterials = objectMaterials;
+								_face32.faceMaterials = face.materials;
 								_face32.overdraw = objectOverdraw;
 								_face32.overdraw = objectOverdraw;
 
 
 								if ( object.geometry.uvs[ f ] ) {
 								if ( object.geometry.uvs[ f ] ) {
@@ -318,7 +316,7 @@ THREE.Projector = function() {
 
 
 						_line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z );
 						_line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z );
 
 
-						_line.material = object.material;
+						_line.materials = object.materials;
 
 
 						renderList.push( _line );
 						renderList.push( _line );
 
 
@@ -346,7 +344,7 @@ THREE.Projector = function() {
 					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) );
 					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) );
 					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) );
 					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) );
 
 
-					_particle.material = object.material;
+					_particle.materials = object.materials;
 
 
 					renderList.push( _particle );
 					renderList.push( _particle );
 
 

+ 12 - 12
src/renderers/SVGRenderer.js

@@ -101,9 +101,9 @@ THREE.SVGRenderer = function () {
 				_v1 = element;
 				_v1 = element;
 				_v1.x *= _svgWidthHalf; _v1.y *= -_svgHeightHalf;
 				_v1.x *= _svgWidthHalf; _v1.y *= -_svgHeightHalf;
 
 
-				for ( m = 0, ml = element.material.length; m < ml; m++ ) {
+				for ( m = 0, ml = element.materials.length; m < ml; m++ ) {
 
 
-					material = element.material[ m ];
+					material = element.materials[ m ];
 					material && renderParticle( _v1, element, material, scene );
 					material && renderParticle( _v1, element, material, scene );
 
 
 				}
 				}
@@ -124,11 +124,11 @@ THREE.SVGRenderer = function () {
 
 
 				}
 				}
 
 
-				m = 0; ml = element.material.length;
+				m = 0; ml = element.materials.length;
 
 
 				while ( m < ml ) {
 				while ( m < ml ) {
 
 
-					material = element.material[ m ++ ];
+					material = element.materials[ m ++ ];
 					material && renderLine( _v1, _v2, element, material, scene );
 					material && renderLine( _v1, _v2, element, material, scene );
 
 
 				}
 				}
@@ -151,19 +151,19 @@ THREE.SVGRenderer = function () {
 
 
 				}
 				}
 
 
-				m = 0; ml = element.meshMaterial.length;
+				m = 0; ml = element.meshMaterials.length;
 
 
 				while ( m < ml ) {
 				while ( m < ml ) {
 
 
-					material = element.meshMaterial[ m ++ ];
+					material = element.meshMaterials[ m ++ ];
 
 
 					if ( material instanceof THREE.MeshFaceMaterial ) {
 					if ( material instanceof THREE.MeshFaceMaterial ) {
 
 
-						fm = 0; fml = element.faceMaterial.length;
+						fm = 0; fml = element.faceMaterials.length;
 
 
 						while ( fm < fml ) {
 						while ( fm < fml ) {
 
 
-							material = element.faceMaterial[ fm ++ ];
+							material = element.faceMaterials[ fm ++ ];
 							material && renderFace3( _v1, _v2, _v3, element, material, scene );
 							material && renderFace3( _v1, _v2, _v3, element, material, scene );
 
 
 						}
 						}
@@ -196,19 +196,19 @@ THREE.SVGRenderer = function () {
 
 
 				}
 				}
 
 
-				m = 0; ml = element.meshMaterial.length;
+				m = 0; ml = element.meshMaterials.length;
 
 
 				while ( m < ml ) {
 				while ( m < ml ) {
 
 
-					material = element.meshMaterial[ m ++ ];
+					material = element.meshMaterials[ m ++ ];
 
 
 					if ( material instanceof THREE.MeshFaceMaterial ) {
 					if ( material instanceof THREE.MeshFaceMaterial ) {
 
 
-						fm = 0; fml = element.faceMaterial.length;
+						fm = 0; fml = element.faceMaterials.length;
 
 
 						while ( fm < fml ) {
 						while ( fm < fml ) {
 
 
-							material = element.faceMaterial[ fm ++ ];
+							material = element.faceMaterials[ fm ++ ];
 							material && renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
 							material && renderFace4( _v1, _v2, _v3, _v4, element, material, scene );
 
 
 						}
 						}

+ 70 - 61
src/renderers/WebGLRenderer.js

@@ -373,13 +373,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 	};
 	};
 
 
 	function setMaterialShaders( material, shaders ) {
 	function setMaterialShaders( material, shaders ) {
-		
+
 		material.fragment_shader = shaders.fragment_shader;
 		material.fragment_shader = shaders.fragment_shader;
 		material.vertex_shader = shaders.vertex_shader;
 		material.vertex_shader = shaders.vertex_shader;
 		material.uniforms = shaders.uniforms;
 		material.uniforms = shaders.uniforms;
-		
+
 	};
 	};
-	
+
 	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk ) {
 	this.renderBuffer = function ( camera, lights, fog, material, geometryChunk ) {
 
 
 		var mColor, mOpacity, mReflectivity,
 		var mColor, mOpacity, mReflectivity,
@@ -397,18 +397,18 @@ THREE.WebGLRenderer = function ( parameters ) {
 			if ( !material.program ) {
 			if ( !material.program ) {
 
 
 				if ( material instanceof THREE.MeshDepthMaterial ) {
 				if ( material instanceof THREE.MeshDepthMaterial ) {
-					
+
 					setMaterialShaders( material, ShaderLib[ 'depth' ] );
 					setMaterialShaders( material, ShaderLib[ 'depth' ] );
-					
-					material.uniforms.mNear.value = material.near;
-					material.uniforms.mFar.value = material.far;
-					
+
+					material.uniforms.mNear.value = camera.near;
+					material.uniforms.mFar.value = camera.far;
+
 				} else if ( material instanceof THREE.MeshNormalMaterial ) {
 				} else if ( material instanceof THREE.MeshNormalMaterial ) {
-					
+
 					setMaterialShaders( material, ShaderLib[ 'normal' ] );
 					setMaterialShaders( material, ShaderLib[ 'normal' ] );
-					
-				}					
-				
+
+				}
+
 				material.program = buildProgram( material.fragment_shader, material.vertex_shader, null );
 				material.program = buildProgram( material.fragment_shader, material.vertex_shader, null );
 
 
 				identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
 				identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
@@ -417,7 +417,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					identifiers.push(u);
 					identifiers.push(u);
 
 
 				}
 				}
-				
+
 				cacheUniformLocations( material.program, identifiers );
 				cacheUniformLocations( material.program, identifiers );
 				cacheAttributeLocations( material.program, [ "position", "normal", "uv", "tangent" ] );
 				cacheAttributeLocations( material.program, [ "position", "normal", "uv", "tangent" ] );
 
 
@@ -447,7 +447,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		this.loadCamera( program, camera );
 		this.loadCamera( program, camera );
 		this.loadMatrices( program );
 		this.loadMatrices( program );
 
 
-		if ( material instanceof THREE.MeshShaderMaterial || 
+		if ( material instanceof THREE.MeshShaderMaterial ||
 		     material instanceof THREE.MeshDepthMaterial ||
 		     material instanceof THREE.MeshDepthMaterial ||
 			 material instanceof THREE.MeshNormalMaterial ) {
 			 material instanceof THREE.MeshNormalMaterial ) {
 
 
@@ -488,12 +488,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			_gl.uniform1i( program.uniforms.useRefract, useRefract );
 			_gl.uniform1i( program.uniforms.useRefract, useRefract );
 			_gl.uniform1f( program.uniforms.mRefractionRatio, mRefractionRatio );
 			_gl.uniform1f( program.uniforms.mRefractionRatio, mRefractionRatio );
-			
+
 			if ( fog ) {
 			if ( fog ) {
-				
-				_gl.uniform1f( program.uniforms.fogDensity, fog.density );
+
+				_gl.uniform1f( program.uniforms.fogNear, fog.near );
+				_gl.uniform1f( program.uniforms.fogFar, fog.far );
 				_gl.uniform3f( program.uniforms.fogColor, fog.color.r, fog.color.g, fog.color.b );
 				_gl.uniform3f( program.uniforms.fogColor, fog.color.r, fog.color.g, fog.color.b );
-				
+
 			}
 			}
 
 
 		}
 		}
@@ -545,7 +546,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.uniform1i( program.uniforms.enableCubeMap, 0 );
 			_gl.uniform1i( program.uniforms.enableCubeMap, 0 );
 
 
 		}
 		}
-		
+
 		attributes = program.attributes;
 		attributes = program.attributes;
 
 
 		// vertices
 		// vertices
@@ -571,7 +572,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
 			_gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 );
 			_gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 );
 			_gl.enableVertexAttribArray( attributes.tangent );
 			_gl.enableVertexAttribArray( attributes.tangent );
-			
+
 		}
 		}
 
 
 		// uvs
 		// uvs
@@ -579,7 +580,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		if ( attributes.uv >= 0 ) {
 		if ( attributes.uv >= 0 ) {
 
 
 			if ( geometryChunk.__webGLUVBuffer ) {
 			if ( geometryChunk.__webGLUVBuffer ) {
-				
+
 				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer );
 				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer );
 				_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
 				_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
 
 
@@ -616,15 +617,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		var i, l, m, ml, material, meshMaterial;
 		var i, l, m, ml, material, meshMaterial;
 
 
-		for ( m = 0, ml = object.material.length; m < ml; m++ ) {
+		for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
 
 
-			meshMaterial = object.material[ m ];
+			meshMaterial = object.materials[ m ];
 
 
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 
 
-				for ( i = 0, l = geometryChunk.material.length; i < l; i++ ) {
+				for ( i = 0, l = geometryChunk.materials.length; i < l; i++ ) {
+
+					material = geometryChunk.materials[ i ];
 
 
-					material = geometryChunk.material[ i ];
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 					if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) {
 
 
 						this.setBlending( material.blending );
 						this.setBlending( material.blending );
@@ -665,7 +667,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 		}
 
 
 		camera.autoUpdateMatrix && camera.updateMatrix();
 		camera.autoUpdateMatrix && camera.updateMatrix();
-		
+
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 
 
@@ -966,9 +968,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			"#ifdef USE_FOG",
 			"#ifdef USE_FOG",
 				"uniform vec3 fogColor;",
 				"uniform vec3 fogColor;",
-				"uniform float fogDensity;",
+				"uniform float fogNear;",
+				"uniform float fogFar;",
 			"#endif",
 			"#endif",
-			
+
 			"uniform int pointLightNumber;",
 			"uniform int pointLightNumber;",
 			"uniform int directionalLightNumber;",
 			"uniform int directionalLightNumber;",
 
 
@@ -1122,17 +1125,23 @@ THREE.WebGLRenderer = function ( parameters ) {
 					"}",
 					"}",
 
 
 				"}",
 				"}",
-				
+
 				"#ifdef USE_FOG",
 				"#ifdef USE_FOG",
-		
+
+					"float depth = gl_FragCoord.z / gl_FragCoord.w;",
+					"float fogFactor = smoothstep( fogNear, fogFar, depth );",
+					"gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );",
+
+					/*
 					"const float LOG2 = 1.442695;",
 					"const float LOG2 = 1.442695;",
 					"float z = gl_FragCoord.z / gl_FragCoord.w;",
 					"float z = gl_FragCoord.z / gl_FragCoord.w;",
 					"float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );",
 					"float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );",
 					"fogFactor = clamp( fogFactor, 0.0, 1.0 );",
 					"fogFactor = clamp( fogFactor, 0.0, 1.0 );",
 					"gl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );",
 					"gl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );",
-			
+					*/
+
 				"#endif",
 				"#endif",
-				
+
 			"}" ];
 			"}" ];
 
 
 		return chunks.join("\n");
 		return chunks.join("\n");
@@ -1246,12 +1255,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 			"#endif",
 			"#endif",
 
 
 			fog ? "#define USE_FOG" : "",
 			fog ? "#define USE_FOG" : "",
-		
+
 			"uniform mat4 viewMatrix;",
 			"uniform mat4 viewMatrix;",
 			"uniform vec3 cameraPosition;",
 			"uniform vec3 cameraPosition;",
 			""
 			""
 		].join("\n"),
 		].join("\n"),
-		
+
 		prefix_vertex = [
 		prefix_vertex = [
 			maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "",
 			maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "",
 
 
@@ -1266,7 +1275,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			"attribute vec2 uv;",
 			"attribute vec2 uv;",
 			""
 			""
 		].join("\n");
 		].join("\n");
-		
+
 		_gl.attachShader( program, getShader( "fragment", prefix_fragment + fragment_shader ) );
 		_gl.attachShader( program, getShader( "fragment", prefix_fragment + fragment_shader ) );
 		_gl.attachShader( program, getShader( "vertex", prefix_vertex + vertex_shader ) );
 		_gl.attachShader( program, getShader( "vertex", prefix_vertex + vertex_shader ) );
 
 
@@ -1449,9 +1458,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 		] );
 		] );
 
 
 		if ( fog ) {
 		if ( fog ) {
-			
-			cacheUniformLocations( program, [ 'fogColor', 'fogDensity' ] );
-			
+
+			cacheUniformLocations( program, [ 'fogColor', 'fogNear', 'fogFar' ] );
+
 		}
 		}
 
 
 		if ( maxDirLights ) {
 		if ( maxDirLights ) {
@@ -1549,15 +1558,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		var m, ml, i, l, needsSmoothNormals = false;
 		var m, ml, i, l, needsSmoothNormals = false;
 
 
-		for ( m = 0, ml = object.material.length; m < ml; m++ ) {
+		for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
 
 
-			meshMaterial = object.material[ m ];
+			meshMaterial = object.materials[ m ];
 
 
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 
 
-				for ( i = 0, l = geometryChunk.material.length; i < l; i++ ) {
+				for ( i = 0, l = geometryChunk.materials.length; i < l; i++ ) {
 
 
-					if ( materialNeedsSmoothNormals( geometryChunk.material[ i ] ) ) {
+					if ( materialNeedsSmoothNormals( geometryChunk.materials[ i ] ) ) {
 
 
 						needsSmoothNormals = true;
 						needsSmoothNormals = true;
 						break;
 						break;
@@ -1651,29 +1660,29 @@ THREE.WebGLRenderer = function ( parameters ) {
 		return str;
 		return str;
 	}
 	}
 	*/
 	*/
-	
+
 	var ShaderLib = {
 	var ShaderLib = {
-		
+
 		'depth': {
 		'depth': {
 
 
-			uniforms: { "mNear": { type: "f", value: 1.0 }, 
+			uniforms: { "mNear": { type: "f", value: 1.0 },
 						"mFar" : { type: "f", value: 2000.0 } },
 						"mFar" : { type: "f", value: 2000.0 } },
 
 
 			fragment_shader: [
 			fragment_shader: [
-				
+
 				"uniform float mNear;",
 				"uniform float mNear;",
 				"uniform float mFar;",
 				"uniform float mFar;",
 
 
 				"void main() {",
 				"void main() {",
-						
+
 					"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 					"float depth = gl_FragCoord.z / gl_FragCoord.w;",
 					"float color = 1.0 - smoothstep( mNear, mFar, depth );",
 					"float color = 1.0 - smoothstep( mNear, mFar, depth );",
 					"gl_FragColor = vec4( vec3( color ), 1.0 );",
 					"gl_FragColor = vec4( vec3( color ), 1.0 );",
-					
+
 				"}"
 				"}"
 
 
 			].join("\n"),
 			].join("\n"),
-						
+
 			vertex_shader: [
 			vertex_shader: [
 
 
 				"void main() {",
 				"void main() {",
@@ -1685,29 +1694,29 @@ THREE.WebGLRenderer = function ( parameters ) {
 			].join("\n")
 			].join("\n")
 
 
 		},
 		},
-		
+
 		'normal': {
 		'normal': {
-			
+
 			uniforms: { },
 			uniforms: { },
-			
+
 			fragment_shader: [
 			fragment_shader: [
-				
+
 				"varying vec3 vNormal;",
 				"varying vec3 vNormal;",
-			
+
 				"void main() {",
 				"void main() {",
-						
+
 					"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );",
 					"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, 1.0 );",
-					
+
 				"}"
 				"}"
 
 
 			].join("\n"),
 			].join("\n"),
-			
+
 			vertex_shader: [
 			vertex_shader: [
-			
+
 				"varying vec3 vNormal;",
 				"varying vec3 vNormal;",
 
 
 				"void main() {",
 				"void main() {",
-			
+
 					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
 					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
 					"vNormal = normalize( normalMatrix * normal );",
 					"vNormal = normalize( normalMatrix * normal );",
 
 
@@ -1716,9 +1725,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 				"}"
 				"}"
 
 
 			].join("\n")
 			].join("\n")
-			
+
 		}
 		}
-		
+
 	};
 	};
 
 
 };
 };

+ 136 - 99
src/renderers/WebGLRenderer2.js

@@ -6,7 +6,7 @@
  * @author supereggbert / http://www.paulbrunt.co.uk/
  * @author supereggbert / http://www.paulbrunt.co.uk/
  */
  */
 
 
-THREE.WebGLRenderer2 = function () {
+THREE.WebGLRenderer2 = function ( antialias ) {
 
 
 	var _renderList = null,
 	var _renderList = null,
 	_projector = new THREE.Projector(),
 	_projector = new THREE.Projector(),
@@ -22,7 +22,8 @@ THREE.WebGLRenderer2 = function () {
 
 
 	try {
 	try {
 
 
-		_gl = _canvas.getContext( 'experimental-webgl', { antialias: true } );
+		antialias = antialias !== undefined ? antialias : true;
+		_gl = _canvas.getContext( 'experimental-webgl', { antialias: antialias } );
 
 
 	} catch(e) { }
 	} catch(e) { }
 
 
@@ -79,6 +80,8 @@ THREE.WebGLRenderer2 = function () {
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_viewMatrixArray.set( camera.matrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 		_projectionMatrixArray.set( camera.projectionMatrix.flatten() );
 
 
+		_currentProgram = null;
+
 		/*
 		/*
 		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
 		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
 
 
@@ -87,7 +90,6 @@ THREE.WebGLRenderer2 = function () {
 		}
 		}
 		*/
 		*/
 
 
-		_currentProgram = null;
 		_renderList = _projector.projectObjects( scene, camera, this.sortObjects );
 		_renderList = _projector.projectObjects( scene, camera, this.sortObjects );
 
 
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
 		for ( o = 0, ol = _renderList.length; o < ol; o++ ) {
@@ -99,7 +101,7 @@ THREE.WebGLRenderer2 = function () {
 		function renderObject( object ) {
 		function renderObject( object ) {
 
 
 			var geometry, material, m, nl,
 			var geometry, material, m, nl,
-			program, attributes;
+			program, uniforms, attributes;
 
 
 			object.autoUpdateMatrix && object.updateMatrix();
 			object.autoUpdateMatrix && object.updateMatrix();
 
 
@@ -123,9 +125,9 @@ THREE.WebGLRenderer2 = function () {
 
 
 				}
 				}
 
 
-				for ( m = 0, ml = object.material.length; m < ml; m ++ ) {
+				for ( m = 0, ml = object.materials.length; m < ml; m ++ ) {
 
 
-					material = object.material[ m ];
+					material = object.materials[ m ];
 
 
 					if ( material.__webglProgram == undefined ) {
 					if ( material.__webglProgram == undefined ) {
 
 
@@ -134,6 +136,7 @@ THREE.WebGLRenderer2 = function () {
 					}
 					}
 
 
 					program = material.__webglProgram;
 					program = material.__webglProgram;
+					uniforms = program.uniforms;
 					attributes = program.attributes;
 					attributes = program.attributes;
 
 
 					if( program != _currentProgram ) {
 					if( program != _currentProgram ) {
@@ -146,54 +149,61 @@ THREE.WebGLRenderer2 = function () {
 
 
 						if ( scene.fog ) {
 						if ( scene.fog ) {
 
 
-							_gl.uniform1i( program.uniforms.fog, 1 );
-							_gl.uniform1f( program.uniforms.fogDensity, scene.fog.density );
-							_gl.uniform3f( program.uniforms.fogColor, scene.fog.color.r, scene.fog.color.g, scene.fog.color.b );
+							_gl.uniform1f( uniforms.fog, 1 );
+							_gl.uniform1f( uniforms.fogNear, scene.fog.near );
+							_gl.uniform1f( uniforms.fogFar, scene.fog.far );
+							_gl.uniform3f( uniforms.fogColor, scene.fog.color.r, scene.fog.color.g, scene.fog.color.b );
 
 
 						} else {
 						} else {
 
 
-							_gl.uniform1i( program.uniforms.fog, 0 );
+							_gl.uniform1f( uniforms.fog, 0 );
 
 
 						}
 						}
 
 
-					}
+						// material
 
 
-					// materials
+						if ( material instanceof THREE.MeshBasicMaterial ||
+						material instanceof THREE.MeshLambertMaterial ||
+						material instanceof THREE.MeshPhongMaterial ) {
 
 
-					if ( material instanceof THREE.MeshBasicMaterial ||
-					material instanceof THREE.MeshLambertMaterial ||
-					material instanceof THREE.MeshPhongMaterial ) {
+							_gl.uniform3f( uniforms.mColor, material.color.r, material.color.g, material.color.b );
+							_gl.uniform1f( uniforms.mOpacity, material.opacity );
 
 
-						_gl.uniform3f( program.uniforms.mColor, material.color.r, material.color.g, material.color.b );
-						_gl.uniform1f( program.uniforms.mOpacity, material.opacity );
+							if ( material.map ) {
 
 
-						if ( material.map ) {
+								setTexture( material.map, 0 );
+								_gl.uniform1i( uniforms.tMap, 0 );
 
 
-							setTexture( material.map, 0 );
-							_gl.uniform1i( program.uniforms.tMap, 0 );
+							}
 
 
-						}
+							if ( material.env_map ) {
+
+								setTexture( material.env_map, 1 );
+								_gl.uniform1i( uniforms.tSpherical, 1 );
 
 
-					} else if ( material instanceof THREE.MeshNormalMaterial ) {
+							}
 
 
-						_gl.uniform1f( program.uniforms.mOpacity, material.opacity );
+						} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
 
-					} else if ( material instanceof THREE.MeshDepthMaterial ) {
+							_gl.uniform1f( uniforms.mOpacity, material.opacity );
 
 
-						_gl.uniform1f( program.uniforms.m2Near, material.__2near );
-						_gl.uniform1f( program.uniforms.mFarPlusNear, material.__farPlusNear );
-						_gl.uniform1f( program.uniforms.mFarMinusNear, material.__farMinusNear );
-						_gl.uniform1f( program.uniforms.mOpacity, material.opacity );
+						} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
 
-					}
+							_gl.uniform1f( uniforms.mNear, camera.near );
+							_gl.uniform1f( uniforms.mFar, camera.far );
+							_gl.uniform1f( uniforms.mOpacity, material.opacity );
 
 
-					_gl.uniform3f( program.uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+						}
 
 
-					_gl.uniformMatrix4fv( program.uniforms.viewMatrix, false, _viewMatrixArray );
-					_gl.uniformMatrix4fv( program.uniforms.projectionMatrix, false, _projectionMatrixArray );
-					_gl.uniformMatrix4fv( program.uniforms.objectMatrix, false, _objectMatrixArray );
-					_gl.uniformMatrix4fv( program.uniforms.modelViewMatrix, false, _modelViewMatrixArray );
-					_gl.uniformMatrix3fv( program.uniforms.normalMatrix, false, _normalMatrixArray );
+						_gl.uniform3f( uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+						_gl.uniformMatrix4fv( uniforms.viewMatrix, false, _viewMatrixArray );
+						_gl.uniformMatrix4fv( uniforms.projectionMatrix, false, _projectionMatrixArray );
+
+					}
+
+					_gl.uniformMatrix4fv( uniforms.objectMatrix, false, _objectMatrixArray );
+					_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, _modelViewMatrixArray );
+					_gl.uniformMatrix3fv( uniforms.normalMatrix, false, _normalMatrixArray );
 
 
 					var buffer, buffers = geometry.__webglBuffers;
 					var buffer, buffers = geometry.__webglBuffers;
 
 
@@ -256,6 +266,14 @@ THREE.WebGLRenderer2 = function () {
 
 
 				}
 				}
 
 
+			} else if ( object instanceof THREE.Line ) {
+
+				
+
+			} else if ( object instanceof THREE.Particle ) {
+
+				
+
 			}
 			}
 
 
 		}
 		}
@@ -466,102 +484,115 @@ THREE.WebGLRenderer2 = function () {
 
 
 		function createProgram( material ) {
 		function createProgram( material ) {
 
 
-			var pvs = '', vs = '', pfs = '', fs = '',
-			identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
+			var vs, fs, identifiers = [ 'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition' ];
 
 
 			if ( material instanceof THREE.MeshBasicMaterial ||
 			if ( material instanceof THREE.MeshBasicMaterial ||
 			material instanceof THREE.MeshLambertMaterial ||
 			material instanceof THREE.MeshLambertMaterial ||
 			material instanceof THREE.MeshPhongMaterial ) {
 			material instanceof THREE.MeshPhongMaterial ) {
 
 
-				vs += 'void main() {\n';
-				fs += 'void main() {\n';
+				vs = [
+					material.map ? 'varying vec2 vUv;' : null,
+					material.env_map ? 'varying vec2 vSpherical;' : null,
 
 
-				vs += 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n';
+					'void main() {',
+						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
 
 
-				pfs += 'uniform vec3 mColor;\n';
-				pfs += 'uniform float mOpacity;\n';
+						material.map ? 'vUv = uv;' : null,
 
 
-				fs += 'gl_FragColor = vec4( mColor.xyz, mOpacity );\n';
+						material.env_map ? 'vec3 u = normalize( modelViewMatrix * vec4( position, 1.0 ) ).xyz;' : null,
+						material.env_map ? 'vec3 n = normalize( normalMatrix * normal );' : null,
+						material.env_map ? 'vec3 r = reflect( u, n );' : null,
+						material.env_map ? 'float m = 2.0 * sqrt( r.x * r.x + r.y * r.y + ( r.z + 1.0 ) * ( r.z + 1.0 ) );' : null,
+						material.env_map ? 'vSpherical.x = r.x / m + 0.5;' : null,
+						material.env_map ? 'vSpherical.y = - r.y / m + 0.5;' : null,
 
 
-				identifiers.push( 'mColor', 'mOpacity' );
+					'}'
+				].filter( removeNull ).join( '\n' );
 
 
-				// uvmap
+				fs = [
+					'uniform vec3 mColor;',
+					'uniform float mOpacity;',
 
 
-				if ( material.map ) {
+					material.map ? 'uniform sampler2D tMap;' : null,
+					material.map ? 'varying vec2 vUv;' : null,
 
 
-					pvs += 'varying vec2 vUv;\n',
-					vs += 'vUv = uv;\n',
+					material.env_map ? 'uniform sampler2D tSpherical;' : null,
+					material.env_map ? 'varying vec2 vSpherical;' : null,
 
 
-					pfs += 'uniform sampler2D tMap;\n';
-					pfs += 'varying vec2 vUv;\n';
+					material.fog ? 'uniform float fog;' : null,
+					material.fog ? 'uniform float fogNear;' : null,
+					material.fog ? 'uniform float fogFar;' : null,
+					material.fog ? 'uniform vec3 fogColor;' : null,
 
 
-					/* Premultiply alpha
-					fs += 'vec4 mapColor = texture2D( tMap, vUv );\n';
-					fs += 'mapColor.xyz *= mapColor.w;\n';
-					*/
+					'void main() {',
+						'gl_FragColor = vec4( mColor.xyz, mOpacity );',
 
 
-					fs += 'gl_FragColor *= texture2D( tMap, vUv );\n';
-
-					identifiers.push( 'tMap' );
-
-				}
+						/* Premultiply alpha
+						material.map ? 'vec4 mapColor = texture2D( tMap, vUv );' : null,
+						material.map ? 'mapColor.xyz *= mapColor.w;' : null,
+						*/
 
 
-				// fog
+						material.map ? 'gl_FragColor *= texture2D( tMap, vUv );' : null,
 
 
-				pfs += 'uniform bool fog;\n';
-				pfs += 'uniform vec3 fogColor;\n';
-				pfs += 'uniform float fogDensity;\n';
+						material.env_map ? 'gl_FragColor += texture2D( tSpherical, vSpherical );' : null,
 
 
-				fs += 'if ( fog ) {\n';
-				fs += 'const float LOG2 = 1.442695;\n';
-				fs += 'float z = gl_FragCoord.z / gl_FragCoord.w;\n';
-				fs += 'float fogFactor = exp2( - fogDensity * fogDensity * z * z * LOG2 );\n';
-				fs += 'fogFactor = clamp( fogFactor, 0.0, 1.0 );\n';
-				fs += 'gl_FragColor = mix( vec4( fogColor, 1.0 ), gl_FragColor, fogFactor );\n',
-				fs += '}\n';
+						material.fog ? 'float depth = gl_FragCoord.z / gl_FragCoord.w;' : null,
+						material.fog ? 'float fogFactor = fog * smoothstep( fogNear, fogFar, depth );' : null,
+						material.fog ? 'gl_FragColor = mix( gl_FragColor, vec4( fogColor, 1.0 ), fogFactor );' : null,
+					'}'
+				].filter( removeNull ).join( '\n' );
 
 
-				identifiers.push( 'fog', 'fogColor', 'fogDensity' );
+				identifiers.push( 'mColor', 'mOpacity' );
 
 
-				vs += '}';
-				fs += '}';
+				material.map ? identifiers.push( 'tMap' ) : null;
+				material.env_map ? identifiers.push( 'tSpherical' ) : null;
+				material.fog ? identifiers.push( 'fog', 'fogColor', 'fogNear', 'fogFar' ) : null;
 
 
 
 
 			} else if ( material instanceof THREE.MeshNormalMaterial ) {
 			} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
 
-				vs += 'void main() {\n';
-				fs += 'void main() {\n';
+				vs = [
+					'varying vec3 vNormal;',
 
 
-				pvs += 'varying vec3 vNormal;\n';
-				vs += 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n';
-				vs += 'vNormal = normalize( normalMatrix * normal );\n';
+					'void main() {',
+						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
+						'vNormal = normalize( normalMatrix * normal );',
+					'}'
+				].join( '\n' );
 
 
-				pfs += 'uniform float mOpacity;\n';
-				pfs += 'varying vec3 vNormal;\n';
-				fs += 'gl_FragColor = vec4( ( normalize( vNormal ) + 1.0 ) * 0.5, mOpacity );\n';
+				fs = [
+					'uniform float mOpacity;',
+					'varying vec3 vNormal;',
 
 
-				identifiers.push( 'mOpacity' );
+					'void main() {',
+						'gl_FragColor = vec4( ( normalize( vNormal ) + 1.0 ) * 0.5, mOpacity );',
+					'}'
+				].join( '\n' );
 
 
-				vs += '}';
-				fs += '}';
+				identifiers.push( 'mOpacity' );
 
 
 			} else if ( material instanceof THREE.MeshDepthMaterial ) {
 			} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
 
-				vs += 'void main() {\n';
-				fs += 'void main() {\n';
+				vs = [
+					'void main() {',
+						'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );',
+					'}'
 
 
-				vs += 'gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n';
+				].join( '\n' );
 
 
-				pfs += 'uniform float mOpacity;\n';
-				pfs += 'uniform float m2Near;\n';
-				pfs += 'uniform float mFarPlusNear;\n';
-				pfs += 'uniform float mFarMinusNear;\n';
-				fs += 'float w = 1.0 - ( m2Near / ( mFarPlusNear - gl_FragCoord.z * mFarMinusNear ) );\n';
-				fs += 'gl_FragColor = vec4( w, w, w, mOpacity );\n';
+				fs = [
+					'uniform float mNear;',
+					'uniform float mFar;',
+					'uniform float mOpacity;',
 
 
-				identifiers.push( 'm2Near', 'mFarPlusNear', 'mFarMinusNear', 'mOpacity' );
+					'void main() {',
+						'float depth = gl_FragCoord.z / gl_FragCoord.w;',
+						'float color = 1.0 - smoothstep( mNear, mFar, depth );',
+						'gl_FragColor = vec4( vec3( color ), 1.0 );',
+					'}'
+				].join( '\n' );
 
 
-				vs += '}';
-				fs += '}';
+				identifiers.push( 'mNear', 'mFar', 'mOpacity' );
 
 
 			} else if ( material instanceof THREE.MeshShaderMaterial ) {
 			} else if ( material instanceof THREE.MeshShaderMaterial ) {
 
 
@@ -580,7 +611,7 @@ THREE.WebGLRenderer2 = function () {
 
 
 			}
 			}
 
 
-			material.__webglProgram = compileProgram( pvs + vs, pfs + fs );
+			material.__webglProgram = compileProgram( vs, fs );
 
 
 			cacheUniformLocations( material.__webglProgram, identifiers );
 			cacheUniformLocations( material.__webglProgram, identifiers );
 			cacheAttributeLocations( material.__webglProgram, [ "position", "normal", "uv"/*, "tangent"*/ ] );
 			cacheAttributeLocations( material.__webglProgram, [ "position", "normal", "uv"/*, "tangent"*/ ] );
@@ -651,8 +682,8 @@ THREE.WebGLRenderer2 = function () {
 				alert( "Could not initialise shaders.\n" +
 				alert( "Could not initialise shaders.\n" +
 				"VALIDATE_STATUS: " + _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ) + "\n" +
 				"VALIDATE_STATUS: " + _gl.getProgramParameter( program, _gl.VALIDATE_STATUS ) + "\n" +
 				"ERROR: " + _gl.getError() + "\n\n" +
 				"ERROR: " + _gl.getError() + "\n\n" +
-				"Vertex Shader: \n" + prefix_vertex + vertex_shader + "\n\n" +
-				"Fragment Shader: \n" + prefix_fragment + fragment_shader );
+				"- Vertex Shader -\n" + prefix_vertex + vertex_shader + "\n\n" +
+				"- Fragment Shader -\n" + prefix_fragment + fragment_shader );
 
 
 			}
 			}
 
 
@@ -748,6 +779,12 @@ THREE.WebGLRenderer2 = function () {
 
 
 		}
 		}
 
 
+		function removeNull( element ) {
+
+			return element !== null;
+
+		}
+
 
 
 	};
 	};
 
 

+ 2 - 2
src/renderers/renderables/RenderableFace3.js

@@ -16,8 +16,8 @@ THREE.RenderableFace3 = function () {
 	this.normalWorld = new THREE.Vector3();
 	this.normalWorld = new THREE.Vector3();
 	this.vertexNormalsWorld = [];
 	this.vertexNormalsWorld = [];
 
 
-	this.meshMaterial = null;
-	this.faceMaterial = null;
+	this.meshMaterials = null;
+	this.faceMaterials = null;
 	this.overdraw = false;
 	this.overdraw = false;
 	this.uvs = [ null, null, null ];
 	this.uvs = [ null, null, null ];
 
 

+ 1 - 1
src/renderers/renderables/RenderableLine.js

@@ -9,6 +9,6 @@ THREE.RenderableLine = function () {
 	this.v1 = new THREE.Vertex();
 	this.v1 = new THREE.Vertex();
 	this.v2 = new THREE.Vertex();
 	this.v2 = new THREE.Vertex();
 
 
-	this.material = null;
+	this.materials = null;
 
 
 };
 };

+ 1 - 1
src/renderers/renderables/RenderableParticle.js

@@ -11,6 +11,6 @@ THREE.RenderableParticle = function () {
 	this.rotation = null;
 	this.rotation = null;
 	this.scale = new THREE.Vector2();
 	this.scale = new THREE.Vector2();
 
 
-	this.material = null;
+	this.materials = null;
 
 
 };
 };

+ 3 - 2
src/scenes/Fog.js

@@ -3,9 +3,10 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.Fog = function ( hex, density ) {
+THREE.Fog = function ( hex, near, far ) {
 
 
 	this.color = new THREE.Color( hex );
 	this.color = new THREE.Color( hex );
-	this.density = density || 0.00025;
+	this.near = near || 1;
+	this.far = far || 1000;
 
 
 };
 };

部分文件因为文件数量过多而无法显示