Przeglądaj źródła

Mergable: added morph target support.

Mikael Emtinger 14 lat temu
rodzic
commit
0750cf1742
35 zmienionych plików z 2189 dodań i 973 usunięć
  1. 67 46
      build/Three.js
  2. 15 15
      build/custom/ThreeCanvas.js
  3. 13 13
      build/custom/ThreeDOM.js
  4. 2 2
      build/custom/ThreeExtras.js
  5. 15 15
      build/custom/ThreeSVG.js
  6. 125 124
      build/custom/ThreeWebGL.js
  7. 2 1
      examples/js/Detector.js
  8. 80 84
      examples/js/gui/gui.css
  9. 523 493
      examples/js/gui/gui.full.js
  10. 29 27
      examples/js/gui/gui.min.js
  11. 3 3
      examples/misc_sound.html
  12. 4 1
      examples/misc_ubiquity_test.html
  13. 4 1
      examples/webgl_geometry_hierarchy.html
  14. 4 1
      examples/webgl_geometry_hierarchy2.html
  15. 3 3
      examples/webgl_lines_colors.html
  16. 5 6
      examples/webgl_materials_video.html
  17. 1 1
      examples/webgl_particles_billboards.html
  18. 11 1
      examples/webgl_particles_billboards_colors.html
  19. 4 1
      examples/webgl_performance.html
  20. 4 4
      examples/webgl_postprocessing.html
  21. 3 3
      examples/webgl_ribbons.html
  22. 1 0
      examples/webgl_sandbox.html
  23. 34 8
      src/cameras/QuakeCamera.js
  24. 5 0
      src/extras/io/Loader.js
  25. 2 0
      src/materials/ParticleBasicMaterial.js
  26. 1 0
      src/materials/Texture.js
  27. 10 5
      src/renderers/WebGLRenderer.js
  28. 840 0
      src/renderers/WebGLShaders.js
  29. 1 1
      src/scenes/FogExp2.js
  30. 2 0
      utils/build.py
  31. 29 23
      utils/exporters/blender/2.49/convert_obj_threejs_slim.py
  32. 0 2
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
  33. 29 23
      utils/exporters/cinema4d/convert_obj_threejs_slim.py
  34. 16 15
      utils/exporters/convert_obj_threejs_slim.py
  35. 302 51
      utils/exporters/max/ThreeJSExporter.ms

+ 67 - 46
build/Three.js

@@ -81,13 +81,13 @@ THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var d=this.data.hierarc
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
 !1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};
