فهرست منبع

Merge remote-tracking branch 'alteredq/dev' into experimental

zz85 14 سال پیش
والد
کامیت
29a547960d
57فایلهای تغییر یافته به همراه4130 افزوده شده و 2829 حذف شده
  1. 68 52
      README.md
  2. 1 1
      REVISION
  3. 251 246
      build/Three.js
  4. 86 86
      build/custom/ThreeCanvas.js
  5. 18 18
      build/custom/ThreeDOM.js
  6. 14 14
      build/custom/ThreeExtras.js
  7. 45 45
      build/custom/ThreeSVG.js
  8. 77 76
      build/custom/ThreeWebGL.js
  9. 761 74
      examples/js/ShaderExtras.js
  10. 12 6
      examples/js/postprocessing/BloomPass.js
  11. 6 5
      examples/js/postprocessing/DotScreenPass.js
  12. 65 8
      examples/js/postprocessing/EffectComposer.js
  13. 5 4
      examples/js/postprocessing/FilmPass.js
  14. 66 0
      examples/js/postprocessing/MaskPass.js
  15. 9 3
      examples/js/postprocessing/RenderPass.js
  16. 7 7
      examples/js/postprocessing/ShaderPass.js
  17. 9 7
      examples/js/postprocessing/TexturePass.js
  18. 0 46
      examples/js/postprocessing/VignettePass.js
  19. 0 1
      examples/webgl_collada.html
  20. 4 0
      examples/webgl_flycamera_earth.html
  21. 39 109
      examples/webgl_geometry_text.html
  22. 223 0
      examples/webgl_interactive_draggablecubes.html
  23. 7 2
      examples/webgl_lines_colors.html
  24. 13 110
      examples/webgl_lines_splines.html
  25. 1 1
      examples/webgl_materials.html
  26. 33 50
      examples/webgl_materials_shaders.html
  27. 17 28
      examples/webgl_materials_texture_filters.html
  28. 26 97
      examples/webgl_materials_video.html
  29. 61 214
      examples/webgl_particles_dynamic.html
  30. 2 0
      examples/webgl_performance.html
  31. 84 47
      examples/webgl_postprocessing.html
  32. 1 1
      examples/webgl_postprocessing_dof.html
  33. 7 2
      examples/webgl_ribbons.html
  34. 5 3
      examples/webgl_sandbox.html
  35. 4 0
      examples/webgl_shader_lava.html
  36. 3 1
      examples/webgl_shadowmap.html
  37. 95 0
      examples/webgl_test_memory.html
  38. 2 2
      src/core/Geometry.js
  39. 7 2
      src/core/Object3D.js
  40. 499 0
      src/core/Projector.js
  41. 6 452
      src/extras/ShaderUtils.js
  42. 0 0
      src/extras/core/Curve.js
  43. 0 0
      src/extras/core/CurvePath.js
  44. 0 0
      src/extras/core/Path.js
  45. 0 0
      src/extras/core/Shape.js
  46. 0 0
      src/extras/core/TextPath.js
  47. 414 421
      src/extras/loaders/BinaryLoader.js
  48. 641 303
      src/extras/loaders/ColladaLoader.js
  49. 1 1
      src/extras/loaders/JSONLoader.js
  50. 7 7
      src/extras/loaders/Loader.js
  51. 167 173
      src/extras/loaders/UTF8Loader.js
  52. 16 12
      src/renderers/Projector.js
  53. 23 0
      src/renderers/WebGLRenderTarget.js
  54. 204 71
      src/renderers/WebGLRenderer.js
  55. 1 1
      src/renderers/WebGLShaders.js
  56. 5 9
      src/textures/DataTexture.js
  57. 12 11
      utils/build.py

+ 68 - 52
README.md

@@ -15,66 +15,66 @@ More? [#three.js on irc.freenode.net](http://webchat.freenode.net/?channels=thre
 
 
 #### WebGL (Context 3D) ####
 #### WebGL (Context 3D) ####
 
 
-[![equirectangular](http://mrdoob.github.com/three.js/assets/examples/44_equirectangular.png)](http://mrdoob.github.com/three.js/examples/webgl_panorama_equirectangular.html)
-[![scissors](http://mrdoob.github.com/three.js/assets/examples/42_scissors.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_texture_filters.html)
-[![lookat](http://mrdoob.github.com/three.js/assets/examples/41_lookat.png)](http://mrdoob.github.com/three.js/examples/misc_lookat.html)
-[![video](http://mrdoob.github.com/three.js/assets/examples/40_video.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_video.html)
-[![dof](http://mrdoob.github.com/three.js/assets/examples/39_dof.png)](http://mrdoob.github.com/three.js/examples/webgl_postprocessing_dof.html)
-[![ribbon](http://mrdoob.github.com/three.js/assets/examples/38_ribbon.png)](http://mrdoob.github.com/three.js/examples/webgl_ribbons.html)
-[![vertexcolors](http://mrdoob.github.com/three.js/assets/examples/37_vertexcolors.png)](http://mrdoob.github.com/three.js/examples/webgl_geometry_colors.html)
-[![particles](http://mrdoob.github.com/three.js/assets/examples/36_particles.png)](http://mrdoob.github.com/three.js/examples/webgl_particles_billboards_colors.html)
-[![lines](http://mrdoob.github.com/three.js/assets/examples/35_lines.png)](http://mrdoob.github.com/three.js/examples/webgl_lines_colors.html)
-[![shader](http://mrdoob.github.com/three.js/assets/examples/34_shader.png)](http://mrdoob.github.com/three.js/examples/webgl_shader.html)
-[![materials_normalmap2](http://mrdoob.github.com/three.js/assets/examples/33_materials_normalmap2.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_normalmap2.html)
-[![materials_grass](http://mrdoob.github.com/three.js/assets/examples/32_materials_grass.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_grass.html)
-[![materials_normalmap](http://mrdoob.github.com/three.js/assets/examples/31_materials_normalmap.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_normalmap.html)
-[![geometry_terrain_gl](http://mrdoob.github.com/three.js/assets/examples/30_geometry_terrain_gl.png)](http://mrdoob.github.com/three.js/examples/webgl_geometry_terrain.html)
-[![geometry_minecraft](http://mrdoob.github.com/three.js/assets/examples/29_geometry_minecraft.png)](http://mrdoob.github.com/three.js/examples/webgl_geometry_minecraft_ao.html)
-[![materials_shader_fresnel](http://mrdoob.github.com/three.js/assets/examples/28_materials_shaders_fresnel.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_shaders_fresnel.html)
-[![materials_cars](http://mrdoob.github.com/three.js/assets/examples/25_materials_cars.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cars.html)
-[![materials_cubemap_refraction](http://mrdoob.github.com/three.js/assets/examples/18_materials_cubemap_refraction.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_refraction.html)
-[![materials_cubemap_balls_reflection](http://mrdoob.github.com/three.js/assets/examples/15_materials_cubemap_balls_reflection.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_balls_reflection.html)
-[![materials_cubemap_balls_refraction](http://mrdoob.github.com/three.js/assets/examples/16_materials_cubemap_balls_refraction.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_balls_refraction.html)
-[![materials_cubemap_escher](http://mrdoob.github.com/three.js/assets/examples/17_materials_cubemap_escher.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_escher.html)
-[![materials_cubemap](http://mrdoob.github.com/three.js/assets/examples/14_materials_cubemap.png)](http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap.html)
-[![materials_gl](http://mrdoob.github.com/three.js/assets/examples/20_materials_gl.png)](http://mrdoob.github.com/three.js/examples/webgl_materials.html)
-[![large_mesh](http://mrdoob.github.com/three.js/assets/examples/12_large_mesh.png)](http://mrdoob.github.com/three.js/examples/webgl_geometry_large_mesh.html)
+<a href="http://mrdoob.github.com/three.js/examples/webgl_panorama_equirectangular.html"><img src="http://mrdoob.github.com/three.js/assets/examples/44_equirectangular.png" width="109" height="82" alt="equirectangular"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_texture_filters.html"><img src="http://mrdoob.github.com/three.js/assets/examples/42_scissors.png" width="109" height="82" alt="scissors"></a>
+<a href="http://mrdoob.github.com/three.js/examples/misc_lookat.html"><img src="http://mrdoob.github.com/three.js/assets/examples/41_lookat.png" width="109" height="82" alt="lookat"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_video.html"><img src="http://mrdoob.github.com/three.js/assets/examples/40_video.png" width="109" height="82" alt="video"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_postprocessing_dof.html"><img src="http://mrdoob.github.com/three.js/assets/examples/39_dof.png" width="109" height="82" alt="dof"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_ribbons.html"><img src="http://mrdoob.github.com/three.js/assets/examples/38_ribbon.png" width="109" height="82" alt="ribbon"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_geometry_colors.html"><img src="http://mrdoob.github.com/three.js/assets/examples/37_vertexcolors.png" width="109" height="82" alt="vertexcolors"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_particles_billboards_colors.html"><img src="http://mrdoob.github.com/three.js/assets/examples/36_particles.png" width="109" height="82" alt="particles"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_lines_colors.html"><img src="http://mrdoob.github.com/three.js/assets/examples/35_lines.png" width="109" height="82" alt="lines"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_shader.html"><img src="http://mrdoob.github.com/three.js/assets/examples/34_shader.png" width="109" height="82" alt="shader"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_normalmap2.html"><img src="http://mrdoob.github.com/three.js/assets/examples/33_materials_normalmap2.png" width="109" height="82" alt="materials_normalmap2"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_grass.html"><img src="http://mrdoob.github.com/three.js/assets/examples/32_materials_grass.png" width="109" height="82" alt="materials_grass"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_normalmap.html"><img src="http://mrdoob.github.com/three.js/assets/examples/31_materials_normalmap.png" width="109" height="82" alt="materials_normalmap"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_geometry_terrain.html"><img src="http://mrdoob.github.com/three.js/assets/examples/30_geometry_terrain_gl.png" width="109" height="82" alt="geometry_terrain_gl"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_geometry_minecraft_ao.html"><img src="http://mrdoob.github.com/three.js/assets/examples/29_geometry_minecraft.png" width="109" height="82" alt="geometry_minecraft"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_shaders_fresnel.html"><img src="http://mrdoob.github.com/three.js/assets/examples/28_materials_shaders_fresnel.png" width="109" height="82" alt="materials_shader_fresnel"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cars.html"><img src="http://mrdoob.github.com/three.js/assets/examples/25_materials_cars.png" width="109" height="82" alt="materials_cars"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_refraction.html"><img src="http://mrdoob.github.com/three.js/assets/examples/18_materials_cubemap_refraction.png" width="109" height="82" alt="materials_cubemap_refraction"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_balls_reflection.html"><img src="http://mrdoob.github.com/three.js/assets/examples/15_materials_cubemap_balls_reflection.png" width="109" height="82" alt="materials_cubemap_balls_reflection"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_balls_refraction.html"><img src="http://mrdoob.github.com/three.js/assets/examples/16_materials_cubemap_balls_refraction.png" width="109" height="82" alt="materials_cubemap_balls_refraction"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap_escher.html"><img src="http://mrdoob.github.com/three.js/assets/examples/17_materials_cubemap_escher.png" width="109" height="82" alt="materials_cubemap_escher"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials_cubemap.html"><img src="http://mrdoob.github.com/three.js/assets/examples/14_materials_cubemap.png" width="109" height="82" alt="materials_cubemap"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_materials.html"><img src="http://mrdoob.github.com/three.js/assets/examples/20_materials_gl.png" width="109" height="82" alt="materials_gl"></a>
+<a href="http://mrdoob.github.com/three.js/examples/webgl_geometry_large_mesh.html"><img src="http://mrdoob.github.com/three.js/assets/examples/12_large_mesh.png" width="109" height="82" alt="large_mesh"></a>
 
 
 
 
 #### Canvas (Context 2D) ####
 #### Canvas (Context 2D) ####
 
 
-[![materials_reflection](http://mrdoob.github.com/three.js/assets/examples/27_materials_reflection.png)](http://mrdoob.github.com/three.js/examples/canvas_materials_reflection.html)
-[![materials](http://mrdoob.github.com/three.js/assets/examples/13_materials.png)](http://mrdoob.github.com/three.js/examples/canvas_materials.html)
-[![materials_depth](http://mrdoob.github.com/three.js/assets/examples/19_materials_depth.png)](http://mrdoob.github.com/three.js/examples/canvas_materials_depth.html)
-[![materials_normal](http://mrdoob.github.com/three.js/assets/examples/22_materials_normal.png)](http://mrdoob.github.com/three.js/examples/canvas_materials_normal.html)
-[![lights_pointlights](http://mrdoob.github.com/three.js/assets/examples/09_walthead.png)](http://mrdoob.github.com/three.js/examples/canvas_lights_pointlights.html)
-[![interactive_cubes](http://mrdoob.github.com/three.js/assets/examples/11_interactive.png)](http://mrdoob.github.com/three.js/examples/canvas_interactive_cubes.html)
-[![camera_ortographic](http://mrdoob.github.com/three.js/assets/examples/10_orthographic.png)](http://mrdoob.github.com/three.js/examples/canvas_camera_orthographic.html)
-[![geometry_birds](http://mrdoob.github.com/three.js/assets/examples/08_birds.png)](http://mrdoob.github.com/three.js/examples/canvas_geometry_birds.html)
-[![geometry_earth](http://mrdoob.github.com/three.js/assets/examples/07_earth.png)](http://mrdoob.github.com/three.js/examples/canvas_geometry_earth.html)
-[![geometry_terrain](http://mrdoob.github.com/three.js/assets/examples/06_terrain.png)](http://mrdoob.github.com/three.js/examples/canvas_geometry_terrain.html)
-[![materials_video](http://mrdoob.github.com/three.js/assets/examples/24_materials_video.png)](http://mrdoob.github.com/three.js/examples/canvas_materials_video.html)
-[![geometry_panorama](http://mrdoob.github.com/three.js/assets/examples/04_vr.png)](http://mrdoob.github.com/three.js/examples/canvas_geometry_panorama.html)
-[![geometry_cube](http://mrdoob.github.com/three.js/assets/examples/03_cube.png)](http://mrdoob.github.com/three.js/examples/canvas_geometry_cube.html)
-[![particles_sprites](http://mrdoob.github.com/three.js/assets/examples/26_particles_sprites.png)](http://mrdoob.github.com/three.js/examples/canvas_particles_sprites.html)
-[![particles_random](http://mrdoob.github.com/three.js/assets/examples/02_random.png)](http://mrdoob.github.com/three.js/examples/canvas_particles_random.html)
-[![particles_wave](http://mrdoob.github.com/three.js/assets/examples/01_waves.png)](http://mrdoob.github.com/three.js/examples/canvas_particles_waves.html)
+<a href="http://mrdoob.github.com/three.js/examples/canvas_materials_reflection.html"><img src="http://mrdoob.github.com/three.js/assets/examples/27_materials_reflection.png" width="109" height="82" alt="materials_reflection"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_materials.html"><img src="http://mrdoob.github.com/three.js/assets/examples/13_materials.png" width="109" height="82" alt="materials"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_materials_depth.html"><img src="http://mrdoob.github.com/three.js/assets/examples/19_materials_depth.png" width="109" height="82" alt="materials_depth"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_materials_normal.html"><img src="http://mrdoob.github.com/three.js/assets/examples/22_materials_normal.png" width="109" height="82" alt="materials_normal"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_lights_pointlights.html"><img src="http://mrdoob.github.com/three.js/assets/examples/09_walthead.png" width="109" height="82" alt="lights_pointlights"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_interactive_cubes.html"><img src="http://mrdoob.github.com/three.js/assets/examples/11_interactive.png" width="109" height="82" alt="interactive_cubes"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_camera_orthographic.html"><img src="http://mrdoob.github.com/three.js/assets/examples/10_orthographic.png" width="109" height="82" alt="camera_ortographic"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_birds.html"><img src="http://mrdoob.github.com/three.js/assets/examples/08_birds.png" width="109" height="82" alt="geometry_birds"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_earth.html"><img src="http://mrdoob.github.com/three.js/assets/examples/07_earth.png" width="109" height="82" alt="geometry_earth"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_terrain.html"><img src="http://mrdoob.github.com/three.js/assets/examples/06_terrain.png" width="109" height="82" alt="geometry_terrain"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_materials_video.html"><img src="http://mrdoob.github.com/three.js/assets/examples/24_materials_video.png" width="109" height="82" alt="materials_video"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_panorama.html"><img src="http://mrdoob.github.com/three.js/assets/examples/04_vr.png" width="109" height="82" alt="geometry_panorama"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_geometry_cube.html"><img src="http://mrdoob.github.com/three.js/assets/examples/03_cube.png" width="109" height="82" alt="geometry_cube"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_particles_sprites.html"><img src="http://mrdoob.github.com/three.js/assets/examples/26_particles_sprites.png" width="109" height="82" alt="particles_sprites"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_particles_random.html"><img src="http://mrdoob.github.com/three.js/assets/examples/02_random.png" width="109" height="82" alt="particles_random"></a>
+<a href="http://mrdoob.github.com/three.js/examples/canvas_particles_waves.html"><img src="http://mrdoob.github.com/three.js/assets/examples/01_waves.png" width="109" height="82" alt="particles_wave"></a>
 
 
 
 
 ### Featured projects ###
 ### Featured projects ###
 
 
-[![Infinite beanstalk](http://mrdoob.github.com/three.js/assets/projects/19_beanstalk.png)](http://inear.se/beanstalk/)
-[![Mission Control](http://mrdoob.github.com/three.js/assets/projects/18_missioncontrol.png)](http://superfad.com/missioncontrol/)
-[![ROME](http://mrdoob.github.com/three.js/assets/projects/17_rome.png)](http://ro.me/)
-[![Globe](http://mrdoob.github.com/three.js/assets/projects/16_globe.png)](http://data-arts.appspot.com/globe)
-[![Photoparticles](http://mrdoob.github.com/three.js/assets/projects/15_photoparticles.png)](http://lab.aerotwist.com/webgl/photoparticles/)
-[![Plumegraph](http://mrdoob.github.com/three.js/assets/projects/14_plumegraph.png)](http://plumegraph.org/)
-[![HelloRacer](http://mrdoob.github.com/three.js/assets/projects/13_helloracer.png)](http://helloracer.com/webgl/)
-[![FastKat](http://mrdoob.github.com/three.js/assets/projects/12_fastkat.png)](http://www.omiod.com/games/fastkat.php)
-[![Sculpt](http://mrdoob.github.com/three.js/assets/projects/11_sculpt.png)](http://antimatter15.com/wp/2010/11/digital-sculpting-with-three-js/)
-[![Voxels](http://mrdoob.github.com/three.js/assets/projects/10_voxels.png)](http://mrdoob.com/projects/voxels/)
-[![The Wilderness Downtown](http://mrdoob.github.com/three.js/assets/projects/09_arcadefire.png)](http://thewildernessdowntown.com/)
-[![Or so they say...](http://mrdoob.github.com/three.js/assets/projects/07_orsotheysay.png)](http://xplsv.com/prods/demos/xplsv_orsotheysay/)
+<a href="http://inear.se/beanstalk/"><img src="http://mrdoob.github.com/three.js/assets/projects/19_beanstalk.png" width="109" height="82" alt="Infinite beanstalk"></a>
+<a href="http://superfad.com/missioncontrol/"><img src="http://mrdoob.github.com/three.js/assets/projects/18_missioncontrol.png" width="109" height="82" alt="Mission Control"></a>
+<a href="http://ro.me/"><img src="http://mrdoob.github.com/three.js/assets/projects/17_rome.png" width="109" height="82" alt="ROME"></a>
+<a href="http://data-arts.appspot.com/globe"><img src="http://mrdoob.github.com/three.js/assets/projects/16_globe.png" width="109" height="82" alt="Globe"></a>
+<a href="http://lab.aerotwist.com/webgl/photoparticles/"><img src="http://mrdoob.github.com/three.js/assets/projects/15_photoparticles.png" width="109" height="82" alt="Photoparticles"></a>
+<a href="http://plumegraph.org/"><img src="http://mrdoob.github.com/three.js/assets/projects/14_plumegraph.png" width="109" height="82" alt="Plumegraph"></a>
+<a href="http://helloracer.com/webgl/"><img src="http://mrdoob.github.com/three.js/assets/projects/13_helloracer.png" width="109" height="82" alt="HelloRacer"></a>
+<a href="http://www.omiod.com/games/fastkat.php"><img src="http://mrdoob.github.com/three.js/assets/projects/12_fastkat.png" width="109" height="82" alt="FastKat"></a>
+<a href="http://antimatter15.com/wp/2010/11/digital-sculpting-with-three-js/"><img src="http://mrdoob.github.com/three.js/assets/projects/11_sculpt.png" width="109" height="82" alt="Sculpt"></a>
+<a href="http://mrdoob.com/projects/voxels/"><img src="http://mrdoob.github.com/three.js/assets/projects/10_voxels.png" width="109" height="82" alt="Voxels"></a>
+<a href="http://thewildernessdowntown.com/"><img src="http://mrdoob.github.com/three.js/assets/projects/09_arcadefire.png" width="109" height="82" alt="The Wilderness Downtown"></a>
+<a href="http://xplsv.com/prods/demos/xplsv_orsotheysay/"><img src="http://mrdoob.github.com/three.js/assets/projects/07_orsotheysay.png" width="109" height="82" alt="Or so they say..."></a>
 
 
 
 
 ### Usage ###
 ### Usage ###
@@ -136,6 +136,21 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
 ### Change Log ###
 ### Change Log ###
 
 
 
 
+2011 09 04 - **r44** (330.356 KB, gzip: 84.039 KB)
+
+* Added `ColladaLoader`. ([timknip2](https://github.com/timknip2))
+* Improved `ExtrudeGeometry`. ([zz85](http://github.com/zz85))
+* Fixed `CylinderGeometry` normals. ([alteredq](http://github.com/alteredq))
+* Fixed issue with `WebGLRenderer.setTexture` ([rectalogic](https://github.com/rectalogic))
+* Fixed `TorusGeometry` normals. ([mrdoob](http://github.com/mrdoob))
+* Fixed `Ray` behind-ray intersects. ([mrdoob](http://github.com/mrdoob))
+* Added `OrthoCamera`. ([alteredq](http://github.com/alteredq))
+* Refactored postprocessing effects used in some examples. ([alteredq](http://github.com/alteredq))
+* Added `.deallocateObject()` and `.deallocateTexture()` methods to `WebGLRenderer`. ([mrdoob](http://github.com/mrdoob))
+* Fixed a glitch in normal and phong shader. ([evanw](http://github.com/evanw) and [alteredq](http://github.com/alteredq))
+* Added `.frustumCulled` property to `Object3D`. ([alteredq](http://github.com/alteredq) and [mrdoob](http://github.com/mrdoob))
+
+
 2011 08 14 - **r43** (298.199 KB, gzip: 74.805 KB)
 2011 08 14 - **r43** (298.199 KB, gzip: 74.805 KB)
 
 
 * Improved Blender exporter - 2.58 (and 2.59) support, normals maps, specular, ao maps... ([alteredq](http://github.com/alteredq))
 * Improved Blender exporter - 2.58 (and 2.59) support, normals maps, specular, ao maps... ([alteredq](http://github.com/alteredq))
@@ -155,6 +170,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a &
 * `CanvasRenderer` now supports `RepeatWrapping`, `texture.offset` and `texture.repeat`. ([mrdoob](http://github.com/mrdoob))
 * `CanvasRenderer` now supports `RepeatWrapping`, `texture.offset` and `texture.repeat`. ([mrdoob](http://github.com/mrdoob))
 * Removed Stencil Shadows and Lensflare code. ([mrdoob](http://github.com/mrdoob))
 * Removed Stencil Shadows and Lensflare code. ([mrdoob](http://github.com/mrdoob))
 
 
+
 2011 07 06 - **r42** (277.852 KB, gzip: 69.469 KB)
 2011 07 06 - **r42** (277.852 KB, gzip: 69.469 KB)
 
 
 * Added `AnaglypWebGLRenderer` and `CrosseyedWebGLRenderer`. ([mrdoob](http://github.com/mrdoob), [alteredq](http://github.com/alteredq) and [marklundin](http://github.com/marklundin))
 * Added `AnaglypWebGLRenderer` and `CrosseyedWebGLRenderer`. ([mrdoob](http://github.com/mrdoob), [alteredq](http://github.com/alteredq) and [marklundin](http://github.com/marklundin))

+ 1 - 1
REVISION

@@ -1 +1 @@
-44dev
+44

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 251 - 246
build/Three.js


+ 86 - 86
build/custom/ThreeCanvas.js

@@ -1,6 +1,6 @@
-// ThreeCanvas.js r44dev - http://github.com/mrdoob/three.js
+// ThreeCanvas.js r44 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
-THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
+THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,f,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),f=a*6-d,a=c*(1-b),g=c*(1-b*f),b=c*(1-b*(1-f)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
 THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
 THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
@@ -15,68 +15,79 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=
 a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){a?(this.x/=a,this.y/=a,this.z/=a,this.w/=a):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),
-c=c.clone().subSelf(b),e=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(e),f=c.dot(c),c=c.dot(e),e=1/(a*f-b*b),f=(f*d-b*c)*e,a=(a*c-b*d)*e;return f>0&&a>0&&f+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,
-Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,i,l,n,j,m,k,p=a.geometry,q=p.vertices,u=[],d=0;for(e=p.faces.length;d<e;d++)if(g=p.faces[d],m=this.origin.clone(),k=this.direction.clone(),l=a.matrixWorld,f=l.multiplyVector3(g.centroid.clone()).subSelf(m),j=f.dot(k),!(j<=0)&&(f=l.multiplyVector3(q[g.a].position.clone()),h=l.multiplyVector3(q[g.b].position.clone()),i=l.multiplyVector3(q[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(q[g.d].position.clone()):null,n=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),
-j=k.dot(n),a.doubleSided||(a.flipSided?j>0:j<0)))if(j=n.dot((new THREE.Vector3).sub(f,m))/j,m=m.addSelf(k.multiplyScalar(j)),g instanceof THREE.Face3)c(m,f,h,i)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g));else if(g instanceof THREE.Face4&&(c(m,f,h,l)||c(m,h,i,l)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g);u.sort(function(a,b){return a.distance-b.distance});return u}else return[]}};
-THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,n,j){h=!1;b=f;c=g;d=n;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
-function(f,g,n,j,m,k){h?(h=!1,b=f<n?f<m?f:m:n<m?n:m,c=g<j?g<k?g:k:j<k?j:k,d=f>n?f>m?f:m:n>m?n:m,e=g>j?g>k?g:k:j>k?j:k):(b=f<n?f<m?f<b?f:b:m<b?m:b:n<m?n<b?n:b:m<b?m:b,c=g<j?g<k?g<c?g:c:k<c?k:c:j<k?j<c?j:c:k<c?k:c,d=f>n?f>m?f>d?f:d:m>d?m:d:n>m?n>d?n:d:m>d?m:d,e=g>j?g>k?g>e?g:e:k>e?k:e:j>k?j>e?j:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
-f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]};
-THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,g,f,h,i,l,n,j,m,k,p,q){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,i||0,l||0,n||1,j||0,m||0,k||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,i,l,n,j,m,k,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=i;this.n32=l;this.n33=n;this.n34=j;this.n41=m;this.n42=k;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
-b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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,g=a.n14,f=a.n21,h=a.n22,i=a.n23,l=a.n24,n=a.n31,j=a.n32,m=a.n33,k=a.n34,p=a.n41,q=a.n42,u=a.n43,s=a.n44,O=b.n11,P=b.n12,
-y=b.n13,B=b.n14,o=b.n21,t=b.n22,r=b.n23,x=b.n24,E=b.n31,Z=b.n32,$=b.n33,I=b.n34,D=b.n41,J=b.n42,M=b.n43,F=b.n44;this.n11=c*O+d*o+e*E+g*D;this.n12=c*P+d*t+e*Z+g*J;this.n13=c*y+d*r+e*$+g*M;this.n14=c*B+d*x+e*I+g*F;this.n21=f*O+h*o+i*E+l*D;this.n22=f*P+h*t+i*Z+l*J;this.n23=f*y+h*r+i*$+l*M;this.n24=f*B+h*x+i*I+l*F;this.n31=n*O+j*o+m*E+k*D;this.n32=n*P+j*t+m*Z+k*J;this.n33=n*y+j*r+m*$+k*M;this.n34=n*B+j*x+m*I+k*F;this.n41=p*O+q*o+u*E+s*D;this.n42=p*P+q*t+u*Z+s*J;this.n43=p*y+q*r+u*$+s*M;this.n44=p*B+q*
-x+u*I+s*F;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=
-a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,h=this.n24,i=this.n31,l=this.n32,n=this.n33,j=this.n34,m=this.n41,k=this.n42,p=this.n43,q=this.n44;return d*f*l*m-c*h*l*m-d*g*n*m+b*h*n*m+c*g*j*m-b*f*j*m-d*f*i*k+c*h*i*k+d*e*n*k-a*h*n*k-c*e*j*k+a*f*j*k+d*g*i*p-b*h*i*p-d*e*l*p+a*h*l*p+b*e*j*p-a*g*j*p-c*g*i*q+b*f*i*q+c*e*l*q-a*f*l*q-b*e*n*q+a*g*n*q},
+c=c.clone().subSelf(b),f=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(f),e=c.dot(c),c=c.dot(f),f=1/(a*e-b*b),e=(e*d-b*c)*f,a=(a*c-b*d)*f;return e>0&&a>0&&e+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,
+Math.max(a.scale.y,a.scale.z)))return[];var f,g,e,h,j,l,o,i,m,k,p=a.geometry,r=p.vertices,u=[],d=0;for(f=p.faces.length;d<f;d++)if(g=p.faces[d],m=this.origin.clone(),k=this.direction.clone(),l=a.matrixWorld,e=l.multiplyVector3(g.centroid.clone()).subSelf(m),i=e.dot(k),!(i<=0)&&(e=l.multiplyVector3(r[g.a].position.clone()),h=l.multiplyVector3(r[g.b].position.clone()),j=l.multiplyVector3(r[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(r[g.d].position.clone()):null,o=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),
+i=k.dot(o),a.doubleSided||(a.flipSided?i>0:i<0)))if(i=o.dot((new THREE.Vector3).sub(e,m))/i,m=m.addSelf(k.multiplyScalar(i)),g instanceof THREE.Face3)c(m,e,h,j)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g));else if(g instanceof THREE.Face4&&(c(m,e,h,l)||c(m,h,j,l)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g);u.sort(function(a,b){return a.distance-b.distance});return u}else return[]}};
+THREE.Rectangle=function(){function a(){g=d-b;e=f-c}var b,c,d,f,g,e,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return e};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,o,i){h=!1;b=e;c=g;d=o;f=i;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=b<e?b:e,c=c<g?c:g,d=d>e?d:e,f=f>g?f:g);a()};this.add3Points=
+function(e,g,o,i,m,k){h?(h=!1,b=e<o?e<m?e:m:o<m?o:m,c=g<i?g<k?g:k:i<k?i:k,d=e>o?e>m?e:m:o>m?o:m,f=g>i?g>k?g:k:i>k?i:k):(b=e<o?e<m?e<b?e:b:m<b?m:b:o<m?o<b?o:b:m<b?m:b,c=g<i?g<k?g<c?g:c:k<c?k:c:i<k?i<c?i:c:k<c?k:c,d=e>o?e>m?e>d?e:d:m>d?m:d:o>m?o>d?o:d:m>d?m:d,f=g>i?g>k?g>f?g:f:k>f?k:f:i>k?i>f?i:f:k>f?k:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),f=f>
+e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]};
+THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,f,g,e,h,j,l,o,i,m,k,p,r){this.set(a||1,b||0,c||0,d||0,f||0,g||1,e||0,h||0,j||0,l||0,o||1,i||0,m||0,k||0,p||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,f,g,e,h,j,l,o,i,m,k,p,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=e;this.n24=h;this.n31=j;this.n32=l;this.n33=o;this.n34=i;this.n41=m;this.n42=k;this.n43=p;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,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;
+a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+
+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,m=a.n33,k=a.n34,p=a.n41,r=a.n42,u=a.n43,s=a.n44,K=b.n11,P=b.n12,
+y=b.n13,L=b.n14,M=b.n21,q=b.n22,n=b.n23,z=b.n24,A=b.n31,R=b.n32,S=b.n33,E=b.n34,I=b.n41,G=b.n42,H=b.n43,N=b.n44;this.n11=c*K+d*M+f*A+g*I;this.n12=c*P+d*q+f*R+g*G;this.n13=c*y+d*n+f*S+g*H;this.n14=c*L+d*z+f*E+g*N;this.n21=e*K+h*M+j*A+l*I;this.n22=e*P+h*q+j*R+l*G;this.n23=e*y+h*n+j*S+l*H;this.n24=e*L+h*z+j*E+l*N;this.n31=o*K+i*M+m*A+k*I;this.n32=o*P+i*q+m*R+k*G;this.n33=o*y+i*n+m*S+k*H;this.n34=o*L+i*z+m*E+k*N;this.n41=p*K+r*M+u*A+s*I;this.n42=p*P+r*q+u*R+s*G;this.n43=p*y+r*n+u*S+s*H;this.n44=p*L+r*
+z+u*E+s*N;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=
+a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,e=this.n23,h=this.n24,j=this.n31,l=this.n32,o=this.n33,i=this.n34,m=this.n41,k=this.n42,p=this.n43,r=this.n44;return d*e*l*m-c*h*l*m-d*g*o*m+b*h*o*m+c*g*i*m-b*e*i*m-d*e*j*k+c*h*j*k+d*f*o*k-a*h*o*k-c*f*i*k+a*e*i*k+d*g*j*p-b*h*j*p-d*f*l*p+a*h*l*p+b*f*i*p-a*g*i*p-c*g*j*r+b*e*j*r+c*f*l*r-a*e*l*r-b*f*o*r+a*g*o*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;
 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.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[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,
 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,g=a.x,f=a.y,h=a.z,i=e*g,l=e*f;this.set(i*g+c,i*f-d*h,i*h+d*f,0,i*f+d*h,l*f+c,l*h-d*g,0,i*h-d*f,l*h+d*g,e*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=
-new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var i=
-f*h,l=f*e,n=d*h,j=d*e;this.n11=i+j*c;this.n12=n*c-l;this.n13=g*d;this.n21=g*e;this.n22=g*h;this.n23=-c;this.n31=l*c-n;this.n32=j+i*c;this.n33=g*f;break;case "ZXY":i=f*h;l=f*e;n=d*h;j=d*e;this.n11=i-j*c;this.n12=-g*e;this.n13=n+l*c;this.n21=l+n*c;this.n22=g*h;this.n23=j-i*c;this.n31=-g*d;this.n32=c;this.n33=g*f;break;case "ZYX":i=g*h;l=g*e;n=c*h;j=c*e;this.n11=f*h;this.n12=n*d-l;this.n13=i*d+j;this.n21=f*e;this.n22=j*d+i;this.n23=l*d-n;this.n31=-d;this.n32=c*f;this.n33=g*f;break;case "YZX":i=g*f;l=
-g*d;n=c*f;j=c*d;this.n11=f*h;this.n12=j-i*e;this.n13=n*e+l;this.n21=e;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*e+n;this.n33=i-j*e;break;case "XZY":i=g*f;l=g*d;n=c*f;j=c*d;this.n11=f*h;this.n12=-e;this.n13=d*h;this.n21=i*e+j;this.n22=g*h;this.n23=l*e-n;this.n31=n*e-l;this.n32=c*h;this.n33=j*e+i;break;default:i=g*h,l=g*e,n=c*h,j=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=l+n*d,this.n22=i-j*d,this.n23=-c*f,this.n31=j-i*d,this.n32=n+l*d,this.n33=g*f}return this},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,i=b*f;b*=h;var l=c*f;c*=h;d*=h;g*=e;f*=e;e*=h;this.n11=1-(l+d);this.n12=i-e;this.n13=b+f;this.n21=i+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;
-d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();
-c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},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,g=a.n14,f=a.n21,h=a.n22,i=a.n23,l=a.n24,n=a.n31,j=a.n32,m=a.n33,k=a.n34,p=a.n41,q=a.n42,u=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=i*k*q-l*m*q+l*j*u-h*k*u-i*j*s+h*m*s;b.n12=g*m*q-e*k*q-g*j*u+d*k*u+e*j*s-d*m*s;b.n13=e*l*q-g*i*q+g*h*u-d*l*u-e*h*s+d*i*s;b.n14=g*i*j-e*l*j-g*h*m+d*l*m+e*h*k-d*i*k;b.n21=l*m*p-i*k*p-l*n*u+f*k*u+i*n*s-f*m*s;b.n22=e*k*p-g*m*p+g*n*u-c*k*u-e*n*s+c*m*s;b.n23=g*i*p-e*l*p-g*f*u+c*l*u+e*f*s-c*i*s;b.n24=
-e*l*n-g*i*n+g*f*m-c*l*m-e*f*k+c*i*k;b.n31=h*k*p-l*j*p+l*n*q-f*k*q-h*n*s+f*j*s;b.n32=g*j*p-d*k*p-g*n*q+c*k*q+d*n*s-c*j*s;b.n33=e*l*p-g*h*p+g*f*q-c*l*q-d*f*s+c*h*s;b.n34=g*h*n-d*l*n-g*f*j+c*l*j+d*f*k-c*h*k;b.n41=i*j*p-h*m*p-i*n*q+f*m*q+h*n*u-f*j*u;b.n42=d*m*p-e*j*p+e*n*q-c*m*q-d*n*u+c*j*u;b.n43=e*h*p-d*i*p-e*f*q+c*i*q+d*f*u-c*h*u;b.n44=d*i*n-e*h*n+e*f*j-c*i*j-d*f*m+c*h*m;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-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,j=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*i;c[6]=a*l;c[7]=a*n;c[8]=a*j;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,i,l;f=new THREE.Matrix4;h=b-a;i=c-d;l=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/i;f.n23=0;f.n24=-((c+d)/i);f.n31=0;f.n32=0;f.n33=-2/l;f.n34=-((g+e)/l);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
-THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;
-this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
+0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,e=a.y,h=a.z,j=f*g,l=f*e;this.set(j*g+c,j*e-d*h,j*h+d*e,0,j*e+d*h,l*e+c,l*h-d*g,0,j*h-d*e,l*h+d*g,f*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=
+new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,f=a.z,g=Math.cos(c),c=Math.sin(c),e=Math.cos(d),d=Math.sin(d),h=Math.cos(f),f=Math.sin(f);switch(b){case "YXZ":var j=
+e*h,l=e*f,o=d*h,i=d*f;this.n11=j+i*c;this.n12=o*c-l;this.n13=g*d;this.n21=g*f;this.n22=g*h;this.n23=-c;this.n31=l*c-o;this.n32=i+j*c;this.n33=g*e;break;case "ZXY":j=e*h;l=e*f;o=d*h;i=d*f;this.n11=j-i*c;this.n12=-g*f;this.n13=o+l*c;this.n21=l+o*c;this.n22=g*h;this.n23=i-j*c;this.n31=-g*d;this.n32=c;this.n33=g*e;break;case "ZYX":j=g*h;l=g*f;o=c*h;i=c*f;this.n11=e*h;this.n12=o*d-l;this.n13=j*d+i;this.n21=e*f;this.n22=i*d+j;this.n23=l*d-o;this.n31=-d;this.n32=c*e;this.n33=g*e;break;case "YZX":j=g*e;l=
+g*d;o=c*e;i=c*d;this.n11=e*h;this.n12=i-j*f;this.n13=o*f+l;this.n21=f;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*f+o;this.n33=j-i*f;break;case "XZY":j=g*e;l=g*d;o=c*e;i=c*d;this.n11=e*h;this.n12=-f;this.n13=d*h;this.n21=j*f+i;this.n22=g*h;this.n23=l*f-o;this.n31=o*f-l;this.n32=c*h;this.n33=i*f+j;break;default:j=g*h,l=g*f,o=c*h,i=c*f,this.n11=e*h,this.n12=-e*f,this.n13=d,this.n21=l+o*d,this.n22=j-i*d,this.n23=-c*e,this.n31=i-j*d,this.n32=o+l*d,this.n33=g*e}return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,d=a.z,f=a.w,g=b+b,e=c+c,h=d+d,a=b*g,j=b*e;b*=h;var l=c*e;c*=h;d*=h;g*=f;e*=f;f*=h;this.n11=1-(l+d);this.n12=j-f;this.n13=b+e;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-e;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,f=THREE.Matrix4.__m2;
+d.identity();d.setRotationFromQuaternion(b);f.setScale(c.x,c.y,c.z);this.multiply(d,f);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);f.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();
+c.y=f.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/b.y,f=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=
+a.n23*f;this.n33=a.n33*f}};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,m=a.n33,k=a.n34,p=a.n41,r=a.n42,u=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*k*r-l*m*r+l*i*u-h*k*u-j*i*s+h*m*s;b.n12=g*m*r-f*k*r-g*i*u+d*k*u+f*i*s-d*m*s;b.n13=f*l*r-g*j*r+g*h*u-d*l*u-f*h*s+d*j*s;b.n14=g*j*i-f*l*i-g*h*m+d*l*m+f*h*k-d*j*k;b.n21=l*m*p-j*k*p-l*o*u+e*k*u+j*o*s-e*m*s;b.n22=f*k*p-g*m*p+g*o*u-c*k*u-f*o*s+c*m*s;b.n23=g*j*p-f*l*p-g*e*u+c*l*u+f*e*s-c*j*s;b.n24=
+f*l*o-g*j*o+g*e*m-c*l*m-f*e*k+c*j*k;b.n31=h*k*p-l*i*p+l*o*r-e*k*r-h*o*s+e*i*s;b.n32=g*i*p-d*k*p-g*o*r+c*k*r+d*o*s-c*i*s;b.n33=f*l*p-g*h*p+g*e*r-c*l*r-d*e*s+c*h*s;b.n34=g*h*o-d*l*o-g*e*i+c*l*i+d*e*k-c*h*k;b.n41=j*i*p-h*m*p-j*o*r+e*m*r+h*o*u-e*i*u;b.n42=d*m*p-f*i*p+f*o*r-c*m*r-d*o*u+c*i*u;b.n43=f*h*p-d*j*p-f*e*r+c*j*r+d*e*u-c*h*u;b.n44=d*j*o-f*h*o+f*e*i-c*j*i-d*e*m+c*h*m;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,e=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*e+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*e;c[4]=a*h;c[5]=a*j;c[6]=a*l;c[7]=a*o;c[8]=a*i;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var e;e=new THREE.Matrix4;e.n11=2*f/(b-a);e.n12=0;e.n13=(b+a)/(b-a);e.n14=0;e.n21=0;e.n22=2*f/(d-c);e.n23=(d+c)/(d-c);e.n24=0;e.n31=0;e.n32=0;e.n33=-(g+f)/(g-f);e.n34=-2*g*f/(g-f);e.n41=0;e.n42=0;e.n43=-1;e.n44=0;return e};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var e,h,j,l;e=new THREE.Matrix4;h=b-a;j=c-d;l=g-f;e.n11=2/h;e.n12=0;e.n13=0;e.n14=-((b+a)/h);e.n21=0;e.n22=2/j;e.n23=0;e.n24=-((c+d)/j);e.n31=0;e.n32=0;e.n33=-2/l;e.n34=-((g+f)/l);e.n41=0;e.n42=0;e.n43=0;e.n44=1;return e};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
+THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
+!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
--1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);
+-1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,f;c=0;for(d=this.children.length;c<d;c++){f=this.children[c];if(f.name===a)return f;if(b&&(f=f.getChildByName(a,b),f!==void 0))return f}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
-this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
+this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Object3DCount=0;
+THREE.Projector=function(){function a(){var a=j[h]=j[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,g=[],e,h,j=[],l,o,i=[],m,k=[],p,r,u=[],s,K,P=[],y=[],L=[],M=new THREE.Vector4,q=new THREE.Vector4,
+n=new THREE.Matrix4,z=new THREE.Matrix4,A=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],R=new THREE.Vector4,S=new THREE.Vector4;this.projectVector=function(a,b){n.multiply(b.projectionMatrix,b.matrixWorldInverse);n.multiplyVector3(a);return a};this.unprojectVector=function(a,b){n.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));n.multiplyVector3(a);return a};this.projectObjects=function(a,c,e){var h,k;f=y.length=0;
+h=a.objects;a=0;for(c=h.length;a<c;a++){k=h[a];var l;if(!(l=!k.visible))if(l=k instanceof THREE.Mesh)if(l=k.frustumCulled){a:{l=void 0;for(var i=k.matrixWorld,j=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),m=0;m<6;m++)if(l=A[m].x*i.n14+A[m].y*i.n24+A[m].z*i.n34+A[m].w,l<=j){l=!1;break a}l=!0}l=!l}if(!l)l=g[f]=g[f]||new THREE.RenderableObject,f++,d=l,M.copy(k.position),n.multiplyVector3(M),d.object=k,d.z=M.z,y.push(d)}e&&y.sort(b);return y};this.projectScene=
+function(d,f,g){var H=f.near,N=f.far,O,U,D,y,v,J,F,w,C,t,B,T,M,da,Y,aa,V;K=r=m=o=L.length=0;f.matrixAutoUpdate&&f.update(void 0,!0);d.update(void 0,!1,f);n.multiply(f.projectionMatrix,f.matrixWorldInverse);A[0].set(n.n41-n.n11,n.n42-n.n12,n.n43-n.n13,n.n44-n.n14);A[1].set(n.n41+n.n11,n.n42+n.n12,n.n43+n.n13,n.n44+n.n14);A[2].set(n.n41+n.n21,n.n42+n.n22,n.n43+n.n23,n.n44+n.n24);A[3].set(n.n41-n.n21,n.n42-n.n22,n.n43-n.n23,n.n44-n.n24);A[4].set(n.n41-n.n31,n.n42-n.n32,n.n43-n.n33,n.n44-n.n34);A[5].set(n.n41+
+n.n31,n.n42+n.n32,n.n43+n.n33,n.n44+n.n34);for(O=0;O<6;O++)C=A[O],C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z));C=this.projectObjects(d,f,!0);d=0;for(O=C.length;d<O;d++)if(t=C[d].object,t.visible)if(B=t.matrixWorld,T=t.matrixRotationWorld,M=t.materials,da=t.overdraw,h=0,t instanceof THREE.Mesh){Y=t.geometry;y=Y.vertices;aa=Y.faces;Y=Y.faceVertexUvs;U=0;for(D=y.length;U<D;U++)e=a(),e.positionWorld.copy(y[U].position),B.multiplyVector3(e.positionWorld),e.positionScreen.copy(e.positionWorld),n.multiplyVector4(e.positionScreen),
+e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>H&&e.positionScreen.z<N;y=0;for(U=aa.length;y<U;y++){D=aa[y];if(D instanceof THREE.Face3)if(v=j[D.a],J=j[D.b],F=j[D.c],v.visible&&J.visible&&F.visible&&(t.doubleSided||t.flipSided!=(F.positionScreen.x-v.positionScreen.x)*(J.positionScreen.y-v.positionScreen.y)-(F.positionScreen.y-v.positionScreen.y)*(J.positionScreen.x-v.positionScreen.x)<0))w=i[o]=i[o]||new THREE.RenderableFace3,o++,l=w,l.v1.copy(v),
+l.v2.copy(J),l.v3.copy(F);else continue;else if(D instanceof THREE.Face4)if(v=j[D.a],J=j[D.b],F=j[D.c],w=j[D.d],v.visible&&J.visible&&F.visible&&w.visible&&(t.doubleSided||t.flipSided!=((w.positionScreen.x-v.positionScreen.x)*(J.positionScreen.y-v.positionScreen.y)-(w.positionScreen.y-v.positionScreen.y)*(J.positionScreen.x-v.positionScreen.x)<0||(J.positionScreen.x-F.positionScreen.x)*(w.positionScreen.y-F.positionScreen.y)-(J.positionScreen.y-F.positionScreen.y)*(w.positionScreen.x-F.positionScreen.x)<
+0)))V=k[m]=k[m]||new THREE.RenderableFace4,m++,l=V,l.v1.copy(v),l.v2.copy(J),l.v3.copy(F),l.v4.copy(w);else continue;l.normalWorld.copy(D.normal);T.multiplyVector3(l.normalWorld);l.centroidWorld.copy(D.centroid);B.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);n.multiplyVector3(l.centroidScreen);F=D.vertexNormals;v=0;for(J=F.length;v<J;v++)w=l.vertexNormalsWorld[v],w.copy(F[v]),T.multiplyVector3(w);v=0;for(J=Y.length;v<J;v++)if(V=Y[v][y]){F=0;for(w=V.length;F<w;F++)l.uvs[v][F]=
+V[F]}l.meshMaterials=M;l.faceMaterials=D.materials;l.overdraw=da;l.z=l.centroidScreen.z;L.push(l)}}else if(t instanceof THREE.Line){z.multiply(n,B);y=t.geometry.vertices;v=a();v.positionScreen.copy(y[0].position);z.multiplyVector4(v.positionScreen);U=1;for(D=y.length;U<D;U++)if(v=a(),v.positionScreen.copy(y[U].position),z.multiplyVector4(v.positionScreen),J=j[h-2],R.copy(v.positionScreen),S.copy(J.positionScreen),c(R,S))R.multiplyScalar(1/R.w),S.multiplyScalar(1/S.w),B=u[r]=u[r]||new THREE.RenderableLine,
+r++,p=B,p.v1.positionScreen.copy(R),p.v2.positionScreen.copy(S),p.z=Math.max(R.z,S.z),p.materials=t.materials,L.push(p)}else if(t instanceof THREE.Particle&&(q.set(t.matrixWorld.n14,t.matrixWorld.n24,t.matrixWorld.n34,1),n.multiplyVector4(q),q.z/=q.w,q.z>0&&q.z<1))B=P[K]=P[K]||new THREE.RenderableParticle,K++,s=B,s.x=q.x/q.w,s.y=q.y/q.w,s.z=q.z,s.rotation=t.rotation.z,s.scale.x=t.scale.x*Math.abs(s.x-(q.x+f.projectionMatrix.n11)/(q.w+f.projectionMatrix.n14)),s.scale.y=t.scale.y*Math.abs(s.y-(q.y+
+f.projectionMatrix.n22)/(q.w+f.projectionMatrix.n24)),s.materials=t.materials,L.push(s);g&&L.sort(b);return L}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-f),f=Math.sin(-f),g=Math.cos(c),c=Math.sin(c),e=a*b,h=d*f;this.w=e*g-h*c;this.x=e*c+h*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,i=this.w,l=i*c+f*e-h*d,n=i*d+h*c-g*e,j=i*e+g*d-f*c,c=-g*
-c-f*d-h*e;b.x=l*i+c*-g+n*-h-j*-f;b.y=n*i+c*-f+j*-g-l*-h;b.z=j*i+c*-h+l*-f-n*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
-THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
+this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,j=this.w,l=j*c+e*f-h*d,o=j*d+h*c-g*f,i=j*f+g*d-e*c,c=-g*
+c-e*d-h*f;b.x=l*j+c*-g+o*-h-i*-e;b.y=o*j+c*-e+i*-g-l*-h;b.z=i*j+c*-h+l*-e-o*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};
+THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
-THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
+THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
 THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),
 THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),
-c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,e,g,f,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],f=this.vertices[g.c],h.sub(f.position,c.position),i.sub(b.position,c.position),h.crossSelf(i);h.isZero()||
+c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,f,g,e,h=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],e=this.vertices[g.c],h.sub(e.position,c.position),j.sub(b.position,c.position),h.crossSelf(j);h.isZero()||
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
-c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,g,r){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;n=f[e];j=f[g];m=f[r];k=i.x-h.x;p=l.x-h.x;q=i.y-h.y;u=l.y-h.y;s=i.z-h.z;O=l.z-h.z;P=j.u-n.u;y=m.u-n.u;B=j.v-n.v;o=m.v-n.v;t=1/(P*o-y*B);Z.set((o*k-B*p)*
-t,(o*q-B*u)*t,(o*s-B*O)*t);$.set((P*p-y*k)*t,(P*u-y*q)*t,(P*O-y*s)*t);x[b].addSelf(Z);x[c].addSelf(Z);x[d].addSelf(Z);E[b].addSelf($);E[c].addSelf($);E[d].addSelf($)}var b,c,d,e,g,f,h,i,l,n,j,m,k,p,q,u,s,O,P,y,B,o,t,r,x=[],E=[],Z=new THREE.Vector3,$=new THREE.Vector3,I=new THREE.Vector3,D=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)x[b]=new THREE.Vector3,E[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],f=this.faceVertexUvs[0][b],g instanceof
-THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var M=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)J.copy(g.vertexNormals[d]),e=g[M[d]],r=x[e],I.copy(r),I.subSelf(J.multiplyScalar(J.dot(r))).normalize(),D.cross(g.vertexNormals[d],r),e=D.dot(E[e]),e=e<0?-1:1,g.vertexTangents[d]=new THREE.Vector4(I.x,I.y,I.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,f,g,n){h=a.vertices[b].position;j=a.vertices[c].position;l=a.vertices[d].position;o=e[f];i=e[g];m=e[n];k=j.x-h.x;p=l.x-h.x;r=j.y-h.y;u=l.y-h.y;s=j.z-h.z;K=l.z-h.z;P=i.u-o.u;y=m.u-o.u;L=i.v-o.v;M=m.v-o.v;q=1/(P*M-y*L);R.set((M*k-L*p)*
+q,(M*r-L*u)*q,(M*s-L*K)*q);S.set((P*p-y*k)*q,(P*u-y*r)*q,(P*K-y*s)*q);z[b].addSelf(R);z[c].addSelf(R);z[d].addSelf(R);A[b].addSelf(S);A[c].addSelf(S);A[d].addSelf(S)}var b,c,d,f,g,e,h,j,l,o,i,m,k,p,r,u,s,K,P,y,L,M,q,n,z=[],A=[],R=new THREE.Vector3,S=new THREE.Vector3,E=new THREE.Vector3,I=new THREE.Vector3,G=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)z[b]=new THREE.Vector3,A[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],e=this.faceVertexUvs[0][b],g instanceof
+THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var H=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)G.copy(g.vertexNormals[d]),f=g[H[d]],n=z[f],E.copy(n),E.subSelf(G.multiplyScalar(G.dot(n))).normalize(),I.cross(g.vertexNormals[d],n),f=I.dot(A[f]),f=f<0?-1:1,g.vertexTangents[d]=new THREE.Vector4(E.x,E.y,E.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
-void 0?(a[b]={set:{},array:[]},a[b].set[c]=1,a[b].array.push(c)):a[b].set[c]===void 0&&(a[b].set[c]=1,a[b].array.push(c))}var c,d,e,g,f,h={};c=0;for(d=this.faces.length;c<d;c++)f=this.faces[c],f instanceof THREE.Face3?(e=a(f.a,f.b),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.a,f.c),b(h,e,c)):f instanceof THREE.Face4&&(e=a(f.b,f.d),b(h,e,c),e=a(f.a,f.b),b(h,e,c),e=a(f.a,f.d),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.c,f.d),b(h,e,c));c=0;for(d=this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];g=f.vertexIndices[1];
-f.faceIndices=h[a(e,g)].array;for(e=0;e<f.faceIndices.length;e++)g=f.faceIndices[e],f.faces.push(this.faces[g])}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
+void 0?(a[b]={set:{},array:[]},a[b].set[c]=1,a[b].array.push(c)):a[b].set[c]===void 0&&(a[b].set[c]=1,a[b].array.push(c))}var c,d,f,g,e,h={};c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],e instanceof THREE.Face3?(f=a(e.a,e.b),b(h,f,c),f=a(e.b,e.c),b(h,f,c),f=a(e.a,e.c),b(h,f,c)):e instanceof THREE.Face4&&(f=a(e.b,e.d),b(h,f,c),f=a(e.a,e.b),b(h,f,c),f=a(e.a,e.d),b(h,f,c),f=a(e.b,e.c),b(h,f,c),f=a(e.c,e.d),b(h,f,c));c=0;for(d=this.edges.length;c<d;c++){e=this.edges[c];f=e.vertexIndices[0];g=e.vertexIndices[1];
+e.faceIndices=h[a(f,g)].array;for(f=0;f<e.faceIndices.length;f++)g=e.faceIndices[f],e.faces.push(this.faces[g])}}};THREE.GeometryCount=0;THREE.Camera=function(a,b,c,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)};
 THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
-THREE.Camera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
+THREE.Camera.prototype.setViewOffset=function(a,b,c,d,f,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=f;this.height=g;this.updateProjectionMatrix()};
 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 if(this.matrixAutoUpdate&&this.updateMatrix(),b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=
 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 if(this.matrixAutoUpdate&&this.updateMatrix(),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.OrthoCamera=function(a,b,c,d,e,g,f){THREE.Camera.call(this,45,1,e,g,f);this.left=a;this.right=b;this.top=c;this.bottom=d;this.updateProjectionMatrix()};THREE.OrthoCamera.prototype=new THREE.Camera;THREE.OrthoCamera.prototype.constructor=THREE.OrthoCamera;
+!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.OrthoCamera=function(a,b,c,d,f,g,e){THREE.Camera.call(this,45,1,f,g,e);this.left=a;this.right=b;this.top=c;this.bottom=d;this.updateProjectionMatrix()};THREE.OrthoCamera.prototype=new THREE.Camera;THREE.OrthoCamera.prototype.constructor=THREE.OrthoCamera;
 THREE.OrthoCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};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.OrthoCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};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,c,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0;this.castShadow=d!==void 0?d:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};
 THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b,c,d){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0;this.castShadow=d!==void 0?d:!1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};
 THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
 THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
@@ -96,7 +107,7 @@ THREE.MeshDepthMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.sha
 THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map!==void 0?a.map:null;this.size=a.size!==void 0?a.size:1;this.sizeAttenuation=a.sizeAttenuation!==void 0?a.sizeAttenuation:!0;this.vertexColors=a.vertexColors!==void 0?a.vertexColors:!1};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;
 THREE.ParticleCanvasMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=a.color!==void 0?new THREE.Color(a.color):new THREE.Color(16777215);this.program=a.program!==void 0?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;
-THREE.Texture=function(a,b,c,d,e,g){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==void 0?e:THREE.LinearFilter;this.minFilter=g!==void 0?g:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
+THREE.Texture=function(a,b,c,d,f,g){this.id=THREE.TextureCount++;this.image=a;this.mapping=b!==void 0?b:new THREE.UVMapping;this.wrapS=c!==void 0?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==void 0?d:THREE.ClampToEdgeWrapping;this.magFilter=f!==void 0?f:THREE.LinearFilter;this.minFilter=g!==void 0?g:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.needsUpdate=!1};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};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.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};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]};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!=void 0?c:THREE.LineStrip};
 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]};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!=void 0?c:THREE.LineStrip};
@@ -104,48 +115,37 @@ THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THR
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=
 THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b&&b.length?b:[b];this.overdraw=!1;if(this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius,this.geometry.morphTargets.length)){this.morphTargetBase=-1;this.morphTargetForcedOrder=[];this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=
 c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
 c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(this.morphTargetDictionary[a]!==void 0)return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
 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=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
-THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var d,e=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<e;d++)a=this.children[d],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(d=0;d<e;d++)this.children[d].update(this.skinMatrix,
+THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var d,f=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(d=0;d<f;d++)a=this.children[d],a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}else for(d=0;d<f;d++)this.children[d].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.overrideMaterial=this.fog=null;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1&&(a.parent!==void 0&&a.parent.removeChild(a),a.parent=this,this.children.push(a),!(a instanceof THREE.Bone)))this.hasNoneBoneChildren=!0};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.collisions=this.overrideMaterial=this.fog=null;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var a=i[h]=i[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,i=[],l,n,j=[],m,k=[],p,q,u=[],s,O,P=[],y=new THREE.Vector4,B=new THREE.Vector4,
-o=new THREE.Matrix4,t=new THREE.Matrix4,r=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],x=new THREE.Vector4,E=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,f){var c=[],h,k,j;e=0;k=
-a.objects;a=0;for(h=k.length;a<h;a++){j=k[a];var l;if(!(l=!j.visible))if(l=j instanceof THREE.Mesh){a:{l=void 0;for(var i=j.matrixWorld,m=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),n=0;n<6;n++)if(l=r[n].x*i.n14+r[n].y*i.n24+r[n].z*i.n34+r[n].w,l<=m){l=!1;break a}l=!0}l=!l}if(!l)l=g[e]=g[e]||new THREE.RenderableObject,e++,d=l,y.copy(j.position),o.multiplyVector3(y),d.object=j,d.z=y.z,c.push(d)}f&&c.sort(b);return c};this.projectScene=function(d,e,g){var D=[],
-J=e.near,M=e.far,F,K,G,Q,w,N,L,y,C,v,A,H,S,la,V,ca,W;O=q=m=n=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);r[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);r[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);r[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);r[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);r[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);r[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+
-o.n33,o.n44+o.n34);for(F=0;F<6;F++)C=r[F],C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z));C=this.projectObjects(d,e,!0);d=0;for(F=C.length;d<F;d++)if(v=C[d].object,v.visible)if(A=v.matrixWorld,H=v.matrixRotationWorld,S=v.materials,la=v.overdraw,h=0,v instanceof THREE.Mesh){V=v.geometry;Q=V.vertices;ca=V.faces;V=V.faceVertexUvs;K=0;for(G=Q.length;K<G;K++)f=a(),f.positionWorld.copy(Q[K].position),A.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),
-f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>J&&f.positionScreen.z<M;Q=0;for(K=ca.length;Q<K;Q++){G=ca[Q];if(G instanceof THREE.Face3)if(w=i[G.a],N=i[G.b],L=i[G.c],w.visible&&N.visible&&L.visible&&(v.doubleSided||v.flipSided!=(L.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(L.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0))y=j[n]=j[n]||new THREE.RenderableFace3,n++,l=y,l.v1.copy(w),
-l.v2.copy(N),l.v3.copy(L);else continue;else if(G instanceof THREE.Face4)if(w=i[G.a],N=i[G.b],L=i[G.c],y=i[G.d],w.visible&&N.visible&&L.visible&&y.visible&&(v.doubleSided||v.flipSided!=((y.positionScreen.x-w.positionScreen.x)*(N.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(N.positionScreen.x-w.positionScreen.x)<0||(N.positionScreen.x-L.positionScreen.x)*(y.positionScreen.y-L.positionScreen.y)-(N.positionScreen.y-L.positionScreen.y)*(y.positionScreen.x-L.positionScreen.x)<
-0)))W=k[m]=k[m]||new THREE.RenderableFace4,m++,l=W,l.v1.copy(w),l.v2.copy(N),l.v3.copy(L),l.v4.copy(y);else continue;l.normalWorld.copy(G.normal);H.multiplyVector3(l.normalWorld);l.centroidWorld.copy(G.centroid);A.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);o.multiplyVector3(l.centroidScreen);L=G.vertexNormals;w=0;for(N=L.length;w<N;w++)y=l.vertexNormalsWorld[w],y.copy(L[w]),H.multiplyVector3(y);w=0;for(N=V.length;w<N;w++)if(W=V[w][Q]){L=0;for(y=W.length;L<y;L++)l.uvs[w][L]=
-W[L]}l.meshMaterials=S;l.faceMaterials=G.materials;l.overdraw=la;l.z=l.centroidScreen.z;D.push(l)}}else if(v instanceof THREE.Line){t.multiply(o,A);Q=v.geometry.vertices;w=a();w.positionScreen.copy(Q[0].position);t.multiplyVector4(w.positionScreen);K=1;for(G=Q.length;K<G;K++)if(w=a(),w.positionScreen.copy(Q[K].position),t.multiplyVector4(w.positionScreen),N=i[h-2],x.copy(w.positionScreen),E.copy(N.positionScreen),c(x,E))x.multiplyScalar(1/x.w),E.multiplyScalar(1/E.w),A=u[q]=u[q]||new THREE.RenderableLine,
-q++,p=A,p.v1.positionScreen.copy(x),p.v2.positionScreen.copy(E),p.z=Math.max(x.z,E.z),p.materials=v.materials,D.push(p)}else if(v instanceof THREE.Particle&&(B.set(v.matrixWorld.n14,v.matrixWorld.n24,v.matrixWorld.n34,1),o.multiplyVector4(B),B.z/=B.w,B.z>0&&B.z<1))A=P[O]=P[O]||new THREE.RenderableParticle,O++,s=A,s.x=B.x/B.w,s.y=B.y/B.w,s.z=B.z,s.rotation=v.rotation.z,s.scale.x=v.scale.x*Math.abs(s.x-(B.x+e.projectionMatrix.n11)/(B.w+e.projectionMatrix.n14)),s.scale.y=v.scale.y*Math.abs(s.y-(B.y+
-e.projectionMatrix.n22)/(B.w+e.projectionMatrix.n24)),s.materials=v.materials,D.push(s);g&&D.sort(b);return D}};
-THREE.CanvasRenderer=function(a){function b(a){if(u!=a)k.globalAlpha=u=a}function c(a){if(s!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}s=a}}function d(a){if(O!=a)k.strokeStyle=O=a}function e(a){if(P!=a)k.fillStyle=P=a}var g=this,f=null,h=new THREE.Projector,a=a||{},i=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
-l,n,j,m,k=i.getContext("2d"),p=new THREE.Color(0),q=0,u=1,s=0,O=null,P=null,y=null,B=null,o=null,t,r,x,E,Z=new THREE.RenderableVertex,$=new THREE.RenderableVertex,I,D,J,M,F,K,G,Q,w,N,L,pa,C=new THREE.Color(0),v=new THREE.Color(0),A=new THREE.Color(0),H=new THREE.Color(0),S=new THREE.Color(0),la=[],V,ca,W,aa,Da,Ea,Fa,Ga,Ha,Ia,ja=new THREE.Rectangle,X=new THREE.Rectangle,U=new THREE.Rectangle,za=!1,ba=new THREE.Color,Y=new THREE.Color,ta=new THREE.Color,ua=new THREE.Color,R=new THREE.Vector3,qa,ra,
-Aa,da,sa,va,a=16;qa=document.createElement("canvas");qa.width=qa.height=2;ra=qa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0,0,2,2);Aa=ra.getImageData(0,0,2,2);da=Aa.data;sa=document.createElement("canvas");sa.width=sa.height=a;va=sa.getContext("2d");va.translate(-a/2,-a/2);va.scale(a,a);a--;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;n=b;j=Math.floor(l/2);m=Math.floor(n/2);i.width=l;i.height=n;
-ja.set(-j,-m,j,m);X.set(-j,-m,j,m);u=1;s=0;o=B=y=P=O=null};this.setClearColor=function(a,b){p.copy(a);q=b;X.set(-j,-m,j,m)};this.setClearColorHex=function(a,b){p.setHex(a);q=b;X.set(-j,-m,j,m)};this.clear=function(){k.setTransform(1,0,0,-1,j,m);X.isEmpty()||(X.minSelf(ja),X.inflate(2),q<1&&k.clearRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight())),q>0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*
-255)+","+q+")"),k.fillRect(Math.floor(X.getX()),Math.floor(X.getY()),Math.floor(X.getWidth()),Math.floor(X.getHeight()))),X.empty())};this.render=function(a,l){function i(a){var b,c,d,e=a.lights;Y.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);a=0;for(b=e.length;a<b;a++)c=e[a],d=c.color,c instanceof THREE.AmbientLight?(Y.r+=d.r,Y.g+=d.g,Y.b+=d.b):c instanceof THREE.DirectionalLight?(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b):c instanceof THREE.PointLight&&(ua.r+=d.r,ua.g+=d.g,ua.b+=d.b)}function n(a,b,c,d){var e,
-f,g,h,l=a.lights,a=0;for(e=l.length;a<e;a++)f=l[a],g=f.color,f instanceof THREE.DirectionalLight?(h=c.dot(f.position),h<=0||(h*=f.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):f instanceof THREE.PointLight&&(h=c.dot(R.sub(f.position,b).normalize()),h<=0||(h*=f.distance==0?1:1-Math.min(b.distanceTo(f.position)/f.distance,1),h!=0&&(h*=f.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,f,g){b(g.opacity);c(g.blending);var h,l,n,i,Ba,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=g.map.image,
-Ba=i.width>>1,o=i.height>>1,g=f.scale.x*j,n=f.scale.y*m,h=g*Ba,l=n*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-n),k.translate(-Ba,-o),k.drawImage(i,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*j,l=f.scale.y*m,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(U)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,l),g.program(k),
-k.restore()))}function q(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)k.lineWidth=y=a;a=g.linecap;if(B!=a)k.lineCap=B=a;a=g.linejoin;if(o!=a)k.lineJoin=o=a;d(g.color.getContextStyle());k.stroke();U.inflate(g.linewidth*2)}}function s(a,d,e,f,h,k,j,i,m){g.data.vertices+=3;g.data.faces++;b(i.opacity);c(i.blending);I=a.positionScreen.x;
-D=a.positionScreen.y;J=d.positionScreen.x;M=d.positionScreen.y;F=e.positionScreen.x;K=e.positionScreen.y;O(I,D,J,M,F,K);if(i instanceof THREE.MeshBasicMaterial)if(i.map)i.map.mapping instanceof THREE.UVMapping&&(aa=j.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[k].u,aa[k].v,i.map));else if(i.envMap){if(i.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(j.vertexNormalsWorld[0]),Da=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ea=-(R.x*a.n21+R.y*a.n22+R.z*
-a.n23)*0.5+0.5,R.copy(j.vertexNormalsWorld[1]),Fa=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ga=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,R.copy(j.vertexNormalsWorld[2]),Ha=(R.x*a.n11+R.y*a.n12+R.z*a.n13)*0.5+0.5,Ia=-(R.x*a.n21+R.y*a.n22+R.z*a.n23)*0.5+0.5,Ca(I,D,J,M,F,K,Da,Ea,Fa,Ga,Ha,Ia,i.envMap)}else i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshLambertMaterial)i.map&&!i.wireframe&&(i.map.mapping instanceof THREE.UVMapping&&
-(aa=j.uvs[0],Ca(I,D,J,M,F,K,aa[f].u,aa[f].v,aa[h].u,aa[h].v,aa[k].u,aa[k].v,i.map)),c(THREE.SubtractiveBlending)),za?!i.wireframe&&i.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==3?(v.r=A.r=H.r=Y.r,v.g=A.g=H.g=Y.g,v.b=A.b=H.b=Y.b,n(m,j.v1.positionWorld,j.vertexNormalsWorld[0],v),n(m,j.v2.positionWorld,j.vertexNormalsWorld[1],A),n(m,j.v3.positionWorld,j.vertexNormalsWorld[2],H),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(v,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W)):(ba.r=Y.r,
-ba.g=Y.g,ba.b=Y.b,n(m,j.centroidWorld,j.normalWorld,ba),C.r=Math.max(0,Math.min(i.color.r*ba.r,1)),C.g=Math.max(0,Math.min(i.color.g*ba.g,1)),C.b=Math.max(0,Math.min(i.color.b*ba.b,1)),i.wireframe?fa(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)):i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshDepthMaterial)V=l.near,ca=l.far,v.r=v.g=v.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,
-V,ca),H.r=H.g=H.b=1-ka(e.positionScreen.z,V,ca),S.r=(A.r+H.r)*0.5,S.g=(A.g+H.g)*0.5,S.b=(A.b+H.b)*0.5,W=wa(v,A,H,S),ma(I,D,J,M,F,K,0,0,1,0,0,1,W);else if(i instanceof THREE.MeshNormalMaterial)C.r=na(j.normalWorld.x),C.g=na(j.normalWorld.y),C.b=na(j.normalWorld.z),i.wireframe?fa(C,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(C)}function u(a,d,e,f,h,i,j,k,m){g.data.vertices+=4;g.data.faces++;b(k.opacity);c(k.blending);if(k.map||k.envMap)s(a,d,f,0,1,3,j,k,m),s(h,e,i,1,2,3,j,k,m);else if(I=
-a.positionScreen.x,D=a.positionScreen.y,J=d.positionScreen.x,M=d.positionScreen.y,F=e.positionScreen.x,K=e.positionScreen.y,G=f.positionScreen.x,Q=f.positionScreen.y,w=h.positionScreen.x,N=h.positionScreen.y,L=i.positionScreen.x,pa=i.positionScreen.y,k instanceof THREE.MeshBasicMaterial)P(I,D,J,M,F,K,G,Q),k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color);else if(k instanceof THREE.MeshLambertMaterial)za?!k.wireframe&&k.shading==THREE.SmoothShading&&j.vertexNormalsWorld.length==
-4?(v.r=A.r=H.r=S.r=Y.r,v.g=A.g=H.g=S.g=Y.g,v.b=A.b=H.b=S.b=Y.b,n(m,j.v1.positionWorld,j.vertexNormalsWorld[0],v),n(m,j.v2.positionWorld,j.vertexNormalsWorld[1],A),n(m,j.v4.positionWorld,j.vertexNormalsWorld[3],H),n(m,j.v3.positionWorld,j.vertexNormalsWorld[2],S),W=wa(v,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)):(ba.r=Y.r,ba.g=Y.g,ba.b=Y.b,n(m,j.centroidWorld,j.normalWorld,ba),C.r=Math.max(0,Math.min(k.color.r*ba.r,1)),C.g=Math.max(0,Math.min(k.color.g*
-ba.g,1)),C.b=Math.max(0,Math.min(k.color.b*ba.b,1)),P(I,D,J,M,F,K,G,Q),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C)):(P(I,D,J,M,F,K,G,Q),k.wireframe?fa(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(k.color));else if(k instanceof THREE.MeshNormalMaterial)C.r=na(j.normalWorld.x),C.g=na(j.normalWorld.y),C.b=na(j.normalWorld.z),P(I,D,J,M,F,K,G,Q),k.wireframe?fa(C,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ga(C);else if(k instanceof
-THREE.MeshDepthMaterial)V=l.near,ca=l.far,v.r=v.g=v.b=1-ka(a.positionScreen.z,V,ca),A.r=A.g=A.b=1-ka(d.positionScreen.z,V,ca),H.r=H.g=H.b=1-ka(f.positionScreen.z,V,ca),S.r=S.g=S.b=1-ka(e.positionScreen.z,V,ca),W=wa(v,A,H,S),O(I,D,J,M,G,Q),ma(I,D,J,M,G,Q,0,0,1,0,0,1,W),O(w,N,F,K,L,pa),ma(w,N,F,K,L,pa,1,0,1,1,0,1,W)}function O(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function P(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,
-f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function fa(a,b,c,e){if(y!=b)k.lineWidth=y=b;if(B!=c)k.lineCap=B=c;if(o!=e)k.lineJoin=o=e;d(a.getContextStyle());k.stroke();U.inflate(b*2)}function ga(a){e(a.getContextStyle());k.fill()}function Ca(a,b,c,d,f,g,h,j,i,l,m,n,o){if(o.image.width!=0){if(o.needsUpdate==!0||la[o.id]==void 0){var p=o.wrapS==THREE.RepeatWrapping,q=o.wrapT==THREE.RepeatWrapping;la[o.id]=k.createPattern(o.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");o.needsUpdate=
-!1}e(la[o.id]);var p=o.offset.x/o.repeat.x,q=o.offset.y/o.repeat.y,r=(o.image.width-1)*o.repeat.x,o=(o.image.height-1)*o.repeat.y,h=(h+p)*r,j=(j+q)*o,i=(i+p)*r,l=(l+q)*o,m=(m+p)*r,n=(n+q)*o;c-=a;d-=b;f-=a;g-=b;i-=h;l-=j;m-=h;n-=j;p=1/(i*n-m*l);o=(n*c-l*f)*p;l=(n*d-l*g)*p;c=(i*f-m*c)*p;d=(i*g-m*d)*p;a=a-o*h-c*j;b=b-l*h-d*j;k.save();k.transform(o,l,c,d,a,b);k.fill();k.restore()}}function ma(a,b,c,d,e,f,g,h,j,i,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;j*=o;i*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;
-j-=g;i-=h;l-=g;m-=h;p=1/(j*m-l*i);o=(m*c-i*e)*p;i=(m*d-i*f)*p;c=(j*e-l*c)*p;d=(j*f-l*d)*p;a=a-o*g-c*h;b=b-i*g-d*h;k.save();k.transform(o,i,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function wa(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);da[0]=e<0?0:e>255?255:e;da[1]=f<0?0:f>255?255:f;da[2]=a<0?0:a>255?255:a;da[4]=g<0?0:g>255?255:g;da[5]=h<0?0:h>255?255:h;
-da[6]=b<0?0:b>255?255:b;da[8]=i<0?0:i>255?255:i;da[9]=j<0?0:j>255?255:j;da[10]=c<0?0:c>255?255:c;da[12]=k<0?0:k>255?255:k;da[13]=l<0?0:l>255?255:l;da[14]=d<0?0:d>255?255:d;ra.putImageData(Aa,0,0);va.drawImage(qa,0,0);return sa}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function na(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xa,Ja,z,ea,ia,oa,ya,T;this.autoClear?this.clear():k.setTransform(1,
-0,0,-1,j,m);g.data.vertices=0;g.data.faces=0;f=h.projectScene(a,l,this.sortElements);(za=a.lights.length>0)&&i(a);xa=0;for(Ja=f.length;xa<Ja;xa++){z=f[xa];U.empty();if(z instanceof THREE.RenderableParticle){t=z;t.x*=j;t.y*=m;ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&p(t,z,T,a)}else if(z instanceof THREE.RenderableLine){if(t=z.v1,r=z.v2,t.positionScreen.x*=j,t.positionScreen.y*=m,r.positionScreen.x*=j,r.positionScreen.y*=m,U.addPoint(t.positionScreen.x,t.positionScreen.y),
-U.addPoint(r.positionScreen.x,r.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.materials.length;ea<ia;)T=z.materials[ea++],T.opacity!=0&&q(t,r,z,T,a)}}else if(z instanceof THREE.RenderableFace3){if(t=z.v1,r=z.v2,x=z.v3,t.positionScreen.x*=j,t.positionScreen.y*=m,r.positionScreen.x*=j,r.positionScreen.y*=m,x.positionScreen.x*=j,x.positionScreen.y*=m,z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,x.positionScreen),ha(x.positionScreen,t.positionScreen)),U.add3Points(t.positionScreen.x,
-t.positionScreen.y,r.positionScreen.x,r.positionScreen.y,x.positionScreen.x,x.positionScreen.y),ja.instersects(U)){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}else T.opacity!=0&&s(t,r,x,0,1,2,z,T,a)}}else if(z instanceof THREE.RenderableFace4&&(t=z.v1,r=z.v2,x=z.v3,E=z.v4,t.positionScreen.x*=j,t.positionScreen.y*=m,r.positionScreen.x*=
-j,r.positionScreen.y*=m,x.positionScreen.x*=j,x.positionScreen.y*=m,E.positionScreen.x*=j,E.positionScreen.y*=m,Z.positionScreen.copy(r.positionScreen),$.positionScreen.copy(E.positionScreen),z.overdraw&&(ha(t.positionScreen,r.positionScreen),ha(r.positionScreen,E.positionScreen),ha(E.positionScreen,t.positionScreen),ha(x.positionScreen,Z.positionScreen),ha(x.positionScreen,$.positionScreen)),U.addPoint(t.positionScreen.x,t.positionScreen.y),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(x.positionScreen.x,
-x.positionScreen.y),U.addPoint(E.positionScreen.x,E.positionScreen.y),ja.instersects(U))){ea=0;for(ia=z.meshMaterials.length;ea<ia;)if(T=z.meshMaterials[ea++],T instanceof THREE.MeshFaceMaterial){oa=0;for(ya=z.faceMaterials.length;oa<ya;)(T=z.faceMaterials[oa++])&&T.opacity!=0&&u(t,r,x,E,Z,$,z,T,a)}else T.opacity!=0&&u(t,r,x,E,Z,$,z,T,a)}X.addRectangle(U)}k.setTransform(1,0,0,1,0,0)}};
+THREE.CanvasRenderer=function(a){function b(a){if(u!=a)k.globalAlpha=u=a}function c(a){if(s!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}s=a}}function d(a){if(K!=a)k.strokeStyle=K=a}function f(a){if(P!=a)k.fillStyle=P=a}var g=this,e=null,h=new THREE.Projector,a=a||{},j=a.canvas!==void 0?a.canvas:document.createElement("canvas"),
+l,o,i,m,k=j.getContext("2d"),p=new THREE.Color(0),r=0,u=1,s=0,K=null,P=null,y=null,L=null,M=null,q,n,z,A,R=new THREE.RenderableVertex,S=new THREE.RenderableVertex,E,I,G,H,N,O,U,D,oa,v,J,F,w=new THREE.Color(0),C=new THREE.Color(0),t=new THREE.Color(0),B=new THREE.Color(0),T=new THREE.Color(0),ya=[],da,Y,aa,V,Da,Ea,Fa,Ga,Ha,Ia,ja=new THREE.Rectangle,Z=new THREE.Rectangle,X=new THREE.Rectangle,za=!1,ba=new THREE.Color,$=new THREE.Color,sa=new THREE.Color,ta=new THREE.Color,Q=new THREE.Vector3,pa,qa,
+Aa,ca,ra,ua,a=16;pa=document.createElement("canvas");pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);Aa=qa.getImageData(0,0,2,2);ca=Aa.data;ra=document.createElement("canvas");ra.width=ra.height=a;ua=ra.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;o=b;i=Math.floor(l/2);m=Math.floor(o/2);j.width=l;j.height=o;
+ja.set(-i,-m,i,m);Z.set(-i,-m,i,m);u=1;s=0;M=L=y=P=K=null};this.setClearColor=function(a,b){p.copy(a);r=b;Z.set(-i,-m,i,m)};this.setClearColorHex=function(a,b){p.setHex(a);r=b;Z.set(-i,-m,i,m)};this.clear=function(){k.setTransform(1,0,0,-1,i,m);Z.isEmpty()||(Z.minSelf(ja),Z.inflate(2),r<1&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),r>0&&(c(THREE.NormalBlending),b(1),f("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*
+255)+","+r+")"),k.fillRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,l){function j(a){var b,c,d,f=a.lights;$.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);a=0;for(b=f.length;a<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?($.r+=d.r,$.g+=d.g,$.b+=d.b):c instanceof THREE.DirectionalLight?(sa.r+=d.r,sa.g+=d.g,sa.b+=d.b):c instanceof THREE.PointLight&&(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b)}function o(a,b,c,d){var f,
+e,g,h,k=a.lights,a=0;for(f=k.length;a<f;a++)e=k[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(Q.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function p(a,e,g){b(g.opacity);c(g.blending);var h,l,j,o,Ba,n;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)o=g.map.image,
+Ba=o.width>>1,n=o.height>>1,g=e.scale.x*i,j=e.scale.y*m,h=g*Ba,l=j*n,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-j),k.translate(-Ba,-n),k.drawImage(o,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*i,l=e.scale.y*m,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.instersects(X)&&(d(g.color.getContextStyle()),f(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,l),g.program(k),
+k.restore()))}function r(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)k.lineWidth=y=a;a=g.linecap;if(L!=a)k.lineCap=L=a;a=g.linejoin;if(M!=a)k.lineJoin=M=a;d(g.color.getContextStyle());k.stroke();X.inflate(g.linewidth*2)}}function s(a,d,e,f,h,k,i,j,m){g.data.vertices+=3;g.data.faces++;b(j.opacity);c(j.blending);E=a.positionScreen.x;
+I=a.positionScreen.y;G=d.positionScreen.x;H=d.positionScreen.y;N=e.positionScreen.x;O=e.positionScreen.y;K(E,I,G,H,N,O);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(V=i.uvs[0],Ca(E,I,G,H,N,O,V[f].u,V[f].v,V[h].u,V[h].v,V[k].u,V[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,Q.copy(i.vertexNormalsWorld[0]),Da=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ea=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*
+0.5+0.5,Q.copy(i.vertexNormalsWorld[1]),Fa=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ga=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(i.vertexNormalsWorld[2]),Ha=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ia=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Ca(E,I,G,H,N,O,Da,Ea,Fa,Ga,Ha,Ia,j.envMap)}else j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&&
+(V=i.uvs[0],Ca(E,I,G,H,N,O,V[f].u,V[f].v,V[h].u,V[h].v,V[k].u,V[k].v,j.map)),c(THREE.SubtractiveBlending)),za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(C.r=t.r=B.r=$.r,C.g=t.g=B.g=$.g,C.b=t.b=B.b=$.b,o(m,i.v1.positionWorld,i.vertexNormalsWorld[0],C),o(m,i.v2.positionWorld,i.vertexNormalsWorld[1],t),o(m,i.v3.positionWorld,i.vertexNormalsWorld[2],B),T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa)):(ba.r=$.r,ba.g=
+$.g,ba.b=$.b,o(m,i.centroidWorld,i.normalWorld,ba),w.r=Math.max(0,Math.min(j.color.r*ba.r,1)),w.g=Math.max(0,Math.min(j.color.g*ba.g,1)),w.b=Math.max(0,Math.min(j.color.b*ba.b,1)),j.wireframe?fa(w,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(w)):j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshDepthMaterial)da=l.near,Y=l.far,C.r=C.g=C.b=1-ka(a.positionScreen.z,da,Y),t.r=t.g=t.b=1-ka(d.positionScreen.z,
+da,Y),B.r=B.g=B.b=1-ka(e.positionScreen.z,da,Y),T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa);else if(j instanceof THREE.MeshNormalMaterial)w.r=ma(i.normalWorld.x),w.g=ma(i.normalWorld.y),w.b=ma(i.normalWorld.z),j.wireframe?fa(w,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(w)}function u(a,d,e,f,h,j,k,i,m){g.data.vertices+=4;g.data.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)s(a,d,f,0,1,3,k,i,m),s(h,e,j,1,2,3,k,i,m);
+else if(E=a.positionScreen.x,I=a.positionScreen.y,G=d.positionScreen.x,H=d.positionScreen.y,N=e.positionScreen.x,O=e.positionScreen.y,U=f.positionScreen.x,D=f.positionScreen.y,oa=h.positionScreen.x,v=h.positionScreen.y,J=j.positionScreen.x,F=j.positionScreen.y,i instanceof THREE.MeshBasicMaterial)P(E,I,G,H,N,O,U,D),i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshLambertMaterial)za?!i.wireframe&&i.shading==THREE.SmoothShading&&
+k.vertexNormalsWorld.length==4?(C.r=t.r=B.r=T.r=$.r,C.g=t.g=B.g=T.g=$.g,C.b=t.b=B.b=T.b=$.b,o(m,k.v1.positionWorld,k.vertexNormalsWorld[0],C),o(m,k.v2.positionWorld,k.vertexNormalsWorld[1],t),o(m,k.v4.positionWorld,k.vertexNormalsWorld[3],B),o(m,k.v3.positionWorld,k.vertexNormalsWorld[2],T),aa=va(C,t,B,T),K(E,I,G,H,U,D),la(E,I,G,H,U,D,0,0,1,0,0,1,aa),K(oa,v,N,O,J,F),la(oa,v,N,O,J,F,1,0,1,1,0,1,aa)):(ba.r=$.r,ba.g=$.g,ba.b=$.b,o(m,k.centroidWorld,k.normalWorld,ba),w.r=Math.max(0,Math.min(i.color.r*
+ba.r,1)),w.g=Math.max(0,Math.min(i.color.g*ba.g,1)),w.b=Math.max(0,Math.min(i.color.b*ba.b,1)),P(E,I,G,H,N,O,U,D),i.wireframe?fa(w,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(w)):(P(E,I,G,H,N,O,U,D),i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color));else if(i instanceof THREE.MeshNormalMaterial)w.r=ma(k.normalWorld.x),w.g=ma(k.normalWorld.y),w.b=ma(k.normalWorld.z),P(E,I,G,H,N,O,U,D),i.wireframe?fa(w,i.wireframeLinewidth,i.wireframeLinecap,
+i.wireframeLinejoin):ga(w);else if(i instanceof THREE.MeshDepthMaterial)da=l.near,Y=l.far,C.r=C.g=C.b=1-ka(a.positionScreen.z,da,Y),t.r=t.g=t.b=1-ka(d.positionScreen.z,da,Y),B.r=B.g=B.b=1-ka(f.positionScreen.z,da,Y),T.r=T.g=T.b=1-ka(e.positionScreen.z,da,Y),aa=va(C,t,B,T),K(E,I,G,H,U,D),la(E,I,G,H,U,D,0,0,1,0,0,1,aa),K(oa,v,N,O,J,F),la(oa,v,N,O,J,F,1,0,1,1,0,1,aa)}function K(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function P(a,b,c,d,e,f,g,h){k.beginPath();
+k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function fa(a,b,c,e){if(y!=b)k.lineWidth=y=b;if(L!=c)k.lineCap=L=c;if(M!=e)k.lineJoin=M=e;d(a.getContextStyle());k.stroke();X.inflate(b*2)}function ga(a){f(a.getContextStyle());k.fill()}function Ca(a,b,c,d,e,g,h,i,j,l,m,o,n){if(n.image.width!=0){if(n.needsUpdate==!0||ya[n.id]==void 0){var p=n.wrapS==THREE.RepeatWrapping,q=n.wrapT==THREE.RepeatWrapping;ya[n.id]=k.createPattern(n.image,p&&q?"repeat":p&&!q?"repeat-x":
+!p&&q?"repeat-y":"no-repeat");n.needsUpdate=!1}f(ya[n.id]);var p=n.offset.x/n.repeat.x,q=n.offset.y/n.repeat.y,r=(n.image.width-1)*n.repeat.x,n=(n.image.height-1)*n.repeat.y,h=(h+p)*r,i=(i+q)*n,j=(j+p)*r,l=(l+q)*n,m=(m+p)*r,o=(o+q)*n;c-=a;d-=b;e-=a;g-=b;j-=h;l-=i;m-=h;o-=i;p=1/(j*o-m*l);n=(o*c-l*e)*p;l=(o*d-l*g)*p;c=(j*e-m*c)*p;d=(j*g-m*d)*p;a=a-n*h-c*i;b=b-l*h-d*i;k.save();k.transform(n,l,c,d,a,b);k.fill();k.restore()}}function la(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;
+h*=p;i*=o;j*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b;i-=g;j-=h;l-=g;m-=h;p=1/(i*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;k.save();k.transform(o,j,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ca[0]=e<0?0:e>255?255:e;ca[1]=f<0?0:f>255?255:f;ca[2]=a<0?0:a>255?255:a;ca[4]=
+g<0?0:g>255?255:g;ca[5]=h<0?0:h>255?255:h;ca[6]=b<0?0:b>255?255:b;ca[8]=i<0?0:i>255?255:i;ca[9]=j<0?0:j>255?255:j;ca[10]=c<0?0:c>255?255:c;ca[12]=k<0?0:k>255?255:k;ca[13]=l<0?0:l>255?255:l;ca[14]=d<0?0:d>255?255:d;qa.putImageData(Aa,0,0);ua.drawImage(pa,0,0);return ra}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ja,x,ea,ia,
+na,xa,W;this.autoClear?this.clear():k.setTransform(1,0,0,-1,i,m);g.data.vertices=0;g.data.faces=0;e=h.projectScene(a,l,this.sortElements);(za=a.lights.length>0)&&j(a);wa=0;for(Ja=e.length;wa<Ja;wa++){x=e[wa];X.empty();if(x instanceof THREE.RenderableParticle){q=x;q.x*=i;q.y*=m;ea=0;for(ia=x.materials.length;ea<ia;)W=x.materials[ea++],W.opacity!=0&&p(q,x,W,a)}else if(x instanceof THREE.RenderableLine){if(q=x.v1,n=x.v2,q.positionScreen.x*=i,q.positionScreen.y*=m,n.positionScreen.x*=i,n.positionScreen.y*=
+m,X.addPoint(q.positionScreen.x,q.positionScreen.y),X.addPoint(n.positionScreen.x,n.positionScreen.y),ja.instersects(X)){ea=0;for(ia=x.materials.length;ea<ia;)W=x.materials[ea++],W.opacity!=0&&r(q,n,x,W,a)}}else if(x instanceof THREE.RenderableFace3){if(q=x.v1,n=x.v2,z=x.v3,q.positionScreen.x*=i,q.positionScreen.y*=m,n.positionScreen.x*=i,n.positionScreen.y*=m,z.positionScreen.x*=i,z.positionScreen.y*=m,x.overdraw&&(ha(q.positionScreen,n.positionScreen),ha(n.positionScreen,z.positionScreen),ha(z.positionScreen,
+q.positionScreen)),X.add3Points(q.positionScreen.x,q.positionScreen.y,n.positionScreen.x,n.positionScreen.y,z.positionScreen.x,z.positionScreen.y),ja.instersects(X)){ea=0;for(ia=x.meshMaterials.length;ea<ia;)if(W=x.meshMaterials[ea++],W instanceof THREE.MeshFaceMaterial){na=0;for(xa=x.faceMaterials.length;na<xa;)(W=x.faceMaterials[na++])&&W.opacity!=0&&s(q,n,z,0,1,2,x,W,a)}else W.opacity!=0&&s(q,n,z,0,1,2,x,W,a)}}else if(x instanceof THREE.RenderableFace4&&(q=x.v1,n=x.v2,z=x.v3,A=x.v4,q.positionScreen.x*=
+i,q.positionScreen.y*=m,n.positionScreen.x*=i,n.positionScreen.y*=m,z.positionScreen.x*=i,z.positionScreen.y*=m,A.positionScreen.x*=i,A.positionScreen.y*=m,R.positionScreen.copy(n.positionScreen),S.positionScreen.copy(A.positionScreen),x.overdraw&&(ha(q.positionScreen,n.positionScreen),ha(n.positionScreen,A.positionScreen),ha(A.positionScreen,q.positionScreen),ha(z.positionScreen,R.positionScreen),ha(z.positionScreen,S.positionScreen)),X.addPoint(q.positionScreen.x,q.positionScreen.y),X.addPoint(n.positionScreen.x,
+n.positionScreen.y),X.addPoint(z.positionScreen.x,z.positionScreen.y),X.addPoint(A.positionScreen.x,A.positionScreen.y),ja.instersects(X))){ea=0;for(ia=x.meshMaterials.length;ea<ia;)if(W=x.meshMaterials[ea++],W instanceof THREE.MeshFaceMaterial){na=0;for(xa=x.faceMaterials.length;na<xa;)(W=x.faceMaterials[na++])&&W.opacity!=0&&u(q,n,z,A,R,S,x,W,a)}else W.opacity!=0&&u(q,n,z,A,R,S,x,W,a)}Z.addRectangle(X)}k.setTransform(1,0,0,1,0,0)}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};

+ 18 - 18
build/custom/ThreeDOM.js

@@ -1,4 +1,4 @@
-// ThreeDOM.js r44dev - http://github.com/mrdoob/three.js
+// ThreeDOM.js r44 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
@@ -26,8 +26,8 @@ THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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;
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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+
 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,g=a.n14,f=a.n21,h=a.n22,j=a.n23,i=a.n24,l=a.n31,k=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44,J=b.n11,M=b.n12,
 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,g=a.n14,f=a.n21,h=a.n22,j=a.n23,i=a.n24,l=a.n31,k=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44,J=b.n11,M=b.n12,
-G=b.n13,v=b.n14,o=b.n21,K=b.n22,z=b.n23,C=b.n24,D=b.n31,Q=b.n32,R=b.n33,S=b.n34,H=b.n41,T=b.n42,O=b.n43,E=b.n44;this.n11=c*J+d*o+e*D+g*H;this.n12=c*M+d*K+e*Q+g*T;this.n13=c*G+d*z+e*R+g*O;this.n14=c*v+d*C+e*S+g*E;this.n21=f*J+h*o+j*D+i*H;this.n22=f*M+h*K+j*Q+i*T;this.n23=f*G+h*z+j*R+i*O;this.n24=f*v+h*C+j*S+i*E;this.n31=l*J+k*o+m*D+n*H;this.n32=l*M+k*K+m*Q+n*T;this.n33=l*G+k*z+m*R+n*O;this.n34=l*v+k*C+m*S+n*E;this.n41=p*J+q*o+s*D+r*H;this.n42=p*M+q*K+s*Q+r*T;this.n43=p*G+q*z+s*R+r*O;this.n44=p*v+q*
-C+s*S+r*E;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*=
+C=b.n13,D=b.n14,H=b.n21,v=b.n22,o=b.n23,K=b.n24,z=b.n31,E=b.n32,F=b.n33,Q=b.n34,R=b.n41,S=b.n42,T=b.n43,U=b.n44;this.n11=c*J+d*H+e*z+g*R;this.n12=c*M+d*v+e*E+g*S;this.n13=c*C+d*o+e*F+g*T;this.n14=c*D+d*K+e*Q+g*U;this.n21=f*J+h*H+j*z+i*R;this.n22=f*M+h*v+j*E+i*S;this.n23=f*C+h*o+j*F+i*T;this.n24=f*D+h*K+j*Q+i*U;this.n31=l*J+k*H+m*z+n*R;this.n32=l*M+k*v+m*E+n*S;this.n33=l*C+k*o+m*F+n*T;this.n34=l*D+k*K+m*Q+n*U;this.n41=p*J+q*H+s*z+r*R;this.n42=p*M+q*v+s*E+r*S;this.n43=p*C+q*o+s*F+r*T;this.n44=p*D+q*
+K+s*Q+r*U;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,g=this.n22,f=this.n23,h=this.n24,j=this.n31,i=this.n32,l=this.n33,k=this.n34,m=this.n41,n=this.n42,p=this.n43,q=this.n44;return d*f*i*m-c*h*i*m-d*g*l*m+b*h*l*m+c*g*k*m-b*f*k*m-d*f*j*n+c*h*j*n+d*e*l*n-a*h*l*n-c*e*k*n+a*f*k*n+d*g*j*p-b*h*j*p-d*e*i*p+a*h*i*p+b*e*k*p-a*g*k*p-c*g*j*q+b*f*j*q+c*e*i*q-a*f*i*q-b*e*l*q+a*g*l*q},
 a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,f=this.n23,h=this.n24,j=this.n31,i=this.n32,l=this.n33,k=this.n34,m=this.n41,n=this.n42,p=this.n43,q=this.n44;return d*f*i*m-c*h*i*m-d*g*l*m+b*h*l*m+c*g*k*m-b*f*k*m-d*f*j*n+c*h*j*n+d*e*l*n-a*h*l*n-c*e*k*n+a*f*k*n+d*g*j*p-b*h*j*p-d*e*i*p+a*h*i*p+b*e*k*p-a*g*k*p-c*g*j*q+b*f*j*q+c*e*i*q-a*f*i*q-b*e*l*q+a*g*l*q},
 transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;
 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.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;
@@ -46,17 +46,28 @@ e*i*l-g*j*l+g*f*m-c*i*m-e*f*n+c*j*n;b.n31=h*n*p-i*k*p+i*l*q-f*n*q-h*l*r+f*k*r;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,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*j;c[6]=a*i;c[7]=a*l;c[8]=a*k;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,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*j;c[6]=a*i;c[7]=a*l;c[8]=a*k;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,j,i;f=new THREE.Matrix4;h=b-a;j=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/j;f.n23=0;f.n24=-((c+d)/j);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,j,i;f=new THREE.Matrix4;h=b-a;j=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/j;f.n23=0;f.n24=-((c+d)/j);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
-THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;
-this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
+THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
+!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);
 -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
-this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Object3DCount=0;
+THREE.Projector=function(){function a(){var a=j[h]=j[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,j=[],i,l,k=[],m,n=[],p,q,s=[],r,J,M=[],C=[],D=[],H=new THREE.Vector4,v=new THREE.Vector4,
+o=new THREE.Matrix4,K=new THREE.Matrix4,z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,F=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,f){var h,i;e=C.length=0;
+h=a.objects;a=0;for(c=h.length;a<c;a++){i=h[a];var j;if(!(j=!i.visible))if(j=i instanceof THREE.Mesh)if(j=i.frustumCulled){a:{j=void 0;for(var k=i.matrixWorld,l=-i.geometry.boundingSphere.radius*Math.max(i.scale.x,Math.max(i.scale.y,i.scale.z)),m=0;m<6;m++)if(j=z[m].x*k.n14+z[m].y*k.n24+z[m].z*k.n34+z[m].w,j<=l){j=!1;break a}j=!0}j=!j}if(!j)j=g[e]=g[e]||new THREE.RenderableObject,e++,d=j,H.copy(i.position),o.multiplyVector3(H),d.object=i,d.z=H.z,C.push(d)}f&&C.sort(b);return C};this.projectScene=
+function(d,e,g){var C=e.near,H=e.far,O,I,x,B,t,y,w,A,G,u,L,V,X,Y,N,W,P;J=q=m=l=D.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);z[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);z[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);z[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);z[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);z[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);z[5].set(o.n41+
+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(O=0;O<6;O++)G=z[O],G.divideScalar(Math.sqrt(G.x*G.x+G.y*G.y+G.z*G.z));G=this.projectObjects(d,e,!0);d=0;for(O=G.length;d<O;d++)if(u=G[d].object,u.visible)if(L=u.matrixWorld,V=u.matrixRotationWorld,X=u.materials,Y=u.overdraw,h=0,u instanceof THREE.Mesh){N=u.geometry;B=N.vertices;W=N.faces;N=N.faceVertexUvs;I=0;for(x=B.length;I<x;I++)f=a(),f.positionWorld.copy(B[I].position),L.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),
+f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>C&&f.positionScreen.z<H;B=0;for(I=W.length;B<I;B++){x=W[B];if(x instanceof THREE.Face3)if(t=j[x.a],y=j[x.b],w=j[x.c],t.visible&&y.visible&&w.visible&&(u.doubleSided||u.flipSided!=(w.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(w.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0))A=k[l]=k[l]||new THREE.RenderableFace3,l++,i=A,i.v1.copy(t),
+i.v2.copy(y),i.v3.copy(w);else continue;else if(x instanceof THREE.Face4)if(t=j[x.a],y=j[x.b],w=j[x.c],A=j[x.d],t.visible&&y.visible&&w.visible&&A.visible&&(u.doubleSided||u.flipSided!=((A.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0||(y.positionScreen.x-w.positionScreen.x)*(A.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(A.positionScreen.x-w.positionScreen.x)<
+0)))P=n[m]=n[m]||new THREE.RenderableFace4,m++,i=P,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w),i.v4.copy(A);else continue;i.normalWorld.copy(x.normal);V.multiplyVector3(i.normalWorld);i.centroidWorld.copy(x.centroid);L.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);w=x.vertexNormals;t=0;for(y=w.length;t<y;t++)A=i.vertexNormalsWorld[t],A.copy(w[t]),V.multiplyVector3(A);t=0;for(y=N.length;t<y;t++)if(P=N[t][B]){w=0;for(A=P.length;w<A;w++)i.uvs[t][w]=
+P[w]}i.meshMaterials=X;i.faceMaterials=x.materials;i.overdraw=Y;i.z=i.centroidScreen.z;D.push(i)}}else if(u instanceof THREE.Line){K.multiply(o,L);B=u.geometry.vertices;t=a();t.positionScreen.copy(B[0].position);K.multiplyVector4(t.positionScreen);I=1;for(x=B.length;I<x;I++)if(t=a(),t.positionScreen.copy(B[I].position),K.multiplyVector4(t.positionScreen),y=j[h-2],E.copy(t.positionScreen),F.copy(y.positionScreen),c(E,F))E.multiplyScalar(1/E.w),F.multiplyScalar(1/F.w),L=s[q]=s[q]||new THREE.RenderableLine,
+q++,p=L,p.v1.positionScreen.copy(E),p.v2.positionScreen.copy(F),p.z=Math.max(E.z,F.z),p.materials=u.materials,D.push(p)}else if(u instanceof THREE.Particle&&(v.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,1),o.multiplyVector4(v),v.z/=v.w,v.z>0&&v.z<1))L=M[J]=M[J]||new THREE.RenderableParticle,J++,r=L,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=u.rotation.z,r.scale.x=u.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=u.scale.y*Math.abs(r.y-(v.y+
+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.materials=u.materials,D.push(r);g&&D.sort(b);return D}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,j=this.w,i=j*c+f*e-h*d,l=j*d+h*c-g*e,k=j*e+g*d-f*c,c=-g*
 this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,j=this.w,i=j*c+f*e-h*d,l=j*d+h*c-g*e,k=j*e+g*d-f*c,c=-g*
-c-f*d-h*e;b.x=i*j+c*-g+l*-h-k*-f;b.y=l*j+c*-f+k*-g-i*-h;b.z=k*j+c*-h+i*-f-l*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+c-f*d-h*e;b.x=i*j+c*-g+l*-h-k*-f;b.y=l*j+c*-f+k*-g-i*-h;b.z=k*j+c*-h+i*-f-l*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;
@@ -72,16 +83,5 @@ b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var a=j[h]=j[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,j=[],i,l,k=[],m,n=[],p,q,s=[],r,J,M=[],G=new THREE.Vector4,v=new THREE.Vector4,
-o=new THREE.Matrix4,K=new THREE.Matrix4,z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],C=new THREE.Vector4,D=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,f){var c=[],h,i,j;e=0;i=
-a.objects;a=0;for(h=i.length;a<h;a++){j=i[a];var k;if(!(k=!j.visible))if(k=j instanceof THREE.Mesh){a:{k=void 0;for(var l=j.matrixWorld,m=-j.geometry.boundingSphere.radius*Math.max(j.scale.x,Math.max(j.scale.y,j.scale.z)),n=0;n<6;n++)if(k=z[n].x*l.n14+z[n].y*l.n24+z[n].z*l.n34+z[n].w,k<=m){k=!1;break a}k=!0}k=!k}if(!k)k=g[e]=g[e]||new THREE.RenderableObject,e++,d=k,G.copy(j.position),o.multiplyVector3(G),d.object=j,d.z=G.z,c.push(d)}f&&c.sort(b);return c};this.projectScene=function(d,e,g){var H=[],
-G=e.near,O=e.far,E,I,x,B,t,y,w,A,F,u,L,U,W,X,N,V,P;J=q=m=l=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);z[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);z[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);z[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);z[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);z[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);z[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+
-o.n33,o.n44+o.n34);for(E=0;E<6;E++)F=z[E],F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z));F=this.projectObjects(d,e,!0);d=0;for(E=F.length;d<E;d++)if(u=F[d].object,u.visible)if(L=u.matrixWorld,U=u.matrixRotationWorld,W=u.materials,X=u.overdraw,h=0,u instanceof THREE.Mesh){N=u.geometry;B=N.vertices;V=N.faces;N=N.faceVertexUvs;I=0;for(x=B.length;I<x;I++)f=a(),f.positionWorld.copy(B[I].position),L.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),
-f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>G&&f.positionScreen.z<O;B=0;for(I=V.length;B<I;B++){x=V[B];if(x instanceof THREE.Face3)if(t=j[x.a],y=j[x.b],w=j[x.c],t.visible&&y.visible&&w.visible&&(u.doubleSided||u.flipSided!=(w.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(w.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0))A=k[l]=k[l]||new THREE.RenderableFace3,l++,i=A,i.v1.copy(t),
-i.v2.copy(y),i.v3.copy(w);else continue;else if(x instanceof THREE.Face4)if(t=j[x.a],y=j[x.b],w=j[x.c],A=j[x.d],t.visible&&y.visible&&w.visible&&A.visible&&(u.doubleSided||u.flipSided!=((A.positionScreen.x-t.positionScreen.x)*(y.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(y.positionScreen.x-t.positionScreen.x)<0||(y.positionScreen.x-w.positionScreen.x)*(A.positionScreen.y-w.positionScreen.y)-(y.positionScreen.y-w.positionScreen.y)*(A.positionScreen.x-w.positionScreen.x)<
-0)))P=n[m]=n[m]||new THREE.RenderableFace4,m++,i=P,i.v1.copy(t),i.v2.copy(y),i.v3.copy(w),i.v4.copy(A);else continue;i.normalWorld.copy(x.normal);U.multiplyVector3(i.normalWorld);i.centroidWorld.copy(x.centroid);L.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);w=x.vertexNormals;t=0;for(y=w.length;t<y;t++)A=i.vertexNormalsWorld[t],A.copy(w[t]),U.multiplyVector3(A);t=0;for(y=N.length;t<y;t++)if(P=N[t][B]){w=0;for(A=P.length;w<A;w++)i.uvs[t][w]=
-P[w]}i.meshMaterials=W;i.faceMaterials=x.materials;i.overdraw=X;i.z=i.centroidScreen.z;H.push(i)}}else if(u instanceof THREE.Line){K.multiply(o,L);B=u.geometry.vertices;t=a();t.positionScreen.copy(B[0].position);K.multiplyVector4(t.positionScreen);I=1;for(x=B.length;I<x;I++)if(t=a(),t.positionScreen.copy(B[I].position),K.multiplyVector4(t.positionScreen),y=j[h-2],C.copy(t.positionScreen),D.copy(y.positionScreen),c(C,D))C.multiplyScalar(1/C.w),D.multiplyScalar(1/D.w),L=s[q]=s[q]||new THREE.RenderableLine,
-q++,p=L,p.v1.positionScreen.copy(C),p.v2.positionScreen.copy(D),p.z=Math.max(C.z,D.z),p.materials=u.materials,H.push(p)}else if(u instanceof THREE.Particle&&(v.set(u.matrixWorld.n14,u.matrixWorld.n24,u.matrixWorld.n34,1),o.multiplyVector4(v),v.z/=v.w,v.z>0&&v.z<1))L=M[J]=M[J]||new THREE.RenderableParticle,J++,r=L,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=u.rotation.z,r.scale.x=u.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=u.scale.y*Math.abs(r.y-(v.y+
-e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.materials=u.materials,H.push(r);g&&H.sort(b);return H}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,g;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;g=d/2};this.render=function(c,d){var j,i,l,k,m,n,p,q;a=b.projectScene(c,d);j=0;for(i=a.length;j<i;j++)if(m=a[j],m instanceof THREE.RenderableParticle){p=m.x*e+e;q=m.y*g+g;l=0;for(k=m.material.length;l<k;l++)if(n=m.material[l],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=p+"px",n.style.top=q+"px"}}};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,g;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;g=d/2};this.render=function(c,d){var j,i,l,k,m,n,p,q;a=b.projectScene(c,d);j=0;for(i=a.length;j<i;j++)if(m=a[j],m instanceof THREE.RenderableParticle){p=m.x*e+e;q=m.y*g+g;l=0;for(k=m.material.length;l<k;l++)if(n=m.material[l],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=p+"px",n.style.top=q+"px"}}};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 14 - 14
build/custom/ThreeExtras.js


+ 45 - 45
build/custom/ThreeSVG.js

@@ -1,4 +1,4 @@
-// ThreeSVG.js r44dev - http://github.com/mrdoob/three.js
+// ThreeSVG.js r44 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(a){a!==void 0&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(c==0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),e=a*6-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
 c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};
@@ -16,19 +16,19 @@ a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;thi
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d;d=c.clone().subSelf(a).dot(b);if(d<=0)return null;a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),
 c=c.clone().subSelf(b),e=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(e),f=c.dot(c),c=c.dot(e),e=1/(a*f-b*b),f=(f*d-b*c)*e,a=(a*c-b*d)*e;return f>0&&a>0&&f+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,
 c=c.clone().subSelf(b),e=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(e),f=c.dot(c),c=c.dot(e),e=1/(a*f-b*b),f=(f*d-b*c)*e,a=(a*c-b*d)*e;return f>0&&a>0&&f+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,
-Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,k,i,l,j,n,m,p=a.geometry,q=p.vertices,w=[],d=0;for(e=p.faces.length;d<e;d++)if(g=p.faces[d],n=this.origin.clone(),m=this.direction.clone(),i=a.matrixWorld,f=i.multiplyVector3(g.centroid.clone()).subSelf(n),j=f.dot(m),!(j<=0)&&(f=i.multiplyVector3(q[g.a].position.clone()),h=i.multiplyVector3(q[g.b].position.clone()),k=i.multiplyVector3(q[g.c].position.clone()),i=g instanceof THREE.Face4?i.multiplyVector3(q[g.d].position.clone()):null,l=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),
-j=m.dot(l),a.doubleSided||(a.flipSided?j>0:j<0)))if(j=l.dot((new THREE.Vector3).sub(f,n))/j,n=n.addSelf(m.multiplyScalar(j)),g instanceof THREE.Face3)c(n,f,h,k)&&(g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},w.push(g));else if(g instanceof THREE.Face4&&(c(n,f,h,i)||c(n,h,k,i)))g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},w.push(g);w.sort(function(a,b){return a.distance-b.distance});return w}else return[]}};
+Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,k,i,l,j,m,n,p=a.geometry,q=p.vertices,v=[],d=0;for(e=p.faces.length;d<e;d++)if(g=p.faces[d],m=this.origin.clone(),n=this.direction.clone(),i=a.matrixWorld,f=i.multiplyVector3(g.centroid.clone()).subSelf(m),j=f.dot(n),!(j<=0)&&(f=i.multiplyVector3(q[g.a].position.clone()),h=i.multiplyVector3(q[g.b].position.clone()),k=i.multiplyVector3(q[g.c].position.clone()),i=g instanceof THREE.Face4?i.multiplyVector3(q[g.d].position.clone()):null,l=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),
+j=n.dot(l),a.doubleSided||(a.flipSided?j>0:j<0)))if(j=l.dot((new THREE.Vector3).sub(f,m))/j,m=m.addSelf(n.multiplyScalar(j)),g instanceof THREE.Face3)c(m,f,h,k)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},v.push(g));else if(g instanceof THREE.Face4&&(c(m,f,h,i)||c(m,h,k,i)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},v.push(g);v.sort(function(a,b){return a.distance-b.distance});return v}else return[]}};
 THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,j){h=!1;b=f;c=g;d=l;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,j){h=!1;b=f;c=g;d=l;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
-function(f,g,l,j,n,m){h?(h=!1,b=f<l?f<n?f:n:l<n?l:n,c=g<j?g<m?g:m:j<m?j:m,d=f>l?f>n?f:n:l>n?l:n,e=g>j?g>m?g:m:j>m?j:m):(b=f<l?f<n?f<b?f:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b,c=g<j?g<m?g<c?g:c:m<c?m:c:j<m?j<c?j:c:m<c?m:c,d=f>l?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>j?g>m?g>e?g:e:m>e?m:e:j>m?j>e?j:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
+function(f,g,l,j,m,n){h?(h=!1,b=f<l?f<m?f:m:l<m?l:m,c=g<j?g<n?g:n:j<n?j:n,d=f>l?f>m?f:m:l>m?l:m,e=g>j?g>n?g:n:j>n?j:n):(b=f<l?f<m?f<b?f:b:m<b?m:b:l<m?l<b?l:b:m<b?m:b,c=g<j?g<n?g<c?g:c:n<c?n:c:j<n?j<c?j:c:n<c?n:c,d=f>l?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d,e=g>j?g>n?g>e?g:e:n>e?n:e:j>n?j>e?j:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]};
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]};
-THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,g,f,h,k,i,l,j,n,m,p,q){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,k||0,i||0,l||1,j||0,n||0,m||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,k,i,l,j,n,m,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=k;this.n32=i;this.n33=l;this.n34=j;this.n41=n;this.n42=m;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
+THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};THREE.Matrix4=function(a,b,c,d,e,g,f,h,k,i,l,j,m,n,p,q){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,k||0,i||0,l||1,j||0,m||0,n||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,k,i,l,j,m,n,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=k;this.n32=i;this.n33=l;this.n34=j;this.n41=m;this.n42=n;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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;
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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+
 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,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,l=a.n31,j=a.n32,n=a.n33,m=a.n34,p=a.n41,q=a.n42,w=a.n43,v=a.n44,A=b.n11,H=b.n12,
-s=b.n13,r=b.n14,o=b.n21,E=b.n22,B=b.n23,x=b.n24,C=b.n31,I=b.n32,J=b.n33,z=b.n34,O=b.n41,L=b.n42,M=b.n43,P=b.n44;this.n11=c*A+d*o+e*C+g*O;this.n12=c*H+d*E+e*I+g*L;this.n13=c*s+d*B+e*J+g*M;this.n14=c*r+d*x+e*z+g*P;this.n21=f*A+h*o+k*C+i*O;this.n22=f*H+h*E+k*I+i*L;this.n23=f*s+h*B+k*J+i*M;this.n24=f*r+h*x+k*z+i*P;this.n31=l*A+j*o+n*C+m*O;this.n32=l*H+j*E+n*I+m*L;this.n33=l*s+j*B+n*J+m*M;this.n34=l*r+j*x+n*z+m*P;this.n41=p*A+q*o+w*C+v*O;this.n42=p*H+q*E+w*I+v*L;this.n43=p*s+q*B+w*J+v*M;this.n44=p*r+q*
-x+w*z+v*P;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,g=this.n22,f=this.n23,h=this.n24,k=this.n31,i=this.n32,l=this.n33,j=this.n34,n=this.n41,m=this.n42,p=this.n43,q=this.n44;return d*f*i*n-c*h*i*n-d*g*l*n+b*h*l*n+c*g*j*n-b*f*j*n-d*f*k*m+c*h*k*m+d*e*l*m-a*h*l*m-c*e*j*m+a*f*j*m+d*g*k*p-b*h*k*p-d*e*i*p+a*h*i*p+b*e*j*p-a*g*j*p-c*g*k*q+b*f*k*q+c*e*i*q-a*f*i*q-b*e*l*q+a*g*l*q},
+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,l=a.n31,j=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,v=a.n43,u=a.n44,C=b.n11,K=b.n12,
+t=b.n13,w=b.n14,z=b.n21,y=b.n22,o=b.n23,E=b.n24,D=b.n31,F=b.n32,G=b.n33,A=b.n34,M=b.n41,N=b.n42,O=b.n43,S=b.n44;this.n11=c*C+d*z+e*D+g*M;this.n12=c*K+d*y+e*F+g*N;this.n13=c*t+d*o+e*G+g*O;this.n14=c*w+d*E+e*A+g*S;this.n21=f*C+h*z+k*D+i*M;this.n22=f*K+h*y+k*F+i*N;this.n23=f*t+h*o+k*G+i*O;this.n24=f*w+h*E+k*A+i*S;this.n31=l*C+j*z+m*D+n*M;this.n32=l*K+j*y+m*F+n*N;this.n33=l*t+j*o+m*G+n*O;this.n34=l*w+j*E+m*A+n*S;this.n41=p*C+q*z+v*D+u*M;this.n42=p*K+q*y+v*F+u*N;this.n43=p*t+q*o+v*G+u*O;this.n44=p*w+q*
+E+v*A+u*S;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,g=this.n22,f=this.n23,h=this.n24,k=this.n31,i=this.n32,l=this.n33,j=this.n34,m=this.n41,n=this.n42,p=this.n43,q=this.n44;return d*f*i*m-c*h*i*m-d*g*l*m+b*h*l*m+c*g*j*m-b*f*j*m-d*f*k*n+c*h*k*n+d*e*l*n-a*h*l*n-c*e*j*n+a*f*j*n+d*g*k*p-b*h*k*p-d*e*i*p+a*h*i*p+b*e*j*p-a*g*j*p-c*g*k*q+b*f*k*q+c*e*i*q-a*f*i*q-b*e*l*q+a*g*l*q},
 transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;
 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.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[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;
@@ -41,37 +41,48 @@ a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,k=b*f;b*=h;var i=c*f;c*=h;d*=h;g*=
 d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();
 d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();
 c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},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=
 c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},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}};
 a.n23*e;this.n33=a.n33*e}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,l=a.n31,j=a.n32,n=a.n33,m=a.n34,p=a.n41,q=a.n42,w=a.n43,v=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=k*m*q-i*n*q+i*j*w-h*m*w-k*j*v+h*n*v;b.n12=g*n*q-e*m*q-g*j*w+d*m*w+e*j*v-d*n*v;b.n13=e*i*q-g*k*q+g*h*w-d*i*w-e*h*v+d*k*v;b.n14=g*k*j-e*i*j-g*h*n+d*i*n+e*h*m-d*k*m;b.n21=i*n*p-k*m*p-i*l*w+f*m*w+k*l*v-f*n*v;b.n22=e*m*p-g*n*p+g*l*w-c*m*w-e*l*v+c*n*v;b.n23=g*k*p-e*i*p-g*f*w+c*i*w+e*f*v-c*k*v;b.n24=
-e*i*l-g*k*l+g*f*n-c*i*n-e*f*m+c*k*m;b.n31=h*m*p-i*j*p+i*l*q-f*m*q-h*l*v+f*j*v;b.n32=g*j*p-d*m*p-g*l*q+c*m*q+d*l*v-c*j*v;b.n33=e*i*p-g*h*p+g*f*q-c*i*q-d*f*v+c*h*v;b.n34=g*h*l-d*i*l-g*f*j+c*i*j+d*f*m-c*h*m;b.n41=k*j*p-h*n*p-k*l*q+f*n*q+h*l*w-f*j*w;b.n42=d*n*p-e*j*p+e*l*q-c*n*q-d*l*w+c*j*w;b.n43=e*h*p-d*k*p-e*f*q+c*k*q+d*f*w-c*h*w;b.n44=d*k*l-e*h*l+e*f*j-c*k*j-d*f*n+c*h*n;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,i=a.n24,l=a.n31,j=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,v=a.n43,u=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=k*n*q-i*m*q+i*j*v-h*n*v-k*j*u+h*m*u;b.n12=g*m*q-e*n*q-g*j*v+d*n*v+e*j*u-d*m*u;b.n13=e*i*q-g*k*q+g*h*v-d*i*v-e*h*u+d*k*u;b.n14=g*k*j-e*i*j-g*h*m+d*i*m+e*h*n-d*k*n;b.n21=i*m*p-k*n*p-i*l*v+f*n*v+k*l*u-f*m*u;b.n22=e*n*p-g*m*p+g*l*v-c*n*v-e*l*u+c*m*u;b.n23=g*k*p-e*i*p-g*f*v+c*i*v+e*f*u-c*k*u;b.n24=
+e*i*l-g*k*l+g*f*m-c*i*m-e*f*n+c*k*n;b.n31=h*n*p-i*j*p+i*l*q-f*n*q-h*l*u+f*j*u;b.n32=g*j*p-d*n*p-g*l*q+c*n*q+d*l*u-c*j*u;b.n33=e*i*p-g*h*p+g*f*q-c*i*q-d*f*u+c*h*u;b.n34=g*h*l-d*i*l-g*f*j+c*i*j+d*f*n-c*h*n;b.n41=k*j*p-h*m*p-k*l*q+f*m*q+h*l*v-f*j*v;b.n42=d*m*p-e*j*p+e*l*q-c*m*q-d*l*v+c*j*v;b.n43=e*h*p-d*k*p-e*f*q+c*k*q+d*f*v-c*h*v;b.n44=d*k*l-e*h*l+e*f*j-c*k*j-d*f*m+c*h*m;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*l;c[8]=a*j;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,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,j=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*l;c[8]=a*j;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,k,i;f=new THREE.Matrix4;h=b-a;k=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/k;f.n23=0;f.n24=-((c+d)/k);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
 THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var f,h,k,i;f=new THREE.Matrix4;h=b-a;k=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/k;f.n23=0;f.n24=-((c+d)/k);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
-THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;
-this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""};
+THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
+!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===
 -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);
 -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c<d;c++){e=this.children[c];if(e.name===a)return e;if(b&&(e=e.getChildByName(a,b),e!==void 0))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
 this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),
-this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
+this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,b=!0;for(var a=0,d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}};THREE.Object3DCount=0;
+THREE.Projector=function(){function a(){var a=k[h]=k[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,f=a.z+a.w,e=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return f>=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,k=[],i,l,j=[],m,n=[],p,q,v=[],u,C,K=[],t=[],w=[],z=new THREE.Vector4,y=new THREE.Vector4,
+o=new THREE.Matrix4,E=new THREE.Matrix4,D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,f){var h,i;e=t.length=0;
+h=a.objects;a=0;for(c=h.length;a<c;a++){i=h[a];var k;if(!(k=!i.visible))if(k=i instanceof THREE.Mesh)if(k=i.frustumCulled){a:{k=void 0;for(var j=i.matrixWorld,l=-i.geometry.boundingSphere.radius*Math.max(i.scale.x,Math.max(i.scale.y,i.scale.z)),m=0;m<6;m++)if(k=D[m].x*j.n14+D[m].y*j.n24+D[m].z*j.n34+D[m].w,k<=l){k=!1;break a}k=!0}k=!k}if(!k)k=g[e]=g[e]||new THREE.RenderableObject,e++,d=k,z.copy(i.position),o.multiplyVector3(z),d.object=i,d.z=z.z,t.push(d)}f&&t.sort(b);return t};this.projectScene=
+function(d,e,g){var t=e.near,S=e.far,z,P,I,L,r,J,H,s,x,B,Q,U,W,X,R,V,T;C=q=m=l=w.length=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);D[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);D[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);D[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);D[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);D[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);D[5].set(o.n41+
+o.n31,o.n42+o.n32,o.n43+o.n33,o.n44+o.n34);for(z=0;z<6;z++)x=D[z],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,e,!0);d=0;for(z=x.length;d<z;d++)if(B=x[d].object,B.visible)if(Q=B.matrixWorld,U=B.matrixRotationWorld,W=B.materials,X=B.overdraw,h=0,B instanceof THREE.Mesh){R=B.geometry;L=R.vertices;V=R.faces;R=R.faceVertexUvs;P=0;for(I=L.length;P<I;P++)f=a(),f.positionWorld.copy(L[P].position),Q.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),
+f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>t&&f.positionScreen.z<S;L=0;for(P=V.length;L<P;L++){I=V[L];if(I instanceof THREE.Face3)if(r=k[I.a],J=k[I.b],H=k[I.c],r.visible&&J.visible&&H.visible&&(B.doubleSided||B.flipSided!=(H.positionScreen.x-r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(H.positionScreen.y-r.positionScreen.y)*(J.positionScreen.x-r.positionScreen.x)<0))s=j[l]=j[l]||new THREE.RenderableFace3,l++,i=s,i.v1.copy(r),
+i.v2.copy(J),i.v3.copy(H);else continue;else if(I instanceof THREE.Face4)if(r=k[I.a],J=k[I.b],H=k[I.c],s=k[I.d],r.visible&&J.visible&&H.visible&&s.visible&&(B.doubleSided||B.flipSided!=((s.positionScreen.x-r.positionScreen.x)*(J.positionScreen.y-r.positionScreen.y)-(s.positionScreen.y-r.positionScreen.y)*(J.positionScreen.x-r.positionScreen.x)<0||(J.positionScreen.x-H.positionScreen.x)*(s.positionScreen.y-H.positionScreen.y)-(J.positionScreen.y-H.positionScreen.y)*(s.positionScreen.x-H.positionScreen.x)<
+0)))T=n[m]=n[m]||new THREE.RenderableFace4,m++,i=T,i.v1.copy(r),i.v2.copy(J),i.v3.copy(H),i.v4.copy(s);else continue;i.normalWorld.copy(I.normal);U.multiplyVector3(i.normalWorld);i.centroidWorld.copy(I.centroid);Q.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);H=I.vertexNormals;r=0;for(J=H.length;r<J;r++)s=i.vertexNormalsWorld[r],s.copy(H[r]),U.multiplyVector3(s);r=0;for(J=R.length;r<J;r++)if(T=R[r][L]){H=0;for(s=T.length;H<s;H++)i.uvs[r][H]=
+T[H]}i.meshMaterials=W;i.faceMaterials=I.materials;i.overdraw=X;i.z=i.centroidScreen.z;w.push(i)}}else if(B instanceof THREE.Line){E.multiply(o,Q);L=B.geometry.vertices;r=a();r.positionScreen.copy(L[0].position);E.multiplyVector4(r.positionScreen);P=1;for(I=L.length;P<I;P++)if(r=a(),r.positionScreen.copy(L[P].position),E.multiplyVector4(r.positionScreen),J=k[h-2],F.copy(r.positionScreen),G.copy(J.positionScreen),c(F,G))F.multiplyScalar(1/F.w),G.multiplyScalar(1/G.w),Q=v[q]=v[q]||new THREE.RenderableLine,
+q++,p=Q,p.v1.positionScreen.copy(F),p.v2.positionScreen.copy(G),p.z=Math.max(F.z,G.z),p.materials=B.materials,w.push(p)}else if(B instanceof THREE.Particle&&(y.set(B.matrixWorld.n14,B.matrixWorld.n24,B.matrixWorld.n34,1),o.multiplyVector4(y),y.z/=y.w,y.z>0&&y.z<1))Q=K[C]=K[C]||new THREE.RenderableParticle,C++,u=Q,u.x=y.x/y.w,u.y=y.y/y.w,u.z=y.z,u.rotation=B.rotation.z,u.scale.x=B.scale.x*Math.abs(u.x-(y.x+e.projectionMatrix.n11)/(y.w+e.projectionMatrix.n14)),u.scale.y=B.scale.y*Math.abs(u.y-(y.y+
+e.projectionMatrix.n22)/(y.w+e.projectionMatrix.n24)),u.materials=B.materials,w.push(u);g&&w.sort(b);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
 this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,i=k*c+f*e-h*d,l=k*d+h*c-g*e,j=k*e+g*d-f*c,c=-g*
 this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,k=this.w,i=k*c+f*e-h*d,l=k*d+h*c-g*e,j=k*e+g*d-f*c,c=-g*
-c-f*d-h*e;b.x=i*k+c*-g+l*-h-j*-f;b.y=l*k+c*-f+j*-g-i*-h;b.z=j*k+c*-h+i*-f-l*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+c-f*d-h*e;b.x=i*k+c*-g+l*-h-j*-f;b.y=l*k+c*-f+j*-g-i*-h;b.z=j*k+c*-h+i*-f-l*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Vertex=function(a){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
-THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
+THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
 THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),
 THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),
 c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,e,g,f,h=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],f=this.vertices[g.c],h.sub(f.position,c.position),k.sub(b.position,c.position),h.crossSelf(k);h.isZero()||
 c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,e,g,f,h=new THREE.Vector3,k=new THREE.Vector3;d=0;for(e=this.faces.length;d<e;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],f=this.vertices[g.c],h.sub(f.position,c.position),k.sub(b.position,c.position),h.crossSelf(k);h.isZero()||
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
-c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,g,D){h=a.vertices[b].position;k=a.vertices[c].position;i=a.vertices[d].position;l=f[e];j=f[g];n=f[D];m=k.x-h.x;p=i.x-h.x;q=k.y-h.y;w=i.y-h.y;v=k.z-h.z;A=i.z-h.z;H=j.u-l.u;s=n.u-l.u;r=j.v-l.v;o=n.v-l.v;E=1/(H*o-s*r);I.set((o*m-r*p)*
-E,(o*q-r*w)*E,(o*v-r*A)*E);J.set((H*p-s*m)*E,(H*w-s*q)*E,(H*A-s*v)*E);x[b].addSelf(I);x[c].addSelf(I);x[d].addSelf(I);C[b].addSelf(J);C[c].addSelf(J);C[d].addSelf(J)}var b,c,d,e,g,f,h,k,i,l,j,n,m,p,q,w,v,A,H,s,r,o,E,B,x=[],C=[],I=new THREE.Vector3,J=new THREE.Vector3,z=new THREE.Vector3,O=new THREE.Vector3,L=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)x[b]=new THREE.Vector3,C[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],f=this.faceVertexUvs[0][b],g instanceof
-THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var M=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)L.copy(g.vertexNormals[d]),e=g[M[d]],B=x[e],z.copy(B),z.subSelf(L.multiplyScalar(L.dot(B))).normalize(),O.cross(g.vertexNormals[d],B),e=O.dot(C[e]),e=e<0?-1:1,g.vertexTangents[d]=new THREE.Vector4(z.x,z.y,z.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,g,o){h=a.vertices[b].position;k=a.vertices[c].position;i=a.vertices[d].position;l=f[e];j=f[g];m=f[o];n=k.x-h.x;p=i.x-h.x;q=k.y-h.y;v=i.y-h.y;u=k.z-h.z;C=i.z-h.z;K=j.u-l.u;t=m.u-l.u;w=j.v-l.v;z=m.v-l.v;y=1/(K*z-t*w);F.set((z*n-w*p)*
+y,(z*q-w*v)*y,(z*u-w*C)*y);G.set((K*p-t*n)*y,(K*v-t*q)*y,(K*C-t*u)*y);E[b].addSelf(F);E[c].addSelf(F);E[d].addSelf(F);D[b].addSelf(G);D[c].addSelf(G);D[d].addSelf(G)}var b,c,d,e,g,f,h,k,i,l,j,m,n,p,q,v,u,C,K,t,w,z,y,o,E=[],D=[],F=new THREE.Vector3,G=new THREE.Vector3,A=new THREE.Vector3,M=new THREE.Vector3,N=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)E[b]=new THREE.Vector3,D[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],f=this.faceVertexUvs[0][b],g instanceof
+THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var O=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)N.copy(g.vertexNormals[d]),e=g[O[d]],o=E[e],A.copy(o),A.subSelf(N.multiplyScalar(N.dot(o))).normalize(),M.cross(g.vertexNormals[d],o),e=M.dot(D[e]),e=e<0?-1:1,g.vertexTangents[d]=new THREE.Vector4(A.x,A.y,A.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,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
 void 0?(a[b]={set:{},array:[]},a[b].set[c]=1,a[b].array.push(c)):a[b].set[c]===void 0&&(a[b].set[c]=1,a[b].array.push(c))}var c,d,e,g,f,h={};c=0;for(d=this.faces.length;c<d;c++)f=this.faces[c],f instanceof THREE.Face3?(e=a(f.a,f.b),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.a,f.c),b(h,e,c)):f instanceof THREE.Face4&&(e=a(f.b,f.d),b(h,e,c),e=a(f.a,f.b),b(h,e,c),e=a(f.a,f.d),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.c,f.d),b(h,e,c));c=0;for(d=this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];g=f.vertexIndices[1];
 void 0?(a[b]={set:{},array:[]},a[b].set[c]=1,a[b].array.push(c)):a[b].set[c]===void 0&&(a[b].set[c]=1,a[b].array.push(c))}var c,d,e,g,f,h={};c=0;for(d=this.faces.length;c<d;c++)f=this.faces[c],f instanceof THREE.Face3?(e=a(f.a,f.b),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.a,f.c),b(h,e,c)):f instanceof THREE.Face4&&(e=a(f.b,f.d),b(h,e,c),e=a(f.a,f.b),b(h,e,c),e=a(f.a,f.d),b(h,e,c),e=a(f.b,f.c),b(h,e,c),e=a(f.c,f.d),b(h,e,c));c=0;for(d=this.edges.length;c<d;c++){f=this.edges[c];e=f.vertexIndices[0];g=f.vertexIndices[1];
-f.faceIndices=h[a(e,g)].array;for(e=0;e<f.faceIndices.length;e++)g=f.faceIndices[e],f.faces.push(this.faces[g])}}};THREE.GeometryIdCounter=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
+f.faceIndices=h[a(e,g)].array;for(e=0;e<f.faceIndices.length;e++)g=f.faceIndices[e],f.faces.push(this.faces[g])}}};THREE.GeometryCount=0;THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
 THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)};
 THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 THREE.Camera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
@@ -104,30 +115,19 @@ b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var a=k[h]=k[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,e,g=[],f,h,k=[],i,l,j=[],n,m=[],p,q,w=[],v,A,H=[],s=new THREE.Vector4,r=new THREE.Vector4,
-o=new THREE.Matrix4,E=new THREE.Matrix4,B=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],x=new THREE.Vector4,C=new THREE.Vector4;this.projectVector=function(a,b){o.multiply(b.projectionMatrix,b.matrixWorldInverse);o.multiplyVector3(a);return a};this.unprojectVector=function(a,b){o.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));o.multiplyVector3(a);return a};this.projectObjects=function(a,c,f){var c=[],h,i,k;e=0;i=
-a.objects;a=0;for(h=i.length;a<h;a++){k=i[a];var j;if(!(j=!k.visible))if(j=k instanceof THREE.Mesh){a:{j=void 0;for(var l=k.matrixWorld,n=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),m=0;m<6;m++)if(j=B[m].x*l.n14+B[m].y*l.n24+B[m].z*l.n34+B[m].w,j<=n){j=!1;break a}j=!0}j=!j}if(!j)j=g[e]=g[e]||new THREE.RenderableObject,e++,d=j,s.copy(k.position),o.multiplyVector3(s),d.object=k,d.z=s.z,c.push(d)}f&&c.sort(b);return c};this.projectScene=function(d,e,g){var s=[],
-L=e.near,M=e.far,P,Q,F,N,y,G,D,K,u,t,R,U,W,X,S,V,T;A=q=n=l=0;e.matrixAutoUpdate&&e.update(void 0,!0);d.update(void 0,!1,e);o.multiply(e.projectionMatrix,e.matrixWorldInverse);B[0].set(o.n41-o.n11,o.n42-o.n12,o.n43-o.n13,o.n44-o.n14);B[1].set(o.n41+o.n11,o.n42+o.n12,o.n43+o.n13,o.n44+o.n14);B[2].set(o.n41+o.n21,o.n42+o.n22,o.n43+o.n23,o.n44+o.n24);B[3].set(o.n41-o.n21,o.n42-o.n22,o.n43-o.n23,o.n44-o.n24);B[4].set(o.n41-o.n31,o.n42-o.n32,o.n43-o.n33,o.n44-o.n34);B[5].set(o.n41+o.n31,o.n42+o.n32,o.n43+
-o.n33,o.n44+o.n34);for(P=0;P<6;P++)u=B[P],u.divideScalar(Math.sqrt(u.x*u.x+u.y*u.y+u.z*u.z));u=this.projectObjects(d,e,!0);d=0;for(P=u.length;d<P;d++)if(t=u[d].object,t.visible)if(R=t.matrixWorld,U=t.matrixRotationWorld,W=t.materials,X=t.overdraw,h=0,t instanceof THREE.Mesh){S=t.geometry;N=S.vertices;V=S.faces;S=S.faceVertexUvs;Q=0;for(F=N.length;Q<F;Q++)f=a(),f.positionWorld.copy(N[Q].position),R.multiplyVector3(f.positionWorld),f.positionScreen.copy(f.positionWorld),o.multiplyVector4(f.positionScreen),
-f.positionScreen.x/=f.positionScreen.w,f.positionScreen.y/=f.positionScreen.w,f.visible=f.positionScreen.z>L&&f.positionScreen.z<M;N=0;for(Q=V.length;N<Q;N++){F=V[N];if(F instanceof THREE.Face3)if(y=k[F.a],G=k[F.b],D=k[F.c],y.visible&&G.visible&&D.visible&&(t.doubleSided||t.flipSided!=(D.positionScreen.x-y.positionScreen.x)*(G.positionScreen.y-y.positionScreen.y)-(D.positionScreen.y-y.positionScreen.y)*(G.positionScreen.x-y.positionScreen.x)<0))K=j[l]=j[l]||new THREE.RenderableFace3,l++,i=K,i.v1.copy(y),
-i.v2.copy(G),i.v3.copy(D);else continue;else if(F instanceof THREE.Face4)if(y=k[F.a],G=k[F.b],D=k[F.c],K=k[F.d],y.visible&&G.visible&&D.visible&&K.visible&&(t.doubleSided||t.flipSided!=((K.positionScreen.x-y.positionScreen.x)*(G.positionScreen.y-y.positionScreen.y)-(K.positionScreen.y-y.positionScreen.y)*(G.positionScreen.x-y.positionScreen.x)<0||(G.positionScreen.x-D.positionScreen.x)*(K.positionScreen.y-D.positionScreen.y)-(G.positionScreen.y-D.positionScreen.y)*(K.positionScreen.x-D.positionScreen.x)<
-0)))T=m[n]=m[n]||new THREE.RenderableFace4,n++,i=T,i.v1.copy(y),i.v2.copy(G),i.v3.copy(D),i.v4.copy(K);else continue;i.normalWorld.copy(F.normal);U.multiplyVector3(i.normalWorld);i.centroidWorld.copy(F.centroid);R.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);o.multiplyVector3(i.centroidScreen);D=F.vertexNormals;y=0;for(G=D.length;y<G;y++)K=i.vertexNormalsWorld[y],K.copy(D[y]),U.multiplyVector3(K);y=0;for(G=S.length;y<G;y++)if(T=S[y][N]){D=0;for(K=T.length;D<K;D++)i.uvs[y][D]=
-T[D]}i.meshMaterials=W;i.faceMaterials=F.materials;i.overdraw=X;i.z=i.centroidScreen.z;s.push(i)}}else if(t instanceof THREE.Line){E.multiply(o,R);N=t.geometry.vertices;y=a();y.positionScreen.copy(N[0].position);E.multiplyVector4(y.positionScreen);Q=1;for(F=N.length;Q<F;Q++)if(y=a(),y.positionScreen.copy(N[Q].position),E.multiplyVector4(y.positionScreen),G=k[h-2],x.copy(y.positionScreen),C.copy(G.positionScreen),c(x,C))x.multiplyScalar(1/x.w),C.multiplyScalar(1/C.w),R=w[q]=w[q]||new THREE.RenderableLine,
-q++,p=R,p.v1.positionScreen.copy(x),p.v2.positionScreen.copy(C),p.z=Math.max(x.z,C.z),p.materials=t.materials,s.push(p)}else if(t instanceof THREE.Particle&&(r.set(t.matrixWorld.n14,t.matrixWorld.n24,t.matrixWorld.n34,1),o.multiplyVector4(r),r.z/=r.w,r.z>0&&r.z<1))R=H[A]=H[A]||new THREE.RenderableParticle,A++,v=R,v.x=r.x/r.w,v.y=r.y/r.w,v.z=r.z,v.rotation=t.rotation.z,v.scale.x=t.scale.x*Math.abs(v.x-(r.x+e.projectionMatrix.n11)/(r.w+e.projectionMatrix.n14)),v.scale.y=t.scale.y*Math.abs(v.y-(r.y+
-e.projectionMatrix.n22)/(r.w+e.projectionMatrix.n24)),v.materials=t.materials,s.push(v);g&&s.sort(b);return s}};
-THREE.SVGRenderer=function(){function a(a,b,c){var d,e,f,g;d=0;for(e=a.lights.length;d<e;d++)f=a.lights[d],f instanceof THREE.DirectionalLight?(g=b.normalWorld.dot(f.position)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(C.sub(f.position,b.centroidWorld),C.normalize(),g=b.normalWorld.dot(C)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function b(b,c,f,h,i,j){g.data.vertices+=3;g.data.faces++;z=d(O++);z.setAttribute("d",
-"M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+"z");i instanceof THREE.MeshBasicMaterial?s.copy(i.color):i instanceof THREE.MeshLambertMaterial?H?(r.r=o.r,r.g=o.g,r.b=o.b,a(j,h,r),s.r=Math.max(0,Math.min(i.color.r*r.r,1)),s.g=Math.max(0,Math.min(i.color.g*r.g,1)),s.b=Math.max(0,Math.min(i.color.b*r.b,1))):s.copy(i.color):i instanceof THREE.MeshDepthMaterial?(x=1-i.__2near/(i.__farPlusNear-h.z*i.__farMinusNear),
-s.setRGB(x,x,x)):i instanceof THREE.MeshNormalMaterial&&s.setRGB(e(h.normalWorld.x),e(h.normalWorld.y),e(h.normalWorld.z));i.wireframe?z.setAttribute("style","fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+i.wireframeLinewidth+"; stroke-opacity: "+i.opacity+"; stroke-linecap: "+i.wireframeLinecap+"; stroke-linejoin: "+i.wireframeLinejoin):z.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+i.opacity);k.appendChild(z)}function c(b,c,f,h,i,j,l){g.data.vertices+=4;g.data.faces++;
-z=d(O++);z.setAttribute("d","M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");j instanceof THREE.MeshBasicMaterial?s.copy(j.color):j instanceof THREE.MeshLambertMaterial?H?(r.r=o.r,r.g=o.g,r.b=o.b,a(l,i,r),s.r=Math.max(0,Math.min(j.color.r*r.r,1)),s.g=Math.max(0,Math.min(j.color.g*r.g,1)),s.b=Math.max(0,Math.min(j.color.b*r.b,1))):s.copy(j.color):j instanceof
-THREE.MeshDepthMaterial?(x=1-j.__2near/(j.__farPlusNear-i.z*j.__farMinusNear),s.setRGB(x,x,x)):j instanceof THREE.MeshNormalMaterial&&s.setRGB(e(i.normalWorld.x),e(i.normalWorld.y),e(i.normalWorld.z));j.wireframe?z.setAttribute("style","fill: none; stroke: "+s.getContextStyle()+"; stroke-width: "+j.wireframeLinewidth+"; stroke-opacity: "+j.opacity+"; stroke-linecap: "+j.wireframeLinecap+"; stroke-linejoin: "+j.wireframeLinejoin):z.setAttribute("style","fill: "+s.getContextStyle()+"; fill-opacity: "+
-j.opacity);k.appendChild(z)}function d(a){I[a]==null&&(I[a]=document.createElementNS("http://www.w3.org/2000/svg","path"),M==0&&I[a].setAttribute("shape-rendering","crispEdges"));return I[a]}function e(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var g=this,f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,j,n,m,p,q,w,v=new THREE.Rectangle,A=new THREE.Rectangle,H=!1,s=new THREE.Color(16777215),r=new THREE.Color(16777215),o=new THREE.Color(0),E=new THREE.Color(0),
-B=new THREE.Color(0),x,C=new THREE.Vector3,I=[],J=[],z,O,L,M=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(a){switch(a){case "high":M=1;break;case "low":M=0}};this.setSize=function(a,b){i=a;l=b;j=i/2;n=l/2;k.setAttribute("viewBox",-j+" "+-n+" "+i+" "+l);k.setAttribute("width",i);k.setAttribute("height",l);v.set(-j,-n,j,n)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=
-function(a,d){var e,i,l,r,s,x,u,t;this.autoClear&&this.clear();g.data.vertices=0;g.data.faces=0;f=h.projectScene(a,d,this.sortElements);L=O=0;if(H=a.lights.length>0){u=a.lights;o.setRGB(0,0,0);E.setRGB(0,0,0);B.setRGB(0,0,0);e=0;for(i=u.length;e<i;e++)l=u[e],r=l.color,l instanceof THREE.AmbientLight?(o.r+=r.r,o.g+=r.g,o.b+=r.b):l instanceof THREE.DirectionalLight?(E.r+=r.r,E.g+=r.g,E.b+=r.b):l instanceof THREE.PointLight&&(B.r+=r.r,B.g+=r.g,B.b+=r.b)}e=0;for(i=f.length;e<i;e++)if(u=f[e],A.empty(),
-u instanceof THREE.RenderableParticle){m=u;m.x*=j;m.y*=-n;l=0;for(r=u.materials.length;l<r;)l++}else if(u instanceof THREE.RenderableLine){if(m=u.v1,p=u.v2,m.positionScreen.x*=j,m.positionScreen.y*=-n,p.positionScreen.x*=j,p.positionScreen.y*=-n,A.addPoint(m.positionScreen.x,m.positionScreen.y),A.addPoint(p.positionScreen.x,p.positionScreen.y),v.instersects(A)){l=0;for(r=u.materials.length;l<r;)if((t=u.materials[l++])&&t.opacity!=0){s=m;x=p;var C=L++;J[C]==null&&(J[C]=document.createElementNS("http://www.w3.org/2000/svg",
-"line"),M==0&&J[C].setAttribute("shape-rendering","crispEdges"));z=J[C];z.setAttribute("x1",s.positionScreen.x);z.setAttribute("y1",s.positionScreen.y);z.setAttribute("x2",x.positionScreen.x);z.setAttribute("y2",x.positionScreen.y);t instanceof THREE.LineBasicMaterial&&(z.setAttribute("style","fill: none; stroke: "+t.color.getContextStyle()+"; stroke-width: "+t.linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.linecap+"; stroke-linejoin: "+t.linejoin),k.appendChild(z))}}}else if(u instanceof
-THREE.RenderableFace3){if(m=u.v1,p=u.v2,q=u.v3,m.positionScreen.x*=j,m.positionScreen.y*=-n,p.positionScreen.x*=j,p.positionScreen.y*=-n,q.positionScreen.x*=j,q.positionScreen.y*=-n,A.addPoint(m.positionScreen.x,m.positionScreen.y),A.addPoint(p.positionScreen.x,p.positionScreen.y),A.addPoint(q.positionScreen.x,q.positionScreen.y),v.instersects(A)){l=0;for(r=u.meshMaterials.length;l<r;)if(t=u.meshMaterials[l++],t instanceof THREE.MeshFaceMaterial){s=0;for(x=u.faceMaterials.length;s<x;)(t=u.faceMaterials[s++])&&
-t.opacity!=0&&b(m,p,q,u,t,a)}else t&&t.opacity!=0&&b(m,p,q,u,t,a)}}else if(u instanceof THREE.RenderableFace4&&(m=u.v1,p=u.v2,q=u.v3,w=u.v4,m.positionScreen.x*=j,m.positionScreen.y*=-n,p.positionScreen.x*=j,p.positionScreen.y*=-n,q.positionScreen.x*=j,q.positionScreen.y*=-n,w.positionScreen.x*=j,w.positionScreen.y*=-n,A.addPoint(m.positionScreen.x,m.positionScreen.y),A.addPoint(p.positionScreen.x,p.positionScreen.y),A.addPoint(q.positionScreen.x,q.positionScreen.y),A.addPoint(w.positionScreen.x,w.positionScreen.y),
-v.instersects(A))){l=0;for(r=u.meshMaterials.length;l<r;)if(t=u.meshMaterials[l++],t instanceof THREE.MeshFaceMaterial){s=0;for(x=u.faceMaterials.length;s<x;)(t=u.faceMaterials[s++])&&t.opacity!=0&&c(m,p,q,w,u,t,a)}else t&&t.opacity!=0&&c(m,p,q,w,u,t,a)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+THREE.SVGRenderer=function(){function a(a,b,c){var d,e,f,g;d=0;for(e=a.lights.length;d<e;d++)f=a.lights[d],f instanceof THREE.DirectionalLight?(g=b.normalWorld.dot(f.position)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(D.sub(f.position,b.centroidWorld),D.normalize(),g=b.normalWorld.dot(D)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function b(b,c,f,h,i,j){g.data.vertices+=3;g.data.faces++;A=d(M++);A.setAttribute("d",
+"M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+"z");i instanceof THREE.MeshBasicMaterial?t.copy(i.color):i instanceof THREE.MeshLambertMaterial?K?(w.r=z.r,w.g=z.g,w.b=z.b,a(j,h,w),t.r=Math.max(0,Math.min(i.color.r*w.r,1)),t.g=Math.max(0,Math.min(i.color.g*w.g,1)),t.b=Math.max(0,Math.min(i.color.b*w.b,1))):t.copy(i.color):i instanceof THREE.MeshDepthMaterial?(E=1-i.__2near/(i.__farPlusNear-h.z*i.__farMinusNear),
+t.setRGB(E,E,E)):i instanceof THREE.MeshNormalMaterial&&t.setRGB(e(h.normalWorld.x),e(h.normalWorld.y),e(h.normalWorld.z));i.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+i.wireframeLinewidth+"; stroke-opacity: "+i.opacity+"; stroke-linecap: "+i.wireframeLinecap+"; stroke-linejoin: "+i.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+i.opacity);k.appendChild(A)}function c(b,c,f,h,i,j,m){g.data.vertices+=4;g.data.faces++;
+A=d(M++);A.setAttribute("d","M "+b.positionScreen.x+" "+b.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+f.positionScreen.x+","+f.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");j instanceof THREE.MeshBasicMaterial?t.copy(j.color):j instanceof THREE.MeshLambertMaterial?K?(w.r=z.r,w.g=z.g,w.b=z.b,a(m,i,w),t.r=Math.max(0,Math.min(j.color.r*w.r,1)),t.g=Math.max(0,Math.min(j.color.g*w.g,1)),t.b=Math.max(0,Math.min(j.color.b*w.b,1))):t.copy(j.color):j instanceof
+THREE.MeshDepthMaterial?(E=1-j.__2near/(j.__farPlusNear-i.z*j.__farMinusNear),t.setRGB(E,E,E)):j instanceof THREE.MeshNormalMaterial&&t.setRGB(e(i.normalWorld.x),e(i.normalWorld.y),e(i.normalWorld.z));j.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+j.wireframeLinewidth+"; stroke-opacity: "+j.opacity+"; stroke-linecap: "+j.wireframeLinecap+"; stroke-linejoin: "+j.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+
+j.opacity);k.appendChild(A)}function d(a){F[a]==null&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg","path"),O==0&&F[a].setAttribute("shape-rendering","crispEdges"));return F[a]}function e(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}var g=this,f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,j,m,n,p,q,v,u=new THREE.Rectangle,C=new THREE.Rectangle,K=!1,t=new THREE.Color(16777215),w=new THREE.Color(16777215),z=new THREE.Color(0),y=new THREE.Color(0),
+o=new THREE.Color(0),E,D=new THREE.Vector3,F=[],G=[],A,M,N,O=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(a){switch(a){case "high":O=1;break;case "low":O=0}};this.setSize=function(a,b){i=a;l=b;j=i/2;m=l/2;k.setAttribute("viewBox",-j+" "+-m+" "+i+" "+l);k.setAttribute("width",i);k.setAttribute("height",l);u.set(-j,-m,j,m)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=
+function(a,d){var e,i,l,r,t,w,s,x;this.autoClear&&this.clear();g.data.vertices=0;g.data.faces=0;f=h.projectScene(a,d,this.sortElements);N=M=0;if(K=a.lights.length>0){s=a.lights;z.setRGB(0,0,0);y.setRGB(0,0,0);o.setRGB(0,0,0);e=0;for(i=s.length;e<i;e++)l=s[e],r=l.color,l instanceof THREE.AmbientLight?(z.r+=r.r,z.g+=r.g,z.b+=r.b):l instanceof THREE.DirectionalLight?(y.r+=r.r,y.g+=r.g,y.b+=r.b):l instanceof THREE.PointLight&&(o.r+=r.r,o.g+=r.g,o.b+=r.b)}e=0;for(i=f.length;e<i;e++)if(s=f[e],C.empty(),
+s instanceof THREE.RenderableParticle){n=s;n.x*=j;n.y*=-m;l=0;for(r=s.materials.length;l<r;)l++}else if(s instanceof THREE.RenderableLine){if(n=s.v1,p=s.v2,n.positionScreen.x*=j,n.positionScreen.y*=-m,p.positionScreen.x*=j,p.positionScreen.y*=-m,C.addPoint(n.positionScreen.x,n.positionScreen.y),C.addPoint(p.positionScreen.x,p.positionScreen.y),u.instersects(C)){l=0;for(r=s.materials.length;l<r;)if((x=s.materials[l++])&&x.opacity!=0){t=n;w=p;var B=N++;G[B]==null&&(G[B]=document.createElementNS("http://www.w3.org/2000/svg",
+"line"),O==0&&G[B].setAttribute("shape-rendering","crispEdges"));A=G[B];A.setAttribute("x1",t.positionScreen.x);A.setAttribute("y1",t.positionScreen.y);A.setAttribute("x2",w.positionScreen.x);A.setAttribute("y2",w.positionScreen.y);x instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+x.color.getContextStyle()+"; stroke-width: "+x.linewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.linecap+"; stroke-linejoin: "+x.linejoin),k.appendChild(A))}}}else if(s instanceof
+THREE.RenderableFace3){if(n=s.v1,p=s.v2,q=s.v3,n.positionScreen.x*=j,n.positionScreen.y*=-m,p.positionScreen.x*=j,p.positionScreen.y*=-m,q.positionScreen.x*=j,q.positionScreen.y*=-m,C.addPoint(n.positionScreen.x,n.positionScreen.y),C.addPoint(p.positionScreen.x,p.positionScreen.y),C.addPoint(q.positionScreen.x,q.positionScreen.y),u.instersects(C)){l=0;for(r=s.meshMaterials.length;l<r;)if(x=s.meshMaterials[l++],x instanceof THREE.MeshFaceMaterial){t=0;for(w=s.faceMaterials.length;t<w;)(x=s.faceMaterials[t++])&&
+x.opacity!=0&&b(n,p,q,s,x,a)}else x&&x.opacity!=0&&b(n,p,q,s,x,a)}}else if(s instanceof THREE.RenderableFace4&&(n=s.v1,p=s.v2,q=s.v3,v=s.v4,n.positionScreen.x*=j,n.positionScreen.y*=-m,p.positionScreen.x*=j,p.positionScreen.y*=-m,q.positionScreen.x*=j,q.positionScreen.y*=-m,v.positionScreen.x*=j,v.positionScreen.y*=-m,C.addPoint(n.positionScreen.x,n.positionScreen.y),C.addPoint(p.positionScreen.x,p.positionScreen.y),C.addPoint(q.positionScreen.x,q.positionScreen.y),C.addPoint(v.positionScreen.x,v.positionScreen.y),
+u.instersects(C))){l=0;for(r=s.meshMaterials.length;l<r;)if(x=s.meshMaterials[l++],x instanceof THREE.MeshFaceMaterial){t=0;for(w=s.faceMaterials.length;t<w;)(x=s.faceMaterials[t++])&&x.opacity!=0&&c(n,p,q,v,s,x,a)}else x&&x.opacity!=0&&c(n,p,q,v,s,x,a)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 77 - 76
build/custom/ThreeWebGL.js


+ 761 - 74
examples/js/ShaderExtras.js

@@ -1,11 +1,242 @@
-var ShaderExtras = {
+/**
+ * @author alteredq / http://alteredqualia.com/
+ *
+ * ShaderExtras currently contains:
+ *
+ *	screen
+ *	convolution
+ *	film
+ * 	bokeh
+ *  sepia
+ *	dotscreen
+ *	vignette
+ *  bleachbypass
+ *	basic
+ *
+ */
+
+THREE.ShaderExtras = {
+
+	/* -------------------------------------------------------------------------
+	//	Full-screen textured quad shader
+	 ------------------------------------------------------------------------- */
+
+	'screen': {
+
+		uniforms: {
+
+			tDiffuse: { type: "t", value: 0, texture: null },
+			opacity:  { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float opacity;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec4 texel = texture2D( tDiffuse, vUv );",
+				"gl_FragColor = opacity * texel;",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* ------------------------------------------------------------------------
+	//	Convolution shader
+	//	  - ported from o3d sample to WebGL / GLSL
+	//			http://o3d.googlecode.com/svn/trunk/samples/convolution.html
+	------------------------------------------------------------------------ */
+
+	'convolution': {
+
+		uniforms: {
+
+			"tDiffuse" : 		{ type: "t", value: 0, texture: null },
+			"uImageIncrement" : { type: "v2", value: new THREE.Vector2( 0.001953125, 0.0 ) },
+			"cKernel" : 		{ type: "fv1", value: [] }
+
+		},
+
+		vertexShader: [
+
+			//"#define KERNEL_SIZE 25.0",
+
+			"uniform vec2 uImageIncrement;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = uv - ( ( KERNEL_SIZE - 1.0 ) / 2.0 ) * uImageIncrement;",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			//"#define KERNEL_SIZE 25",
+			"uniform float cKernel[ KERNEL_SIZE ];",
+
+			"uniform sampler2D tDiffuse;",
+			"uniform vec2 uImageIncrement;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec2 imageCoord = vUv;",
+				"vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );",
+
+				"for( int i = 0; i < KERNEL_SIZE; i ++ ) {",
+
+					"sum += texture2D( tDiffuse, imageCoord ) * cKernel[ i ];",
+					"imageCoord += uImageIncrement;",
+
+				"}",
+
+				"gl_FragColor = sum;",
+
+			"}"
+
+
+		].join("\n")
+
+	},
+
+	/* -------------------------------------------------------------------------
+
+	// Film grain & scanlines shader
+
+	//	- ported from HLSL to WebGL / GLSL
+	//	  http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
+
+	// Screen Space Static Postprocessor
+	//
+	// Produces an analogue noise overlay similar to a film grain / TV static
+	//
+	// Original implementation and noise algorithm
+	// Pat 'Hawthorne' Shearon
+	//
+	// Optimized scanlines + noise version with intensity scaling
+	// Georg 'Leviathan' Steinrohder
+
+	// This version is provided under a Creative Commons Attribution 3.0 License
+	// http://creativecommons.org/licenses/by/3.0/
+	 ------------------------------------------------------------------------- */
+
+	'film': {
+
+		uniforms: {
+
+			tDiffuse:   { type: "t", value: 0, texture: null },
+			time: 	    { type: "f", value: 0.0 },
+			nIntensity: { type: "f", value: 0.5 },
+			sIntensity: { type: "f", value: 0.05 },
+			sCount: 	{ type: "f", value: 4096 },
+			grayscale:  { type: "i", value: 1 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			// control parameter
+			"uniform float time;",
+
+			"uniform bool grayscale;",
+
+			// noise effect intensity value (0 = no effect, 1 = full effect)
+			"uniform float nIntensity;",
+
+			// scanlines effect intensity value (0 = no effect, 1 = full effect)
+			"uniform float sIntensity;",
+
+			// scanlines effect count value (0 = no effect, 4096 = full effect)
+			"uniform float sCount;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				// sample the source
+				"vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
+
+				// make some noise
+				"float x = vUv.x * vUv.y * time *  1000.0;",
+				"x = mod( x, 13.0 ) * mod( x, 123.0 );",
+				"float dx = mod( x, 0.01 );",
+
+				// add noise
+				"vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );",
+
+				// get us a sine and cosine
+				"vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
+
+				// add scanlines
+				"cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
+
+				// interpolate between source and result by intensity
+				"cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
+
+				// convert to grayscale if desired
+				"if( grayscale ) {",
+
+					"cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
+
+				"}",
+
+				"gl_FragColor =  vec4( cResult, cTextureScreen.a );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
 
 
 	/* -------------------------------------------------------------------------
 	/* -------------------------------------------------------------------------
 	//	Depth-of-field shader with bokeh
 	//	Depth-of-field shader with bokeh
-	//	ported from GLSL shader by Martins Upitis 
+	//	ported from GLSL shader by Martins Upitis
 	//	http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
 	//	http://artmartinsh.blogspot.com/2010/02/glsl-lens-blur-filter-with-bokeh.html
 	 ------------------------------------------------------------------------- */
 	 ------------------------------------------------------------------------- */
-	
+
 	'bokeh'	: {
 	'bokeh'	: {
 
 
 	uniforms: { tColor:   { type: "t", value: 0, texture: null },
 	uniforms: { tColor:   { type: "t", value: 0, texture: null },
@@ -21,10 +252,10 @@ var ShaderExtras = {
 	"varying vec2 vUv;",
 	"varying vec2 vUv;",
 
 
 	"void main() {",
 	"void main() {",
-		
+
 		"vUv = vec2( uv.x, 1.0 - uv.y );",
 		"vUv = vec2( uv.x, 1.0 - uv.y );",
 		"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
 		"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-		
+
 	"}"
 	"}"
 
 
 	].join("\n"),
 	].join("\n"),
@@ -32,84 +263,540 @@ var ShaderExtras = {
 	fragmentShader: [
 	fragmentShader: [
 
 
 	"varying vec2 vUv;",
 	"varying vec2 vUv;",
-	
+
 	"uniform sampler2D tColor;",
 	"uniform sampler2D tColor;",
 	"uniform sampler2D tDepth;",
 	"uniform sampler2D tDepth;",
 
 
 	"uniform float maxblur;",  	// max blur amount
 	"uniform float maxblur;",  	// max blur amount
 	"uniform float aperture;",	// aperture - bigger values for shallower depth of field
 	"uniform float aperture;",	// aperture - bigger values for shallower depth of field
-	
+
 	"uniform float focus;",
 	"uniform float focus;",
 	"uniform float aspect;",
 	"uniform float aspect;",
-	
+
 	"void main() {",
 	"void main() {",
 
 
-	"vec2 aspectcorrect = vec2( 1.0, aspect );",
-
-	"vec4 depth1 = texture2D( tDepth, vUv );",
-
-	"float factor = depth1.x - focus;",
- 
-	"vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
-	
-	"vec2 dofblur9 = dofblur * 0.9;",
-	"vec2 dofblur7 = dofblur * 0.7;",
-	"vec2 dofblur4 = dofblur * 0.4;",
-
-	"vec4 col = vec4( 0.0 );",
-
-	"col += texture2D( tColor, vUv.xy );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.15,  0.37 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.37,  0.15 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.40,  0.0  ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.37, -0.15 ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.15,  0.37 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.37,  0.15 ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.15, -0.37 ) * aspectcorrect ) * dofblur );",
-
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.15,  0.37 ) * aspectcorrect ) * dofblur9 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.37,  0.15 ) * aspectcorrect ) * dofblur9 );",		
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",		
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.15,  0.37 ) * aspectcorrect ) * dofblur9 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.37,  0.15 ) * aspectcorrect ) * dofblur9 );",		
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",	
-
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur7 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.40,  0.0  ) * aspectcorrect ) * dofblur7 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur7 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur7 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur7 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur7 );",
-		 
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur4 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.4,   0.0  ) * aspectcorrect ) * dofblur4 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur4 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur4 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur4 );",
-	"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",	
-	"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur4 );",
-
-	"gl_FragColor = col / 41.0;",
-	"gl_FragColor.a = 1.0;",
-	
+		"vec2 aspectcorrect = vec2( 1.0, aspect );",
+
+		"vec4 depth1 = texture2D( tDepth, vUv );",
+
+		"float factor = depth1.x - focus;",
+
+		"vec2 dofblur = vec2 ( clamp( factor * aperture, -maxblur, maxblur ) );",
+
+		"vec2 dofblur9 = dofblur * 0.9;",
+		"vec2 dofblur7 = dofblur * 0.7;",
+		"vec2 dofblur4 = dofblur * 0.4;",
+
+		"vec4 col = vec4( 0.0 );",
+
+		"col += texture2D( tColor, vUv.xy );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.15,  0.37 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.37,  0.15 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.40,  0.0  ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.37, -0.15 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.15,  0.37 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.37,  0.15 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.15, -0.37 ) * aspectcorrect ) * dofblur );",
+
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.15,  0.37 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.37,  0.15 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.15,  0.37 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.37,  0.15 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.37, -0.15 ) * aspectcorrect ) * dofblur9 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.15, -0.37 ) * aspectcorrect ) * dofblur9 );",
+
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.40,  0.0  ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur7 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur7 );",
+
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29,  0.29 ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.4,   0.0  ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,  -0.4  ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29,  0.29 ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.4,   0.0  ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2( -0.29, -0.29 ) * aspectcorrect ) * dofblur4 );",
+		"col += texture2D( tColor, vUv.xy + ( vec2(  0.0,   0.4  ) * aspectcorrect ) * dofblur4 );",
+
+		"gl_FragColor = col / 41.0;",
+		"gl_FragColor.a = 1.0;",
+
 	"}"
 	"}"
-	
-	].join("\n")	
-	
-}
+
+	].join("\n")
+
+	},
+
+	/* -------------------------------------------------------------------------
+	//	Depth-of-field shader using mipmaps
+	//	- from Matt Handley @applmak
+	//	- requires power-of-2 sized render target with enabled mipmaps
+	 ------------------------------------------------------------------------- */
+
+	'dofmipmap': {
+
+		uniforms: {
+
+			tColor:   { type: "t", value: 0, texture: null },
+			tDepth:   { type: "t", value: 1, texture: null },
+			focus:    { type: "f", value: 1.0 },
+			maxblur:  { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float focus;",
+			"uniform float maxblur;",
+
+			"uniform sampler2D tColor;",
+			"uniform sampler2D tDepth;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec4 depth = texture2D( tDepth, vUv );",
+
+				"float factor = depth.x - focus;",
+
+				"vec4 col = texture2D( tColor, vUv, 2.0 * maxblur * abs( focus - depth.x ) );",
+
+				"gl_FragColor = col;",
+				"gl_FragColor.a = 1.0;",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* -------------------------------------------------------------------------
+	//	Sepia tone shader
+	//  - based on glfx.js sepia shader
+	//		https://github.com/evanw/glfx.js
+	 ------------------------------------------------------------------------- */
+
+	'sepia': {
+
+		uniforms: {
+
+			tDiffuse: { type: "t", value: 0, texture: null },
+			amount:   { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float amount;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec4 color = texture2D( tDiffuse, vUv );",
+				"vec3 c = color.rgb;",
+
+				"color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );",
+				"color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );",
+				"color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );",
+
+				"gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* -------------------------------------------------------------------------
+	//	Dot screen shader
+	//  - based on glfx.js sepia shader
+	//		https://github.com/evanw/glfx.js
+	 ------------------------------------------------------------------------- */
+
+	'dotscreen': {
+
+		uniforms: {
+
+			tDiffuse: { type: "t", value: 0, texture: null },
+			tSize:    { type: "v2", value: new THREE.Vector2( 256, 256 ) },
+			center:   { type: "v2", value: new THREE.Vector2( 0.5, 0.5 ) },
+			angle:	  { type: "f", value: 1.57 },
+			scale:	  { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform vec2 center;",
+			"uniform float angle;",
+			"uniform float scale;",
+			"uniform vec2 tSize;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"float pattern() {",
+
+				"float s = sin( angle ), c = cos( angle );",
+
+				"vec2 tex = vUv * tSize - center;",
+				"vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;",
+
+				"return ( sin( point.x ) * sin( point.y ) ) * 4.0;",
+
+			"}",
+
+			"void main() {",
+
+				"vec4 color = texture2D( tDiffuse, vUv );",
+
+				"float average = ( color.r + color.g + color.b ) / 3.0;",
+
+				"gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* ------------------------------------------------------------------------------------------------
+	//	Vignette shader
+	//	- based on PaintEffect postprocess from ro.me
+	//		http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
+	 ------------------------------------------------------------------------------------------------ */
+
+	'vignette': {
+
+		uniforms: {
+
+			tDiffuse: { type: "t", value: 0, texture: null },
+			offset:   { type: "f", value: 1.0 },
+			darkness: { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float offset;",
+			"uniform float darkness;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				// Eskil's vignette
+
+				"vec4 texel = texture2D( tDiffuse, vUv );",
+				"vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );",
+				"gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );",
+
+				/*
+				// alternative version from glfx.js
+				// this one makes more "dusty" look (as opposed to "burned")
+
+				"vec4 color = texture2D( tDiffuse, vUv );",
+				"float dist = distance( vUv, vec2( 0.5 ) );",
+				"color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
+				"gl_FragColor = color;",
+				*/
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* -------------------------------------------------------------------------
+	//	Bleach bypass shader [http://en.wikipedia.org/wiki/Bleach_bypass]
+	//	- based on Nvidia example
+	//		http://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html#post_bleach_bypass
+	 ------------------------------------------------------------------------- */
+
+	'bleachbypass': {
+
+		uniforms: {
+
+			tDiffuse: { type: "t", value: 0, texture: null },
+			opacity:  { type: "f", value: 1.0 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float opacity;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec4 base = texture2D( tDiffuse, vUv );",
+
+				"vec3 lumCoeff = vec3( 0.25, 0.65, 0.1 );",
+				"float lum = dot( lumCoeff, base.rgb );",
+				"vec3 blend = vec3( lum );",
+
+				"float L = min( 1.0, max( 0.0, 10.0 * ( lum - 0.45 ) ) );",
+
+				"vec3 result1 = 2.0 * base.rgb * blend;",
+				"vec3 result2 = 1.0 - 2.0 * ( 1.0 - blend ) * ( 1.0 - base.rgb );",
+
+				"vec3 newColor = mix( result1, result2, L );",
+
+				"float A2 = opacity * base.a;",
+				"vec3 mixRGB = A2 * newColor.rgb;",
+				"mixRGB += ( ( 1.0 - A2 ) * base.rgb );",
+
+				"gl_FragColor = vec4( mixRGB, base.a );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	/* --------------------------------------------------------------------------------------------------
+	//	Focus shader
+	//	- based on PaintEffect postprocess from ro.me
+	//		http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
+	 -------------------------------------------------------------------------------------------------- */
+
+	'focus': {
+
+		uniforms : {
+
+			"tDiffuse": 		{ type: "t", value: 0, texture: null },
+			"screenWidth": 		{ type: "f", value: 1024 },
+			"screenHeight": 	{ type: "f", value: 1024 },
+			"sampleDistance": 	{ type: "f", value: 0.94 },
+			"waveFactor": 		{ type: "f", value: 0.00125 }
+
+		},
+
+		vertexShader: [
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vUv = vec2( uv.x, 1.0 - uv.y );",
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"uniform float screenWidth;",
+			"uniform float screenHeight;",
+			"uniform float sampleDistance;",
+			"uniform float waveFactor;",
+
+			"uniform sampler2D tDiffuse;",
+
+			"varying vec2 vUv;",
+
+			"void main() {",
+
+				"vec4 color, org, tmp, add;",
+				"float sample_dist, f;",
+				"vec2 vin;",
+				"vec2 uv = vUv;",
+
+				"add += color = org = texture2D( tDiffuse, uv );",
+
+				"vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
+				"sample_dist = dot( vin, vin ) * 2.0;",
+
+				"f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
+
+				"vec2 sampleSize = vec2(  1.0 / screenWidth, 1.0 / screenHeight ) * vec2( f );",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( 0.111964, 0.993712 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( 0.846724, 0.532032 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( 0.943883, -0.330279 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( 0.330279, -0.943883 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( -0.532032, -0.846724 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( -0.993712, -0.111964 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"add += tmp = texture2D( tDiffuse, uv + vec2( -0.707107, 0.707107 ) * sampleSize );",
+				"if( tmp.b < color.b ) color = tmp;",
+
+				"color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
+				"color = color + ( add / vec4( 8.0 ) - color ) * ( vec4( 1.0 ) - vec4( sample_dist * 0.5 ) );",
+
+				"gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
+
+			"}"
+
+
+		].join("\n")
+	},
+
+	/* -------------------------------------------------------------------------
+	//	Simple test shader
+	 ------------------------------------------------------------------------- */
+
+	'basic': {
+
+		uniforms: {},
+
+		vertexShader: [
+
+			"void main() {",
+
+				"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+
+			"}"
+
+		].join("\n"),
+
+		fragmentShader: [
+
+			"void main() {",
+
+				"gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
+
+			"}"
+
+		].join("\n")
+
+	},
+
+	// METHODS
+
+	buildKernel: function( sigma ) {
+
+		// We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.
+
+		function gauss( x, sigma ) {
+
+			return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) );
+
+		}
+
+		var i, values, sum, halfWidth, kMaxKernelSize = 25, kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1;
+
+		if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize;
+		halfWidth = ( kernelSize - 1 ) * 0.5
+
+		values = new Array( kernelSize );
+		sum = 0.0;
+		for ( i = 0; i < kernelSize; ++i ) {
+
+			values[ i ] = gauss( i - halfWidth, sigma );
+			sum += values[ i ];
+
+		}
+
+		// normalize the kernel
+
+		for ( i = 0; i < kernelSize; ++i ) values[ i ] /= sum;
+
+		return values;
+
+	}
 
 
 };
 };

+ 12 - 6
examples/js/postprocessing/BloomPass.js

@@ -18,7 +18,7 @@ THREE.BloomPass = function( strength, kernelSize, sigma, resolution ) {
 
 
 	// screen material
 	// screen material
 
 
-	var screenShader = THREE.ShaderUtils.lib[ "screen" ];
+	var screenShader = THREE.ShaderExtras[ "screen" ];
 
 
 	this.screenUniforms = THREE.UniformsUtils.clone( screenShader.uniforms );
 	this.screenUniforms = THREE.UniformsUtils.clone( screenShader.uniforms );
 
 
@@ -36,12 +36,12 @@ THREE.BloomPass = function( strength, kernelSize, sigma, resolution ) {
 
 
 	// convolution material
 	// convolution material
 
 
-	var convolutionShader = THREE.ShaderUtils.lib[ "convolution" ];
+	var convolutionShader = THREE.ShaderExtras[ "convolution" ];
 
 
 	this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms );
 	this.convolutionUniforms = THREE.UniformsUtils.clone( convolutionShader.uniforms );
 
 
 	this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurx;
 	this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurx;
-	this.convolutionUniforms[ "cKernel" ].value = THREE.ShaderUtils.buildKernel( sigma );
+	this.convolutionUniforms[ "cKernel" ].value = THREE.ShaderExtras.buildKernel( sigma );
 
 
 	this.materialConvolution = new THREE.MeshShaderMaterial( {
 	this.materialConvolution = new THREE.MeshShaderMaterial( {
 
 
@@ -51,17 +51,21 @@ THREE.BloomPass = function( strength, kernelSize, sigma, resolution ) {
 
 
 	} );
 	} );
 
 
+	this.needsSwap = false;
+
 };
 };
 
 
 THREE.BloomPass.prototype = {
 THREE.BloomPass.prototype = {
 
 
-	render: function ( renderer, renderTarget, delta ) {
+	render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
+
+		if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );
 
 
 		// Render quad with blured scene into texture (convolution pass 1)
 		// Render quad with blured scene into texture (convolution pass 1)
 
 
 		THREE.EffectComposer.quad.materials[ 0 ] = this.materialConvolution;
 		THREE.EffectComposer.quad.materials[ 0 ] = this.materialConvolution;
 
 
-		this.convolutionUniforms[ "tDiffuse" ].texture = renderTarget;
+		this.convolutionUniforms[ "tDiffuse" ].texture = readBuffer;
 		this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
 		this.convolutionUniforms[ "uImageIncrement" ].value = THREE.BloomPass.blurX;
 
 
 		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTargetX, true );
 		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, this.renderTargetX, true );
@@ -79,7 +83,9 @@ THREE.BloomPass.prototype = {
 
 
 		this.screenUniforms[ "tDiffuse" ].texture = this.renderTargetY;
 		this.screenUniforms[ "tDiffuse" ].texture = this.renderTargetY;
 
 
-		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, renderTarget, false );
+		if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );
+
+		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer, false );
 
 
 	}
 	}
 
 

+ 6 - 5
examples/js/postprocessing/DotScreenPass.js

@@ -4,7 +4,7 @@
 
 
 THREE.DotScreenPass = function( center, angle, scale ) {
 THREE.DotScreenPass = function( center, angle, scale ) {
 
 
-	var shader = THREE.ShaderUtils.lib[ "dotscreen" ];
+	var shader = THREE.ShaderExtras[ "dotscreen" ];
 
 
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
 
@@ -23,15 +23,16 @@ THREE.DotScreenPass = function( center, angle, scale ) {
 	} );
 	} );
 
 
 	this.renderToScreen = false;
 	this.renderToScreen = false;
+	this.needsSwap = true;
 
 
 };
 };
 
 
 THREE.DotScreenPass.prototype = {
 THREE.DotScreenPass.prototype = {
 
 
-	render: function ( renderer, renderTarget, delta ) {
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
 
 
-		this.uniforms[ "tDiffuse" ].texture = renderTarget;
-		this.uniforms[ "tSize" ].value.set( renderTarget.width, renderTarget.height );
+		this.uniforms[ "tDiffuse" ].texture = readBuffer;
+		this.uniforms[ "tSize" ].value.set( readBuffer.width, readBuffer.height );
 
 
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 
 
@@ -41,7 +42,7 @@ THREE.DotScreenPass.prototype = {
 
 
 		} else {
 		} else {
 
 
-			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, renderTarget, false );
+			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
 
 
 		}
 		}
 
 

+ 65 - 8
examples/js/postprocessing/EffectComposer.js

@@ -5,21 +5,37 @@
 THREE.EffectComposer = function( renderer, renderTarget ) {
 THREE.EffectComposer = function( renderer, renderTarget ) {
 
 
 	this.renderer = renderer;
 	this.renderer = renderer;
-	this.renderTarget = renderTarget;
 
 
-	if ( this.renderTarget === undefined ) {
+	this.renderTarget1 = renderTarget;
+
+	if ( this.renderTarget1 === undefined ) {
 
 
 		this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBufer: false };
 		this.renderTargetParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBufer: false };
-		this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
+		this.renderTarget1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
 
 
 	}
 	}
 
 
+	this.renderTarget2 = this.renderTarget1.clone();
+
+	this.writeBuffer = this.renderTarget1;
+	this.readBuffer = this.renderTarget2;
+
 	this.passes = [];
 	this.passes = [];
 
 
+	this.copyPass = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
+
 };
 };
 
 
 THREE.EffectComposer.prototype = {
 THREE.EffectComposer.prototype = {
 
 
+	swapBuffers: function() {
+
+		var tmp = this.readBuffer;
+		this.readBuffer = this.writeBuffer;
+		this.writeBuffer = tmp;
+
+	},
+
 	addPass: function ( pass ) {
 	addPass: function ( pass ) {
 
 
 		this.passes.push( pass );
 		this.passes.push( pass );
@@ -28,24 +44,66 @@ THREE.EffectComposer.prototype = {
 
 
 	render: function ( delta ) {
 	render: function ( delta ) {
 
 
+		this.writeBuffer = this.renderTarget1;
+		this.readBuffer = this.renderTarget2;
+
+		var maskActive = false;
+
 		var i, il = this.passes.length;
 		var i, il = this.passes.length;
 
 
 		for ( i = 0; i < il; i ++ ) {
 		for ( i = 0; i < il; i ++ ) {
 
 
-			this.passes[ i ].render( this.renderer, this.renderTarget, delta );
+			this.passes[ i ].render( this.renderer, this.writeBuffer, this.readBuffer, delta, maskActive );
+
+			if ( this.passes[ i ].needsSwap ) {
+
+				if ( maskActive ) {
+
+					var context = this.renderer.context;
+
+					context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );
+
+					this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, delta );
+
+					context.stencilFunc( context.EQUAL, 1, 0xffffffff );
+
+				}
+
+				this.swapBuffers();
+
+			}
+
+			if ( this.passes[ i ] instanceof THREE.MaskPass ) {
+
+				maskActive = true;
+
+			}
+
+			if ( this.passes[ i ] instanceof THREE.ClearMaskPass ) {
+
+				maskActive = false;
+
+			}
 
 
 		}
 		}
 
 
 	},
 	},
 
 
-	reset: function () {
+	reset: function ( renderTarget ) {
+
+		this.renderTarget1 = renderTarget;
 
 
-		if ( this.renderTargetParameters ) {
+		if ( this.renderTarget1 === undefined ) {
 
 
-			this.renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
+			this.renderTarget1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, this.renderTargetParameters );
 
 
 		}
 		}
 
 
+		this.renderTarget2 = this.renderTarget1.clone();
+
+		this.writeBuffer = this.renderTarget1;
+		this.readBuffer = this.renderTarget2;
+
 		THREE.EffectComposer.quad.scale.set( window.innerWidth, window.innerHeight, 1 );
 		THREE.EffectComposer.quad.scale.set( window.innerWidth, window.innerHeight, 1 );
 
 
 		THREE.EffectComposer.camera.left = window.innerWidth / - 2;
 		THREE.EffectComposer.camera.left = window.innerWidth / - 2;
@@ -55,7 +113,6 @@ THREE.EffectComposer.prototype = {
 
 
 		THREE.EffectComposer.camera.updateProjectionMatrix();
 		THREE.EffectComposer.camera.updateProjectionMatrix();
 
 
-
 	}
 	}
 
 
 };
 };

+ 5 - 4
examples/js/postprocessing/FilmPass.js

@@ -4,7 +4,7 @@
 
 
 THREE.FilmPass = function( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
 THREE.FilmPass = function( noiseIntensity, scanlinesIntensity, scanlinesCount, grayscale ) {
 
 
-	var shader = THREE.ShaderUtils.lib[ "film" ];
+	var shader = THREE.ShaderExtras[ "film" ];
 
 
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
 
@@ -22,14 +22,15 @@ THREE.FilmPass = function( noiseIntensity, scanlinesIntensity, scanlinesCount, g
 	if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
 	if ( scanlinesCount !== undefined ) this.uniforms.sCount.value = scanlinesCount;
 
 
 	this.renderToScreen = false;
 	this.renderToScreen = false;
+	this.needsSwap = true;
 
 
 };
 };
 
 
 THREE.FilmPass.prototype = {
 THREE.FilmPass.prototype = {
 
 
-	render: function ( renderer, renderTarget, delta ) {
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
 
 
-		this.uniforms[ "tDiffuse" ].texture = renderTarget;
+		this.uniforms[ "tDiffuse" ].texture = readBuffer;
 		this.uniforms[ "time" ].value += delta;
 		this.uniforms[ "time" ].value += delta;
 
 
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
@@ -40,7 +41,7 @@ THREE.FilmPass.prototype = {
 
 
 		} else {
 		} else {
 
 
-			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, renderTarget, false );
+			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
 
 
 		}
 		}
 
 

+ 66 - 0
examples/js/postprocessing/MaskPass.js

@@ -0,0 +1,66 @@
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.MaskPass = function ( scene, camera ) {
+
+	this.scene = scene;
+	this.camera = camera;
+
+	this.clear = true;
+	this.needsSwap = false;
+
+};
+
+THREE.MaskPass.prototype = {
+
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
+
+		var context = renderer.context;
+
+		// don't update color or depth
+
+		context.colorMask( false, false, false, false );
+		context.depthMask( false );
+
+		// set up stencil
+
+		context.enable( context.STENCIL_TEST );
+		context.stencilOp( context.REPLACE, context.REPLACE, context.REPLACE );
+		context.stencilFunc( context.ALWAYS, 1, 0xffffffff );
+
+		// draw into the stencil buffer
+
+		renderer.render( this.scene, this.camera, readBuffer, this.clear );
+		renderer.render( this.scene, this.camera, writeBuffer, this.clear );
+
+		// re-enable update of color and depth
+
+		context.colorMask( true, true, true, true );
+		context.depthMask( true );
+
+		// only render where stencil is set to 1
+
+		context.stencilFunc( context.EQUAL, 1, 0xffffffff );  // draw if == 1
+		context.stencilOp( context.KEEP, context.KEEP, context.KEEP );
+
+	}
+
+};
+
+
+THREE.ClearMaskPass = function () {
+
+};
+
+THREE.ClearMaskPass.prototype = {
+
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
+
+		var context = renderer.context;
+
+		context.disable( context.STENCIL_TEST );
+
+	}
+
+};

+ 9 - 3
examples/js/postprocessing/RenderPass.js

@@ -2,20 +2,26 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.RenderPass = function ( scene, camera ) {
+THREE.RenderPass = function ( scene, camera, overrideMaterial ) {
 
 
 	this.scene = scene;
 	this.scene = scene;
 	this.camera = camera;
 	this.camera = camera;
+	this.overrideMaterial = overrideMaterial;
 
 
 	this.clear = true;
 	this.clear = true;
+	this.needsSwap = false;
 
 
 };
 };
 
 
 THREE.RenderPass.prototype = {
 THREE.RenderPass.prototype = {
 
 
-	render: function ( renderer, renderTarget, delta ) {
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
 
 
-		renderer.render( this.scene, this.camera, renderTarget, this.clear );
+		this.scene.overrideMaterial = this.overrideMaterial;
+
+		renderer.render( this.scene, this.camera, readBuffer, this.clear );
+
+		this.scene.overrideMaterial = null;
 
 
 	}
 	}
 
 

+ 7 - 7
examples/js/postprocessing/SepiaPass.js → examples/js/postprocessing/ShaderPass.js

@@ -2,12 +2,11 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.SepiaPass = function( amount ) {
+THREE.ShaderPass = function( shader, textureID ) {
 
 
-	var shader = THREE.ShaderUtils.lib[ "sepia" ];
+	this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";
 
 
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-	this.uniforms[ "amount" ].value = ( amount !== undefined ) ? amount : 1.0;
 
 
 	this.material = new THREE.MeshShaderMaterial( {
 	this.material = new THREE.MeshShaderMaterial( {
 
 
@@ -18,14 +17,15 @@ THREE.SepiaPass = function( amount ) {
 	} );
 	} );
 
 
 	this.renderToScreen = false;
 	this.renderToScreen = false;
+	this.needsSwap = true;
 
 
 };
 };
 
 
-THREE.SepiaPass.prototype = {
+THREE.ShaderPass.prototype = {
 
 
-	render: function ( renderer, renderTarget, delta ) {
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
 
 
-		this.uniforms[ "tDiffuse" ].texture = renderTarget;
+		this.uniforms[ this.textureID ].texture = readBuffer;
 
 
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 
 
@@ -35,7 +35,7 @@ THREE.SepiaPass.prototype = {
 
 
 		} else {
 		} else {
 
 
-			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, renderTarget, false );
+			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, writeBuffer, false );
 
 
 		}
 		}
 
 

+ 9 - 7
examples/js/postprocessing/ScreenPass.js → examples/js/postprocessing/TexturePass.js

@@ -2,12 +2,14 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  */
  */
 
 
-THREE.ScreenPass = function( opacity ) {
+THREE.TexturePass = function( texture, opacity ) {
 
 
-	var shader = THREE.ShaderUtils.lib[ "screen" ];
+	var shader = THREE.ShaderExtras[ "screen" ];
 
 
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
+
 	this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
 	this.uniforms[ "opacity" ].value = ( opacity !== undefined ) ? opacity : 1.0;
+	this.uniforms[ "tDiffuse" ].texture = texture;
 
 
 	this.material = new THREE.MeshShaderMaterial( {
 	this.material = new THREE.MeshShaderMaterial( {
 
 
@@ -17,17 +19,17 @@ THREE.ScreenPass = function( opacity ) {
 
 
 	} );
 	} );
 
 
-};
+	this.needsSwap = false;
 
 
-THREE.ScreenPass.prototype = {
+};
 
 
-	render: function ( renderer, renderTarget, delta ) {
+THREE.TexturePass.prototype = {
 
 
-		this.uniforms[ "tDiffuse" ].texture = renderTarget;
+	render: function ( renderer, writeBuffer, readBuffer, delta ) {
 
 
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
 
 
-		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
+		renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, readBuffer );
 
 
 	}
 	}
 
 

+ 0 - 46
examples/js/postprocessing/VignettePass.js

@@ -1,46 +0,0 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
-
-THREE.VignettePass = function( offset, darkness ) {
-
-	var shader = THREE.ShaderUtils.lib[ "vignette" ];
-
-	this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );
-
-	if ( offset !== undefined )	this.uniforms[ "offset"].value = offset;
-	if ( darkness !== undefined ) this.uniforms[ "darkness"].value = darkness;
-
-	this.material = new THREE.MeshShaderMaterial( {
-
-		uniforms: this.uniforms,
-		vertexShader: shader.vertexShader,
-		fragmentShader: shader.fragmentShader
-
-	} );
-
-	this.renderToScreen = false;
-
-};
-
-THREE.VignettePass.prototype = {
-
-	render: function ( renderer, renderTarget, delta ) {
-
-		this.uniforms[ "tDiffuse" ].texture = renderTarget;
-
-		THREE.EffectComposer.quad.materials[ 0 ] = this.material;
-
-		if ( this.renderToScreen ) {
-
-			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera );
-
-		} else {
-
-			renderer.render( THREE.EffectComposer.scene, THREE.EffectComposer.camera, renderTarget, false );
-
-		}
-
-	}
-
-};

+ 0 - 1
examples/webgl_collada.html

@@ -21,7 +21,6 @@
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
-		<script type="text/javascript" src="../src/extras/loaders/ColladaLoader.js"></script>
 
 
 		<script type="text/javascript">
 		<script type="text/javascript">
 
 

+ 4 - 0
examples/webgl_flycamera_earth.html

@@ -33,7 +33,11 @@
 
 
 	<script type="text/javascript" src="../build/Three.js"></script>
 	<script type="text/javascript" src="../build/Three.js"></script>
 
 
+	<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 	<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 	<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+	<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+	<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
 	<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 	<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 	<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
 	<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
 
 

+ 39 - 109
examples/webgl_geometry_text.html

@@ -41,6 +41,15 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
+		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
+
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -68,6 +77,8 @@
 
 
 			var camera, scene, renderer;
 			var camera, scene, renderer;
 
 
+			var composer;
+
 			var textMesh1, textMesh2, textGeo, faceMaterial, textMaterialFront, textMaterialSide, parent;
 			var textMesh1, textMesh2, textGeo, faceMaterial, textMaterialFront, textMaterialSide, parent;
 
 
 			var firstLetter = true;
 			var firstLetter = true;
@@ -148,11 +159,15 @@
 
 
 				permalink = document.getElementById( "permalink" );
 				permalink = document.getElementById( "permalink" );
 
 
+				// CAMERA
+
 				camera = new THREE.Camera( 30, window.innerWidth / window.innerHeight, 1, 1500 );
 				camera = new THREE.Camera( 30, window.innerWidth / window.innerHeight, 1, 1500 );
 				camera.position.y = 400;
 				camera.position.y = 400;
 				camera.position.z = 700;
 				camera.position.z = 700;
 				camera.target.position.y = 100;
 				camera.target.position.y = 100;
 
 
+				// SCENE
+
 				scene = new THREE.Scene();
 				scene = new THREE.Scene();
 
 
 				scene.fog = new THREE.Fog( 0x000000, 250, 1400 );
 				scene.fog = new THREE.Fog( 0x000000, 250, 1400 );
@@ -222,6 +237,8 @@
 				plane.position.y = 100;
 				plane.position.y = 100;
 				scene.addChild( plane );
 				scene.addChild( plane );
 
 
+				// RENDERER
+
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 
@@ -229,11 +246,15 @@
 
 
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
+				// STATS
+
 				stats = new Stats();
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
 				stats.domElement.style.top = '0px';
 				//container.appendChild( stats.domElement );
 				//container.appendChild( stats.domElement );
 
 
+				// EVENTS
+
 				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
 				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
 				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
 				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
 				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
 				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
@@ -315,9 +336,23 @@
 
 
 				}, false );
 				}, false );
 
 
-				initPostprocessing();
+
+				// POSTPROCESSING
+
 				renderer.autoClear = false;
 				renderer.autoClear = false;
 
 
+				var renderModel = new THREE.RenderPass( scene, camera );
+				var effectBloom = new THREE.BloomPass( 0.25 );
+				var effectFilm = new THREE.FilmPass( 0.5, 0.125, 2048, false );
+
+				effectFilm.renderToScreen = true;
+
+				composer = new THREE.EffectComposer( renderer );
+
+				composer.addPass( renderModel );
+				composer.addPass( effectBloom );
+				composer.addPass( effectFilm );
+
 			}
 			}
 
 
 			//
 			//
@@ -561,76 +596,6 @@
 
 
 			//
 			//
 
 
-			function initPostprocessing() {
-
-				postprocessing.scene = new THREE.Scene();
-
-				postprocessing.camera = new THREE.OrthoCamera( window.innerWidth / - 2, window.innerWidth / 2,  window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
-				postprocessing.camera.position.z = 100;
-
-				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
-				postprocessing.rtTexture1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
-				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
-				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
-
-				var screen_shader = THREE.ShaderUtils.lib["screen"];
-				var screen_uniforms = THREE.UniformsUtils.clone( screen_shader.uniforms );
-
-				screen_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
-				screen_uniforms["opacity"].value = 1.0;
-
-				postprocessing.materialScreen = new THREE.MeshShaderMaterial( {
-
-					uniforms: screen_uniforms,
-					vertexShader: screen_shader.vertexShader,
-					fragmentShader: screen_shader.fragmentShader,
-					blending: THREE.AdditiveBlending,
-					transparent: true
-
-				} );
-
-				var convolution_shader = THREE.ShaderUtils.lib["convolution"];
-				var convolution_uniforms = THREE.UniformsUtils.clone( convolution_shader.uniforms );
-
-				postprocessing.blurx = new THREE.Vector2( 0.001953125, 0.0 ),
-				postprocessing.blury = new THREE.Vector2( 0.0, 0.001953125 );
-
-				convolution_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
-				convolution_uniforms["uImageIncrement"].value = postprocessing.blurx;
-				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
-
-				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
-
-					uniforms: convolution_uniforms,
-					vertexShader:   "#define KERNEL_SIZE 25.0\n" + convolution_shader.vertexShader,
-					fragmentShader: "#define KERNEL_SIZE 25\n"   + convolution_shader.fragmentShader
-
-				} );
-
-				var film_shader = THREE.ShaderUtils.lib["film"];
-				var film_uniforms = THREE.UniformsUtils.clone( film_shader.uniforms );
-
-				film_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
-
-				postprocessing.materialFilm = new THREE.MeshShaderMaterial( { uniforms: film_uniforms, vertexShader: film_shader.vertexShader, fragmentShader: film_shader.fragmentShader } );
-				postprocessing.materialFilm.uniforms.grayscale.value = 0;
-				postprocessing.materialFilm.uniforms.nIntensity.value = 0.15;
-				postprocessing.materialFilm.uniforms.sIntensity.value = 0.25;
-				postprocessing.materialFilm.uniforms.sCount.value = 2048;
-
-				//postprocessing.materialFilm.uniforms.nIntensity.value = 0;
-				//postprocessing.materialFilm.uniforms.sIntensity.value = 0;
-
-				postprocessing.materialScreen.uniforms.opacity.value = glow;
-
-				postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
-				postprocessing.quad.position.z = - 500;
-				postprocessing.scene.addObject( postprocessing.quad );
-
-			}
-
-			//
-
 			function animate() {
 			function animate() {
 
 
 				requestAnimationFrame( animate );
 				requestAnimationFrame( animate );
@@ -652,49 +617,14 @@
 
 
 				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
 				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
 
 
-				if ( postprocessing.enabled ) {
-
-					renderer.clear();
-
-					// Render scene into texture
+				renderer.clear();
 
 
-					renderer.render( scene, camera, postprocessing.rtTexture1, true );
-
-					// Render quad with blured scene into texture (convolution pass 1)
-
-					postprocessing.quad.materials[ 0 ] = postprocessing.materialConvolution;
-
-					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
-					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
-
-					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, true );
-
-					// Render original scene with superimposed blur to texture
-
-					postprocessing.quad.materials[ 0 ] = postprocessing.materialScreen;
-
-					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
-
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
-
-					// Render to screen
-
-					postprocessing.materialFilm.uniforms.time.value += 0.01;
-					postprocessing.quad.materials[ 0 ] = postprocessing.materialFilm;
+				if ( postprocessing.enabled ) {
 
 
-					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
-					renderer.render( postprocessing.scene, postprocessing.camera );
+					composer.render( 0.05 );
 
 
 				} else {
 				} else {
 
 
-					renderer.clear();
 					renderer.render( scene, camera );
 					renderer.render( scene, camera );
 
 
 				}
 				}

+ 223 - 0
examples/webgl_interactive_draggablecubes.html

@@ -0,0 +1,223 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js webgl - draggable cubes</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				font-family: Monospace;
+				background-color: #f0f0f0;
+				margin: 0px;
+				overflow: hidden;
+			}
+		</style>
+	</head>
+	<body>
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			var container, stats;
+			var camera, scene, projector, renderer;
+			var objects = [], plane;
+
+			var mouse = new THREE.Vector2(),
+			offset = new THREE.Vector3(),
+			INTERSECTED, SELECTED;
+
+			init();
+			animate();
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				var info = document.createElement( 'div' );
+				info.style.position = 'absolute';
+				info.style.top = '10px';
+				info.style.width = '100%';
+				info.style.textAlign = 'center';
+				info.innerHTML = '<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> webgl - draggable cubes';
+				container.appendChild( info );
+
+				camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 5000 );
+				camera.position.z = 1000;
+
+				scene = new THREE.Scene();
+
+				var light = new THREE.SpotLight( 0xffffff, 2 );
+				light.position.set( 0, 500, 2000 );
+				light.castShadow = true;
+				scene.addLight( light );
+
+				var geometry = new THREE.CubeGeometry( 40, 40, 40 );
+
+				for ( var i = 0; i < 200; i ++ ) {
+
+					var object = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: Math.random() * 0xffffff } ) );
+					object.position.x = Math.random() * 1000 - 500;
+					object.position.y = Math.random() * 600 - 300;
+					object.position.z = Math.random() * 800 - 400;
+					object.rotation.x = ( Math.random() * 360 ) * Math.PI / 180;
+					object.rotation.y = ( Math.random() * 360 ) * Math.PI / 180;
+					object.rotation.z = ( Math.random() * 360 ) * Math.PI / 180;
+					object.scale.x = Math.random() * 2 + 1;
+					object.scale.y = Math.random() * 2 + 1;
+					object.scale.z = Math.random() * 2 + 1;
+					object.castShadow = true;
+					object.receiveShadow = true;
+					scene.addObject( object );
+
+					objects.push( object );
+
+				}
+
+				plane = new THREE.Mesh( new THREE.PlaneGeometry( 2000, 2000, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.5, wireframe: true } ) );
+				plane.visible = false;
+				scene.addObject( plane );
+
+				projector = new THREE.Projector();
+
+				renderer = new THREE.WebGLRenderer( { antialias: true } );
+				renderer.sortObjects = false;
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				renderer.shadowCameraNear = 3;
+				renderer.shadowCameraFar = camera.far;
+				renderer.shadowCameraFov = 30;
+
+				renderer.shadowMapBias = 0.00389;
+				renderer.shadowMapDarkness = 0.5;
+				renderer.shadowMapWidth = 1024;
+				renderer.shadowMapHeight = 1024;
+
+				renderer.shadowMapEnabled = true;
+				renderer.shadowMapSoft = true;
+
+				container.appendChild(renderer.domElement);
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				container.appendChild( stats.domElement );
+
+				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
+				document.addEventListener( 'mouseup', onDocumentMouseUp, false );
+
+			}
+
+			function onDocumentMouseMove( event ) {
+
+				event.preventDefault();
+
+				mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
+				mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
+
+				//
+
+				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
+				projector.unprojectVector( vector, camera );
+
+				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+
+
+				if ( SELECTED ) {
+
+					var intersects = ray.intersectObject( plane );
+					SELECTED.position.copy( intersects[ 0 ].point.subSelf( offset ) );
+					return;
+
+				}
+
+
+				var intersects = ray.intersectObjects( objects );
+
+				if ( intersects.length > 0 ) {
+
+					if ( INTERSECTED != intersects[ 0 ].object ) {
+
+						if ( INTERSECTED ) INTERSECTED.materials[ 0 ].color.setHex( INTERSECTED.currentHex );
+
+						INTERSECTED = intersects[ 0 ].object;
+						INTERSECTED.currentHex = INTERSECTED.materials[ 0 ].color.getHex();
+
+						plane.position.copy( INTERSECTED.position );
+
+					}
+
+					container.style.cursor = 'pointer';
+
+				} else {
+
+					if ( INTERSECTED ) INTERSECTED.materials[ 0 ].color.setHex( INTERSECTED.currentHex );
+
+					INTERSECTED = null;
+
+					container.style.cursor = 'auto';
+
+				}
+
+			}
+
+			function onDocumentMouseDown( event ) {
+
+				event.preventDefault();
+
+				var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
+				projector.unprojectVector( vector, camera );
+
+				var ray = new THREE.Ray( camera.position, vector.subSelf( camera.position ).normalize() );
+
+				var intersects = ray.intersectObjects( objects );
+
+				if ( intersects.length > 0 ) {
+
+					SELECTED = intersects[ 0 ].object;
+
+					var intersects = ray.intersectObject( plane );
+					offset.copy( intersects[ 0 ].point ).subSelf( plane.position );
+
+					container.style.cursor = 'move';
+
+				}
+			}
+
+			function onDocumentMouseUp( event ) {
+
+				event.preventDefault();
+
+				plane.position.copy( INTERSECTED.position );
+
+				SELECTED = null;
+
+				container.style.cursor = 'auto';
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 7 - 2
examples/webgl_lines_colors.html

@@ -45,9 +45,12 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
-		<script type="text/javascript" src="js/postprocessing/ScreenPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 
 
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
@@ -153,7 +156,9 @@
 
 
 				var renderModel = new THREE.RenderPass( scene, camera );
 				var renderModel = new THREE.RenderPass( scene, camera );
 				var effectBloom = new THREE.BloomPass( 1.3 );
 				var effectBloom = new THREE.BloomPass( 1.3 );
-				var effectScreen = new THREE.ScreenPass();
+				var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
+
+				effectScreen.renderToScreen = true;
 
 
 				composer = new THREE.EffectComposer( renderer );
 				composer = new THREE.EffectComposer( renderer );
 
 

+ 13 - 110
examples/webgl_lines_splines.html

@@ -53,8 +53,6 @@
 
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
 
-			var postprocessing = false;
-			
 			var mouseX = 0, mouseY = 0,
 			var mouseX = 0, mouseY = 0,
 
 
 			windowHalfX = window.innerWidth / 2,
 			windowHalfX = window.innerWidth / 2,
@@ -62,8 +60,6 @@
 
 
 			camera, scene, renderer, material;
 			camera, scene, renderer, material;
 
 
-			var cameraOrtho, sceneScreen, rtTexture1, rtTexture2, rtTexture3, materialScreen, materialConvolution, blurx, blury, quadScreen;
-
 			init();
 			init();
 			animate();
 			animate();
 
 
@@ -81,7 +77,7 @@
 
 
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
 				renderer = new THREE.WebGLRenderer( { antialias: true } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
-				renderer.autoClear = false;
+
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 
 
 				var geometry = new THREE.Geometry(),
 				var geometry = new THREE.Geometry(),
@@ -93,14 +89,14 @@
 				n_sub = 6;
 				n_sub = 6;
 
 
 				var position, index;
 				var position, index;
-				
+
 				var spline = new THREE.Spline( points );
 				var spline = new THREE.Spline( points );
-				
+
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
 				for ( i = 0; i < points.length * n_sub; i ++ ) {
-				
+
 					index = i / ( points.length * n_sub );
 					index = i / ( points.length * n_sub );
 					position = spline.getPoint( index );
 					position = spline.getPoint( index );
-					
+
 					geometry.vertices[ i ] = new THREE.Vertex( new THREE.Vector3( position.x, position.y, position.z ) );
 					geometry.vertices[ i ] = new THREE.Vertex( new THREE.Vector3( position.x, position.y, position.z ) );
 
 
 					colors[ i ] = new THREE.Color( 0xffffff );
 					colors[ i ] = new THREE.Color( 0xffffff );
@@ -112,8 +108,8 @@
 
 
 					colors3[ i ] = new THREE.Color( 0xffffff );
 					colors3[ i ] = new THREE.Color( 0xffffff );
 					colors3[ i ].setHSV( i / ( points.length * n_sub ), 1.0, 1.0 );
 					colors3[ i ].setHSV( i / ( points.length * n_sub ), 1.0, 1.0 );
-					
-					
+
+
 				}
 				}
 
 
 				geometry2.vertices = geometry3.vertices = geometry.vertices;
 				geometry2.vertices = geometry3.vertices = geometry.vertices;
@@ -133,7 +129,7 @@
 
 
 				material.vertexColors = true;
 				material.vertexColors = true;
 
 
-				for ( i = 0; i < parameters.length; ++i ) {
+				for ( i = 0; i < parameters.length; ++ i ) {
 
 
 					p = parameters[ i ];
 					p = parameters[ i ];
 					line = new THREE.Line( p[ 3 ],  p[ 0 ] );
 					line = new THREE.Line( p[ 3 ],  p[ 0 ] );
@@ -145,57 +141,6 @@
 
 
 				}
 				}
 
 
-				// postprocessing
-
-				cameraOrtho = new THREE.Camera();
-				cameraOrtho.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2, window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
-				cameraOrtho.position.z = 100;
-
-				sceneScreen = new THREE.Scene();
-
-				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter };
-				rtTexture1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
-				rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
-				rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
-
-				var screen_shader = THREE.ShaderUtils.lib["screen"];
-				var screen_uniforms = THREE.UniformsUtils.clone( screen_shader.uniforms );
-
-				screen_uniforms["tDiffuse"].texture = rtTexture1;
-				screen_uniforms["opacity"].value = 1.0;
-
-				materialScreen = new THREE.MeshShaderMaterial( {
-
-					uniforms: screen_uniforms,
-					vertexShader: screen_shader.vertexShader,
-					fragmentShader: screen_shader.fragmentShader,
-					blending: THREE.AdditiveBlending
-
-				} );
-
-				var convolution_shader = THREE.ShaderUtils.lib["convolution"];
-				var convolution_uniforms = THREE.UniformsUtils.clone( convolution_shader.uniforms );
-
-				blurx = new THREE.Vector2( 0.001953125, 0.0 ),
-				blury = new THREE.Vector2( 0.0, 0.001953125 );
-
-				convolution_uniforms["tDiffuse"].texture = rtTexture1;
-				convolution_uniforms["uImageIncrement"].value = blurx;
-				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
-
-				materialConvolution = new THREE.MeshShaderMaterial( {
-
-					uniforms: convolution_uniforms,
-					vertexShader:   "#define KERNEL_SIZE 25.0\n" + convolution_shader.vertexShader,
-					fragmentShader: "#define KERNEL_SIZE 25\n"   + convolution_shader.fragmentShader
-
-				} );
-
-				var plane = new THREE.PlaneGeometry( window.innerWidth, window.innerHeight );
-
-				quadScreen = new THREE.Mesh( plane, materialConvolution );
-				quadScreen.position.z = -100;
-				sceneScreen.addObject( quadScreen );
 
 
 				stats = new Stats();
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.position = 'absolute';
@@ -249,6 +194,7 @@
 				}
 				}
 
 
 				return vec;
 				return vec;
+
 			}
 			}
 
 
 			//
 			//
@@ -279,6 +225,7 @@
 					mouseX = event.touches[ 0 ].pageX - windowHalfX;
 					mouseX = event.touches[ 0 ].pageX - windowHalfX;
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 					mouseY = event.touches[ 0 ].pageY - windowHalfY;
 				}
 				}
+
 			}
 			}
 
 
 			//
 			//
@@ -294,60 +241,16 @@
 
 
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05;
 				camera.position.y += ( - mouseY + 200 - camera.position.y ) * .05;
-				camera.updateMatrix();
 
 
 				var time = new Date().getTime() * 0.0005;
 				var time = new Date().getTime() * 0.0005;
 
 
-				for( var i = 0; i<scene.objects.length; i++ ) {
-
-					scene.objects[i].rotation.y = time * ( i % 2 ? 1 : -1);
-
-				}
-
-				renderer.clear();
-
-				if ( postprocessing ) {
-				
-					// Render scene into texture
-
-					renderer.render( scene, camera, rtTexture1 );
-
-					// 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 );
-
-					// 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 );
-
-					// Render original scene with superimposed blur to texture
-
-					quadScreen.materials = [ materialScreen ];
-
-					materialScreen.uniforms.tDiffuse.texture = rtTexture3;
-					materialScreen.uniforms.opacity.value = 1.3;
-
-					renderer.render( sceneScreen, cameraOrtho, rtTexture1, false );
-
-					// Render to screen
-
-					materialScreen.uniforms.tDiffuse.texture = rtTexture1;
-					renderer.render( sceneScreen, cameraOrtho );
+				for( var i = 0; i < scene.objects.length; i ++ ) {
 
 
-				} else {
-				
-					renderer.render( scene, camera );
+					scene.objects[ i ].rotation.y = time * ( i % 2 ? 1 : -1);
 
 
 				}
 				}
 
 
+				renderer.render( scene, camera );
 
 
 			}
 			}
 
 

+ 1 - 1
examples/webgl_materials.html

@@ -75,7 +75,7 @@
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.FlatShading } ) );
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.FlatShading } ) );
 				materials.push( new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.FlatShading } ) );
 				materials.push( new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0xdddddd, specular: 0x009900, shininess: 30, shading: THREE.FlatShading } ) );
 				materials.push( new THREE.MeshNormalMaterial( ) );
 				materials.push( new THREE.MeshNormalMaterial( ) );
-				materials.push( new THREE.MeshBasicMaterial( { color: 0x665500, blending: THREE.AdditiveBlending } ) );
+				materials.push( new THREE.MeshBasicMaterial( { color: 0xffaa00, transparent: true, blending: THREE.AdditiveBlending } ) );
 				//materials.push( new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ) );
 				//materials.push( new THREE.MeshBasicMaterial( { color: 0xff0000, blending: THREE.SubtractiveBlending } ) );
 
 
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ) );
 				materials.push( new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.SmoothShading } ) );

+ 33 - 50
examples/webgl_materials_shaders.html

@@ -16,7 +16,6 @@
 			h1 { }
 			h1 { }
 			a { color:skyblue }
 			a { color:skyblue }
 			canvas { pointer-events:none; z-index:10; }
 			canvas { pointer-events:none; z-index:10; }
-			#log { position:absolute; top:50px; text-align:left; display:block; z-index:100 }
 			#d { text-align:center; margin:1em 0 -19.7em 0; z-index:0; position:relative; display:block }
 			#d { text-align:center; margin:1em 0 -19.7em 0; z-index:0; position:relative; display:block }
 			.button { background:orange; color:#fff; padding:0.2em 0.5em; cursor:pointer }
 			.button { background:orange; color:#fff; padding:0.2em 0.5em; cursor:pointer }
 			.inactive { background:#999; color:#eee }
 			.inactive { background:#999; color:#eee }
@@ -39,8 +38,6 @@
 			<p>Blinn-Phong shader only works in WebGL, canvas has only diffuse materials.
 			<p>Blinn-Phong shader only works in WebGL, canvas has only diffuse materials.
 		</div>
 		</div>
 
 
-		<pre id="log"></pre>
-
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
@@ -69,8 +66,8 @@
 			var render_canvas = 1, render_gl = 1;
 			var render_canvas = 1, render_gl = 1;
 			var has_gl = 0;
 			var has_gl = 0;
 
 
-			var bcanvas = document.getElementById("rcanvas");
-			var bwebgl = document.getElementById("rwebgl");
+			var bcanvas = document.getElementById( "rcanvas" );
+			var bwebgl = document.getElementById( "rwebgl" );
 
 
 			init();
 			init();
 			animate();
 			animate();
@@ -82,16 +79,14 @@
 			function addMesh( geometry, scale, x, y, z, rx, ry, rz, material ) {
 			function addMesh( geometry, scale, x, y, z, rx, ry, rz, material ) {
 
 
 				mesh = new THREE.Mesh( geometry, material );
 				mesh = new THREE.Mesh( geometry, material );
-				mesh.scale.x = mesh.scale.y = mesh.scale.z = scale;
-				mesh.position.x = x;
-				mesh.position.y = y;
-				mesh.position.z = z;
-				mesh.rotation.x = rx;
-				mesh.rotation.y = ry;
-				mesh.rotation.z = rz;
+
+				mesh.scale.set( scale, scale, scale );
+				mesh.position.set( x, y, z );
+				mesh.rotation.set( rx, ry, rz );
+
 				mesh.overdraw = true;
 				mesh.overdraw = true;
-				mesh.updateMatrix();
-				scene.addObject(mesh);
+
+				scene.addObject( mesh );
 
 
 			}
 			}
 
 
@@ -112,28 +107,24 @@
 				scene.addLight( ambient );
 				scene.addLight( ambient );
 
 
 				directionalLight = new THREE.DirectionalLight( 0xffffff );
 				directionalLight = new THREE.DirectionalLight( 0xffffff );
-				directionalLight.position.x = 1;
-				directionalLight.position.y = 1;
-				directionalLight.position.z = 2;
+				directionalLight.position.set( 1, 1, 2 );
 				directionalLight.position.normalize();
 				directionalLight.position.normalize();
 				scene.addLight( directionalLight );
 				scene.addLight( directionalLight );
 
 
 				pointLight = new THREE.PointLight( 0xffffff );
 				pointLight = new THREE.PointLight( 0xffffff );
-				pointLight.position.x = 0;
-				pointLight.position.y = 0;
-				pointLight.position.z = 0;
 				scene.addLight( pointLight );
 				scene.addLight( pointLight );
 
 
 				// light representation
 				// light representation
+
 				sphere = new THREE.SphereGeometry( 100, 16, 8 );
 				sphere = new THREE.SphereGeometry( 100, 16, 8 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
-				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
+				lightMesh.scale.set( 0.05, 0.05, 0.05 );
 				lightMesh.position = pointLight.position;
 				lightMesh.position = pointLight.position;
 				lightMesh.overdraw = true;
 				lightMesh.overdraw = true;
-				lightMesh.updateMatrix();
 				scene.addObject( lightMesh );
 				scene.addObject( lightMesh );
 
 
 				// material samples
 				// material samples
+
 				sphere = new THREE.SphereGeometry( 100, 32, 32 );
 				sphere = new THREE.SphereGeometry( 100, 32, 32 );
 
 
 				var y1 = 0, y2 = - 200;
 				var y1 = 0, y2 = - 200;
@@ -159,16 +150,22 @@
 				addMesh( sphere, 1,  600, y1, 0, 0,0,0, new THREE.MeshPhongMaterial( { ambient: 0x000000, color: 0x5500ff, specular: 0x555555, shininess: 30 } ) );
 				addMesh( sphere, 1,  600, y1, 0, 0,0,0, new THREE.MeshPhongMaterial( { ambient: 0x000000, color: 0x5500ff, specular: 0x555555, shininess: 30 } ) );
 				addMesh( sphere, 1,  600, y2, 0, 0,0,0, new THREE.MeshLambertMaterial( { color: 0x5500ff } ) );
 				addMesh( sphere, 1,  600, y2, 0, 0,0,0, new THREE.MeshLambertMaterial( { color: 0x5500ff } ) );
 
 
+				addToruses( new THREE.TorusGeometry( 100, 20, 32, 32 ) );
+
+				//
+
 				if ( render_gl ) {
 				if ( render_gl ) {
 
 
 					try {
 					try {
+
 						webglRenderer = new THREE.WebGLRenderer();
 						webglRenderer = new THREE.WebGLRenderer();
 						webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 						webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 						webglRenderer.domElement.style.position = "relative";
 						webglRenderer.domElement.style.position = "relative";
 						container.appendChild( webglRenderer.domElement );
 						container.appendChild( webglRenderer.domElement );
 						has_gl = 1;
 						has_gl = 1;
-					}
-					catch (e) {
+
+					} catch (e) {
+
 					}
 					}
 
 
 				}
 				}
@@ -181,6 +178,7 @@
 
 
 				}
 				}
 
 
+				//
 
 
 				stats = new Stats();
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.position = 'absolute';
@@ -191,27 +189,21 @@
 				bcanvas.addEventListener("click", toggleCanvas, false);
 				bcanvas.addEventListener("click", toggleCanvas, false);
 				bwebgl.addEventListener("click", toggleWebGL, false);
 				bwebgl.addEventListener("click", toggleWebGL, false);
 
 
-				var loader = new THREE.JSONLoader();
-				loader.load( { model: "obj/torus/Torus_slim.js", callback: function( geometry ) { createScene( geometry ) } } );
-				
-				//var loader = new THREE.BinaryLoader();
-				//loader.load( { model: "obj/torus/Torus_bin.js", callback: function( geometry ) { createScene( geometry ) } } );
-
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 				document.addEventListener('mousemove', onDocumentMouseMove, false);
 
 
 			}
 			}
 
 
-			function createScene( geometry ) {
+			function addToruses( geometry ) {
 
 
-				var s = 80, t = s + 20, y = 200;
+				var s = 0.85, t = s + 100, y = 200, rx = 0;
 
 
-				addMesh( geometry, s, -6*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x000000, color: 0x000000, specular: 0x333333, shininess: 10 } ) );
-				addMesh( geometry, s, -4*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x888888, specular: 0x333333, shininess: 10 } ) );
-				addMesh( geometry, s, -2*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0xff5500, shininess: 10 } ) );
-				addMesh( geometry, s,    0, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0xffaa00, shininess: 10 } ) );
-				addMesh( geometry, s,  2*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x55ff00, shininess: 10 } ) );
-				addMesh( geometry, s,  4*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x0055ff, shininess: 10 } ) );
-				addMesh( geometry, s,  6*t, y, 0, 1.57,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x5500ff, shininess: 10 } ) );
+				addMesh( geometry, s, -6*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x000000, color: 0x000000, specular: 0x333333, shininess: 10 } ) );
+				addMesh( geometry, s, -4*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x888888, specular: 0x333333, shininess: 10 } ) );
+				addMesh( geometry, s, -2*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0xff5500, shininess: 10 } ) );
+				addMesh( geometry, s,    0, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0xffaa00, shininess: 10 } ) );
+				addMesh( geometry, s,  2*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x55ff00, shininess: 10 } ) );
+				addMesh( geometry, s,  4*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x0055ff, shininess: 10 } ) );
+				addMesh( geometry, s,  6*t, y, 0, rx,0,0, new THREE.MeshPhongMaterial( { ambient: 0x030303, color: 0x030303, specular: 0x5500ff, shininess: 10 } ) );
 
 
 			}
 			}
 
 
@@ -240,24 +232,15 @@
 
 
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.x += ( mouseX - camera.position.x ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
 				camera.position.y += ( - mouseY - camera.position.y ) * .05;
-				camera.updateMatrix();
 
 
-				lightMesh.position.x = 700*Math.cos( timer );
-				lightMesh.position.z = 700*Math.sin( timer );
-				lightMesh.updateMatrix();
+				lightMesh.position.x = 700 * Math.cos( timer );
+				lightMesh.position.z = 700 * Math.sin( timer );
 
 
 				if ( render_canvas ) canvasRenderer.render( scene, camera );
 				if ( render_canvas ) canvasRenderer.render( scene, camera );
 				if ( render_gl && has_gl ) webglRenderer.render( scene, camera );
 				if ( render_gl && has_gl ) webglRenderer.render( scene, camera );
 
 
 			}
 			}
 
 
-			function log(text) {
-
-				var e = document.getElementById("log");
-				e.innerHTML = text + "<br/>" + e.innerHTML;
-
-			}
-
 			function toggleCanvas() {
 			function toggleCanvas() {
 
 
 				render_canvas = !render_canvas;
 				render_canvas = !render_canvas;

+ 17 - 28
examples/webgl_materials_texture_filters.html

@@ -109,6 +109,7 @@
 
 
 				context.fillStyle = "#444";
 				context.fillStyle = "#444";
 				context.fillRect( 0, 0, 128, 128 );
 				context.fillRect( 0, 0, 128, 128 );
+
 				context.fillStyle = "#fff";
 				context.fillStyle = "#fff";
 				context.fillRect( 0, 0, 64, 64);
 				context.fillRect( 0, 0, 64, 64);
 				context.fillRect( 64, 64, 64, 64 );
 				context.fillRect( 64, 64, 64, 64 );
@@ -117,36 +118,25 @@
 					materialCanvas = new THREE.MeshBasicMaterial( { map: textureCanvas } );
 					materialCanvas = new THREE.MeshBasicMaterial( { map: textureCanvas } );
 
 
 				textureCanvas.needsUpdate = true;
 				textureCanvas.needsUpdate = true;
+				textureCanvas.repeat.set( 1000, 1000 );
 
 
 				var textureCanvas2 = new THREE.Texture( imageCanvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping, THREE.NearestFilter, THREE.NearestFilter );
 				var textureCanvas2 = new THREE.Texture( imageCanvas, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping, THREE.NearestFilter, THREE.NearestFilter );
-					materialCanvas2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: textureCanvas2 } );
+					materialCanvas2 = new THREE.MeshBasicMaterial( { color: 0xffccaa, map: textureCanvas2 } );
 
 
 				textureCanvas2.needsUpdate = true;
 				textureCanvas2.needsUpdate = true;
+				textureCanvas2.repeat.set( 1000, 1000 );
 
 
-				var i, j, uvs, geometryRepeat = new THREE.PlaneGeometry( 100, 100, 1, 1 );
-
-				for ( i = 0; i < geometryRepeat.faceVertexUvs[ 0 ].length; i ++ ) {
-
-					uvs = geometryRepeat.faceVertexUvs[ 0 ][ i ];
-
-					for ( j = 0; j < uvs.length; j ++ ) {
-
-						uvs[ j ].u *= 1000;
-						uvs[ j ].v *= 1000;
-
-					}
-
-				}
+				var geometry = new THREE.PlaneGeometry( 100, 100 );
 
 
 
 
-				var meshCanvas = new THREE.Mesh( geometryRepeat, materialCanvas );
+				var meshCanvas = new THREE.Mesh( geometry, materialCanvas );
 				meshCanvas.rotation.x = Math.PI / 2;
 				meshCanvas.rotation.x = Math.PI / 2;
-				meshCanvas.scale.x = meshCanvas.scale.y = meshCanvas.scale.z = 1000;
+				meshCanvas.scale.set( 1000, 1000, 1000 );
 				meshCanvas.doubleSided = true;
 				meshCanvas.doubleSided = true;
 
 
-				var meshCanvas2 = new THREE.Mesh( geometryRepeat, materialCanvas2 );
+				var meshCanvas2 = new THREE.Mesh( geometry, materialCanvas2 );
 				meshCanvas2.rotation.x = Math.PI / 2;
 				meshCanvas2.rotation.x = Math.PI / 2;
-				meshCanvas2.scale.x = meshCanvas2.scale.y = meshCanvas2.scale.z = 1000;
+				meshCanvas2.scale.set( 1000, 1000, 1000 );
 				meshCanvas2.doubleSided = true;
 				meshCanvas2.doubleSided = true;
 
 
 
 
@@ -160,7 +150,7 @@
 					scene.addObject( meshCanvas );
 					scene.addObject( meshCanvas );
 					scene2.addObject( meshCanvas2 );
 					scene2.addObject( meshCanvas2 );
 
 
-					var geometry = new THREE.PlaneGeometry( 100, 100, 1, 1 ),
+					var geometry = new THREE.PlaneGeometry( 100, 100 ),
 						mesh = new THREE.Mesh( geometry, materialPainting ),
 						mesh = new THREE.Mesh( geometry, materialPainting ),
 						mesh2 = new THREE.Mesh( geometry, materialPainting2 );
 						mesh2 = new THREE.Mesh( geometry, materialPainting2 );
 
 
@@ -174,15 +164,14 @@
 
 
 						zscene.addObject( zmesh );
 						zscene.addObject( zmesh );
 
 
-						var meshFrame = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000 } )  );
+						var meshFrame = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, polygonOffset: true, polygonOffsetFactor: 1, polygonOffsetUnits: 5 } )  );
 
 
-						meshFrame.position.z = -0.5;
 						meshFrame.scale.x = 1.1 * image.width / 100;
 						meshFrame.scale.x = 1.1 * image.width / 100;
 						meshFrame.scale.y = 1.1 * image.height / 100;
 						meshFrame.scale.y = 1.1 * image.height / 100;
 
 
 						zscene.addObject( meshFrame );
 						zscene.addObject( meshFrame );
 
 
-						var meshShadow = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.9 } )  );
+						var meshShadow = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { color: 0x000000, opacity: 0.9, transparent: true } )  );
 
 
 						meshShadow.position.z = - 1.1 * image.height/2;
 						meshShadow.position.z = - 1.1 * image.height/2;
 						meshShadow.scale.x = 1.1 * image.width / 100;
 						meshShadow.scale.x = 1.1 * image.width / 100;
@@ -202,8 +191,8 @@
 
 
 				var texturePainting = THREE.ImageUtils.loadTexture( "textures/758px-Canestra_di_frutta_(Caravaggio).jpg", THREE.UVMapping, callbackPainting ),
 				var texturePainting = THREE.ImageUtils.loadTexture( "textures/758px-Canestra_di_frutta_(Caravaggio).jpg", THREE.UVMapping, callbackPainting ),
 					texturePainting2 = new THREE.Texture(),
 					texturePainting2 = new THREE.Texture(),
-					materialPainting = new THREE.MeshBasicMaterial( { color:0xffffff, map: texturePainting } ),
-					materialPainting2 = new THREE.MeshBasicMaterial( { color:0xffccaa, map: texturePainting2 } );
+					materialPainting = new THREE.MeshBasicMaterial( { color: 0xffffff, map: texturePainting } ),
+					materialPainting2 = new THREE.MeshBasicMaterial( { color: 0xffccaa, map: texturePainting2 } );
 
 
 				texturePainting2.minFilter = texturePainting2.magFilter = THREE.NearestFilter;
 				texturePainting2.minFilter = texturePainting2.magFilter = THREE.NearestFilter;
 				texturePainting.minFilter = texturePainting.magFilter = THREE.LinearFilter;
 				texturePainting.minFilter = texturePainting.magFilter = THREE.LinearFilter;
@@ -211,12 +200,12 @@
 
 
 				renderer = new THREE.WebGLRenderer();
 				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
-				renderer.domElement.style.position = "relative";
-				container.appendChild( renderer.domElement );
-
 				renderer.setClearColor( scene.fog.color, 1 );
 				renderer.setClearColor( scene.fog.color, 1 );
 				renderer.autoClear = false;
 				renderer.autoClear = false;
 
 
+				renderer.domElement.style.position = "relative";
+				container.appendChild( renderer.domElement );
+
 				stats = new Stats();
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
 				stats.domElement.style.top = '0px';

+ 26 - 97
examples/webgl_materials_video.html

@@ -38,6 +38,14 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
+		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -57,14 +65,14 @@
 
 
 			var video, texture, material, mesh;
 			var video, texture, material, mesh;
 
 
+			var composer;
+
 			var mouseX = 0;
 			var mouseX = 0;
 			var mouseY = 0;
 			var mouseY = 0;
 
 
 			var windowHalfX = window.innerWidth / 2;
 			var windowHalfX = window.innerWidth / 2;
 			var windowHalfY = window.innerHeight / 2;
 			var windowHalfY = window.innerHeight / 2;
 
 
-			var postprocessing = { enabled: true };
-
 			var cube_count,
 			var cube_count,
 
 
 				meshes = [],
 				meshes = [],
@@ -163,7 +171,6 @@
 
 
 				}
 				}
 
 
-				initPostprocessing();
 				renderer.autoClear = false;
 				renderer.autoClear = false;
 
 
 				stats = new Stats();
 				stats = new Stats();
@@ -173,6 +180,20 @@
 
 
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 
 
+				// postprocessing
+
+				var renderModel = new THREE.RenderPass( scene, camera );
+				var effectBloom = new THREE.BloomPass( 1.3 );
+				var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
+
+				effectScreen.renderToScreen = true;
+
+				composer = new THREE.EffectComposer( renderer );
+
+				composer.addPass( renderModel );
+				composer.addPass( effectBloom );
+				composer.addPass( effectScreen );
+
 			}
 			}
 
 
 			function change_uvs( geometry, unitx, unity, offsetx, offsety ) {
 			function change_uvs( geometry, unitx, unity, offsetx, offsety ) {
@@ -195,58 +216,6 @@
 			}
 			}
 
 
 
 
-			function initPostprocessing() {
-
-				postprocessing.scene = new THREE.Scene();
-
-				postprocessing.camera = new THREE.OrthoCamera( window.innerWidth / - 2, window.innerWidth / 2,  window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
-				postprocessing.camera.position.z = 100;
-
-				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
-				postprocessing.rtTexture1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
-				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
-				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
-
-				var screen_shader = THREE.ShaderUtils.lib["screen"];
-				var screen_uniforms = THREE.UniformsUtils.clone( screen_shader.uniforms );
-
-				screen_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
-				screen_uniforms["opacity"].value = 1.0;
-
-				postprocessing.materialScreen = new THREE.MeshShaderMaterial( {
-
-					uniforms: screen_uniforms,
-					vertexShader: screen_shader.vertexShader,
-					fragmentShader: screen_shader.fragmentShader,
-					blending: THREE.AdditiveBlending,
-					transparent: true
-
-				} );
-
-				var convolution_shader = THREE.ShaderUtils.lib["convolution"];
-				var convolution_uniforms = THREE.UniformsUtils.clone( convolution_shader.uniforms );
-
-				postprocessing.blurx = new THREE.Vector2( 0.001953125, 0.0 ),
-				postprocessing.blury = new THREE.Vector2( 0.0, 0.001953125 );
-
-				convolution_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
-				convolution_uniforms["uImageIncrement"].value = postprocessing.blurx;
-				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
-
-				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
-
-					uniforms: convolution_uniforms,
-					vertexShader:   "#define KERNEL_SIZE 25.0\n" + convolution_shader.vertexShader,
-					fragmentShader: "#define KERNEL_SIZE 25\n"   + convolution_shader.fragmentShader
-
-				} );
-
-				postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
-				postprocessing.quad.position.z = -500;
-				postprocessing.scene.addObject( postprocessing.quad );
-
-			}
-
 			function onDocumentMouseMove(event) {
 			function onDocumentMouseMove(event) {
 
 
 				mouseX = ( event.clientX - windowHalfX );
 				mouseX = ( event.clientX - windowHalfX );
@@ -319,51 +288,11 @@
 
 
 				}
 				}
 
 
-				counter++;
+				counter ++;
 
 
 				renderer.clear();
 				renderer.clear();
+				composer.render();
 
 
-				if ( postprocessing.enabled ) {
-
-					// Render scene into texture
-
-					renderer.render( scene, camera, postprocessing.rtTexture1, true );
-
-					// Render quad with blured scene into texture (convolution pass 1)
-
-					postprocessing.quad.materials = [ postprocessing.materialConvolution ];
-
-					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
-					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
-
-					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, true );
-
-					// Render original scene with superimposed blur to texture
-
-					postprocessing.quad.materials = [ postprocessing.materialScreen ];
-
-					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
-					postprocessing.materialScreen.uniforms.opacity.value = 1.3;
-
-					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
-
-					// Render to screen
-
-					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
-					renderer.render( postprocessing.scene, postprocessing.camera );
-
-				} else {
-
-					renderer.render( scene, camera );
-
-				}
 
 
 			}
 			}
 
 

+ 61 - 214
examples/webgl_particles_dynamic.html

@@ -41,6 +41,15 @@
 
 
         <script type="text/javascript" src="../build/Three.js"></script>
         <script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
+		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
+
         <script type="text/javascript" src="js/Stats.js"></script>
         <script type="text/javascript" src="js/Stats.js"></script>
         <script type="text/javascript" src="js/Detector.js"></script>
         <script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
@@ -65,8 +74,7 @@
 
 
 			var total = 0, totaln = 0;
 			var total = 0, totaln = 0;
 
 
-			var postprocessing1 = {};
-			var postprocessing2 = {};
+			var composer, effectFocus;
 
 
             init();
             init();
             animate();
             animate();
@@ -88,9 +96,6 @@
 				directionalLight.position.normalize();
 				directionalLight.position.normalize();
 				scene.addLight( directionalLight );
 				scene.addLight( directionalLight );
 
 
-				initPostprocessingBloom( postprocessing1 );
-				initPostprocessingFocus( postprocessing2 );
-
 				aloader = new THREE.JSONLoader( );
 				aloader = new THREE.JSONLoader( );
 				bloader = new THREE.BinaryLoader( true );
 				bloader = new THREE.BinaryLoader( true );
 
 
@@ -130,6 +135,8 @@
 
 
 				} } );
 				} } );
 
 
+				//
+
                 renderer = new THREE.WebGLRenderer( { clearColor: 0x000000, clearAlpha: 1, antialias: false } );
                 renderer = new THREE.WebGLRenderer( { clearColor: 0x000000, clearAlpha: 1, antialias: false } );
 				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 				renderer.autoClear = false;
 				renderer.autoClear = false;
@@ -138,11 +145,15 @@
 
 
 				renderer.setClearColor( scene.fog.color, 1 );
 				renderer.setClearColor( scene.fog.color, 1 );
 
 
+				//
+
                 stats = new Stats();
                 stats = new Stats();
                 stats.domElement.style.position = 'absolute';
                 stats.domElement.style.position = 'absolute';
                 stats.domElement.style.top = '0px';
                 stats.domElement.style.top = '0px';
                 //container.appendChild( stats.domElement );
                 //container.appendChild( stats.domElement );
 
 
+				//
+
 				parent = new THREE.Object3D();
 				parent = new THREE.Object3D();
 				scene.addObject( parent );
 				scene.addObject( parent );
 
 
@@ -154,8 +165,50 @@
 				totaln += 1;
 				totaln += 1;
 				total += grid.geometry.vertices.length;
 				total += grid.geometry.vertices.length;
 
 
+				// postprocessing
+
+				var renderModel = new THREE.RenderPass( scene, camera );
+				var effectBloom = new THREE.BloomPass( 0.75 );
+				var effectFilm = new THREE.FilmPass( 0.5, 0.5, 1448, false );
+
+				effectFocus = new THREE.ShaderPass( THREE.ShaderExtras[ "focus" ] );
+
+				effectFocus.uniforms[ "screenWidth" ].value = window.innerWidth;
+				effectFocus.uniforms[ "screenHeight" ].value = window.innerHeight;
+
+				effectFocus.renderToScreen = true;
+
+				composer = new THREE.EffectComposer( renderer );
+
+				composer.addPass( renderModel );
+				composer.addPass( effectBloom );
+				composer.addPass( effectFilm );
+				composer.addPass( effectFocus );
+
+				//
+
+				window.addEventListener( 'resize', onWindowResize, false );
+
             }
             }
 
 
+			//
+
+			function onWindowResize( event ) {
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+				composer.reset();
+
+				effectFocus.uniforms[ "screenWidth" ].value = window.innerWidth;
+				effectFocus.uniforms[ "screenHeight" ].value = window.innerHeight;
+
+			}
+
+			//
+
 			function createMesh( originalGeometry, scene, scale, x, y, z, color, dynamic ) {
 			function createMesh( originalGeometry, scene, scale, x, y, z, color, dynamic ) {
 
 
 				var i, c;
 				var i, c;
@@ -234,177 +287,10 @@
 							  dynamic: dynamic,
 							  dynamic: dynamic,
 							  bb: geometry.boundingBox } );
 							  bb: geometry.boundingBox } );
 
 
-				console.log( total, totaln );
+				//console.log( total, totaln );
 
 
 			}
 			}
 
 
-			function initPostprocessingFocus( effect ) {
-
-				effect.type = "focus";
-
-				effect.scene = new THREE.Scene();
-
-				effect.camera = new THREE.OrthoCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10000, 10000 );
-				effect.camera.position.z = 100;
-
-				effect.texture = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBFormat } );
-
-				var heatUniforms = {
-
-					"map": { type: "t", value:0, texture: effect.texture },
-					"screenWidth": { type: "f", value: SCREEN_WIDTH },
-					"screenHeight": { type: "f", value: SCREEN_HEIGHT },
-					"sampleDistance": { type: "f", value: 0.94 },
-					"waveFactor": { type: "f", value: 0.00125 }
-
-				};
-
-				effect.materialHeat = new THREE.MeshShaderMaterial( {
-
-					uniforms: heatUniforms,
-					vertexShader: [
-
-						"varying vec2 vUv;",
-
-						"void main() {",
-
-							"vUv = vec2( uv.x, 1.0 - uv.y );",
-							"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-						"}"
-
-					].join("\n"),
-
-					fragmentShader: [
-
-							"uniform float screenWidth;",
-							"uniform float screenHeight;",
-							"uniform float sampleDistance;",
-							"uniform float waveFactor;",
-
-							"uniform sampler2D map;",
-							"varying vec2 vUv;",
-
-							"void main() {",
-
-								"vec4 color, org, tmp, add;",
-								"float sample_dist, f;",
-								"vec2 vin;",
-								"vec2 uv = vUv;",
-
-								"add += color = org = texture2D( map, uv );",
-
-								"vin = ( uv - vec2( 0.5 ) ) * vec2( 1.4 );",
-								"sample_dist = dot( vin, vin ) * 2.0;",
-
-								"f = ( waveFactor * 100.0 + sample_dist ) * sampleDistance * 4.0;",
-
-								"vec2 sampleSize = vec2(  1.0 / screenWidth, 1.0 / screenHeight ) * vec2(f);",
-
-								"add += tmp = texture2D( map, uv + vec2(0.111964, 0.993712) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(0.846724, 0.532032) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(0.943883, -0.330279) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(0.330279, -0.943883) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(-0.532032, -0.846724) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(-0.993712, -0.111964) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"add += tmp = texture2D( map, uv + vec2(-0.707107, 0.707107) * sampleSize );",
-								"if( tmp.b < color.b ) color = tmp;",
-
-								"color = color * vec4( 2.0 ) - ( add / vec4( 8.0 ) );",
-								"color = color + ( add / vec4(8.0) - color ) * ( vec4(1.0) - vec4(sample_dist * 0.5) );",
-
-								"gl_FragColor = vec4( color.rgb * color.rgb * vec3( 0.95 ) + color.rgb, 1.0 );",
-
-							"}"
-
-
-						].join("\n")
-
-				} );
-
-				effect.quad = new THREE.Mesh( new THREE.PlaneGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialHeat );
-				effect.quad.position.z = -500;
-				effect.scene.addObject( effect.quad );
-
-			}
-
-			function initPostprocessingBloom( effect ) {
-
-				effect.type = "bloomnoise";
-
-				effect.scene = new THREE.Scene();
-
-				effect.camera = new THREE.OrthoCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10000, 10000 );
-				effect.camera.position.z = 100;
-
-				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat };
-
-				effect.rtTexture1 = new THREE.WebGLRenderTarget( SCREEN_WIDTH, SCREEN_HEIGHT, pars );
-				effect.rtTexture2 = new THREE.WebGLRenderTarget( 256, 512, pars );
-				effect.rtTexture3 = new THREE.WebGLRenderTarget( 512, 256, pars );
-
-				var screen_shader = THREE.ShaderUtils.lib["screen"];
-				var screen_uniforms = THREE.UniformsUtils.clone( screen_shader.uniforms );
-
-				screen_uniforms["tDiffuse"].texture = effect.rtTexture3;
-				screen_uniforms["opacity"].value = 0.75;
-
-				effect.materialScreen = new THREE.MeshShaderMaterial( {
-
-					uniforms: screen_uniforms,
-					vertexShader: screen_shader.vertexShader,
-					fragmentShader: screen_shader.fragmentShader,
-					blending: THREE.AdditiveBlending,
-					transparent: true
-
-				} );
-
-				var convolution_shader = THREE.ShaderUtils.lib["convolution"];
-				var convolution_uniforms = THREE.UniformsUtils.clone( convolution_shader.uniforms );
-
-				effect.blurx = new THREE.Vector2( 0.001953125, 0.0 ),
-				effect.blury = new THREE.Vector2( 0.0, 0.001953125 );
-
-				convolution_uniforms["tDiffuse"].texture = effect.rtTexture1;
-				convolution_uniforms["uImageIncrement"].value = effect.blurx;
-				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
-
-				effect.materialConvolution = new THREE.MeshShaderMaterial( {
-
-					uniforms: convolution_uniforms,
-					vertexShader:   "#define KERNEL_SIZE 25.0\n" + convolution_shader.vertexShader,
-					fragmentShader: "#define KERNEL_SIZE 25\n"   + convolution_shader.fragmentShader
-
-				} );
-
-				var film_shader = THREE.ShaderUtils.lib["film"];
-				var film_uniforms = THREE.UniformsUtils.clone( film_shader.uniforms );
-
-				film_uniforms["tDiffuse"].texture = effect.rtTexture1;
-
-				effect.materialFilm = new THREE.MeshShaderMaterial( { uniforms: film_uniforms, vertexShader: film_shader.vertexShader, fragmentShader: film_shader.fragmentShader } );
-				effect.materialFilm.uniforms.grayscale.value = 0;
-				effect.materialFilm.uniforms.nIntensity.value = 0.5;
-				effect.materialFilm.uniforms.sIntensity.value = 0.5;
-				effect.materialFilm.uniforms.sCount.value = 1448;
-
-				effect.quad = new THREE.Mesh( new THREE.PlaneGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialConvolution );
-				effect.quad.position.z = -500;
-				effect.scene.addObject( effect.quad );
-
-			}
 
 
 			var j, jl, cm, data, vertices, vertices_tmp, vl, d, vt,
 			var j, jl, cm, data, vertices, vertices_tmp, vl, d, vt,
 				time, oldTime, delta;
 				time, oldTime, delta;
@@ -414,7 +300,7 @@
 				requestAnimationFrame( animate );
 				requestAnimationFrame( animate );
 
 
 				render();
 				render();
-				//stats.update();
+				stats.update();
 
 
 			}
 			}
 
 
@@ -589,46 +475,7 @@
 				}
 				}
 
 
 				renderer.clear();
 				renderer.clear();
-
-				// BLOOM
-
-				// Render scene into texture
-
-				renderer.render( scene, camera, postprocessing1.rtTexture1, true );
-
-				// Render quad with blured scene into texture (convolution pass 1)
-
-				postprocessing1.quad.materials[ 0 ] = postprocessing1.materialConvolution;
-
-				postprocessing1.materialConvolution.uniforms.tDiffuse.texture = postprocessing1.rtTexture1;
-				postprocessing1.materialConvolution.uniforms.uImageIncrement.value = postprocessing1.blurx;
-
-				renderer.render( postprocessing1.scene, postprocessing1.camera, postprocessing1.rtTexture2, true );
-
-				// Render quad with blured scene into texture (convolution pass 2)
-
-				postprocessing1.materialConvolution.uniforms.tDiffuse.texture = postprocessing1.rtTexture2;
-				postprocessing1.materialConvolution.uniforms.uImageIncrement.value = postprocessing1.blury;
-
-				renderer.render( postprocessing1.scene, postprocessing1.camera, postprocessing1.rtTexture3, true );
-
-				// Render original scene with superimposed blur to texture
-
-				postprocessing1.quad.materials[ 0 ] = postprocessing1.materialScreen;
-
-				renderer.render( postprocessing1.scene, postprocessing1.camera, postprocessing1.rtTexture1, false );
-
-
-				// NOISE + SCANLINES
-
-				postprocessing1.materialFilm.uniforms.time.value += 0.01;
-				postprocessing1.quad.materials[ 0 ] = postprocessing1.materialFilm;
-
-				renderer.render( postprocessing1.scene, postprocessing1.camera, postprocessing2.texture, true );
-
-				// FOCUS
-
-				renderer.render( postprocessing2.scene, postprocessing2.camera );
+				composer.render( 0.01 );
 
 
             }
             }
 
 

+ 2 - 0
examples/webgl_performance.html

@@ -70,6 +70,8 @@
 						mesh.matrixAutoUpdate = false;
 						mesh.matrixAutoUpdate = false;
 						mesh.updateMatrix();
 						mesh.updateMatrix();
 
 
+						//mesh.frustumCulled = false;
+
 						scene.addObject( mesh );
 						scene.addObject( mesh );
 
 
 					}
 					}

+ 84 - 47
examples/webgl_postprocessing.html

@@ -11,7 +11,7 @@
 			text-align:center;
 			text-align:center;
 			font-weight: bold;
 			font-weight: bold;
 
 
-			background-color: #fff;
+			background-color: #000;
 			margin: 0px;
 			margin: 0px;
 			overflow: hidden;
 			overflow: hidden;
 		    }
 		    }
@@ -20,7 +20,7 @@
 			color:#fff;
 			color:#fff;
 			background-color: rgba( 0, 0, 0, 0.5 );
 			background-color: rgba( 0, 0, 0, 0.5 );
 			position: relative;
 			position: relative;
-			margin: 0 auto -2em;
+			margin: 0 auto -2.1em;
 			top: 0px;
 			top: 0px;
 			width: 550px;
 			width: 550px;
 			padding: 5px;
 			padding: 5px;
@@ -41,14 +41,17 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
-		<script type="text/javascript" src="js/postprocessing/SepiaPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/DotScreenPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/DotScreenPass.js"></script>
-		<script type="text/javascript" src="js/postprocessing/ScreenPass.js"></script>
-		<script type="text/javascript" src="js/postprocessing/VignettePass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/TexturePass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
 
 
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
@@ -64,6 +67,7 @@
 			void main() {
 			void main() {
 
 
 				//gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
 				//gl_FragColor = vec4( time, vUv.x, vUv.y, 1.0 );
+				//gl_FragColor = vec4( 0.4, 0.4, 0.4, 1.0 );
 				gl_FragColor = vec4( 0.2, 0.4, 0.5, 1.0 );
 				gl_FragColor = vec4( 0.2, 0.4, 0.5, 1.0 );
 
 
 			}
 			}
@@ -99,7 +103,9 @@
 			var halfWidth = window.innerWidth / 2;
 			var halfWidth = window.innerWidth / 2;
 			var halfHeight = window.innerHeight / 2;
 			var halfHeight = window.innerHeight / 2;
 
 
-			var rtTexture, materialColor, material2D, quadBG1, quadBG2;
+			var materialColor, material2D, quadBG, quadMask, renderScene;
+
+			var rtParameters;
 
 
 			var delta = 0.01;
 			var delta = 0.01;
 
 
@@ -144,15 +150,27 @@
 
 
 				var plane = new THREE.PlaneGeometry( 1, 1 );
 				var plane = new THREE.PlaneGeometry( 1, 1 );
 
 
-				quadBG1 = new THREE.Mesh( plane, materialColor );
-				quadBG1.position.z = -500;
-				quadBG1.scale.set( window.innerWidth, window.innerHeight, 1 );
-				sceneBG.addObject( quadBG1 );
+				quadBG = new THREE.Mesh( plane, materialColor );
+				quadBG.position.z = -500;
+				quadBG.scale.set( window.innerWidth, window.innerHeight, 1 );
+				sceneBG.addObject( quadBG );
+
+				//
+
+				var sceneMask = new THREE.Scene();
+
+				var plane = new THREE.PlaneGeometry( 1, 1 );
+
+				quadMask = new THREE.Mesh( plane, new THREE.MeshBasicMaterial( { color: 0xffaa00 } )  );
+				quadMask.position.z = -300;
+				quadMask.scale.set( window.innerWidth / 2, window.innerHeight/2, 1 );
+				sceneMask.addObject( quadMask );
 
 
 				//
 				//
 
 
 				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.setClearColorHex( 0x000000, 1 );
 				renderer.autoClear = false;
 				renderer.autoClear = false;
 
 
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
@@ -166,18 +184,39 @@
 
 
 				//
 				//
 
 
-				var effectBloom = new THREE.BloomPass( 0.75 );
-				var effectFilm = new THREE.FilmPass( 0.75, 0.025, 648, false );
+				var shaderBleach = THREE.ShaderExtras[ "bleachbypass" ];
+				var shaderSepia = THREE.ShaderExtras[ "sepia" ];
+				var shaderVignette = THREE.ShaderExtras[ "vignette" ];
+				var shaderScreen = THREE.ShaderExtras[ "screen" ];
+
+				var effectBleach = new THREE.ShaderPass( shaderBleach );
+				var effectSepia = new THREE.ShaderPass( shaderSepia );
+				var effectVignette = new THREE.ShaderPass( shaderVignette );
+				var effectScreen = new THREE.ShaderPass( shaderScreen );
+
+				effectBleach.uniforms[ "opacity" ].value = 0.95;
+
+				effectSepia.uniforms[ "amount" ].value = 0.9;
+
+				effectVignette.uniforms[ "offset" ].value = 0.95;
+				effectVignette.uniforms[ "darkness" ].value = 1.6;
+
+				var effectBloom = new THREE.BloomPass( 0.5 );
+				var effectFilm = new THREE.FilmPass( 0.5, 0.025, 648, false );
 				var effectFilmBW = new THREE.FilmPass( 0.35, 0.5, 2048, true );
 				var effectFilmBW = new THREE.FilmPass( 0.35, 0.5, 2048, true );
-				var effectSepia = new THREE.SepiaPass( 1.0 );
-				var effectScreen = new THREE.ScreenPass();
-				var effectDotScreen = new THREE.DotScreenPass( new THREE.Vector2( 0, 0 ), 0.5, 0.4 );
-				var effectVignette = new THREE.VignettePass( 0.95, 1.6 );
+				var effectFilmBW2 = new THREE.FilmPass( 0.05, 0.5, 2048, true );
+				var effectDotScreen = new THREE.DotScreenPass( new THREE.Vector2( 0, 0 ), 0.5, 0.6 );
+
+				//var renderMask = new THREE.MaskPass( sceneMask, cameraOrtho );
+				var renderMask = new THREE.MaskPass( sceneModel, cameraPerspective );
+				var clearMask = new THREE.ClearMaskPass();
 
 
 				//effectFilm.renderToScreen = true;
 				//effectFilm.renderToScreen = true;
 				//effectFilmBW.renderToScreen = true;
 				//effectFilmBW.renderToScreen = true;
 				//effectDotScreen.renderToScreen = true;
 				//effectDotScreen.renderToScreen = true;
+				//effectBleach.renderToScreen = true;
 				effectVignette.renderToScreen = true;
 				effectVignette.renderToScreen = true;
+				//effectScreen.renderToScreen = true;
 
 
 				//
 				//
 
 
@@ -193,64 +232,62 @@
 
 
 				//
 				//
 
 
-				scene2D = new THREE.Scene();
-
-				var shader = THREE.ShaderUtils.lib[ "screen" ];
+				renderScene = new THREE.TexturePass( composerScene.renderTarget );
 
 
-				material2D = new THREE.MeshShaderMaterial( {
+				rtParameters = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBFormat, stencilBufer: true };
 
 
-					uniforms: THREE.UniformsUtils.clone( shader.uniforms ),
-					vertexShader: shader.vertexShader,
-					fragmentShader: shader.fragmentShader
-
-				} );
-
-				material2D.uniforms[ "tDiffuse" ].texture = composerScene.renderTarget;
-
-				quadBG2 = new THREE.Mesh( plane, material2D );
-				quadBG2.position.z = -500;
-				quadBG2.scale.set( window.innerWidth, window.innerHeight, 1 );
-				scene2D.addObject( quadBG2 );
-
-				var renderScene = new THREE.RenderPass( scene2D, cameraOrtho );
+				var rtWidth  = window.innerWidth / 2;
+				var rtHeight = window.innerHeight / 2;
 
 
 				//
 				//
 
 
-				composer1 = new THREE.EffectComposer( renderer );
+				composer1 = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth, rtHeight, rtParameters ) );
 
 
 				composer1.addPass( renderScene );
 				composer1.addPass( renderScene );
-				composer1.addPass( effectBloom );
+				//composer1.addPass( renderMask );
 				composer1.addPass( effectFilmBW );
 				composer1.addPass( effectFilmBW );
+				//composer1.addPass( clearMask );
 				composer1.addPass( effectVignette );
 				composer1.addPass( effectVignette );
 
 
 				//
 				//
 
 
-				composer2 = new THREE.EffectComposer( renderer );
+				composer2 = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth, rtHeight, rtParameters ) );
 
 
 				composer2.addPass( renderScene );
 				composer2.addPass( renderScene );
+				composer2.addPass( renderMask );
 				composer2.addPass( effectDotScreen );
 				composer2.addPass( effectDotScreen );
+				composer2.addPass( clearMask );
+				composer2.addPass( effectFilmBW2 );
 				composer2.addPass( effectVignette );
 				composer2.addPass( effectVignette );
 
 
 				//
 				//
 
 
-				composer3 = new THREE.EffectComposer( renderer );
+				composer3 = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth, rtHeight, rtParameters ) );
 
 
 				composer3.addPass( renderScene );
 				composer3.addPass( renderScene );
+				//composer3.addPass( renderMask );
 				composer3.addPass( effectSepia );
 				composer3.addPass( effectSepia );
 				composer3.addPass( effectFilm );
 				composer3.addPass( effectFilm );
+				//composer3.addPass( clearMask );
 				composer3.addPass( effectVignette );
 				composer3.addPass( effectVignette );
 
 
 				//
 				//
 
 
-				composer4 = new THREE.EffectComposer( renderer );
+				composer4 = new THREE.EffectComposer( renderer, new THREE.WebGLRenderTarget( rtWidth, rtHeight, rtParameters ) );
 
 
 				composer4.addPass( renderScene );
 				composer4.addPass( renderScene );
+				//composer4.addPass( renderMask );
 				composer4.addPass( effectBloom );
 				composer4.addPass( effectBloom );
+				composer4.addPass( effectFilm );
+				composer4.addPass( effectBleach );
+				//composer4.addPass( clearMask );
 				composer4.addPass( effectVignette );
 				composer4.addPass( effectVignette );
 
 
 				//
 				//
 
 
-				onWindowResize();
+				//onWindowResize();
+
+				renderScene.uniforms[ "tDiffuse" ].texture = composerScene.renderTarget2;
 
 
 				window.addEventListener( 'resize', onWindowResize, false );
 				window.addEventListener( 'resize', onWindowResize, false );
 
 
@@ -275,15 +312,15 @@
 
 
 				composerScene.reset();
 				composerScene.reset();
 
 
-				composer1.reset();
-				composer2.reset();
-				composer3.reset();
-				composer4.reset();
+				composer1.reset( new THREE.WebGLRenderTarget( halfWidth, halfHeight, rtParameters ) );
+				composer2.reset( new THREE.WebGLRenderTarget( halfWidth, halfHeight, rtParameters ) );
+				composer3.reset( new THREE.WebGLRenderTarget( halfWidth, halfHeight, rtParameters ) );
+				composer4.reset( new THREE.WebGLRenderTarget( halfWidth, halfHeight, rtParameters ) );
 
 
-				material2D.uniforms[ "tDiffuse" ].texture = composerScene.renderTarget;
+				renderScene.uniforms[ "tDiffuse" ].texture = composerScene.renderTarget2;
 
 
-				quadBG1.scale.set( window.innerWidth, window.innerHeight, 1 );
-				quadBG2.scale.set( window.innerWidth, window.innerHeight, 1 );
+				quadBG.scale.set( window.innerWidth, window.innerHeight, 1 );
+				quadMask.scale.set( window.innerWidth / 2, window.innerHeight / 2, 1 );
 
 
 			}
 			}
 
 

+ 1 - 1
examples/webgl_postprocessing_dof.html

@@ -241,7 +241,7 @@
 				postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( window.innerWidth, height, pars );
 				postprocessing.rtTextureDepth = new THREE.WebGLRenderTarget( window.innerWidth, height, pars );
 				postprocessing.rtTextureColor = new THREE.WebGLRenderTarget( window.innerWidth, height, pars );
 				postprocessing.rtTextureColor = new THREE.WebGLRenderTarget( window.innerWidth, height, pars );
 
 
-				var bokeh_shader = ShaderExtras[ "bokeh" ];
+				var bokeh_shader = THREE.ShaderExtras[ "bokeh" ];
 
 
 				postprocessing.bokeh_uniforms = THREE.UniformsUtils.clone( bokeh_shader.uniforms );
 				postprocessing.bokeh_uniforms = THREE.UniformsUtils.clone( bokeh_shader.uniforms );
 
 

+ 7 - 2
examples/webgl_ribbons.html

@@ -33,9 +33,12 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
-		<script type="text/javascript" src="js/postprocessing/ScreenPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 
 
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
@@ -198,7 +201,9 @@
 
 
 				var renderModel = new THREE.RenderPass( scene, camera );
 				var renderModel = new THREE.RenderPass( scene, camera );
 				var effectBloom = new THREE.BloomPass( 1.0 );
 				var effectBloom = new THREE.BloomPass( 1.0 );
-				var effectScreen = new THREE.ScreenPass();
+				var effectScreen = new THREE.ShaderPass( THREE.ShaderExtras[ "screen" ] );
+
+				effectScreen.renderToScreen = true;
 
 
 				composer = new THREE.EffectComposer( renderer );
 				composer = new THREE.EffectComposer( renderer );
 
 

+ 5 - 3
examples/webgl_sandbox.html

@@ -139,6 +139,8 @@
 		<script type="text/javascript" src="../src/extras/renderers/AnaglyphWebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/extras/renderers/AnaglyphWebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/extras/renderers/CrosseyedWebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/extras/renderers/CrosseyedWebGLRenderer.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 
 
@@ -173,9 +175,9 @@
 
 
 				var geometry = new THREE.SphereGeometry( 50, 32, 16 );
 				var geometry = new THREE.SphereGeometry( 50, 32, 16 );
 
 
-				var uniforms = THREE.ShaderUtils.lib[ 'basic' ].uniforms;
-				var vertexShader = THREE.ShaderUtils.lib[ 'basic' ].vertexShader;
-				var fragmentShader = THREE.ShaderUtils.lib[ 'basic' ].fragmentShader;
+				var uniforms = THREE.ShaderExtras[ 'basic' ].uniforms;
+				var vertexShader = THREE.ShaderExtras[ 'basic' ].vertexShader;
+				var fragmentShader = THREE.ShaderExtras[ 'basic' ].fragmentShader;
 
 
 				var texture = new THREE.Texture( generateTexture( 0, 0.5, 1 ), new THREE.UVMapping() );
 				var texture = new THREE.Texture( generateTexture( 0, 0.5, 1 ), new THREE.UVMapping() );
 				var texture2 = new THREE.Texture( generateTexture( 0, 1, 0 ), new THREE.SphericalReflectionMapping() );
 				var texture2 = new THREE.Texture( generateTexture( 0, 1, 0 ), new THREE.SphericalReflectionMapping() );

+ 4 - 0
examples/webgl_shader_lava.html

@@ -37,7 +37,11 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
 		<script type="text/javascript" src="js/postprocessing/EffectComposer.js"></script>
+		<script type="text/javascript" src="js/postprocessing/ShaderPass.js"></script>
+		<script type="text/javascript" src="js/postprocessing/MaskPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/RenderPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/BloomPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>
 		<script type="text/javascript" src="js/postprocessing/FilmPass.js"></script>

+ 3 - 1
examples/webgl_shadowmap.html

@@ -32,6 +32,8 @@
 
 
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
+		<script type="text/javascript" src="js/ShaderExtras.js"></script>
+
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
@@ -138,7 +140,7 @@
 				cameraOrtho = new THREE.OrthoCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2,  SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10, 1000 );
 				cameraOrtho = new THREE.OrthoCamera( SCREEN_WIDTH / - 2, SCREEN_WIDTH / 2,  SCREEN_HEIGHT / 2, SCREEN_HEIGHT / - 2, -10, 1000 );
 				cameraOrtho.position.z = 10;
 				cameraOrtho.position.z = 10;
 
 
-				var shader = THREE.ShaderUtils.lib[ "screen" ];
+				var shader = THREE.ShaderExtras[ "screen" ];
 				var uniforms = new THREE.UniformsUtils.clone( shader.uniforms );
 				var uniforms = new THREE.UniformsUtils.clone( shader.uniforms );
 
 
 				hudMaterial = new THREE.MeshShaderMaterial( { vertexShader: shader.vertexShader, fragmentShader: shader.fragmentShader, uniforms: uniforms } );
 				hudMaterial = new THREE.MeshShaderMaterial( { vertexShader: shader.vertexShader, fragmentShader: shader.fragmentShader, uniforms: uniforms } );

+ 95 - 0
examples/webgl_test_memory.html

@@ -0,0 +1,95 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js - webgl</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				background:#fff;
+				padding:0;
+				margin:0;
+				overflow:hidden;
+			}
+
+		</style>
+	</head>
+
+	<body>
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript">
+
+			var container;
+
+			var camera, scene, renderer;
+
+			init();
+			setInterval( render, 1000 / 60 );
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				camera = new THREE.Camera( 60, window.innerWidth / window.innerHeight, 1, 10000 );
+				camera.position.z = 200;
+
+				scene = new THREE.Scene();
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				container.appendChild( renderer.domElement );
+
+			}
+
+			function createImage() {
+
+				var canvas = document.createElement( 'canvas' );
+				canvas.width = 256;
+				canvas.height = 256;
+
+				var context = canvas.getContext( '2d' );
+				context.fillStyle = 'rgb(' + Math.floor( Math.random() * 256 ) + ',' + Math.floor( Math.random() * 256 ) + ',' + Math.floor( Math.random() * 256 ) + ')';
+				context.fillRect( 0, 0, 256, 256 );
+
+				return canvas;
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+
+			}
+
+			function render() {
+
+				var geometry = new THREE.SphereGeometry( 50, Math.random() * 64, Math.random() * 32 );
+
+				var texture = new THREE.Texture( createImage() );
+				texture.needsUpdate = true;
+
+				var material = new THREE.MeshBasicMaterial( { map: texture, wireframe: true } )
+
+				var mesh = new THREE.Mesh( geometry, material );
+
+				scene.addObject( mesh );
+
+				renderer.render( scene, camera );
+
+				scene.removeObject( mesh );
+
+				renderer.deallocateObject( mesh );
+				renderer.deallocateTexture( texture );
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 2 - 2
src/core/Geometry.js

@@ -7,7 +7,7 @@
 
 
 THREE.Geometry = function () {
 THREE.Geometry = function () {
 
 
-	this.id = "Geometry" + THREE.GeometryIdCounter ++;
+	this.id = THREE.GeometryCount ++;
 
 
 	this.vertices = [];
 	this.vertices = [];
 	this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon
 	this.colors = []; // one-to-one vertex colors, used in ParticleSystem, Line and Ribbon
@@ -510,4 +510,4 @@ THREE.Geometry.prototype = {
 
 
 };
 };
 
 
-THREE.GeometryIdCounter = 0;
+THREE.GeometryCount = 0;

+ 7 - 2
src/core/Object3D.js

@@ -6,6 +6,9 @@
 
 
 THREE.Object3D = function() {
 THREE.Object3D = function() {
 
 
+	this.id = THREE.Object3DCount ++;
+	this.name = "";
+
 	this.parent = undefined;
 	this.parent = undefined;
 	this.children = [];
 	this.children = [];
 
 
@@ -43,9 +46,9 @@ THREE.Object3D = function() {
 	this.castShadow = false;
 	this.castShadow = false;
 	this.receiveShadow = false;
 	this.receiveShadow = false;
 
 
-	this._vector = new THREE.Vector3();
+	this.frustumCulled = true;
 
 
-	this.name = "";
+	this._vector = new THREE.Vector3();
 
 
 };
 };
 
 
@@ -233,3 +236,5 @@ THREE.Object3D.prototype = {
 	}
 	}
 
 
 };
 };
+
+THREE.Object3DCount = 0;

+ 499 - 0
src/core/Projector.js

@@ -0,0 +1,499 @@
+/**
+ * @author mr.doob / http://mrdoob.com/
+ * @author supereggbert / http://www.paulbrunt.co.uk/
+ * @author julianwa / https://github.com/julianwa
+ */
+
+THREE.Projector = function() {
+
+	var _object, _objectCount, _objectPool = [],
+	_vertex, _vertexCount, _vertexPool = [],
+	_face, _face3Count, _face3Pool = [], _face4Count, _face4Pool = [],
+	_line, _lineCount, _linePool = [],
+	_particle, _particleCount, _particlePool = [],
+
+	_objectList = [], _renderList = [],
+
+	_vector3 = new THREE.Vector4(),
+	_vector4 = new THREE.Vector4(),
+	_projScreenMatrix = new THREE.Matrix4(),
+	_projScreenObjectMatrix = new THREE.Matrix4(),
+
+	_frustum = [
+		new THREE.Vector4(),
+		new THREE.Vector4(),
+		new THREE.Vector4(),
+		new THREE.Vector4(),
+		new THREE.Vector4(),
+		new THREE.Vector4()
+	 ],
+
+	_clippedVertex1PositionScreen = new THREE.Vector4(),
+	_clippedVertex2PositionScreen = new THREE.Vector4(),
+
+	_face3VertexNormals;
+
+
+	this.projectVector = function ( vector, camera ) {
+
+		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
+		_projScreenMatrix.multiplyVector3( vector );
+
+		return vector;
+
+	};
+
+	this.unprojectVector = function ( vector, camera ) {
+
+		_projScreenMatrix.multiply( camera.matrixWorld, THREE.Matrix4.makeInvert( camera.projectionMatrix ) );
+		_projScreenMatrix.multiplyVector3( vector );
+
+		return vector;
+
+	};
+
+	this.projectObjects = function ( scene, camera, sort ) {
+
+		var o, ol, objects, object, matrix;
+
+		_objectList.length = 0;
+		_objectCount = 0;
+
+		objects = scene.objects;
+
+		for ( o = 0, ol = objects.length; o < ol; o ++ ) {
+
+			object = objects[ o ];
+
+			if ( !object.visible || ( object instanceof THREE.Mesh && ( object.frustumCulled && !isInFrustum( object ) ) ) ) continue;
+
+			_object = getNextObjectInPool();
+
+			_vector3.copy( object.position );
+			_projScreenMatrix.multiplyVector3( _vector3 );
+
+			_object.object = object;
+			_object.z = _vector3.z;
+
+			_objectList.push( _object );
+
+		}
+
+		sort && _objectList.sort( painterSort );
+
+		return _objectList;
+
+	};
+
+	// TODO: Rename to projectElements?
+
+	this.projectScene = function ( scene, camera, sort ) {
+
+		var near = camera.near, far = camera.far,
+		o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object,
+		objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw,
+		geometry, vertices, vertex, vertexPositionScreen,
+		faces, face, faceVertexNormals, normal, faceVertexUvs, uvs,
+		v1, v2, v3, v4;
+
+		_renderList.length = 0;
+
+		_face3Count = 0;
+		_face4Count = 0;
+		_lineCount = 0;
+		_particleCount = 0;
+
+		camera.matrixAutoUpdate && camera.update( undefined, true );
+
+		scene.update( undefined, false, camera );
+
+		_projScreenMatrix.multiply( camera.projectionMatrix, camera.matrixWorldInverse );
+		computeFrustum( _projScreenMatrix );
+
+		objects = this.projectObjects( scene, camera, true );
+
+		for ( o = 0, ol = objects.length; o < ol; o++ ) {
+
+			object = objects[ o ].object;
+
+			if ( !object.visible ) continue;
+
+			objectMatrix = object.matrixWorld;
+			objectMatrixRotation = object.matrixRotationWorld;
+
+			objectMaterials = object.materials;
+			objectOverdraw = object.overdraw;
+
+			_vertexCount = 0;
+
+			if ( object instanceof THREE.Mesh ) {
+
+				geometry = object.geometry;
+				vertices = geometry.vertices;
+				faces = geometry.faces;
+				faceVertexUvs = geometry.faceVertexUvs;
+
+				for ( v = 0, vl = vertices.length; v < vl; v ++ ) {
+
+					_vertex = getNextVertexInPool();
+					_vertex.positionWorld.copy( vertices[ v ].position );
+
+					objectMatrix.multiplyVector3( _vertex.positionWorld );
+
+					_vertex.positionScreen.copy( _vertex.positionWorld );
+					_projScreenMatrix.multiplyVector4( _vertex.positionScreen );
+
+					_vertex.positionScreen.x /= _vertex.positionScreen.w;
+					_vertex.positionScreen.y /= _vertex.positionScreen.w;
+
+					_vertex.visible = _vertex.positionScreen.z > near && _vertex.positionScreen.z < far;
+
+				}
+
+				for ( f = 0, fl = faces.length; f < fl; f ++ ) {
+
+					face = faces[ f ];
+
+					if ( face instanceof THREE.Face3 ) {
+
+						v1 = _vertexPool[ face.a ];
+						v2 = _vertexPool[ face.b ];
+						v3 = _vertexPool[ face.c ];
+
+						if ( v1.visible && v2.visible && v3.visible &&
+							( object.doubleSided || ( object.flipSided !=
+							( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
+							( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) {
+
+							_face = getNextFace3InPool();
+
+							_face.v1.copy( v1 );
+							_face.v2.copy( v2 );
+							_face.v3.copy( v3 );
+
+						} else {
+
+							continue;
+
+						}
+
+					} else if ( face instanceof THREE.Face4 ) {
+
+						v1 = _vertexPool[ face.a ];
+						v2 = _vertexPool[ face.b ];
+						v3 = _vertexPool[ face.c ];
+						v4 = _vertexPool[ face.d ];
+
+						if ( v1.visible && v2.visible && v3.visible && v4.visible &&
+							( object.doubleSided || ( object.flipSided !=
+							( ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
+							( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ||
+							( v2.positionScreen.x - v3.positionScreen.x ) * ( v4.positionScreen.y - v3.positionScreen.y ) -
+							( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) {
+
+							_face = getNextFace4InPool();
+
+							_face.v1.copy( v1 );
+							_face.v2.copy( v2 );
+							_face.v3.copy( v3 );
+							_face.v4.copy( v4 );
+
+						} else {
+
+							continue;
+
+						}
+
+					}
+
+					_face.normalWorld.copy( face.normal );
+					objectMatrixRotation.multiplyVector3( _face.normalWorld );
+
+					_face.centroidWorld.copy( face.centroid );
+					objectMatrix.multiplyVector3( _face.centroidWorld );
+
+					_face.centroidScreen.copy( _face.centroidWorld );
+					_projScreenMatrix.multiplyVector3( _face.centroidScreen );
+
+					faceVertexNormals = face.vertexNormals;
+
+					for ( n = 0, nl = faceVertexNormals.length; n < nl; n ++ ) {
+
+						normal = _face.vertexNormalsWorld[ n ];
+						normal.copy( faceVertexNormals[ n ] );
+						objectMatrixRotation.multiplyVector3( normal );
+
+					}
+
+					for ( c = 0, cl = faceVertexUvs.length; c < cl; c ++ ) {
+
+						uvs = faceVertexUvs[ c ][ f ];
+
+						if ( !uvs ) continue;
+
+						for ( u = 0, ul = uvs.length; u < ul; u ++ ) {
+
+							_face.uvs[ c ][ u ] = uvs[ u ];
+
+						}
+
+					}
+
+					_face.meshMaterials = objectMaterials;
+					_face.faceMaterials = face.materials;
+					_face.overdraw = objectOverdraw;
+
+					_face.z = _face.centroidScreen.z;
+
+					_renderList.push( _face );
+
+				}
+
+			} else if ( object instanceof THREE.Line ) {
+
+				_projScreenObjectMatrix.multiply( _projScreenMatrix, objectMatrix );
+
+				vertices = object.geometry.vertices;
+
+				v1 = getNextVertexInPool();
+				v1.positionScreen.copy( vertices[ 0 ].position );
+				_projScreenObjectMatrix.multiplyVector4( v1.positionScreen );
+
+				for ( v = 1, vl = vertices.length; v < vl; v++ ) {
+
+					v1 = getNextVertexInPool();
+					v1.positionScreen.copy( vertices[ v ].position );
+					_projScreenObjectMatrix.multiplyVector4( v1.positionScreen );
+
+					v2 = _vertexPool[ _vertexCount - 2 ];
+
+					_clippedVertex1PositionScreen.copy( v1.positionScreen );
+					_clippedVertex2PositionScreen.copy( v2.positionScreen );
+
+					if ( clipLine( _clippedVertex1PositionScreen, _clippedVertex2PositionScreen ) ) {
+
+						// Perform the perspective divide
+						_clippedVertex1PositionScreen.multiplyScalar( 1 / _clippedVertex1PositionScreen.w );
+						_clippedVertex2PositionScreen.multiplyScalar( 1 / _clippedVertex2PositionScreen.w );
+
+						_line = getNextLineInPool();
+						_line.v1.positionScreen.copy( _clippedVertex1PositionScreen );
+						_line.v2.positionScreen.copy( _clippedVertex2PositionScreen );
+
+						_line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z );
+
+						_line.materials = object.materials;
+
+						_renderList.push( _line );
+
+					}
+				}
+
+			} else if ( object instanceof THREE.Particle ) {
+
+				_vector4.set( object.matrixWorld.n14, object.matrixWorld.n24, object.matrixWorld.n34, 1 );
+				_projScreenMatrix.multiplyVector4( _vector4 );
+
+				_vector4.z /= _vector4.w;
+
+				if ( _vector4.z > 0 && _vector4.z < 1 ) {
+
+					_particle = getNextParticleInPool();
+					_particle.x = _vector4.x / _vector4.w;
+					_particle.y = _vector4.y / _vector4.w;
+					_particle.z = _vector4.z;
+
+					_particle.rotation = object.rotation.z;
+
+					_particle.scale.x = object.scale.x * Math.abs( _particle.x - ( _vector4.x + camera.projectionMatrix.n11 ) / ( _vector4.w + camera.projectionMatrix.n14 ) );
+					_particle.scale.y = object.scale.y * Math.abs( _particle.y - ( _vector4.y + camera.projectionMatrix.n22 ) / ( _vector4.w + camera.projectionMatrix.n24 ) );
+
+					_particle.materials = object.materials;
+
+					_renderList.push( _particle );
+
+				}
+
+			}
+
+		}
+
+		sort && _renderList.sort( painterSort );
+
+		return _renderList;
+
+	};
+
+	// Pools
+
+	function getNextObjectInPool() {
+
+		var object = _objectPool[ _objectCount ] = _objectPool[ _objectCount ] || new THREE.RenderableObject();
+
+		_objectCount ++;
+
+		return object;
+
+	}
+
+	function getNextVertexInPool() {
+
+		var vertex = _vertexPool[ _vertexCount ] = _vertexPool[ _vertexCount ] || new THREE.RenderableVertex();
+
+		_vertexCount ++;
+
+		return vertex;
+
+	}
+
+	function getNextFace3InPool() {
+
+		var face = _face3Pool[ _face3Count ] = _face3Pool[ _face3Count ] || new THREE.RenderableFace3();
+
+		_face3Count ++;
+
+		return face;
+
+	}
+
+	function getNextFace4InPool() {
+
+		var face = _face4Pool[ _face4Count ] = _face4Pool[ _face4Count ] || new THREE.RenderableFace4();
+
+		_face4Count ++;
+
+		return face;
+
+	}
+
+	function getNextLineInPool() {
+
+		var line = _linePool[ _lineCount ] = _linePool[ _lineCount ] || new THREE.RenderableLine();
+
+		_lineCount ++;
+
+		return line;
+
+	}
+
+	function getNextParticleInPool() {
+
+		var particle = _particlePool[ _particleCount ] = _particlePool[ _particleCount ] || new THREE.RenderableParticle();
+		_particleCount ++;
+		return particle;
+
+	}
+
+	//
+
+	function painterSort( a, b ) {
+
+		return b.z - a.z;
+
+	}
+
+	function computeFrustum( m ) {
+
+		_frustum[ 0 ].set( m.n41 - m.n11, m.n42 - m.n12, m.n43 - m.n13, m.n44 - m.n14 );
+		_frustum[ 1 ].set( m.n41 + m.n11, m.n42 + m.n12, m.n43 + m.n13, m.n44 + m.n14 );
+		_frustum[ 2 ].set( m.n41 + m.n21, m.n42 + m.n22, m.n43 + m.n23, m.n44 + m.n24 );
+		_frustum[ 3 ].set( m.n41 - m.n21, m.n42 - m.n22, m.n43 - m.n23, m.n44 - m.n24 );
+		_frustum[ 4 ].set( m.n41 - m.n31, m.n42 - m.n32, m.n43 - m.n33, m.n44 - m.n34 );
+		_frustum[ 5 ].set( m.n41 + m.n31, m.n42 + m.n32, m.n43 + m.n33, m.n44 + m.n34 );
+
+		for ( var i = 0; i < 6; i ++ ) {
+
+			var plane = _frustum[ i ];
+			plane.divideScalar( Math.sqrt( plane.x * plane.x + plane.y * plane.y + plane.z * plane.z ) );
+
+		}
+
+	}
+
+	function isInFrustum( object ) {
+
+		var distance, matrix = object.matrixWorld,
+		radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) );
+
+		for ( var i = 0; i < 6; i ++ ) {
+
+			distance = _frustum[ i ].x * matrix.n14 + _frustum[ i ].y * matrix.n24 + _frustum[ i ].z * matrix.n34 + _frustum[ i ].w;
+			if ( distance <= radius ) return false;
+
+		}
+
+		return true;
+
+	};
+
+	function clipLine( s1, s2 ) {
+
+		var alpha1 = 0, alpha2 = 1,
+
+		// Calculate the boundary coordinate of each vertex for the near and far clip planes,
+		// Z = -1 and Z = +1, respectively.
+		bc1near =  s1.z + s1.w,
+		bc2near =  s2.z + s2.w,
+		bc1far =  - s1.z + s1.w,
+		bc2far =  - s2.z + s2.w;
+
+		if ( bc1near >= 0 && bc2near >= 0 && bc1far >= 0 && bc2far >= 0 ) {
+
+			// Both vertices lie entirely within all clip planes.
+			return true;
+
+		} else if ( ( bc1near < 0 && bc2near < 0) || (bc1far < 0 && bc2far < 0 ) ) {
+
+			// Both vertices lie entirely outside one of the clip planes.
+			return false;
+
+		} else {
+
+			// The line segment spans at least one clip plane.
+
+			if ( bc1near < 0 ) {
+
+				// v1 lies outside the near plane, v2 inside
+				alpha1 = Math.max( alpha1, bc1near / ( bc1near - bc2near ) );
+
+			} else if ( bc2near < 0 ) {
+
+				// v2 lies outside the near plane, v1 inside
+				alpha2 = Math.min( alpha2, bc1near / ( bc1near - bc2near ) );
+
+			}
+
+			if ( bc1far < 0 ) {
+
+				// v1 lies outside the far plane, v2 inside
+				alpha1 = Math.max( alpha1, bc1far / ( bc1far - bc2far ) );
+
+			} else if ( bc2far < 0 ) {
+
+				// v2 lies outside the far plane, v2 inside
+				alpha2 = Math.min( alpha2, bc1far / ( bc1far - bc2far ) );
+
+			}
+
+			if ( alpha2 < alpha1 ) {
+
+				// The line segment spans two boundaries, but is outside both of them.
+				// (This can't happen when we're only clipping against just near/far but good
+				//  to leave the check here for future usage if other clip planes are added.)
+				return false;
+
+			} else {
+
+				// Update the s1 and s2 vertices to match the clipped line segment.
+				s1.lerpSelf( s2, alpha1 );
+				s2.lerpSelf( s1, 1 - alpha2 );
+
+				return true;
+
+			}
+
+		}
+
+	}
+
+};

+ 6 - 452
src/extras/ShaderUtils.js

@@ -2,14 +2,12 @@
  * @author alteredq / http://alteredqualia.com/
  * @author alteredq / http://alteredqualia.com/
  * @author mr.doob / http://mrdoob.com/
  * @author mr.doob / http://mrdoob.com/
  *
  *
- * ShaderUtils currently contains
+ * ShaderUtils currently contains:
+ *
  *	fresnel
  *	fresnel
  *	normal
  *	normal
  * 	cube
  * 	cube
- * 	convolution
- * 	film
- * 	screen
- *	basic
+ *
  */
  */
 
 
 if ( THREE.WebGLRenderer ) {
 if ( THREE.WebGLRenderer ) {
@@ -304,9 +302,11 @@ THREE.ShaderUtils = {
 				"void main() {",
 				"void main() {",
 
 
 					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
 					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
-					"vViewPosition = cameraPosition - mPosition.xyz;",
 
 
 					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
 					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+
+					"vViewPosition = -mvPosition.xyz;",
+
 					"vNormal = normalize( normalMatrix * normal );",
 					"vNormal = normalize( normalMatrix * normal );",
 
 
 					// tangent and binormal vectors
 					// tangent and binormal vectors
@@ -400,454 +400,8 @@ THREE.ShaderUtils = {
 
 
 			].join("\n")
 			].join("\n")
 
 
-		},
-
-		/* ------------------------------------------------------------------------
-		//	Convolution shader
-		//	  - ported from o3d sample to WebGL / GLSL
-		//			http://o3d.googlecode.com/svn/trunk/samples/convolution.html
-		------------------------------------------------------------------------ */
-
-		'convolution': {
-
-			uniforms: {
-
-				"tDiffuse" : { type: "t", value: 0, texture: null },
-				"uImageIncrement" : { type: "v2", value: new THREE.Vector2( 0.001953125, 0.0 ) },
-				"cKernel" : { type: "fv1", value: [] }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"uniform vec2 uImageIncrement;",
-				//"#define KERNEL_SIZE 25.0",
-
-				"void main(void) {",
-
-					"vUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"varying vec2 vUv;",
-
-				"uniform sampler2D tDiffuse;",
-				"uniform vec2 uImageIncrement;",
-
-				//"#define KERNEL_SIZE 25",
-				"uniform float cKernel[KERNEL_SIZE];",
-
-				"void main(void) {",
-
-					"vec2 imageCoord = vUv;",
-					"vec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );",
-					"for( int i=0; i<KERNEL_SIZE; ++i ) {",
-						"sum += texture2D( tDiffuse, imageCoord ) * cKernel[i];",
-						"imageCoord += uImageIncrement;",
-					"}",
-					"gl_FragColor = sum;",
-
-				"}"
-
-
-			].join("\n")
-
-		},
-
-		/* -------------------------------------------------------------------------
-
-		// Film grain & scanlines shader
-
-		//	- ported from HLSL to WebGL / GLSL
-		//	  http://www.truevision3d.com/forums/showcase/staticnoise_colorblackwhite_scanline_shaders-t18698.0.html
-
-		// Screen Space Static Postprocessor
-		//
-		// Produces an analogue noise overlay similar to a film grain / TV static
-		//
-		// Original implementation and noise algorithm
-		// Pat 'Hawthorne' Shearon
-		//
-		// Optimized scanlines + noise version with intensity scaling
-		// Georg 'Leviathan' Steinrohder
-
-		// This version is provided under a Creative Commons Attribution 3.0 License
-		// http://creativecommons.org/licenses/by/3.0/
-		 ------------------------------------------------------------------------- */
-
-		'film': {
-
-			uniforms: {
-
-				tDiffuse:   { type: "t", value: 0, texture: null },
-				time: 	    { type: "f", value: 0.0 },
-				nIntensity: { type: "f", value: 0.5 },
-				sIntensity: { type: "f", value: 0.05 },
-				sCount: 	{ type: "f", value: 4096 },
-				grayscale:  { type: "i", value: 1 }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"void main() {",
-
-					"vUv = vec2( uv.x, 1.0 - uv.y );",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"varying vec2 vUv;",
-				"uniform sampler2D tDiffuse;",
-
-				// control parameter
-				"uniform float time;",
-
-				"uniform bool grayscale;",
-
-				// noise effect intensity value (0 = no effect, 1 = full effect)
-				"uniform float nIntensity;",
-
-				// scanlines effect intensity value (0 = no effect, 1 = full effect)
-				"uniform float sIntensity;",
-
-				// scanlines effect count value (0 = no effect, 4096 = full effect)
-				"uniform float sCount;",
-
-				"void main() {",
-
-					// sample the source
-					"vec4 cTextureScreen = texture2D( tDiffuse, vUv );",
-
-					// make some noise
-					"float x = vUv.x * vUv.y * time *  1000.0;",
-					"x = mod( x, 13.0 ) * mod( x, 123.0 );",
-					"float dx = mod( x, 0.01 );",
-
-					// add noise
-					"vec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );",
-
-					// get us a sine and cosine
-					"vec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );",
-
-					// add scanlines
-					"cResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;",
-
-					// interpolate between source and result by intensity
-					"cResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );",
-
-					// convert to grayscale if desired
-					"if( grayscale ) {",
-						"cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );",
-					"}",
-
-					"gl_FragColor =  vec4( cResult, cTextureScreen.a );",
-
-				"}"
-
-			].join("\n")
-
-		},
-
-
-		/* -------------------------------------------------------------------------
-		//	Sepia tone shader
-		//  - based on glfx.js sepia shader
-		//		https://github.com/evanw/glfx.js
-		 ------------------------------------------------------------------------- */
-
-		'sepia': {
-
-			uniforms: {
-
-				tDiffuse: { type: "t", value: 0, texture: null },
-				amount:   { type: "f", value: 1.0 }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"void main() {",
-
-					"vUv = vec2( uv.x, 1.0 - uv.y );",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"uniform float amount;",
-
-				"varying vec2 vUv;",
-				"uniform sampler2D tDiffuse;",
-
-				"void main() {",
-
-					"vec4 color = texture2D( tDiffuse, vUv );",
-					"vec3 c = color.rgb;",
-
-					"color.r = dot( c, vec3( 1.0 - 0.607 * amount, 0.769 * amount, 0.189 * amount ) );",
-					"color.g = dot( c, vec3( 0.349 * amount, 1.0 - 0.314 * amount, 0.168 * amount ) );",
-					"color.b = dot( c, vec3( 0.272 * amount, 0.534 * amount, 1.0 - 0.869 * amount ) );",
-
-					"gl_FragColor = vec4( min( vec3( 1.0 ), color.rgb ), color.a );",
-
-				"}"
-
-			].join("\n")
-
-		},
-
-		/* -------------------------------------------------------------------------
-		//	Dot screen shader
-		//  - based on glfx.js sepia shader
-		//		https://github.com/evanw/glfx.js
-		 ------------------------------------------------------------------------- */
-
-		'dotscreen': {
-
-			uniforms: {
-
-				tDiffuse: { type: "t", value: 0, texture: null },
-				tSize:    { type: "v2", value: new THREE.Vector2( 256, 256 ) },
-				center:   { type: "v2", value: new THREE.Vector2( 0.5, 0.5 ) },
-				angle:	  { type: "f", value: 1.57 },
-				scale:	  { type: "f", value: 1.0 }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"void main() {",
-
-					"vUv = vec2( uv.x, 1.0 - uv.y );",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"uniform vec2 center;",
-				"uniform float angle;",
-				"uniform float scale;",
-				"uniform vec2 tSize;",
-
-				"varying vec2 vUv;",
-				"uniform sampler2D tDiffuse;",
-
-				"float pattern() {",
-
-					"float s = sin( angle ), c = cos( angle );",
-
-					"vec2 tex = vUv * tSize - center;",
-					"vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * scale;",
-
-					"return ( sin( point.x ) * sin( point.y ) ) * 4.0;",
-
-				"}",
-
-				"void main() {",
-
-					"vec4 color = texture2D( tDiffuse, vUv );",
-
-					"float average = ( color.r + color.g + color.b ) / 3.0;",
-
-					"gl_FragColor = vec4( vec3( average * 10.0 - 5.0 + pattern() ), color.a );",
-
-				"}"
-
-			].join("\n")
-
-		},
-
-		/* ------------------------------------------------------------------------------------------------
-		//	Vignette shader
-		//	- based on PaintEffect postprocess from ro.me
-		//		http://code.google.com/p/3-dreams-of-black/source/browse/deploy/js/effects/PaintEffect.js
-		 ------------------------------------------------------------------------------------------------ */
-
-		'vignette': {
-
-			uniforms: {
-
-				tDiffuse: { type: "t", value: 0, texture: null },
-				offset:   { type: "f", value: 1.0 },
-				darkness: { type: "f", value: 1.0 }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"void main() {",
-
-					"vUv = vec2( uv.x, 1.0 - uv.y );",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"uniform float offset;",
-				"uniform float darkness;",
-
-				"varying vec2 vUv;",
-				"uniform sampler2D tDiffuse;",
-
-				"void main() {",
-
-					// Eskil's vignette
-
-					"vec4 texel = texture2D( tDiffuse, vUv );",
-					"vec2 uv = ( vUv - vec2( 0.5 ) ) * vec2( offset );",
-					"gl_FragColor = vec4( mix( texel.rgb, vec3( 1.0 - darkness ), dot( uv, uv ) ), texel.a );",
-
-					/*
-					// alternative version from glfx.js
-					// this one makes more "dusty" look (as opposed to "burned")
-
-					"vec4 color = texture2D( tDiffuse, vUv );",
-					"float dist = distance( vUv, vec2( 0.5 ) );",
-					"color.rgb *= smoothstep( 0.8, offset * 0.799, dist *( darkness + offset ) );",
-					"gl_FragColor = color;",
-					*/
-
-				"}"
-
-			].join("\n")
-
-		},
-
-		/* -------------------------------------------------------------------------
-		//	Full-screen textured quad shader
-		 ------------------------------------------------------------------------- */
-
-		'screen': {
-
-			uniforms: {
-
-				tDiffuse: { type: "t", value: 0, texture: null },
-				opacity:  { type: "f", value: 1.0 }
-
-			},
-
-			vertexShader: [
-
-				"varying vec2 vUv;",
-
-				"void main() {",
-
-					"vUv = vec2( uv.x, 1.0 - uv.y );",
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"varying vec2 vUv;",
-				"uniform sampler2D tDiffuse;",
-				"uniform float opacity;",
-
-				"void main() {",
-
-					"vec4 texel = texture2D( tDiffuse, vUv );",
-					"gl_FragColor = opacity * texel;",
-
-				"}"
-
-			].join("\n")
-
-		},
-
-
-		/* -------------------------------------------------------------------------
-		//	Simple test shader
-		 ------------------------------------------------------------------------- */
-
-		'basic': {
-
-			uniforms: {},
-
-			vertexShader: [
-
-				"void main() {",
-
-					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-
-				"}"
-
-			].join("\n"),
-
-			fragmentShader: [
-
-				"void main() {",
-
-					"gl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );",
-
-				"}"
-
-			].join("\n")
-
-		}
-
-	},
-
-	buildKernel: function( sigma ) {
-
-		// We lop off the sqrt(2 * pi) * sigma term, since we're going to normalize anyway.
-
-		function gauss( x, sigma ) {
-
-			return Math.exp( - ( x * x ) / ( 2.0 * sigma * sigma ) );
-
 		}
 		}
 
 
-		var i, values, sum, halfWidth, kMaxKernelSize = 25, kernelSize = 2 * Math.ceil( sigma * 3.0 ) + 1;
-
-		if ( kernelSize > kMaxKernelSize ) kernelSize = kMaxKernelSize;
-		halfWidth = ( kernelSize - 1 ) * 0.5
-
-		values = new Array( kernelSize );
-		sum = 0.0;
-		for ( i = 0; i < kernelSize; ++i ) {
-
-			values[ i ] = gauss( i - halfWidth, sigma );
-			sum += values[ i ];
-
-		}
-
-		// normalize the kernel
-
-		for ( i = 0; i < kernelSize; ++i ) values[ i ] /= sum;
-
-		return values;
-
 	}
 	}
 
 
 };
 };

+ 0 - 0
src/extras/geometries/Curve.js → src/extras/core/Curve.js


+ 0 - 0
src/extras/geometries/CurvePath.js → src/extras/core/CurvePath.js


+ 0 - 0
src/extras/geometries/Path.js → src/extras/core/Path.js


+ 0 - 0
src/extras/geometries/Shape.js → src/extras/core/Shape.js


+ 0 - 0
src/extras/geometries/TextPath.js → src/extras/core/TextPath.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 414 - 421
src/extras/loaders/BinaryLoader.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 641 - 303
src/extras/loaders/ColladaLoader.js


+ 1 - 1
src/extras/loaders/JSONLoader.js

@@ -405,4 +405,4 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 
 	callback( geometry );
 	callback( geometry );
 
 
-}
+};

+ 7 - 7
src/extras/loaders/Loader.js

@@ -55,7 +55,7 @@ THREE.Loader.prototype = {
 
 
 	},
 	},
 
 
-	extractUrlbase: function( url ) {
+	extractUrlbase: function ( url ) {
 
 
 		var chunks = url.split( "/" );
 		var chunks = url.split( "/" );
 		chunks.pop();
 		chunks.pop();
@@ -63,11 +63,11 @@ THREE.Loader.prototype = {
 
 
 	},
 	},
 
 
-	init_materials: function( scope, materials, texture_path ) {
+	init_materials: function ( scope, materials, texture_path ) {
 
 
 		scope.materials = [];
 		scope.materials = [];
 
 
-		for ( var i = 0; i < materials.length; ++i ) {
+		for ( var i = 0; i < materials.length; ++ i ) {
 
 
 			scope.materials[ i ] = [ THREE.Loader.prototype.createMaterial( materials[ i ], texture_path ) ];
 			scope.materials[ i ] = [ THREE.Loader.prototype.createMaterial( materials[ i ], texture_path ) ];
 
 
@@ -75,7 +75,7 @@ THREE.Loader.prototype = {
 
 
 	},
 	},
 
 
-	hasNormals: function( scope ) {
+	hasNormals: function ( scope ) {
 
 
 		var m, i, il = scope.materials.length;
 		var m, i, il = scope.materials.length;
 
 
@@ -136,7 +136,7 @@ THREE.Loader.prototype = {
 
 
 		}
 		}
 
 
-		function create_texture( where, name, sourceFile, repeat, offset, wrap ) {
+		function create_texture ( where, name, sourceFile, repeat, offset, wrap ) {
 
 
 			var texture = document.createElement( 'canvas' );
 			var texture = document.createElement( 'canvas' );
 
 
@@ -174,7 +174,7 @@ THREE.Loader.prototype = {
 
 
 		}
 		}
 
 
-		function rgb2hex( rgb ) {
+		function rgb2hex ( rgb ) {
 
 
 			return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
 			return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255;
 
 
@@ -367,7 +367,7 @@ THREE.Loader.prototype = {
 		return material;
 		return material;
 
 
 	},
 	},
-	
+
 	constructor : THREE.Loader
 	constructor : THREE.Loader
 
 
 };
 };

+ 167 - 173
src/extras/loaders/UTF8Loader.js

@@ -21,297 +21,287 @@ THREE.UTF8Loader.prototype = new THREE.UTF8Loader();
 THREE.UTF8Loader.prototype.constructor = THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.constructor = THREE.UTF8Loader;
 
 
 
 
-THREE.UTF8Loader.prototype = {
+// Load UTF8 compressed models generated by objcompress
+//  - parameters
+//		- model (required)
+//		- callback (required)
 
 
-	// Load UTF8 compressed models generated by objcompress
-	//  - parameters
-	//		- model (required)
-	//		- callback (required)
+THREE.UTF8Loader.prototype.load = function( parameters ) {
 
 
-	load: function( parameters ) {
+	var xhr = new XMLHttpRequest(),
+		url = parameters.model,
 
 
-		var xhr = new XMLHttpRequest(),
-			url = parameters.model,
+		callback = parameters.callback,
+		callback_progress = null,
 
 
-			callback = parameters.callback,
-			callback_progress = null,
+		scale = parameters.scale !== undefined ? parameters.scale : 1,
+		offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0,
+		offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0,
+		offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0;
 
 
-			scale = parameters.scale !== undefined ? parameters.scale : 1,
-			offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0,
-			offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0,
-			offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0;
+	var length = 0;
 
 
-		var length = 0;
+	xhr.onreadystatechange = function() {
 
 
-		xhr.onreadystatechange = function() {
+		if ( xhr.readyState == 4 ) {
 
 
-			if ( xhr.readyState == 4 ) {
+			if ( xhr.status == 200 || xhr.status == 0 ) {
 
 
-				if ( xhr.status == 200 || xhr.status == 0 ) {
+				THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ );
 
 
-					THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ );
+			} else {
 
 
-				} else {
+				alert( "Couldn't load [" + url + "] [" + xhr.status + "]" );
 
 
-					alert( "Couldn't load [" + url + "] [" + xhr.status + "]" );
-
-				}
-
-			} else if ( xhr.readyState == 3 ) {
-
-				if ( callback_progress ) {
+			}
 
 
-					if ( length == 0 ) {
+		} else if ( xhr.readyState == 3 ) {
 
 
-						length = xhr.getResponseHeader( "Content-Length" );
+			if ( callback_progress ) {
 
 
-					}
+				if ( length == 0 ) {
 
 
-					callback_progress( { total: length, loaded: xhr.responseText.length } );
+					length = xhr.getResponseHeader( "Content-Length" );
 
 
 				}
 				}
 
 
-			} else if ( xhr.readyState == 2 ) {
-
-				length = xhr.getResponseHeader( "Content-Length" );
+				callback_progress( { total: length, loaded: xhr.responseText.length } );
 
 
 			}
 			}
 
 
-		}
+		} else if ( xhr.readyState == 2 ) {
 
 
-		xhr.open( "GET", url, true );
-		xhr.send( null );
+			length = xhr.getResponseHeader( "Content-Length" );
 
 
-	},
+		}
 
 
-	// UTF-8 decoder from webgl-loader
-	// http://code.google.com/p/webgl-loader/
+	}
 
 
-	// Copyright 2011 Google Inc. All Rights Reserved.
-	//
-	// Licensed under the Apache License, Version 2.0 (the "License"); you
-	// may not use this file except in compliance with the License. You
-	// may obtain a copy of the License at
-	//
-	// http://www.apache.org/licenses/LICENSE-2.0
-	//
-	// Unless required by applicable law or agreed to in writing, software
-	// distributed under the License is distributed on an "AS IS" BASIS,
-	// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-	// implied. See the License for the specific language governing
-	// permissions and limitations under the License.
+	xhr.open( "GET", url, true );
+	xhr.send( null );
 
 
-	decompressMesh: function ( str ) {
+};
 
 
-		var num_verts = str.charCodeAt( 0 );
+// UTF-8 decoder from webgl-loader
+// http://code.google.com/p/webgl-loader/
 
 
-		if ( num_verts >= 0xE000 ) {
+// Copyright 2011 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License"); you
+// may not use this file except in compliance with the License. You
+// may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+// implied. See the License for the specific language governing
+// permissions and limitations under the License.
 
 
-			num_verts -= 0x0800;
+THREE.UTF8Loader.prototype.decompressMesh = function ( str ) {
 
 
-		}
+	var num_verts = str.charCodeAt( 0 );
 
 
-		num_verts ++;
+	if ( num_verts >= 0xE000 ) {
 
 
-		var attribs_out = new Float32Array( 8 * num_verts );
+		num_verts -= 0x0800;
 
 
-		var offset = 1;
+	}
 
 
-		for ( var i = 0; i < 8; i ++ ) {
+	num_verts ++;
 
 
-			var prev_attrib = 0;
+	var attribs_out = new Float32Array( 8 * num_verts );
 
 
-			for ( var j = 0; j < num_verts; ++ j ) {
+	var offset = 1;
 
 
-				var code = str.charCodeAt( j + offset );
+	for ( var i = 0; i < 8; i ++ ) {
 
 
-				prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) );
+		var prev_attrib = 0;
 
 
-				attribs_out[ 8 * j + i ] = prev_attrib;
+		for ( var j = 0; j < num_verts; ++ j ) {
 
 
-			}
+			var code = str.charCodeAt( j + offset );
+
+			prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) );
 
 
-			offset += num_verts;
+			attribs_out[ 8 * j + i ] = prev_attrib;
 
 
 		}
 		}
 
 
-		var num_indices = str.length - offset;
+		offset += num_verts;
 
 
-		var indices_out = new Uint16Array( num_indices );
+	}
 
 
-		var index_high_water_mark = 0;
+	var num_indices = str.length - offset;
 
 
-		for ( var i = 0; i < num_indices; i ++ ) {
+	var indices_out = new Uint16Array( num_indices );
 
 
-			var code = str.charCodeAt( i + offset );
+	var index_high_water_mark = 0;
 
 
-			indices_out[ i ] = index_high_water_mark - code;
+	for ( var i = 0; i < num_indices; i ++ ) {
 
 
-			if ( code == 0 ) {
+		var code = str.charCodeAt( i + offset );
 
 
-				index_high_water_mark ++;
+		indices_out[ i ] = index_high_water_mark - code;
 
 
-			}
+		if ( code == 0 ) {
+
+			index_high_water_mark ++;
 
 
 		}
 		}
 
 
-		return [ attribs_out, indices_out ];
+	}
 
 
-	},
+	return [ attribs_out, indices_out ];
 
 
-	createModel: function ( data, callback, scale, offsetX, offsetY, offsetZ ) {
+};
 
 
-		var Model = function ( texture_path ) {
+THREE.UTF8Loader.prototype.createModel = function ( data, callback, scale, offsetX, offsetY, offsetZ ) {
 
 
-			//var s = (new Date).getTime();
+	var Model = function ( texture_path ) {
 
 
-			var scope = this;
+		//var s = (new Date).getTime();
 
 
-			scope.materials = [];
+		var scope = this;
 
 
-			THREE.Geometry.call( this );
+		scope.materials = [];
 
 
-			var buffers = THREE.UTF8Loader.prototype.decompressMesh( data );
+		THREE.Geometry.call( this );
 
 
-			var normals = [],
-				uvs = [];
+		var buffers = THREE.UTF8Loader.prototype.decompressMesh( data );
 
 
-			init_vertices( buffers[ 0 ], 8, 0 );
-			init_uvs( buffers[ 0 ], 8, 3 );
-			init_normals( buffers[ 0 ], 8, 5 );
+		var normals = [],
+			uvs = [];
 
 
-			init_faces( buffers[ 1 ] );
+		init_vertices( buffers[ 0 ], 8, 0 );
+		init_uvs( buffers[ 0 ], 8, 3 );
+		init_normals( buffers[ 0 ], 8, 5 );
 
 
-			this.computeCentroids();
-			this.computeFaceNormals();
-			//this.computeTangents();
+		init_faces( buffers[ 1 ] );
 
 
-			//var e = (new Date).getTime();
+		this.computeCentroids();
+		this.computeFaceNormals();
+		//this.computeTangents();
 
 
-			//console.log( "utf8 data parse time: " + (e-s) + " ms" );
+		//var e = (new Date).getTime();
 
 
-			function init_vertices( data, stride, offset ) {
+		//console.log( "utf8 data parse time: " + (e-s) + " ms" );
 
 
-				var i, x, y, z,
-					end = data.length;
+		function init_vertices( data, stride, offset ) {
 
 
-				for( i = offset; i < end; i += stride ) {
+			var i, x, y, z,
+				end = data.length;
 
 
-					x = data[ i ];
-					y = data[ i + 1 ];
-					z = data[ i + 2 ];
+			for( i = offset; i < end; i += stride ) {
 
 
-					// fix scale and offsets
+				x = data[ i ];
+				y = data[ i + 1 ];
+				z = data[ i + 2 ];
 
 
-					x = ( x / 16383 ) * scale;
-					y = ( y / 16383 ) * scale;
-					z = ( z / 16383 ) * scale;
+				// fix scale and offsets
 
 
-					x += offsetX;
-					y += offsetY;
-					z += offsetZ;
+				x = ( x / 16383 ) * scale;
+				y = ( y / 16383 ) * scale;
+				z = ( z / 16383 ) * scale;
 
 
-					THREE.UTF8Loader.prototype.v( scope, x, y, z );
+				x += offsetX;
+				y += offsetY;
+				z += offsetZ;
 
 
-				}
+				vertex( scope, x, y, z );
 
 
 			}
 			}
 
 
-			function init_normals( data, stride, offset ) {
+		};
 
 
-				var i, x, y, z,
-					end = data.length;
+		function init_normals( data, stride, offset ) {
 
 
-				for( i = offset; i < end; i += stride ) {
+			var i, x, y, z,
+				end = data.length;
 
 
-					x = data[ i ];
-					y = data[ i + 1 ];
-					z = data[ i + 2 ];
+			for( i = offset; i < end; i += stride ) {
 
 
-					// normalize to <-1,1>
+				x = data[ i ];
+				y = data[ i + 1 ];
+				z = data[ i + 2 ];
 
 
-					x = ( x - 512 ) / 511;
-					y = ( y - 512 ) / 511;
-					z = ( z - 512 ) / 511;
+				// normalize to <-1,1>
 
 
-					normals.push( x, y, z );
+				x = ( x - 512 ) / 511;
+				y = ( y - 512 ) / 511;
+				z = ( z - 512 ) / 511;
 
 
-				}
+				normals.push( x, y, z );
 
 
 			}
 			}
 
 
-			function init_uvs( data, stride, offset ) {
+		};
 
 
-				var i, u, v,
-					end = data.length;
+		function init_uvs( data, stride, offset ) {
 
 
-				for( i = offset; i < end; i += stride ) {
+			var i, u, v,
+				end = data.length;
 
 
-					u = data[ i ];
-					v = data[ i + 1 ];
+			for( i = offset; i < end; i += stride ) {
 
 
-					// normalize to <0,1>
+				u = data[ i ];
+				v = data[ i + 1 ];
 
 
-					u /= 1023;
-					v /= 1023;
+				// normalize to <0,1>
 
 
-					uvs.push( u, v );
+				u /= 1023;
+				v /= 1023;
 
 
-				}
+				uvs.push( u, v );
 
 
 			}
 			}
 
 
-			function init_faces( indices ) {
-
-				var i,
-					a, b, c,
-					u1, v1, u2, v2, u3, v3,
-					m,
-					end = indices.length;
+		};
 
 
-				m = 0; // all faces defaulting to material 0
+		function init_faces( indices ) {
 
 
-				for( i = 0; i < end; i += 3 ) {
+			var i,
+				a, b, c,
+				u1, v1, u2, v2, u3, v3,
+				m,
+				end = indices.length;
 
 
-					a = indices[ i ];
-					b = indices[ i + 1 ];
-					c = indices[ i + 2 ];
+			m = 0; // all faces defaulting to material 0
 
 
-					THREE.UTF8Loader.prototype.f3n( scope, normals, a, b, c, m, a, b, c );
+			for( i = 0; i < end; i += 3 ) {
 
 
-					u1 = uvs[ a * 2 ];
-					v1 = uvs[ a * 2 + 1 ];
+				a = indices[ i ];
+				b = indices[ i + 1 ];
+				c = indices[ i + 2 ];
 
 
-					u2 = uvs[ b * 2 ];
-					v2 = uvs[ b * 2 + 1 ];
+				f3n( scope, normals, a, b, c, m, a, b, c );
 
 
-					u3 = uvs[ c * 2 ];
-					v3 = uvs[ c * 2 + 1 ];
+				u1 = uvs[ a * 2 ];
+				v1 = uvs[ a * 2 + 1 ];
 
 
-					THREE.UTF8Loader.prototype.uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 );
+				u2 = uvs[ b * 2 ];
+				v2 = uvs[ b * 2 + 1 ];
 
 
-				}
+				u3 = uvs[ c * 2 ];
+				v3 = uvs[ c * 2 + 1 ];
 
 
+				uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 );
 
 
 			}
 			}
 
 
-		}
-
-		Model.prototype = new THREE.Geometry();
-		Model.prototype.constructor = Model;
-
-		callback( new Model() );
 
 
-	},
+		}
 
 
+	};
 
 
-	v: function( scope, x, y, z ) {
+	function vertex ( scope, x, y, z ) {
 
 
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
 
 
-	},
+	};
 
 
-	f3n: function( scope, normals, a, b, c, mi, na, nb, nc ) {
+	function f3n ( scope, normals, a, b, c, mi, na, nb, nc ) {
 
 
 		var material = scope.materials[ mi ],
 		var material = scope.materials[ mi ],
 
 
@@ -333,9 +323,9 @@ THREE.UTF8Loader.prototype = {
 
 
 		scope.faces.push( new THREE.Face3( a, b, c, [ na, nb, nc ], null, material ) );
 		scope.faces.push( new THREE.Face3( a, b, c, [ na, nb, nc ], null, material ) );
 
 
-	},
+	};
 
 
-	uv3: function( where, u1, v1, u2, v2, u3, v3 ) {
+	function uv3 ( where, u1, v1, u2, v2, u3, v3 ) {
 
 
 		var uv = [];
 		var uv = [];
 		uv.push( new THREE.UV( u1, v1 ) );
 		uv.push( new THREE.UV( u1, v1 ) );
@@ -343,8 +333,12 @@ THREE.UTF8Loader.prototype = {
 		uv.push( new THREE.UV( u3, v3 ) );
 		uv.push( new THREE.UV( u3, v3 ) );
 		where.push( uv );
 		where.push( uv );
 
 
-	},
+	};
+
+
+	Model.prototype = new THREE.Geometry();
+	Model.prototype.constructor = Model;
 
 
-	constructor : THREE.UTF8Loader
+	callback( new Model() );
 
 
 };
 };

+ 16 - 12
src/renderers/Projector.js

@@ -12,6 +12,8 @@ THREE.Projector = function() {
 	_line, _lineCount, _linePool = [],
 	_line, _lineCount, _linePool = [],
 	_particle, _particleCount, _particlePool = [],
 	_particle, _particleCount, _particlePool = [],
 
 
+	_objectList = [], _renderList = [],
+
 	_vector3 = new THREE.Vector4(),
 	_vector3 = new THREE.Vector4(),
 	_vector4 = new THREE.Vector4(),
 	_vector4 = new THREE.Vector4(),
 	_projScreenMatrix = new THREE.Matrix4(),
 	_projScreenMatrix = new THREE.Matrix4(),
@@ -52,9 +54,9 @@ THREE.Projector = function() {
 
 
 	this.projectObjects = function ( scene, camera, sort ) {
 	this.projectObjects = function ( scene, camera, sort ) {
 
 
-		var renderList = [],
-		o, ol, objects, object, matrix;
+		var o, ol, objects, object, matrix;
 
 
+		_objectList.length = 0;
 		_objectCount = 0;
 		_objectCount = 0;
 
 
 		objects = scene.objects;
 		objects = scene.objects;
@@ -63,7 +65,7 @@ THREE.Projector = function() {
 
 
 			object = objects[ o ];
 			object = objects[ o ];
 
 
-			if ( !object.visible || ( object instanceof THREE.Mesh && !isInFrustum( object ) ) ) continue;
+			if ( !object.visible || ( object instanceof THREE.Mesh && !( object.frustumCulled && isInFrustum( object ) ) ) ) continue;
 
 
 			_object = getNextObjectInPool();
 			_object = getNextObjectInPool();
 
 
@@ -73,13 +75,13 @@ THREE.Projector = function() {
 			_object.object = object;
 			_object.object = object;
 			_object.z = _vector3.z;
 			_object.z = _vector3.z;
 
 
-			renderList.push( _object );
+			_objectList.push( _object );
 
 
 		}
 		}
 
 
-		sort && renderList.sort( painterSort );
+		sort && _objectList.sort( painterSort );
 
 
-		return renderList;
+		return _objectList;
 
 
 	};
 	};
 
 
@@ -87,13 +89,15 @@ THREE.Projector = function() {
 
 
 	this.projectScene = function ( scene, camera, sort ) {
 	this.projectScene = function ( scene, camera, sort ) {
 
 
-		var renderList = [], near = camera.near, far = camera.far,
+		var near = camera.near, far = camera.far,
 		o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object,
 		o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, objects, object,
 		objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw,
 		objectMatrix, objectMatrixRotation, objectMaterials, objectOverdraw,
 		geometry, vertices, vertex, vertexPositionScreen,
 		geometry, vertices, vertex, vertexPositionScreen,
 		faces, face, faceVertexNormals, normal, faceVertexUvs, uvs,
 		faces, face, faceVertexNormals, normal, faceVertexUvs, uvs,
 		v1, v2, v3, v4;
 		v1, v2, v3, v4;
 
 
+		_renderList.length = 0;
+
 		_face3Count = 0;
 		_face3Count = 0;
 		_face4Count = 0;
 		_face4Count = 0;
 		_lineCount = 0;
 		_lineCount = 0;
@@ -241,7 +245,7 @@ THREE.Projector = function() {
 
 
 					_face.z = _face.centroidScreen.z;
 					_face.z = _face.centroidScreen.z;
 
 
-					renderList.push( _face );
+					_renderList.push( _face );
 
 
 				}
 				}
 
 
@@ -280,7 +284,7 @@ THREE.Projector = function() {
 
 
 						_line.materials = object.materials;
 						_line.materials = object.materials;
 
 
-						renderList.push( _line );
+						_renderList.push( _line );
 
 
 					}
 					}
 				}
 				}
@@ -306,7 +310,7 @@ THREE.Projector = function() {
 
 
 					_particle.materials = object.materials;
 					_particle.materials = object.materials;
 
 
-					renderList.push( _particle );
+					_renderList.push( _particle );
 
 
 				}
 				}
 
 
@@ -314,9 +318,9 @@ THREE.Projector = function() {
 
 
 		}
 		}
 
 
-		sort && renderList.sort( painterSort );
+		sort && _renderList.sort( painterSort );
 
 
-		return renderList;
+		return _renderList;
 
 
 	};
 	};
 
 

+ 23 - 0
src/renderers/WebGLRenderTarget.js

@@ -25,3 +25,26 @@ THREE.WebGLRenderTarget = function ( width, height, options ) {
 	this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
 	this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;
 
 
 };
 };
+
+THREE.WebGLRenderTarget.prototype.clone = function() {
+
+	var tmp = new THREE.WebGLRenderTarget( this.width, this.height );
+
+	tmp.wrapS = this.wrapS;
+	tmp.wrapT = this.wrapT;
+
+	tmp.magFilter = this.magFilter;
+	tmp.minFilter = this.minFilter;
+
+	tmp.offset.copy( this.offset );
+	tmp.repeat.copy( this.repeat );
+
+	tmp.format = this.format;
+	tmp.type = this.type;
+
+	tmp.depthBuffer = this.depthBuffer;
+	tmp.stencilBuffer = this.stencilBuffer;
+
+	return tmp;
+
+};

+ 204 - 71
src/renderers/WebGLRenderer.js

@@ -138,6 +138,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	_gl.clearColor( 0, 0, 0, 1 );
 	_gl.clearColor( 0, 0, 0, 1 );
 	_gl.clearDepth( 1 );
 	_gl.clearDepth( 1 );
+	_gl.clearStencil( 0 );
 
 
 	_gl.enable( _gl.DEPTH_TEST );
 	_gl.enable( _gl.DEPTH_TEST );
 	_gl.depthFunc( _gl.LEQUAL );
 	_gl.depthFunc( _gl.LEQUAL );
@@ -289,12 +290,59 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	this.getContext = function() {
+	this.getContext = function () {
 
 
 		return _gl;
 		return _gl;
 
 
 	};
 	};
 
 
+	this.deallocateObject = function ( object ) {
+
+		if ( ! object.__webglInit ) return;
+
+		object.__webglInit = false;
+
+		delete object._modelViewMatrix;
+
+		delete object._normalMatrixArray;
+		delete object._modelViewMatrixArray;
+		delete object._objectMatrixArray;
+
+		if ( object instanceof THREE.Mesh ) {
+
+			for ( g in object.geometry.geometryGroups ) {
+
+				deleteMeshBuffers( object.geometry.geometryGroups[ g ] );
+
+			}
+
+		} else if ( object instanceof THREE.Ribbon ) {
+
+			deleteRibbonBuffers( object.geometry );
+
+		} else if ( object instanceof THREE.Line ) {
+
+			deleteLineBuffers( object.geometry );
+
+		} else if ( object instanceof THREE.ParticleSystem ) {
+
+			deleteParticleBuffers( object.geometry );
+
+		}
+
+	};
+
+	this.deallocateTexture = function ( texture ) {
+
+		if ( ! texture.__webglInit ) return;
+
+		texture.__webglInit = false;
+		_gl.deleteTexture( texture.__webglTexture );
+
+	};
+
+	//
+
 	function setupLights ( program, lights ) {
 	function setupLights ( program, lights ) {
 
 
 		var l, ll, light, n,
 		var l, ll, light, n,
@@ -396,7 +444,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
-	function createParticleBuffers ( geometry ) {
+	// Buffer allocation
+
+	function createParticleBuffers( geometry ) {
 
 
 		geometry.__webglVertexBuffer = _gl.createBuffer();
 		geometry.__webglVertexBuffer = _gl.createBuffer();
 		geometry.__webglColorBuffer = _gl.createBuffer();
 		geometry.__webglColorBuffer = _gl.createBuffer();
@@ -450,6 +500,60 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	// Buffer deallocation
+
+	function deleteParticleBuffers( geometry ) {
+
+		_gl.deleteBuffer( geometry.__webglVertexBuffer );
+		_gl.deleteBuffer( geometry.__webglColorBuffer );
+
+	};
+
+	function deleteLineBuffers( geometry ) {
+
+		_gl.deleteBuffer( geometry.__webglVertexBuffer );
+		_gl.deleteBuffer( geometry.__webglColorBuffer );
+
+	};
+
+	function deleteRibbonBuffers( geometry ) {
+
+		_gl.deleteBuffer( geometry.__webglVertexBuffer );
+		_gl.deleteBuffer( geometry.__webglColorBuffer );
+
+	};
+
+	function deleteMeshBuffers( geometryGroup ) {
+
+		_gl.deleteBuffer( geometryGroup.__webglVertexBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglNormalBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglTangentBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglColorBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglUVBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglUV2Buffer );
+
+		_gl.deleteBuffer( geometryGroup.__webglSkinVertexABuffer );
+		_gl.deleteBuffer( geometryGroup.__webglSkinVertexBBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglSkinIndicesBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglSkinWeightsBuffer );
+
+		_gl.deleteBuffer( geometryGroup.__webglFaceBuffer );
+		_gl.deleteBuffer( geometryGroup.__webglLineBuffer );
+
+		if ( geometryGroup.numMorphTargets ) {
+
+			for ( var m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
+
+				_gl.deleteBuffer( geometryGroup.__webglMorphTargetsBuffers[ m ] );
+
+			}
+
+		}
+
+	};
+
+	//
+
 	function initLineBuffers ( geometry ) {
 	function initLineBuffers ( geometry ) {
 
 
 		var nvertices = geometry.vertices.length;
 		var nvertices = geometry.vertices.length;
@@ -3360,7 +3464,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 					if ( object.visible && object.castShadow ) {
 					if ( object.visible && object.castShadow ) {
 
 
-						if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) {
+						if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || isInFrustum( object ) ) {
 
 
 							object.matrixWorld.flattenToArray( object._objectMatrixArray );
 							object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
@@ -3453,6 +3557,20 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 	};
 	};
 
 
+	this.clearTarget = function ( renderTarget, colorBit, depthBit, stencilBit ) {
+
+		setRenderTarget( renderTarget );
+
+		var bits = 0;
+
+		if ( colorBit ) bits |= _gl.COLOR_BUFFER_BIT;
+		if ( depthBit ) bits |= _gl.DEPTH_BUFFER_BIT;
+		if ( stencilBit ) bits |= _gl.STENCIL_BUFFER_BIT;
+
+		_gl.clear( bits );
+
+	};
+
 	this.render = function( scene, camera, renderTarget, forceClear ) {
 	this.render = function( scene, camera, renderTarget, forceClear ) {
 
 
 		var i, program, opaque, transparent, material,
 		var i, program, opaque, transparent, material,
@@ -3497,7 +3615,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			if ( object.visible ) {
 			if ( object.visible ) {
 
 
-				if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) {
+				if ( ! ( object instanceof THREE.Mesh ) || ! ( object.frustumCulled ) || isInFrustum( object ) ) {
 
 
 					object.matrixWorld.flattenToArray( object._objectMatrixArray );
 					object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
@@ -3951,7 +4069,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		var g, geometry, geometryGroup;
 		var g, geometry, geometryGroup;
 
 
-		if ( object._modelViewMatrix == undefined ) {
+		if ( ! object.__webglInit ) {
+
+			object.__webglInit = true;
 
 
 			object._modelViewMatrix = new THREE.Matrix4();
 			object._modelViewMatrix = new THREE.Matrix4();
 
 
@@ -3961,106 +4081,107 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			object.matrixWorld.flattenToArray( object._objectMatrixArray );
 			object.matrixWorld.flattenToArray( object._objectMatrixArray );
 
 
-		}
 
 
-		if ( object instanceof THREE.Mesh ) {
+			if ( object instanceof THREE.Mesh ) {
 
 
-			geometry = object.geometry;
+				geometry = object.geometry;
 
 
-			if ( geometry.geometryGroups == undefined ) {
+				if ( geometry.geometryGroups == undefined ) {
 
 
-				sortFacesByMaterial( geometry );
+					sortFacesByMaterial( geometry );
 
 
-			}
+				}
 
 
-			// create separate VBOs per geometry chunk
+				// create separate VBOs per geometry chunk
 
 
-			for ( g in geometry.geometryGroups ) {
+				for ( g in geometry.geometryGroups ) {
 
 
-				geometryGroup = geometry.geometryGroups[ g ];
+					geometryGroup = geometry.geometryGroups[ g ];
 
 
-				// initialise VBO on the first access
+					// initialise VBO on the first access
 
 
-				if ( ! geometryGroup.__webglVertexBuffer ) {
+					if ( ! geometryGroup.__webglVertexBuffer ) {
 
 
-					createMeshBuffers( geometryGroup );
-					initMeshBuffers( geometryGroup, object );
+						createMeshBuffers( geometryGroup );
+						initMeshBuffers( geometryGroup, object );
 
 
-					geometry.__dirtyVertices = true;
-					geometry.__dirtyMorphTargets = true;
-					geometry.__dirtyElements = true;
-					geometry.__dirtyUvs = true;
-					geometry.__dirtyNormals = true;
-					geometry.__dirtyTangents = true;
-					geometry.__dirtyColors = true;
+						geometry.__dirtyVertices = true;
+						geometry.__dirtyMorphTargets = true;
+						geometry.__dirtyElements = true;
+						geometry.__dirtyUvs = true;
+						geometry.__dirtyNormals = true;
+						geometry.__dirtyTangents = true;
+						geometry.__dirtyColors = true;
 
 
-				}
+					}
 
 
-				addBuffer( scene.__webglObjects, geometryGroup, object );
+					addBuffer( scene.__webglObjects, geometryGroup, object );
 
 
-			}
+				}
 
 
-		} else if ( object instanceof THREE.Ribbon ) {
+			} else if ( object instanceof THREE.Ribbon ) {
 
 
-			geometry = object.geometry;
+				geometry = object.geometry;
 
 
-			if( ! geometry.__webglVertexBuffer ) {
+				if( ! geometry.__webglVertexBuffer ) {
 
 
-				createRibbonBuffers( geometry );
-				initRibbonBuffers( geometry );
+					createRibbonBuffers( geometry );
+					initRibbonBuffers( geometry );
 
 
-				geometry.__dirtyVertices = true;
-				geometry.__dirtyColors = true;
+					geometry.__dirtyVertices = true;
+					geometry.__dirtyColors = true;
 
 
-			}
+				}
 
 
-			addBuffer( scene.__webglObjects, geometry, object );
+				addBuffer( scene.__webglObjects, geometry, object );
 
 
-		} else if ( object instanceof THREE.Line ) {
+			} else if ( object instanceof THREE.Line ) {
 
 
-			geometry = object.geometry;
+				geometry = object.geometry;
+
+				if( ! geometry.__webglVertexBuffer ) {
 
 
-			if( ! geometry.__webglVertexBuffer ) {
+					createLineBuffers( geometry );
+					initLineBuffers( geometry );
 
 
-				createLineBuffers( geometry );
-				initLineBuffers( geometry );
+					geometry.__dirtyVertices = true;
+					geometry.__dirtyColors = true;
 
 
-				geometry.__dirtyVertices = true;
-				geometry.__dirtyColors = true;
+				}
 
 
-			}
+				addBuffer( scene.__webglObjects, geometry, object );
 
 
-			addBuffer( scene.__webglObjects, geometry, object );
+			} else if ( object instanceof THREE.ParticleSystem ) {
 
 
-		} else if ( object instanceof THREE.ParticleSystem ) {
+				geometry = object.geometry;
 
 
-			geometry = object.geometry;
+				if ( ! geometry.__webglVertexBuffer ) {
 
 
-			if ( ! geometry.__webglVertexBuffer ) {
+					createParticleBuffers( geometry );
+					initParticleBuffers( geometry, object );
 
 
-				createParticleBuffers( geometry );
-				initParticleBuffers( geometry, object );
+					geometry.__dirtyVertices = true;
+					geometry.__dirtyColors = true;
 
 
-				geometry.__dirtyVertices = true;
-				geometry.__dirtyColors = true;
+				}
 
 
-			}
+				addBuffer( scene.__webglObjects, geometry, object );
 
 
-			addBuffer( scene.__webglObjects, geometry, object );
+			} else if ( THREE.MarchingCubes !== undefined && object instanceof THREE.MarchingCubes ) {
 
 
-		} else if ( THREE.MarchingCubes !== undefined && object instanceof THREE.MarchingCubes ) {
+				addBufferImmediate( scene.__webglObjectsImmediate, object );
 
 
-			addBufferImmediate( scene.__webglObjectsImmediate, object );
+			} else if ( object instanceof THREE.Sprite ) {
 
 
-		} else if ( object instanceof THREE.Sprite ) {
+				scene.__webglSprites.push( object );
 
 
-			scene.__webglSprites.push( object );
+			}
 
 
-		}
+			/*else if ( object instanceof THREE.Particle ) {
 
 
-		/*else if ( object instanceof THREE.Particle ) {
+			}*/
 
 
-		}*/
+		}
 
 
 	};
 	};
 
 
@@ -4086,7 +4207,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-
 		return false;
 		return false;
 
 
 	};
 	};
@@ -4125,9 +4245,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			// check all geometry groups
 			// check all geometry groups
 
 
-			for ( g in geometry.geometryGroups ) {
+			for( var i = 0, il = geometry.geometryGroupsList.length; i < il; i ++ ) {
 
 
-				geometryGroup = geometry.geometryGroups[ g ];
+				geometryGroup = geometry.geometryGroupsList[ i ];
 
 
 				customAttributeDirty = areCustomAttributesDirty( geometryGroup );
 				customAttributeDirty = areCustomAttributesDirty( geometryGroup );
 
 
@@ -4279,7 +4399,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			var hash_array = [];
 			var hash_array = [];
 
 
-			for ( i = 0, l = material.length; i < l; i++ ) {
+			for ( i = 0, l = material.length; i < l; i ++ ) {
 
 
 				if ( material[ i ] == undefined ) {
 				if ( material[ i ] == undefined ) {
 
 
@@ -4297,7 +4417,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
-		for ( f = 0, fl = geometry.faces.length; f < fl; f++ ) {
+		for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
 
 
 			face = geometry.faces[ f ];
 			face = geometry.faces[ f ];
 			materials = face.materials;
 			materials = face.materials;
@@ -4338,6 +4458,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 		}
 		}
 
 
+		geometry.geometryGroupsList = [];
+
+		for ( var g in geometry.geometryGroups ) {
+
+			geometry.geometryGroupsList.push( geometry.geometryGroups[ g ] );
+
+		}
+
 	};
 	};
 
 
 	function addBuffer( objlist, buffer, object ) {
 	function addBuffer( objlist, buffer, object ) {
@@ -4634,7 +4762,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 	function loadUniformsMatrices( uniforms, object ) {
 	function loadUniformsMatrices( uniforms, object ) {
 
 
 		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
 		_gl.uniformMatrix4fv( uniforms.modelViewMatrix, false, object._modelViewMatrixArray );
-		_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray );
+
+		if ( uniforms.normalMatrix ) {
+
+			_gl.uniformMatrix3fv( uniforms.normalMatrix, false, object._normalMatrixArray );
+
+		}
 
 
 	};
 	};
 
 
@@ -4888,8 +5021,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 
 			if ( ! texture.__webglInit ) {
 			if ( ! texture.__webglInit ) {
 
 
-				texture.__webglTexture = _gl.createTexture();
 				texture.__webglInit = true;
 				texture.__webglInit = true;
+				texture.__webglTexture = _gl.createTexture();
 
 
 			}
 			}
 
 
@@ -5294,13 +5427,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 			material, meshMaterial,
 			material, meshMaterial,
 			materials = [];
 			materials = [];
 
 
-		for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
+		for ( m = 0, ml = object.materials.length; m < ml; m ++ ) {
 
 
 			meshMaterial = object.materials[ m ];
 			meshMaterial = object.materials[ m ];
 
 
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 
 
-				for ( i = 0, l = geometryGroup.materials.length; i < l; i++ ) {
+				for ( i = 0, l = geometryGroup.materials.length; i < l; i ++ ) {
 
 
 					material = geometryGroup.materials[ i ];
 					material = geometryGroup.materials[ i ];
 
 

+ 1 - 1
src/renderers/WebGLShaders.js

@@ -1428,7 +1428,7 @@ THREE.ShaderLib = {
 
 
 				"#endif",
 				"#endif",
 
 
-				"vViewPosition = cameraPosition - mPosition.xyz;",
+				"vViewPosition = -mvPosition.xyz;",
 
 
 				"vec3 transformedNormal = normalize( normalMatrix * normal );",
 				"vec3 transformedNormal = normalize( normalMatrix * normal );",
 				"vNormal = transformedNormal;",
 				"vNormal = transformedNormal;",

+ 5 - 9
src/textures/DataTexture.js

@@ -15,17 +15,13 @@ THREE.DataTexture = function ( data, width, height, format, mapping, wrapS, wrap
 THREE.DataTexture.prototype = new THREE.Texture();
 THREE.DataTexture.prototype = new THREE.Texture();
 THREE.DataTexture.prototype.constructor = THREE.DataTexture;
 THREE.DataTexture.prototype.constructor = THREE.DataTexture;
 
 
-THREE.DataTexture.prototype = {
+THREE.DataTexture.prototype.clone = function () {
 
 
-	clone: function () {
+	var clonedTexture = new THREE.DataTexture( this.data.slice( 0 ), this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter );
 
 
-		var clonedTexture = new THREE.DataTexture( this.data.slice( 0 ), this.mapping, this.wrapS, this.wrapT, this.magFilter, this.minFilter );
+	clonedTexture.offset.copy( this.offset );
+	clonedTexture.repeat.copy( this.repeat );
 
 
-		clonedTexture.offset.copy( this.offset );
-		clonedTexture.repeat.copy( this.repeat );
-
-		return clonedTexture;
-
-	}
+	return clonedTexture;
 
 
 };
 };

+ 12 - 11
utils/build.py

@@ -22,6 +22,7 @@ COMMON_FILES = [
 'core/Matrix3.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Matrix4.js',
 'core/Object3D.js',
 'core/Object3D.js',
+'core/Projector.js',
 'core/Quaternion.js',
 'core/Quaternion.js',
 'core/Vertex.js',
 'core/Vertex.js',
 'core/Face3.js',
 'core/Face3.js',
@@ -63,7 +64,6 @@ COMMON_FILES = [
 'scenes/Scene.js',
 'scenes/Scene.js',
 'scenes/Fog.js',
 'scenes/Fog.js',
 'scenes/FogExp2.js',
 'scenes/FogExp2.js',
-'renderers/Projector.js',
 'renderers/DOMRenderer.js',
 'renderers/DOMRenderer.js',
 'renderers/CanvasRenderer.js',
 'renderers/CanvasRenderer.js',
 'renderers/SVGRenderer.js',
 'renderers/SVGRenderer.js',
@@ -85,6 +85,11 @@ EXTRAS_FILES = [
 'extras/ImageUtils.js',
 'extras/ImageUtils.js',
 'extras/SceneUtils.js',
 'extras/SceneUtils.js',
 'extras/ShaderUtils.js',
 'extras/ShaderUtils.js',
+'extras/core/Curve.js',
+'extras/core/CurvePath.js',
+'extras/core/Path.js',
+'extras/core/Shape.js',
+'extras/core/TextPath.js',
 'extras/animation/AnimationHandler.js',
 'extras/animation/AnimationHandler.js',
 'extras/animation/Animation.js',
 'extras/animation/Animation.js',
 'extras/cameras/FirstPersonCamera.js',
 'extras/cameras/FirstPersonCamera.js',
@@ -93,11 +98,6 @@ EXTRAS_FILES = [
 'extras/cameras/RollCamera.js',
 'extras/cameras/RollCamera.js',
 'extras/cameras/TrackballCamera.js',
 'extras/cameras/TrackballCamera.js',
 'extras/cameras/QuakeCamera.js',
 'extras/cameras/QuakeCamera.js',
-'extras/geometries/Curve.js',
-'extras/geometries/CurvePath.js',
-'extras/geometries/Path.js',
-'extras/geometries/Shape.js',
-'extras/geometries/TextPath.js',
 'extras/geometries/CubeGeometry.js',
 'extras/geometries/CubeGeometry.js',
 'extras/geometries/CylinderGeometry.js',
 'extras/geometries/CylinderGeometry.js',
 'extras/geometries/ExtrudeGeometry.js',
 'extras/geometries/ExtrudeGeometry.js',
@@ -109,8 +109,9 @@ EXTRAS_FILES = [
 'extras/geometries/TorusGeometry.js',
 'extras/geometries/TorusGeometry.js',
 'extras/geometries/TorusKnotGeometry.js',
 'extras/geometries/TorusKnotGeometry.js',
 'extras/loaders/Loader.js',
 'extras/loaders/Loader.js',
-'extras/loaders/JSONLoader.js',
 'extras/loaders/BinaryLoader.js',
 'extras/loaders/BinaryLoader.js',
+'extras/loaders/ColladaLoader.js',
+'extras/loaders/JSONLoader.js',
 'extras/loaders/SceneLoader.js',
 'extras/loaders/SceneLoader.js',
 'extras/loaders/UTF8Loader.js',
 'extras/loaders/UTF8Loader.js',
 'extras/objects/MarchingCubes.js',
 'extras/objects/MarchingCubes.js',
@@ -132,6 +133,7 @@ CANVAS_FILES = [
 'core/Matrix3.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Matrix4.js',
 'core/Object3D.js',
 'core/Object3D.js',
+'core/Projector.js',
 'core/Quaternion.js',
 'core/Quaternion.js',
 'core/Vertex.js',
 'core/Vertex.js',
 'core/Face3.js',
 'core/Face3.js',
@@ -160,7 +162,6 @@ CANVAS_FILES = [
 'objects/Mesh.js',
 'objects/Mesh.js',
 'objects/Bone.js',
 'objects/Bone.js',
 'scenes/Scene.js',
 'scenes/Scene.js',
-'renderers/Projector.js',
 'renderers/CanvasRenderer.js',
 'renderers/CanvasRenderer.js',
 'renderers/renderables/RenderableVertex.js',
 'renderers/renderables/RenderableVertex.js',
 'renderers/renderables/RenderableFace3.js',
 'renderers/renderables/RenderableFace3.js',
@@ -181,6 +182,7 @@ DOM_FILES = [
 'core/Matrix3.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Matrix4.js',
 'core/Object3D.js',
 'core/Object3D.js',
+'core/Projector.js',
 'core/Quaternion.js',
 'core/Quaternion.js',
 'core/Vertex.js',
 'core/Vertex.js',
 'core/Face3.js',
 'core/Face3.js',
@@ -192,7 +194,6 @@ DOM_FILES = [
 'objects/Particle.js',
 'objects/Particle.js',
 'objects/Bone.js',
 'objects/Bone.js',
 'scenes/Scene.js',
 'scenes/Scene.js',
-'renderers/Projector.js',
 'renderers/DOMRenderer.js',
 'renderers/DOMRenderer.js',
 'renderers/renderables/RenderableParticle.js'
 'renderers/renderables/RenderableParticle.js'
 ]
 ]
@@ -208,6 +209,7 @@ SVG_FILES = [
 'core/Matrix3.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Matrix4.js',
 'core/Object3D.js',
 'core/Object3D.js',
+'core/Projector.js',
 'core/Quaternion.js',
 'core/Quaternion.js',
 'core/Vertex.js',
 'core/Vertex.js',
 'core/Face3.js',
 'core/Face3.js',
@@ -234,7 +236,6 @@ SVG_FILES = [
 'objects/Mesh.js',
 'objects/Mesh.js',
 'objects/Bone.js',
 'objects/Bone.js',
 'scenes/Scene.js',
 'scenes/Scene.js',
-'renderers/Projector.js',
 'renderers/SVGRenderer.js',
 'renderers/SVGRenderer.js',
 'renderers/renderables/RenderableVertex.js',
 'renderers/renderables/RenderableVertex.js',
 'renderers/renderables/RenderableFace3.js',
 'renderers/renderables/RenderableFace3.js',
@@ -255,6 +256,7 @@ WEBGL_FILES = [
 'core/Matrix3.js',
 'core/Matrix3.js',
 'core/Matrix4.js',
 'core/Matrix4.js',
 'core/Object3D.js',
 'core/Object3D.js',
+'core/Projector.js',
 'core/Quaternion.js',
 'core/Quaternion.js',
 'core/Vertex.js',
 'core/Vertex.js',
 'core/Face3.js',
 'core/Face3.js',
@@ -293,7 +295,6 @@ WEBGL_FILES = [
 'scenes/Scene.js',
 'scenes/Scene.js',
 'scenes/Fog.js',
 'scenes/Fog.js',
 'scenes/FogExp2.js',
 'scenes/FogExp2.js',
-'renderers/Projector.js',
 'renderers/WebGLShaders.js',
 'renderers/WebGLShaders.js',
 'renderers/WebGLRenderer.js',
 'renderers/WebGLRenderer.js',
 'renderers/WebGLRenderTarget.js',
 'renderers/WebGLRenderTarget.js',

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است