-THREE.QuakeCamera=function(a){function b(c,d){return function(){d.apply(c,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==
-undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phy=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=
-!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();c.stopPropagation();switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};
-this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?
-this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lat=Math.max(-85,Math.min(85,this.lat));
-this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var c=this.target.position,d=this.position;c.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=d.y+100*Math.cos(this.phi);c.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),
-!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
+THREE.QuakeCamera=function(a){function b(c,d){return function(){d.apply(c,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.dragToLook=!1;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
+a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phy=this.lon=this.lat=
+this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();c.stopPropagation();if(!this.dragToLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(!this.dragToLook)switch(c.button){case 0:this.moveForward=
+!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
+!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);
+var c=this.lookSpeed;this.dragToLook&&!this.mouseDragOn&&(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;c=this.target.position;var d=this.position;c.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=d.y+100*Math.cos(this.phi);c.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},
+!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
 THREE.QuakeCamera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
 THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
@@ -112,8 +112,8 @@ undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=
 THREE.MeshShaderMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.vertexShader=this.fragmentShader="void main() {}";this.uniforms={};this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;if(a){if(a.fragmentShader!==undefined)this.fragmentShader=a.fragmentShader;if(a.vertexShader!==undefined)this.vertexShader=
 a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;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.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==undefined)this.wireframeLinewidth=a.wireframeLinewidth;if(a.wireframeLinecap!==undefined)this.wireframeLinecap=a.wireframeLinecap;if(a.wireframeLinejoin!==
 undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning;if(a.morphTargets!==undefined)this.morphTargets=a.morphTargets}};
-THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
-undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
+a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
 THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,b,c,d,f,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==undefined?f:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};
 THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;
 THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;
@@ -144,7 +144,7 @@ THREE.VertexAnimatedMesh.prototype.play=function(a){this.time=Math.max(0,a%this.
 THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
-THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
+THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b!==undefined?b:2.5E-4};
 THREE.Projector=function(){function a(M,e){return e.z-M.z}function b(M,e){var X=0,S=1,da=M.z+M.w,ga=e.z+e.w,I=-M.z+M.w,ca=-e.z+e.w;if(da>=0&&ga>=0&&I>=0&&ca>=0)return!0;else if(da<0&&ga<0||I<0&&ca<0)return!1;else{if(da<0)X=Math.max(X,da/(da-ga));else ga<0&&(S=Math.min(S,da/(da-ga)));if(I<0)X=Math.max(X,I/(I-ca));else ca<0&&(S=Math.min(S,I/(I-ca)));if(S<X)return!1;else{M.lerpSelf(e,X);e.lerpSelf(M,1-S);return!0}}}var c,d,f=[],g,h,j,k=[],o,q,x=[],u,t,z=[],B=new THREE.Vector4,D=new THREE.Vector4,v=new THREE.Matrix4,
 E=new THREE.Matrix4,w=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Vector4,L=new THREE.Vector4,Y;this.projectObjects=function(M,e,X){e=[];var S,da,ga;d=0;da=M.objects;M=0;for(S=da.length;M<S;M++){ga=da[M];var I;if(!(I=!ga.visible))if(I=ga instanceof THREE.Mesh){a:{I=void 0;for(var ca=ga.matrixWorld,za=-ga.geometry.boundingSphere.radius*Math.max(ga.scale.x,Math.max(ga.scale.y,ga.scale.z)),ea=0;ea<6;ea++){I=w[ea].x*ca.n14+
 w[ea].y*ca.n24+w[ea].z*ca.n34+w[ea].w;if(I<=za){I=!1;break a}}I=!0}I=!I}if(!I){c=f[d]=f[d]||new THREE.RenderableObject;B.copy(ga.position);v.multiplyVector3(B);c.object=ga;c.z=B.z;e.push(c);d++}}X&&e.sort(a);return e};this.projectScene=function(M,e,X){var S=[],da=e.near,ga=e.far,I,ca,za,ea,xa,ja,ha,va,Aa,ia,$,qa,ra,Q,ma,ta;j=q=t=0;e.matrixAutoUpdate&&e.update();v.multiply(e.projectionMatrix,e.matrixWorldInverse);w[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);w[1].set(v.n41+v.n11,v.n42+
@@ -192,45 +192,66 @@ $;)if(ma=Q.materials[ia++]){qa=u;ra=t;ta=ea++;if(ga[ta]==null){ga[ta]=document.c
 "; stroke-width: "+ma.linewidth+"; stroke-opacity: "+ma.opacity+"; stroke-linecap: "+ma.linecap+"; stroke-linejoin: "+ma.linejoin);j.appendChild(I)}}}}else if(Q instanceof THREE.RenderableFace3){u=Q.v1;t=Q.v2;z=Q.v3;u.positionScreen.x*=q;u.positionScreen.y*=-x;t.positionScreen.x*=q;t.positionScreen.y*=-x;z.positionScreen.x*=q;z.positionScreen.y*=-x;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(z.positionScreen.x,z.positionScreen.y);
 if(D.instersects(v)){ia=0;for($=Q.meshMaterials.length;ia<$;){ma=Q.meshMaterials[ia++];if(ma instanceof THREE.MeshFaceMaterial){qa=0;for(ra=Q.faceMaterials.length;qa<ra;)(ma=Q.faceMaterials[qa++])&&b(u,t,z,Q,ma,ja)}else ma&&b(u,t,z,Q,ma,ja)}}}else if(Q instanceof THREE.RenderableFace4){u=Q.v1;t=Q.v2;z=Q.v3;B=Q.v4;u.positionScreen.x*=q;u.positionScreen.y*=-x;t.positionScreen.x*=q;t.positionScreen.y*=-x;z.positionScreen.x*=q;z.positionScreen.y*=-x;B.positionScreen.x*=q;B.positionScreen.y*=-x;v.addPoint(u.positionScreen.x,
 u.positionScreen.y);v.addPoint(t.positionScreen.x,t.positionScreen.y);v.addPoint(z.positionScreen.x,z.positionScreen.y);v.addPoint(B.positionScreen.x,B.positionScreen.y);if(D.instersects(v)){ia=0;for($=Q.meshMaterials.length;ia<$;){ma=Q.meshMaterials[ia++];if(ma instanceof THREE.MeshFaceMaterial){qa=0;for(ra=Q.faceMaterials.length;qa<ra;)(ma=Q.faceMaterials[qa++])&&c(u,t,z,B,Q,ma,ja)}else ma&&c(u,t,z,B,Q,ma,ja)}}}}}};
+THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
+envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
+envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
+map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
+lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
+lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
+color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};
+THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},lightMap:{type:"t",value:2,texture:null},envMap:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",
+value:1},ambientLightColor:{type:"fv",value:[]},directionalLightDirection:{type:"fv",value:[]},directionalLightColor:{type:"fv",value:[]},pointLightPosition:{type:"fv",value:[]},pointLightColor:{type:"fv",value:[]}},particle:{psColor:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:0,texture:null},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}}};
+THREE.ShaderLib={depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},fragmentShader:"uniform float mNear;\nuniform float mFar;\nuniform float opacity;\nvoid main() {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat color = 1.0 - smoothstep( mNear, mFar, depth );\ngl_FragColor = vec4( vec3( color ), opacity );\n}",vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"},normal:{uniforms:{opacity:{type:"f",
+value:1}},fragmentShader:"uniform float opacity;\nvarying vec3 vNormal;\nvoid main() {\ngl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );\n}",vertexShader:"varying vec3 vNormal;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\ngl_Position = projectionMatrix * mvPosition;\n}"},basic:{uniforms:THREE.UniformsLib.common,fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,
+THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:[THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
+THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},lambert:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nvarying vec3 vLightWeighting;",
+THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( diffuse, opacity );\ngl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["varying vec3 vLightWeighting;",
+THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"vec3 transformedNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.lights_vertex,
+THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},phong:{uniforms:Uniforms.merge([THREE.UniformsLib.common,THREE.UniformsLib.lights,{ambient:{type:"c",value:new THREE.Color(328965)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform vec3 ambient;\nuniform vec3 specular;\nuniform float shininess;\nvarying vec3 vLightWeighting;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,
+THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightWeighting, 1.0 );",THREE.ShaderChunk.lights_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.lightmap_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",
+THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
+THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",
+THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
 THREE.WebGLRenderer=function(a){function b(l,A,p){var n,m,C,y=l.vertices,G=y.length,N=l.colors,R=N.length,F=l.__vertexArray,aa=l.__colorArray,ka=l.__sortArray,na=l.__dirtyVertices,wa=l.__dirtyColors;if(p.sortParticles){Aa.multiplySelf(p.matrixWorld);for(n=0;n<G;n++){m=y[n].position;qa.copy(m);Aa.multiplyVector3(qa);ka[n]=[qa.z,n]}ka.sort(function(la,Ca){return Ca[0]-la[0]});for(n=0;n<G;n++){m=y[ka[n][1]].position;C=n*3;F[C]=m.x;F[C+1]=m.y;F[C+2]=m.z}for(n=0;n<R;n++){C=n*3;color=N[ka[n][1]];aa[C]=
 color.r;aa[C+1]=color.g;aa[C+2]=color.b}}else{if(na)for(n=0;n<G;n++){m=y[n].position;C=n*3;F[C]=m.x;F[C+1]=m.y;F[C+2]=m.z}if(wa)for(n=0;n<R;n++){color=N[n];C=n*3;aa[C]=color.r;aa[C+1]=color.g;aa[C+2]=color.b}}if(na||p.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,F,A)}if(wa||p.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,aa,A)}}function c(l,A){l.fragmentShader=A.fragmentShader;l.vertexShader=A.vertexShader;
-l.uniforms=Uniforms.clone(A.uniforms)}function d(l,A,p,n,m){n.program||da.initMaterial(n,A,p,m);var C=n.program,y=C.uniforms,G=n.uniforms;if(C!=X){e.useProgram(C);X=C;e.uniformMatrix4fv(y.projectionMatrix,!1,ia)}if(p&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){G.fogNear.value=p.near;
+l.uniforms=Uniforms.clone(A.uniforms)}function d(l,A,p,n,m){n.program||da.initMaterial(n,A,p,m);var C=n.program,y=C.uniforms,G=n.uniforms;if(C!=X){e.useProgram(C);X=C}e.uniformMatrix4fv(y.projectionMatrix,!1,ia);if(p&&(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial||n instanceof THREE.LineBasicMaterial||n instanceof THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(p.color.hex);if(p instanceof THREE.Fog){G.fogNear.value=p.near;
 G.fogFar.value=p.far}else if(p instanceof THREE.FogExp2)G.fogDensity.value=p.density}if(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial){var N,R,F=0,aa=0,ka=0,na,wa,la,Ca=ra,Da=Ca.directional.colors,Pa=Ca.directional.positions,K=Ca.point.colors,Na=Ca.point.positions,Ia=0,Oa=0;p=R=R=0;for(N=A.length;p<N;p++){R=A[p];na=R.color;wa=R.position;la=R.intensity;if(R instanceof THREE.AmbientLight){F+=na.r;aa+=na.g;ka+=na.b}else if(R instanceof THREE.DirectionalLight){R=Ia*3;Da[R]=
 na.r*la;Da[R+1]=na.g*la;Da[R+2]=na.b*la;Pa[R]=wa.x;Pa[R+1]=wa.y;Pa[R+2]=wa.z;Ia+=1}else if(R instanceof THREE.PointLight){R=Oa*3;K[R]=na.r*la;K[R+1]=na.g*la;K[R+2]=na.b*la;Na[R]=wa.x;Na[R+1]=wa.y;Na[R+2]=wa.z;Oa+=1}}for(p=Ia*3;p<Da.length;p++)Da[p]=0;for(p=Oa*3;p<K.length;p++)K[p]=0;Ca.point.length=Oa;Ca.directional.length=Ia;Ca.ambient[0]=F;Ca.ambient[1]=aa;Ca.ambient[2]=ka;A=ra;G.enableLighting.value=A.directional.length+A.point.length;G.ambientLightColor.value=A.ambient;G.directionalLightColor.value=
 A.directional.colors;G.directionalLightDirection.value=A.directional.positions;G.pointLightColor.value=A.point.colors;G.pointLightPosition.value=A.point.positions}if(n instanceof THREE.MeshBasicMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity;G.map.texture=n.map;G.lightMap.texture=n.lightMap;G.envMap.texture=n.envMap;G.reflectivity.value=n.reflectivity;
-G.refractionRatio.value=n.refractionRatio;G.combine.value=n.combine;G.useRefract.value=n.envMap&&n.envMap.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity;G.size.value=n.size;G.map.texture=n.map}else if(n instanceof
-THREE.MeshPhongMaterial){G.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);G.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);G.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)G.opacity.value=n.opacity;for(var T in G)if(F=C.uniforms[T]){p=G[T];N=p.type;A=p.value;if(N=="i")e.uniform1i(F,A);else if(N=="f")e.uniform1f(F,A);else if(N=="fv1")e.uniform1fv(F,
-A);else if(N=="fv")e.uniform3fv(F,A);else if(N=="v2")e.uniform2f(F,A.x,A.y);else if(N=="v3")e.uniform3f(F,A.x,A.y,A.z);else if(N=="c")e.uniform3f(F,A.r,A.g,A.b);else if(N=="t"){e.uniform1i(F,A);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(p.needsUpdate){if(p.__wasSetOnce){e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(N=0;N<6;++N)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,0,0,e.RGBA,e.UNSIGNED_BYTE,p.image[N])}else{p.image.__webGLTextureCube=
-e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(N=0;N<6;++N)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image[N]);p.__wasSetOnce=!0}E(e.TEXTURE_CUBE_MAP,p,p.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,p.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,
-0,0,0,e.RGBA,e.UNSIGNED_BYTE,p.image)}else{p.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,p.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image);p.__wasSetOnce=!0}E(e.TEXTURE_2D,p,p.image);e.bindTexture(e.TEXTURE_2D,null);p.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_2D,p.__webGLTexture)}}}e.uniformMatrix4fv(y.modelViewMatrix,!1,m._modelViewMatrixArray);e.uniformMatrix3fv(y.normalMatrix,!1,m._normalMatrixArray);(n instanceof THREE.MeshShaderMaterial||
-n instanceof THREE.MeshPhongMaterial||n.envMap)&&e.uniform3f(y.cameraPosition,l.position.x,l.position.y,l.position.z);(n instanceof THREE.MeshShaderMaterial||n.envMap||n.skinning)&&e.uniformMatrix4fv(y.objectMatrix,!1,m._objectMatrixArray);(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial||n.skinning)&&e.uniformMatrix4fv(y.viewMatrix,!1,$);if(n.skinning){e.uniformMatrix4fv(y.cameraInverseMatrix,!1,$);e.uniformMatrix4fv(y.boneGlobalMatrices,
-!1,m.boneMatrices)}return C}function f(l,A,p,n,m,C){l=d(l,A,p,n,C).attributes;if(n.morphTargets){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLMorphTargetsBuffers[C.morphTargetBase]);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);A=[];p=-1;var y=0,G=C.morphTargetInfluences,N,R=G.length,F=0;for(A[C.morphTargetBase]=1;F<n.numSupportedMorphTargets;){for(N=0;N<R;N++)if(!A[N]&&p<G[N]){y=N;p=G[y]}e.bindBuffer(e.ARRAY_BUFFER,m.__webGLMorphTargetsBuffers[y]);e.vertexAttribPointer(l["morphTarget"+F],3,e.FLOAT,
-!1,0,0);C.__webGLMorphTargetInfluences[F]=p;A[y]=1;p=-1;F++}e.uniform1fv(n.program.uniforms.morphTargetInfluences,C.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0)}if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,3,e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,
-m.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(m.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(m.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);if(n.skinning&&l.skinVertexA>=0&&
-l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,4,e.FLOAT,!1,0,0)}if(C instanceof
-THREE.Mesh)if(n.wireframe){e.lineWidth(n.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);e.drawElements(e.LINES,m.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,m.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(C instanceof THREE.Line){C=C.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(n.linewidth);e.drawArrays(C,0,m.__webGLLineCount)}else if(C instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,
-0,m.__webGLParticleCount);else C instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,m.__webGLVertexCount)}function g(l,A){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.position);e.vertexAttribPointer(A.attributes.position,3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,
-l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.normal);e.vertexAttribPointer(A.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(ga!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ga=l.doubleSided}if(I!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);I=l.flipSided}}function j(l){if(za!=l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);
-za=l}}function k(l){va[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);va[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);va[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);va[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);va[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);va[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var A;for(l=0;l<6;l++){A=va[l];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z))}}function o(l){for(var A=l.matrixWorld,p=-l.geometry.boundingSphere.radius*
-Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),n=0;n<6;n++){l=va[n].x*A.n14+va[n].y*A.n24+va[n].z*A.n34+va[n].w;if(l<=p)return!1}return!0}function q(l,A){l.list[l.count]=A;l.count+=1}function x(l){var A,p,n=l.object,m=l.opaque,C=l.transparent;C.count=0;l=m.count=0;for(A=n.materials.length;l<A;l++){p=n.materials[l];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?q(C,p):q(m,p)}}function u(l){var A,p,n,m,C=l.object,y=l.buffer,G=l.opaque,N=l.transparent;N.count=0;l=G.count=0;for(n=C.materials.length;l<
-n;l++){A=C.materials[l];if(A instanceof THREE.MeshFaceMaterial){A=0;for(p=y.materials.length;A<p;A++)(m=y.materials[A])&&(m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?q(N,m):q(G,m))}else{m=A;m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?q(N,m):q(G,m)}}}function t(l,A){return A.z-l.z}function z(l,A){l._modelViewMatrix.multiplyToArray(A.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}
-function B(l){function A(ka){var na=[];p=0;for(n=ka.length;p<n;p++)ka[p]==undefined?na.push("undefined"):na.push(ka[p].id);return na.join("_")}var p,n,m,C,y,G,N,R,F={},aa=l.morphTargets!==undefined?l.morphTargets.length:0;l.geometryGroups={};m=0;for(C=l.faces.length;m<C;m++){y=l.faces[m];G=y.materials;N=A(G);F[N]==undefined&&(F[N]={hash:N,counter:0});R=F[N].hash+"_"+F[N].counter;l.geometryGroups[R]==undefined&&(l.geometryGroups[R]={faces:[],materials:G,vertices:0,numMorphTargets:aa});y=y instanceof
-THREE.Face3?3:4;if(l.geometryGroups[R].vertices+y>65535){F[N].counter+=1;R=F[N].hash+"_"+F[N].counter;l.geometryGroups[R]==undefined&&(l.geometryGroups[R]={faces:[],materials:G,vertices:0,numMorphTargets:aa})}l.geometryGroups[R].faces.push(m);l.geometryGroups[R].vertices+=y}}function D(l,A,p){l.push({buffer:A,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(l){if(l!=ca){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,
-e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}ca=l}}function E(l,A,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){e.texParameteri(l,e.TEXTURE_WRAP_S,Y(A.wrapS));e.texParameteri(l,e.TEXTURE_WRAP_T,Y(A.wrapT));e.texParameteri(l,e.TEXTURE_MAG_FILTER,
-Y(A.magFilter));e.texParameteri(l,e.TEXTURE_MIN_FILTER,Y(A.minFilter));e.generateMipmap(l)}else{e.texParameteri(l,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(l,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(l,e.TEXTURE_MAG_FILTER,L(A.magFilter));e.texParameteri(l,e.TEXTURE_MIN_FILTER,L(A.minFilter))}}function w(l){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,
-l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Y(l.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Y(l.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Y(l.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Y(l.minFilter));e.texImage2D(e.TEXTURE_2D,0,Y(l.format),l.width,l.height,0,Y(l.format),Y(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,
-l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var A,p;if(l){A=l.__webGLFramebuffer;p=l.width;l=l.height}else{A=null;p=ja;l=ha}if(A!=S){e.bindFramebuffer(e.FRAMEBUFFER,A);e.viewport(ea,xa,p,l);S=A}}function O(l,A){var p;if(l=="fragment")p=
-e.createShader(e.FRAGMENT_SHADER);else l=="vertex"&&(p=e.createShader(e.VERTEX_SHADER));e.shaderSource(p,A);e.compileShader(p);if(!e.getShaderParameter(p,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(p));return null}return p}function L(l){switch(l){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return e.LINEAR}}function Y(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;
-case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;
-case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),
-e,X=null,S=null,da=this,ga=null,I=null,ca=null,za=null,ea=0,xa=0,ja=0,ha=0,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,ia=new Float32Array(16),$=new Float32Array(16),qa=new THREE.Vector4,ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Q=!0,ma=new THREE.Color(0),ta=0;if(a){if(a.antialias!==undefined)Q=a.antialias;a.clearColor!==undefined&&ma.setHex(a.clearColor);
-if(a.clearAlpha!==undefined)ta=a.clearAlpha}this.maxMorphTargets=8;this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(l,A,p){try{if(!(e=M.getContext("experimental-webgl",{antialias:l})))throw"Error creating WebGL context.";}catch(n){console.error(n)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(A.r,A.g,A.b,p);_cullEnabled=
-!0})(Q,ma,ta);this.context=e;this.setSize=function(l,A){M.width=l;M.height=A;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(l,A,p,n){ea=l;xa=A;ja=p;ha=n;e.viewport(ea,xa,ja,ha)};this.setScissor=function(l,A,p,n){e.scissor(l,A,p,n)};this.enableScissorTest=function(l){l?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(l){e.depthMask(l)};this.setClearColorHex=function(l,A){var p=new THREE.Color(l);e.clearColor(p.r,p.g,p.b,A)};this.setClearColor=
-function(l,A){e.clearColor(l.r,l.g,l.b,A)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,A,p,n){var m,C;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);
-else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var y,G,N,R;C=N=R=0;for(y=A.length;C<y;C++){G=A[C];G instanceof THREE.DirectionalLight&&N++;G instanceof THREE.PointLight&&R++}if(R+N<=4)A=N;else{A=Math.ceil(4*N/(R+N));R=4-A}C={directional:A,point:R};y=50;if(n!==undefined&&n instanceof THREE.SkinnedMesh)y=n.bones.length;R=l.fragmentShader;A=l.vertexShader;y={fog:p,map:l.map,envMap:l.envMap,lightMap:l.lightMap,
-vertexColors:l.vertexColors,skinning:l.skinning,morphTargets:l.morphTargets,maxMorphTargets:1,maxDirLights:C.directional,maxPointLights:C.point,maxBones:y};p=e.createProgram();C=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP":"",y.vertexColors?
-"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,"#define MAX_BONES "+y.maxBones,y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP":"",y.vertexColors?"#define USE_COLOR":"",y.skinning?"#define USE_SKINNING":"",y.morphTargets?"#define USE_MORPHTARGETS":
-"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+G.refractionRatio.value=n.refractionRatio;G.combine.value=n.combine;G.useRefract.value=n.envMap&&n.envMap.mapping instanceof THREE.CubeRefractionMapping}if(n instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity}else if(n instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(n.color.r*n.opacity,n.color.g*n.opacity,n.color.b*n.opacity);G.opacity.value=n.opacity;G.size.value=n.size;G.scale.value=M.height/
+2;G.map.texture=n.map}else if(n instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(n.ambient.r,n.ambient.g,n.ambient.b);G.specular.value.setRGB(n.specular.r,n.specular.g,n.specular.b);G.shininess.value=n.shininess}else if(n instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=n.opacity}else if(n instanceof THREE.MeshNormalMaterial)G.opacity.value=n.opacity;for(var T in G)if(F=C.uniforms[T]){p=G[T];N=p.type;A=p.value;if(N=="i")e.uniform1i(F,A);else if(N==
+"f")e.uniform1f(F,A);else if(N=="fv1")e.uniform1fv(F,A);else if(N=="fv")e.uniform3fv(F,A);else if(N=="v2")e.uniform2f(F,A.x,A.y);else if(N=="v3")e.uniform3f(F,A.x,A.y,A.z);else if(N=="c")e.uniform3f(F,A.r,A.g,A.b);else if(N=="t"){e.uniform1i(F,A);if(p=p.texture)if(p.image instanceof Array&&p.image.length==6){if(p.image.length==6){if(p.needsUpdate){if(p.__wasSetOnce){e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(N=0;N<6;++N)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,0,0,e.RGBA,
+e.UNSIGNED_BYTE,p.image[N])}else{p.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube);for(N=0;N<6;++N)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+N,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image[N]);p.__wasSetOnce=!0}E(e.TEXTURE_CUBE_MAP,p,p.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);p.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webGLTextureCube)}}else{if(p.needsUpdate){if(p.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
+p.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,p.image)}else{p.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,p.__webGLTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image);p.__wasSetOnce=!0}E(e.TEXTURE_2D,p,p.image);e.bindTexture(e.TEXTURE_2D,null);p.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_2D,p.__webGLTexture)}}}e.uniformMatrix4fv(y.modelViewMatrix,!1,m._modelViewMatrixArray);e.uniformMatrix3fv(y.normalMatrix,
+!1,m._normalMatrixArray);(n instanceof THREE.MeshShaderMaterial||n instanceof THREE.MeshPhongMaterial||n.envMap)&&e.uniform3f(y.cameraPosition,l.position.x,l.position.y,l.position.z);(n instanceof THREE.MeshShaderMaterial||n.envMap||n.skinning)&&e.uniformMatrix4fv(y.objectMatrix,!1,m._objectMatrixArray);(n instanceof THREE.MeshPhongMaterial||n instanceof THREE.MeshLambertMaterial||n instanceof THREE.MeshShaderMaterial||n.skinning)&&e.uniformMatrix4fv(y.viewMatrix,!1,$);if(n.skinning){e.uniformMatrix4fv(y.cameraInverseMatrix,
+!1,$);e.uniformMatrix4fv(y.boneGlobalMatrices,!1,m.boneMatrices)}return C}function f(l,A,p,n,m,C){if(n.opacity!=0){l=d(l,A,p,n,C).attributes;if(n.morphTargets){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLMorphTargetsBuffers[C.morphTargetBase]);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);A=[];p=-1;var y=0,G=C.morphTargetInfluences,N,R=G.length,F=0;for(A[C.morphTargetBase]=1;F<n.numSupportedMorphTargets;){for(N=0;N<R;N++)if(!A[N]&&p<G[N]){y=N;p=G[y]}e.bindBuffer(e.ARRAY_BUFFER,m.__webGLMorphTargetsBuffers[y]);
+e.vertexAttribPointer(l["morphTarget"+F],3,e.FLOAT,!1,0,0);C.__webGLMorphTargetInfluences[F]=p;A[y]=1;p=-1;F++}e.uniform1fv(n.program.uniforms.morphTargetInfluences,C.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0)}if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,
+3,e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(m.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(m.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);
+if(n.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,m.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,
+4,e.FLOAT,!1,0,0)}if(C instanceof THREE.Mesh)if(n.wireframe){e.lineWidth(n.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webGLLineBuffer);e.drawElements(e.LINES,m.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,m.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(C instanceof THREE.Line){C=C.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(n.linewidth);e.drawArrays(C,0,m.__webGLLineCount)}else if(C instanceof
+THREE.ParticleSystem)e.drawArrays(e.POINTS,0,m.__webGLParticleCount);else C instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,m.__webGLVertexCount)}}function g(l,A){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.position);e.vertexAttribPointer(A.attributes.position,
+3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.normal);e.vertexAttribPointer(A.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(ga!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ga=l.doubleSided}if(I!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);I=l.flipSided}}function j(l){if(za!=
+l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);za=l}}function k(l){va[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);va[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);va[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);va[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);va[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);va[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var A;for(l=0;l<6;l++){A=va[l];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*
+A.z))}}function o(l){for(var A=l.matrixWorld,p=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),n=0;n<6;n++){l=va[n].x*A.n14+va[n].y*A.n24+va[n].z*A.n34+va[n].w;if(l<=p)return!1}return!0}function q(l,A){l.list[l.count]=A;l.count+=1}function x(l){var A,p,n=l.object,m=l.opaque,C=l.transparent;C.count=0;l=m.count=0;for(A=n.materials.length;l<A;l++){p=n.materials[l];p.opacity&&p.opacity<1||p.blending!=THREE.NormalBlending?q(C,p):q(m,p)}}function u(l){var A,p,n,m,C=l.object,
+y=l.buffer,G=l.opaque,N=l.transparent;N.count=0;l=G.count=0;for(n=C.materials.length;l<n;l++){A=C.materials[l];if(A instanceof THREE.MeshFaceMaterial){A=0;for(p=y.materials.length;A<p;A++)(m=y.materials[A])&&(m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?q(N,m):q(G,m))}else{m=A;m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?q(N,m):q(G,m)}}}function t(l,A){return A.z-l.z}function z(l,A){l._modelViewMatrix.multiplyToArray(A.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);
+THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function B(l){function A(ka){var na=[];p=0;for(n=ka.length;p<n;p++)ka[p]==undefined?na.push("undefined"):na.push(ka[p].id);return na.join("_")}var p,n,m,C,y,G,N,R,F={},aa=l.morphTargets!==undefined?l.morphTargets.length:0;l.geometryGroups={};m=0;for(C=l.faces.length;m<C;m++){y=l.faces[m];G=y.materials;N=A(G);F[N]==undefined&&(F[N]={hash:N,counter:0});R=F[N].hash+"_"+F[N].counter;l.geometryGroups[R]==undefined&&
+(l.geometryGroups[R]={faces:[],materials:G,vertices:0,numMorphTargets:aa});y=y instanceof THREE.Face3?3:4;if(l.geometryGroups[R].vertices+y>65535){F[N].counter+=1;R=F[N].hash+"_"+F[N].counter;l.geometryGroups[R]==undefined&&(l.geometryGroups[R]={faces:[],materials:G,vertices:0,numMorphTargets:aa})}l.geometryGroups[R].faces.push(m);l.geometryGroups[R].vertices+=y}}function D(l,A,p){l.push({buffer:A,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(l){if(l!=ca){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);
+e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}ca=l}}function E(l,A,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){e.texParameteri(l,e.TEXTURE_WRAP_S,
+Y(A.wrapS));e.texParameteri(l,e.TEXTURE_WRAP_T,Y(A.wrapT));e.texParameteri(l,e.TEXTURE_MAG_FILTER,Y(A.magFilter));e.texParameteri(l,e.TEXTURE_MIN_FILTER,Y(A.minFilter));e.generateMipmap(l)}else{e.texParameteri(l,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(l,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(l,e.TEXTURE_MAG_FILTER,L(A.magFilter));e.texParameteri(l,e.TEXTURE_MIN_FILTER,L(A.minFilter))}}function w(l){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=
+e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Y(l.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Y(l.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Y(l.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Y(l.minFilter));e.texImage2D(e.TEXTURE_2D,
+0,Y(l.format),l.width,l.height,0,Y(l.format),Y(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var A,p;if(l){A=l.__webGLFramebuffer;p=l.width;l=l.height}else{A=null;p=ja;l=ha}if(A!=S){e.bindFramebuffer(e.FRAMEBUFFER,
+A);e.viewport(ea,xa,p,l);S=A}}function O(l,A){var p;if(l=="fragment")p=e.createShader(e.FRAGMENT_SHADER);else l=="vertex"&&(p=e.createShader(e.VERTEX_SHADER));e.shaderSource(p,A);e.compileShader(p);if(!e.getShaderParameter(p,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(p));return null}return p}function L(l){switch(l){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return e.LINEAR}}
+function Y(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
+case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}
+var M=document.createElement("canvas"),e,X=null,S=null,da=this,ga=null,I=null,ca=null,za=null,ea=0,xa=0,ja=0,ha=0,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,ia=new Float32Array(16),$=new Float32Array(16),qa=new THREE.Vector4,ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},Q=!0,ma=new THREE.Color(0),ta=0;if(a){if(a.antialias!==undefined)Q=a.antialias;
+a.clearColor!==undefined&&ma.setHex(a.clearColor);if(a.clearAlpha!==undefined)ta=a.clearAlpha}this.maxMorphTargets=8;this.domElement=M;this.autoClear=!0;this.sortObjects=!0;(function(l,A,p){try{if(!(e=M.getContext("experimental-webgl",{antialias:l})))throw"Error creating WebGL context.";}catch(n){console.error(n)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);
+e.clearColor(A.r,A.g,A.b,p);_cullEnabled=!0})(Q,ma,ta);this.context=e;this.setSize=function(l,A){M.width=l;M.height=A;this.setViewport(0,0,M.width,M.height)};this.setViewport=function(l,A,p,n){ea=l;xa=A;ja=p;ha=n;e.viewport(ea,xa,ja,ha)};this.setScissor=function(l,A,p,n){e.scissor(l,A,p,n)};this.enableScissorTest=function(l){l?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(l){e.depthMask(l)};this.setClearColorHex=function(l,A){var p=new THREE.Color(l);e.clearColor(p.r,
+p.g,p.b,A)};this.setClearColor=function(l,A){e.clearColor(l.r,l.g,l.b,A)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,A,p,n){var m,C;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,
+THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var y,G,N,R;C=N=R=0;for(y=A.length;C<y;C++){G=A[C];G instanceof THREE.DirectionalLight&&N++;G instanceof THREE.PointLight&&R++}if(R+N<=4)A=N;else{A=Math.ceil(4*N/(R+N));R=4-A}C={directional:A,point:R};y=50;if(n!==undefined&&n instanceof THREE.SkinnedMesh)y=n.bones.length;R=l.fragmentShader;A=l.vertexShader;y={fog:p,map:l.map,
+envMap:l.envMap,lightMap:l.lightMap,vertexColors:l.vertexColors,skinning:l.skinning,morphTargets:l.morphTargets,maxDirLights:C.directional,maxPointLights:C.point,maxBones:y};p=e.createProgram();C=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.fog?"#define USE_FOG":"",y.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP":
+"",y.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");y=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,"#define MAX_BONES "+y.maxBones,y.map?"#define USE_MAP":"",y.envMap?"#define USE_ENVMAP":"",y.lightMap?"#define USE_LIGHTMAP":"",y.vertexColors?"#define USE_COLOR":"",y.skinning?"#define USE_SKINNING":"",y.morphTargets?"#define USE_MORPHTARGETS":
+"",y.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
 e.attachShader(p,O("fragment",C+R));e.attachShader(p,O("vertex",y+A));e.linkProgram(p);e.getProgramParameter(p,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(p,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");p.uniforms={};p.attributes={};l.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(m in l.uniforms)p.push(m);m=
 l.program;R=0;for(A=p.length;R<A;R++){C=p[R];m.uniforms[C]=e.getUniformLocation(m,C)}p=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(m=0;m<this.maxMorphTargets;m++)p.push("morphTarget"+m);m=l.program;R=0;for(A=p.length;R<A;R++){C=p[R];m.attributes[C]=e.getAttribLocation(m,C)}m=l.program.attributes;e.enableVertexAttribArray(m.position);m.color>=0&&e.enableVertexAttribArray(m.color);m.normal>=0&&e.enableVertexAttribArray(m.normal);m.tangent>=
 0&&e.enableVertexAttribArray(m.tangent);if(l.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.enableVertexAttribArray(m.skinVertexA);e.enableVertexAttribArray(m.skinVertexB);e.enableVertexAttribArray(m.skinIndex);e.enableVertexAttribArray(m.skinWeight)}if(l.morphTargets){l.numSupportedMorphTargets=0;if(m.morphTarget0>=0){e.enableVertexAttribArray(m.morphTarget0);l.numSupportedMorphTargets++}if(m.morphTarget1>=0){e.enableVertexAttribArray(m.morphTarget1);l.numSupportedMorphTargets++}if(m.morphTarget2>=
@@ -395,5 +416,5 @@ d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:
 b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,j,k){g=a.materials[g];var o=b[j*3],q=b[j*3+1];j=b[j*3+2];var x=b[k*3],u=b[k*3+1];k=b[k*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(o,q,j),new THREE.Vector3(x,u,k)],g))},f4n:function(a,b,c,d,f,g,h,j,k,o,q){h=a.materials[h];var x=b[k*3],u=b[k*3+1];k=b[k*3+2];var t=b[o*3],z=b[o*3+1];o=b[o*3+2];var B=b[q*3],D=b[q*3+1];q=b[q*3+2];a.faces.push(new THREE.Face4(c,
 d,f,g,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(x,u,k),new THREE.Vector3(t,z,o),new THREE.Vector3(B,D,q)],h))},uv3:function(a,b,c,d,f,g,h){var j=[];j.push(new THREE.UV(b,c));j.push(new THREE.UV(d,f));j.push(new THREE.UV(g,h));a.push(j)},uv4:function(a,b,c,d,f,g,h,j,k){var o=[];o.push(new THREE.UV(b,c));o.push(new THREE.UV(d,f));o.push(new THREE.UV(g,h));o.push(new THREE.UV(j,k));a.push(o)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=
 [THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function d(j,k){var o=new Image;o.onload=function(){if(!c(this.width)||!c(this.height)){var q=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),x=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));j.image.width=q;j.image.height=x;j.image.getContext("2d").drawImage(this,0,0,q,x)}else j.image=this;j.needsUpdate=!0};o.src=k}var f,g,h;f="MeshLambertMaterial";
-g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.mapDiffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&b){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);
-d(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.mapDiffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);g.map.sourceFile=a.mapDiffuse;d(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&b){h=document.createElement("canvas");
+g.lightMap=new THREE.Texture(h);g.lightMap.sourceFile=a.mapLightmap;d(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 15 - 15
build/custom/ThreeCanvas.js

@@ -21,19 +21,19 @@ d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 THREE.Matrix4=function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,p||1,n||0,o||0,q||0,u||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=p;this.n34=n;this.n41=o;this.n42=q;this.n43=u;this.n44=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
-e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
-multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+
-this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44,G=b.n11,F=b.n12,K=b.n13,I=b.n14,S=b.n21,C=b.n22,A=b.n23,L=b.n24,y=b.n31,M=b.n32,D=b.n33,x=b.n34;this.n11=c*G+d*S+e*y;this.n12=
-c*F+d*C+e*M;this.n13=c*K+d*A+e*D;this.n14=c*I+d*L+e*x+f;this.n21=g*G+j*S+h*y;this.n22=g*F+j*C+h*M;this.n23=g*K+j*A+h*D;this.n24=g*I+j*L+h*x+i;this.n31=p*G+n*S+o*y;this.n32=p*F+n*C+o*M;this.n33=p*K+n*A+o*D;this.n34=p*I+n*L+o*x+q;this.n41=u*G+v*S+s*y;this.n42=u*F+v*C+s*M;this.n43=u*K+v*A+s*D;this.n44=u*I+v*L+s*x+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;
-c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,
-g=this.n23,j=this.n24,h=this.n31,i=this.n32,p=this.n33,n=this.n34,o=this.n41,q=this.n42,u=this.n43,v=this.n44;return d*g*i*o-c*j*i*o-d*f*p*o+b*j*p*o+c*f*n*o-b*g*n*o-d*g*h*q+c*j*h*q+d*e*p*q-a*j*p*q-c*e*n*q+a*g*n*q+d*f*h*u-b*j*h*u-d*e*i*u+a*j*i*u+b*e*n*u-a*f*n*u-c*f*h*v+b*g*h*v+c*e*i*v-a*g*i*v-b*e*p*v+a*f*p*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;
-this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;
-this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;
-a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=
-Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+c,0,0,0,0,1);return this},
-setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;
-c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=
-a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;d.cross(c,f).normalize();if(d.length()===0){f.x+=1.0E-4;d.cross(c,f).normalize()}e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
+d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44,G=b.n11,F=b.n12,K=b.n13,I=b.n14,S=b.n21,C=b.n22,
+A=b.n23,L=b.n24,y=b.n31,M=b.n32,D=b.n33,x=b.n34;this.n11=c*G+d*S+e*y;this.n12=c*F+d*C+e*M;this.n13=c*K+d*A+e*D;this.n14=c*I+d*L+e*x+f;this.n21=g*G+j*S+h*y;this.n22=g*F+j*C+h*M;this.n23=g*K+j*A+h*D;this.n24=g*I+j*L+h*x+i;this.n31=p*G+n*S+o*y;this.n32=p*F+n*C+o*M;this.n33=p*K+n*A+o*D;this.n34=p*I+n*L+o*x+q;this.n41=u*G+v*S+s*y;this.n42=u*F+v*C+s*M;this.n43=u*K+v*A+s*D;this.n44=u*I+v*L+s*x+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
+this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,p=this.n33,n=this.n34,o=this.n41,q=this.n42,u=this.n43,v=this.n44;return d*g*i*o-c*j*i*o-d*f*p*o+b*j*p*o+c*f*n*o-b*g*n*o-d*g*h*q+c*j*h*q+d*e*p*q-a*j*p*q-c*e*n*q+a*g*n*q+d*f*h*u-b*j*h*u-d*e*i*u+a*j*i*u+b*e*n*u-a*f*n*u-c*f*h*v+b*g*h*v+c*e*i*v-a*g*i*v-b*e*p*v+a*f*p*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
+this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
+this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*
+f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
+a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
 THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*v-i*o*v+i*n*s-j*q*s-h*n*k+j*o*k;b.n12=f*o*v-e*q*v-f*n*s+d*q*s+e*n*k-d*o*k;b.n13=e*i*v-f*h*v+f*j*s-d*i*s-e*j*k+d*h*k;b.n14=f*h*n-e*i*n-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*u-h*q*u-i*p*s+g*q*s+h*p*k-g*o*k;b.n22=e*q*u-f*o*u+f*p*s-c*q*s-e*p*k+c*o*k;b.n23=f*h*u-e*i*u-f*g*s+c*i*s+e*g*k-c*h*k;
 b.n24=e*i*p-f*h*p+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*u-i*n*u+i*p*v-g*q*v-j*p*k+g*n*k;b.n32=f*n*u-d*q*u-f*p*v+c*q*v+d*p*k-c*n*k;b.n33=e*i*u-f*j*u+f*g*v-c*i*v-d*g*k+c*j*k;b.n34=f*j*p-d*i*p-f*g*n+c*i*n+d*g*q-c*j*q;b.n41=h*n*u-j*o*u-h*p*v+g*o*v+j*p*s-g*n*s;b.n42=d*o*u-e*n*u+e*p*v-c*o*v-d*p*s+c*n*s;b.n43=e*j*u-d*h*u-e*g*v+c*h*v+d*g*s-c*j*s;b.n44=d*h*p-e*j*p+e*g*n-c*h*n-d*g*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*p;c[8]=a*n;return b};
@@ -84,8 +84,8 @@ THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.o
 undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
 THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;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;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
 undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
-THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
-undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
+a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
 THREE.Texture=function(a,b,c,d,e,f){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=f!==undefined?f:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};
 THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;
 THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;

+ 13 - 13
build/custom/ThreeDOM.js

@@ -21,19 +21,19 @@ d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,j||0,n||1,m||0,l||0,o||0,q||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
-e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
-multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+
-this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44,D=b.n11,z=b.n12,G=b.n13,H=b.n14,M=b.n21,x=b.n22,v=b.n23,E=b.n24,B=b.n31,F=b.n32,A=b.n33,w=b.n34;this.n11=c*D+d*M+e*B;this.n12=
-c*z+d*x+e*F;this.n13=c*G+d*v+e*A;this.n14=c*H+d*E+e*w+f;this.n21=g*D+i*M+h*B;this.n22=g*z+i*x+h*F;this.n23=g*G+i*v+h*A;this.n24=g*H+i*E+h*w+j;this.n31=n*D+m*M+l*B;this.n32=n*z+m*x+l*F;this.n33=n*G+m*v+l*A;this.n34=n*H+m*E+l*w+o;this.n41=q*D+r*M+p*B;this.n42=q*z+r*x+p*F;this.n43=q*G+r*v+p*A;this.n44=q*H+r*E+p*w+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;
-c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,
-g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*g*j*l-c*i*j*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*j*q+a*i*j*q+b*e*m*q-a*f*m*q-c*f*h*r+b*g*h*r+c*e*j*r-a*g*j*r-b*e*n*r+a*f*n*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;
-this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;
-this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;
-a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=
-Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g,j*i+d*f,e*i*i+c,0,0,0,0,1);return this},
-setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var j=c*g;
-c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=
-a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;d.cross(c,f).normalize();if(d.length()===0){f.x+=1.0E-4;d.cross(c,f).normalize()}e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
+d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44,D=b.n11,z=b.n12,G=b.n13,H=b.n14,M=b.n21,x=b.n22,
+v=b.n23,E=b.n24,B=b.n31,F=b.n32,A=b.n33,w=b.n34;this.n11=c*D+d*M+e*B;this.n12=c*z+d*x+e*F;this.n13=c*G+d*v+e*A;this.n14=c*H+d*E+e*w+f;this.n21=g*D+i*M+h*B;this.n22=g*z+i*x+h*F;this.n23=g*G+i*v+h*A;this.n24=g*H+i*E+h*w+j;this.n31=n*D+m*M+l*B;this.n32=n*z+m*x+l*F;this.n33=n*G+m*v+l*A;this.n34=n*H+m*E+l*w+o;this.n41=q*D+r*M+p*B;this.n42=q*z+r*x+p*F;this.n43=q*G+r*v+p*A;this.n44=q*H+r*E+p*w+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
+this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*g*j*l-c*i*j*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*j*q+a*i*j*q+b*e*m*q-a*f*m*q-c*f*h*r+b*g*h*r+c*e*j*r-a*g*j*r-b*e*n*r+a*f*n*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
+this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
+this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*
+f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g,j*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
+a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
 THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-j*l*r+j*m*p-i*o*p-h*m*k+i*l*k;b.n12=f*l*r-e*o*r-f*m*p+d*o*p+e*m*k-d*l*k;b.n13=e*j*r-f*h*r+f*i*p-d*j*p-e*i*k+d*h*k;b.n14=f*h*m-e*j*m-f*i*l+d*j*l+e*i*o-d*h*o;b.n21=j*l*q-h*o*q-j*n*p+g*o*p+h*n*k-g*l*k;b.n22=e*o*q-f*l*q+f*n*p-c*o*p-e*n*k+c*l*k;b.n23=f*h*q-e*j*q-f*g*p+c*j*p+e*g*k-c*h*k;
 b.n24=e*j*n-f*h*n+f*g*l-c*j*l-e*g*o+c*h*o;b.n31=i*o*q-j*m*q+j*n*r-g*o*r-i*n*k+g*m*k;b.n32=f*m*q-d*o*q-f*n*r+c*o*r+d*n*k-c*m*k;b.n33=e*j*q-f*i*q+f*g*r-c*j*r-d*g*k+c*i*k;b.n34=f*i*n-d*j*n-f*g*m+c*j*m+d*g*o-c*i*o;b.n41=h*m*q-i*l*q-h*n*r+g*l*r+i*n*p-g*m*p;b.n42=d*l*q-e*m*q+e*n*r-c*l*r-d*n*p+c*m*p;b.n43=e*i*q-d*h*q-e*g*r+c*h*r+d*g*p-c*i*p;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*n;c[8]=a*m;return b};

+ 2 - 2
build/custom/ThreeExtras.js

@@ -102,5 +102,5 @@ a.bones);THREE.Loader.prototype.animation(c,a.animation)})();this.computeCentroi
 new THREE.Color(16777215);h.setRGB(d,b,f);a.colors.push(h)},f3:function(a,d,b,f,h){a.faces.push(new THREE.Face3(d,b,f,null,a.materials[h]))},f4:function(a,d,b,f,h,c){a.faces.push(new THREE.Face4(d,b,f,h,null,a.materials[c]))},f3n:function(a,d,b,f,h,c,e,g,j){c=a.materials[c];var m=d[g*3],k=d[g*3+1];g=d[g*3+2];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];a.faces.push(new THREE.Face3(b,f,h,[new THREE.Vector3(d[e*3],d[e*3+1],d[e*3+2]),new THREE.Vector3(m,k,g),new THREE.Vector3(v,q,j)],c))},f4n:function(a,d,b,f,
 h,c,e,g,j,m,k){e=a.materials[e];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];var n=d[m*3],p=d[m*3+1];m=d[m*3+2];var u=d[k*3],z=d[k*3+1];k=d[k*3+2];a.faces.push(new THREE.Face4(b,f,h,c,[new THREE.Vector3(d[g*3],d[g*3+1],d[g*3+2]),new THREE.Vector3(v,q,j),new THREE.Vector3(n,p,m),new THREE.Vector3(u,z,k)],e))},uv3:function(a,d,b,f,h,c,e){var g=[];g.push(new THREE.UV(d,b));g.push(new THREE.UV(f,h));g.push(new THREE.UV(c,e));a.push(g)},uv4:function(a,d,b,f,h,c,e,g,j){var m=[];m.push(new THREE.UV(d,b));m.push(new THREE.UV(f,
 h));m.push(new THREE.UV(c,e));m.push(new THREE.UV(g,j));a.push(m)},init_materials:function(a,d,b){a.materials=[];for(var f=0;f<d.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],b)]},createMaterial:function(a,d){function b(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}function f(g,j){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var k=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));g.image.width=
-k;g.image.height=v;g.image.getContext("2d").drawImage(this,0,0,k,v)}else g.image=this;g.needsUpdate=!0};m.src=j}var h,c,e;h="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(h="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;c.color=
-e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[h](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+k;g.image.height=v;g.image.getContext("2d").drawImage(this,0,0,k,v)}else g.image=this;g.needsUpdate=!0};m.src=j}var h,c,e;h="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(h="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);c.map.sourceFile=a.mapDiffuse;f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+
+a.colorDiffuse[2]*255;c.color=e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);c.lightMap.sourceFile=a.mapLightmap;f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[h](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 15 - 15
build/custom/ThreeSVG.js

@@ -21,19 +21,19 @@ d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,r||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=r;this.n44=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
-e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},
-multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+
-this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44,J=b.n11,q=b.n12,A=b.n13,F=b.n14,R=b.n21,B=b.n22,z=b.n23,L=b.n24,G=b.n31,N=b.n32,H=b.n33,s=b.n34;this.n11=c*J+d*R+e*G;this.n12=
-c*q+d*B+e*N;this.n13=c*A+d*z+e*H;this.n14=c*F+d*L+e*s+f;this.n21=g*J+i*R+h*G;this.n22=g*q+i*B+h*N;this.n23=g*A+i*z+h*H;this.n24=g*F+i*L+h*s+l;this.n31=n*J+m*R+k*G;this.n32=n*q+m*B+k*N;this.n33=n*A+m*z+k*H;this.n34=n*F+m*L+k*s+o;this.n41=r*J+v*R+u*G;this.n42=r*q+v*B+u*N;this.n43=r*A+v*z+u*H;this.n44=r*F+v*L+u*s+j;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;
-c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,
-g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,r=this.n43,v=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*r-b*i*h*r-d*e*l*r+a*i*l*r+b*e*m*r-a*f*m*r-c*f*h*v+b*g*h*v+c*e*l*v-a*g*l*v-b*e*n*v+a*f*n*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;
-this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;
-this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;
-a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=
-Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+c,0,0,0,0,1);return this},
-setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;
-c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=
-a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
+e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;d.cross(c,f).normalize();if(d.length()===0){f.x+=1.0E-4;d.cross(c,f).normalize()}e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*
+d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44,J=b.n11,q=b.n12,A=b.n13,F=b.n14,R=b.n21,B=b.n22,
+z=b.n23,L=b.n24,G=b.n31,N=b.n32,H=b.n33,s=b.n34;this.n11=c*J+d*R+e*G;this.n12=c*q+d*B+e*N;this.n13=c*A+d*z+e*H;this.n14=c*F+d*L+e*s+f;this.n21=g*J+i*R+h*G;this.n22=g*q+i*B+h*N;this.n23=g*A+i*z+h*H;this.n24=g*F+i*L+h*s+l;this.n31=n*J+m*R+k*G;this.n32=n*q+m*B+k*N;this.n33=n*A+m*z+k*H;this.n34=n*F+m*L+k*s+o;this.n41=r*J+v*R+u*G;this.n42=r*q+v*B+u*N;this.n43=r*A+v*z+u*H;this.n44=r*F+v*L+u*s+j;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
+this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
+this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,r=this.n43,v=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*r-b*i*h*r-d*e*l*r+a*i*l*r+b*e*m*r-a*f*m*r-c*f*h*v+b*g*h*v+c*e*l*v-a*g*l*v-b*e*n*v+a*f*n*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
+this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
+this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*
+f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
+a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}};
 THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*v-l*k*v+l*m*u-i*o*u-h*m*j+i*k*j;b.n12=f*k*v-e*o*v-f*m*u+d*o*u+e*m*j-d*k*j;b.n13=e*l*v-f*h*v+f*i*u-d*l*u-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*r-h*o*r-l*n*u+g*o*u+h*n*j-g*k*j;b.n22=e*o*r-f*k*r+f*n*u-c*o*u-e*n*j+c*k*j;b.n23=f*h*r-e*l*r-f*g*u+c*l*u+e*g*j-c*h*j;
 b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*r-l*m*r+l*n*v-g*o*v-i*n*j+g*m*j;b.n32=f*m*r-d*o*r-f*n*v+c*o*v+d*n*j-c*m*j;b.n33=e*l*r-f*i*r+f*g*v-c*l*v-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*r-i*k*r-h*n*v+g*k*v+i*n*u-g*m*u;b.n42=d*k*r-e*m*r+e*n*v-c*k*v-d*n*u+c*m*u;b.n43=e*i*r-d*h*r-e*g*v+c*h*v+d*g*u-c*i*u;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*l;c[7]=a*n;c[8]=a*m;return b};
@@ -84,8 +84,8 @@ THREE.MeshDepthMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.o
 undefined)this.wireframeLinewidth=a.wireframeLinewidth}};
 THREE.MeshNormalMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.opacity=1;this.shading=THREE.FlatShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;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;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.wireframe!==undefined)this.wireframe=a.wireframe;if(a.wireframeLinewidth!==
 undefined)this.wireframeLinewidth=a.wireframeLinewidth}};THREE.MeshFaceMaterial=function(){};
-THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==
-undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
+THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.sizeAttenuation!==undefined)this.sizeAttenuation=
+a.sizeAttenuation;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}};
 THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=c!=undefined?c:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.flipSided=!1;this.doubleSided=!1;this.overdraw=!1;if(this.geometry){this.geometry.boundingSphere||this.geometry.computeBoundingSphere();this.boundRadius=a.boundingSphere.radius}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;

+ 125 - 124
build/custom/ThreeWebGL.js

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

+ 2 - 1
examples/js/Detector.js

@@ -9,7 +9,8 @@ Detector = {
 	canvas	: !!window.CanvasRenderingContext2D,
 	webgl	: !!window.WebGLRenderingContext,
 	workers : !!window.Worker,
-
+	fileapi : window.File && window.FileReader && window.FileList && window.Blob,
+	
 	// helper methods
 
 	addGetWebGLMessage: function( parameters ) {

+ 80 - 84
examples/js/gui/gui.css

@@ -1,170 +1,166 @@
 #guidat { 
-	position: fixed;
-	top: 0; 
-	right: 0;
-	width: auto;
-	z-index: 1001;
-	text-align: right;
+    position: fixed;
+    top: 0; 
+    right: 0;
+    width: auto;
+    z-index: 1001;
+    text-align: right;
 }
 
 .guidat { 
-	color: #fff;
-	opacity: 0.97;
-	text-align: left;
-	float: right;
-	margin-right: 20px;
-	margin-bottom: 20px;
-	background-color: #fff;
+    color: #fff;
+    opacity: 0.97;
+    text-align: left;
+    float: right;
+    margin-right: 20px;
+    margin-bottom: 20px;
+    background-color: #fff;
 }
 
 .guidat,
 .guidat input { 
-	font: 9.5px Lucida Grande, sans-serif;
+    font: 9.5px Lucida Grande, sans-serif;
 }
 
 .guidat-controllers { 
-	height: 300px;
-	overflow-y: auto;
-	overflow-x: hidden;
-	background-color: rgba(0,0,0,0.1);
-	/*
-	-moz-transition: height .2s ease-out;
-	-webkit-transition: height .2s ease-out;
-	transition: height .2s ease-out;
-	*/
+    height: 300px;
+    overflow-y: auto;
+    overflow-x: hidden;
+    background-color: rgba(0,0,0,0.1);
 }
 
 a.guidat-toggle { 
-	text-decoration: none;
-	cursor: pointer;
-	color: #fff;
-	background-color: #222;
-	text-align: center;
-	display: block;
-	padding: 5px;
+    text-decoration: none;
+    cursor: pointer;
+    color: #fff;
+    background-color: #222;
+    text-align: center;
+    display: block;
+    padding: 5px;
 
 }
 
 a.guidat-toggle:hover { 
-	background-color: #000;
+    background-color: #000;
 }
 
 .guidat-controller { 
-	padding: 3px;
-	height: 25px;
-	clear: left;
-	border-bottom: 1px solid #222;
-	background-color: #111;
+    padding: 3px;
+    height: 25px;
+    clear: left;
+    border-bottom: 1px solid #222;
+    background-color: #111;
 }
 
 .guidat-controller,
 .guidat-controller input,
 .guidat-slider-bg,
 .guidat-slider-fg { 
-	-moz-transition: background-color 0.15s linear;
-	-webkit-transition: background-color 0.15s linear;
-	transition: background-color 0.15s linear;
+    -moz-transition: background-color 0.15s linear;
+    -webkit-transition: background-color 0.15s linear;
+    transition: background-color 0.15s linear;
 }
 
 .guidat-controller.boolean:hover,
 .guidat-controller.function:hover {
-	background-color: #000;
+    background-color: #000;
 }
 
 .guidat-controller input { 
-	float: right;
-	outline: none;
-	border: 0;
-	padding: 4px;
-	margin-top: 2px;
-	background-color: #222;
+    float: right;
+    outline: none;
+    border: 0;
+    padding: 4px;
+    margin-top: 2px;
+    background-color: #222;
 }
 
 
 .guidat-controller select {
-	margin-top: 4px;
-	float: right;
+    margin-top: 4px;
+    float: right;
 }
 
-.guidat-controller input:hover { 
-	background-color: #444;
+.guidat-controller input:hover.
+.guidat-controller.number.active { 
+    background-color: #444;
 }
 
 .guidat-controller input:focus { 
-	background-color: #555;
+    background-color: #555;
 }
 
 .guidat-controller.number { 
-	border-left: 5px solid #00aeff ;
+    border-left: 5px solid #00aeff ;
 }
 
 .guidat-controller.string { 
-	border-left: 5px solid #1ed36f;
+    border-left: 5px solid #1ed36f;
 }
 
 .guidat-controller.string input { 
-	border: 0;
-	color: #1ed36f;
-	margin-right: 2px;
-	width: 148px;
+    border: 0;
+    color: #1ed36f;
+    margin-right: 2px;
+    width: 148px;
 }
 
 .guidat-controller.boolean { 
-	border-left: 5px solid #54396e;
+    border-left: 5px solid #54396e;
 }
 
 .guidat-controller.function { 
-	border-left: 5px solid #e61d5f;
+    border-left: 5px solid #e61d5f;
 }
 
 .guidat-controller.number input[type=text] {
-	width: 35px;
-	margin-left: 5px;
-	margin-right: 2px;
-	color: #00aeff;
+    width: 35px;
+    margin-left: 5px;
+    margin-right: 2px;
+    color: #00aeff;
 }
 
 .guidat .guidat-controller.boolean input { 
-	margin-top: 6px;
-	margin-right: 2px;
-	font-size: 20px;
+    margin-top: 6px;
+    margin-right: 2px;
+    font-size: 20px;
 }
 
 .guidat-controller:last-child {
-	border-bottom: none;
-	-webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
-	-moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
-	box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
+    border-bottom: none;
+    -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
+    -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
+    box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.5);
 }
 
 .guidat-propertyname { 
-	padding: 5px;
-	padding-top: 7px;
-	cursor: default;
-	display: inline-block;
+    padding: 5px;
+    padding-top: 7px;
+    cursor: default;
+    display: inline-block;
 }
 
 
 .guidat-slider-bg:hover,
 .guidat-slider-bg.active {
-	background-color: #444;
+    background-color: #444;
 }
 
 .guidat-slider-bg:hover .guidat-slider-fg, 
 .guidat-slider-bg.active .guidat-slider-fg { 
-	background-color: #52c8ff;
+    background-color: #52c8ff;
 }
 
 .guidat-slider-bg { 
-	background-color: #222;
-	cursor: ew-resize;
-	width: 40%;
-	margin-top: 2px;
-	float: right;
-	height: 21px;
+    background-color: #222;
+    cursor: ew-resize;
+    width: 40%;
+    margin-top: 2px;
+    float: right;
+    height: 21px;
 }
 
 .guidat-slider-fg { 
-	background-color: #00aeff;
-	height: 20px;
+    background-color: #00aeff;
+    height: 20px;
 }

Plik diff jest za duży
+ 523 - 493
examples/js/gui/gui.full.js


+ 29 - 27
examples/js/gui/gui.min.js

@@ -1,34 +1,36 @@
-var GUI=function(){var a=this,b=[],d=[],e=true,j,k,h=0;a=this;var l=false,n=280,o=false,i,f,q=0,s;this.domElement=document.createElement("div");this.domElement.setAttribute("class","guidat");this.domElement.style.width=n+"px";var p=document.createElement("div");p.setAttribute("class","guidat-controllers");p.addEventListener("DOMMouseScroll",function(c){var g=this.scrollTop;if(c.wheelDelta)g+=c.wheelDelta;else if(c.detail)g+=c.detail;c.preventDefault&&c.preventDefault();c.returnValue=false;p.scrollTop=
-g},false);p.style.height="0px";var r=document.createElement("a");r.setAttribute("class","guidat-toggle");r.setAttribute("href","#");r.innerHTML="Show Controls";var u=false,C=0,v=false,w,y,x,z,D=function(c){y=w;z=x;w=c.pageY;x=c.pageX;c=w-y;if(!l)if(c>0){l=true;h=i=1;r.innerHTML=f||"Hide Controls"}else return;var g=z-x;if(c>0&&h>k){var m=GUI.map(h,k,k+100,1,0);c*=m}u=true;C+=c;dragDisplacementX+=g;i+=c;n+=g;h+=c;p.style.height=i+"px";n=GUI.constrain(n,240,500);a.domElement.style.width=n+"px";A()};
-r.addEventListener("mousedown",function(c){y=w=c.pageY;z=x=c.pageX;v=true;c.preventDefault();dragDisplacementX=C=0;document.addEventListener("mousemove",D,false);return false},false);r.addEventListener("click",function(c){c.preventDefault();return false},false);document.addEventListener("mouseup",function(c){if(v&&!u){a.toggle();a.domElement.style.width=n+1+"px";setTimeout(function(){a.domElement.style.width=n+"px"},1)}if(v&&u){if(dragDisplacementX==0){a.domElement.style.width=n+1+"px";setTimeout(function(){a.domElement.style.width=
-n+"px"},1)}if(i>k){clearTimeout(s);i=q=k;t()}else if(p.children.length>=1){var g=p.children[0].offsetHeight;clearTimeout(s);q=Math.round(h/g)*g-1;if(q<=0){a.hide();i=g*2}else{i=q;t()}}}document.removeEventListener("mousemove",D,false);c.preventDefault();return v=u=false},false);this.domElement.appendChild(p);this.domElement.appendChild(r);if(GUI.autoPlace){if(GUI.autoPlaceContainer==null){GUI.autoPlaceContainer=document.createElement("div");GUI.autoPlaceContainer.setAttribute("id","guidat");document.body.appendChild(GUI.autoPlaceContainer)}GUI.autoPlaceContainer.appendChild(this.domElement)}this.autoListenIntervalTime=
-1E3/60;var E=function(){j=setInterval(function(){a.listen()},this.autoListenIntervalTime)};this.__defineSetter__("autoListen",function(c){if(e=c)d.length>0&&E();else clearInterval(j)});this.__defineGetter__("autoListen",function(){return e});this.listenTo=function(c){d.length==0&&E();d.push(c)};this.unlistenTo=function(c){for(var g=0;g<d.length;g++)d[g]==c&&d.splice(g,1);d.length<=0&&clearInterval(j)};this.listen=function(c){c=c||d;for(var g in c)c[g].updateDisplay()};this.listenAll=function(){this.listen(b)};
-this.autoListen=true;var F=function(c,g){for(var m in b)if(b[m].object==c&&b[m].propertyName==g)return true;return false},G=function(c,g){function m(){return c.apply(this,g)}m.prototype=c.prototype;return new m};this.add=function(){var c=arguments[0],g=arguments[1];F(c,g);var m=c[g];if(m==undefined)GUI.error(c+' either has no property "'+g+'", or the property is inaccessible.');else{c=typeof m;m=I[c];if(m==undefined)GUI.error('Cannot create controller for data type "'+c+'"');else{for(var H=[this],
-B=0;B<arguments.length;B++)H.push(arguments[B]);if(m=G(m,H)){p.appendChild(m.domElement);b.push(m);GUI.allControllers.push(m);if(c!="function"&&GUI.saveIndex<GUI.savedValues.length){m.setValue(GUI.savedValues[GUI.saveIndex]);GUI.saveIndex++}A();o||(i=k);return m}else GUI.error('Error creating controller for "'+g+'".')}}};var A=function(){k=0;for(var c in b)k+=b[c].domElement.offsetHeight;p.style.overflowY=k-1>i?"auto":"hidden"},I={number:GUI.NumberController,string:GUI.StringController,"boolean":GUI.BooleanController,
-"function":GUI.FunctionController};F=function(c,g){for(var m in b)if(b[m].object==c&&b[m].propertyName==g)return true;return false};G=function(c,g){function m(){return c.apply(this,g)}m.prototype=c.prototype;return new m};this.reset=function(){};this.toggle=function(){l?this.hide():this.show()};this.show=function(){r.innerHTML=f||"Hide Controls";q=i;clearTimeout(s);t();l=true};this.hide=function(){r.innerHTML=f||"Show Controls";q=0;clearTimeout(s);t();l=false};this.name=function(c){f=c;r.innerHTML=
-c};this.appearanceVars=function(){return[l,n,i,p.scrollTop]};var t=function(){h+=(q-h)*0.6;if(Math.abs(h-q)<1)h=q;else s=setTimeout(t,1E3/30);p.style.height=Math.round(h)+"px";A()};if(GUI.guiIndex<GUI.savedAppearanceVars.length){n=parseInt(GUI.savedAppearanceVars[GUI.guiIndex][1]);a.domElement.style.width=n+"px";i=parseInt(GUI.savedAppearanceVars[GUI.guiIndex][2]);o=true;if(eval(GUI.savedAppearanceVars[GUI.guiIndex][0])==true){h=i;var J=GUI.savedAppearanceVars[GUI.guiIndex][3];setTimeout(function(){p.scrollTop=
-J},0);if(GUI.scrollTop>-1)document.body.scrollTop=GUI.scrollTop;q=i;this.show()}GUI.guiIndex++}GUI.allGuis.push(this)};GUI.autoPlace=true;GUI.autoPlaceContainer=null;GUI.allControllers=[];GUI.allGuis=[];GUI.saveURL=function(){title=window.location;url=GUI.replaceGetVar("saveString",GUI.getSaveString());window.location=url};GUI.scrollTop=-1;
-GUI.load=function(a){a=a.split(",");var b=parseInt(a[0]);GUI.scrollTop=parseInt(a[1]);for(var d=0;d<b;d++){var e=a.splice(2,4);GUI.savedAppearanceVars.push(e)}GUI.savedValues=a.splice(2,a.length)};GUI.savedValues=[];GUI.savedAppearanceVars=[];
-GUI.getSaveString=function(){var a=[];a.push(GUI.allGuis.length);a.push(document.body.scrollTop);for(var b in GUI.allGuis)for(var d=GUI.allGuis[b].appearanceVars(),e=0;e<d.length;e++)a.push(d[e]);for(b in GUI.allControllers)if(GUI.allControllers[b].type!="function"){d=GUI.allControllers[b].getValue();if(GUI.allControllers[b].type=="number")d=GUI.roundToDecimal(d,4);a.push(d)}return a.join(",")};
-GUI.getVarFromURL=function(a){for(var b,d=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),e=0;e<d.length;e++){b=d[e].split("=");if(b!=undefined)if(b[0]==a)return b[1]}return null};
-GUI.replaceGetVar=function(a,b){for(var d,e=window.location.href,j=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),k=0;k<j.length;k++){d=j[k].split("=");if(d!=undefined)if(d[0]==a)return e.replace(d[1],b)}if(window.location.href.indexOf("?")!=-1)return e+"&"+a+"="+b;return e+"?"+a+"="+b};GUI.saveIndex=0;GUI.guiIndex=0;GUI.showSaveString=function(){alert(GUI.getSaveString())};
-GUI.makeUnselectable=function(a){a.onselectstart=function(){return false};a.style.MozUserSelect="none";a.style.KhtmlUserSelect="none";a.unselectable="on"};GUI.makeSelectable=function(a){a.onselectstart=function(){};a.style.MozUserSelect="auto";a.style.KhtmlUserSelect="auto";a.unselectable="off"};GUI.map=function(a,b,d,e,j){return a=e+(j-e)*((a-b)/(d-b))};GUI.constrain=function(a,b,d){if(a<b)a=b;else if(a>d)a=d;return a};
+var GUI=function(){var a=this,b=[],d=[],f=true,m,k,h=0;a=this;var n=false,i=280,o=false,g,p,e=0,s;this.domElement=document.createElement("div");this.domElement.setAttribute("class","guidat");this.domElement.style.width=i+"px";var q=document.createElement("div");q.setAttribute("class","guidat-controllers");q.addEventListener("DOMMouseScroll",function(c){var j=this.scrollTop;if(c.wheelDelta)j+=c.wheelDelta;else if(c.detail)j+=c.detail;c.preventDefault&&c.preventDefault();c.returnValue=false;q.scrollTop=
+j},false);q.style.height="0px";var r=document.createElement("a");r.setAttribute("class","guidat-toggle");r.setAttribute("href","#");r.innerHTML="Show Controls";var u=false,C=0,v=false,w,y,x,z,D=function(c){y=w;z=x;w=c.pageY;x=c.pageX;c=w-y;if(!n)if(c>0){n=true;h=g=1;r.innerHTML=p||"Hide Controls"}else return;var j=z-x;if(c>0&&h>k){var l=GUI.map(h,k,k+100,1,0);c*=l}u=true;C+=c;dragDisplacementX+=j;g+=c;i+=j;h+=c;q.style.height=g+"px";i=GUI.constrain(i,240,500);a.domElement.style.width=i+"px";A()};
+r.addEventListener("mousedown",function(c){y=w=c.pageY;z=x=c.pageX;v=true;c.preventDefault();dragDisplacementX=C=0;document.addEventListener("mousemove",D,false);return false},false);r.addEventListener("click",function(c){c.preventDefault();return false},false);document.addEventListener("mouseup",function(c){v&&!u&&a.toggle();if(v&&u){dragDisplacementX==0&&E();if(g>k){clearTimeout(s);g=e=k;t()}else if(q.children.length>=1){var j=q.children[0].offsetHeight;clearTimeout(s);e=Math.round(h/j)*j-1;if(e<=
+0){a.hide();g=j*2}else{g=e;t()}}}document.removeEventListener("mousemove",D,false);c.preventDefault();return v=u=false},false);this.domElement.appendChild(q);this.domElement.appendChild(r);if(GUI.autoPlace){if(GUI.autoPlaceContainer==null){GUI.autoPlaceContainer=document.createElement("div");GUI.autoPlaceContainer.setAttribute("id","guidat");document.body.appendChild(GUI.autoPlaceContainer)}GUI.autoPlaceContainer.appendChild(this.domElement)}this.autoListenIntervalTime=1E3/60;var F=function(){m=setInterval(function(){a.listen()},
+this.autoListenIntervalTime)};this.__defineSetter__("autoListen",function(c){if(f=c)d.length>0&&F();else clearInterval(m)});this.__defineGetter__("autoListen",function(){return f});this.listenTo=function(c){d.length==0&&F();d.push(c)};this.unlistenTo=function(c){for(var j=0;j<d.length;j++)d[j]==c&&d.splice(j,1);d.length<=0&&clearInterval(m)};this.listen=function(c){c=c||d;for(var j in c)c[j].updateDisplay()};this.listenAll=function(){this.listen(b)};this.autoListen=true;var G=function(c,j){for(var l in b)if(b[l].object==
+c&&b[l].propertyName==j)return true;return false},H=function(c,j){function l(){return c.apply(this,j)}l.prototype=c.prototype;return new l};this.add=function(){var c=arguments[0],j=arguments[1];G(c,j);var l=c[j];if(l==undefined)GUI.error(c+' either has no property "'+j+'", or the property is inaccessible.');else{c=typeof l;l=J[c];if(l==undefined)GUI.error('Cannot create controller for data type "'+c+'"');else{for(var I=[this],B=0;B<arguments.length;B++)I.push(arguments[B]);if(l=H(l,I)){q.appendChild(l.domElement);
+b.push(l);GUI.allControllers.push(l);if(c!="function"&&GUI.saveIndex<GUI.savedValues.length){l.setValue(GUI.savedValues[GUI.saveIndex]);GUI.saveIndex++}A();o||(g=k);return l}else GUI.error('Error creating controller for "'+j+'".')}}};var A=function(){k=0;for(var c in b)k+=b[c].domElement.offsetHeight;q.style.overflowY=k-1>g?"auto":"hidden"},J={number:GUI.NumberController,string:GUI.StringController,"boolean":GUI.BooleanController,"function":GUI.FunctionController};G=function(c,j){for(var l in b)if(b[l].object==
+c&&b[l].propertyName==j)return true;return false};H=function(c,j){function l(){return c.apply(this,j)}l.prototype=c.prototype;return new l};this.reset=function(){};this.toggle=function(){n?this.hide():this.show()};this.show=function(){r.innerHTML=p||"Hide Controls";e=g;clearTimeout(s);t();n=true};this.hide=function(){r.innerHTML=p||"Show Controls";e=0;clearTimeout(s);t();n=false};this.name=function(c){p=c;r.innerHTML=c};this.appearanceVars=function(){return[n,i,g,q.scrollTop]};var t=function(){h+=
+(e-h)*0.6;if(Math.abs(h-e)<1){h=e;E()}else s=setTimeout(t,1E3/30);q.style.height=Math.round(h)+"px";A()},E=function(){a.domElement.style.width=i+1+"px";setTimeout(function(){a.domElement.style.width=i+"px"},1)};if(GUI.guiIndex<GUI.savedAppearanceVars.length){i=parseInt(GUI.savedAppearanceVars[GUI.guiIndex][1]);a.domElement.style.width=i+"px";g=parseInt(GUI.savedAppearanceVars[GUI.guiIndex][2]);o=true;if(eval(GUI.savedAppearanceVars[GUI.guiIndex][0])==true){h=g;var K=GUI.savedAppearanceVars[GUI.guiIndex][3];
+setTimeout(function(){q.scrollTop=K},0);if(GUI.scrollTop>-1)document.body.scrollTop=GUI.scrollTop;e=g;this.show()}GUI.guiIndex++}GUI.allGuis.push(this);GUI.allGuis.length==1&&window.addEventListener("keyup",function(c){c.keyCode==72&&GUI.toggleHide()},false)};GUI.hidden=false;GUI.autoPlace=true;GUI.autoPlaceContainer=null;GUI.allControllers=[];GUI.allGuis=[];GUI.toggleHide=function(){GUI.hidden?GUI.show():GUI.hide()};
+GUI.show=function(){GUI.hidden=false;for(var a in GUI.allGuis)GUI.allGuis[a].domElement.style.display="block"};GUI.hide=function(){GUI.hidden=true;for(var a in GUI.allGuis)GUI.allGuis[a].domElement.style.display="none"};GUI.saveURL=function(){var a=GUI.replaceGetVar("saveString",GUI.getSaveString());window.location=a};GUI.scrollTop=-1;
+GUI.load=function(a){a=a.split(",");var b=parseInt(a[0]);GUI.scrollTop=parseInt(a[1]);for(var d=0;d<b;d++){var f=a.splice(2,4);GUI.savedAppearanceVars.push(f)}GUI.savedValues=a.splice(2,a.length)};GUI.savedValues=[];GUI.savedAppearanceVars=[];
+GUI.getSaveString=function(){var a=[],b;a.push(GUI.allGuis.length);a.push(document.body.scrollTop);for(b in GUI.allGuis)for(var d=GUI.allGuis[b].appearanceVars(),f=0;f<d.length;f++)a.push(d[f]);for(b in GUI.allControllers)if(GUI.allControllers[b].type!="function"){d=GUI.allControllers[b].getValue();if(GUI.allControllers[b].type=="number")d=GUI.roundToDecimal(d,4);a.push(d)}return a.join(",")};
+GUI.getVarFromURL=function(a){for(var b,d=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),f=0;f<d.length;f++){b=d[f].split("=");if(b!=undefined)if(b[0]==a)return b[1]}return null};
+GUI.replaceGetVar=function(a,b){for(var d,f=window.location.href,m=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),k=0;k<m.length;k++){d=m[k].split("=");if(d!=undefined)if(d[0]==a)return f.replace(d[1],b)}if(window.location.href.indexOf("?")!=-1)return f+"&"+a+"="+b;return f+"?"+a+"="+b};GUI.saveIndex=0;GUI.guiIndex=0;GUI.showSaveString=function(){alert(GUI.getSaveString())};
+GUI.makeUnselectable=function(a){a.onselectstart=function(){return false};a.style.MozUserSelect="none";a.style.KhtmlUserSelect="none";a.unselectable="on"};GUI.makeSelectable=function(a){a.onselectstart=function(){};a.style.MozUserSelect="auto";a.style.KhtmlUserSelect="auto";a.unselectable="off"};GUI.map=function(a,b,d,f,m){return f+(m-f)*((a-b)/(d-b))};GUI.constrain=function(a,b,d){if(a<b)a=b;else if(a>d)a=d;return a};
 GUI.error=function(a){typeof console.error=="function"&&console.error("[GUI ERROR] "+a)};GUI.roundToDecimal=function(a,b){var d=Math.pow(10,b);return Math.round(a*d)/d};GUI.extendController=function(a){a.prototype=new GUI.Controller;a.prototype.constructor=a};GUI.getVarFromURL("saveString")!=null&&GUI.load(GUI.getVarFromURL("saveString"));
-GUI.Slider=function(a,b,d,e,j){b=b;d=d;e=e;var k=false,h=this;this.domElement=document.createElement("div");this.domElement.setAttribute("class","guidat-slider-bg");this.fg=document.createElement("div");this.fg.setAttribute("class","guidat-slider-fg");this.domElement.appendChild(this.fg);this.__defineSetter__("value",function(o){this.fg.style.width=GUI.map(o,b,d,0,100)+"%"});var l=function(o){if(k){var i;i=h.domElement;var f=curtop=0;if(i.offsetParent){do{f+=i.offsetLeft;curtop+=i.offsetTop}while(i=
-i.offsetParent);i=[f,curtop]}else i=void 0;o=GUI.map(o.pageX,i[0],i[0]+h.domElement.offsetWidth,b,d);o=Math.round(o/e)*e;a.setValue(o)}};this.domElement.addEventListener("mousedown",function(o){k=true;h.domElement.setAttribute("class","guidat-slider-bg active");h.fg.setAttribute("class","guidat-slider-fg active");l(o);document.addEventListener("mouseup",n,false)},false);var n=function(){h.domElement.setAttribute("class","guidat-slider-bg");h.fg.setAttribute("class","guidat-slider-fg");k=false;a.finishChangeFunction!=
-null&&a.finishChangeFunction.call(this,a.getValue());document.removeEventListener("mouseup",n,false)};document.addEventListener("mousemove",l,false);this.value=j};
+GUI.Slider=function(a,b,d,f,m){var k=false,h=this;this.domElement=document.createElement("div");this.domElement.setAttribute("class","guidat-slider-bg");this.fg=document.createElement("div");this.fg.setAttribute("class","guidat-slider-fg");this.domElement.appendChild(this.fg);var n=function(g){if(k){var p=o(h.domElement);g=GUI.map(g.pageX,p[0],p[0]+h.domElement.offsetWidth,b,d);g=Math.round(g/f)*f;a.setValue(g)}};this.domElement.addEventListener("mousedown",function(g){k=true;h.domElement.className+=
+" active";h.fg.className+=" active";a.domElement.className+=" active";n(g);document.addEventListener("mouseup",i,false)},false);var i=function(){h.domElement.className=h.domElement.className.replace(" active","");h.fg.className=h.fg.className.replace(" active","");a.domElement.className=a.domElement.className.replace(" active","");k=false;a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());document.removeEventListener("mouseup",i,false)},o=function(g){var p=0,e=0;if(g.offsetParent){do{p+=
+g.offsetLeft;e+=g.offsetTop}while(g=g.offsetParent);return[p,e]}};this.__defineSetter__("value",function(g){this.fg.style.width=GUI.map(g,b,d,0,100)+"%"});n=function(g){if(k){var p=o(h.domElement);g=GUI.map(g.pageX,p[0],p[0]+h.domElement.offsetWidth,b,d);g=Math.round(g/f)*f;a.setValue(g)}};this.domElement.addEventListener("mousedown",function(g){k=true;h.domElement.setAttribute("class","guidat-slider-bg active");h.fg.setAttribute("class","guidat-slider-fg active");n(g);document.addEventListener("mouseup",
+i,false)},false);i=function(){h.domElement.setAttribute("class","guidat-slider-bg");h.fg.setAttribute("class","guidat-slider-fg");k=false;a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());document.removeEventListener("mouseup",i,false)};document.addEventListener("mousemove",n,false);this.value=m};
 GUI.Controller=function(){this.parent=arguments[0];this.object=arguments[1];this.propertyName=arguments[2];if(arguments.length>0)this.initialValue=this.propertyName[this.object];this.domElement=document.createElement("div");this.domElement.setAttribute("class","guidat-controller "+this.type);this.propertyNameElement=document.createElement("span");this.propertyNameElement.setAttribute("class","guidat-propertyname");this.name(this.propertyName);this.domElement.appendChild(this.propertyNameElement);
 GUI.makeUnselectable(this.domElement)};GUI.Controller.prototype.changeFunction=null;GUI.Controller.prototype.finishChangeFunction=null;GUI.Controller.prototype.name=function(a){this.propertyNameElement.innerHTML=a;return this};GUI.Controller.prototype.reset=function(){this.setValue(this.initialValue);return this};GUI.Controller.prototype.listen=function(){this.parent.listenTo(this);return this};GUI.Controller.prototype.unlisten=function(){this.parent.unlistenTo(this);return this};
 GUI.Controller.prototype.setValue=function(a){this.object[this.propertyName]=a;this.changeFunction!=null&&this.changeFunction.call(this,a);this.updateDisplay();return this};GUI.Controller.prototype.getValue=function(){return this.object[this.propertyName]};GUI.Controller.prototype.updateDisplay=function(){};GUI.Controller.prototype.onChange=function(a){this.changeFunction=a;return this};GUI.Controller.prototype.onFinishChange=function(a){this.finishChangeFunction=a;return this};
-GUI.Controller.prototype.options=function(){var a=this,b=document.createElement("select");if(arguments.length==1){var d=arguments[0],e;for(e in d){var j=document.createElement("option");j.innerHTML=e;j.setAttribute("value",d[e]);b.appendChild(j)}}else for(e=0;e<arguments.length;e++){j=document.createElement("option");j.innerHTML=arguments[e];j.setAttribute("value",arguments[e]);b.appendChild(j)}b.addEventListener("change",function(){a.setValue(this.value);a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,
-a.getValue())});a.domElement.appendChild(b);return this};
+GUI.Controller.prototype.options=function(){var a=this,b=document.createElement("select");if(arguments.length==1){var d=arguments[0],f;for(f in d){var m=document.createElement("option");m.innerHTML=f;m.setAttribute("value",d[f]);b.appendChild(m)}}else for(f=0;f<arguments.length;f++){m=document.createElement("option");m.innerHTML=arguments[f];m.setAttribute("value",arguments[f]);b.appendChild(m)}b.addEventListener("change",function(){a.setValue(this.value);a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,
+a.getValue())},false);a.domElement.appendChild(b);return this};
 GUI.BooleanController=function(){this.type="boolean";GUI.Controller.apply(this,arguments);var a=this,b=document.createElement("input");b.setAttribute("type","checkbox");this.domElement.addEventListener("click",function(d){b.checked=!b.checked;d.preventDefault();a.setValue(b.checked)},false);b.addEventListener("mouseup",function(){b.checked=!b.checked},false);this.domElement.style.cursor="pointer";this.propertyNameElement.style.cursor="pointer";this.domElement.appendChild(b);this.updateDisplay=function(){b.checked=
-a.getValue()};this.setValue=function(d){if(typeof d!="boolean")try{d=eval(d)}catch(e){}return GUI.Controller.prototype.setValue.call(this,d)}};GUI.extendController(GUI.BooleanController);
+a.getValue()};this.setValue=function(d){if(typeof d!="boolean")try{d=eval(d)}catch(f){}return GUI.Controller.prototype.setValue.call(this,d)}};GUI.extendController(GUI.BooleanController);
 GUI.FunctionController=function(){this.type="function";var a=this;GUI.Controller.apply(this,arguments);this.domElement.addEventListener("click",function(){a.fire()},false);this.domElement.style.cursor="pointer";this.propertyNameElement.style.cursor="pointer";var b=null;this.onFire=function(d){b=d;return this};this.fire=function(){b!=null&&b.call(this);a.object[a.propertyName].call(a.object)}};GUI.extendController(GUI.FunctionController);
-GUI.NumberController=function(){this.type="number";GUI.Controller.apply(this,arguments);var a=this,b=false,d=false,e=py=0,j=arguments[3],k=arguments[4],h=arguments[5];h||(h=j!=undefined&&k!=undefined?(k-j)*0.01:1);var l=document.createElement("input");l.setAttribute("id",this.propertyName);l.setAttribute("type","text");l.setAttribute("value",this.getValue());h&&l.setAttribute("step",h);this.domElement.appendChild(l);var n;if(j!=undefined&&k!=undefined){n=new GUI.Slider(this,j,k,h,this.getValue());
-this.domElement.appendChild(n.domElement)}l.addEventListener("blur",function(){var f=parseFloat(this.value);console.log(f);isNaN(f)||a.setValue(f)},false);l.addEventListener("mousewheel",function(f){f.preventDefault();a.setValue(a.getValue()+Math.abs(f.wheelDeltaY)/f.wheelDeltaY*h);return false},false);l.addEventListener("mousedown",function(f){py=e=f.pageY;d=true;document.addEventListener("mousemove",i,false);document.addEventListener("mouseup",o,false)},false);l.addEventListener("keydown",function(f){switch(f.keyCode){case 38:f=
-a.getValue()+h;a.setValue(f);break;case 40:f=a.getValue()-h;a.setValue(f)}},false);var o=function(){document.removeEventListener("mousemove",i,false);GUI.makeSelectable(a.parent.domElement);GUI.makeSelectable(l);if(d&&!b){l.focus();l.select()}d=b=false;a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());document.removeEventListener("mouseup",o,false)},i=function(f){b=true;f.preventDefault();GUI.makeUnselectable(a.parent.domElement);GUI.makeUnselectable(l);py=e;e=f.pageY;f=
-py-e;f=a.getValue()+f*h;a.setValue(f);return false};this.options=function(){a.noSlider();a.domElement.removeChild(l);return GUI.Controller.prototype.options.apply(this,arguments)};this.noSlider=function(){n&&a.domElement.removeChild(n.domElement);return this};this.setValue=function(f){f=parseFloat(f);if(j!=undefined&&f<=j)f=j;else if(k!=undefined&&f>=k)f=k;return GUI.Controller.prototype.setValue.call(this,f)};this.updateDisplay=function(){l.value=GUI.roundToDecimal(a.getValue(),4);if(n)n.value=a.getValue()}};
-GUI.extendController(GUI.NumberController);
-GUI.StringController=function(){this.type="string";var a=this;GUI.Controller.apply(this,arguments);var b=document.createElement("input"),d=this.getValue();b.setAttribute("value",d);b.setAttribute("spellcheck","false");this.domElement.addEventListener("mouseup",function(){b.focus();b.select()},false);b.addEventListener("keyup",function(e){e.keyCode==13&&a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());a.setValue(b.value)},false);b.addEventListener("blur",function(){a.finishChangeFunction!=
+GUI.NumberController=function(){this.type="number";GUI.Controller.apply(this,arguments);var a=this,b=false,d=false,f=0,m=0,k=arguments[3],h=arguments[4],n=arguments[5];n||(n=k!=undefined&&h!=undefined?(h-k)*0.01:1);var i=document.createElement("input");i.setAttribute("id",this.propertyName);i.setAttribute("type","text");i.setAttribute("value",this.getValue());n&&i.setAttribute("step",n);this.domElement.appendChild(i);var o;if(k!=undefined&&h!=undefined){o=new GUI.Slider(this,k,h,n,this.getValue());
+this.domElement.appendChild(o.domElement)}i.addEventListener("blur",function(){var e=parseFloat(this.value);isNaN(e)||a.setValue(e)},false);i.addEventListener("mousewheel",function(e){e.preventDefault();a.setValue(a.getValue()+Math.abs(e.wheelDeltaY)/e.wheelDeltaY*n);return false},false);i.addEventListener("mousedown",function(e){m=f=e.pageY;d=true;document.addEventListener("mousemove",p,false);document.addEventListener("mouseup",g,false)},false);i.addEventListener("keydown",function(e){switch(e.keyCode){case 13:e=
+parseFloat(this.value);a.setValue(e);break;case 38:e=a.getValue()+n;a.setValue(e);break;case 40:e=a.getValue()-n;a.setValue(e)}},false);var g=function(){document.removeEventListener("mousemove",p,false);GUI.makeSelectable(a.parent.domElement);GUI.makeSelectable(i);if(d&&!b){i.focus();i.select()}if(o)o.domElement.className=o.domElement.className.replace(" active","");d=b=false;a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());document.removeEventListener("mouseup",g,false)},
+p=function(e){b=true;e.preventDefault();GUI.makeUnselectable(a.parent.domElement);GUI.makeUnselectable(i);if(o)o.domElement.className+=" active";m=f;f=e.pageY;e=m-f;e=a.getValue()+e*n;a.setValue(e);return false};this.options=function(){a.noSlider();a.domElement.removeChild(i);return GUI.Controller.prototype.options.apply(this,arguments)};this.noSlider=function(){o&&a.domElement.removeChild(o.domElement);return this};this.setValue=function(e){e=parseFloat(e);if(k!=undefined&&e<=k)e=k;else if(h!=undefined&&
+e>=h)e=h;return GUI.Controller.prototype.setValue.call(this,e)};this.updateDisplay=function(){i.value=GUI.roundToDecimal(a.getValue(),4);if(o)o.value=a.getValue()}};GUI.extendController(GUI.NumberController);
+GUI.StringController=function(){this.type="string";var a=this;GUI.Controller.apply(this,arguments);var b=document.createElement("input"),d=this.getValue();b.setAttribute("value",d);b.setAttribute("spellcheck","false");this.domElement.addEventListener("mouseup",function(){b.focus();b.select()},false);b.addEventListener("keyup",function(f){f.keyCode==13&&a.finishChangeFunction!=null&&a.finishChangeFunction.call(this,a.getValue());a.setValue(b.value)},false);b.addEventListener("blur",function(){a.finishChangeFunction!=
 null&&a.finishChangeFunction.call(this,a.getValue())},false);this.updateDisplay=function(){b.value=a.getValue()};this.options=function(){a.domElement.removeChild(b);return GUI.Controller.prototype.options.apply(this,arguments)};this.domElement.appendChild(b)};GUI.extendController(GUI.StringController);

+ 3 - 3
examples/misc_sound.html

@@ -235,14 +235,14 @@
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2, true );
 
 					// Render quad with blured scene into texture (convolution pass 2)
 
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture2;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blury;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3, true );
 
 					// Render original scene with superimposed blur to texture
 
@@ -251,7 +251,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.3;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
 
 					// Render to screen
 

+ 4 - 1
examples/misc_ubiquity_test.html

@@ -33,6 +33,7 @@
 		<script type="text/javascript" src="../src/core/Face4.js"></script>
 		<script type="text/javascript" src="../src/core/UV.js"></script>
 		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
 		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
 		<script type="text/javascript" src="../src/animation/Animation.js"></script>
 		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
@@ -65,6 +66,7 @@
 		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -72,6 +74,7 @@
 		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
@@ -91,7 +94,7 @@
 		<script type="text/javascript" src="../src/extras/primitives/LathedObject.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-
+		
 		<script type="text/javascript" src="obj/Qrcode.js"></script>
 
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>

+ 4 - 1
examples/webgl_geometry_hierarchy.html

@@ -33,6 +33,7 @@
 		<script type="text/javascript" src="../src/core/Face4.js"></script>
 		<script type="text/javascript" src="../src/core/UV.js"></script>
 		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
 		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
 		<script type="text/javascript" src="../src/animation/Animation.js"></script>
 		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
@@ -65,6 +66,7 @@
 		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -72,6 +74,7 @@
 		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
@@ -91,7 +94,7 @@
 		<script type="text/javascript" src="../src/extras/primitives/LathedObject.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-
+		
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 4 - 1
examples/webgl_geometry_hierarchy2.html

@@ -33,6 +33,7 @@
 		<script type="text/javascript" src="../src/core/Face4.js"></script>
 		<script type="text/javascript" src="../src/core/UV.js"></script>
 		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
 		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
 		<script type="text/javascript" src="../src/animation/Animation.js"></script>
 		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
@@ -65,6 +66,7 @@
 		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -72,6 +74,7 @@
 		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
@@ -91,7 +94,7 @@
 		<script type="text/javascript" src="../src/extras/primitives/LathedObject.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-
+		
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 3 - 3
examples/webgl_lines_colors.html

@@ -307,14 +307,14 @@
 				materialConvolution.uniforms.tDiffuse.texture = rtTexture1;
 				materialConvolution.uniforms.uImageIncrement.value = blurx;
 
-				renderer.render( sceneScreen, cameraOrtho, rtTexture2 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture2, true );
 
 				// Render quad with blured scene into texture (convolution pass 2)
 
 				materialConvolution.uniforms.tDiffuse.texture = rtTexture2;
 				materialConvolution.uniforms.uImageIncrement.value = blury;
 
-				renderer.render( sceneScreen, cameraOrtho, rtTexture3 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture3, true );
 
 				// Render original scene with superimposed blur to texture
 
@@ -323,7 +323,7 @@
 				materialScreen.uniforms.tDiffuse.texture = rtTexture3;
 				materialScreen.uniforms.opacity.value = 1.3;
 
-				renderer.render( sceneScreen, cameraOrtho, rtTexture1 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture1, false );
 
 				// Render to screen
 

+ 5 - 6
examples/webgl_materials_video.html

@@ -322,9 +322,9 @@
 
 				counter++;
 
-				if ( postprocessing.enabled ) {
+				renderer.clear();
 
-					renderer.clear();
+				if ( postprocessing.enabled ) {
 
 					// Render scene into texture
 
@@ -337,14 +337,14 @@
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2, true );
 
 					// Render quad with blured scene into texture (convolution pass 2)
 
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture2;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blury;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3, true );
 
 					// Render original scene with superimposed blur to texture
 
@@ -353,7 +353,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.3;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
 
 					// Render to screen
 
@@ -362,7 +362,6 @@
 
 				} else {
 
-					renderer.clear();
 					renderer.render( scene, camera );
 
 				}

+ 1 - 1
examples/webgl_particles_billboards.html

@@ -81,7 +81,7 @@
 
 				}
 
-				material = new THREE.ParticleBasicMaterial( { size: 35, map: sprite, blending: THREE.BillboardBlending } );
+				material = new THREE.ParticleBasicMaterial( { size: 35, sizeAttenuation: false, map: sprite, blending: THREE.BillboardBlending } );
 				material.color.setHSV( 1.0, 0.2, 0.8 );
 
 				particles = new THREE.ParticleSystem( geometry, material );

+ 11 - 1
examples/webgl_particles_billboards_colors.html

@@ -85,7 +85,7 @@
 
 				geometry.colors = colors;
 
-				material = new THREE.ParticleBasicMaterial( { size: 35, map: sprite, blending: THREE.BillboardBlending, vertexColors: true } );
+				material = new THREE.ParticleBasicMaterial( { size: 85, map: sprite, blending: THREE.BillboardBlending, vertexColors: true } );
 				material.color.setHSV( 1.0, 0.2, 0.8 );
 
 				particles = new THREE.ParticleSystem( geometry, material );
@@ -111,6 +111,7 @@
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
 				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
+				window.addEventListener( 'resize', onWindowResize, false );
 
 			}
 
@@ -146,6 +147,15 @@
 
 			}
 
+			function onWindowResize( event ) {
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+			}
+
 			//
 
 			function animate() {

+ 4 - 1
examples/webgl_performance.html

@@ -33,6 +33,7 @@
 		<script type="text/javascript" src="../src/core/Face4.js"></script>
 		<script type="text/javascript" src="../src/core/UV.js"></script>
 		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
 		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
 		<script type="text/javascript" src="../src/animation/Animation.js"></script>
 		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
@@ -65,6 +66,7 @@
 		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -72,6 +74,7 @@
 		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
@@ -91,7 +94,7 @@
 		<script type="text/javascript" src="../src/extras/primitives/LathedObject.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-
+		
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 4 - 4
examples/webgl_postprocessing.html

@@ -284,20 +284,20 @@
 
 				// model
 
-				renderer.render( sceneModel, cameraPerspective, rtTexture1 );
+				renderer.render( sceneModel, cameraPerspective, rtTexture1, false );
 
 				// Render quad with blured scene into texture (convolution pass 1)
 
 				quadScreen.materials = [ materialConvolution ];
 				materialConvolution.uniforms.tDiffuse.texture = rtTexture1;
 				materialConvolution.uniforms.uImageIncrement.value = blurx;
-				renderer.render( sceneScreen, cameraOrtho, rtTexture2 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture2, true );
 
 				// Render quad with blured scene into texture (convolution pass 2)
 
 				materialConvolution.uniforms.tDiffuse.texture = rtTexture2;
 				materialConvolution.uniforms.uImageIncrement.value = blury;
-				renderer.render( sceneScreen, cameraOrtho, rtTexture3 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture3, true );
 
 				// Render original scene with superimposed blur into texture
 
@@ -305,7 +305,7 @@
 
 				materialScreen.uniforms.tDiffuse.texture = rtTexture3;
 				materialScreen.uniforms.opacity.value = 1.0;
-				renderer.render( sceneScreen, cameraOrtho, rtTexture1 );
+				renderer.render( sceneScreen, cameraOrtho, rtTexture1, false );
 
 				// Render final scene to the screen with film shader
 

+ 3 - 3
examples/webgl_ribbons.html

@@ -332,14 +332,14 @@
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2, true );
 
 					// Render quad with blured scene into texture (convolution pass 2)
 
 					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture2;
 					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blury;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3, true );
 
 					// Render original scene with superimposed blur to texture
 
@@ -348,7 +348,7 @@
 					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
 					postprocessing.materialScreen.uniforms.opacity.value = 1.2;
 
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1 );
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
 
 					// Render to screen
 

+ 1 - 0
examples/webgl_sandbox.html

@@ -91,6 +91,7 @@
 		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>

+ 34 - 8
src/cameras/QuakeCamera.js

@@ -37,6 +37,8 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.lookVertical = true;
 	this.autoForward = false;
 
+	this.dragToLook = false;
+	
 	this.heightSpeed = false;
 	this.heightCoef = 1.0;
 	this.heightMin = 0.0;
@@ -51,6 +53,8 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( parameters.lookVertical !== undefined ) this.lookVertical = parameters.lookVertical;
 
 		if ( parameters.autoForward !== undefined ) this.autoForward = parameters.autoForward;
+		
+		if ( parameters.dragToLook !== undefined ) this.dragToLook = parameters.dragToLook;
 
 		if ( parameters.heightSpeed !== undefined ) this.heightSpeed = parameters.heightSpeed;
 		if ( parameters.heightCoef !== undefined ) this.heightCoef = parameters.heightCoef;
@@ -76,6 +80,8 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.moveLeft = false;
 	this.moveRight = false;
 
+	this.mouseDragOn = false;
+	
 	this.windowHalfX = window.innerWidth / 2;
 	this.windowHalfY = window.innerHeight / 2;
 
@@ -84,12 +90,18 @@ THREE.QuakeCamera = function ( parameters ) {
 		event.preventDefault();
 		event.stopPropagation();
 
-		switch ( event.button ) {
+		if ( !this.dragToLook ) {
+
+			switch ( event.button ) {
 
-			case 0: this.moveForward = true; break;
-			case 2: this.moveBackward = true; break;
+				case 0: this.moveForward = true; break;
+				case 2: this.moveBackward = true; break;
+
+			}
 
 		}
+		
+		this.mouseDragOn = true;
 
 	};
 
@@ -98,12 +110,18 @@ THREE.QuakeCamera = function ( parameters ) {
 		event.preventDefault();
 		event.stopPropagation();
 
-		switch ( event.button ) {
+		if ( !this.dragToLook ) {
+
+			switch ( event.button ) {
 
-			case 0: this.moveForward = false; break;
-			case 2: this.moveBackward = false; break;
+				case 0: this.moveForward = false; break;
+				case 2: this.moveBackward = false; break;
+
+			}
 
 		}
+		
+		this.mouseDragOn = false;
 
 	};
 
@@ -174,8 +192,16 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( this.moveLeft ) this.translateX( - this.movementSpeed );
 		if ( this.moveRight ) this.translateX( this.movementSpeed );
 
-		this.lon += this.mouseX * this.lookSpeed;
-		if( this.lookVertical ) this.lat -= this.mouseY * this.lookSpeed;
+		var actualLookSpeed = this.lookSpeed;
+		
+		if ( this.dragToLook && !this.mouseDragOn ) {
+
+			actualLookSpeed = 0;
+
+		}
+		
+		this.lon += this.mouseX * actualLookSpeed;
+		if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed;
 
 		this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
 		this.phi = ( 90 - this.lat ) * Math.PI / 180;

+ 5 - 0
src/extras/io/Loader.js

@@ -1277,7 +1277,10 @@ THREE.Loader.prototype = {
 		if ( m.mapDiffuse && texture_path ) {
 
 			texture = document.createElement( 'canvas' );
+			
 			mpars.map = new THREE.Texture( texture );
+			mpars.map.sourceFile = m.mapDiffuse;
+			
 			load_image( mpars.map, texture_path + "/" + m.mapDiffuse );
 
 		} else if ( m.colorDiffuse ) {
@@ -1295,7 +1298,9 @@ THREE.Loader.prototype = {
 		if ( m.mapLightmap && texture_path ) {
 
 			texture = document.createElement( 'canvas' );
+			
 			mpars.lightMap = new THREE.Texture( texture );
+			mpars.lightMap.sourceFile = m.mapLightmap;
 			
 			load_image( mpars.lightMap, texture_path + "/" + m.mapLightmap );
 

+ 2 - 0
src/materials/ParticleBasicMaterial.js

@@ -25,6 +25,7 @@ THREE.ParticleBasicMaterial = function ( parameters ) {
 	this.map = null;
 
 	this.size = 1.0;
+	this.sizeAttenuation = true;
 
 	this.blending = THREE.NormalBlending;
 	this.depthTest = true;
@@ -40,6 +41,7 @@ THREE.ParticleBasicMaterial = function ( parameters ) {
 		if ( parameters.map !== undefined ) this.map = parameters.map;
 
 		if ( parameters.size !== undefined ) this.size = parameters.size;
+		if ( parameters.sizeAttenuation !== undefined ) this.sizeAttenuation = parameters.sizeAttenuation;
 
 		if ( parameters.blending !== undefined ) this.blending = parameters.blending;
 		if ( parameters.depthTest !== undefined ) this.depthTest = parameters.depthTest;

+ 1 - 0
src/materials/Texture.js

@@ -17,6 +17,7 @@ THREE.Texture = function ( image, mapping, wrapS, wrapT, magFilter, minFilter )
 	this.minFilter = minFilter !== undefined ? minFilter : THREE.LinearMipMapLinearFilter;
 
 	this.needsUpdate = false;
+	//this.needsUpdate = ( image!== undefined && image.getContext ) ? true : false; // true by default for <canvas> element
 
 };
 

+ 10 - 5
src/renderers/WebGLRenderer.js

@@ -1406,6 +1406,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		uniforms.psColor.value.setRGB( material.color.r * material.opacity, material.color.g * material.opacity, material.color.b * material.opacity );
 		uniforms.opacity.value = material.opacity;
 		uniforms.size.value = material.size;
+		uniforms.scale.value = _canvas.height / 2.0; // TODO: Cache this.
 		uniforms.map.texture = material.map;
 
 	};
@@ -1492,7 +1493,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		
 		parameters = { fog: fog, map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors,
 					   skinning: material.skinning,
-					   morphTargets: material.morphTargets, maxMorphTargets: 1,
+					   morphTargets: material.morphTargets,
 					   maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point,
 					   maxBones: maxBones };
 
@@ -1566,7 +1567,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setProgram ( camera, lights, fog, material, object ) {
+	function setProgram( camera, lights, fog, material, object ) {
 
 		if ( !material.program ) _this.initMaterial( material, lights, fog, object );
 
@@ -1579,10 +1580,10 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.useProgram( program );
 			_oldProgram = program;
 
-			_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
-
 		}
 
+		_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
+
 		// refresh uniforms common to several materials
 
 		if ( fog && (
@@ -1684,6 +1685,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function renderBuffer ( camera, lights, fog, material, geometryGroup, object ) {
 
+		if ( material.opacity == 0 ) return;
+
 		var program, attributes, linewidth, primitives;
 
 		program = setProgram( camera, lights, fog, material, object );
@@ -1809,7 +1812,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 		if ( material.skinning &&
-			 attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 &&
+			 attributes.skinVertexA >= 0 && attributes.skinVertexB >= 0 &&
 			 attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) {
 
 			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexABuffer );
@@ -2780,6 +2783,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			parameters.morphTargets ? "#define USE_MORPHTARGETS" : "",
 
 
+			parameters.sizeAttenuation ? "#define USE_SIZEATTENUATION" : "",
+
 			"uniform mat4 objectMatrix;",
 			"uniform mat4 modelViewMatrix;",
 			"uniform mat4 projectionMatrix;",

+ 840 - 0
src/renderers/WebGLShaders.js

@@ -0,0 +1,840 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ * @author mrdoob / http://mrdoob.com/
+ * @author mikael emtinger / http://gomo.se/
+ */
+
+THREE.ShaderChunk = {
+
+	// FOG
+
+	fog_pars_fragment: [
+
+	"#ifdef USE_FOG",
+
+		"uniform vec3 fogColor;",
+
+		"#ifdef FOG_EXP2",
+			"uniform float fogDensity;",
+		"#else",
+			"uniform float fogNear;",
+			"uniform float fogFar;",
+		"#endif",
+
+	"#endif"
+
+	].join("\n"),
+
+	fog_fragment: [
+
+	"#ifdef USE_FOG",
+
+		"float depth = gl_FragCoord.z / gl_FragCoord.w;",
+
+		"#ifdef FOG_EXP2",
+			"const float LOG2 = 1.442695;",
+			"float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );",
+			"fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );",
+		"#else",
+			"float fogFactor = smoothstep( fogNear, fogFar, depth );",
+		"#endif",
+
+		"gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );",
+
+	"#endif"
+
+	].join("\n"),
+
+	// ENVIRONMENT MAP
+
+	envmap_pars_fragment: [
+
+	"#ifdef USE_ENVMAP",
+
+		"varying vec3 vReflect;",
+		"uniform float reflectivity;",
+		"uniform samplerCube envMap;",
+		"uniform int combine;",
+
+	"#endif"
+
+	].join("\n"),
+
+	envmap_fragment: [
+
+	"#ifdef USE_ENVMAP",
+
+		"vec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );",
+
+		"if ( combine == 1 ) {",
+
+			//"gl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );",
+			"gl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );",
+
+		"} else {",
+
+			"gl_FragColor = gl_FragColor * cubeColor;",
+
+		"}",
+
+	"#endif"
+
+	].join("\n"),
+
+	envmap_pars_vertex: [
+
+	"#ifdef USE_ENVMAP",
+
+		"varying vec3 vReflect;",
+		"uniform float refractionRatio;",
+		"uniform bool useRefract;",
+
+	"#endif"
+
+	].join("\n"),
+
+	envmap_vertex : [
+
+	"#ifdef USE_ENVMAP",
+
+		"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+		"vec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;",
+
+		"if ( useRefract ) {",
+
+			"vReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );",
+
+		"} else {",
+
+			"vReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );",
+
+		"}",
+
+	"#endif"
+
+	].join("\n"),
+
+	// COLOR MAP (particles)
+
+	map_particle_pars_fragment: [
+
+	"#ifdef USE_MAP",
+
+		"uniform sampler2D map;",
+
+	"#endif"
+
+	].join("\n"),
+
+
+	map_particle_fragment: [
+
+	"#ifdef USE_MAP",
+
+		"gl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );",
+
+	"#endif"
+
+	].join("\n"),
+
+	// COLOR MAP (triangles)
+
+	map_pars_fragment: [
+
+	"#ifdef USE_MAP",
+
+		"varying vec2 vUv;",
+		"uniform sampler2D map;",
+
+	"#endif"
+
+	].join("\n"),
+
+	map_pars_vertex: [
+
+	"#ifdef USE_MAP",
+
+		"varying vec2 vUv;",
+
+	"#endif"
+
+	].join("\n"),
+
+	map_fragment: [
+
+	"#ifdef USE_MAP",
+
+		"gl_FragColor = gl_FragColor * texture2D( map, vUv );",
+
+	"#endif"
+
+	].join("\n"),
+
+	map_vertex: [
+
+	"#ifdef USE_MAP",
+
+		"vUv = uv;",
+
+	"#endif"
+
+	].join("\n"),
+
+	// LIGHT MAP
+
+	lightmap_pars_fragment: [
+
+	"#ifdef USE_LIGHTMAP",
+
+		"varying vec2 vUv2;",
+		"uniform sampler2D lightMap;",
+
+	"#endif"
+
+	].join("\n"),
+
+	lightmap_pars_vertex: [
+
+	"#ifdef USE_LIGHTMAP",
+
+		"varying vec2 vUv2;",
+
+	"#endif"
+
+	].join("\n"),
+
+	lightmap_fragment: [
+
+	"#ifdef USE_LIGHTMAP",
+
+		"gl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );",
+
+	"#endif"
+
+	].join("\n"),
+
+	lightmap_vertex: [
+
+	"#ifdef USE_LIGHTMAP",
+
+		"vUv2 = uv2;",
+
+	"#endif"
+
+	].join("\n"),
+
+	lights_pars_vertex: [
+
+	"uniform bool enableLighting;",
+	"uniform vec3 ambientLightColor;",
+
+	"#if MAX_DIR_LIGHTS > 0",
+
+		"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];",
+		"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];",
+
+	"#endif",
+
+	"#if MAX_POINT_LIGHTS > 0",
+
+		"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];",
+		"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];",
+
+		"#ifdef PHONG",
+			"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];",
+		"#endif",
+
+	"#endif"
+
+	].join("\n"),
+
+	// LIGHTS
+
+	lights_vertex: [
+
+	"if ( !enableLighting ) {",
+
+		"vLightWeighting = vec3( 1.0 );",
+
+	"} else {",
+
+		"vLightWeighting = ambientLightColor;",
+
+		"#if MAX_DIR_LIGHTS > 0",
+
+		"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {",
+
+			"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
+			"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );",
+			"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;",
+
+		"}",
+
+		"#endif",
+
+		"#if MAX_POINT_LIGHTS > 0",
+
+		"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
+
+			"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
+			"vec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
+			"float pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );",
+			"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;",
+
+			"#ifdef PHONG",
+				"vPointLightVector[ i ] = pointLightVector;",
+			"#endif",
+
+		"}",
+
+		"#endif",
+
+	"}"
+
+	].join("\n"),
+
+	lights_pars_fragment: [
+
+	"#if MAX_DIR_LIGHTS > 0",
+		"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];",
+	"#endif",
+
+	"#if MAX_POINT_LIGHTS > 0",
+		"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];",
+	"#endif",
+
+	"varying vec3 vViewPosition;",
+	"varying vec3 vNormal;"
+
+	].join("\n"),
+
+	lights_fragment: [
+
+	"vec3 normal = normalize( vNormal );",
+	"vec3 viewPosition = normalize( vViewPosition );",
+
+	"vec4 mColor = vec4( diffuse, opacity );",
+	"vec4 mSpecular = vec4( specular, opacity );",
+
+	"#if MAX_POINT_LIGHTS > 0",
+
+		"vec4 pointDiffuse  = vec4( 0.0 );",
+		"vec4 pointSpecular = vec4( 0.0 );",
+
+		"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
+
+			"vec3 pointVector = normalize( vPointLightVector[ i ] );",
+			"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );",
+
+			"float pointDotNormalHalf = dot( normal, pointHalfVector );",
+			"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
+
+			"float pointSpecularWeight = 0.0;",
+			"if ( pointDotNormalHalf >= 0.0 )",
+				"pointSpecularWeight = pow( pointDotNormalHalf, shininess );",
+
+			"pointDiffuse  += mColor * pointDiffuseWeight;",
+			"pointSpecular += mSpecular * pointSpecularWeight;",
+
+			"}",
+
+	"#endif",
+
+	"#if MAX_DIR_LIGHTS > 0",
+
+		"vec4 dirDiffuse  = vec4( 0.0 );",
+		"vec4 dirSpecular = vec4( 0.0 );" ,
+
+		"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {",
+
+			"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );",
+
+			"vec3 dirVector = normalize( lDirection.xyz );",
+			"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );",
+
+			"float dirDotNormalHalf = dot( normal, dirHalfVector );",
+
+			"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
+
+			"float dirSpecularWeight = 0.0;",
+			"if ( dirDotNormalHalf >= 0.0 )",
+				"dirSpecularWeight = pow( dirDotNormalHalf, shininess );",
+
+			"dirDiffuse  += mColor * dirDiffuseWeight;",
+			"dirSpecular += mSpecular * dirSpecularWeight;",
+
+		"}",
+
+	"#endif",
+
+	"vec4 totalLight = vec4( ambient, opacity );",
+
+	"#if MAX_DIR_LIGHTS > 0",
+		"totalLight += dirDiffuse + dirSpecular;",
+	"#endif",
+
+	"#if MAX_POINT_LIGHTS > 0",
+		"totalLight += pointDiffuse + pointSpecular;",
+	"#endif",
+
+	"gl_FragColor = gl_FragColor * totalLight;"
+
+	].join("\n"),
+
+	// VERTEX COLORS
+
+	color_pars_fragment: [
+
+	"#ifdef USE_COLOR",
+
+		"varying vec3 vColor;",
+
+	"#endif"
+
+	].join("\n"),
+
+
+	color_fragment: [
+
+	"#ifdef USE_COLOR",
+
+		"gl_FragColor = gl_FragColor * vec4( vColor, opacity );",
+
+	"#endif"
+
+	].join("\n"),
+
+	color_pars_vertex: [
+
+	"#ifdef USE_COLOR",
+
+		"varying vec3 vColor;",
+
+	"#endif"
+
+	].join("\n"),
+
+
+	color_vertex: [
+
+	"#ifdef USE_COLOR",
+
+		"vColor = color;",
+
+	"#endif"
+
+	].join("\n"),
+
+	// skinning
+
+	skinning_pars_vertex: [
+
+	"#ifdef USE_SKINNING",
+
+		"uniform mat4 boneGlobalMatrices[ MAX_BONES ];",
+
+	"#endif"
+
+	].join("\n"),
+
+	skinning_vertex: [
+
+	"#ifdef USE_SKINNING",
+
+		"gl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;",
+		"gl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;",
+
+		// this doesn't work, no idea why
+		//"gl_Position  = projectionMatrix * cameraInverseMatrix * objectMatrix * gl_Position;",
+
+		"gl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;",
+
+	"#else",
+
+		"gl_Position = projectionMatrix * mvPosition;",
+
+	"#endif"
+
+	].join("\n")
+
+};
+
+THREE.UniformsLib = {
+
+	common: {
+
+	"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
+	"opacity" : { type: "f", value: 1.0 },
+	"map"     : { type: "t", value: 0, texture: null },
+
+	"lightMap"       : { type: "t", value: 2, texture: null },
+
+	"envMap" 		  : { type: "t", value: 1, texture: null },
+	"useRefract"	  : { type: "i", value: 0 },
+	"reflectivity"    : { type: "f", value: 1.0 },
+	"refractionRatio": { type: "f", value: 0.98 },
+	"combine"		  : { type: "i", value: 0 },
+
+	"fogDensity": { type: "f", value: 0.00025 },
+	"fogNear"	: { type: "f", value: 1 },
+	"fogFar"	: { type: "f", value: 2000 },
+	"fogColor"	: { type: "c", value: new THREE.Color( 0xffffff ) }
+
+	},
+
+	lights: {
+
+	"enableLighting" 			: { type: "i", value: 1 },
+	"ambientLightColor" 		: { type: "fv", value: [] },
+	"directionalLightDirection" : { type: "fv", value: [] },
+	"directionalLightColor" 	: { type: "fv", value: [] },
+	"pointLightPosition"		: { type: "fv", value: [] },
+	"pointLightColor"			: { type: "fv", value: [] }
+
+	},
+
+	particle: {
+
+	"psColor"   : { type: "c", value: new THREE.Color( 0xeeeeee ) },
+	"opacity" : { type: "f", value: 1.0 },
+	"size" 	  : { type: "f", value: 1.0 },
+	"scale"   : { type: "f", value: 1.0 },
+	"map"     : { type: "t", value: 0, texture: null },
+
+	"fogDensity": { type: "f", value: 0.00025 },
+	"fogNear"	: { type: "f", value: 1 },
+	"fogFar"	: { type: "f", value: 2000 },
+	"fogColor"	: { type: "c", value: new THREE.Color( 0xffffff ) }
+
+	}
+
+};
+
+THREE.ShaderLib = {
+
+	'depth': {
+
+		uniforms: { "mNear": { type: "f", value: 1.0 },
+					"mFar" : { type: "f", value: 2000.0 },
+					"opacity" : { type: "f", value: 1.0 }
+				  },
+
+		fragmentShader: [
+
+			"uniform float mNear;",
+			"uniform float mFar;",
+			"uniform float opacity;",
+
+			"void main() {",
+
+				"float depth = gl_FragCoord.z / gl_FragCoord.w;",
+				"float color = 1.0 - smoothstep( mNear, mFar, depth );",
+				"gl_FragColor = vec4( vec3( color ), opacity );",
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			"void main() {",
+
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	'normal': {
+
+		uniforms: { "opacity" : { type: "f", value: 1.0 } },
+
+		fragmentShader: [
+
+			"uniform float opacity;",
+			"varying vec3 vNormal;",
+
+			"void main() {",
+
+				"gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			"varying vec3 vNormal;",
+
+			"void main() {",
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+				"vNormal = normalize( normalMatrix * normal );",
+
+				"gl_Position = projectionMatrix * mvPosition;",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	'basic': {
+
+		uniforms: THREE.UniformsLib[ "common" ],
+
+		fragmentShader: [
+
+			"uniform vec3 diffuse;",
+			"uniform float opacity;",
+
+			THREE.ShaderChunk[ "color_pars_fragment" ],
+			THREE.ShaderChunk[ "map_pars_fragment" ],
+			THREE.ShaderChunk[ "lightmap_pars_fragment" ],
+			THREE.ShaderChunk[ "envmap_pars_fragment" ],
+			THREE.ShaderChunk[ "fog_pars_fragment" ],
+
+			"void main() {",
+
+				"gl_FragColor = vec4( diffuse, opacity );",
+
+				THREE.ShaderChunk[ "map_fragment" ],
+				THREE.ShaderChunk[ "lightmap_fragment" ],
+				THREE.ShaderChunk[ "color_fragment" ],
+				THREE.ShaderChunk[ "envmap_fragment" ],
+				THREE.ShaderChunk[ "fog_fragment" ],
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			THREE.ShaderChunk[ "map_pars_vertex" ],
+			THREE.ShaderChunk[ "lightmap_pars_vertex" ],
+			THREE.ShaderChunk[ "envmap_pars_vertex" ],
+			THREE.ShaderChunk[ "color_pars_vertex" ],
+			THREE.ShaderChunk[ "skinning_pars_vertex" ],
+
+			"void main() {",
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+
+				THREE.ShaderChunk[ "map_vertex" ],
+				THREE.ShaderChunk[ "lightmap_vertex" ],
+				THREE.ShaderChunk[ "envmap_vertex" ],
+				THREE.ShaderChunk[ "color_vertex" ],
+				THREE.ShaderChunk[ "skinning_vertex" ],
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	'lambert': {
+
+		uniforms: Uniforms.merge( [ THREE.UniformsLib[ "common" ],
+									THREE.UniformsLib[ "lights" ] ] ),
+
+		fragmentShader: [
+
+			"uniform vec3 diffuse;",
+			"uniform float opacity;",
+
+			"varying vec3 vLightWeighting;",
+
+			THREE.ShaderChunk[ "color_pars_fragment" ],
+			THREE.ShaderChunk[ "map_pars_fragment" ],
+			THREE.ShaderChunk[ "lightmap_pars_fragment" ],
+			THREE.ShaderChunk[ "envmap_pars_fragment" ],
+			THREE.ShaderChunk[ "fog_pars_fragment" ],
+
+			"void main() {",
+
+				"gl_FragColor = vec4( diffuse, opacity );",
+				"gl_FragColor = gl_FragColor * vec4( vLightWeighting, 1.0 );",
+
+				THREE.ShaderChunk[ "map_fragment" ],
+				THREE.ShaderChunk[ "lightmap_fragment" ],
+				THREE.ShaderChunk[ "color_fragment" ],
+				THREE.ShaderChunk[ "envmap_fragment" ],
+				THREE.ShaderChunk[ "fog_fragment" ],
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			"varying vec3 vLightWeighting;",
+
+			THREE.ShaderChunk[ "map_pars_vertex" ],
+			THREE.ShaderChunk[ "lightmap_pars_vertex" ],
+			THREE.ShaderChunk[ "envmap_pars_vertex" ],
+			THREE.ShaderChunk[ "lights_pars_vertex" ],
+			THREE.ShaderChunk[ "color_pars_vertex" ],
+			THREE.ShaderChunk[ "skinning_pars_vertex" ],
+
+			"void main() {",
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+
+				THREE.ShaderChunk[ "map_vertex" ],
+				THREE.ShaderChunk[ "lightmap_vertex" ],
+				THREE.ShaderChunk[ "envmap_vertex" ],
+				THREE.ShaderChunk[ "color_vertex" ],
+
+				"vec3 transformedNormal = normalize( normalMatrix * normal );",
+
+				THREE.ShaderChunk[ "lights_vertex" ],
+				THREE.ShaderChunk[ "skinning_vertex" ],
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	'phong': {
+
+		uniforms: Uniforms.merge( [ THREE.UniformsLib[ "common" ],
+									THREE.UniformsLib[ "lights" ],
+
+									{ "ambient"  : { type: "c", value: new THREE.Color( 0x050505 ) },
+									  "specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
+									  "shininess": { type: "f", value: 30 }
+									}
+
+								] ),
+
+		fragmentShader: [
+
+			"uniform vec3 diffuse;",
+			"uniform float opacity;",
+
+			"uniform vec3 ambient;",
+			"uniform vec3 specular;",
+			"uniform float shininess;",
+
+			"varying vec3 vLightWeighting;",
+
+			THREE.ShaderChunk[ "color_pars_fragment" ],
+			THREE.ShaderChunk[ "map_pars_fragment" ],
+			THREE.ShaderChunk[ "lightmap_pars_fragment" ],
+			THREE.ShaderChunk[ "envmap_pars_fragment" ],
+			THREE.ShaderChunk[ "fog_pars_fragment" ],
+			THREE.ShaderChunk[ "lights_pars_fragment" ],
+
+			"void main() {",
+
+				"gl_FragColor = vec4( vLightWeighting, 1.0 );",
+				THREE.ShaderChunk[ "lights_fragment" ],
+
+				THREE.ShaderChunk[ "map_fragment" ],
+				THREE.ShaderChunk[ "lightmap_fragment" ],
+				THREE.ShaderChunk[ "color_fragment" ],
+				THREE.ShaderChunk[ "envmap_fragment" ],
+				THREE.ShaderChunk[ "fog_fragment" ],
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			"#define PHONG",
+
+			"varying vec3 vLightWeighting;",
+			"varying vec3 vViewPosition;",
+			"varying vec3 vNormal;",
+
+			THREE.ShaderChunk[ "map_pars_vertex" ],
+			THREE.ShaderChunk[ "lightmap_pars_vertex" ],
+			THREE.ShaderChunk[ "envmap_pars_vertex" ],
+			THREE.ShaderChunk[ "lights_pars_vertex" ],
+			THREE.ShaderChunk[ "color_pars_vertex" ],
+			THREE.ShaderChunk[ "skinning_pars_vertex" ],
+
+			"void main() {",
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+
+				THREE.ShaderChunk[ "map_vertex" ],
+				THREE.ShaderChunk[ "lightmap_vertex" ],
+				THREE.ShaderChunk[ "envmap_vertex" ],
+				THREE.ShaderChunk[ "color_vertex" ],
+
+				"#ifndef USE_ENVMAP",
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+				"#endif",
+
+				"vViewPosition = cameraPosition - mPosition.xyz;",
+
+				"vec3 transformedNormal = normalize( normalMatrix * normal );",
+				"vNormal = transformedNormal;",
+
+				THREE.ShaderChunk[ "lights_vertex" ],
+				THREE.ShaderChunk[ "skinning_vertex" ],
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	'particle_basic': {
+
+		uniforms: THREE.UniformsLib[ "particle" ],
+
+		fragmentShader: [
+
+			"uniform vec3 psColor;",
+			"uniform float opacity;",
+
+			THREE.ShaderChunk[ "color_pars_fragment" ],
+			THREE.ShaderChunk[ "map_particle_pars_fragment" ],
+			THREE.ShaderChunk[ "fog_pars_fragment" ],
+
+			"void main() {",
+
+				"gl_FragColor = vec4( psColor, opacity );",
+
+				THREE.ShaderChunk[ "map_particle_fragment" ],
+				THREE.ShaderChunk[ "color_fragment" ],
+				THREE.ShaderChunk[ "fog_fragment" ],
+
+			"}"
+
+		].join("\n"),
+
+		vertexShader: [
+
+			"uniform float size;",
+			"uniform float scale;",
+
+			THREE.ShaderChunk[ "color_pars_vertex" ],
+
+			"void main() {",
+
+				THREE.ShaderChunk[ "color_vertex" ],
+
+				"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+
+				"#ifdef USE_SIZEATTENUATION",
+					"gl_PointSize = size * ( scale / length( mvPosition.xyz ) );",
+				"#else",
+					"gl_PointSize = size;",
+				"#endif",
+
+				"gl_Position = projectionMatrix * mvPosition;",
+
+			"}"
+
+		].join("\n")
+
+	}
+
+};

+ 1 - 1
src/scenes/FogExp2.js

@@ -6,6 +6,6 @@
 THREE.FogExp2 = function ( hex, density ) {
 
 	this.color = new THREE.Color( hex );
-	this.density = density || 0.00025;
+	this.density = ( density !== undefined ) ? density : 0.00025;
 
 };

+ 2 - 0
utils/build.py

@@ -70,6 +70,7 @@ COMMON_FILES = [
 'renderers/DOMRenderer.js',
 'renderers/CanvasRenderer.js',
 'renderers/SVGRenderer.js',
+'renderers/WebGLShaders.js',
 'renderers/WebGLRenderer.js',
 'renderers/SoundRenderer.js',
 'renderers/renderables/RenderableObject.js',
@@ -268,6 +269,7 @@ WEBGL_FILES = [
 'scenes/Fog.js',
 'scenes/FogExp2.js',
 'renderers/SoundRenderer.js',
+'renderers/WebGLShaders.js',
 'renderers/WebGLRenderer.js',
 ]
 

+ 29 - 23
utils/exporters/blender/2.49/convert_obj_threejs_slim.py

@@ -241,8 +241,8 @@ def file_exists(filename):
 def get_name(fname):
     """Create model name based of filename ("path/fname.js" -> "fname").
     """
-    
-    return os.path.basename(fname).split(".")[0]
+
+    return os.path.splitext(os.path.basename(fname))
 
 def bbox(vertices):
     """Compute bounding box of vertex array.
@@ -323,13 +323,18 @@ def normalize(v):
     """Normalize 3d vector"""
     
     l = math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
-    v[0] /= l
-    v[1] /= l
-    v[2] /= l
+    if l:
+        v[0] /= l
+        v[1] /= l
+        v[2] /= l
 
 # #####################################################
 # MTL parser
 # #####################################################
+def texture_relative_path(fullpath):
+    texture_file = os.path.basename(fullpath)
+    return texture_file
+    
 def parse_mtl(fname):
     """Parse MTL file.
     """
@@ -383,27 +388,27 @@ def parse_mtl(fname):
             # Diffuse texture
             # map_Kd texture_diffuse.jpg
             if chunks[0] == "map_Kd" and len(chunks) == 2:
-                materials[identifier]["mapDiffuse"] = chunks[1]
+                materials[identifier]["mapDiffuse"] = texture_relative_path(chunks[1])
 
             # Ambient texture
             # map_Ka texture_ambient.jpg
             if chunks[0] == "map_Ka" and len(chunks) == 2:
-                materials[identifier]["mapAmbient"] = chunks[1]
+                materials[identifier]["mapAmbient"] = texture_relative_path(chunks[1])
 
             # Specular texture
             # map_Ks texture_specular.jpg
             if chunks[0] == "map_Ks" and len(chunks) == 2:
-                materials[identifier]["mapSpecular"] = chunks[1]
+                materials[identifier]["mapSpecular"] = texture_relative_path(chunks[1])
 
             # Alpha texture
             # map_d texture_alpha.png
             if chunks[0] == "map_d" and len(chunks) == 2:
-                materials[identifier]["mapAlpha"] = chunks[1]
+                materials[identifier]["mapAlpha"] = texture_relative_path(chunks[1])
 
             # Bump texture
             # map_bump texture_bump.jpg or bump texture_bump.jpg
             if (chunks[0] == "map_bump" or chunks[0] == "bump") and len(chunks) == 2:
-                materials[identifier]["mapBump"] = chunks[1]
+                materials[identifier]["mapBump"] = texture_relative_path(chunks[1])
 
             # Illumination
             # illum 2
@@ -657,19 +662,20 @@ def generate_materials(mtl, materials):
     
     mtl_array = []
     for m in mtl:
-        index = materials[m]
-        
-        # add debug information
-        #  materials should be sorted according to how
-        #  they appeared in OBJ file (for the first time)
-        #  this index is identifier used in face definitions
-        mtl[m]['DbgName'] = m
-        mtl[m]['DbgIndex'] = index
-        mtl[m]['DbgColor'] = generate_color(index)
-        
-        mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
-        mtl_string = "\t{\n%s\n\t}" % mtl_raw
-        mtl_array.append([index, mtl_string])
+        if m in materials:
+            index = materials[m]
+            
+            # add debug information
+            #  materials should be sorted according to how
+            #  they appeared in OBJ file (for the first time)
+            #  this index is identifier used in face definitions
+            mtl[m]['DbgName'] = m
+            mtl[m]['DbgIndex'] = index
+            mtl[m]['DbgColor'] = generate_color(index)
+            
+            mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
+            mtl_string = "\t{\n%s\n\t}" % mtl_raw
+            mtl_array.append([index, mtl_string])
         
     return ",\n\n".join([m for i,m in sorted(mtl_array)])
 

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

@@ -629,8 +629,6 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
     if not filepath.lower().endswith('.js'):
         filepath += '.js'
 
-    classname = os.path.basename(filepath).split(".")[0]
-
     if not obj:
         raise Exception("Error, Select 1 active object")
 

+ 29 - 23
utils/exporters/cinema4d/convert_obj_threejs_slim.py

@@ -241,8 +241,8 @@ def file_exists(filename):
 def get_name(fname):
     """Create model name based of filename ("path/fname.js" -> "fname").
     """
-    
-    return os.path.basename(fname).split(".")[0]
+
+    return os.path.splitext(os.path.basename(fname))
 
 def bbox(vertices):
     """Compute bounding box of vertex array.
@@ -323,13 +323,18 @@ def normalize(v):
     """Normalize 3d vector"""
     
     l = math.sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
-    v[0] /= l
-    v[1] /= l
-    v[2] /= l
+    if l:
+        v[0] /= l
+        v[1] /= l
+        v[2] /= l
 
 # #####################################################
 # MTL parser
 # #####################################################
+def texture_relative_path(fullpath):
+    texture_file = os.path.basename(fullpath)
+    return texture_file
+    
 def parse_mtl(fname):
     """Parse MTL file.
     """
@@ -383,27 +388,27 @@ def parse_mtl(fname):
             # Diffuse texture
             # map_Kd texture_diffuse.jpg
             if chunks[0] == "map_Kd" and len(chunks) == 2:
-                materials[identifier]["mapDiffuse"] = chunks[1]
+                materials[identifier]["mapDiffuse"] = texture_relative_path(chunks[1])
 
             # Ambient texture
             # map_Ka texture_ambient.jpg
             if chunks[0] == "map_Ka" and len(chunks) == 2:
-                materials[identifier]["mapAmbient"] = chunks[1]
+                materials[identifier]["mapAmbient"] = texture_relative_path(chunks[1])
 
             # Specular texture
             # map_Ks texture_specular.jpg
             if chunks[0] == "map_Ks" and len(chunks) == 2:
-                materials[identifier]["mapSpecular"] = chunks[1]
+                materials[identifier]["mapSpecular"] = texture_relative_path(chunks[1])
 
             # Alpha texture
             # map_d texture_alpha.png
             if chunks[0] == "map_d" and len(chunks) == 2:
-                materials[identifier]["mapAlpha"] = chunks[1]
+                materials[identifier]["mapAlpha"] = texture_relative_path(chunks[1])
 
             # Bump texture
             # map_bump texture_bump.jpg or bump texture_bump.jpg
             if (chunks[0] == "map_bump" or chunks[0] == "bump") and len(chunks) == 2:
-                materials[identifier]["mapBump"] = chunks[1]
+                materials[identifier]["mapBump"] = texture_relative_path(chunks[1])
 
             # Illumination
             # illum 2
@@ -657,19 +662,20 @@ def generate_materials(mtl, materials):
     
     mtl_array = []
     for m in mtl:
-        index = materials[m]
-        
-        # add debug information
-        #  materials should be sorted according to how
-        #  they appeared in OBJ file (for the first time)
-        #  this index is identifier used in face definitions
-        mtl[m]['DbgName'] = m
-        mtl[m]['DbgIndex'] = index
-        mtl[m]['DbgColor'] = generate_color(index)
-        
-        mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
-        mtl_string = "\t{\n%s\n\t}" % mtl_raw
-        mtl_array.append([index, mtl_string])
+        if m in materials:
+            index = materials[m]
+            
+            # add debug information
+            #  materials should be sorted according to how
+            #  they appeared in OBJ file (for the first time)
+            #  this index is identifier used in face definitions
+            mtl[m]['DbgName'] = m
+            mtl[m]['DbgIndex'] = index
+            mtl[m]['DbgColor'] = generate_color(index)
+            
+            mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
+            mtl_string = "\t{\n%s\n\t}" % mtl_raw
+            mtl_array.append([index, mtl_string])
         
     return ",\n\n".join([m for i,m in sorted(mtl_array)])
 

+ 16 - 15
utils/exporters/convert_obj_threejs_slim.py

@@ -241,8 +241,8 @@ def file_exists(filename):
 def get_name(fname):
     """Create model name based of filename ("path/fname.js" -> "fname").
     """
-    
-    return os.path.basename(fname).split(".")[0]
+
+    return os.path.splitext(os.path.basename(fname))
 
 def bbox(vertices):
     """Compute bounding box of vertex array.
@@ -662,19 +662,20 @@ def generate_materials(mtl, materials):
     
     mtl_array = []
     for m in mtl:
-        index = materials[m]
-        
-        # add debug information
-        #  materials should be sorted according to how
-        #  they appeared in OBJ file (for the first time)
-        #  this index is identifier used in face definitions
-        mtl[m]['DbgName'] = m
-        mtl[m]['DbgIndex'] = index
-        mtl[m]['DbgColor'] = generate_color(index)
-        
-        mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
-        mtl_string = "\t{\n%s\n\t}" % mtl_raw
-        mtl_array.append([index, mtl_string])
+        if m in materials:
+            index = materials[m]
+            
+            # add debug information
+            #  materials should be sorted according to how
+            #  they appeared in OBJ file (for the first time)
+            #  this index is identifier used in face definitions
+            mtl[m]['DbgName'] = m
+            mtl[m]['DbgIndex'] = index
+            mtl[m]['DbgColor'] = generate_color(index)
+            
+            mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
+            mtl_string = "\t{\n%s\n\t}" % mtl_raw
+            mtl_array.append([index, mtl_string])
         
     return ",\n\n".join([m for i,m in sorted(mtl_array)])
 

+ 302 - 51
utils/exporters/max/ThreeJSExporter.ms

@@ -13,6 +13,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	headerFormat = "// Converted from: %
 //  vertices: %
 //  normals: %
+//  colors: %
 //  uvs: %
 //  triangles: %
 //  materials: %
@@ -38,24 +39,33 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-- User interface
 
-	group "ThreeJSExporter  v0.2" 
+
+	group "ThreeJSExporter  v0.4"
 	(
 
 		label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
-		hyperLink lab1 "Original source at GitHub" address:"https://github.com/mrdoob/three.js" align:#left
+		hyperLink lab1 "Original source at GitHub" address:"https://github.com/alteredq/three.js/blob/master/utils/exporters/max/ThreeJSExporter.ms" color:(color 255 120 0) align:#left
 
+		label dummy1 "--------------------------------------------------------" align:#left
+		
+		checkbox exportColor "Export vertex colors" checked:false enabled:true
 		checkbox exportUv "Export uvs" checked:true enabled:true
 		checkbox exportNormal "Export normals" checked:true enabled:true
 		checkbox smoothNormal "Use vertex normals" checked:false enabled:true
-		checkbox exportColor "Export vertex colors" checked:false enabled:false
+		
+		label dummy2 "--------------------------------------------------------" align:#left
+		
 		checkbox flipYZ "Flip YZ" checked:true enabled:true
 		checkbox flipUV "Flip UV" checked:true enabled:true
 		checkbox flipFace "Flip all faces" checked:false enabled:true
 		checkbox autoflipFace "Try fixing flipped faces" checked:false enabled:true
 
+		label dummy3 "--------------------------------------------------------" align:#left
+		
+		button btn_export "Export selected objects"
+
 	)
 
-	button btn_export "Export selected objects"
 
 	-------------------------------------------------------------------------------------
 	-- Dump vertices
@@ -104,6 +114,50 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		Format "],\n\n" to:ostream
 
 	)
+	
+	-------------------------------------------------------------------------------------
+	-- Dump colors
+
+	function SmallColor c = 
+	(
+
+		if c == 255 then 
+			return "1"
+		else 
+			return formattedPrint ( c / 255 ) format:".4f"
+
+	)
+	
+	function DumpColors src useColors = 
+	(
+
+		Format "'colors': [" to:ostream
+
+		num = src.count
+
+		if num > 0 and useColors then
+		(
+
+			for i = 1 to num do
+			(
+
+				col = src[i]
+				
+				r = SmallColor col.r
+				g = SmallColor col.g
+				b = SmallColor col.b
+				
+				Format "%,%,%" r g b to:ostream
+				
+				if i < num then Format "," to:ostream
+
+			)
+
+		)
+
+		Format "],\n\n" to:ostream
+
+	)	
 
 	-------------------------------------------------------------------------------------
 	-- Dump normals
@@ -408,7 +462,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-------------------------------------------------------------------------------------
 	-- Export materials
 
-	function ExportMaterials zmaterials = 
+	function ExportMaterials zmaterials useVertexColors = 
 	(
 
 		Format "'materials': [\n" to:ostream
@@ -424,34 +478,49 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			-- debug
 
 			Format "'DbgIndex' : %,\n" (i-1) to:ostream
-			Format "'DbgName'  : '%',\n" mat.name to:ostream
 
-			-- colors
+			if classof mat != BooleanClass then
+			(
 
-			DumpColor mat.diffuse  "colorDiffuse"
-			DumpColor mat.ambient  "colorAmbient"
-			DumpColor mat.specular "colorSpecular"
+				Format "'DbgName'  : '%',\n" mat.name to:ostream
+				
+				-- colors
 
-			t = mat.opacity / 100
-			s = mat.glossiness
-			
-			Format "'transparency'  : %,\n" t to:ostream
-			Format "'specularCoef'  : %,\n" s to:ostream
+				DumpColor mat.diffuse  "colorDiffuse"
+				DumpColor mat.ambient  "colorAmbient"
+				DumpColor mat.specular "colorSpecular"
+
+				t = mat.opacity / 100
+				s = mat.glossiness
+				
+				Format "'transparency'  : %,\n" t to:ostream
+				Format "'specularCoef'  : %,\n" s to:ostream
 
-			-- maps
+				-- maps
 
-			DumpMap mat.diffuseMap  "mapDiffuse"
-			DumpMap mat.ambientMap  "mapAmbient"
-			DumpMap mat.specularMap "mapSpecular"
-			DumpMap mat.bumpMap 	"mapBump"
-			DumpMap mat.opacityMap 	"mapAlpha"
+				DumpMap mat.diffuseMap  "mapDiffuse"
+				DumpMap mat.ambientMap  "mapAmbient"
+				DumpMap mat.specularMap "mapSpecular"
+				DumpMap mat.bumpMap 	"mapBump"
+				DumpMap mat.opacityMap 	"mapAlpha"
 
+			)
+			else 
+			(
+				
+				Format "'DbgName'  : '%',\n" "dummy" to:ostream
+				
+				DumpColor red "colorDiffuse"
+				
+			)
+				
+			Format "'vertexColors' : %\n" useVertexColors to:ostream
 			Format "}" to:ostream
 
-			if i < totalMaterials then Format "," to:ostream
+			if ( i < totalMaterials ) then Format "," to:ostream
 			Format "\n\n" to:ostream
 
-		)
+		)		
 
 		Format "],\n\n" to:ostream
 
@@ -465,7 +534,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 		n = obj.numVerts
 
-		for i = 1 to n do 
+		for i = 1 to n do
 		(
 
 			v = GetVert obj i
@@ -475,11 +544,89 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 	)
 
+	-------------------------------------------------------------------------------------
+	-- Extract vertex colors from mesh
+
+	function BlendValues x y =
+	(
+
+		return x + ( y - x )/2
+
+	)
+	
+	function HandleColor firstColor i whereto startOffset c = 
+	(
+
+		if firstColor[ i ] then 
+		(
+			whereto[ startOffset + i ] = c
+			firstColor[ i ] = false
+		)
+		else
+		(
+			whereto[ startOffset + i ] = BlendValues whereto[ startOffset + i ] c
+		)
+
+	)
+	
+	function ExtractColors obj whereto =
+	(
+
+		-- white no-op fallback color for all vertices
+		
+		nVertices = obj.numVerts
+		
+		startOffset = whereto.count
+		
+		firstColor = #()
+		
+		for i = 1 to nVertices do
+		(
+
+			append whereto (color 255 255 255)
+			append firstColor true
+
+		)
+
+		nColors = GetNumCPVVerts obj
+		
+		if nColors > 0 then
+		(
+
+			nFaces = obj.numFaces
+			
+			for i = 1 to nFaces do 
+			(
+
+				f  = GetFace obj i
+				cf = GetVCFace obj i
+				
+				c1 = GetVertColor obj cf[1]
+				c2 = GetVertColor obj cf[2]
+				c3 = GetVertColor obj cf[3]
+				
+				-- set vertices to vertex colors
+				-- ( there is no guaranteed 1-1 correspondence
+				--   between vertices and vertex colors in max
+				--   so this may mess up things, but in Three
+				--   there is 1-1 correspondence, so we need this )
+				
+				HandleColor firstColor f.x whereto startOffset c1
+				HandleColor firstColor f.y whereto startOffset c2
+				HandleColor firstColor f.z whereto startOffset c3
+
+			)
+
+		)		
+
+	)
+
 	-------------------------------------------------------------------------------------
 	-- Extract normals from mesh
 
 	function ExtractNormals obj whereto needsFlip =
 	(
+
 		if smoothNormal.checked then
 		(
 
@@ -554,29 +701,64 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 		useMultiMaterial = false
 		materialIDList = #()
-
-		if ( classof objMaterial ) == StandardMaterial then 
+		
+		materialClass = classof objMaterial
+		
+		if materialClass == StandardMaterial then 
 		(
+
 			fm = findItem allMaterials objMaterial
+
 		)
-		else
+		else if materialClass == MultiMaterial then
 		(
+
 			useMultiMaterial = true
 
 			for i = 1 to n do 
 			(
+
 				mID = GetFaceMatID objMesh i
 				materialIndex = findItem objMaterial.materialIDList mID
-				subMaterial = objMaterial.materialList[materialIndex]
+				
+				if materialIndex > 0 then
+				(
+
+					subMaterial = objMaterial.materialList[materialIndex]
 
-				mMergedIndex = findItem allMaterials subMaterial
-				if mMergedIndex > 0 then 
+					mMergedIndex = findItem allMaterials subMaterial
+
+					if mMergedIndex > 0 then 
+					(
+
+						materialIDList[mID] = mMergedIndex
+
+					)
+					else
+					(
+
+						materialIDList[mID] = findItem allMaterials false
+
+					)
+
+				)
+				else
 				(
-					materialIDList[mID] = mMergedIndex
+
+					materialIDList[mID] = findItem allMaterials false
+
 				)
 
 			)
 
+		)
+		else
+		(
+			
+			-- undefined material
+			
+			fm = findItem allMaterials false
+			
 		)
 		
 		for i = 1 to n do 
@@ -592,8 +774,10 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 			if useMultiMaterial then 
 			(
+
 				mID = GetFaceMatID objMesh i
-				fm = materialIDList[mID]
+				fm = materialIDList[mID]				
+
 			)
 
 			if hasUVs then
@@ -608,7 +792,9 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			)
 			else
 			(
+
 				fuv = false
+
 			)
 
 			append zface fv 
@@ -623,18 +809,21 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	)
 
 	-------------------------------------------------------------------------------------
-	-- Extract materials from eventual multimaterial
+	-- Extract materials from eventual multi-material
 	
-	function ExtractMaterials objMesh objMaterial whereto =
+	function ExtractMaterials objMesh objMaterial whereto zname =
 	(
 		
 		materialClass = classof objMaterial
 
 		if materialClass == StandardMaterial then
 		(
+
 			if ( findItem whereto objMaterial ) == 0 then
 			(
+
 				append whereto objMaterial
+
 			)
 
 		)
@@ -648,16 +837,32 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			
 				mID = getFaceMatId objMesh i
 				materialIndex = findItem objMaterial.materialIDList mID
-				subMaterial = objMaterial.materialList[materialIndex]
-
-				if ( findItem whereto subMaterial ) == 0 then
+				
+				if materialIndex > 0 then
 				(
-					append whereto subMaterial
-				)
+
+					subMaterial = objMaterial.materialList[materialIndex]
+
+					if ( findItem whereto subMaterial ) == 0 then
+					(
+
+						append whereto subMaterial
+
+					)
+
+				)				
 
 			)
 
 		)
+		else
+		(
+			
+			-- unknown or undefined material
+			
+			append whereto false
+
+		)
 
 	)
 
@@ -696,13 +901,25 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		if SuperClassOf node == GeometryClass then
 		(
 			needsFlip = false
+			hasVColors = false
+			
+			zmesh = SnapshotAsMesh node
 			
 			if autoflipFace.checked then
 			(
+
 				needsFlip = NeedsFaceFlip node
+
+			)
+			
+			if exportColor.checked and ( getNumCPVVerts zmesh ) > 0 then
+			(
+
+				hasVColors = true
+
 			)
 			
-			return #( SnapshotAsMesh node, node.name, node.material, needsFlip )
+			return #( zmesh, node.name, node.material, needsFlip, hasVColors )
 
 		)
 
@@ -724,32 +941,41 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 		mergedVertices = #()
 		mergedNormals = #()
+		mergedColors = #()
+		
 		mergedUvs = #()
 		mergedFaces = #()
 		mergedMaterials = #()
-
+		
+		sceneHasVColors = false
+		
 		for obj in selection do 
 		(
 
 			result = ExtractMesh obj
-
-			meshObj   	 = result[1]
-			meshName     = result[2]
-			meshMaterial = result[3]
-			needsFlip    = result[4]
+			meshObj = result[1]
 
 			if ClassOf meshObj == TriMesh then 
 			(
 
+				meshName     = result[2]
+				meshMaterial = result[3]
+				needsFlip    = result[4]
+				hasVColors   = result[5]
+				
+				sceneHasVColors = sceneHasVColors or hasVColors
+				
 				append meshObjects result
 
 				vertexOffset = mergedVertices.count
 				uvOffset = mergedUvs.count
 
-				ExtractMaterials meshObj meshMaterial mergedMaterials
+				ExtractMaterials meshObj meshMaterial mergedMaterials meshName
 
 				ExtractVertices meshObj mergedVertices
 				ExtractNormals meshObj mergedNormals needsFlip
+				ExtractColors meshObj mergedColors
+				
 				ExtractUvs meshObj mergedUvs
 
 				ExtractFaces meshObj meshMaterial mergedFaces mergedMaterials needsFlip vertexOffset uvOffset
@@ -761,23 +987,39 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		totalVertices = mergedVertices.count
 		totalFaces = mergedFaces.count
 		totalMaterials = mergedMaterials.count
-
+		
+		totalColors = 0
 		totalNormals = 0
+		totalUvs = 0
+		
+		useColors = false
+		
+		if sceneHasVColors and exportColor.checked then
+		(
+
+			totalColors = totalVertices
+			useColors = true
+
+		)
+
 		if exportNormal.checked then 
 		(
+
 			totalNormals = mergedNormals.count
+
 		)
 
-		totalUvs = 0
 		if exportUv.checked then
 		(
+
 			totalUvs = mergedUvs.count
+
 		)
 
 
 		-- Dump header
 
-		Format headerFormat maxFileName totalVertices totalNormals totalUvs totalFaces totalMaterials to:ostream
+		Format headerFormat maxFileName totalVertices totalNormals totalColors totalUvs totalFaces totalMaterials to:ostream
 
 		-- Dump objects (debug)
 
@@ -800,12 +1042,13 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 		-- Dump all materials in the scene
 
-		ExportMaterials mergedMaterials
+		ExportMaterials mergedMaterials useColors
 
 		-- Dump merged data from all selected geometries
 
 		DumpVertices mergedVertices
 		DumpNormals mergedNormals
+		DumpColors mergedColors useColors
 		DumpUvs mergedUvs
 		DumpFaces mergedFaces
 
@@ -826,13 +1069,19 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 		fname = GetSaveFileName filename:zname types:"JavaScript file (*.js)|*.js|All Files(*.*)|*.*|"
 		if fname == undefined then
+		(
+
 			return undefined
 
+		)
+
 		ostream = CreateFile fname
 		if ostream == undefined then
 		(
+
 			MessageBox "Couldn't open file for writing !"
 			return undefined
+
 		)
 
 		return ostream
@@ -846,8 +1095,10 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		ostream = GetSaveFileStream()
 		if ostream != undefined then
 		(
+
 			ExportScene()
 			close ostream
+
 		)
 
 	)

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików