From 76e7ea3461e4f19643aa0f580bb24da9d77865c3 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 9 Apr 2011 12:38:39 +0100 Subject: [PATCH] Added namespace to all the objects that missed it (geometries, uniforms, etc) WebGLRenderer antialias is off by default (considering Firefox doesn't support it...) Formatting clean up here and there --- README.md | 2 +- build/Three.js | 564 +++++++------- build/custom/ThreeCanvas.js | 2 +- build/custom/ThreeDOM.js | 2 +- build/custom/ThreeExtras.js | 63 +- build/custom/ThreeSVG.js | 2 +- build/custom/ThreeWebGL.js | 196 ++--- examples/canvas_camera_orthographic.html | 2 +- examples/canvas_geometry_cube.html | 4 +- examples/canvas_geometry_earth.html | 4 +- examples/canvas_geometry_hierarchy.html | 4 +- examples/canvas_geometry_panorama.html | 2 +- .../canvas_geometry_panorama_fisheye.html | 2 +- examples/canvas_geometry_terrain.html | 2 +- examples/canvas_interactive_cubes.html | 2 +- examples/canvas_interactive_cubes_tween.html | 2 +- examples/canvas_interactive_voxelpainter.html | 6 +- examples/canvas_materials.html | 8 +- examples/canvas_materials_depth.html | 5 +- examples/canvas_materials_reflection.html | 2 +- examples/canvas_materials_video.html | 2 +- examples/canvas_performance.html | 2 +- examples/canvas_sandbox.html | 4 +- examples/misc_lights_test.html | 2 +- examples/misc_lookat.html | 4 +- examples/misc_materials_multimaterials.html | 29 +- examples/misc_sound.html | 26 +- examples/misc_ubiquity_test.html | 9 +- examples/webgl_collisions_box.html | 50 +- examples/webgl_collisions_primitives.html | 86 +-- examples/webgl_collisions_reaction.html | 90 +-- examples/webgl_collisions_terrain.html | 62 +- examples/webgl_collisions_trigger.html | 85 +- examples/webgl_geometries.html | 18 +- .../webgl_geometry_blenderexport_colors.html | 6 +- examples/webgl_geometry_colors.html | 32 +- examples/webgl_geometry_dynamic.html | 12 +- examples/webgl_geometry_hierarchy.html | 4 +- examples/webgl_geometry_hierarchy2.html | 4 +- examples/webgl_geometry_large_mesh.html | 14 +- examples/webgl_geometry_minecraft.html | 28 +- examples/webgl_geometry_minecraft_ao.html | 18 +- examples/webgl_geometry_terrain.html | 12 +- examples/webgl_geometry_terrain_fog.html | 12 +- examples/webgl_hdr.html | 4 +- examples/webgl_interactive_voxelpainter.html | 10 +- examples/webgl_lights_pointlights.html | 2 +- examples/webgl_lines_colors.html | 18 +- examples/webgl_lines_splines.html | 12 +- examples/webgl_lod.html | 22 +- examples/webgl_materials.html | 8 +- examples/webgl_materials_cars.html | 6 +- examples/webgl_materials_cars_camaro.html | 36 +- examples/webgl_materials_cubemap.html | 18 +- ...gl_materials_cubemap_balls_reflection.html | 10 +- ...gl_materials_cubemap_balls_refraction.html | 11 +- examples/webgl_materials_cubemap_escher.html | 6 +- .../webgl_materials_cubemap_refraction.html | 14 +- examples/webgl_materials_grass.html | 4 +- examples/webgl_materials_normalmap.html | 22 +- examples/webgl_materials_normalmap2.html | 12 +- examples/webgl_materials_shaders.html | 14 +- examples/webgl_materials_shaders_fresnel.html | 13 +- examples/webgl_materials_texture_filters.html | 79 +- examples/webgl_materials_video.html | 18 +- examples/webgl_morphtargets.html | 40 +- examples/webgl_objconvert_test.html | 18 +- examples/webgl_panorama_equirectangular.html | 2 +- examples/webgl_particles_billboards.html | 4 +- .../webgl_particles_billboards_colors.html | 4 +- examples/webgl_particles_sprites.html | 14 +- examples/webgl_postprocessing.html | 24 +- examples/webgl_postprocessing_dof.html | 18 +- examples/webgl_ribbons.html | 12 +- examples/webgl_rtt.html | 4 +- examples/webgl_sandbox.html | 13 +- examples/webgl_scene_test.html | 2 +- examples/webgl_scene_test_blender.html | 4 +- examples/webgl_shader.html | 2 +- examples/webgl_shader2.html | 6 +- examples/webgl_shader_lava.html | 54 +- examples/webgl_sprites.html | 6 +- examples/webgl_stencil.html | 18 +- examples/webgl_stencilLensFlare.html | 16 +- src/Three.js | 7 + src/extras/ImageUtils.js | 16 +- src/extras/SceneUtils.js | 58 +- src/extras/ShaderUtils.js | 726 +++++++++--------- src/extras/cameras/PathCamera.js | 130 ++-- src/extras/cameras/QuakeCamera.js | 48 +- src/extras/geometries/Cube.js | 10 +- src/extras/geometries/Cylinder.js | 6 +- src/extras/geometries/Icosahedron.js | 6 +- src/extras/geometries/Lathe.js | 6 +- src/extras/geometries/Plane.js | 8 +- src/extras/geometries/Sphere.js | 6 +- src/extras/geometries/Torus.js | 10 +- src/extras/geometries/TorusKnot.js | 9 +- src/extras/io/BinaryLoader.js | 98 +-- src/extras/io/JSONLoader.js | 24 +- src/extras/io/SceneLoader.js | 64 +- src/extras/objects/MarchingCubes.js | 473 ++++++------ src/materials/Uniforms.js | 59 -- src/objects/ShadowVolume.js | 184 ++--- src/objects/SkinnedMesh.js | 8 - src/renderers/WebGLRenderer.js | 29 +- src/renderers/WebGLShaders.js | 75 +- utils/build.py | 2 - 108 files changed, 2087 insertions(+), 2062 deletions(-) delete mode 100644 src/materials/Uniforms.js diff --git a/README.md b/README.md index 5fa304bf..ab9ffb28 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ three.js #### Javascript 3D Engine #### -The aim of this project is to create a lightweight 3D engine with a very low level of abstraction — in other words, for dummies. The engine can render using <canvas>, <svg> and WebGL. +The aim of the project is to create a lightweight 3D engine with a very low level of complexity — in other words, for dummies. The engine can render using <canvas>, <svg> and WebGL. [Contributors](https://github.com/mrdoob/three.js/contributors) — [API Reference](https://github.com/mrdoob/three.js/wiki/API-Reference) diff --git a/build/Three.js b/build/Three.js index 6fd6431f..a8ee9124 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,5 +1,5 @@ // Three.js r38 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(b){this.setHex(b)}; +var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)}; THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,c){this.r=b;this.g=d;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,c){var f,g,h,j,k,m;if(c==0)f=g=h=0;else{j=Math.floor(b*6);k=b*6-j;b=c*(1-d);m=c*(1-d*k);d=c*(1-d*(1-k));switch(j){case 1:f=m;g=c;h=b;break;case 2:f=b;g=c;h=d;break;case 3:f=b;g=m;h=c;break;case 4:f=d;g=b;h=c;break;case 5:f=c;g=b; h=m;break;case 6:case 0:f=c;g=d;h=b}}this.r=f;this.g=g;this.b=h;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)}; @@ -12,21 +12,21 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,c,f){this.set(b||0,d||0,c||0,f||1)}; THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&J>0&&O+J<1}var c,f,g,h,j,k,m,p,o,v, -y,u=b.geometry,B=u.vertices,F=[];c=0;for(f=u.faces.length;c0:o<0)){p=p.dot((new THREE.Vector3).sub(h,v))/ -o;v=v.addSelf(y.multiplyScalar(p));if(g instanceof THREE.Face3){if(d(v,h,j,k)){g={distance:this.origin.distanceTo(v),point:v,face:g,object:b};F.push(g)}}else if(g instanceof THREE.Face4&&(d(v,h,j,m)||d(v,j,k,m))){g={distance:this.origin.distanceTo(v),point:v,face:g,object:b};F.push(g)}}}return F}}; -THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,p,o,v){k=!1;d=m;c=p;f=o;g=v;b()};this.addPoint=function(m,p){if(k){k=!1;d=m;c=p;f=m;g=p}else{d=dm?f:m;g=g>p?g:p}b()}; -this.add3Points=function(m,p,o,v,y,u){if(k){k=!1;d=mo?m>y?m:y:o>y?o:y;g=p>v?p>u?p:u:v>u?v:u}else{d=mo?m>y?m>f?m:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>v?p>u?p>g?p:g:u>g?u:g:v>u?v>g?v:g:u>g?u:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? +THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b0&&H>0&&Q+H<1}var c,f,g,h,j,k,m,p,o,u, +y,t=b.geometry,B=t.vertices,F=[];c=0;for(f=t.faces.length;c0:o<0)){p=p.dot((new THREE.Vector3).sub(h,u))/ +o;u=u.addSelf(y.multiplyScalar(p));if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};F.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,m)||d(u,j,k,m))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};F.push(g)}}}return F}}; +THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,p,o,u){k=!1;d=m;c=p;f=o;g=u;b()};this.addPoint=function(m,p){if(k){k=!1;d=m;c=p;f=m;g=p}else{d=dm?f:m;g=g>p?g:p}b()}; +this.add3Points=function(m,p,o,u,y,t){if(k){k=!1;d=mo?m>y?m:y:o>y?o:y;g=p>u?p>t?p:t:u>t?u:t}else{d=mo?m>y?m>f?m:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>u?p>t?p>g?p:g:t>g?t:g:u>t?u>g?u:g:t>g?t:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}}; -THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,p,o,v,y,u,B,F){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,p||0,o||1,v||0,y||0,u||0,B||0,F||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,p,o,v,y,u,B,F){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=p;this.n33=o;this.n34=v;this.n41=y;this.n42=u;this.n43=B;this.n44=F;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1, +THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,p,o,u,y,t,B,F){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,p||0,o||1,u||0,y||0,t||0,B||0,F||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,p,o,u,y,t,B,F){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=p;this.n33=o;this.n34=u;this.n41=y;this.n42=t;this.n43=B;this.n44=F;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23* f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize(); -return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,v=b.n32,y=b.n33,u=b.n34,B=b.n41,F=b.n42,J=b.n43,H=b.n44,W=d.n11,A=d.n12,L=d.n13,O=d.n14,R=d.n21,Ca=d.n22, -ka=d.n23,va=d.n24,aa=d.n31,e=d.n32,da=d.n33,ya=d.n34;this.n11=c*W+f*R+g*aa;this.n12=c*A+f*Ca+g*e;this.n13=c*L+f*ka+g*da;this.n14=c*O+f*va+g*ya+h;this.n21=j*W+k*R+m*aa;this.n22=j*A+k*Ca+m*e;this.n23=j*L+k*ka+m*da;this.n24=j*O+k*va+m*ya+p;this.n31=o*W+v*R+y*aa;this.n32=o*A+v*Ca+y*e;this.n33=o*L+v*ka+y*da;this.n34=o*O+v*va+y*ya+u;this.n41=B*W+F*R+J*aa;this.n42=B*A+F*Ca+J*e;this.n43=B*L+F*ka+J*da;this.n44=B*O+F*va+J*ya+H;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]= +return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,t=b.n34,B=b.n41,F=b.n42,H=b.n43,G=b.n44,X=d.n11,A=d.n12,M=d.n13,Q=d.n14,R=d.n21,Da=d.n22, +ma=d.n23,va=d.n24,ca=d.n31,e=d.n32,ea=d.n33,ya=d.n34;this.n11=c*X+f*R+g*ca;this.n12=c*A+f*Da+g*e;this.n13=c*M+f*ma+g*ea;this.n14=c*Q+f*va+g*ya+h;this.n21=j*X+k*R+m*ca;this.n22=j*A+k*Da+m*e;this.n23=j*M+k*ma+m*ea;this.n24=j*Q+k*va+m*ya+p;this.n31=o*X+u*R+y*ca;this.n32=o*A+u*Da+y*e;this.n33=o*M+u*ma+y*ea;this.n34=o*Q+u*va+y*ya+t;this.n41=B*X+F*R+H*ca;this.n42=B*A+F*Da+H*e;this.n43=B*M+F*ma+H*ea;this.n44=B*Q+F*va+H*ya+G;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);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(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*= -b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,o=this.n33,v=this.n34,y=this.n41,u=this.n42,B=this.n43,F=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*v*y-d*j*v*y-f*j*m*u+c*k*m*u+f*g*o*u-b*k*o*u-c*g*v*u+b*j*v*u+f*h*m*B-d*k*m*B-f*g*p*B+b*k*p*B+d*g*v*B-b*h*v*B-c*h*m*F+d*j*m*F+c*g*p*F-b*j*p*F-d*g*o*F+b*h*o*F},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31= +b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,o=this.n33,u=this.n34,y=this.n41,t=this.n42,B=this.n43,F=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*u*y-d*j*u*y-f*j*m*t+c*k*m*t+f*g*o*t-b*k*o*t-c*g*u*t+b*j*u*t+f*h*m*B-d*k*m*B-f*g*p*B+b*k*p*B+d*g*u*B-b*h*u*B-c*h*m*F+d*j*m*F+c*g*p*F-b*j*p*F-d*g*o*F+b*h*o*F},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31= this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]= this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42; b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0, @@ -34,9 +34,9 @@ b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=t 1-c,h=b.x,j=b.y,k=b.z,m=g*h,p=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,p*j+c,p*k-f*h,0,m*k-f*j,p*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33= b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14= b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,v=b.n32,y=b.n33,u=b.n34,B=b.n41,F=b.n42,J=b.n43,H=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*u*F-p*y*F+p*v*J-k*u*J-m*v*H+k*y*H;d.n12=h*y*F-g*u*F-h*v*J+f*u*J+g*v*H-f*y*H;d.n13=g*p*F-h*m*F+h*k*J-f*p*J-g*k*H+f*m*H;d.n14=h*m*v-g*p*v-h*k*y+f*p*y+g*k*u-f*m*u;d.n21=p*y*B-m*u*B-p*o*J+j*u*J+m*o*H-j*y*H;d.n22=g*u*B-h*y*B+h*o*J-c*u*J-g*o*H+c*y*H;d.n23=h*m*B-g*p*B-h*j*J+c*p*J+g*j*H-c*m*H; -d.n24=g*p*o-h*m*o+h*j*y-c*p*y-g*j*u+c*m*u;d.n31=k*u*B-p*v*B+p*o*F-j*u*F-k*o*H+j*v*H;d.n32=h*v*B-f*u*B-h*o*F+c*u*F+f*o*H-c*v*H;d.n33=g*p*B-h*k*B+h*j*F-c*p*F-f*j*H+c*k*H;d.n34=h*k*o-f*p*o-h*j*v+c*p*v+f*j*u-c*k*u;d.n41=m*v*B-k*y*B-m*o*F+j*y*F+k*o*J-j*v*J;d.n42=f*y*B-g*v*B+g*o*F-c*y*F-f*o*J+c*v*J;d.n43=g*k*B-f*m*B-g*j*F+c*m*F+f*j*J-c*k*J;d.n44=f*m*o-g*k*o+g*j*v-c*m*v-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d}; -THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*p;c[7]=b*o;c[8]=b*v;return d}; +THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,t=b.n34,B=b.n41,F=b.n42,H=b.n43,G=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*t*F-p*y*F+p*u*H-k*t*H-m*u*G+k*y*G;d.n12=h*y*F-g*t*F-h*u*H+f*t*H+g*u*G-f*y*G;d.n13=g*p*F-h*m*F+h*k*H-f*p*H-g*k*G+f*m*G;d.n14=h*m*u-g*p*u-h*k*y+f*p*y+g*k*t-f*m*t;d.n21=p*y*B-m*t*B-p*o*H+j*t*H+m*o*G-j*y*G;d.n22=g*t*B-h*y*B+h*o*H-c*t*H-g*o*G+c*y*G;d.n23=h*m*B-g*p*B-h*j*H+c*p*H+g*j*G-c*m*G; +d.n24=g*p*o-h*m*o+h*j*y-c*p*y-g*j*t+c*m*t;d.n31=k*t*B-p*u*B+p*o*F-j*t*F-k*o*G+j*u*G;d.n32=h*u*B-f*t*B-h*o*F+c*t*F+f*o*G-c*u*G;d.n33=g*p*B-h*k*B+h*j*F-c*p*F-f*j*G+c*k*G;d.n34=h*k*o-f*p*o-h*j*u+c*p*u+f*j*t-c*k*t;d.n41=m*u*B-k*y*B-m*o*F+j*y*F+k*o*H-j*u*H;d.n42=f*y*B-g*u*B+g*o*F-c*y*F-f*o*H+c*u*H;d.n43=g*k*B-f*m*B-g*j*F+c*m*F+f*j*H-c*k*H;d.n44=f*m*o-g*k*o+g*j*u-c*m*u-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d}; +THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*p;c[7]=b*o;c[8]=b*u;return d}; THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)}; THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,p;j=new THREE.Matrix4;k=d-b;m=c-f;p=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible= @@ -47,7 +47,7 @@ undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d d,c)}};THREE.Quaternion=function(b,d,c,f){this.set(b||0,d||0,c||0,f!==undefined?f:1)}; THREE.Quaternion.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,c=b.x*d,f=b.y*d,g=b.z*d;b=Math.cos(f);f=Math.sin(f);d=Math.cos(-g);g=Math.sin(-g);var h=Math.cos(c);c=Math.sin(c);var j=b*d,k=f*g;this.w=j*h-k*c;this.x=j*c+k*h;this.y=f*d*h+b*g*c;this.z=b*g*h-f*d*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*= -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,c=this.y,f=this.z,g=this.w,h=b.x,j=b.y,k=b.z;b=b.w;this.x=d*b+g*h+c*k-f*j;this.y=c*b+g*j+f*h-d*k;this.z=f*b+g*k+d*j-c*h;this.w=g*b-d*h-c*j-f*k;return this}, -multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,p=m*c+j*g-k*f,o=m*f+k*c-h*g,v=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=p*m+c*-h+o*-k-v*-j;d.y=o*m+c*-j+v*-h-p*-k;d.z=v*m+c*-k+p*-j-o*-h;return d}}; +multiplyVector3:function(b,d){d||(d=b);var c=b.x,f=b.y,g=b.z,h=this.x,j=this.y,k=this.z,m=this.w,p=m*c+j*g-k*f,o=m*f+k*c-h*g,u=m*g+h*f-j*c;c=-h*c-j*f-k*g;d.x=p*m+c*-h+o*-k-u*-j;d.y=o*m+c*-j+u*-h-p*-k;d.z=u*m+c*-k+p*-j-o*-h;return d}}; THREE.Quaternion.slerp=function(b,d,c,f){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,d,c,f,g,h){this.a=b;this.b=d;this.c=c;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=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,d,c,f,g,h,j){this.a=b;this.b=d;this.c=c;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; @@ -56,17 +56,17 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,m=new THREE.Vector3;f=0;for(g=this.faces.length;f0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;dthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;dthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]]; -v=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(p.x,o.x,v.x,y.x,j,k,m);f.y=d(p.y,o.y,v.y,y.y,j,k,m);f.z=d(p.z,o.z,v.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var u,B,F=this.points.length,J=[];for(u=0;uthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]]; +u=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(p.x,o.x,u.x,y.x,j,k,m);f.y=d(p.y,o.y,u.y,y.y,j,k,m);f.z=d(p.z,o.z,u.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var t,B,F=this.points.length,H=[];for(t=0;t1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",u,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c=== -"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",t,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c=== +"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;tb.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];p=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],p[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],p[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],p[2],g,c,j);return f}; THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]}; @@ -115,14 +115,13 @@ THREE.ParticleBasicMaterial=function(b){THREE.Material.call(this,b);b=b||{};this THREE.ParticleCanvasMaterial=function(b){THREE.Material.call(this,b);b=b||{};this.color=b.color!==undefined?new THREE.Color(b.color):new THREE.Color(16777215);this.program=b.program!==undefined?b.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;THREE.ParticleDOMMaterial=function(b){THREE.Material.call(this);this.domElement=b}; THREE.Texture=function(b,d,c,f,g,h){this.image=b;this.mapping=d!==undefined?d:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=f!==undefined?f:THREE.ClampToEdgeWrapping;this.magFilter=g!==undefined?g:THREE.LinearFilter;this.minFilter=h!==undefined?h:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1};THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}}; THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17; -THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;var Uniforms={clone:function(b){var d,c,f,g={};for(d in b){g[d]={};for(c in b[d]){f=b[d][c];g[d][c]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return g},merge:function(b){var d,c,f,g={};for(d=0;d1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance){this.LODs[f-1].object3D.visible= !1;this.LODs[f].object3D.visible=!0}else break;for(;fv){c=o;o=v;v=c}}else if(ou){c=y;y=u;u=c}}else if(yu){c=o;o=u;u=c}}else if(ot){c=y;y=t;t=c}}else if(y=0&&Y>=0&&oa>=0&&pa>=0)return!0;else if(Ea<0&&Y<0||oa<0&&pa<0)return!1;else{if(Ea<0)ya=Math.max(ya,Ea/(Ea-Y));else Y<0&&(za=Math.min(za,Ea/(Ea-Y)));if(oa<0)ya=Math.max(ya,oa/(oa-pa));else pa<0&&(za=Math.min(za,oa/(oa-pa)));if(zaEa&&j.positionScreen.z0&&O.z<1){Ta=A[W]=A[W]||new THREE.RenderableParticle;W++;H=Ta;H.x=O.x/O.w;H.y=O.y/O.w;H.z=O.z;H.rotation=ua.rotation.z;H.scale.x=ua.scale.x*Math.abs(H.x-(O.x+da.projectionMatrix.n11)/(O.w+da.projectionMatrix.n14));H.scale.y=ua.scale.y*Math.abs(H.y-(O.y+da.projectionMatrix.n22)/(O.w+da.projectionMatrix.n24));H.materials=ua.materials;za.push(H)}}}}ya&&za.sort(d);return za}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,p,o,v,y,u,B,F;b=d.projectScene(j,k);m=0;for(p=b.length;m>1;Ba=ha.height>>1;sa=ja.scale.x*m;qa=ja.scale.y*p;la=sa*Q;Ja=qa*Ba;ab.set(V.x-la,V.y-Ja,V.x+la,V.y+Ja);if(ea.instersects(ab)){o.save();o.translate(V.x,V.y);o.rotate(-ja.rotation); -o.scale(sa,-qa);o.translate(-Q,-Ba);o.drawImage(ha,0,0);o.restore()}}}else if(sa instanceof THREE.ParticleCanvasMaterial){la=ja.scale.x*m;Ja=ja.scale.y*p;ab.set(V.x-la,V.y-Ja,V.x+la,V.y+Ja);if(ea.instersects(ab)){c(sa.color.__styleString);qa=sa.color.__styleString;if(J!=qa)o.fillStyle=J=qa;o.save();o.translate(V.x,V.y);o.rotate(-ja.rotation);o.scale(la,Ja);sa.program(o);o.restore()}}}function cb(V,ja,sa,la){b(la.opacity);d(la.blending);o.beginPath();o.moveTo(V.positionScreen.x,V.positionScreen.y); -o.lineTo(ja.positionScreen.x,ja.positionScreen.y);o.closePath();if(la instanceof THREE.LineBasicMaterial){ma.__styleString=la.color.__styleString;V=la.linewidth;if(H!=V)o.lineWidth=H=V;V=la.linecap;if(W!=V)o.lineCap=W=V;V=la.linejoin;if(A!=V)o.lineJoin=A=V;c(ma.__styleString);o.stroke();ab.inflate(la.linewidth*2)}}function Ga(V,ja,sa,la,Ja,qa,ha,Q,Ba){b(Q.opacity);d(Q.blending);aa=V.positionScreen.x;e=V.positionScreen.y;da=ja.positionScreen.x;ya=ja.positionScreen.y;za=sa.positionScreen.x;Ea=sa.positionScreen.y; -Fa(aa,e,da,ya,za,Ea);if(Q instanceof THREE.MeshBasicMaterial)if(Q.map){if(Q.map.mapping instanceof THREE.UVMapping){Qa=ha.uvs[0];t(aa,e,da,ya,za,Ea,Q.map.image,Qa[la].u,Qa[la].v,Qa[Ja].u,Qa[Ja].v,Qa[qa].u,Qa[qa].v)}}else if(Q.envMap){if(Q.envMap.mapping instanceof THREE.SphericalReflectionMapping){V=ra.matrixWorldInverse;G.copy(ha.vertexNormalsWorld[0]);U=(G.x*V.n11+G.y*V.n12+G.z*V.n13)*0.5+0.5;ca=-(G.x*V.n21+G.y*V.n22+G.z*V.n23)*0.5+0.5;G.copy(ha.vertexNormalsWorld[1]);na=(G.x*V.n11+G.y*V.n12+G.z* -V.n13)*0.5+0.5;Aa=-(G.x*V.n21+G.y*V.n22+G.z*V.n23)*0.5+0.5;G.copy(ha.vertexNormalsWorld[2]);La=(G.x*V.n11+G.y*V.n12+G.z*V.n13)*0.5+0.5;wa=-(G.x*V.n21+G.y*V.n22+G.z*V.n23)*0.5+0.5;t(aa,e,da,ya,za,Ea,Q.envMap.image,U,ca,na,Aa,La,wa)}}else Q.wireframe?D(Q.color.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){if(Q.map.mapping instanceof THREE.UVMapping){Qa=ha.uvs[0];t(aa,e,da,ya, -za,Ea,Q.map.image,Qa[la].u,Qa[la].v,Qa[Ja].u,Qa[Ja].v,Qa[qa].u,Qa[qa].v)}d(THREE.SubtractiveBlending)}if(n)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==3){Da.r=ga.r=ia.r=w.r;Da.g=ga.g=ia.g=w.g;Da.b=ga.b=ia.b=w.b;xa(Ba,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Da);xa(Ba,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ga);xa(Ba,ha.v3.positionWorld,ha.vertexNormalsWorld[2],ia);ua.r=(ga.r+ia.r)*0.5;ua.g=(ga.g+ia.g)*0.5;ua.b=(ga.b+ia.b)*0.5;Za=db(Da,ga,ia,ua);t(aa,e,da, -ya,za,Ea,Za,0,0,1,0,0,1)}else{C.r=w.r;C.g=w.g;C.b=w.b;xa(Ba,ha.centroidWorld,ha.normalWorld,C);ma.r=Q.color.r*C.r;ma.g=Q.color.g*C.g;ma.b=Q.color.b*C.b;ma.updateStyleString();Q.wireframe?D(ma.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(ma.__styleString)}else Q.wireframe?D(Q.color.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){Ta=ra.near;Ya=ra.far;Da.r=Da.g=Da.b=1-hb(V.positionScreen.z, -Ta,Ya);ga.r=ga.g=ga.b=1-hb(ja.positionScreen.z,Ta,Ya);ia.r=ia.g=ia.b=1-hb(sa.positionScreen.z,Ta,Ya);ua.r=(ga.r+ia.r)*0.5;ua.g=(ga.g+ia.g)*0.5;ua.b=(ga.b+ia.b)*0.5;Za=db(Da,ga,ia,ua);t(aa,e,da,ya,za,Ea,Za,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){ma.r=Ra(ha.normalWorld.x);ma.g=Ra(ha.normalWorld.y);ma.b=Ra(ha.normalWorld.z);ma.updateStyleString();Q.wireframe?D(ma.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(ma.__styleString)}}function Ha(V,ja,sa,la, -Ja,qa,ha,Q,Ba){b(Q.opacity);d(Q.blending);if(Q.map||Q.envMap){Ga(V,ja,la,0,1,3,ha,Q,Ba);Ga(Ja,sa,qa,1,2,3,ha,Q,Ba)}else{aa=V.positionScreen.x;e=V.positionScreen.y;da=ja.positionScreen.x;ya=ja.positionScreen.y;za=sa.positionScreen.x;Ea=sa.positionScreen.y;Y=la.positionScreen.x;oa=la.positionScreen.y;pa=Ja.positionScreen.x;ta=Ja.positionScreen.y;fa=qa.positionScreen.x;Z=qa.positionScreen.y;if(Q instanceof THREE.MeshBasicMaterial){Ua(aa,e,da,ya,za,Ea,Y,oa);Q.wireframe?D(Q.color.__styleString,Q.wireframeLinewidth, -Q.wireframeLinecap,Q.wireframeLinejoin):$(Q.color.__styleString)}else if(Q instanceof THREE.MeshLambertMaterial)if(n)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==4){Da.r=ga.r=ia.r=ua.r=w.r;Da.g=ga.g=ia.g=ua.g=w.g;Da.b=ga.b=ia.b=ua.b=w.b;xa(Ba,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Da);xa(Ba,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ga);xa(Ba,ha.v4.positionWorld,ha.vertexNormalsWorld[3],ia);xa(Ba,ha.v3.positionWorld,ha.vertexNormalsWorld[2],ua);Za=db(Da,ga, -ia,ua);Fa(aa,e,da,ya,Y,oa);t(aa,e,da,ya,Y,oa,Za,0,0,1,0,0,1);Fa(pa,ta,za,Ea,fa,Z);t(pa,ta,za,Ea,fa,Z,Za,1,0,1,1,0,1)}else{C.r=w.r;C.g=w.g;C.b=w.b;xa(Ba,ha.centroidWorld,ha.normalWorld,C);ma.r=Q.color.r*C.r;ma.g=Q.color.g*C.g;ma.b=Q.color.b*C.b;ma.updateStyleString();Ua(aa,e,da,ya,za,Ea,Y,oa);Q.wireframe?D(ma.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(ma.__styleString)}else{Ua(aa,e,da,ya,za,Ea,Y,oa);Q.wireframe?D(Q.color.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap, -Q.wireframeLinejoin):$(Q.color.__styleString)}else if(Q instanceof THREE.MeshNormalMaterial){ma.r=Ra(ha.normalWorld.x);ma.g=Ra(ha.normalWorld.y);ma.b=Ra(ha.normalWorld.z);ma.updateStyleString();Ua(aa,e,da,ya,za,Ea,Y,oa);Q.wireframe?D(ma.__styleString,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):$(ma.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){Ta=ra.near;Ya=ra.far;Da.r=Da.g=Da.b=1-hb(V.positionScreen.z,Ta,Ya);ga.r=ga.g=ga.b=1-hb(ja.positionScreen.z,Ta,Ya);ia.r=ia.g= -ia.b=1-hb(la.positionScreen.z,Ta,Ya);ua.r=ua.g=ua.b=1-hb(sa.positionScreen.z,Ta,Ya);Za=db(Da,ga,ia,ua);Fa(aa,e,da,ya,Y,oa);t(aa,e,da,ya,Y,oa,Za,0,0,1,0,0,1);Fa(pa,ta,za,Ea,fa,Z);t(pa,ta,za,Ea,fa,Z,Za,1,0,1,1,0,1)}}}function Fa(V,ja,sa,la,Ja,qa){o.beginPath();o.moveTo(V,ja);o.lineTo(sa,la);o.lineTo(Ja,qa);o.lineTo(V,ja);o.closePath()}function Ua(V,ja,sa,la,Ja,qa,ha,Q){o.beginPath();o.moveTo(V,ja);o.lineTo(sa,la);o.lineTo(Ja,qa);o.lineTo(ha,Q);o.lineTo(V,ja);o.closePath()}function D(V,ja,sa,la){if(H!= -ja)o.lineWidth=H=ja;if(W!=sa)o.lineCap=W=sa;if(A!=la)o.lineJoin=A=la;c(V);o.stroke();ab.inflate(ja*2)}function $(V){if(J!=V)o.fillStyle=J=V;o.fill()}function t(V,ja,sa,la,Ja,qa,ha,Q,Ba,Oa,Ka,ib,gb){var Xa,$a;Xa=ha.width-1;$a=ha.height-1;Q*=Xa;Ba*=$a;Oa*=Xa;Ka*=$a;ib*=Xa;gb*=$a;sa-=V;la-=ja;Ja-=V;qa-=ja;Oa-=Q;Ka-=Ba;ib-=Q;gb-=Ba;Xa=Oa*gb-ib*Ka;if(Xa!=0){$a=1/Xa;Xa=(gb*sa-Ka*Ja)*$a;Ka=(gb*la-Ka*qa)*$a;sa=(Oa*Ja-ib*sa)*$a;la=(Oa*qa-ib*la)*$a;V=V-Xa*Q-sa*Ba;ja=ja-Ka*Q-la*Ba;o.save();o.transform(Xa,Ka, -sa,la,V,ja);o.clip();o.drawImage(ha,0,0);o.restore()}}function db(V,ja,sa,la){var Ja=~~(V.r*255),qa=~~(V.g*255);V=~~(V.b*255);var ha=~~(ja.r*255),Q=~~(ja.g*255);ja=~~(ja.b*255);var Ba=~~(sa.r*255),Oa=~~(sa.g*255);sa=~~(sa.b*255);var Ka=~~(la.r*255),ib=~~(la.g*255);la=~~(la.b*255);E[0]=Ja<0?0:Ja>255?255:Ja;E[1]=qa<0?0:qa>255?255:qa;E[2]=V<0?0:V>255?255:V;E[4]=ha<0?0:ha>255?255:ha;E[5]=Q<0?0:Q>255?255:Q;E[6]=ja<0?0:ja>255?255:ja;E[8]=Ba<0?0:Ba>255?255:Ba;E[9]=Oa<0?0:Oa>255?255:Oa;E[10]=sa<0?0:sa>255? -255:sa;E[12]=Ka<0?0:Ka>255?255:Ka;E[13]=ib<0?0:ib>255?255:ib;E[14]=la<0?0:la>255?255:la;I.putImageData(S,0,0);K.drawImage(M,0,0);return N}function hb(V,ja,sa){V=(V-ja)/(sa-ja);return V*V*(3-2*V)}function Ra(V){V=(V+1)*0.5;return V<0?0:V>1?1:V}function Sa(V,ja){var sa=ja.x-V.x,la=ja.y-V.y,Ja=1/Math.sqrt(sa*sa+la*la);sa*=Ja;la*=Ja;ja.x+=sa;ja.y+=la;V.x-=sa;V.y-=la}var jb,kb,Ia,Va,Pa,bb,Wa,T;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,p);f=g.projectScene(P,ra,this.sortElements);(n=P.lights.length> -0)&&Na(P);jb=0;for(kb=f.length;jb0){pa.r+=Z.color.r*ma;pa.g+=Z.color.g*ma;pa.b+=Z.color.b*ma}}else if(Z instanceof THREE.PointLight){va.sub(Z.position,oa.centroidWorld);va.normalize();ma=oa.normalWorld.dot(va)*Z.intensity;if(ma>0){pa.r+=Z.color.r*ma;pa.g+=Z.color.g*ma;pa.b+=Z.color.b*ma}}}}function d(Y,oa,pa,ta,fa,Z){da=f(ya++); -da.setAttribute("d","M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(fa instanceof THREE.MeshBasicMaterial)A.__styleString=fa.color.__styleString;else if(fa instanceof THREE.MeshLambertMaterial)if(W){L.r=O.r;L.g=O.g;L.b=O.b;b(Z,ta,L);A.r=fa.color.r*L.r;A.g=fa.color.g*L.g;A.b=fa.color.b*L.b;A.updateStyleString()}else A.__styleString=fa.color.__styleString;else if(fa instanceof THREE.MeshDepthMaterial){ka= -1-fa.__2near/(fa.__farPlusNear-ta.z*fa.__farMinusNear);A.setRGB(ka,ka,ka)}else fa instanceof THREE.MeshNormalMaterial&&A.setRGB(g(ta.normalWorld.x),g(ta.normalWorld.y),g(ta.normalWorld.z));fa.wireframe?da.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+fa.wireframeLinewidth+"; stroke-opacity: "+fa.opacity+"; stroke-linecap: "+fa.wireframeLinecap+"; stroke-linejoin: "+fa.wireframeLinejoin):da.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+fa.opacity); -k.appendChild(da)}function c(Y,oa,pa,ta,fa,Z,ma){da=f(ya++);da.setAttribute("d","M "+Y.positionScreen.x+" "+Y.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+ta.positionScreen.x+","+ta.positionScreen.y+"z");if(Z instanceof THREE.MeshBasicMaterial)A.__styleString=Z.color.__styleString;else if(Z instanceof THREE.MeshLambertMaterial)if(W){L.r=O.r;L.g=O.g;L.b=O.b;b(ma,fa,L);A.r=Z.color.r*L.r;A.g=Z.color.g*L.g;A.b=Z.color.b*L.b; -A.updateStyleString()}else A.__styleString=Z.color.__styleString;else if(Z instanceof THREE.MeshDepthMaterial){ka=1-Z.__2near/(Z.__farPlusNear-fa.z*Z.__farMinusNear);A.setRGB(ka,ka,ka)}else Z instanceof THREE.MeshNormalMaterial&&A.setRGB(g(fa.normalWorld.x),g(fa.normalWorld.y),g(fa.normalWorld.z));Z.wireframe?da.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+Z.wireframeLinewidth+"; stroke-opacity: "+Z.opacity+"; stroke-linecap: "+Z.wireframeLinecap+"; stroke-linejoin: "+ -Z.wireframeLinejoin):da.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+Z.opacity);k.appendChild(da)}function f(Y){if(aa[Y]==null){aa[Y]=document.createElementNS("http://www.w3.org/2000/svg","path");Ea==0&&aa[Y].setAttribute("shape-rendering","crispEdges")}return aa[Y]}function g(Y){return Y<0?Math.min((1+Y)*0.5,0.5):0.5+Math.min(Y*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,o,v,y,u,B,F,J=new THREE.Rectangle,H=new THREE.Rectangle, -W=!1,A=new THREE.Color(16777215),L=new THREE.Color(16777215),O=new THREE.Color(0),R=new THREE.Color(0),Ca=new THREE.Color(0),ka,va=new THREE.Vector3,aa=[],e=[],da,ya,za,Ea=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(Y){switch(Y){case "high":Ea=1;break;case "low":Ea=0}};this.setSize=function(Y,oa){m=Y;p=oa;o=m/2;v=p/2;k.setAttribute("viewBox",-o+" "+-v+" "+m+" "+p);k.setAttribute("width",m);k.setAttribute("height",p);J.set(-o,-v,o,v)};this.clear= -function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(Y,oa){var pa,ta,fa,Z,ma,Da,ga,ia;this.autoClear&&this.clear();h=j.projectScene(Y,oa,this.sortElements);za=ya=0;if(W=Y.lights.length>0){ga=Y.lights;O.setRGB(0,0,0);R.setRGB(0,0,0);Ca.setRGB(0,0,0);pa=0;for(ta=ga.length;pa=0&&Z>=0&&oa>=0&&pa>=0)return!0;else if(Fa<0&&Z<0||oa<0&&pa<0)return!1;else{if(Fa<0)ya=Math.max(ya,Fa/(Fa-Z));else Z<0&&(Ba=Math.min(Ba,Fa/(Fa-Z)));if(oa<0)ya=Math.max(ya,oa/(oa-pa));else pa<0&&(Ba=Math.min(Ba,oa/(oa-pa)));if(BaFa&&j.positionScreen.z0&&Q.z<1){Ra=A[X]=A[X]||new THREE.RenderableParticle;X++;G=Ra;G.x=Q.x/Q.w;G.y=Q.y/Q.w;G.z=Q.z;G.rotation=ua.rotation.z;G.scale.x=ua.scale.x*Math.abs(G.x-(Q.x+ea.projectionMatrix.n11)/(Q.w+ea.projectionMatrix.n14));G.scale.y=ua.scale.y*Math.abs(G.y-(Q.y+ea.projectionMatrix.n22)/(Q.w+ea.projectionMatrix.n24));G.materials=ua.materials;Ba.push(G)}}}}ya&&Ba.sort(d);return Ba}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,p,o,u,y,t,B,F;b=d.projectScene(j,k);m=0;for(p=b.length;m>1;Ia=ha.height>>1;ka=ia.scale.x*m;qa=ia.scale.y*p;da=ka*Y;ra=qa*Ia;x.set(W.x-da,W.y-ra,W.x+da,W.y+ra);if(C.instersects(x)){o.save();o.translate(W.x,W.y); +o.rotate(-ia.rotation);o.scale(ka,-qa);o.translate(-Y,-Ia);o.drawImage(ha,0,0);o.restore()}}}else if(ka instanceof THREE.ParticleCanvasMaterial){da=ia.scale.x*m;ra=ia.scale.y*p;x.set(W.x-da,W.y-ra,W.x+da,W.y+ra);if(C.instersects(x)){c(ka.color.__styleString);qa=ka.color.__styleString;if(H!=qa)o.fillStyle=H=qa;o.save();o.translate(W.x,W.y);o.rotate(-ia.rotation);o.scale(da,ra);ka.program(o);o.restore()}}}function Ua(W,ia,ka,da){b(da.opacity);d(da.blending);o.beginPath();o.moveTo(W.positionScreen.x, +W.positionScreen.y);o.lineTo(ia.positionScreen.x,ia.positionScreen.y);o.closePath();if(da instanceof THREE.LineBasicMaterial){na.__styleString=da.color.__styleString;W=da.linewidth;if(G!=W)o.lineWidth=G=W;W=da.linecap;if(X!=W)o.lineCap=X=W;W=da.linejoin;if(A!=W)o.lineJoin=A=W;c(na.__styleString);o.stroke();x.inflate(da.linewidth*2)}}function E(W,ia,ka,da,ra,qa,ha,Y,Ia){b(Y.opacity);d(Y.blending);ca=W.positionScreen.x;e=W.positionScreen.y;ea=ia.positionScreen.x;ya=ia.positionScreen.y;Ba=ka.positionScreen.x; +Fa=ka.positionScreen.y;v(ca,e,ea,ya,Ba,Fa);if(Y instanceof THREE.MeshBasicMaterial)if(Y.map){if(Y.map.mapping instanceof THREE.UVMapping){Na=ha.uvs[0];Pa(ca,e,ea,ya,Ba,Fa,Y.map.image,Na[da].u,Na[da].v,Na[ra].u,Na[ra].v,Na[qa].u,Na[qa].v)}}else if(Y.envMap){if(Y.envMap.mapping instanceof THREE.SphericalReflectionMapping){W=Oa.matrixWorldInverse;D.copy(ha.vertexNormalsWorld[0]);T=(D.x*W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;P=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;D.copy(ha.vertexNormalsWorld[1]);N=(D.x* +W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;Ca=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;D.copy(ha.vertexNormalsWorld[2]);Ka=(D.x*W.n11+D.y*W.n12+D.z*W.n13)*0.5+0.5;n=-(D.x*W.n21+D.y*W.n22+D.z*W.n23)*0.5+0.5;Pa(ca,e,ea,ya,Ba,Fa,Y.envMap.image,T,P,N,Ca,Ka,n)}}else Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){if(Y.map.mapping instanceof THREE.UVMapping){Na=ha.uvs[0]; +Pa(ca,e,ea,ya,Ba,Fa,Y.map.image,Na[da].u,Na[da].v,Na[ra].u,Na[ra].v,Na[qa].u,Na[qa].v)}d(THREE.SubtractiveBlending)}if(z)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==3){Ea.r=ja.r=la.r=K.r;Ea.g=ja.g=la.g=K.g;Ea.b=ja.b=la.b=K.b;wa(Ia,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ea);wa(Ia,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ja);wa(Ia,ha.v3.positionWorld,ha.vertexNormalsWorld[2],la);ua.r=(ja.r+la.r)*0.5;ua.g=(ja.g+la.g)*0.5;ua.b=(ja.b+la.b)*0.5;Za=hb(Ea,ja,la, +ua);Pa(ca,e,ea,ya,Ba,Fa,Za,0,0,1,0,0,1)}else{J.r=K.r;J.g=K.g;J.b=K.b;wa(Ia,ha.centroidWorld,ha.normalWorld,J);na.r=Y.color.r*J.r;na.g=Y.color.g*J.g;na.b=Y.color.b*J.b;na.updateStyleString();Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ra=Oa.near;Ya=Oa.far;Ea.r= +Ea.g=Ea.b=1-eb(W.positionScreen.z,Ra,Ya);ja.r=ja.g=ja.b=1-eb(ia.positionScreen.z,Ra,Ya);la.r=la.g=la.b=1-eb(ka.positionScreen.z,Ra,Ya);ua.r=(ja.r+la.r)*0.5;ua.g=(ja.g+la.g)*0.5;ua.b=(ja.b+la.b)*0.5;Za=hb(Ea,ja,la,ua);Pa(ca,e,ea,ya,Ba,Fa,Za,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){na.r=$a(ha.normalWorld.x);na.g=$a(ha.normalWorld.y);na.b=$a(ha.normalWorld.z);na.updateStyleString();Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}} +function fa(W,ia,ka,da,ra,qa,ha,Y,Ia){b(Y.opacity);d(Y.blending);if(Y.map||Y.envMap){E(W,ia,da,0,1,3,ha,Y,Ia);E(ra,ka,qa,1,2,3,ha,Y,Ia)}else{ca=W.positionScreen.x;e=W.positionScreen.y;ea=ia.positionScreen.x;ya=ia.positionScreen.y;Ba=ka.positionScreen.x;Fa=ka.positionScreen.y;Z=da.positionScreen.x;oa=da.positionScreen.y;pa=ra.positionScreen.x;sa=ra.positionScreen.y;ga=qa.positionScreen.x;aa=qa.positionScreen.y;if(Y instanceof THREE.MeshBasicMaterial){bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(Y.color.__styleString, +Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshLambertMaterial)if(z)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==4){Ea.r=ja.r=la.r=ua.r=K.r;Ea.g=ja.g=la.g=ua.g=K.g;Ea.b=ja.b=la.b=ua.b=K.b;wa(Ia,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ea);wa(Ia,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ja);wa(Ia,ha.v4.positionWorld,ha.vertexNormalsWorld[3],la);wa(Ia,ha.v3.positionWorld,ha.vertexNormalsWorld[2], +ua);Za=hb(Ea,ja,la,ua);v(ca,e,ea,ya,Z,oa);Pa(ca,e,ea,ya,Z,oa,Za,0,0,1,0,0,1);v(pa,sa,Ba,Fa,ga,aa);Pa(pa,sa,Ba,Fa,ga,aa,Za,1,0,1,1,0,1)}else{J.r=K.r;J.g=K.g;J.b=K.b;wa(Ia,ha.centroidWorld,ha.normalWorld,J);na.r=Y.color.r*J.r;na.g=Y.color.g*J.g;na.b=Y.color.b*J.b;na.updateStyleString();bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else{bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(Y.color.__styleString,Y.wireframeLinewidth, +Y.wireframeLinecap,Y.wireframeLinejoin):Ma(Y.color.__styleString)}else if(Y instanceof THREE.MeshNormalMaterial){na.r=$a(ha.normalWorld.x);na.g=$a(ha.normalWorld.y);na.b=$a(ha.normalWorld.z);na.updateStyleString();bb(ca,e,ea,ya,Ba,Fa,Z,oa);Y.wireframe?db(na.__styleString,Y.wireframeLinewidth,Y.wireframeLinecap,Y.wireframeLinejoin):Ma(na.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){Ra=Oa.near;Ya=Oa.far;Ea.r=Ea.g=Ea.b=1-eb(W.positionScreen.z,Ra,Ya);ja.r=ja.g=ja.b=1-eb(ia.positionScreen.z, +Ra,Ya);la.r=la.g=la.b=1-eb(da.positionScreen.z,Ra,Ya);ua.r=ua.g=ua.b=1-eb(ka.positionScreen.z,Ra,Ya);Za=hb(Ea,ja,la,ua);v(ca,e,ea,ya,Z,oa);Pa(ca,e,ea,ya,Z,oa,Za,0,0,1,0,0,1);v(pa,sa,Ba,Fa,ga,aa);Pa(pa,sa,Ba,Fa,ga,aa,Za,1,0,1,1,0,1)}}}function v(W,ia,ka,da,ra,qa){o.beginPath();o.moveTo(W,ia);o.lineTo(ka,da);o.lineTo(ra,qa);o.lineTo(W,ia);o.closePath()}function bb(W,ia,ka,da,ra,qa,ha,Y){o.beginPath();o.moveTo(W,ia);o.lineTo(ka,da);o.lineTo(ra,qa);o.lineTo(ha,Y);o.lineTo(W,ia);o.closePath()}function db(W, +ia,ka,da){if(G!=ia)o.lineWidth=G=ia;if(X!=ka)o.lineCap=X=ka;if(A!=da)o.lineJoin=A=da;c(W);o.stroke();x.inflate(ia*2)}function Ma(W){if(H!=W)o.fillStyle=H=W;o.fill()}function Pa(W,ia,ka,da,ra,qa,ha,Y,Ia,Va,Ta,ib,Wa){var fb,gb;fb=ha.width-1;gb=ha.height-1;Y*=fb;Ia*=gb;Va*=fb;Ta*=gb;ib*=fb;Wa*=gb;ka-=W;da-=ia;ra-=W;qa-=ia;Va-=Y;Ta-=Ia;ib-=Y;Wa-=Ia;fb=Va*Wa-ib*Ta;if(fb!=0){gb=1/fb;fb=(Wa*ka-Ta*ra)*gb;Ta=(Wa*da-Ta*qa)*gb;ka=(Va*ra-ib*ka)*gb;da=(Va*qa-ib*da)*gb;W=W-fb*Y-ka*Ia;ia=ia-Ta*Y-da*Ia;o.save(); +o.transform(fb,Ta,ka,da,W,ia);o.clip();o.drawImage(ha,0,0);o.restore()}}function hb(W,ia,ka,da){var ra=~~(W.r*255),qa=~~(W.g*255);W=~~(W.b*255);var ha=~~(ia.r*255),Y=~~(ia.g*255);ia=~~(ia.b*255);var Ia=~~(ka.r*255),Va=~~(ka.g*255);ka=~~(ka.b*255);var Ta=~~(da.r*255),ib=~~(da.g*255);da=~~(da.b*255);V[0]=ra<0?0:ra>255?255:ra;V[1]=qa<0?0:qa>255?255:qa;V[2]=W<0?0:W>255?255:W;V[4]=ha<0?0:ha>255?255:ha;V[5]=Y<0?0:Y>255?255:Y;V[6]=ia<0?0:ia>255?255:ia;V[8]=Ia<0?0:Ia>255?255:Ia;V[9]=Va<0?0:Va>255?255:Va; +V[10]=ka<0?0:ka>255?255:ka;V[12]=Ta<0?0:Ta>255?255:Ta;V[13]=ib<0?0:ib>255?255:ib;V[14]=da<0?0:da>255?255:da;L.putImageData($,0,0);Ja.drawImage(O,0,0);return xa}function eb(W,ia,ka){W=(W-ia)/(ka-ia);return W*W*(3-2*W)}function $a(W){W=(W+1)*0.5;return W<0?0:W>1?1:W}function ab(W,ia){var ka=ia.x-W.x,da=ia.y-W.y,ra=1/Math.sqrt(ka*ka+da*da);ka*=ra;da*=ra;ia.x+=ka;ia.y+=da;W.x-=ka;W.y-=da}var La,cb,Aa,U,Qa,Sa,jb,Xa;this.autoClear?this.clear():o.setTransform(1,0,0,-1,m,p);f=g.projectScene(ta,Oa,this.sortElements); +(z=ta.lights.length>0)&&Ga(ta);La=0;for(cb=f.length;La0){pa.r+=aa.color.r*na;pa.g+=aa.color.g*na;pa.b+=aa.color.b*na}}else if(aa instanceof THREE.PointLight){va.sub(aa.position,oa.centroidWorld);va.normalize();na=oa.normalWorld.dot(va)*aa.intensity;if(na>0){pa.r+=aa.color.r*na;pa.g+=aa.color.g*na;pa.b+=aa.color.b*na}}}}function d(Z,oa,pa, +sa,ga,aa){ea=f(ya++);ea.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)A.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(X){M.r=Q.r;M.g=Q.g;M.b=Q.b;b(aa,sa,M);A.r=ga.color.r*M.r;A.g=ga.color.g*M.g;A.b=ga.color.b*M.b;A.updateStyleString()}else A.__styleString=ga.color.__styleString;else if(ga instanceof +THREE.MeshDepthMaterial){ma=1-ga.__2near/(ga.__farPlusNear-sa.z*ga.__farMinusNear);A.setRGB(ma,ma,ma)}else ga instanceof THREE.MeshNormalMaterial&&A.setRGB(g(sa.normalWorld.x),g(sa.normalWorld.y),g(sa.normalWorld.z));ga.wireframe?ea.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):ea.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+ +ga.opacity);k.appendChild(ea)}function c(Z,oa,pa,sa,ga,aa,na){ea=f(ya++);ea.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)A.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(X){M.r=Q.r;M.g=Q.g;M.b=Q.b;b(na,ga,M);A.r=aa.color.r*M.r;A.g=aa.color.g*M.g; +A.b=aa.color.b*M.b;A.updateStyleString()}else A.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){ma=1-aa.__2near/(aa.__farPlusNear-ga.z*aa.__farMinusNear);A.setRGB(ma,ma,ma)}else aa instanceof THREE.MeshNormalMaterial&&A.setRGB(g(ga.normalWorld.x),g(ga.normalWorld.y),g(ga.normalWorld.z));aa.wireframe?ea.setAttribute("style","fill: none; stroke: "+A.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+ +"; stroke-linejoin: "+aa.wireframeLinejoin):ea.setAttribute("style","fill: "+A.__styleString+"; fill-opacity: "+aa.opacity);k.appendChild(ea)}function f(Z){if(ca[Z]==null){ca[Z]=document.createElementNS("http://www.w3.org/2000/svg","path");Fa==0&&ca[Z].setAttribute("shape-rendering","crispEdges")}return ca[Z]}function g(Z){return Z<0?Math.min((1+Z)*0.5,0.5):0.5+Math.min(Z*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,p,o,u,y,t,B,F,H=new THREE.Rectangle, +G=new THREE.Rectangle,X=!1,A=new THREE.Color(16777215),M=new THREE.Color(16777215),Q=new THREE.Color(0),R=new THREE.Color(0),Da=new THREE.Color(0),ma,va=new THREE.Vector3,ca=[],e=[],ea,ya,Ba,Fa=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(Z){switch(Z){case "high":Fa=1;break;case "low":Fa=0}};this.setSize=function(Z,oa){m=Z;p=oa;o=m/2;u=p/2;k.setAttribute("viewBox",-o+" "+-u+" "+m+" "+p);k.setAttribute("width",m);k.setAttribute("height",p); +H.set(-o,-u,o,u)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(Z,oa){var pa,sa,ga,aa,na,Ea,ja,la;this.autoClear&&this.clear();h=j.projectScene(Z,oa,this.sortElements);Ba=ya=0;if(X=Z.lights.length>0){ja=Z.lights;Q.setRGB(0,0,0);R.setRGB(0,0,0);Da.setRGB(0,0,0);pa=0;for(sa=ja.length;pa 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", -default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"}; +default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,c,f,g={};for(d=0;dE){N=K;E=S[N]}e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[N]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0); -G.__webglMorphTargetInfluences[w]=E;I[N]=1;E=-1;w++}}e.uniform1fv(x.program.uniforms.morphTargetInfluences,G.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(z.__webglCustomAttributes)for(M in z.__webglCustomAttributes)if(n[M]>=0){C=z.__webglCustomAttributes[M];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[M],C.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglColorBuffer); +THREE.LineBasicMaterial){I.diffuse.value=x.color;I.opacity.value=x.opacity}else if(x instanceof THREE.ParticleBasicMaterial){I.psColor.value=x.color;I.opacity.value=x.opacity;I.size.value=x.size;I.scale.value=ea.height/2;I.map.texture=x.map}else if(x instanceof THREE.MeshPhongMaterial){I.ambient.value=x.ambient;I.specular.value=x.specular;I.shininess.value=x.shininess}else if(x instanceof THREE.MeshDepthMaterial){I.mNear.value=n.near;I.mFar.value=n.far;I.opacity.value=x.opacity}else if(x instanceof +THREE.MeshNormalMaterial)I.opacity.value=x.opacity;for(var v in I)if(L=J.uniforms[v]){S=I[v];O=S.type;w=S.value;if(O=="i")e.uniform1i(L,w);else if(O=="f")e.uniform1f(L,w);else if(O=="fv1")e.uniform1fv(L,w);else if(O=="fv")e.uniform3fv(L,w);else if(O=="v2")e.uniform2f(L,w.x,w.y);else if(O=="v3")e.uniform3f(L,w.x,w.y,w.z);else if(O=="v4")e.uniform4f(L,w.x,w.y,w.z,w.w);else if(O=="c")e.uniform3f(L,w.r,w.g,w.b);else if(O=="t"){e.uniform1i(L,w);if(S=S.texture)if(S.image instanceof Array&&S.image.length== +6){if(S.image.length==6){if(S.needsUpdate){if(S.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube);for(O=0;O<6;++O)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,0,0,e.RGBA,e.UNSIGNED_BYTE,S.image[O])}else{S.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube);for(O=0;O<6;++O)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+O,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,S.image[O]);S.__webglInit=!0}Q(e.TEXTURE_CUBE_MAP,S,S.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP, +null);S.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,S.image.__webglTextureCube)}}else R(S,w)}}e.uniformMatrix4fv(K.modelViewMatrix,!1,z._modelViewMatrixArray);e.uniformMatrix3fv(K.normalMatrix,!1,z._normalMatrixArray);(x instanceof THREE.MeshShaderMaterial||x instanceof THREE.MeshPhongMaterial||x.envMap)&&e.uniform3f(K.cameraPosition,n.position.x,n.position.y,n.position.z);(x instanceof THREE.MeshShaderMaterial||x.envMap||x.skinning)&&e.uniformMatrix4fv(K.objectMatrix, +!1,z._objectMatrixArray);(x instanceof THREE.MeshPhongMaterial||x instanceof THREE.MeshLambertMaterial||x instanceof THREE.MeshShaderMaterial||x.skinning)&&e.uniformMatrix4fv(K.viewMatrix,!1,Za);if(x instanceof THREE.ShadowVolumeDynamicMaterial){n=I.directionalLightDirection.value;n[0]=-C[1].position.x;n[1]=-C[1].position.y;n[2]=-C[1].position.z;e.uniform3fv(K.directionalLightDirection,n);e.uniformMatrix4fv(K.objectMatrix,!1,z._objectMatrixArray);e.uniformMatrix4fv(K.viewMatrix,!1,Za)}if(x.skinning){e.uniformMatrix4fv(K.cameraInverseMatrix, +!1,Za);e.uniformMatrix4fv(K.boneGlobalMatrices,!1,z.boneMatrices)}return J}function f(n,C,w,x,z,J){if(x.opacity!=0){var K;n=c(n,C,w,x,J).attributes;if(x.morphTargets){C=x.program.attributes;J.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[J.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0);if(J.morphTargetForcedOrder.length){w=0;for(var I=J.morphTargetForcedOrder,S=J.morphTargetInfluences;wD){O=L;D=S[O]}e.bindBuffer(e.ARRAY_BUFFER,z.__webglMorphTargetsBuffers[O]);e.vertexAttribPointer(C["morphTarget"+w],3,e.FLOAT,!1,0,0); +J.__webglMorphTargetInfluences[w]=D;I[O]=1;D=-1;w++}}e.uniform1fv(x.program.uniforms.morphTargetInfluences,J.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,z.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}if(z.__webglCustomAttributes)for(K in z.__webglCustomAttributes)if(n[K]>=0){C=z.__webglCustomAttributes[K];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(n[K],C.size,e.FLOAT,!1,0,0)}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglColorBuffer); e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(z.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,z.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(z.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER, z.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(x.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex, -4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,z.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(G instanceof THREE.Mesh)if(x.wireframe){e.lineWidth(x.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglLineBuffer);e.drawElements(e.LINES,z.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,z.__webglFaceBuffer);e.drawElements(e.TRIANGLES,z.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(G instanceof THREE.Line){G=G.type==THREE.LineStrip? -e.LINE_STRIP:e.LINES;e.lineWidth(x.linewidth);e.drawArrays(G,0,z.__webglLineCount)}else if(G instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,z.__webglParticleCount);else G instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,z.__webglVertexCount)}}function g(n,C,w){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray, -e.DYNAMIC_DRAW);e.enableVertexAttribArray(C.attributes.position);e.vertexAttribPointer(C.attributes.position,3,e.FLOAT,!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(w==THREE.FlatShading){var x,z,G,M,I,S,E,N,K,X,P=n.count*3;for(X=0;X0&&Na[0]< -ga&&Na[1]>0&&Na[1]0.001&&I.scale>0.001){ra[0]=I.x;ra[1]=I.y;ra[2]=I.z;X=I.size*I.scale/ia;P[0]=X*E;P[1]=X;e.uniform3fv(xa.screenPosition,ra);e.uniform2fv(xa.scale,P);e.uniform1f(xa.rotation,I.rotation); -e.uniform1f(xa.opacity,I.opacity);L(I.blending);R(I.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Y)}function J(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function H(n){var C,w,x,z,G;if(n instanceof THREE.Mesh){w=n.geometry;for(C in w.geometryGroups){x=w.geometryGroups[C];G=!1;for(z in x.__webglCustomAttributes)if(x.__webglCustomAttributes[z].needsUpdate){G= -!0;break}if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||G){G=e.DYNAMIC_DRAW;var M=void 0,I=void 0,S=void 0,E=void 0;S=void 0;var N=void 0,K=void 0,X=void 0,P=void 0,ra=void 0,Na=void 0,xa=void 0,Ma=void 0,cb=void 0,Ga=void 0,Ha=void 0,Fa=void 0,Ua=void 0;K=void 0;X=void 0;E=void 0;P=void 0;E=void 0;var D=void 0,$=void 0;K=void 0;D=void 0;$=void 0;var t=void 0,db=void 0;D=void 0;$=void 0;t=void 0;db=void 0;D=void 0; -$=void 0;t=void 0;db=void 0;D=void 0;$=void 0;t=void 0;E=void 0;P=void 0;N=void 0;S=void 0;S=void 0;D=void 0;$=void 0;t=void 0;var hb=void 0,Ra=0,Sa=0,jb=0,kb=0,Ia=0,Va=0,Pa=0,bb=0,Wa=0,T=0,V=0;$=D=0;var ja=x.__vertexArray,sa=x.__uvArray,la=x.__uv2Array,Ja=x.__normalArray,qa=x.__tangentArray,ha=x.__colorArray,Q=x.__skinVertexAArray,Ba=x.__skinVertexBArray,Oa=x.__skinIndexArray,Ka=x.__skinWeightArray,ib=x.__morphTargetsArrays,gb=x.__webglCustomAttributes;t=void 0;var Xa=x.__faceArray,$a=x.__lineArray, -yb=x.__needsSmoothNormals;Na=x.__vertexColorType;ra=x.__uvType;xa=x.__normalType;var eb=n.geometry,sb=eb.__dirtyVertices,tb=eb.__dirtyElements,rb=eb.__dirtyUvs,ub=eb.__dirtyNormals,vb=eb.__dirtyTangents,wb=eb.__dirtyColors,xb=eb.__dirtyMorphTargets,nb=eb.vertices,zb=x.faces,Cb=eb.faces,Ab=eb.faceVertexUvs[0],Bb=eb.faceVertexUvs[1],ob=eb.skinVerticesA,pb=eb.skinVerticesB,qb=eb.skinIndices,lb=eb.skinWeights,mb=n instanceof THREE.ShadowVolume?eb.edgeFaces:undefined;morphTargets=eb.morphTargets;if(gb)for(hb in gb){gb[hb].offset= -0;gb[hb].offsetSrc=0}M=0;for(I=zb.length;M0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ha,G)}if(ub){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ja,G)}if(vb&&eb.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER, -qa,G)}if(rb&&jb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,sa,G)}if(rb&&kb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,la,G)}if(tb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Xa,G);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,$a,G)}if(T>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,Q,G);e.bindBuffer(e.ARRAY_BUFFER, -x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,G);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,Oa,G);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Ka,G)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Na=n.vertices; -x=n.colors;xa=Na.length;G=x.length;Ma=n.__vertexArray;M=n.__colorArray;cb=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I65535){N[S].counter+=1;E=N[S].hash+"_"+N[S].counter;n.geometryGroups[E]==undefined&&(n.geometryGroups[E]={faces:[],materials:I,vertices:0,numMorphTargets:K})}n.geometryGroups[E].faces.push(z);n.geometryGroups[E].vertices+= -M}}function A(n,C,w){n.push({buffer:C,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(n){if(n!=fa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA, -e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}fa=n}}function O(n,C,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,aa(C.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,aa(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,aa(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,aa(C.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER, -va(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,va(C.minFilter))}}function R(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);n.__webglInit=!0}O(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+ -C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function Ca(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer();n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,aa(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,aa(n.wrapT));e.texParameteri(e.TEXTURE_2D, -e.TEXTURE_MAG_FILTER,aa(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,aa(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,aa(n.format),n.width,n.height,0,aa(n.format),aa(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height); -e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,w;if(n){C= -n.__webglFramebuffer;w=n.width;n=n.height}else{C=null;w=ga;n=ia}if(C!=Ea){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(ma,Da,w,n);Ea=C}}function ka(n,C){var w;if(n=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,C);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(C);return null}return w}function va(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST; -default:return e.LINEAR}}function aa(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR; -case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0} -var e,da=document.createElement("canvas"),ya=[],za=null,Ea=null,Y=!0,oa=this,pa=null,ta=null,fa=null,Z=null,ma=0,Da=0,ga=0,ia=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ta=new THREE.Matrix4,Ya=new Float32Array(16),Za=new Float32Array(16),Qa=new THREE.Vector4,U={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},ca=!0,na=!0,Aa=new THREE.Color(0),La=0;if(b){if(b.stencil!= -undefined)ca=b.stencil;if(b.antialias!==undefined)na=b.antialias;b.clearColor!==undefined&&Aa.setHex(b.clearColor);if(b.clearAlpha!==undefined)La=b.clearAlpha}this.maxMorphTargets=8;this.domElement=da;this.autoClear=!0;this.sortObjects=!0;(function(n,C,w,x){try{if(!(e=da.getContext("experimental-webgl",{antialias:n,stencil:x})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+ -" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r,C.g,C.b,w)})(na,Aa,La,ca);this.context=e;if(ca){var wa={};wa.vertices=new Float32Array(12);wa.faces=new Uint16Array(6);wa.darkness=0.5;wa.vertices[0]=-20;wa.vertices[1]=-20;wa.vertices[2]=-1;wa.vertices[3]= -20;wa.vertices[4]=-20;wa.vertices[5]=-1;wa.vertices[6]=20;wa.vertices[7]=20;wa.vertices[8]=-1;wa.vertices[9]=-20;wa.vertices[10]=20;wa.vertices[11]=-1;wa.faces[0]=0;wa.faces[1]=1;wa.faces[2]=2;wa.faces[3]=0;wa.faces[4]=2;wa.faces[5]=3;wa.vertexBuffer=e.createBuffer();wa.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,wa.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,wa.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,wa.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,wa.faces, -e.STATIC_DRAW);wa.program=e.createProgram();e.attachShader(wa.program,ka("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(wa.program,ka("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(wa.program);wa.vertexLocation=e.getAttribLocation(wa.program,"position");wa.projectionLocation=e.getUniformLocation(wa.program,"projectionMatrix");wa.darknessLocation=e.getUniformLocation(wa.program,"darkness")}var ea={};ea.vertices=new Float32Array(16);ea.faces=new Uint16Array(6); -b=0;ea.vertices[b++]=-1;ea.vertices[b++]=-1;ea.vertices[b++]=0;ea.vertices[b++]=0;ea.vertices[b++]=1;ea.vertices[b++]=-1;ea.vertices[b++]=1;ea.vertices[b++]=0;ea.vertices[b++]=1;ea.vertices[b++]=1;ea.vertices[b++]=1;ea.vertices[b++]=1;ea.vertices[b++]=-1;ea.vertices[b++]=1;ea.vertices[b++]=0;ea.vertices[b++]=1;b=0;ea.faces[b++]=0;ea.faces[b++]=1;ea.faces[b++]=2;ea.faces[b++]=0;ea.faces[b++]=2;ea.faces[b++]=3;ea.vertexBuffer=e.createBuffer();ea.elementBuffer=e.createBuffer();ea.tempTexture=e.createTexture(); -ea.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,ea.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ea.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ea.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ea.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,ea.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D, -e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,ea.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<= -0){ea.hasVertexTexture=!1;ea.program=e.createProgram();e.attachShader(ea.program,ka("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(ea.program,ka("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{ea.hasVertexTexture=!0;ea.program=e.createProgram();e.attachShader(ea.program,ka("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(ea.program,ka("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(ea.program);ea.attributes= -{};ea.uniforms={};ea.attributes.vertex=e.getAttribLocation(ea.program,"position");ea.attributes.uv=e.getAttribLocation(ea.program,"UV");ea.uniforms.renderType=e.getUniformLocation(ea.program,"renderType");ea.uniforms.map=e.getUniformLocation(ea.program,"map");ea.uniforms.occlusionMap=e.getUniformLocation(ea.program,"occlusionMap");ea.uniforms.opacity=e.getUniformLocation(ea.program,"opacity");ea.uniforms.scale=e.getUniformLocation(ea.program,"scale");ea.uniforms.rotation=e.getUniformLocation(ea.program, -"rotation");ea.uniforms.screenPosition=e.getUniformLocation(ea.program,"screenPosition");var fb=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1; -_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW); -_sprite.program=e.createProgram();e.attachShader(_sprite.program,ka("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ka("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale= -e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates"); -_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var ab=!1;this.setSize=function(n,C){da.width=n;da.height=C;this.setViewport(0,0,da.width,da.height)};this.setViewport=function(n,C,w,x){ma= -n;Da=C;ga=w;ia=x;e.viewport(ma,Da,ga,ia)};this.setScissor=function(n,C,w,x){e.scissor(n,C,w,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){Y=n;e.depthMask(n)};this.setClearColorHex=function(n,C){var w=new THREE.Color(n);e.clearColor(w.r,w.g,w.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness= -function(n){wa.darkness=n};this.initMaterial=function(n,C,w,x){var z,G,M;if(n instanceof THREE.MeshDepthMaterial)M="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)M="shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)M="normal";else if(n instanceof THREE.MeshBasicMaterial)M="basic";else if(n instanceof THREE.MeshLambertMaterial)M="lambert";else if(n instanceof THREE.MeshPhongMaterial)M="phong";else if(n instanceof THREE.LineBasicMaterial)M="basic";else n instanceof THREE.ParticleBasicMaterial&& -(M="particle_basic");if(M){var I=THREE.ShaderLib[M];n.uniforms=Uniforms.clone(I.uniforms);n.vertexShader=I.vertexShader;n.fragmentShader=I.fragmentShader}var S,E,N;S=N=I=0;for(E=C.length;S0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights, -"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.morphTargets?"#define USE_MORPHTARGETS":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); -e.attachShader(X,ka("fragment",prefix_fragment+S));e.attachShader(X,ka("vertex",prefix_vertex+E));e.linkProgram(X);e.getProgramParameter(X,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(X,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");X.uniforms={};X.attributes={};var P;S=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(P in I)S.push(P); -P=S;I=0;for(S=P.length;I=0&&e.enableVertexAttribArray(K.color);K.normal>= -0&&e.enableVertexAttribArray(K.normal);K.tangent>=0&&e.enableVertexAttribArray(K.tangent);if(n.skinning&&K.skinVertexA>=0&&K.skinVertexB>=0&&K.skinIndex>=0&&K.skinWeight>=0){e.enableVertexAttribArray(K.skinVertexA);e.enableVertexAttribArray(K.skinVertexB);e.enableVertexAttribArray(K.skinIndex);e.enableVertexAttribArray(K.skinWeight)}for(z in n.attributes)K[z]>=0&&e.enableVertexAttribArray(K[z]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(K.morphTarget0>=0){e.enableVertexAttribArray(K.morphTarget0); -n.numSupportedMorphTargets++}if(K.morphTarget1>=0){e.enableVertexAttribArray(K.morphTarget1);n.numSupportedMorphTargets++}if(K.morphTarget2>=0){e.enableVertexAttribArray(K.morphTarget2);n.numSupportedMorphTargets++}if(K.morphTarget3>=0){e.enableVertexAttribArray(K.morphTarget3);n.numSupportedMorphTargets++}if(K.morphTarget4>=0){e.enableVertexAttribArray(K.morphTarget4);n.numSupportedMorphTargets++}if(K.morphTarget5>=0){e.enableVertexAttribArray(K.morphTarget5);n.numSupportedMorphTargets++}if(K.morphTarget6>= -0){e.enableVertexAttribArray(K.morphTarget6);n.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(z=this.maxMorphTargets;n0||X.faceVertexUvs.length>0)M.__uvArray=new Float32Array(S*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)M.__uv2Array=new Float32Array(S*2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){M.__skinVertexAArray= -new Float32Array(S*4);M.__skinVertexBArray=new Float32Array(S*4);M.__skinIndexArray=new Float32Array(S*4);M.__skinWeightArray=new Float32Array(S*4)}M.__faceArray=new Uint16Array(ra*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));M.__lineArray=new Uint16Array(Na*2);if(M.numMorphTargets){M.__morphTargetsArrays=[];X=0;for(P=M.numMorphTargets;X=0;z--){x=w.__webglObjects[z].object;if(C==x){w.__webglObjects.splice(z,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(w=n.__webglObjects.length;C0&&Ja[0]< +ja&&Ja[1]>0&&Ja[1]0.001&&I.scale>0.001){xa[0]=I.x;xa[1]=I.y;xa[2]=I.z;$=I.size*I.scale/la;V[0]=$*D;V[1]=$;e.uniform3fv(za.screenPosition,xa);e.uniform2fv(za.scale,V);e.uniform1f(za.rotation,I.rotation);e.uniform1f(za.opacity, +I.opacity);M(I.blending);R(I.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Z)}function H(n,C){n._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function G(n){var C,w,x,z,J;if(n instanceof THREE.Mesh){w=n.geometry;for(C in w.geometryGroups){x=w.geometryGroups[C];J=!1;for(z in x.__webglCustomAttributes)if(x.__webglCustomAttributes[z].needsUpdate){J= +!0;break}if(w.__dirtyVertices||w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||J){J=e.DYNAMIC_DRAW;var K=void 0,I=void 0,S=void 0,D=void 0;S=void 0;var O=void 0,L=void 0,$=void 0,V=void 0,xa=void 0,Ja=void 0,za=void 0,ta=void 0,Oa=void 0,Ga=void 0,wa=void 0,Ha=void 0,Ua=void 0;L=void 0;$=void 0;D=void 0;V=void 0;D=void 0;var E=void 0,fa=void 0;L=void 0;E=void 0;fa=void 0;var v=void 0,bb=void 0;E=void 0;fa=void 0;v=void 0;bb=void 0;E=void 0; +fa=void 0;v=void 0;bb=void 0;E=void 0;fa=void 0;v=void 0;D=void 0;V=void 0;O=void 0;S=void 0;S=void 0;E=void 0;fa=void 0;v=void 0;var db=void 0,Ma=0,Pa=0,hb=0,eb=0,$a=0,ab=0,La=0,cb=0,Aa=0,U=0,Qa=0;fa=E=0;var Sa=x.__vertexArray,jb=x.__uvArray,Xa=x.__uv2Array,W=x.__normalArray,ia=x.__tangentArray,ka=x.__colorArray,da=x.__skinVertexAArray,ra=x.__skinVertexBArray,qa=x.__skinIndexArray,ha=x.__skinWeightArray,Y=x.__morphTargetsArrays,Ia=x.__webglCustomAttributes;v=void 0;var Va=x.__faceArray,Ta=x.__lineArray, +ib=x.__needsSmoothNormals;Ja=x.__vertexColorType;xa=x.__uvType;za=x.__normalType;var Wa=n.geometry,fb=Wa.__dirtyVertices,gb=Wa.__dirtyElements,qb=Wa.__dirtyUvs,rb=Wa.__dirtyNormals,sb=Wa.__dirtyTangents,tb=Wa.__dirtyColors,ub=Wa.__dirtyMorphTargets,mb=Wa.vertices,vb=x.faces,yb=Wa.faces,wb=Wa.faceVertexUvs[0],xb=Wa.faceVertexUvs[1],nb=Wa.skinVerticesA,ob=Wa.skinVerticesB,pb=Wa.skinIndices,kb=Wa.skinWeights,lb=n instanceof THREE.ShadowVolume?Wa.edgeFaces:undefined;morphTargets=Wa.morphTargets;if(Ia)for(db in Ia){Ia[db].offset= +0;Ia[db].offsetSrc=0}K=0;for(I=vb.length;K0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ka,J)}if(rb){e.bindBuffer(e.ARRAY_BUFFER,x.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER, +W,J)}if(sb&&Wa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,x.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ia,J)}if(qb&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,jb,J)}if(qb&&eb>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Xa,J)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Va,J);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,x.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER, +Ta,J)}if(U>0){e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,da,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ra,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,qa,J);e.bindBuffer(e.ARRAY_BUFFER,x.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ha,J)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors= +!1}else if(n instanceof THREE.Ribbon){w=n.geometry;if(w.__dirtyVertices||w.__dirtyColors){n=w;C=e.DYNAMIC_DRAW;Ja=n.vertices;x=n.colors;za=Ja.length;J=x.length;ta=n.__vertexArray;K=n.__colorArray;Oa=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I65535){O[S].counter+=1;D=O[S].hash+"_"+O[S].counter;n.geometryGroups[D]==undefined&&(n.geometryGroups[D]= +{faces:[],materials:I,vertices:0,numMorphTargets:L})}n.geometryGroups[D].faces.push(z);n.geometryGroups[D].vertices+=K}}function A(n,C,w){n.push({buffer:C,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(n){if(n!=ga){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD); +e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}ga=n}}function Q(n,C,w){if((w.width&w.width-1)==0&&(w.height&w.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,ca(C.wrapS));e.texParameteri(n,e.TEXTURE_WRAP_T,ca(C.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,ca(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ca(C.minFilter));e.generateMipmap(n)}else{e.texParameteri(n, +e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,va(C.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,va(C.minFilter))}}function R(n,C){if(n.needsUpdate){if(n.__webglInit){e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,n.image)}else{n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE, +n.image);n.__webglInit=!0}Q(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function Da(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer();n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D, +e.TEXTURE_WRAP_S,ca(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,ca(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,ca(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,ca(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,ca(n.format),n.width,n.height,0,ca(n.format),ca(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture, +0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D, +null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,w;if(n){C=n.__webglFramebuffer;w=n.width;n=n.height}else{C=null;w=ja;n=la}if(C!=Fa){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(na,Ea,w,n);Fa=C}}function ma(n,C){var w;if(n=="fragment")w=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(w=e.createShader(e.VERTEX_SHADER));e.shaderSource(w,C);e.compileShader(w);if(!e.getShaderParameter(w,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(w));console.error(C); +return null}return w}function va(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function ca(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR; +case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA; +case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var e,ea=document.createElement("canvas"),ya=[],Ba=null,Fa=null,Z=!0,oa=this,pa=null,sa=null,ga=null,aa=null,na=0,Ea=0,ja=0,la=0,ua=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ra=new THREE.Matrix4,Ya=new Float32Array(16),Za=new Float32Array(16),Na=new THREE.Vector4, +T={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};stencil=b.stencil!==undefined?b.stencil:!0;antialias=b.antialias!==undefined?b.antialias:!1;clearColor=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0);clearAlpha=b.clearAlpha!==undefined?b.clearAlpha:0;this.maxMorphTargets=8;this.domElement=ea;this.autoClear=!0;this.sortObjects=!0;(function(n,C,w,x){try{if(!(e=ea.getContext("experimental-webgl",{antialias:n, +stencil:x})))throw"Error creating WebGL context.";}catch(z){console.error(z)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(C.r, +C.g,C.b,w)})(antialias,clearColor,clearAlpha,stencil);this.context=e;if(stencil){var P={};P.vertices=new Float32Array(12);P.faces=new Uint16Array(6);P.darkness=0.5;P.vertices[0]=-20;P.vertices[1]=-20;P.vertices[2]=-1;P.vertices[3]=20;P.vertices[4]=-20;P.vertices[5]=-1;P.vertices[6]=20;P.vertices[7]=20;P.vertices[8]=-1;P.vertices[9]=-20;P.vertices[10]=20;P.vertices[11]=-1;P.faces[0]=0;P.faces[1]=1;P.faces[2]=2;P.faces[3]=0;P.faces[4]=2;P.faces[5]=3;P.vertexBuffer=e.createBuffer();P.elementBuffer=e.createBuffer(); +e.bindBuffer(e.ARRAY_BUFFER,P.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,P.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,P.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,P.faces,e.STATIC_DRAW);P.program=e.createProgram();e.attachShader(P.program,ma("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(P.program,ma("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(P.program);P.vertexLocation=e.getAttribLocation(P.program,"position");P.projectionLocation= +e.getUniformLocation(P.program,"projectionMatrix");P.darknessLocation=e.getUniformLocation(P.program,"darkness")}var N={};N.vertices=new Float32Array(16);N.faces=new Uint16Array(6);b=0;N.vertices[b++]=-1;N.vertices[b++]=-1;N.vertices[b++]=0;N.vertices[b++]=0;N.vertices[b++]=1;N.vertices[b++]=-1;N.vertices[b++]=1;N.vertices[b++]=0;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=1;N.vertices[b++]=-1;N.vertices[b++]=1;N.vertices[b++]=0;N.vertices[b++]=1;b=0;N.faces[b++]=0;N.faces[b++]= +1;N.faces[b++]=2;N.faces[b++]=0;N.faces[b++]=2;N.faces[b++]=3;N.vertexBuffer=e.createBuffer();N.elementBuffer=e.createBuffer();N.tempTexture=e.createTexture();N.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,N.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,N.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,N.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,N.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,N.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE, +null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D,N.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D, +e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){N.hasVertexTexture=!1;N.program=e.createProgram();e.attachShader(N.program,ma("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(N.program,ma("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{N.hasVertexTexture=!0;N.program=e.createProgram();e.attachShader(N.program,ma("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)); +e.attachShader(N.program,ma("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(N.program);N.attributes={};N.uniforms={};N.attributes.vertex=e.getAttribLocation(N.program,"position");N.attributes.uv=e.getAttribLocation(N.program,"UV");N.uniforms.renderType=e.getUniformLocation(N.program,"renderType");N.uniforms.map=e.getUniformLocation(N.program,"map");N.uniforms.occlusionMap=e.getUniformLocation(N.program,"occlusionMap");N.uniforms.opacity=e.getUniformLocation(N.program, +"opacity");N.uniforms.scale=e.getUniformLocation(N.program,"scale");N.uniforms.rotation=e.getUniformLocation(N.program,"rotation");N.uniforms.screenPosition=e.getUniformLocation(N.program,"screenPosition");var Ca=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]= +1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, +_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,ma("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,ma("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv"); +_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity"); +_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var Ka=!1;this.setSize=function(n,C){ea.width= +n;ea.height=C;this.setViewport(0,0,ea.width,ea.height)};this.setViewport=function(n,C,w,x){na=n;Ea=C;ja=w;la=x;e.viewport(na,Ea,ja,la)};this.setScissor=function(n,C,w,x){e.scissor(n,C,w,x)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){Z=n;e.depthMask(n)};this.setClearColorHex=function(n,C){var w=new THREE.Color(n);e.clearColor(w.r,w.g,w.b,C)};this.setClearColor=function(n,C){e.clearColor(n.r,n.g,n.b,C)};this.clear= +function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){P.darkness=n};this.initMaterial=function(n,C,w,x){var z,J,K;if(n instanceof THREE.MeshDepthMaterial)K="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)K="shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)K="normal";else if(n instanceof THREE.MeshBasicMaterial)K="basic";else if(n instanceof THREE.MeshLambertMaterial)K="lambert";else if(n instanceof +THREE.MeshPhongMaterial)K="phong";else if(n instanceof THREE.LineBasicMaterial)K="basic";else n instanceof THREE.ParticleBasicMaterial&&(K="particle_basic");if(K){var I=THREE.ShaderLib[K];n.uniforms=THREE.UniformsUtils.clone(I.uniforms);n.vertexShader=I.vertexShader;n.fragmentShader=I.fragmentShader}var S,D,O;S=O=I=0;for(D=C.length;S0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.morphTargets?"#define USE_MORPHTARGETS":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); +e.attachShader($,ma("fragment",prefix_fragment+S));e.attachShader($,ma("vertex",prefix_vertex+D));e.linkProgram($);e.getProgramParameter($,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter($,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");$.uniforms={};$.attributes={};var V;S=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(V in I)S.push(V); +V=S;I=0;for(S=V.length;I=0&&e.enableVertexAttribArray(L.color);L.normal>= +0&&e.enableVertexAttribArray(L.normal);L.tangent>=0&&e.enableVertexAttribArray(L.tangent);if(n.skinning&&L.skinVertexA>=0&&L.skinVertexB>=0&&L.skinIndex>=0&&L.skinWeight>=0){e.enableVertexAttribArray(L.skinVertexA);e.enableVertexAttribArray(L.skinVertexB);e.enableVertexAttribArray(L.skinIndex);e.enableVertexAttribArray(L.skinWeight)}for(z in n.attributes)L[z]>=0&&e.enableVertexAttribArray(L[z]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(L.morphTarget0>=0){e.enableVertexAttribArray(L.morphTarget0); +n.numSupportedMorphTargets++}if(L.morphTarget1>=0){e.enableVertexAttribArray(L.morphTarget1);n.numSupportedMorphTargets++}if(L.morphTarget2>=0){e.enableVertexAttribArray(L.morphTarget2);n.numSupportedMorphTargets++}if(L.morphTarget3>=0){e.enableVertexAttribArray(L.morphTarget3);n.numSupportedMorphTargets++}if(L.morphTarget4>=0){e.enableVertexAttribArray(L.morphTarget4);n.numSupportedMorphTargets++}if(L.morphTarget5>=0){e.enableVertexAttribArray(L.morphTarget5);n.numSupportedMorphTargets++}if(L.morphTarget6>= +0){e.enableVertexAttribArray(L.morphTarget6);n.numSupportedMorphTargets++}if(L.morphTarget7>=0){e.enableVertexAttribArray(L.morphTarget7);n.numSupportedMorphTargets++}x.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(z=this.maxMorphTargets;n0||$.faceVertexUvs.length>0)K.__uvArray=new Float32Array(S*2);if($.faceUvs.length>1||$.faceVertexUvs.length>1)K.__uv2Array=new Float32Array(S*2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){K.__skinVertexAArray= +new Float32Array(S*4);K.__skinVertexBArray=new Float32Array(S*4);K.__skinIndexArray=new Float32Array(S*4);K.__skinWeightArray=new Float32Array(S*4)}K.__faceArray=new Uint16Array(xa*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));K.__lineArray=new Uint16Array(Ja*2);if(K.numMorphTargets){K.__morphTargetsArrays=[];$=0;for(V=K.numMorphTargets;$=0;z--){x=w.__webglObjects[z].object;if(C==x){w.__webglObjects.splice(z,1);break}}n.__objectsRemoved.splice(0,1)}C=0;for(w=n.__webglObjects.length;C0}}; THREE.WebGLRenderTarget=function(b,d,c){this.width=b;this.height=d;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBAFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!== undefined?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==undefined?c.stencilBuffer:!0}; @@ -355,13 +355,14 @@ THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.posi 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.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}; -var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,v=j.length;o= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -380,89 +381,88 @@ this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0 (90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var f=this.target.position,g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/ 3.14+this.verticalMin;f=this.target.position;g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this, this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))}; -THREE.PathCamera=function(b){function d(p,o,v,y){var u={name:v,fps:0.6,length:y,hierarchy:[]},B,F=o.getControlPointsArray(),J=o.getLength(),H=F.length,W=0;B=H-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:F[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[B]={time:y,pos:F[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B=0?y:y+g;y=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange; -this.phi=(this.phi-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[0];y=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(u[1]-u[0])/(y[1]-y[0])+u[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,v)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); -this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation= +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,u){var y,t;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange; +this.phi=(this.phi-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0];y=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,u)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); +this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation= d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,o){return function(){o.apply(p,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -var Cube=function(b,d,c,f,g,h,j,k,m){function p(J,H,W,A,L,O,R,Ca){var ka,va,aa=f||1,e=g||1,da=L/2,ya=O/2,za=o.vertices.length;if(J=="x"&&H=="y"||J=="y"&&H=="x")ka="z";else if(J=="x"&&H=="z"||J=="z"&&H=="x"){ka="y";e=h||1}else if(J=="z"&&H=="y"||J=="y"&&H=="z"){ka="x";aa=h||1}var Ea=aa+1,Y=e+1;L/=aa;var oa=O/e;for(va=0;va0){j(0,0,-o-(h||0));for(m=b;m0){j(0,0,o+(g||0));for(m= -b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0){j(0,0,-o-(h||0));for(m=b;m0){j(0,0,o+(g||0)); +for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,y)))-1);p.push(o)}d.push(p)}var u,B,F;g=d.length;for(c=0;c0)for(f=0;f1){u=this.vertices[j].position.clone(); -B=this.vertices[m].position.clone();F=this.vertices[p].position.clone();u.normalize();B.normalize();F.normalize();this.faces.push(new THREE.Face3(j,m,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(F.x,F.y,F.z)]));this.faceVertexUvs[0].push([o,v,J])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(b,d,c,f){this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];THREE.Geometry.call(this);for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c= -1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(b,d,c,f,g,h,j){function k(v,y,u,B,F,J){y=u/B*v;u=Math.cos(y);return new THREE.Vector3(F*(2+u)*0.5*Math.cos(v),F*(2+u)*Math.sin(v)*0.5,J*F*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,y)))-1);p.push(o)}d.push(p)}var t,B,F;g=d.length;for(c=0;c0)for(f=0;f1){t=this.vertices[j].position.clone(); +B=this.vertices[m].position.clone();F=this.vertices[p].position.clone();t.normalize();B.normalize();F.normalize();this.faces.push(new THREE.Face3(j,m,p,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(F.x,F.y,F.z)]));this.faceVertexUvs[0].push([o,u,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Torus=function(b,d,c,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c= +1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; +THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(u,y,t,B,F,H){y=t/B*u;t=Math.cos(y);return new THREE.Vector3(F*(2+t)*0.5*Math.cos(u),F*(2+t)*Math.sin(u)*0.5,H*F*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b>7)-127;na|=(La&127)<<16|Aa<<8;if(na==0&&ea==-127)return 0;return(1-2*(wa>>7))*(1+na*Math.pow(2,-23))*Math.pow(2,ea)}function k(U,ca){var na=o(U,ca),Aa=o(U,ca+1),La=o(U,ca+2);return(o(U,ca+3)<<24)+(La<<16)+(Aa<<8)+na}function m(U,ca){var na=o(U,ca);return(o(U,ca+1)<<8)+na}function p(U,ca){var na=o(U, -ca);return na>127?na-256:na}function o(U,ca){return U.charCodeAt(ca)&255}function v(U){var ca,na,Aa;ca=k(b,U);na=k(b,U+R);Aa=k(b,U+Ca);U=m(b,U+ka);THREE.BinaryLoader.prototype.f3(H,ca,na,Aa,U)}function y(U){var ca,na,Aa,La,wa,ea;ca=k(b,U);na=k(b,U+R);Aa=k(b,U+Ca);La=m(b,U+ka);wa=k(b,U+va);ea=k(b,U+aa);U=k(b,U+e);THREE.BinaryLoader.prototype.f3n(H,L,ca,na,Aa,La,wa,ea,U)}function u(U){var ca,na,Aa,La;ca=k(b,U);na=k(b,U+da);Aa=k(b,U+ya);La=k(b,U+za);U=m(b,U+Ea);THREE.BinaryLoader.prototype.f4(H,ca,na, -Aa,La,U)}function B(U){var ca,na,Aa,La,wa,ea,fb,ab;ca=k(b,U);na=k(b,U+da);Aa=k(b,U+ya);La=k(b,U+za);wa=m(b,U+Ea);ea=k(b,U+Y);fb=k(b,U+oa);ab=k(b,U+pa);U=k(b,U+ta);THREE.BinaryLoader.prototype.f4n(H,L,ca,na,Aa,La,wa,ea,fb,ab,U)}function F(U){var ca,na;ca=k(b,U);na=k(b,U+fa);U=k(b,U+Z);THREE.BinaryLoader.prototype.uv3(H.faceVertexUvs[0],O[ca*2],O[ca*2+1],O[na*2],O[na*2+1],O[U*2],O[U*2+1])}function J(U){var ca,na,Aa;ca=k(b,U);na=k(b,U+ma);Aa=k(b,U+Da);U=k(b,U+ga);THREE.BinaryLoader.prototype.uv4(H.faceVertexUvs[0], -O[ca*2],O[ca*2+1],O[na*2],O[na*2+1],O[Aa*2],O[Aa*2+1],O[U*2],O[U*2+1])}var H=this,W=0,A,L=[],O=[],R,Ca,ka,va,aa,e,da,ya,za,Ea,Y,oa,pa,ta,fa,Z,ma,Da,ga,ia,ua,Ta,Ya,Za,Qa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,f,h);A={signature:b.substr(W,8),header_bytes:o(b,W+8),vertex_coordinate_bytes:o(b,W+9),normal_coordinate_bytes:o(b,W+10),uv_coordinate_bytes:o(b,W+11),vertex_index_bytes:o(b,W+12),normal_index_bytes:o(b,W+13),uv_index_bytes:o(b,W+14),material_index_bytes:o(b,W+15),nvertices:k(b, -W+16),nnormals:k(b,W+16+4),nuvs:k(b,W+16+8),ntri_flat:k(b,W+16+12),ntri_smooth:k(b,W+16+16),ntri_flat_uv:k(b,W+16+20),ntri_smooth_uv:k(b,W+16+24),nquad_flat:k(b,W+16+28),nquad_smooth:k(b,W+16+32),nquad_flat_uv:k(b,W+16+36),nquad_smooth_uv:k(b,W+16+40)};W+=A.header_bytes;R=A.vertex_index_bytes;Ca=A.vertex_index_bytes*2;ka=A.vertex_index_bytes*3;va=A.vertex_index_bytes*3+A.material_index_bytes;aa=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;e=A.vertex_index_bytes*3+A.material_index_bytes+ -A.normal_index_bytes*2;da=A.vertex_index_bytes;ya=A.vertex_index_bytes*2;za=A.vertex_index_bytes*3;Ea=A.vertex_index_bytes*4;Y=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;pa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;ta=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;fa=A.uv_index_bytes;Z=A.uv_index_bytes*2;ma=A.uv_index_bytes;Da=A.uv_index_bytes*2;ga=A.uv_index_bytes*3;h=A.vertex_index_bytes* -3+A.material_index_bytes;Qa=A.vertex_index_bytes*4+A.material_index_bytes;ia=A.ntri_flat*h;ua=A.ntri_smooth*(h+A.normal_index_bytes*3);Ta=A.ntri_flat_uv*(h+A.uv_index_bytes*3);Ya=A.ntri_smooth_uv*(h+A.normal_index_bytes*3+A.uv_index_bytes*3);Za=A.nquad_flat*Qa;h=A.nquad_smooth*(Qa+A.normal_index_bytes*4);Qa=A.nquad_flat_uv*(Qa+A.uv_index_bytes*4);W+=function(U){for(var ca,na,Aa,La=A.vertex_coordinate_bytes*3,wa=U+A.nvertices*La;U>7)-127;N|=(Ka&127)<<16|Ca<<8;if(N==0&&C==-127)return 0;return(1-2*(n>>7))*(1+N*Math.pow(2,-23))*Math.pow(2,C)}function k(T,P){var N=o(T,P),Ca=o(T,P+1),Ka=o(T,P+2);return(o(T,P+3)<<24)+(Ka<<16)+(Ca<<8)+N}function m(T,P){var N=o(T,P);return(o(T,P+1)<<8)+N}function p(T,P){var N=o(T,P);return N>127?N-256:N}function o(T, +P){return T.charCodeAt(P)&255}function u(T){var P,N,Ca;P=k(b,T);N=k(b,T+R);Ca=k(b,T+Da);T=m(b,T+ma);THREE.BinaryLoader.prototype.f3(G,P,N,Ca,T)}function y(T){var P,N,Ca,Ka,n,C;P=k(b,T);N=k(b,T+R);Ca=k(b,T+Da);Ka=m(b,T+ma);n=k(b,T+va);C=k(b,T+ca);T=k(b,T+e);THREE.BinaryLoader.prototype.f3n(G,M,P,N,Ca,Ka,n,C,T)}function t(T){var P,N,Ca,Ka;P=k(b,T);N=k(b,T+ea);Ca=k(b,T+ya);Ka=k(b,T+Ba);T=m(b,T+Fa);THREE.BinaryLoader.prototype.f4(G,P,N,Ca,Ka,T)}function B(T){var P,N,Ca,Ka,n,C,w,x;P=k(b,T);N=k(b,T+ea); +Ca=k(b,T+ya);Ka=k(b,T+Ba);n=m(b,T+Fa);C=k(b,T+Z);w=k(b,T+oa);x=k(b,T+pa);T=k(b,T+sa);THREE.BinaryLoader.prototype.f4n(G,M,P,N,Ca,Ka,n,C,w,x,T)}function F(T){var P,N;P=k(b,T);N=k(b,T+ga);T=k(b,T+aa);THREE.BinaryLoader.prototype.uv3(G.faceVertexUvs[0],Q[P*2],Q[P*2+1],Q[N*2],Q[N*2+1],Q[T*2],Q[T*2+1])}function H(T){var P,N,Ca;P=k(b,T);N=k(b,T+na);Ca=k(b,T+Ea);T=k(b,T+ja);THREE.BinaryLoader.prototype.uv4(G.faceVertexUvs[0],Q[P*2],Q[P*2+1],Q[N*2],Q[N*2+1],Q[Ca*2],Q[Ca*2+1],Q[T*2],Q[T*2+1])}var G=this,X= +0,A,M=[],Q=[],R,Da,ma,va,ca,e,ea,ya,Ba,Fa,Z,oa,pa,sa,ga,aa,na,Ea,ja,la,ua,Ra,Ya,Za,Na;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(G,f,h);A={signature:b.substr(X,8),header_bytes:o(b,X+8),vertex_coordinate_bytes:o(b,X+9),normal_coordinate_bytes:o(b,X+10),uv_coordinate_bytes:o(b,X+11),vertex_index_bytes:o(b,X+12),normal_index_bytes:o(b,X+13),uv_index_bytes:o(b,X+14),material_index_bytes:o(b,X+15),nvertices:k(b,X+16),nnormals:k(b,X+16+4),nuvs:k(b,X+16+8),ntri_flat:k(b,X+16+12),ntri_smooth:k(b, +X+16+16),ntri_flat_uv:k(b,X+16+20),ntri_smooth_uv:k(b,X+16+24),nquad_flat:k(b,X+16+28),nquad_smooth:k(b,X+16+32),nquad_flat_uv:k(b,X+16+36),nquad_smooth_uv:k(b,X+16+40)};X+=A.header_bytes;R=A.vertex_index_bytes;Da=A.vertex_index_bytes*2;ma=A.vertex_index_bytes*3;va=A.vertex_index_bytes*3+A.material_index_bytes;ca=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;e=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;ea=A.vertex_index_bytes;ya=A.vertex_index_bytes* +2;Ba=A.vertex_index_bytes*3;Fa=A.vertex_index_bytes*4;Z=A.vertex_index_bytes*4+A.material_index_bytes;oa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;pa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;sa=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;ga=A.uv_index_bytes;aa=A.uv_index_bytes*2;na=A.uv_index_bytes;Ea=A.uv_index_bytes*2;ja=A.uv_index_bytes*3;h=A.vertex_index_bytes*3+A.material_index_bytes;Na=A.vertex_index_bytes*4+A.material_index_bytes; +la=A.ntri_flat*h;ua=A.ntri_smooth*(h+A.normal_index_bytes*3);Ra=A.ntri_flat_uv*(h+A.uv_index_bytes*3);Ya=A.ntri_smooth_uv*(h+A.normal_index_bytes*3+A.uv_index_bytes*3);Za=A.nquad_flat*Na;h=A.nquad_smooth*(Na+A.normal_index_bytes*4);Na=A.nquad_flat_uv*(Na+A.uv_index_bytes*4);X+=function(T){for(var P,N,Ca,Ka=A.vertex_coordinate_bytes*3,n=T+A.nvertices*Ka;T=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;fthis.size-1&&(m=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);p=Math.floor(p+k);p>this.size-1&&(p= -this.size-1);var u=Math.floor(o-k);u<1&&(u=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,F,J,H,W,A;v0&&(this.field[J+B]+=H)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,p=this.size,o=this.yd,v=this.zd,y=this.field,u=p*Math.sqrt(c/f);u>p&&(u=p);for(g=0;g0)for(h=0;ho&&(B=o);for(h=0;h0){m=h*v;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;fthis.size-1&&(m=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);p=Math.floor(p+k);p>this.size-1&&(p= +this.size-1);var t=Math.floor(o-k);t<1&&(t=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,F,H,G,X,A;u0&&(this.field[H+B]+=G)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,p=this.size,o=this.yd,u=this.zd,y=this.field,t=p*Math.sqrt(c/f);t>p&&(t=p);for(g=0;g0)for(h=0;ho&&(B=o);for(h=0;h0){m=h*u;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; diff --git a/build/custom/ThreeDOM.js b/build/custom/ThreeDOM.js index c59f18dd..8f91123d 100644 --- a/build/custom/ThreeDOM.js +++ b/build/custom/ThreeDOM.js @@ -1,5 +1,5 @@ // ThreeDOM.js r38 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; +var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(a){this.setHex(a)}; THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,g,f,i,h;if(c==0)e=d=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:e=h;d=c;g=a;break;case 2:e=a;d=c;g=b;break;case 3:e=a;d=h;g=c;break;case 4:e=b;d=a;g=c;break;case 5:e=c;d=a; g=h;break;case 6:case 0:e=c;d=b;g=a}}this.r=e;this.g=d;this.b=g;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index dec48508..2317b17d 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,11 +1,12 @@ // ThreeExtras.js r38 - http://github.com/mrdoob/three.js var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,e=c?b.geometry:b,f=a.vertices,h=e.vertices,g=a.faces,j=e.faces,l=a.faceVertexUvs[0];e=e.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var k=0,n=h.length;k= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", @@ -31,31 +32,31 @@ p,t=new THREE.Geometry;for(n=0;n=0?p:p+e;p=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange; this.phi=(this.phi-p[0])*(t[1]-t[0])/(p[1]-p[0])+t[0];p=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(t[1]-t[0])/(p[1]-p[0])+t[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,n)};this.onMouseMove=function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); -this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),g=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(g,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= +this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),g=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(g,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -var Cube=function(a,b,c,d,e,f,h,g,j){function l(u,B,z,m,y,C,G,K){var J,I,E=d||1,L=e||1,P=y/2,Q=C/2,R=k.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=f||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=f||1}var M=E+1,F=L+1;y/=E;var N=C/L;for(I=0;I0){h(0,0,-k-(f||0));for(j=a;j0){h(0,0,k+(e||0));for(j= -a+a/2;j<2*a;j++)g.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0){h(0,0,-k-(f||0));for(j=a;j0){h(0,0,k+(e||0)); +for(j=a+a/2;j<2*a;j++)g.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,g,p)))-1);l.push(k)}b.push(l)}var t,w,x;e=b.length;for(c=0;c0)for(d=0;d1){t=this.vertices[h].position.clone(); -w=this.vertices[j].position.clone();x=this.vertices[l].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([k,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= -1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;e=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,e,f,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,b,c,d,e,f,h){function g(n,p,t,w,x,u){p=t/w*n;t=Math.cos(p);return new THREE.Vector3(x*(2+t)*0.5*Math.cos(n),x*(2+t)*Math.sin(n)*0.5,u*x*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,g,p)))-1);l.push(k)}b.push(l)}var t,w,x;e=b.length;for(c=0;c0)for(d=0;d1){t=this.vertices[h].position.clone(); +w=this.vertices[j].position.clone();x=this.vertices[l].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([k,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Torus=function(a,b,c,d){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= +1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;e=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,e,f,h));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; +THREE.TorusKnot=function(a,b,c,d,e,f,h){function g(n,p,t,w,x,u){p=t/w*n;t=Math.cos(p);return new THREE.Vector3(x*(2+t)*0.5*Math.cos(n),x*(2+t)*Math.sin(n)*0.5,u*x*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index 19a805ff..3ea31350 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -1,5 +1,5 @@ // ThreeWebGL.js r38 - http://github.com/mrdoob/three.js -var THREE=THREE||{};THREE.Color=function(b){this.setHex(b)}; +var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)}; THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,e,d){this.r=b;this.g=e;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,e,d){var h,g,k,i,p,q;if(d==0)h=g=k=0;else{i=Math.floor(b*6);p=b*6-i;b=d*(1-e);q=d*(1-e*p);e=d*(1-e*(1-p));switch(i){case 1:h=q;g=d;k=b;break;case 2:h=b;g=d;k=e;break;case 3:h=b;g=q;k=d;break;case 4:h=e;g=b;k=d;break;case 5:h=d;g=b; k=q;break;case 6:case 0:h=d;g=e;k=b}}this.r=h;this.g=g;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g* 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,e){this.set(b||0,e||0)}; @@ -12,7 +12,7 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,e,d,h){this.set(b||0,e||0,d||0,h||1)}; THREE.Vector4.prototype={set:function(b,e,d,h){this.x=b;this.y=e;this.z=d;this.w=h;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y,b.z+e.z,b.w+e.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.y,b.z-e.z,b.w-e.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,e){this.set(this.x+(b.x-this.x)*e,this.y+(b.y-this.y)*e,this.z+(b.z-this.z)*e,this.w+(b.w-this.w)*e)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,e){this.origin=b||new THREE.Vector3;this.direction=e||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(b){var e,d,h=b.objects,g=[];b=0;for(e=h.length;b0&&U>0&&Z+U< +THREE.Ray.prototype={intersectScene:function(b){var e,d,h=b.objects,g=[];b=0;for(e=h.length;b0&&V>0&&Z+V< 1}var d,h,g,k,i,p,q,u,D,E,I,F=b.geometry,M=F.vertices,N=[];d=0;for(h=F.faces.length;d0:D<0)){u=u.dot((new THREE.Vector3).sub(k, E))/D;E=E.addSelf(I.multiplyScalar(u));if(g instanceof THREE.Face3){if(e(E,k,i,p)){g={distance:this.origin.distanceTo(E),point:E,face:g,object:b};N.push(g)}}else if(g instanceof THREE.Face4&&(e(E,k,i,q)||e(E,i,p,q))){g={distance:this.origin.distanceTo(E),point:E,face:g,object:b};N.push(g)}}}return N}}; THREE.Rectangle=function(){function b(){k=h-e;i=g-d}var e,d,h,g,k,i,p=!0;this.getX=function(){return e};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return i};this.getLeft=function(){return e};this.getTop=function(){return d};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(q,u,D,E){p=!1;e=q;d=u;h=D;g=E;b()};this.addPoint=function(q,u){if(p){p=!1;e=q;d=u;h=q;g=u}else{e=eq?h:q;g=g>u?g:u}b()}; @@ -23,8 +23,8 @@ THREE.Matrix4=function(b,e,d,h,g,k,i,p,q,u,D,E,I,F,M,N){this.set(b||1,e||0,d||0, THREE.Matrix4.prototype={set:function(b,e,d,h,g,k,i,p,q,u,D,E,I,F,M,N){this.n11=b;this.n12=e;this.n13=d;this.n14=h;this.n21=g;this.n22=k;this.n23=i;this.n24=p;this.n31=q;this.n32=u;this.n33=D;this.n34=E;this.n41=I;this.n42=F;this.n43=M;this.n44=N;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,e,d){var h=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,e).normalize();if(k.length()===0)k.z=1;h.cross(d,k).normalize();if(h.length()===0){k.x+=1.0E-4;h.cross(d,k).normalize()}g.cross(k,h).normalize();this.n11=h.x;this.n12=g.x;this.n13=k.x;this.n21=h.y;this.n22=g.y;this.n23=k.y;this.n31=h.z;this.n32=g.z;this.n33=k.z;return this},multiplyVector3:function(b){var e=b.x,d=b.y,h=b.z,g=1/(this.n41*e+this.n42*d+this.n43*h+this.n44);b.x=(this.n11*e+this.n12*d+this.n13*h+this.n14)*g;b.y=(this.n21*e+this.n22*d+this.n23* h+this.n24)*g;b.z=(this.n31*e+this.n32*d+this.n33*h+this.n34)*g;return b},multiplyVector4:function(b){var e=b.x,d=b.y,h=b.z,g=b.w;b.x=this.n11*e+this.n12*d+this.n13*h+this.n14*g;b.y=this.n21*e+this.n22*d+this.n23*h+this.n24*g;b.z=this.n31*e+this.n32*d+this.n33*h+this.n34*g;b.w=this.n41*e+this.n42*d+this.n43*h+this.n44*g;return b},rotateAxis:function(b){var e=b.x,d=b.y,h=b.z;b.x=e*this.n11+d*this.n12+h*this.n13;b.y=e*this.n21+d*this.n22+h*this.n23;b.z=e*this.n31+d*this.n32+h*this.n33;b.normalize(); -return b},crossVector:function(b){var e=new THREE.Vector4;e.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;e.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;e.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;e.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return e},multiply:function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,U=b.n43,L=b.n44,sa=e.n11,da=e.n12,oa=e.n13,Z=e.n14,K=e.n21,Ia=e.n22, -ca=e.n23,Ea=e.n24,fa=e.n31,c=e.n32,R=e.n33,pa=e.n34;this.n11=d*sa+h*K+g*fa;this.n12=d*da+h*Ia+g*c;this.n13=d*oa+h*ca+g*R;this.n14=d*Z+h*Ea+g*pa+k;this.n21=i*sa+p*K+q*fa;this.n22=i*da+p*Ia+q*c;this.n23=i*oa+p*ca+q*R;this.n24=i*Z+p*Ea+q*pa+u;this.n31=D*sa+E*K+I*fa;this.n32=D*da+E*Ia+I*c;this.n33=D*oa+E*ca+I*R;this.n34=D*Z+E*Ea+I*pa+F;this.n41=M*sa+N*K+U*fa;this.n42=M*da+N*Ia+U*c;this.n43=M*oa+N*ca+U*R;this.n44=M*Z+N*Ea+U*pa+L;return this},multiplyToArray:function(b,e,d){this.multiply(b,e);d[0]=this.n11; +return b},crossVector:function(b){var e=new THREE.Vector4;e.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;e.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;e.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;e.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return e},multiply:function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44,sa=e.n11,da=e.n12,oa=e.n13,Z=e.n14,K=e.n21,Ia=e.n22, +ca=e.n23,Ea=e.n24,fa=e.n31,c=e.n32,S=e.n33,pa=e.n34;this.n11=d*sa+h*K+g*fa;this.n12=d*da+h*Ia+g*c;this.n13=d*oa+h*ca+g*S;this.n14=d*Z+h*Ea+g*pa+k;this.n21=i*sa+p*K+q*fa;this.n22=i*da+p*Ia+q*c;this.n23=i*oa+p*ca+q*S;this.n24=i*Z+p*Ea+q*pa+u;this.n31=D*sa+E*K+I*fa;this.n32=D*da+E*Ia+I*c;this.n33=D*oa+E*ca+I*S;this.n34=D*Z+E*Ea+I*pa+F;this.n41=M*sa+N*K+V*fa;this.n42=M*da+N*Ia+V*c;this.n43=M*oa+N*ca+V*S;this.n44=M*Z+N*Ea+V*pa+L;return this},multiplyToArray:function(b,e,d){this.multiply(b,e);d[0]=this.n11; d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*= b;return this},determinant:function(){var b=this.n11,e=this.n12,d=this.n13,h=this.n14,g=this.n21,k=this.n22,i=this.n23,p=this.n24,q=this.n31,u=this.n32,D=this.n33,E=this.n34,I=this.n41,F=this.n42,M=this.n43,N=this.n44;return h*i*u*I-d*p*u*I-h*k*D*I+e*p*D*I+d*k*E*I-e*i*E*I-h*i*q*F+d*p*q*F+h*g*D*F-b*p*D*F-d*g*E*F+b*i*E*F+h*k*q*M-e*p*q*M-h*g*u*M+b*p*u*M+e*g*E*M-b*k*E*M-d*k*q*N+e*i*q*N+d*g*u*N-b*i*u*N-e*g*D*N+b*k*D*N},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31= this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]= @@ -34,8 +34,8 @@ b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=t 1-d,k=b.x,i=b.y,p=b.z,q=g*k,u=g*i;this.set(q*k+d,q*i-h*p,q*p+h*i,0,q*i+h*p,u*i+d,u*p-h*k,0,q*p-h*i,u*p+h*k,g*p*p+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var e=b.x,d=b.y,h=b.z;b=Math.cos(e);e=Math.sin(e);var g=Math.cos(d);d=Math.sin(d);var k=Math.cos(h);h=Math.sin(h);var i=b*d,p=e*d;this.n11=g*k;this.n12=-g*h;this.n13=d;this.n21=p*k+b*h;this.n22=-p*h+b*k;this.n23=-e*g;this.n31=-i*k+e*h;this.n32=i*h+e*k;this.n33= b*g;return this},setRotationFromQuaternion:function(b){var e=b.x,d=b.y,h=b.z,g=b.w,k=e+e,i=d+d,p=h+h;b=e*k;var q=e*i;e*=p;var u=d*i;d*=p;h*=p;k*=g;i*=g;g*=p;this.n11=1-(u+h);this.n12=q-g;this.n13=e+i;this.n21=q+g;this.n22=1-(b+h);this.n23=d-k;this.n31=e-i;this.n32=d+k;this.n33=1-(b+u);return this},scale:function(b){var e=b.x,d=b.y;b=b.z;this.n11*=e;this.n12*=d;this.n13*=b;this.n21*=e;this.n22*=d;this.n23*=b;this.n31*=e;this.n32*=d;this.n33*=b;this.n41*=e;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14= b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,e){var d=1/e.x,h=1/e.y,g=1/e.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*h;this.n22=b.n22*h;this.n32=b.n32*h;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,U=b.n43,L=b.n44;e===undefined&&(e=new THREE.Matrix4);e.n11=q*F*N-u*I*N+u*E*U-p*F*U-q*E*L+p*I*L;e.n12=k*I*N-g*F*N-k*E*U+h*F*U+g*E*L-h*I*L;e.n13=g*u*N-k*q*N+k*p*U-h*u*U-g*p*L+h*q*L;e.n14=k*q*E-g*u*E-k*p*I+h*u*I+g*p*F-h*q*F;e.n21=u*I*M-q*F*M-u*D*U+i*F*U+q*D*L-i*I*L;e.n22=g*F*M-k*I*M+k*D*U-d*F*U-g*D*L+d*I*L;e.n23=k*q*M-g*u*M-k*i*U+d*u*U+g*i*L-d*q*L; -e.n24=g*u*D-k*q*D+k*i*I-d*u*I-g*i*F+d*q*F;e.n31=p*F*M-u*E*M+u*D*N-i*F*N-p*D*L+i*E*L;e.n32=k*E*M-h*F*M-k*D*N+d*F*N+h*D*L-d*E*L;e.n33=g*u*M-k*p*M+k*i*N-d*u*N-h*i*L+d*p*L;e.n34=k*p*D-h*u*D-k*i*E+d*u*E+h*i*F-d*p*F;e.n41=q*E*M-p*I*M-q*D*N+i*I*N+p*D*U-i*E*U;e.n42=h*I*M-g*E*M+g*D*N-d*I*N-h*D*U+d*E*U;e.n43=g*p*M-h*q*M-g*i*N+d*q*N+h*i*U-d*p*U;e.n44=h*q*D-g*p*D+g*i*E-d*q*E-h*i*I+d*p*I;e.multiplyScalar(1/b.determinant());return e}; +THREE.Matrix4.makeInvert=function(b,e){var d=b.n11,h=b.n12,g=b.n13,k=b.n14,i=b.n21,p=b.n22,q=b.n23,u=b.n24,D=b.n31,E=b.n32,I=b.n33,F=b.n34,M=b.n41,N=b.n42,V=b.n43,L=b.n44;e===undefined&&(e=new THREE.Matrix4);e.n11=q*F*N-u*I*N+u*E*V-p*F*V-q*E*L+p*I*L;e.n12=k*I*N-g*F*N-k*E*V+h*F*V+g*E*L-h*I*L;e.n13=g*u*N-k*q*N+k*p*V-h*u*V-g*p*L+h*q*L;e.n14=k*q*E-g*u*E-k*p*I+h*u*I+g*p*F-h*q*F;e.n21=u*I*M-q*F*M-u*D*V+i*F*V+q*D*L-i*I*L;e.n22=g*F*M-k*I*M+k*D*V-d*F*V-g*D*L+d*I*L;e.n23=k*q*M-g*u*M-k*i*V+d*u*V+g*i*L-d*q*L; +e.n24=g*u*D-k*q*D+k*i*I-d*u*I-g*i*F+d*q*F;e.n31=p*F*M-u*E*M+u*D*N-i*F*N-p*D*L+i*E*L;e.n32=k*E*M-h*F*M-k*D*N+d*F*N+h*D*L-d*E*L;e.n33=g*u*M-k*p*M+k*i*N-d*u*N-h*i*L+d*p*L;e.n34=k*p*D-h*u*D-k*i*E+d*u*E+h*i*F-d*p*F;e.n41=q*E*M-p*I*M-q*D*N+i*I*N+p*D*V-i*E*V;e.n42=h*I*M-g*E*M+g*D*N-d*I*N-h*D*V+d*E*V;e.n43=g*p*M-h*q*M-g*i*N+d*q*N+h*i*V-d*p*V;e.n44=h*q*D-g*p*D+g*i*E-d*q*E-h*i*I+d*p*I;e.multiplyScalar(1/b.determinant());return e}; THREE.Matrix4.makeInvert3x3=function(b){var e=b.m33,d=e.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,i=-b.n33*b.n12+b.n32*b.n13,p=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,u=b.n23*b.n12-b.n22*b.n13,D=-b.n23*b.n11+b.n21*b.n13,E=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*i+b.n31*u;if(b==0)throw"matrix not invertible";b=1/b;d[0]=b*h;d[1]=b*g;d[2]=b*k;d[3]=b*i;d[4]=b*p;d[5]=b*q;d[6]=b*u;d[7]=b*D;d[8]=b*E;return e}; THREE.Matrix4.makeFrustum=function(b,e,d,h,g,k){var i;i=new THREE.Matrix4;i.n11=2*g/(e-b);i.n12=0;i.n13=(e+b)/(e-b);i.n14=0;i.n21=0;i.n22=2*g/(h-d);i.n23=(h+d)/(h-d);i.n24=0;i.n31=0;i.n32=0;i.n33=-(k+g)/(k-g);i.n34=-2*k*g/(k-g);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(b,e,d,h){var g;b=d*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*e,b*e,g,b,d,h)}; THREE.Matrix4.makeOrtho=function(b,e,d,h,g,k){var i,p,q,u;i=new THREE.Matrix4;p=e-b;q=d-h;u=k-g;i.n11=2/p;i.n12=0;i.n13=0;i.n14=-((e+b)/p);i.n21=0;i.n22=2/q;i.n23=0;i.n24=-((d+h)/q);i.n31=0;i.n32=0;i.n33=-2/u;i.n34=-((k+g)/u);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; @@ -56,8 +56,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,e,d;b=0;for(e=this.f d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var e,d,h,g,k,i,p=new THREE.Vector3,q=new THREE.Vector3;h=0;for(g=this.faces.length;h0){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 e=1,d=this.vertices.length;ethis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,e=0,d=this.vertices.length;e1){b=d.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var h=1;h=this.LODs[h].visibleAtDistance){this.LODs[h-1].object3D.visible= !1;this.LODs[h].object3D.visible=!0}else break;for(;hE){d=D;D=E;E=d}}else if(DF){d=I;I=F;F=d}}else if(IE){d=D;D=E;E=d}}else if(DF){d=I;I=F;F=d}}else if(I=0&&ta>=0&&aa>=0&&ma>=0)return!0;else if(Fa<0&&ta<0||aa<0&&ma<0)return!1;else{if(Fa<0)pa=Math.max(pa,Fa/(Fa-ta));else ta<0&&(ra=Math.min(ra,Fa/(Fa-ta)));if(aa<0)pa=Math.max(pa,aa/(aa-ma));else ma<0&&(ra=Math.min(ra,aa/(aa-ma)));if(raFa&&i.positionScreen.z=0&&ta>=0&&aa>=0&&ma>=0)return!0;else if(Fa<0&&ta<0||aa<0&&ma<0)return!1;else{if(Fa<0)pa=Math.max(pa,Fa/(Fa-ta));else ta<0&&(ra=Math.min(ra,Fa/(Fa-ta)));if(aa<0)pa=Math.max(pa,aa/(aa-ma));else ma<0&&(ra=Math.min(ra,aa/(aa-ma)));if(raFa&&i.positionScreen.z0&&Z.z<1){Pa=da[sa]=da[sa]||new THREE.RenderableParticle;sa++;L=Pa;L.x=Z.x/Z.w;L.y=Z.y/Z.w;L.z=Z.z;L.rotation=$.rotation.z;L.scale.x=$.scale.x*Math.abs(L.x-(Z.x+R.projectionMatrix.n11)/(Z.w+R.projectionMatrix.n14));L.scale.y=$.scale.y*Math.abs(L.y-(Z.y+R.projectionMatrix.n22)/(Z.w+R.projectionMatrix.n24));L.materials=$.materials;ra.push(L)}}}}pa&&ra.sort(e);return ra}}; +Y.positionScreen.y)-(ya.positionScreen.y-Y.positionScreen.y)*(wa.positionScreen.x-Y.positionScreen.x)<0||(wa.positionScreen.x-qa.positionScreen.x)*(ya.positionScreen.y-qa.positionScreen.y)-(wa.positionScreen.y-qa.positionScreen.y)*(ya.positionScreen.x-qa.positionScreen.x)<0))){J=F[I]=F[I]||new THREE.RenderableFace4;I++;u=J;u.v1.copy(Y);u.v2.copy(wa);u.v3.copy(qa);u.v4.copy(ya)}else continue}u.normalWorld.copy(na.normal);Ta.multiplyVector3(u.normalWorld);u.centroidWorld.copy(na.centroid);Pa.multiplyVector3(u.centroidWorld); +u.centroidScreen.copy(u.centroidWorld);K.multiplyVector3(u.centroidScreen);qa=na.vertexNormals;Y=0;for(wa=qa.length;Y0&&Z.z<1){Pa=da[sa]=da[sa]||new THREE.RenderableParticle;sa++;L=Pa;L.x=Z.x/Z.w;L.y=Z.y/Z.w;L.z=Z.z;L.rotation=$.rotation.z;L.scale.x=$.scale.x*Math.abs(L.x-(Z.x+S.projectionMatrix.n11)/(Z.w+S.projectionMatrix.n14));L.scale.y=$.scale.y*Math.abs(L.y-(Z.y+S.projectionMatrix.n22)/(Z.w+S.projectionMatrix.n24));L.materials=$.materials;ra.push(L)}}}}pa&&ra.sort(e);return ra}}; THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,e,d){d&&b.update(undefined,!1,e);d=b.sounds;var h,g=d.length;for(h=0;h 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", -default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"}; +default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var e,d,h,g={};for(e=0;e0&&W[0]0&&W[1]0.001&&v.scale>0.001){O[0]=v.x;O[1]=v.y;O[2]=v.z;G=v.size*v.scale/za;B[0]=G*t;B[1]=G;c.uniform3fv(P.screenPosition,O);c.uniform2fv(P.scale,B);c.uniform1f(P.rotation,v.rotation);c.uniform1f(P.opacity,v.opacity);oa(v.blending);K(v.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT, -0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function U(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var s,m,n,o,w;if(f instanceof THREE.Mesh){m=f.geometry;for(s in m.geometryGroups){n=m.geometryGroups[s];w=!1;for(o in n.__webglCustomAttributes)if(n.__webglCustomAttributes[o].needsUpdate){w=!0;break}if(m.__dirtyVertices|| -m.__dirtyMorphTargets||m.__dirtyElements||m.__dirtyUvs||m.__dirtyNormals||m.__dirtyColors||m.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,v=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,G=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,S=void 0,Q=void 0,T=void 0,ua=void 0;z=void 0;G=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,H=void 0;z=void 0;r=void 0;H=void 0;var j=void 0,Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0; -H=void 0;j=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;H=void 0;j=void 0;var Va=void 0,va=0,Aa=0,ab=0,bb=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;H=r=0;var Ca=n.__vertexArray,hb=n.__uvArray,ib=n.__uv2Array,Qa=n.__normalArray,ha=n.__tangentArray,Da=n.__colorArray,ia=n.__skinVertexAArray,ja=n.__skinVertexBArray,ka=n.__skinIndexArray,la=n.__skinWeightArray,jb=n.__morphTargetsArrays,Ra=n.__webglCustomAttributes;j=void 0;var Na=n.__faceArray,Oa=n.__lineArray,sb=n.__needsSmoothNormals;W=n.__vertexColorType; -O=n.__uvType;P=n.__normalType;var Ha=f.geometry,kb=Ha.__dirtyVertices,lb=Ha.__dirtyElements,gb=Ha.__dirtyUvs,mb=Ha.__dirtyNormals,nb=Ha.__dirtyTangents,ob=Ha.__dirtyColors,pb=Ha.__dirtyMorphTargets,cb=Ha.vertices,tb=n.faces,yb=Ha.faces,ub=Ha.faceVertexUvs[0],vb=Ha.faceVertexUvs[1],db=Ha.skinVerticesA,eb=Ha.skinVerticesB,fb=Ha.skinIndices,Wa=Ha.skinWeights,$a=f instanceof THREE.ShadowVolume?Ha.edgeFaces:undefined;morphTargets=Ha.morphTargets;if(Ra)for(Va in Ra){Ra[Va].offset=0;Ra[Va].offsetSrc=0}x= -0;for(v=tb.length;x0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(mb){c.bindBuffer(c.ARRAY_BUFFER,n.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(nb&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,n.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,w)}if(gb&&ab>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,hb,w)}if(gb&& -bb>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,ib,w)}if(lb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,w);c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER, +0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ta)}function V(f,s){f._modelViewMatrix.multiplyToArray(s.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var s,m,n,o,w;if(f instanceof THREE.Mesh){m=f.geometry;for(s in m.geometryGroups){n=m.geometryGroups[s];w=!1;for(o in n.__webglCustomAttributes)if(n.__webglCustomAttributes[o].needsUpdate){w=!0;break}if(m.__dirtyVertices|| +m.__dirtyMorphTargets||m.__dirtyElements||m.__dirtyUvs||m.__dirtyNormals||m.__dirtyColors||m.__dirtyTangents||w){w=c.DYNAMIC_DRAW;var x=void 0,v=void 0,A=void 0,t=void 0;A=void 0;var y=void 0,z=void 0,G=void 0,B=void 0,O=void 0,W=void 0,P=void 0,X=void 0,Ga=void 0,T=void 0,Q=void 0,U=void 0,ua=void 0;z=void 0;G=void 0;t=void 0;B=void 0;t=void 0;var r=void 0,H=void 0;z=void 0;r=void 0;H=void 0;var j=void 0,Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0;H=void 0;j=void 0;Ka=void 0;r=void 0; +H=void 0;j=void 0;t=void 0;B=void 0;y=void 0;A=void 0;A=void 0;r=void 0;H=void 0;j=void 0;var Va=void 0,va=0,Aa=0,Za=0,$a=0,Ja=0,La=0,ea=0,Ma=0,xa=0,C=0,Ba=0;H=r=0;var Ca=n.__vertexArray,fb=n.__uvArray,gb=n.__uv2Array,Qa=n.__normalArray,ha=n.__tangentArray,Da=n.__colorArray,ia=n.__skinVertexAArray,ja=n.__skinVertexBArray,ka=n.__skinIndexArray,la=n.__skinWeightArray,hb=n.__morphTargetsArrays,Ra=n.__webglCustomAttributes;j=void 0;var Na=n.__faceArray,Oa=n.__lineArray,qb=n.__needsSmoothNormals;W=n.__vertexColorType; +O=n.__uvType;P=n.__normalType;var Ha=f.geometry,ib=Ha.__dirtyVertices,jb=Ha.__dirtyElements,eb=Ha.__dirtyUvs,kb=Ha.__dirtyNormals,lb=Ha.__dirtyTangents,mb=Ha.__dirtyColors,nb=Ha.__dirtyMorphTargets,ab=Ha.vertices,rb=n.faces,ub=Ha.faces,sb=Ha.faceVertexUvs[0],tb=Ha.faceVertexUvs[1],bb=Ha.skinVerticesA,cb=Ha.skinVerticesB,db=Ha.skinIndices,Wa=Ha.skinWeights,Ya=f instanceof THREE.ShadowVolume?Ha.edgeFaces:undefined;morphTargets=Ha.morphTargets;if(Ra)for(Va in Ra){Ra[Va].offset=0;Ra[Va].offsetSrc=0}x= +0;for(v=rb.length;x0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Da,w)}if(kb){c.bindBuffer(c.ARRAY_BUFFER,n.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Qa,w)}if(lb&&Ha.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,n.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,w)}if(eb&&Za>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,fb,w)}if(eb&& +$a>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,gb,w)}if(jb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,w);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Oa,w)}if(C>0){c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,w);c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,w);c.bindBuffer(c.ARRAY_BUFFER, n.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,w);c.bindBuffer(c.ARRAY_BUFFER,n.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,la,w)}}}m.__dirtyVertices=!1;m.__dirtyMorphTargets=!1;m.__dirtyElements=!1;m.__dirtyUvs=!1;m.__dirtyNormals=!1;m.__dirtyTangents=!1;m.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){m=f.geometry;if(m.__dirtyVertices||m.__dirtyColors){f=m;s=c.DYNAMIC_DRAW;W=f.vertices;n=f.colors;P=W.length;w=n.length;X=f.__vertexArray;x=f.__colorArray;Ga=f.__dirtyColors; if(f.__dirtyVertices){for(v=0;v0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+m.maxDirLights,"#define MAX_POINT_LIGHTS "+m.maxPointLights,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.lightMap?"#define USE_LIGHTMAP":"",m.vertexColors? "#define USE_COLOR":"",m.skinning?"#define USE_SKINNING":"",m.morphTargets?"#define USE_MORPHTARGETS":"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n"); @@ -280,21 +280,21 @@ B=A;v=0;for(A=B.length;v=0&&c.enableVertexAttribArray(z.tangent);if(f.skinning&&z.skinVertexA>=0&&z.skinVertexB>=0&&z.skinIndex>=0&&z.skinWeight>=0){c.enableVertexAttribArray(z.skinVertexA);c.enableVertexAttribArray(z.skinVertexB);c.enableVertexAttribArray(z.skinIndex);c.enableVertexAttribArray(z.skinWeight)}for(o in f.attributes)z[o]>=0&&c.enableVertexAttribArray(z[o]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(z.morphTarget0>=0){c.enableVertexAttribArray(z.morphTarget0); f.numSupportedMorphTargets++}if(z.morphTarget1>=0){c.enableVertexAttribArray(z.morphTarget1);f.numSupportedMorphTargets++}if(z.morphTarget2>=0){c.enableVertexAttribArray(z.morphTarget2);f.numSupportedMorphTargets++}if(z.morphTarget3>=0){c.enableVertexAttribArray(z.morphTarget3);f.numSupportedMorphTargets++}if(z.morphTarget4>=0){c.enableVertexAttribArray(z.morphTarget4);f.numSupportedMorphTargets++}if(z.morphTarget5>=0){c.enableVertexAttribArray(z.morphTarget5);f.numSupportedMorphTargets++}if(z.morphTarget6>= 0){c.enableVertexAttribArray(z.morphTarget6);f.numSupportedMorphTargets++}if(z.morphTarget7>=0){c.enableVertexAttribArray(z.morphTarget7);f.numSupportedMorphTargets++}n.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(o=this.maxMorphTargets;f0||G.faceVertexUvs.length>0)x.__uvArray=new Float32Array(A*2);if(G.faceUvs.length>1||G.faceVertexUvs.length>1)x.__uv2Array=new Float32Array(A*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length){x.__skinVertexAArray=new Float32Array(A*4);x.__skinVertexBArray=new Float32Array(A* -4);x.__skinIndexArray=new Float32Array(A*4);x.__skinWeightArray=new Float32Array(A*4)}x.__faceArray=new Uint16Array(O*3+(v.geometry.edgeFaces?v.geometry.edgeFaces.length*6:0));x.__lineArray=new Uint16Array(W*2);if(x.numMorphTargets){x.__morphTargetsArrays=[];G=0;for(B=x.numMorphTargets;G=0;o--){n=m.__webglObjects[o].object;if(s==n){m.__webglObjects.splice(o,1);break}}f.__objectsRemoved.splice(0,1)}s=0;for(m=f.__webglObjects.length;s0}}; +Pa.multiply(s.projectionMatrix,s.matrixWorldInverse);p(Pa);this.initWebGLObjects(f);Ia(m);(this.autoClear||n)&&this.clear();A=f.__webglObjects.length;for(n=0;n0||G.faceVertexUvs.length>0)x.__uvArray=new Float32Array(A*2);if(G.faceUvs.length>1||G.faceVertexUvs.length>1)x.__uv2Array=new Float32Array(A*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length){x.__skinVertexAArray=new Float32Array(A* +4);x.__skinVertexBArray=new Float32Array(A*4);x.__skinIndexArray=new Float32Array(A*4);x.__skinWeightArray=new Float32Array(A*4)}x.__faceArray=new Uint16Array(O*3+(v.geometry.edgeFaces?v.geometry.edgeFaces.length*6:0));x.__lineArray=new Uint16Array(W*2);if(x.numMorphTargets){x.__morphTargetsArrays=[];G=0;for(B=x.numMorphTargets;G=0;o--){n=m.__webglObjects[o].object;if(s==n){m.__webglObjects.splice(o,1);break}}f.__objectsRemoved.splice(0,1)}s=0;for(m=f.__webglObjects.length;s0}}; THREE.WebGLRenderTarget=function(b,e,d){this.width=b;this.height=e;d=d||{};this.wrapS=d.wrapS!==undefined?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==undefined?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==undefined?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==undefined?d.minFilter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBAFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!== undefined?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==undefined?d.stencilBuffer:!0}; diff --git a/examples/canvas_camera_orthographic.html b/examples/canvas_camera_orthographic.html index 310ff526..3ad3f101 100644 --- a/examples/canvas_camera_orthographic.html +++ b/examples/canvas_camera_orthographic.html @@ -71,7 +71,7 @@ // Cubes - var geometry = new Cube( 50, 50, 50 ); + var geometry = new THREE.Cube( 50, 50, 50 ); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ); for ( var i = 0; i < 100; i ++ ) { diff --git a/examples/canvas_geometry_cube.html b/examples/canvas_geometry_cube.html index 20f6ac27..611deada 100644 --- a/examples/canvas_geometry_cube.html +++ b/examples/canvas_geometry_cube.html @@ -70,14 +70,14 @@ } - cube = new THREE.Mesh( new Cube( 200, 200, 200, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() ); + cube = new THREE.Mesh( new THREE.Cube( 200, 200, 200, 1, 1, 1, materials ), new THREE.MeshFaceMaterial() ); cube.position.y = 150; cube.overdraw = true; scene.addObject( cube ); // Plane - plane = new THREE.Mesh( new Plane( 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0 } ) ); + plane = new THREE.Mesh( new THREE.Plane( 200, 200 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0 } ) ); plane.rotation.x = - 90 * ( Math.PI / 180 ); plane.overdraw = true; scene.addObject( plane ); diff --git a/examples/canvas_geometry_earth.html b/examples/canvas_geometry_earth.html index ccc0e2e8..1e4c41e6 100644 --- a/examples/canvas_geometry_earth.html +++ b/examples/canvas_geometry_earth.html @@ -63,12 +63,12 @@ scene = new THREE.Scene(); - mesh = new THREE.Mesh( new Plane( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/shadow.png' ) } ) ); + mesh = new THREE.Mesh( new THREE.Plane( 300, 300, 3, 3 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ) ); mesh.position.y = - 250; mesh.rotation.x = - 90 * Math.PI / 180; scene.addObject(mesh); - mesh = new THREE.Mesh( new Sphere( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ) ); + mesh = new THREE.Mesh( new THREE.Sphere( 200, 20, 20 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ) ); mesh.overdraw = true; scene.addObject(mesh); diff --git a/examples/canvas_geometry_hierarchy.html b/examples/canvas_geometry_hierarchy.html index 32aa498f..03f87834 100644 --- a/examples/canvas_geometry_hierarchy.html +++ b/examples/canvas_geometry_hierarchy.html @@ -16,7 +16,7 @@ - + @@ -48,7 +48,7 @@ scene = new THREE.Scene(); - var geometry = new Cube( 100, 100, 100 ); + var geometry = new THREE.Cube( 100, 100, 100 ); var material = new THREE.MeshNormalMaterial(); group = new THREE.Object3D(); diff --git a/examples/canvas_geometry_panorama.html b/examples/canvas_geometry_panorama.html index c24882d7..79c65248 100644 --- a/examples/canvas_geometry_panorama.html +++ b/examples/canvas_geometry_panorama.html @@ -76,7 +76,7 @@ ]; - mesh = new THREE.Mesh( new Cube( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() ); + mesh = new THREE.Mesh( new THREE.Cube( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() ); mesh.overdraw = true; scene.addObject( mesh ); diff --git a/examples/canvas_geometry_panorama_fisheye.html b/examples/canvas_geometry_panorama_fisheye.html index 3498e6bc..9a3aa0d0 100644 --- a/examples/canvas_geometry_panorama_fisheye.html +++ b/examples/canvas_geometry_panorama_fisheye.html @@ -76,7 +76,7 @@ ]; - mesh = new THREE.Mesh( new Cube( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() ); + mesh = new THREE.Mesh( new THREE.Cube( 300, 300, 300, 7, 7, 7, materials, true ), new THREE.MeshFaceMaterial() ); mesh.overdraw = true; scene.addObject( mesh ); diff --git a/examples/canvas_geometry_terrain.html b/examples/canvas_geometry_terrain.html index 7de80a63..3ad66b30 100644 --- a/examples/canvas_geometry_terrain.html +++ b/examples/canvas_geometry_terrain.html @@ -70,7 +70,7 @@ var material = new THREE.MeshBasicMaterial( { map: new THREE.Texture( generateTexture( data, 1024, 1024 ) ) } ); var quality = 16, step = 1024 / quality; - var plane = new Plane( 2000, 2000, quality - 1, quality - 1 ); + var plane = new THREE.Plane( 2000, 2000, quality - 1, quality - 1 ); for ( var i = 0, l = plane.vertices.length; i < l; i ++ ) { diff --git a/examples/canvas_interactive_cubes.html b/examples/canvas_interactive_cubes.html index 329b8bbe..17e2dcaa 100644 --- a/examples/canvas_interactive_cubes.html +++ b/examples/canvas_interactive_cubes.html @@ -47,7 +47,7 @@ scene = new THREE.Scene(); - var geometry = new Cube( 100, 100, 100 ); + var geometry = new THREE.Cube( 100, 100, 100 ); for ( var i = 0; i < 10; i ++ ) { diff --git a/examples/canvas_interactive_cubes_tween.html b/examples/canvas_interactive_cubes_tween.html index 48aa0fcb..9ad77f80 100644 --- a/examples/canvas_interactive_cubes_tween.html +++ b/examples/canvas_interactive_cubes_tween.html @@ -47,7 +47,7 @@ scene = new THREE.Scene(); - var geometry = new Cube( 100, 100, 100 ); + var geometry = new THREE.Cube( 100, 100, 100 ); for ( var i = 0; i < 20; i ++ ) { diff --git a/examples/canvas_interactive_voxelpainter.html b/examples/canvas_interactive_voxelpainter.html index b80dec0d..6a2197ea 100644 --- a/examples/canvas_interactive_voxelpainter.html +++ b/examples/canvas_interactive_voxelpainter.html @@ -23,7 +23,7 @@ var container, stats; var camera, scene, renderer; - var projector, plane, cube; + var projector, plane; var mouse2D, mouse3D, ray, rollOveredFace, isShiftDown = false, theta = 45, isCtrlDown = false; @@ -73,7 +73,7 @@ projector = new THREE.Projector(); - plane = new THREE.Mesh( new Plane( 1000, 1000, 20, 20 ), new THREE.MeshFaceMaterial() ); + plane = new THREE.Mesh( new THREE.Plane( 1000, 1000, 20, 20 ), new THREE.MeshFaceMaterial() ); plane.rotation.x = - 90 * Math.PI / 180; scene.addObject( plane ); @@ -145,7 +145,7 @@ var position = new THREE.Vector3().add( intersects[ 0 ].point, intersects[ 0 ].object.matrixRotationWorld.multiplyVector3( intersects[ 0 ].face.normal.clone() ) ); - var voxel = new THREE.Mesh( new Cube( 50, 50, 50 ), [ new THREE.MeshLambertMaterial( { color: 0x00ff80, opacity: 1, shading: THREE.FlatShading } ), new THREE.MeshFaceMaterial() ] ); + var voxel = new THREE.Mesh( new THREE.Cube( 50, 50, 50 ), [ new THREE.MeshLambertMaterial( { color: 0x00ff80, opacity: 1, shading: THREE.FlatShading } ), new THREE.MeshFaceMaterial() ] ); voxel.position.x = Math.floor( position.x / 50 ) * 50 + 25; voxel.position.y = Math.floor( position.y / 50 ) * 50 + 25; voxel.position.z = Math.floor( position.z / 50 ) * 50 + 25; diff --git a/examples/canvas_materials.html b/examples/canvas_materials.html index a5c71e51..2ffd1d18 100644 --- a/examples/canvas_materials.html +++ b/examples/canvas_materials.html @@ -65,7 +65,7 @@ // Spheres - var geometry = new Sphere( 100, 14, 7, false ); + var geometry = new THREE.Sphere( 100, 14, 7, false ); var materials = [ @@ -75,9 +75,9 @@ { material: new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ), overdraw: true, doubleSided: false }, { material: new THREE.MeshDepthMaterial(), overdraw: true, doubleSided: false }, { material: new THREE.MeshNormalMaterial(), overdraw: true, doubleSided: false }, - { material: new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false }, - { material: new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false }, - { material: new THREE.MeshBasicMaterial( { envMap: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } + { material: new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false }, + { material: new THREE.MeshLambertMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ), overdraw: false, doubleSided: false }, + { material: new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ), overdraw: false, doubleSided: false } ]; diff --git a/examples/canvas_materials_depth.html b/examples/canvas_materials_depth.html index fe15a4f3..a466415a 100644 --- a/examples/canvas_materials_depth.html +++ b/examples/canvas_materials_depth.html @@ -72,7 +72,7 @@ var material = new THREE.MeshDepthMaterial(); - plane = new THREE.Mesh( new Plane( 1000, 1000, 10, 10 ), material ); + plane = new THREE.Mesh( new THREE.Plane( 1000, 1000, 10, 10 ), material ); plane.rotation.x = - 90 * ( Math.PI / 180 ); plane.position.y = - 100; plane.doubleSided = true; @@ -80,8 +80,7 @@ // Spheres - geometry = new Cube( 100, 100, 100 ); - //material = new THREE.MeshLambertMaterial( { color: 0xffffff } ); + geometry = new THREE.Cube( 100, 100, 100 ); material = new THREE.MeshDepthMaterial( { near: 1, far: 2000 } ); for (var i = 0; i < 20; i ++ ) { diff --git a/examples/canvas_materials_reflection.html b/examples/canvas_materials_reflection.html index f3b4d6ad..92864055 100644 --- a/examples/canvas_materials_reflection.html +++ b/examples/canvas_materials_reflection.html @@ -66,7 +66,7 @@ geometry = new WaltHead(); geometry.computeVertexNormals(); - mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ) ); + mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ) ); mesh.overdraw = true; scene.addObject( mesh ); diff --git a/examples/canvas_materials_video.html b/examples/canvas_materials_video.html index 3b2795bd..fb01d2f5 100644 --- a/examples/canvas_materials_video.html +++ b/examples/canvas_materials_video.html @@ -104,7 +104,7 @@ // - var plane = new Plane( 480, 204, 4, 4 ); + var plane = new THREE.Plane( 480, 204, 4, 4 ); mesh = new THREE.Mesh( plane, material ); mesh.scale.x = mesh.scale.y = mesh.scale.z = 1.5; diff --git a/examples/canvas_performance.html b/examples/canvas_performance.html index 43375d7d..7895c70e 100644 --- a/examples/canvas_performance.html +++ b/examples/canvas_performance.html @@ -74,7 +74,7 @@ // Spheres - geometry = new Sphere( 100, 26, 18 ); + geometry = new THREE.Sphere( 100, 26, 18 ); material = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading, opacity: 1 } ); for ( var i = 0; i < 20; i ++ ) { diff --git a/examples/canvas_sandbox.html b/examples/canvas_sandbox.html index 7f92a1ca..02b906ec 100644 --- a/examples/canvas_sandbox.html +++ b/examples/canvas_sandbox.html @@ -171,8 +171,8 @@ objects = []; - geometry = new Sphere( 100, 16, 8 ); - material = new THREE.MeshBasicMaterial( { envMap: ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ); + geometry = new THREE.Sphere( 100, 16, 8 ); + material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ); for ( var i = 0; i < 10; i ++ ) { diff --git a/examples/misc_lights_test.html b/examples/misc_lights_test.html index 184d17a8..31a4932c 100644 --- a/examples/misc_lights_test.html +++ b/examples/misc_lights_test.html @@ -90,7 +90,7 @@ // Spheres - var geometry = new Sphere( 100, 16, 8 ); + var geometry = new THREE.Sphere( 100, 16, 8 ); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ); for ( var i = 0; i < 30; i ++ ) { diff --git a/examples/misc_lookat.html b/examples/misc_lookat.html index 5dde8357..6249f3f6 100644 --- a/examples/misc_lookat.html +++ b/examples/misc_lookat.html @@ -65,10 +65,10 @@ scene = new THREE.Scene(); - var geometry = new Cube( 10, 10, 100 ); + var geometry = new THREE.Cube( 10, 10, 100 ); var material = new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ); - target = new THREE.Mesh( new Sphere( 100, 20, 20 ), material ); + target = new THREE.Mesh( new THREE.Sphere( 100, 20, 20 ), material ); scene.addObject( target ); for ( var i = 0; i < 1000; i ++ ) { diff --git a/examples/misc_materials_multimaterials.html b/examples/misc_materials_multimaterials.html index 2c71eb9c..5d33ce31 100644 --- a/examples/misc_materials_multimaterials.html +++ b/examples/misc_materials_multimaterials.html @@ -49,7 +49,7 @@ var SCREEN_WIDTH = window.innerWidth/2; var SCREEN_HEIGHT = window.innerHeight; - var FLOOR = -250; + var FLOOR = - 250; var container; var stats; @@ -96,8 +96,10 @@ // SPHERES - sphere = new Sphere( 100, 16, 8 ); - for (var i=0; i<10; i++) { + sphere = new THREE.Sphere( 100, 16, 8 ); + + for ( var i = 0; i < 10; i ++ ) { + //mesh = new THREE.Mesh( sphere, new THREE.MeshLambertMaterial( ) ); mesh = new THREE.Mesh( sphere, [ new THREE.MeshLambertMaterial( { color: 0xffffff } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 1.5 } ) ] ); //mesh = new THREE.Mesh( sphere, new THREE.MeshLambertMaterial( { color: 0x00aa00, wireframe: true, wireframeLinewidth: 1.5 } ) ); @@ -107,6 +109,7 @@ mesh.position.z = 500 * ( Math.random() - 0.5 ); mesh.scale.x = mesh.scale.y = mesh.scale.z = 0.25 * (Math.random() + 0.5); scene.addObject(mesh); + } @@ -132,10 +135,12 @@ mesh.position = pointLight.position; scene.addObject(mesh); - if( render_canvas ) { + if ( render_canvas ) { + canvasRenderer = new THREE.CanvasRenderer(); canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT ); container.appendChild( canvasRenderer.domElement ); + } if ( render_gl ) { @@ -234,12 +239,12 @@ function createMaterialsPalette( materials, size, bottom ) { - for ( var i=0; i - @@ -103,7 +102,7 @@ - + @@ -150,7 +149,7 @@ // CUBES - var cube = new Cube( 100, 100, 100 ); + var cube = new THREE.Cube( 100, 100, 100 ); mesh = new THREE.Mesh( cube, new THREE.MeshBasicMaterial( { color: 0x0000ff, opacity: 0.5 } ) ); mesh.position.x = 500; @@ -169,7 +168,7 @@ // PLANE - mesh = new THREE.Mesh( new Plane( 100, 100 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); + mesh = new THREE.Mesh( new THREE.Plane( 100, 100 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); mesh.position.y = -500; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; mesh.doubleSided = true; @@ -177,7 +176,7 @@ // CYLINDER - mesh = new THREE.Mesh( new Cylinder( 10, 20, 100, 200, - 50, - 20 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); + mesh = new THREE.Mesh( new THREE.Cylinder( 10, 20, 100, 200, - 50, - 20 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); mesh.position.x = -500; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; scene.addObject( mesh ); diff --git a/examples/webgl_collisions_box.html b/examples/webgl_collisions_box.html index 8dd52712..c5c3ecbb 100644 --- a/examples/webgl_collisions_box.html +++ b/examples/webgl_collisions_box.html @@ -1,9 +1,9 @@ - - - -three.js webgl - intersection: ray with box - - - + @@ -52,9 +52,9 @@ function init() { container = document.createElement( 'div' ); document.body.appendChild( container ); - + info = document.getElementById("info"); - + camera = new THREE.Camera( 40, window.innerWidth / window.innerHeight, 1, 10000 ); camera.position.z = -500; mouse2d = new THREE.Vector3( 0, 0, 1 ); @@ -64,14 +64,14 @@ function init() { renderer = new THREE.WebGLRenderer(); renderer.setSize( window.innerWidth, window.innerHeight ); container.appendChild(renderer.domElement); - + var ambientLight = new THREE.AmbientLight( 0x606060 ); scene.addLight( ambientLight ); sun = new THREE.DirectionalLight( 0xffffff ); sun.position = camera.position.clone(); scene.addLight( sun ); - + createCube( 200, new THREE.Vector3( 0,0,0 ) ); stats = new Stats(); @@ -85,9 +85,9 @@ function init() { } function createCube( s, p ) { - - cube = new THREE.Mesh ( - new Cube( s,s,s, 1,1,1 ), + + cube = new THREE.Mesh ( + new THREE.Cube( s,s,s, 1,1,1 ), new THREE.MeshLambertMaterial( { color: 0x003300 }) ); @@ -100,7 +100,7 @@ function createCube( s, p ) { function onDocumentMouseMove( event ) { - event.preventDefault(); + event.preventDefault(); mouse2d.x = ( event.clientX / window.innerWidth ) * 2 - 1; mouse2d.y = - ( event.clientY / window.innerHeight ) * 2 + 1; mouse2d.z = 1; @@ -110,7 +110,7 @@ function onDocumentMouseMove( event ) { function animate() { requestAnimationFrame( animate ); - + var r = new THREE.Ray(); r.origin.copy( mouse2d ); @@ -124,7 +124,7 @@ function animate() { var c = THREE.Collisions.rayCastNearest( r ); if( c ) { - + info.innerHTML += "Found @ distance " + c.distance.toFixed(2); c.mesh.materials[ 0 ].color.setHex( 0xaa0000 ); @@ -134,15 +134,15 @@ function animate() { cube.materials[0].color.setHex( 0x003300 ); } - - + + cube.rotation.x += 0.01; cube.rotation.y += 0.02; cube.position.x = Math.sin(bounce) * 100; bounce += 0.01; renderer.render( scene, camera ); - + stats.update(); }; @@ -156,11 +156,11 @@ function vts(v) { - + - +
- + - \ No newline at end of file + diff --git a/examples/webgl_collisions_primitives.html b/examples/webgl_collisions_primitives.html index 6eb5d840..53431132 100644 --- a/examples/webgl_collisions_primitives.html +++ b/examples/webgl_collisions_primitives.html @@ -3,18 +3,18 @@ three.js webgl - intersection: ray with sphere/AABB/plane - + diff --git a/examples/webgl_collisions_reaction.html b/examples/webgl_collisions_reaction.html index 6a6c2dac..536285b2 100644 --- a/examples/webgl_collisions_reaction.html +++ b/examples/webgl_collisions_reaction.html @@ -3,18 +3,18 @@ three.js webgl - collision reaction diff --git a/examples/webgl_collisions_terrain.html b/examples/webgl_collisions_terrain.html index d045f52a..5592e050 100644 --- a/examples/webgl_collisions_terrain.html +++ b/examples/webgl_collisions_terrain.html @@ -1,9 +1,9 @@ - - - -three.js webgl - intersection: ray with terrain mesh (through box) - - - + - - + - +
- + - \ No newline at end of file + diff --git a/examples/webgl_collisions_trigger.html b/examples/webgl_collisions_trigger.html index 7cbd706a..bc5504f5 100644 --- a/examples/webgl_collisions_trigger.html +++ b/examples/webgl_collisions_trigger.html @@ -3,18 +3,18 @@ three.js webgl - collision detection - + diff --git a/examples/webgl_geometries.html b/examples/webgl_geometries.html index b20889b6..8027e65e 100644 --- a/examples/webgl_geometries.html +++ b/examples/webgl_geometries.html @@ -54,30 +54,30 @@ scene.addLight( light ); material = [ - new THREE.MeshLambertMaterial( { map: ImageUtils.loadTexture( 'textures/UV.jpg' ) } ), + new THREE.MeshLambertMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/UV.jpg' ) } ), new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true, opacity: 0.1 } ) ]; - object = new THREE.Mesh( new Cube( 100, 100, 100, 4, 4, 4 ), material ); + object = new THREE.Mesh( new THREE.Cube( 100, 100, 100, 4, 4, 4 ), material ); object.position.x = - 200; object.position.z = 200; scene.addObject( object ); - object = new THREE.Mesh( new Cylinder( 50, 25, 75, 100 ), material ); + object = new THREE.Mesh( new THREE.Cylinder( 50, 25, 75, 100 ), material ); object.position.z = 200; scene.addObject( object ); - object = new THREE.Mesh( new Icosahedron( 2 ), material ); + object = new THREE.Mesh( new THREE.Icosahedron( 2 ), material ); object.position.x = 200; object.position.z = 200; object.scale.x = object.scale.y = object.scale.z = 75; scene.addObject( object ); - object = new THREE.Mesh( new Plane( 100, 100, 4, 4 ), material ); + object = new THREE.Mesh( new THREE.Plane( 100, 100, 4, 4 ), material ); object.position.x = - 200; scene.addObject( object ); - object = new THREE.Mesh( new Sphere( 75, 20, 10 ), material ); + object = new THREE.Mesh( new THREE.Sphere( 75, 20, 10 ), material ); scene.addObject( object ); var points = []; @@ -88,16 +88,16 @@ } - object = new THREE.Mesh( new Lathe( points, 20 ), material ); + object = new THREE.Mesh( new THREE.Lathe( points, 20 ), material ); object.position.x = 200; scene.addObject( object ); - object = new THREE.Mesh( new Torus( 50, 20, 20, 20 ), material ); + object = new THREE.Mesh( new THREE.Torus( 50, 20, 20, 20 ), material ); object.position.x = - 200; object.position.z = - 200; scene.addObject( object ); - object = new THREE.Mesh( new TorusKnot( 50, 10, 50, 20 ), material ); + object = new THREE.Mesh( new THREE.TorusKnot( 50, 10, 50, 20 ), material ); object.position.z = - 200; scene.addObject( object ); diff --git a/examples/webgl_geometry_blenderexport_colors.html b/examples/webgl_geometry_blenderexport_colors.html index b793fc3d..631192e7 100644 --- a/examples/webgl_geometry_blenderexport_colors.html +++ b/examples/webgl_geometry_blenderexport_colors.html @@ -34,7 +34,7 @@
three.js webgl - io blender - vertex colors
- + @@ -97,7 +97,7 @@ var material = [ new THREE.MeshFaceMaterial(), new THREE.MeshLambertMaterial( { color: 0xffffff, opacity:0.9, shading:THREE.FlatShading, wireframe: true, wireframeLinewidth: 2 } ) ]; - mesh = SceneUtils.addMesh( scene, geometry, 250, 400, 0, 0, 0, 0, 0, material ); + mesh = THREE.SceneUtils.addMesh( scene, geometry, 250, 400, 0, 0, 0, 0, 0, material ); } @@ -107,7 +107,7 @@ var material = new THREE.MeshFaceMaterial(); - mesh2 = SceneUtils.addMesh( scene, geometry, 250, -400, 0, 0, 0, 0, 0, material ); + mesh2 = THREE.SceneUtils.addMesh( scene, geometry, 250, -400, 0, 0, 0, 0, 0, material ); } diff --git a/examples/webgl_geometry_colors.html b/examples/webgl_geometry_colors.html index 758dd30b..3a400f78 100644 --- a/examples/webgl_geometry_colors.html +++ b/examples/webgl_geometry_colors.html @@ -71,8 +71,8 @@ light.position.normalize(); scene.addLight( light ); - var shadowMaterial = new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/shadow.png' ) } ); - var shadowGeo = new Plane( 300, 300, 1, 1 ); + var shadowMaterial = new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ); + var shadowGeo = new THREE.Plane( 300, 300, 1, 1 ); mesh = new THREE.Mesh( shadowGeo, shadowMaterial ); mesh.position.y = - 250; @@ -92,44 +92,44 @@ scene.addObject( mesh ); var faceIndices = [ 'a', 'b', 'c', 'd' ]; - + var color, f, f2, f3, p, n, vertexIndex, - geometry = new Icosahedron( 1 ), - geometry2 = new Icosahedron( 1 ), - geometry3 = new Icosahedron( 1 ); + geometry = new THREE.Icosahedron( 1 ), + geometry2 = new THREE.Icosahedron( 1 ), + geometry3 = new THREE.Icosahedron( 1 ); + + for ( var i = 0; i < geometry.faces.length; i++ ) { - for( var i = 0; i < geometry.faces.length; i++ ) { - f = geometry.faces[ i ]; f2 = geometry2.faces[ i ]; f3 = geometry3.faces[ i ]; - + n = ( f instanceof THREE.Face3 ) ? 3 : 4; - + for( var j = 0; j < n; j++ ) { - + vertexIndex = f[ faceIndices[ j ] ]; - + p = geometry.vertices[ vertexIndex ].position; color = new THREE.Color( 0xffffff ); color.setHSV( ( p.y + 1 ) / 2, 1.0, 1.0 ); - + f.vertexColors[ j ] = color; color = new THREE.Color( 0xffffff ); color.setHSV( 0.0, ( p.y + 1 ) / 2, 1.0 ); - + f2.vertexColors[ j ] = color; color = new THREE.Color( 0xffffff ); color.setHSV( 0.125 * vertexIndex/geometry.vertices.length, 1.0, 1.0 ); - + f3.vertexColors[ j ] = color; } - + } diff --git a/examples/webgl_geometry_dynamic.html b/examples/webgl_geometry_dynamic.html index e4834ff2..7837905f 100644 --- a/examples/webgl_geometry_dynamic.html +++ b/examples/webgl_geometry_dynamic.html @@ -70,8 +70,12 @@ container = document.getElementById( 'container' ); - camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000, - movementSpeed: 10, lookSpeed: 0.004, noFly: false, lookVertical: true } ); + camera = new THREE.QuakeCamera( { + + fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000, + movementSpeed: 10, lookSpeed: 0.004, noFly: false, lookVertical: true + + } ); camera.target.position.z = - 100; @@ -85,7 +89,7 @@ camera.position.y = 200; camera.target.position.y = camera.position.y; - geometry = new Plane( 20000, 20000, worldWidth - 1, worldDepth - 1 ); + geometry = new THREE.Plane( 20000, 20000, worldWidth - 1, worldDepth - 1 ); var i, j, il, jl; @@ -113,7 +117,7 @@ geometry.computeFaceNormals(); geometry.computeVertexNormals(); - var texture = ImageUtils.loadTexture( "textures/water.jpg" ); + var texture = THREE.ImageUtils.loadTexture( "textures/water.jpg" ); texture.wrapS = texture.wrapT = THREE.RepeatWrapping; material = new THREE.MeshBasicMaterial( { color:0x0044ff, opacity:1, map: texture } ); diff --git a/examples/webgl_geometry_hierarchy.html b/examples/webgl_geometry_hierarchy.html index 9e7ae709..8f9b3b13 100644 --- a/examples/webgl_geometry_hierarchy.html +++ b/examples/webgl_geometry_hierarchy.html @@ -16,7 +16,7 @@ - + @@ -49,7 +49,7 @@ scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0xffffff, 1, 10000 ); - var geometry = new Cube( 100, 100, 100 ); + var geometry = new THREE.Cube( 100, 100, 100 ); var material = new THREE.MeshNormalMaterial(); group = new THREE.Object3D(); diff --git a/examples/webgl_geometry_hierarchy2.html b/examples/webgl_geometry_hierarchy2.html index f9eb5f2e..7005df09 100644 --- a/examples/webgl_geometry_hierarchy2.html +++ b/examples/webgl_geometry_hierarchy2.html @@ -16,7 +16,7 @@ - + @@ -49,7 +49,7 @@ scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0xffffff, 1, 10000 ); - var geometry = new Cube( 100, 100, 100 ); + var geometry = new THREE.Cube( 100, 100, 100 ); var material = new THREE.MeshNormalMaterial(); var mesh = new THREE.Mesh( geometry, material ); diff --git a/examples/webgl_geometry_large_mesh.html b/examples/webgl_geometry_large_mesh.html index 5b9dd7de..90ba6d6d 100644 --- a/examples/webgl_geometry_large_mesh.html +++ b/examples/webgl_geometry_large_mesh.html @@ -45,7 +45,7 @@

 
 		
-		
+
 		
 		
 
@@ -55,12 +55,9 @@
 			var SCREEN_HEIGHT = window.innerHeight;
 			var FLOOR = -250;
 
-			var container;
-			var stats;
+			var container, stats;
 
-			var camera;
-			var scene;
-			var canvasRenderer, webglRenderer;
+			var camera, scene, canvasRenderer, webglRenderer;
 
 			var loader;
 
@@ -68,8 +65,7 @@
 
 			var directionalLight, pointLight;
 
-			var mouseX = 0;
-			var mouseY = 0;
+			var mouseX = 0, mouseY = 0;
 
 			var windowHalfX = window.innerWidth / 2;
 			var windowHalfY = window.innerHeight / 2;
@@ -135,7 +131,7 @@
 				scene.addLight( pointLight );
 
 				// light representation
-				sphere = new Sphere( 100, 16, 8, 1 );
+				sphere = new THREE.Sphere( 100, 16, 8, 1 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
 				lightMesh.position = pointLight.position;
diff --git a/examples/webgl_geometry_minecraft.html b/examples/webgl_geometry_minecraft.html
index e5f4e57a..501503bf 100644
--- a/examples/webgl_geometry_minecraft.html
+++ b/examples/webgl_geometry_minecraft.html
@@ -75,25 +75,29 @@
 
 				container = document.getElementById( 'container' );
 
-				camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
-												   movementSpeed: 15, lookSpeed: 0.005, noFly: false, lookVertical: true } );
+				camera = new THREE.QuakeCamera( {
+
+					fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
+					movementSpeed: 15, lookSpeed: 0.005, noFly: false, lookVertical: true
+
+				} );
 
 				camera.target.position.z = - 100;
 
 				scene = new THREE.Scene();
 
 				var grass_dirt = loadTexture( 'textures/minecraft/grass_dirt.png' ),
-					grass 	   = loadTexture( 'textures/minecraft/grass.png' ),
-					dirt	   = loadTexture( 'textures/minecraft/dirt.png' );
+				grass = loadTexture( 'textures/minecraft/grass.png' ),
+				dirt = loadTexture( 'textures/minecraft/dirt.png' );
 
 				var materials = [
 
 					grass_dirt, // right
 					grass_dirt, // left
-					grass, 		// top
-					dirt, 		// bottom
+					grass, // top
+					dirt, // bottom
 					grass_dirt, // back
-					grass_dirt 	// front
+					grass_dirt  // front
 
 				];
 
@@ -101,11 +105,11 @@
 
 				for ( var i = 0; i < 16; i++ ) {
 
-					px = (i & 8) == 8;
-					nx = (i & 4) == 4;
-					pz = (i & 2) == 2;
-					nz = (i & 1) == 1;
-					cubes[ i ] = new Cube( 100, 100, 100, 1, 1, 1, materials, false, { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz } );
+					px = ( i & 8 ) == 8;
+					nx = ( i & 4 ) == 4;
+					pz = ( i & 2 ) == 2;
+					nz = ( i & 1 ) == 1;
+					cubes[ i ] = new THREE.Cube( 100, 100, 100, 1, 1, 1, materials, false, { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz } );
 
 				}
 
diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html
index b5889279..84b40cdc 100644
--- a/examples/webgl_geometry_minecraft_ao.html
+++ b/examples/webgl_geometry_minecraft_ao.html
@@ -70,9 +70,7 @@
 
 			var camera, scene, renderer;
 
-			var mesh;
-			
-			var mat;
+			var mesh, mat;
 
 			var worldWidth = 128, worldDepth = 128,
 			worldHalfWidth = worldWidth / 2, worldHalfDepth = worldDepth / 2,
@@ -85,9 +83,13 @@
 
 				container = document.getElementById( 'container' );
 
-				camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
-												  constrainVertical: true, verticalMin: 1.1, verticalMax: 2.2,
-												  movementSpeed: 15, lookSpeed: 0.005, noFly: false, lookVertical: true } );
+				camera = new THREE.QuakeCamera( {
+
+					fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
+					constrainVertical: true, verticalMin: 1.1, verticalMax: 2.2,
+					movementSpeed: 15, lookSpeed: 0.005, noFly: false, lookVertical: true
+
+				} );
 
 				camera.target.position.z = - 100;
 
@@ -369,11 +371,11 @@
 
 						sides = { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz };
 
-						cube = new Cube( 100, 100, 100, 1, 1, 1, materials, false, sides );
+						cube = new THREE.Cube( 100, 100, 100, 1, 1, 1, materials, false, sides );
 
 						// set UV tiles
 
-						for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i++ ) {
+						for ( i = 0; i < cube.faceVertexUvs[ 0 ].length; i ++ ) {
 
 							uv = cube.faceVertexUvs[ 0 ][ i ];
 
diff --git a/examples/webgl_geometry_terrain.html b/examples/webgl_geometry_terrain.html
index 74a4f74b..eb652bc3 100644
--- a/examples/webgl_geometry_terrain.html
+++ b/examples/webgl_geometry_terrain.html
@@ -67,8 +67,12 @@
 
 				container = document.getElementById( 'container' );
 
-				camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
-												  movementSpeed: 15, lookSpeed: 0.004, noFly: false, lookVertical: true } );
+				camera = new THREE.QuakeCamera( {
+
+					fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
+					movementSpeed: 15, lookSpeed: 0.004, noFly: false, lookVertical: true
+
+				} );
 
 				camera.target.position.z = - 100;
 
@@ -79,7 +83,7 @@
 				camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] + 500;
 				camera.target.position.y = camera.position.y;
 
-				var geometry = new Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 );
+				var geometry = new THREE.Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 );
 
 				for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {
 
@@ -89,7 +93,7 @@
 
 				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
 				texture.needsUpdate = true;
-				
+
 				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
 				mesh.rotation.x = - 90 * Math.PI / 180;
 				scene.addObject( mesh );
diff --git a/examples/webgl_geometry_terrain_fog.html b/examples/webgl_geometry_terrain_fog.html
index ed34c072..614744f9 100644
--- a/examples/webgl_geometry_terrain_fog.html
+++ b/examples/webgl_geometry_terrain_fog.html
@@ -66,8 +66,12 @@
 
 				container = document.getElementById( 'container' );
 
-				camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 10000,
-												  movementSpeed: 5, lookSpeed: 0.004, noFly: false, lookVertical: true } );
+				camera = new THREE.QuakeCamera( {
+
+					fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 10000,
+					movementSpeed: 5, lookSpeed: 0.004, noFly: false, lookVertical: true
+
+				} );
 
 				camera.target.position.z = - 100;
 
@@ -79,7 +83,7 @@
 				camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] * 10 + 500;
 				camera.target.position.y = camera.position.y;
 
-				var geometry = new Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 );
+				var geometry = new THREE.Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 );
 
 				for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) {
 
@@ -89,7 +93,7 @@
 
 				texture = new THREE.Texture( generateTexture( data, worldWidth, worldDepth ), new THREE.UVMapping(), THREE.ClampToEdgeWrapping, THREE.ClampToEdgeWrapping );
 				texture.needsUpdate = true;
-				
+
 				mesh = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map: texture } ) );
 				mesh.rotation.x = - 90 * Math.PI / 180;
 				scene.addObject( mesh );
diff --git a/examples/webgl_hdr.html b/examples/webgl_hdr.html
index 47c99345..77d0c89d 100644
--- a/examples/webgl_hdr.html
+++ b/examples/webgl_hdr.html
@@ -127,7 +127,7 @@
 				directionalLight.position.normalize();
 				scene.addLight( directionalLight );
 
-				var texture = ImageUtils.loadTexture( "textures/memorial.png" );
+				var texture = THREE.ImageUtils.loadTexture( "textures/memorial.png" );
 				texture.minFilter = THREE.LinearFilter;
 				texture.magFilter = THREE.NearestFilter;
 
@@ -143,7 +143,7 @@
 
 				} );
 
-				var plane = new Plane( 512, 768 );
+				var plane = new THREE.Plane( 512, 768 );
 
 				quad = new THREE.Mesh( plane, materialHDR );
 				quad.position.z = -100;
diff --git a/examples/webgl_interactive_voxelpainter.html b/examples/webgl_interactive_voxelpainter.html
index afd19984..0dc1495e 100644
--- a/examples/webgl_interactive_voxelpainter.html
+++ b/examples/webgl_interactive_voxelpainter.html
@@ -61,7 +61,7 @@
 
 				// roll-over helpers
 
-				rollOverGeo = new Cube( 50, 50, 50 );
+				rollOverGeo = new THREE.Cube( 50, 50, 50 );
 				rollOverMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, transparent: true } );
 				rollOverMesh = new THREE.Mesh( rollOverGeo, rollOverMaterial );
 				scene.addObject( rollOverMesh );
@@ -69,8 +69,8 @@
 
 				// cubes
 
-				cubeGeo = new Cube( 50, 50, 50 );
-				cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x00ff80, shading: THREE.FlatShading, map: ImageUtils.loadTexture( "textures/square-outline-textured.png" ) } );
+				cubeGeo = new THREE.Cube( 50, 50, 50 );
+				cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x00ff80, shading: THREE.FlatShading, map: THREE.ImageUtils.loadTexture( "textures/square-outline-textured.png" ) } );
 				cubeMaterial.color.setHSV( 0.1, 0.7, 1.0 );
 				// picking
 
@@ -78,7 +78,7 @@
 
 				// grid
 
-				plane = new THREE.Mesh( new Plane( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) );
+				plane = new THREE.Mesh( new THREE.Plane( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) );
 				plane.rotation.x = - 90 * Math.PI / 180;
 				scene.addObject( plane );
 
@@ -107,7 +107,7 @@
 				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
-				container.appendChild(renderer.domElement);
+				container.appendChild( renderer.domElement );
 
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
diff --git a/examples/webgl_lights_pointlights.html b/examples/webgl_lights_pointlights.html
index a8d5918b..c3424ce1 100644
--- a/examples/webgl_lights_pointlights.html
+++ b/examples/webgl_lights_pointlights.html
@@ -106,7 +106,7 @@
 				light3 = new THREE.PointLight( 0x80ff80, 2, 50 );
 				scene.addLight( light3 );
 
-				var sphere = new Sphere( 0.5, 16, 8 );
+				var sphere = new THREE.Sphere( 0.5, 16, 8 );
 
 				var l1 = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xff0040 } ) );
 				l1.position = light1.position;
diff --git a/examples/webgl_lines_colors.html b/examples/webgl_lines_colors.html
index 556d2070..a450319c 100644
--- a/examples/webgl_lines_colors.html
+++ b/examples/webgl_lines_colors.html
@@ -191,7 +191,7 @@
 			}
 
 			//
-			
+
 			function initPostprocessing() {
 
 				postprocessing.scene = new THREE.Scene();
@@ -205,8 +205,8 @@
 				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
 				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
 
-				var screen_shader = ShaderUtils.lib["screen"];
-				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+				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;
@@ -221,15 +221,15 @@
 
 				} );
 
-				var convolution_shader = ShaderUtils.lib["convolution"];
-				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+				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 = ShaderUtils.buildKernel( 4.0 );
+				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
 
 				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
 
@@ -239,11 +239,11 @@
 
 				} );
 
-				postprocessing.quad = new THREE.Mesh( new Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
-				postprocessing.quad.position.z = -500;
+				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad.position.z = - 500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
-			}			
+			}
 
 			function onDocumentMouseMove(event) {
 
diff --git a/examples/webgl_lines_splines.html b/examples/webgl_lines_splines.html
index 5f2f0ad6..d838d748 100644
--- a/examples/webgl_lines_splines.html
+++ b/examples/webgl_lines_splines.html
@@ -158,8 +158,8 @@
 				rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
 				rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
 
-				var screen_shader = ShaderUtils.lib["screen"];
-				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+				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;
@@ -173,15 +173,15 @@
 
 				} );
 
-				var convolution_shader = ShaderUtils.lib["convolution"];
-				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+				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 = ShaderUtils.buildKernel( 4.0 );
+				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
 
 				materialConvolution = new THREE.MeshShaderMaterial( {
 
@@ -191,7 +191,7 @@
 
 				} );
 
-				var plane = new Plane( window.innerWidth, window.innerHeight );
+				var plane = new THREE.Plane( window.innerWidth, window.innerHeight );
 
 				quadScreen = new THREE.Mesh( plane, materialConvolution );
 				quadScreen.position.z = -100;
diff --git a/examples/webgl_lod.html b/examples/webgl_lod.html
index 33a33ad9..189dbb35 100644
--- a/examples/webgl_lod.html
+++ b/examples/webgl_lod.html
@@ -82,16 +82,20 @@
 				scene.addLight( light );
 
 				var material = [
-							new THREE.MeshLambertMaterial( { color: 0xffffff } ),
-							new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, wireframe: true } )
-						];
+
+					new THREE.MeshLambertMaterial( { color: 0xffffff } ),
+					new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, wireframe: true } )
+
+				];
 
 				var geometry = [
-							[ new Sphere( 100, 64, 32 ), 300 ],
-							[ new Sphere( 100, 32, 16 ), 1000 ],
-							[ new Sphere( 100, 16, 8 ), 2000 ],
-							[ new Sphere( 100, 8, 4 ), 10000 ]
-						  ];
+
+					[ new THREE.Sphere( 100, 64, 32 ), 300 ],
+					[ new THREE.Sphere( 100, 32, 16 ), 1000 ],
+					[ new THREE.Sphere( 100, 16, 8 ), 2000 ],
+					[ new THREE.Sphere( 100, 8, 4 ), 10000 ]
+
+				];
 
 				var i, j, mesh, lod;
 
@@ -117,7 +121,7 @@
 
 
 
-				renderer = new THREE.WebGLRenderer( { clearColor:0x000000, clearAlpha: 1 } );
+				renderer = new THREE.WebGLRenderer( { antialias: true, clearColor:0x000000, clearAlpha: 1 } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortObjects = false;
 				container.appendChild( renderer.domElement );
diff --git a/examples/webgl_materials.html b/examples/webgl_materials.html
index a0bf46e0..da4b38ac 100644
--- a/examples/webgl_materials.html
+++ b/examples/webgl_materials.html
@@ -88,9 +88,9 @@
 
 				// Spheres geometry
 
-				var geometry_smooth = new Sphere( 70, 32, 16 );
-				var geometry_flat = new Sphere( 70, 32, 16 );
-				var geometry_pieces = new Sphere( 70, 32, 16 ); // Extra geometry to be broken down for MeshFaceMaterial
+				var geometry_smooth = new THREE.Sphere( 70, 32, 16 );
+				var geometry_flat = new THREE.Sphere( 70, 32, 16 );
+				var geometry_pieces = new THREE.Sphere( 70, 32, 16 ); // Extra geometry to be broken down for MeshFaceMaterial
 
 				for ( var i = 0, l = geometry_pieces.faces.length; i < l; i ++ ) {
 
@@ -127,7 +127,7 @@
 
 				}
 
-				particleLight = new THREE.Mesh( new Sphere( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) );
+				particleLight = new THREE.Mesh( new THREE.Sphere( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) );
 				scene.addObject( particleLight );
 
 				// Lights
diff --git a/examples/webgl_materials_cars.html b/examples/webgl_materials_cars.html
index afb9ada7..e03caf8a 100644
--- a/examples/webgl_materials_cars.html
+++ b/examples/webgl_materials_cars.html
@@ -196,7 +196,7 @@
 				pointLight.position.z = 10000;
 				scene.addLight( pointLight );
 
-				SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
+				THREE.SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
 
 				webglRenderer = new THREE.WebGLRenderer();
 				webglRenderer.setSize( window.innerWidth, window.innerHeight );
@@ -221,7 +221,7 @@
 							 r + "posy.jpg", r + "negy.jpg",
 							 r + "posz.jpg", r + "negz.jpg" ];
 
-				var textureCube = ImageUtils.loadTextureCube( urls );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls );
 
 				// common materials
 
@@ -552,7 +552,7 @@
 
 				}
 
-				CARS[ car ].object = SceneUtils.addMesh( scene, geometry, s, 0, 0, 0, r[0], r[1], r[2], m );
+				CARS[ car ].object = THREE.SceneUtils.addMesh( scene, geometry, s, 0, 0, 0, r[0], r[1], r[2], m );
 
 				CARS[ car ].buttons = createButtons( materials.body, car );
 				attachButtonMaterials( materials.body, geometry, bm, car );
diff --git a/examples/webgl_materials_cars_camaro.html b/examples/webgl_materials_cars_camaro.html
index cf8bff9c..7fa604e0 100644
--- a/examples/webgl_materials_cars_camaro.html
+++ b/examples/webgl_materials_cars_camaro.html
@@ -92,7 +92,7 @@
 				scene.addLight( pointLight );
 
 
-				sphere = new Sphere( 100, 16, 8, 1 );
+				sphere = new THREE.Sphere( 100, 16, 8, 1 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
 				lightMesh.position = pointLight.position;
@@ -119,17 +119,17 @@
 							 r + "py.jpg", r + "ny.jpg",
 							 r + "pz.jpg", r + "nz.jpg" ];
 
-				var textureCube = ImageUtils.loadTextureCube( urls );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls );
 
 				var camaroMaterials = {
 
-					body: 		[],
-					chrome: 	new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube } ),
+					body: [],
+					chrome: new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: textureCube } ),
 					darkchrome: new THREE.MeshLambertMaterial( { color: 0x444444, envMap: textureCube } ),
-					glass:		new THREE.MeshBasicMaterial( { color: 0x223344, envMap: textureCube, opacity: 0.25, combine: THREE.MixOperation, reflectivity: 0.25, transparent: true } ),
-					tire:       new THREE.MeshLambertMaterial( { color: 0x050505 } ),
-					interior:   new THREE.MeshPhongMaterial( { color: 0x050505, shininess: 20 } ),
-					black:      new THREE.MeshLambertMaterial( { color: 0x000000 } )
+					glass: new THREE.MeshBasicMaterial( { color: 0x223344, envMap: textureCube, opacity: 0.25, combine: THREE.MixOperation, reflectivity: 0.25, transparent: true } ),
+					tire: new THREE.MeshLambertMaterial( { color: 0x050505 } ),
+					interior: new THREE.MeshPhongMaterial( { color: 0x050505, shininess: 20 } ),
+					black: new THREE.MeshLambertMaterial( { color: 0x000000 } )
 
 				}
 
@@ -177,17 +177,17 @@
 
 				var s = 75, m = new THREE.MeshFaceMaterial();
 
-				geometry.materials[ 0 ][ 0 ] = materials.body[ 0 ][ 1 ]; 	// car body
-				geometry.materials[ 1 ][ 0 ] = materials.chrome; 			// wheels chrome
-				geometry.materials[ 2 ][ 0 ] = materials.chrome; 			// grille chrome
-				geometry.materials[ 3 ][ 0 ] = materials.darkchrome; 		// door lines
-				geometry.materials[ 4 ][ 0 ] = materials.glass; 			// windshield
-				geometry.materials[ 5 ][ 0 ] = materials.interior;          // interior
-				geometry.materials[ 6 ][ 0 ] = materials.tire;              // tire
-				geometry.materials[ 7 ][ 0 ] = materials.black;             // tireling
-				geometry.materials[ 8 ][ 0 ] = materials.black;             // behind grille
+				geometry.materials[ 0 ][ 0 ] = materials.body[ 0 ][ 1 ]; // car body
+				geometry.materials[ 1 ][ 0 ] = materials.chrome; // wheels chrome
+				geometry.materials[ 2 ][ 0 ] = materials.chrome; // grille chrome
+				geometry.materials[ 3 ][ 0 ] = materials.darkchrome; // door lines
+				geometry.materials[ 4 ][ 0 ] = materials.glass; // windshield
+				geometry.materials[ 5 ][ 0 ] = materials.interior; // interior
+				geometry.materials[ 6 ][ 0 ] = materials.tire; // tire
+				geometry.materials[ 7 ][ 0 ] = materials.black; // tireling
+				geometry.materials[ 8 ][ 0 ] = materials.black; // behind grille
 
-				SceneUtils.addMesh( scene, geometry, s, 0, 0, 0, 0.0, 1.0, 0.0, m );
+				THREE.SceneUtils.addMesh( scene, geometry, s, 0, 0, 0, 0.0, 1.0, 0.0, m );
 
 				createButtons( materials.body, geometry );
 
diff --git a/examples/webgl_materials_cubemap.html b/examples/webgl_materials_cubemap.html
index 80235cfb..baa87eae 100644
--- a/examples/webgl_materials_cubemap.html
+++ b/examples/webgl_materials_cubemap.html
@@ -70,8 +70,8 @@
 
 			function init() {
 
-				container = document.createElement('div');
-				document.body.appendChild(container);
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
 
 				camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 5000 );
 				camera.position.z = 2000;
@@ -90,7 +90,7 @@
 				scene.addLight( pointLight );
 
 				// light representation
-				sphere = new Sphere( 100, 16, 8 );
+				sphere = new THREE.Sphere( 100, 16, 8 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) );
 				lightMesh.position = pointLight.position;
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
@@ -104,15 +104,15 @@
 						path + 'pz' + format, path + 'nz' + format
 					];
 
-				var reflectionCube = ImageUtils.loadTextureCube( urls );
+				var reflectionCube = THREE.ImageUtils.loadTextureCube( urls );
 				var refractionCube = new THREE.Texture( reflectionCube.image, new THREE.CubeRefractionMapping() );
-				
+
 				//var cubeMaterial3 = new THREE.MeshPhongMaterial( { color: 0x000000, specular:0xaa0000, envMap: reflectionCube, combine: THREE.MixOperation, reflectivity: 0.25 } );
 				var cubeMaterial3 = new THREE.MeshLambertMaterial( { color: 0xff6600, envMap: reflectionCube, combine: THREE.MixOperation, reflectivity: 0.3 } );
 				var cubeMaterial2 = new THREE.MeshLambertMaterial( { color: 0xffee00, envMap: refractionCube, refractionRatio: 0.95 } );
 				var cubeMaterial1 = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: reflectionCube } )
 
-				SceneUtils.addPanoramaCubeWebGL( sceneCube, 10, reflectionCube );
+				THREE.SceneUtils.addPanoramaCubeWebGL( sceneCube, 10, reflectionCube );
 
 				renderer = new THREE.WebGLRenderer();
 				renderer.setSize( window.innerWidth, window.innerHeight );
@@ -137,9 +137,9 @@
 
 				var s = 15;
 
-				SceneUtils.addMesh( scene, geometry, s,      0, 0, -100, 0,0,0, m1 );
-				SceneUtils.addMesh( scene, geometry, s,   -900, 0, -100, 0,0,0, m2 );
-				SceneUtils.addMesh( scene, geometry, s,    900, 0, -100, 0,0,0, m3 );
+				THREE.SceneUtils.addMesh( scene, geometry, s,      0, 0, -100, 0,0,0, m1 );
+				THREE.SceneUtils.addMesh( scene, geometry, s,   -900, 0, -100, 0,0,0, m2 );
+				THREE.SceneUtils.addMesh( scene, geometry, s,    900, 0, -100, 0,0,0, m3 );
 
 				loader.statusDomElement.style.display = "none";
 
diff --git a/examples/webgl_materials_cubemap_balls_reflection.html b/examples/webgl_materials_cubemap_balls_reflection.html
index 92ee386a..73dc55e1 100644
--- a/examples/webgl_materials_cubemap_balls_reflection.html
+++ b/examples/webgl_materials_cubemap_balls_reflection.html
@@ -77,7 +77,7 @@
 				scene = new THREE.Scene();
 				sceneCube = new THREE.Scene();
 
-				var geometry = new Sphere( 100, 32, 16 );
+				var geometry = new THREE.Sphere( 100, 32, 16 );
 
 				var path = "textures/cube/pisa/";
 				var format = '.png';
@@ -87,7 +87,7 @@
 					path + 'pz' + format, path + 'nz' + format
 				];
 
-				var textureCube = ImageUtils.loadTextureCube( urls );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls );
 				var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube } );
 
 				for ( var i = 0; i < 500; i ++ ) {
@@ -96,16 +96,16 @@
 					mesh.position.x = Math.random() * 10000 - 5000;
 					mesh.position.y = Math.random() * 10000 - 5000;
 					mesh.position.z = Math.random() * 10000 - 5000;
-					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 2 + 1;
+					mesh.scale.x = mesh.scale.y = mesh.scale.z = Math.random() * 3 + 1;
 					scene.addObject( mesh );
 
 					spheres.push( mesh );
 
 				}
 
-				SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
+				THREE.SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, textureCube );
 
-				webglRenderer = new THREE.WebGLRenderer( { antialias: false } );
+				webglRenderer = new THREE.WebGLRenderer();
 				webglRenderer.setSize( window.innerWidth, window.innerHeight );
 				webglRenderer.autoClear = false;
 				container.appendChild( webglRenderer.domElement );
diff --git a/examples/webgl_materials_cubemap_balls_refraction.html b/examples/webgl_materials_cubemap_balls_refraction.html
index 7fb24bfb..12522e8a 100644
--- a/examples/webgl_materials_cubemap_balls_refraction.html
+++ b/examples/webgl_materials_cubemap_balls_refraction.html
@@ -38,7 +38,6 @@
 
 		
 		
-		
 
 		
-		
+
 		
 		
 		
@@ -116,7 +116,7 @@
 
 				// light representation
 
-				var sphere = new Sphere( 100, 16, 8 );
+				var sphere = new THREE.Sphere( 100, 16, 8 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) );
 				lightMesh.position = pointLight.position;
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
@@ -128,17 +128,17 @@
 
 				// normal map shader
 
-				var shader = ShaderUtils.lib[ "normal" ];
-				var uniforms = Uniforms.clone( shader.uniforms );
+				var shader = THREE.ShaderUtils.lib[ "normal" ];
+				var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
 				uniforms[ "enableAO" ].value = true;
 				uniforms[ "enableDiffuse" ].value = false;
 
-				uniforms[ "tNormal" ].texture = ImageUtils.loadTexture( "textures/normal/ninja/normal.jpg" );
-				uniforms[ "tAO" ].texture = ImageUtils.loadTexture( "textures/normal/ninja/ao.jpg" );
+				uniforms[ "tNormal" ].texture = THREE.ImageUtils.loadTexture( "textures/normal/ninja/normal.jpg" );
+				uniforms[ "tAO" ].texture = THREE.ImageUtils.loadTexture( "textures/normal/ninja/ao.jpg" );
 
-				uniforms[ "tDisplacement" ].texture = ImageUtils.loadTexture( "textures/normal/ninja/displacement.jpg" );
-				uniforms[ "uDisplacementBias" ].value = -0.428408 * scale;
+				uniforms[ "tDisplacement" ].texture = THREE.ImageUtils.loadTexture( "textures/normal/ninja/displacement.jpg" );
+				uniforms[ "uDisplacementBias" ].value = - 0.428408 * scale;
 				uniforms[ "uDisplacementScale" ].value = 2.436143 * scale;
 
 				uniforms[ "uPointLightPos" ].value = pointLight.position;
@@ -188,9 +188,9 @@
 			function createScene( geometry, scale, material1, material2 ) {
 
 				geometry.computeTangents();
-				
-				mesh1 = SceneUtils.addMesh( scene, geometry, scale, -scale * 12, 0, 0, 0,0,0, material1 );
-				mesh2 = SceneUtils.addMesh( scene, geometry, scale,  scale * 12, 0, 0, 0,0,0, material2 );
+
+				mesh1 = THREE.SceneUtils.addMesh( scene, geometry, scale, -scale * 12, 0, 0, 0,0,0, material1 );
+				mesh2 = THREE.SceneUtils.addMesh( scene, geometry, scale,  scale * 12, 0, 0, 0,0,0, material2 );
 
 				loader.statusDomElement.style.display = "none";
 
diff --git a/examples/webgl_materials_normalmap2.html b/examples/webgl_materials_normalmap2.html
index 8554e654..f88948a6 100644
--- a/examples/webgl_materials_normalmap2.html
+++ b/examples/webgl_materials_normalmap2.html
@@ -28,7 +28,7 @@
 
 			#oldie {
 				background:rgb(200,100,0) !important;
-				color:#fff;				
+				color:#fff;
 			}
 
 			#vt { display:none }
@@ -113,13 +113,13 @@
 
 				var ambient = 0x444444, diffuse = 0x888888, specular = 0x080810, shininess = 2;
 
-				var shader = ShaderUtils.lib[ "normal" ];
-				var uniforms = Uniforms.clone( shader.uniforms );
+				var shader = THREE.ShaderUtils.lib[ "normal" ];
+				var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
  
-				uniforms[ "tNormal" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
+				uniforms[ "tNormal" ].texture = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
 				uniforms[ "uNormalScale" ].value = - 0.75;
 
-				uniforms[ "tDiffuse" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
+				uniforms[ "tDiffuse" ].texture = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
 
 				uniforms[ "enableAO" ].value = false;
 				uniforms[ "enableDiffuse" ].value = true;
@@ -168,7 +168,7 @@
 
 				geometry.computeTangents();
 
-				mesh1 = SceneUtils.addMesh( scene, geometry, scale, 0, - 50, 0, 0, 0, 0, material );
+				mesh1 = THREE.SceneUtils.addMesh( scene, geometry, scale, 0, - 50, 0, 0, 0, 0, material );
 
 				loader.statusDomElement.style.display = "none";
 
diff --git a/examples/webgl_materials_shaders.html b/examples/webgl_materials_shaders.html
index 022921bd..d242fb65 100644
--- a/examples/webgl_materials_shaders.html
+++ b/examples/webgl_materials_shaders.html
@@ -125,18 +125,18 @@
 				scene.addLight( pointLight );
 
 				// light representation
-				sphere = new Sphere( 100, 16, 8 );
+				sphere = new THREE.Sphere( 100, 16, 8 );
 				lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) );
 				lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05;
 				lightMesh.position = pointLight.position;
 				lightMesh.overdraw = true;
 				lightMesh.updateMatrix();
-				scene.addObject(lightMesh);
+				scene.addObject( lightMesh );
 
 				// material samples
-				sphere = new Sphere( 100, 32, 32 );
+				sphere = new THREE.Sphere( 100, 32, 32 );
 
-				var y1 = 0, y2 = -200;
+				var y1 = 0, y2 = - 200;
 
 				addMesh( sphere, 1, -600, y1, 0, 0,0,0, new THREE.MeshPhongMaterial( { ambient: 0x050505, color: 0x000000, specular: 0x555555, shininess: 30 } ) );
 				addMesh( sphere, 1, -600, y2, 0, 0,0,0, new THREE.MeshLambertMaterial( { color: 0x050505 } ) );
@@ -160,6 +160,7 @@
 				addMesh( sphere, 1,  600, y2, 0, 0,0,0, new THREE.MeshLambertMaterial( { color: 0x5500ff } ) );
 
 				if ( render_gl ) {
+
 					try {
 						webglRenderer = new THREE.WebGLRenderer();
 						webglRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
@@ -169,12 +170,15 @@
 					}
 					catch (e) {
 					}
+
 				}
 
-				if( render_canvas ) {
+				if ( render_canvas ) {
+
 					canvasRenderer = new THREE.CanvasRenderer();
 					canvasRenderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
 					container.appendChild( canvasRenderer.domElement );
+
 				}
 
 
diff --git a/examples/webgl_materials_shaders_fresnel.html b/examples/webgl_materials_shaders_fresnel.html
index e5488ecd..cf01e10b 100644
--- a/examples/webgl_materials_shaders_fresnel.html
+++ b/examples/webgl_materials_shaders_fresnel.html
@@ -41,7 +41,6 @@
 
 		
 		
-		
 
 		
 
@@ -109,31 +109,31 @@
 				scene.addLight( light );
 
 
+				var geometry = new THREE.Cube( 100, 100, 100 );
 				var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true } );
-				var geometry = new Cube( 100, 100, 100 );
 
 				// construct 8 blend shapes
-				
-				for( var i = 0; i < geometry.vertices.length; i++ ) {
-					
+
+				for ( var i = 0; i < geometry.vertices.length; i ++ ) {
+
 					var vertices = [];
-					
-					for( var v = 0; v < geometry.vertices.length; v++ ) {
-						
+
+					for ( var v = 0; v < geometry.vertices.length; v ++ ) {
+
 						vertices.push( new THREE.Vertex( geometry.vertices[ v ].position.clone() ) )
-						
-						if( v === i ) {
-							
-							vertices[ vertices.length -1 ].position.x *= 2;
-							vertices[ vertices.length -1 ].position.y *= 2;
-							vertices[ vertices.length -1 ].position.z *= 2;
-							
+
+						if ( v === i ) {
+
+							vertices[ vertices.length - 1 ].position.x *= 2;
+							vertices[ vertices.length - 1 ].position.y *= 2;
+							vertices[ vertices.length - 1 ].position.z *= 2;
+
 						}
-						
+
 					}
-					
+
 					geometry.morphTargets.push( { name: "target" + i, vertices: vertices } );
-					
+
 				}
 
 				mesh = new THREE.Mesh( geometry, material );
@@ -174,7 +174,7 @@
 				renderer.render( scene, camera );
 
 			}
-			
+
 			function log( text ) {
 
 				var e = document.getElementById("log");
diff --git a/examples/webgl_objconvert_test.html b/examples/webgl_objconvert_test.html
index 0a53b8ac..a699eae2 100644
--- a/examples/webgl_objconvert_test.html
+++ b/examples/webgl_objconvert_test.html
@@ -110,14 +110,14 @@
 
 				var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x, THREE.UVMapping, THREE.RepeatWrapping, THREE.RepeatWrapping ) } );
 				xm.map.needsUpdate = true;
-				
-				geometry = new Plane( 100, 100, 15, 10 );
+
+				geometry = new THREE.Plane( 100, 100, 15, 10 );
 				for( var i = 0; i < geometry.faceVertexUvs[ 0 ].length; i++ ) {
-					
+
 					var uvs = geometry.faceVertexUvs[ 0 ][ i ];
-					
+
 					for ( j = 0, jl = uvs.length; j < jl; j++ ) {
-					
+
 						uvs[ j ].u *= 10;
 						uvs[ j ].v *= 10;
 
@@ -137,7 +137,7 @@
 				// SPHERES
 
 				var material_spheres = new THREE.MeshLambertMaterial( { color: 0xdddddd } ),
-					sphere = new Sphere( 100, 16, 8 );
+					sphere = new THREE.Sphere( 100, 16, 8 );
 				for (var i=0; i<10; i++) {
 					mesh = new THREE.Mesh( sphere, material_spheres );
 					mesh.position.x = 500 * (Math.random() - 0.5);
@@ -222,10 +222,10 @@
 
 			function createMaterialsPalette( materials, size, bottom ) {
 
-				for ( var i = 0; i < materials.length; ++i ) {
+				for ( var i = 0; i < materials.length; i ++ ) {
 
 					// material
-					mesh = new THREE.Mesh( new Plane( size, size ), materials[i] );
+					mesh = new THREE.Mesh( new THREE.Plane( size, size ), materials[i] );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
 					mesh.position.y = FLOOR + size/2 + bottom;
 					mesh.position.z = -100;
@@ -247,7 +247,7 @@
 					var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ) } );
 					xm.map.needsUpdate = true;
 
-					mesh = new THREE.Mesh( new Plane( size, size ), xm );
+					mesh = new THREE.Mesh( new THREE.Plane( size, size ), xm );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
 					mesh.position.y = FLOOR + size/2 + bottom;
 					mesh.position.z = -99;
diff --git a/examples/webgl_panorama_equirectangular.html b/examples/webgl_panorama_equirectangular.html
index 4f0b82f4..0cc4fa91 100644
--- a/examples/webgl_panorama_equirectangular.html
+++ b/examples/webgl_panorama_equirectangular.html
@@ -59,7 +59,7 @@
 
 				scene = new THREE.Scene();
 
-				mesh = new THREE.Mesh( new Sphere( 500, 60, 40 ), new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' ) } ) );
+				mesh = new THREE.Mesh( new THREE.Sphere( 500, 60, 40 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' ) } ) );
 				mesh.scale.x = -1;
 				scene.addObject( mesh );
 
diff --git a/examples/webgl_particles_billboards.html b/examples/webgl_particles_billboards.html
index 07c66084..2c43f6e2 100644
--- a/examples/webgl_particles_billboards.html
+++ b/examples/webgl_particles_billboards.html
@@ -68,7 +68,7 @@
 
 				geometry = new THREE.Geometry();
 
-				sprite = ImageUtils.loadTexture( "textures/sprites/circle.png" );
+				sprite = THREE.ImageUtils.loadTexture( "textures/sprites/circle.png" );
 
 				for ( i = 0; i < 10000; i++ ) {
 
@@ -95,7 +95,7 @@
 				light.position.z = 1;
 				scene.addLight( light );
 
-				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
diff --git a/examples/webgl_particles_billboards_colors.html b/examples/webgl_particles_billboards_colors.html
index 779c4c5b..a87b94da 100644
--- a/examples/webgl_particles_billboards_colors.html
+++ b/examples/webgl_particles_billboards_colors.html
@@ -68,7 +68,7 @@
 
 				geometry = new THREE.Geometry();
 
-				sprite = ImageUtils.loadTexture( "textures/sprites/ball.png" );
+				sprite = THREE.ImageUtils.loadTexture( "textures/sprites/ball.png" );
 
 				for ( i = 0; i < 5000; i++ ) {
 
@@ -99,7 +99,7 @@
 				light.position.z = 1;
 				scene.addLight( light );
 
-				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
diff --git a/examples/webgl_particles_sprites.html b/examples/webgl_particles_sprites.html
index fa1e6fff..981605a1 100644
--- a/examples/webgl_particles_sprites.html
+++ b/examples/webgl_particles_sprites.html
@@ -69,13 +69,13 @@
 
 				geometry = new THREE.Geometry();
 
-				sprite1 = ImageUtils.loadTexture( "textures/sprites/snowflake1.png" );
-				sprite2 = ImageUtils.loadTexture( "textures/sprites/snowflake2.png" );
-				sprite3 = ImageUtils.loadTexture( "textures/sprites/snowflake3.png" );
-				sprite4 = ImageUtils.loadTexture( "textures/sprites/snowflake4.png" );
-				sprite5 = ImageUtils.loadTexture( "textures/sprites/snowflake5.png" );
+				sprite1 = THREE.ImageUtils.loadTexture( "textures/sprites/snowflake1.png" );
+				sprite2 = THREE.ImageUtils.loadTexture( "textures/sprites/snowflake2.png" );
+				sprite3 = THREE.ImageUtils.loadTexture( "textures/sprites/snowflake3.png" );
+				sprite4 = THREE.ImageUtils.loadTexture( "textures/sprites/snowflake4.png" );
+				sprite5 = THREE.ImageUtils.loadTexture( "textures/sprites/snowflake5.png" );
 
-				for ( i = 0; i < 2000; i++ ) {
+				for ( i = 0; i < 2000; i ++ ) {
 
 					vector = new THREE.Vector3( Math.random() * 2000 - 1000, Math.random() * 2000 - 1000, Math.random() * 2000 - 1000 );
 					geometry.vertices.push( new THREE.Vertex( vector ) );
@@ -102,7 +102,7 @@
 
 				}
 
-				renderer = new THREE.WebGLRenderer( { antialias: false, clearAlpha: 1 });
+				renderer = new THREE.WebGLRenderer( { clearAlpha: 1 });
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
diff --git a/examples/webgl_postprocessing.html b/examples/webgl_postprocessing.html
index 69461baa..9ee5a839 100644
--- a/examples/webgl_postprocessing.html
+++ b/examples/webgl_postprocessing.html
@@ -122,8 +122,8 @@
 
 				} );
 
-				var screen_shader = ShaderUtils.lib["screen"];
-				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+				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 = 0.4;
@@ -138,8 +138,8 @@
 
 				} );
 
-				var film_shader = ShaderUtils.lib["film"];
-				var film_uniforms = Uniforms.clone( film_shader.uniforms );
+				var film_shader = THREE.ShaderUtils.lib["film"];
+				var film_uniforms = THREE.UniformsUtils.clone( film_shader.uniforms );
 
 				film_uniforms["tDiffuse"].texture = rtTexture1;
 				film_uniforms["nIntensity"].value = 0.25;
@@ -158,12 +158,12 @@
 				blurx = new THREE.Vector2( increment, 0.0 ),
 				blury = new THREE.Vector2( 0.0, increment );
 
-				var convolution_shader = ShaderUtils.lib["convolution"];
-				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+				var convolution_shader = THREE.ShaderUtils.lib["convolution"];
+				var convolution_uniforms = THREE.UniformsUtils.clone( convolution_shader.uniforms );
 
 				convolution_uniforms["tDiffuse"].texture = rtTexture1;
 				convolution_uniforms["uImageIncrement"].value = blurx;
-				convolution_uniforms["cKernel"].value = ShaderUtils.buildKernel( 4.0 );
+				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
 
 				materialConvolution = new THREE.MeshShaderMaterial( {
 
@@ -173,7 +173,7 @@
 
 				} );
 
-				var plane = new Plane( window.innerWidth, window.innerHeight );
+				var plane = new THREE.Plane( window.innerWidth, window.innerHeight );
 
 				quadBG = new THREE.Mesh( plane, materialColor );
 				quadBG.position.z = -500;
@@ -211,13 +211,13 @@
 
 				var ambient = 0x444444, diffuse = 0x888888, specular = 0x080810, shininess = 2;
 
-				var shader = ShaderUtils.lib[ "normal" ];
-				var uniforms = Uniforms.clone( shader.uniforms );
+				var shader = THREE.ShaderUtils.lib[ "normal" ];
+				var uniforms = THREE.UniformsUtils.clone( shader.uniforms );
 
-				uniforms[ "tNormal" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
+				uniforms[ "tNormal" ].texture = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Infinite-Level_02_Tangent_SmoothUV.jpg" );
 				uniforms[ "uNormalScale" ].value = - 0.75;
 
-				uniforms[ "tDiffuse" ].texture = ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
+				uniforms[ "tDiffuse" ].texture = THREE.ImageUtils.loadTexture( "obj/leeperrysmith/Map-COL.jpg" );
 
 				uniforms[ "enableAO" ].value = false;
 				uniforms[ "enableDiffuse" ].value = true;
diff --git a/examples/webgl_postprocessing_dof.html b/examples/webgl_postprocessing_dof.html
index 3dd4320f..1c1eb8e6 100644
--- a/examples/webgl_postprocessing_dof.html
+++ b/examples/webgl_postprocessing_dof.html
@@ -93,7 +93,7 @@
 						path + 'pz' + format, path + 'nz' + format
 					];
 
-				var textureCube = ImageUtils.loadTextureCube( urls );
+				var textureCube = THREE.ImageUtils.loadTextureCube( urls );
 
 				parameters = { color: 0xff1100, envMap: textureCube, shading: THREE.FlatShading };
 				cubeMaterial = new THREE.MeshBasicMaterial( parameters );
@@ -102,12 +102,12 @@
 
 				if( singleMaterial ) zmaterial = [ cubeMaterial ];
 
-				//var geo = new Cube( 1, 1, 1 );
-				//var geo = new Icosahedron( 2 );
-				var geo = new Sphere( 1, 20, 10 );
+				//var geo = new THREE.Cube( 1, 1, 1 );
+				//var geo = new THREE.Icosahedron( 2 );
+				var geo = new THREE.Sphere( 1, 20, 10 );
 
 				var start = new Date().getTime();
-				
+
 				renderer.initMaterial( cubeMaterial, scene.lights, scene.fog );
 
 				var xgrid = 14,
@@ -155,7 +155,7 @@
 				}
 
 				//console.log("init time: ", new Date().getTime() - start );
-				
+
 				scene.matrixAutoUpdate = false;
 
 				initPostprocessing();
@@ -244,7 +244,7 @@
 
 				var bokeh_shader = ShaderExtras["bokeh"];
 
-				postprocessing.bokeh_uniforms = Uniforms.clone( bokeh_shader.uniforms );
+				postprocessing.bokeh_uniforms = THREE.UniformsUtils.clone( bokeh_shader.uniforms );
 
 				postprocessing.bokeh_uniforms["tColor"].texture = postprocessing.rtTextureColor;
 				postprocessing.bokeh_uniforms["tDepth"].texture = postprocessing.rtTextureDepth;
@@ -259,8 +259,8 @@
 
 				} );
 
-				postprocessing.quad = new THREE.Mesh( new Plane( window.innerWidth, window.innerHeight ), postprocessing.materialBokeh );
-				postprocessing.quad.position.z = -500;
+				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialBokeh );
+				postprocessing.quad.position.z = - 500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
 			}
diff --git a/examples/webgl_ribbons.html b/examples/webgl_ribbons.html
index d5bd7a70..eca5acdd 100644
--- a/examples/webgl_ribbons.html
+++ b/examples/webgl_ribbons.html
@@ -236,8 +236,8 @@
 				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
 				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
 
-				var screen_shader = ShaderUtils.lib["screen"];
-				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+				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;
@@ -252,15 +252,15 @@
 
 				} );
 
-				var convolution_shader = ShaderUtils.lib["convolution"];
-				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+				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 = ShaderUtils.buildKernel( 4.0 );
+				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
 
 				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
 
@@ -270,7 +270,7 @@
 
 				} );
 
-				postprocessing.quad = new THREE.Mesh( new Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
 				postprocessing.quad.position.z = -500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
diff --git a/examples/webgl_rtt.html b/examples/webgl_rtt.html
index 53454f65..f258d3d2 100644
--- a/examples/webgl_rtt.html
+++ b/examples/webgl_rtt.html
@@ -150,7 +150,7 @@
 
 				// var mt = new THREE.MeshBasicMaterial( { color:0xffffff, map: ImageUtils.loadTexture( "textures/land_ocean_ice_cloud_2048.jpg" ) } );
 
-				var plane = new Plane( window.innerWidth, window.innerHeight );
+				var plane = new THREE.Plane( window.innerWidth, window.innerHeight );
 
 				quad = new THREE.Mesh( plane, material );
 				quad.position.z = -100;
@@ -164,7 +164,7 @@
 				sceneScreen.addObject( quad );
 
 				var n = 5,
-					geometry = new Sphere( 10, 64, 32 ),
+					geometry = new THREE.Sphere( 10, 64, 32 ),
 					material2 = new THREE.MeshLambertMaterial( { color:0xffffff, map: rtTexture } );
 					//material2 = new THREE.MeshBasicMaterial( { color:0xffffff, map: rtTexture } );
 
diff --git a/examples/webgl_sandbox.html b/examples/webgl_sandbox.html
index 2c33caa4..7260b58d 100644
--- a/examples/webgl_sandbox.html
+++ b/examples/webgl_sandbox.html
@@ -74,7 +74,6 @@
 		
 		
 		
-		
 		
 		
 		
@@ -153,11 +152,11 @@
 				scene = new THREE.Scene();
 				scene.fog = new THREE.Fog( 0xffffff, 1, 10000 );
 
-				var geometry = new Sphere( 50, 32, 16 );
+				var geometry = new THREE.Sphere( 50, 32, 16 );
 
-				var uniforms = ShaderUtils.lib[ 'basic' ].uniforms;
-				var vertexShader = ShaderUtils.lib[ 'basic' ].vertexShader;
-				var fragmentShader = ShaderUtils.lib[ 'basic' ].fragmentShader;
+				var uniforms = THREE.ShaderUtils.lib[ 'basic' ].uniforms;
+				var vertexShader = THREE.ShaderUtils.lib[ 'basic' ].vertexShader;
+				var fragmentShader = THREE.ShaderUtils.lib[ 'basic' ].fragmentShader;
 
 				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() );
@@ -168,8 +167,8 @@
 					new THREE.MeshDepthMaterial(),
 					new THREE.MeshBasicMaterial( { color: 0x0066ff, blending: THREE.AdditiveBlending } ),
 					new THREE.MeshBasicMaterial( { map: texture, fog: false } ),
-					new THREE.MeshBasicMaterial( { map: ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
-					new THREE.MeshBasicMaterial( { map: texture2, envMap: ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ),
+					new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/land_ocean_ice_cloud_2048.jpg' ) } ),
+					new THREE.MeshBasicMaterial( { map: texture2, envMap: THREE.ImageUtils.loadTexture( 'textures/envmap.png', new THREE.SphericalReflectionMapping() ) } ),
 					new THREE.MeshShaderMaterial( { uniforms: uniforms, vertexShader: vertexShader, fragmentShader: fragmentShader } )
 
 					/*
diff --git a/examples/webgl_scene_test.html b/examples/webgl_scene_test.html
index 2c239e8c..256121e8 100644
--- a/examples/webgl_scene_test.html
+++ b/examples/webgl_scene_test.html
@@ -353,7 +353,7 @@
 				var object, geometry, material, light, count = 500, range = 200;
 
 				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
-				geometry = new Cube( 5, 5, 5 );
+				geometry = new THREE.Cube( 5, 5, 5 );
 
 				for( var i = 0; i < count; i++ ) {
 
diff --git a/examples/webgl_scene_test_blender.html b/examples/webgl_scene_test_blender.html
index 3f53f7fd..7ebf9eb5 100644
--- a/examples/webgl_scene_test_blender.html
+++ b/examples/webgl_scene_test_blender.html
@@ -150,7 +150,7 @@
 		

 
 		
-		
+
 		
 		
 		
@@ -342,7 +342,7 @@
 				var object, geometry, material, light, count = 500, range = 200;
 
 				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
-				geometry = new Cube( 5, 5, 5 );
+				geometry = new THREE.Cube( 5, 5, 5 );
 
 				for( var i = 0; i < count; i++ ) {
 
diff --git a/examples/webgl_shader.html b/examples/webgl_shader.html
index d5d27c70..0facee39 100644
--- a/examples/webgl_shader.html
+++ b/examples/webgl_shader.html
@@ -125,7 +125,7 @@
 
 					} );
 
-				mesh = new THREE.Mesh( new Plane( 2, 2 ), material );
+				mesh = new THREE.Mesh( new THREE.Plane( 2, 2 ), material );
 				scene.addObject( mesh );
 
 				renderer = new THREE.WebGLRenderer();
diff --git a/examples/webgl_shader2.html b/examples/webgl_shader2.html
index b172feaa..3f185123 100644
--- a/examples/webgl_shader2.html
+++ b/examples/webgl_shader2.html
@@ -208,7 +208,7 @@
 				uniforms2 = {
 					time: { type: "f", value: 1.0 },
 					resolution: { type: "v2", value: new THREE.Vector2() },
-					texture: { type: "t", value: 0, texture: ImageUtils.loadTexture( "textures/disturb.jpg" ) }
+					texture: { type: "t", value: 0, texture: THREE.ImageUtils.loadTexture( "textures/disturb.jpg" ) }
 				};
 
 				uniforms2.texture.texture.wrapS = uniforms2.texture.texture.wrapT = THREE.Repeat;
@@ -228,8 +228,8 @@
 
 					mlib[ i ] = material;
 
-					mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, 1, [ mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ] ], false ), new THREE.MeshFaceMaterial() );
-					mesh.position.x = i - (params.length - 1)/2;
+					mesh = new THREE.Mesh( new THREE.Cube( size, size, size, 1, 1, 1, [ mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ] ], false ), new THREE.MeshFaceMaterial() );
+					mesh.position.x = i - ( params.length - 1 ) / 2;
 					mesh.position.y = i % 2 - 0.5;
 					scene.addObject( mesh );
 
diff --git a/examples/webgl_shader_lava.html b/examples/webgl_shader_lava.html
index f07a9259..0cf00ee9 100644
--- a/examples/webgl_shader_lava.html
+++ b/examples/webgl_shader_lava.html
@@ -45,7 +45,7 @@
 
 			uniform float time;
 			uniform vec2 resolution;
-			
+
 			uniform float fogDensity;
 			uniform vec3 fogColor;
 
@@ -61,28 +61,28 @@
 				vec4 noise = texture2D( texture1, vUv );
 				vec2 T1 = vUv + vec2( 1.5, -1.5 ) * time  *0.02;
 				vec2 T2 = vUv + vec2( -0.5, 2.0 ) * time * 0.01;
-				
+
 				T1.x += noise.x * 2.0;
 				T1.y += noise.y * 2.0;
 				T2.x -= noise.y * 0.2;
 				T2.y += noise.z * 0.2;
-				
+
 				float p = texture2D( texture1, T1 * 2.0 ).a;
-				
+
 				vec4 color = texture2D( texture2, T2 * 2.0 );
 				vec4 temp = color * ( vec4( p, p, p, p ) * 2.0 ) + ( color * color - 0.1 );
-				
+
 				if( temp.r > 1.0 ){ temp.bg += clamp( temp.r - 2.0, 0.0, 100.0 ); }
 				if( temp.g > 1.0 ){ temp.rb += temp.g - 1.0; }
 				if( temp.b > 1.0 ){ temp.rg += temp.b - 1.0; }
-				
+
 				gl_FragColor = temp;
 
 				float depth = gl_FragCoord.z / gl_FragCoord.w;
 				const float LOG2 = 1.442695;
 				float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );
 				fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );
-				
+
 				gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
 
 			}
@@ -123,7 +123,7 @@
 			var windowHalfY = window.innerHeight / 2;
 
 			var postprocessing = { enabled : true };
-			
+
 			init();
 			animate();
 
@@ -139,14 +139,14 @@
 				start_time = new Date().getTime();
 
 				uniforms = {
-				
+
 					fogDensity: { type: "f", value: 0.45 },
-					fogColor: 	{ type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
-					time: 		{ type: "f", value: 1.0 },
+					fogColor: { type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
+					time: { type: "f", value: 1.0 },
 					resolution: { type: "v2", value: new THREE.Vector2() },
-					uvScale: 	{ type: "v2", value: new THREE.Vector2( 3.0, 1.0 ) },
-					texture1: 	{ type: "t", value: 0, texture: ImageUtils.loadTexture( "textures/lava/cloud.png" ) },
-					texture2: 	{ type: "t", value: 1, texture: ImageUtils.loadTexture( "textures/lava/lavatile.jpg" ) }
+					uvScale: { type: "v2", value: new THREE.Vector2( 3.0, 1.0 ) },
+					texture1: { type: "t", value: 0, texture: THREE.ImageUtils.loadTexture( "textures/lava/cloud.png" ) },
+					texture2: { type: "t", value: 1, texture: THREE.ImageUtils.loadTexture( "textures/lava/lavatile.jpg" ) }
 
 				};
 
@@ -163,7 +163,7 @@
 
 				} );
 
-				mesh = new THREE.Mesh( new Torus( size, 0.3, 30, 30 ), [ material /*, new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 2 } ) */ ] );
+				mesh = new THREE.Mesh( new THREE.Torus( size, 0.3, 30, 30 ), [ material /*, new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 2 } ) */ ] );
 				mesh.position.x = 0;
 				mesh.position.y = 0;
 				mesh.rotation.x = 0.3;
@@ -212,8 +212,8 @@
 				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
 				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
 
-				var screen_shader = ShaderUtils.lib["screen"];
-				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+				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;
@@ -228,15 +228,15 @@
 
 				} );
 
-				var convolution_shader = ShaderUtils.lib["convolution"];
-				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+				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 = ShaderUtils.buildKernel( 4.0 );
+				convolution_uniforms["cKernel"].value = THREE.ShaderUtils.buildKernel( 4.0 );
 
 				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
 
@@ -246,23 +246,23 @@
 
 				} );
 
-				var film_shader = ShaderUtils.lib["film"];
-				var film_uniforms = Uniforms.clone( film_shader.uniforms );
-				
+				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.35;
 				postprocessing.materialFilm.uniforms.sIntensity.value = 0.95;
 				postprocessing.materialFilm.uniforms.sCount.value = 2048;
 
-				postprocessing.quad = new THREE.Mesh( new Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
-				postprocessing.quad.position.z = -500;
+				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad.position.z = - 500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
 			}
-			
+
 			//
 
 			function animate() {
diff --git a/examples/webgl_sprites.html b/examples/webgl_sprites.html
index a5a562b6..81264b5f 100644
--- a/examples/webgl_sprites.html
+++ b/examples/webgl_sprites.html
@@ -51,8 +51,8 @@
 
 				var amount = 200;
 				var radius = 500;
-				var mapA =  ImageUtils.loadTexture( "textures/sprite0.png" );
-				var mapB =  ImageUtils.loadTexture( "textures/sprite1.png" );
+				var mapA = THREE.ImageUtils.loadTexture( "textures/sprite0.png" );
+				var mapB = THREE.ImageUtils.loadTexture( "textures/sprite1.png" );
 
 				group = new THREE.Object3D();
 
@@ -98,7 +98,7 @@
 
 				// renderer
 
-				renderer = new THREE.WebGLRenderer( { antialias: false } );
+				renderer = new THREE.WebGLRenderer();
 				renderer.setClearColorHex( 0x000000, 1 );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.sortObjects = true;
diff --git a/examples/webgl_stencil.html b/examples/webgl_stencil.html
index 69cd5e27..40e7b273 100644
--- a/examples/webgl_stencil.html
+++ b/examples/webgl_stencil.html
@@ -51,22 +51,22 @@
 
 				// world
 
-				var cube = new Cube( 300, 300, 10 );
+				var cube = new THREE.Cube( 300, 300, 10 );
 				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
 				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
 				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
 
 				var mesh1 = new THREE.Mesh( cube, material0 );
-				mesh1.position.z = -150;
+				mesh1.position.z = - 150;
 				scene.addChild( mesh1 );
 
 				var mesh2 = new THREE.Mesh( cube, material1 );
-				mesh2.position.x = -150;
+				mesh2.position.x = - 150;
 				mesh2.rotation.y = 90 * Math.PI / 180;
 				scene.addChild( mesh2 );
 
 				var mesh3 = new THREE.Mesh( cube, material2 );
-				mesh3.position.y = -150;
+				mesh3.position.y = - 150;
 				mesh3.rotation.x = 90 * Math.PI / 180;
 				scene.addChild( mesh3 );
 
@@ -77,10 +77,10 @@
 
 				// moving objects
 
-				var cube = new Cube( 40, 40, 40 );
-				var torus = new Torus( 40, 10 );
-				var sphere = new Sphere( 40 );
-				var cylinder = new Cylinder( 10, 10, 20, 40, 0, 0 );
+				var cube = new THREE.Cube( 40, 40, 40 );
+				var torus = new THREE.Torus( 40, 10 );
+				var sphere = new THREE.Sphere( 40 );
+				var cylinder = new THREE.Cylinder( 10, 10, 20, 40, 0, 0 );
 				mesh = new THREE.Mesh( torus, material1 );
 				scene.addChild( mesh );
 
@@ -97,7 +97,7 @@
 				light.position.set( 0, 1, 0 );
 				scene.addChild( light );
 
-				var cube = new Sphere( 5 );
+				var cube = new THREE.Sphere( 5 );
 				lightCube = new THREE.Mesh( cube, material2 );
 				scene.addChild( lightCube );
 
diff --git a/examples/webgl_stencilLensFlare.html b/examples/webgl_stencilLensFlare.html
index 403e6bec..1e456f33 100644
--- a/examples/webgl_stencilLensFlare.html
+++ b/examples/webgl_stencilLensFlare.html
@@ -50,7 +50,7 @@
 
 				// world
 
-				var cube = new Cube( 300, 300, 10 );
+				var cube = new THREE.Cube( 300, 300, 10 );
 				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
 				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
 				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
@@ -76,10 +76,10 @@
 
 				// moving objects
 
-				var cube = new Cube( 40, 40, 40 );
-				var torus = new Torus( 40, 10 );
-				var sphere = new Sphere( 40 );
-				var cylinder = new Cylinder( 10, 10, 20, 40, 0, 0 );
+				var cube = new THREE.Cube( 40, 40, 40 );
+				var torus = new THREE.Torus( 40, 10 );
+				var sphere = new THREE.Sphere( 40 );
+				var cylinder = new THREE.Cylinder( 10, 10, 20, 40, 0, 0 );
 				mesh = new THREE.Mesh( torus, material1 );
 				scene.addChild( mesh );
 
@@ -101,13 +101,13 @@
 				scene.addChild( light );
 
 
-				var cube = new Sphere( 2 );
+				var cube = new THREE.Sphere( 2 );
 				lightCube = new THREE.Mesh( cube, material2 );
 				lightCube.visible = false;
 				scene.addChild( lightCube );
 
-				var lensFlare = new THREE.LensFlare( ImageUtils.loadTexture( "textures/lensflare0.png" ), 128, 0.0, THREE.AdditiveBlending );
-				lensFlare.add( ImageUtils.loadTexture( "textures/lensflare1.png" ), 256, 0.33, THREE.AdditiveBlending );
+				var lensFlare = new THREE.LensFlare( THREE.ImageUtils.loadTexture( "textures/lensflare0.png" ), 128, 0.0, THREE.AdditiveBlending );
+				lensFlare.add( THREE.ImageUtils.loadTexture( "textures/lensflare1.png" ), 256, 0.33, THREE.AdditiveBlending );
 				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 300, 0.66, THREE.AdditiveBlending );
 				lensFlare.add( lensFlare.lensFlares[ 1 ].texture, 400, 1.0, THREE.AdditiveBlending );
 
diff --git a/src/Three.js b/src/Three.js
index fe1cc50a..f593c83e 100644
--- a/src/Three.js
+++ b/src/Three.js
@@ -3,3 +3,10 @@
  */
 
 var THREE = THREE || {};
+
+if ( ! window.Int32Array ) {
+
+	window.Int32Array = Array;
+	window.Float32Array = Array;
+
+}
diff --git a/src/extras/ImageUtils.js b/src/extras/ImageUtils.js
index 12c9eeaf..516cc4f3 100644
--- a/src/extras/ImageUtils.js
+++ b/src/extras/ImageUtils.js
@@ -1,11 +1,15 @@
-var ImageUtils = {
+/**
+ * @author alteredq / http://alteredqualia.com/
+ */
+
+THREE.ImageUtils = {
 
 	loadTexture: function ( path, mapping, callback ) {
 
 		var image = new Image(),
 			texture = new THREE.Texture( image, mapping );
 
-		image.onload = function () { texture.needsUpdate = true; if( callback ) callback( this ); };
+		image.onload = function () { texture.needsUpdate = true; if ( callback ) callback( this ); };
 		image.src = path;
 
 		return texture;
@@ -25,11 +29,11 @@ var ImageUtils = {
 			images[ i ] = new Image();
 			images[ i ].onload = function () {
 
-					images.loadCount += 1; 
-					if( images.loadCount == 6 ) texture.needsUpdate = true; 
-					if( callback ) callback( this ); 
+				images.loadCount += 1; 
+				if ( images.loadCount == 6 ) texture.needsUpdate = true; 
+				if ( callback ) callback( this );
 
-				};
+			};
 
 			images[ i ].src = array[ i ];
 
diff --git a/src/extras/SceneUtils.js b/src/extras/SceneUtils.js
index 6a5a481d..4c7c0987 100644
--- a/src/extras/SceneUtils.js
+++ b/src/extras/SceneUtils.js
@@ -2,7 +2,7 @@
  * @author alteredq / http://alteredqualia.com/
  */
 
-var SceneUtils = {
+THREE.SceneUtils = {
 
 	addMesh : function ( scene, geometry, scale, x, y, z, rx, ry, rz, material ) {
 
@@ -22,15 +22,18 @@ var SceneUtils = {
 
 	addPanoramaCubeWebGL : function ( scene, size, textureCube ) {
 
-		var shader = ShaderUtils.lib["cube"];
+		var shader = THREE.ShaderUtils.lib["cube"];
 		shader.uniforms["tCube"].texture = textureCube;
 
-		var material = new THREE.MeshShaderMaterial( { fragmentShader: shader.fragmentShader,
-								   vertexShader: shader.vertexShader,
-								   uniforms: shader.uniforms
-								} ),
+		var material = new THREE.MeshShaderMaterial( {
 
-		mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, 1, null, true ), material );
+			fragmentShader: shader.fragmentShader,
+			vertexShader: shader.vertexShader,
+			uniforms: shader.uniforms
+
+		} ),
+
+		mesh = new THREE.Mesh( new THREE.Cube( size, size, size, 1, 1, 1, null, true ), material );
 		scene.addObject( mesh );
 
 		return mesh;
@@ -40,6 +43,7 @@ var SceneUtils = {
 	addPanoramaCube : function( scene, size, images ) {
 
 		var materials = [], mesh;
+
 		materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 0 ] ) } ) );
 		materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 1 ] ) } ) );
 		materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 2 ] ) } ) );
@@ -47,7 +51,7 @@ var SceneUtils = {
 		materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 4 ] ) } ) );
 		materials.push( new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[ 5 ] ) } ) );
 
-		mesh = new THREE.Mesh( new Cube( size, size, size, 1, 1, materials, true ), new THREE.MeshFaceMaterial() );
+		mesh = new THREE.Mesh( new THREE.Cube( size, size, size, 1, 1, materials, true ), new THREE.MeshFaceMaterial() );
 		scene.addObject( mesh );
 
 		return mesh;
@@ -57,36 +61,36 @@ var SceneUtils = {
 	addPanoramaCubePlanes : function ( scene, size, images ) {
 
 
-		var hsize = size / 2, plane = new Plane( size, size ), pi = Math.PI, pi2 = Math.PI / 2;
+		var hsize = size / 2, plane = new THREE.Plane( size, size ), pi = Math.PI, pi2 = Math.PI / 2;
 
-		SceneUtils.addMesh( scene, plane, 1,      0,     0,  -hsize,  0,      0,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[5] ) } ) );
-		SceneUtils.addMesh( scene, plane, 1, -hsize,     0,       0,  0,    pi2,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[0] ) } ) );
-		SceneUtils.addMesh( scene, plane, 1,  hsize,     0,       0,  0,   -pi2,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[1] ) } ) );
-		SceneUtils.addMesh( scene, plane, 1,     0,  hsize,       0,  pi2,    0, pi, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[2] ) } ) );
-		SceneUtils.addMesh( scene, plane, 1,     0, -hsize,       0, -pi2,    0, pi, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[3] ) } ) );
+		THREE.SceneUtils.addMesh( scene, plane, 1,      0,     0,  -hsize,  0,      0,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[5] ) } ) );
+		THREE.SceneUtils.addMesh( scene, plane, 1, -hsize,     0,       0,  0,    pi2,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[0] ) } ) );
+		THREE.SceneUtils.addMesh( scene, plane, 1,  hsize,     0,       0,  0,   -pi2,  0, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[1] ) } ) );
+		THREE.SceneUtils.addMesh( scene, plane, 1,     0,  hsize,       0,  pi2,    0, pi, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[2] ) } ) );
+		THREE.SceneUtils.addMesh( scene, plane, 1,     0, -hsize,       0, -pi2,    0, pi, new THREE.MeshBasicMaterial( { map: new THREE.Texture( images[3] ) } ) );
 
 	},
-	
+
 	showHierarchy : function ( root, visible ) {
-		
-		SceneUtils.traverseHierarchy( root, function( node ) { node.visible = visible; } );
-		
+
+		THREE.SceneUtils.traverseHierarchy( root, function( node ) { node.visible = visible; } );
+
 	},
-	
+
 	traverseHierarchy : function ( root, callback ) {
-		
+
 		var n, i, l = root.children.length;
-		
-		for( i = 0; i < l; i++ ) {
-			
+
+		for ( i = 0; i < l; i ++ ) {
+
 			n = root.children[ i ];
-			
+
 			callback( n );
-			
+
 			SceneUtils.traverseHierarchy( n, callback );
-			
+
 		}
-		
+
 	}
 
 };
diff --git a/src/extras/ShaderUtils.js b/src/extras/ShaderUtils.js
index af1ee9c1..2b983914 100644
--- a/src/extras/ShaderUtils.js
+++ b/src/extras/ShaderUtils.js
@@ -2,392 +2,394 @@
  * @author alteredq / http://alteredqualia.com/
  * @author mr.doob / http://mrdoob.com/
  */
- 
-var ShaderUtils = {
 
-	lib: { 
-		
+THREE.ShaderUtils = {
+
+	lib: {
+
 		/* -------------------------------------------------------------------------
 		//	Fresnel shader
 		//	- based on Nvidia Cg tutorial
 		 ------------------------------------------------------------------------- */
-		
+
 		'fresnel': {
 
-		uniforms: {
+			uniforms: {
 
-		"mRefractionRatio": { type: "f", value: 1.02 },
-		"mFresnelBias": { type: "f", value: 0.1 },
-		"mFresnelPower": { type: "f", value: 2.0 },
-		"mFresnelScale": { type: "f", value: 1.0 },
-		"tCube": { type: "t", value: 1, texture: null }
+				"mRefractionRatio": { type: "f", value: 1.02 },
+				"mFresnelBias": { type: "f", value: 0.1 },
+				"mFresnelPower": { type: "f", value: 2.0 },
+				"mFresnelScale": { type: "f", value: 1.0 },
+				"tCube": { type: "t", value: 1, texture: null }
 
-		},
+			},
 
-		fragmentShader: [
+			fragmentShader: [
 
-		"uniform samplerCube tCube;",
+				"uniform samplerCube tCube;",
 
-		"varying vec3 vReflect;",
-		"varying vec3 vRefract[3];",
-		"varying float vReflectionFactor;",
+				"varying vec3 vReflect;",
+				"varying vec3 vRefract[3];",
+				"varying float vReflectionFactor;",
 
-		"void main() {",
-		
-			"vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
-			"vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );",
+				"void main() {",
 
-			"refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
-			"refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
-			"refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
-			"refractedColor.a = 1.0;",
+					"vec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );",
+					"vec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );",
 
-			"gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
-		
-		"}"
+					"refractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;",
+					"refractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;",
+					"refractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;",
+					"refractedColor.a = 1.0;",
 
-		].join("\n"),
+					"gl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );",
 
-		vertexShader: [
+				"}"
 
-		"uniform float mRefractionRatio;",
-		"uniform float mFresnelBias;",
-		"uniform float mFresnelScale;",
-		"uniform float mFresnelPower;",
+			].join("\n"),
 
-		"varying vec3 vReflect;",
-		"varying vec3 vRefract[3];",
-		"varying float vReflectionFactor;",
+			vertexShader: [
 
-		"void main() {",
-		
-			"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
-			"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+				"uniform float mRefractionRatio;",
+				"uniform float mFresnelBias;",
+				"uniform float mFresnelScale;",
+				"uniform float mFresnelPower;",
 
-			"vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );",
+				"varying vec3 vReflect;",
+				"varying vec3 vRefract[3];",
+				"varying float vReflectionFactor;",
 
-			"vec3 I = mPosition.xyz - cameraPosition;",
+				"void main() {",
 
-			"vReflect = reflect( I, nWorld );",
-			"vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );",
-			"vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );",
-			"vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );",
-			"vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );",
+					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
 
-			"gl_Position = projectionMatrix * mvPosition;",
-			
-		"}"
+					"vec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );",
 
-		].join("\n")
+					"vec3 I = mPosition.xyz - cameraPosition;",
+
+					"vReflect = reflect( I, nWorld );",
+					"vRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );",
+					"vRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );",
+					"vRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );",
+					"vReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );",
+
+					"gl_Position = projectionMatrix * mvPosition;",
+
+				"}"
+
+			].join("\n")
 
 		},
 
 		/* -------------------------------------------------------------------------
-		//	Normal map shader 
-		//		- Blinn-Phong 
+		//	Normal map shader
+		//		- Blinn-Phong
 		//		- normal + diffuse + AO + displacement maps
 		//		- 1 point and 1 directional lights
 		 ------------------------------------------------------------------------- */
-		
+
 		'normal' : {
 
-		uniforms: {
+			uniforms: {
 
-		"enableAO": { type: "i", value: 0 },
-		"enableDiffuse": { type: "i", value: 0 },
+				"enableAO": { type: "i", value: 0 },
+				"enableDiffuse": { type: "i", value: 0 },
 
-		"tDiffuse": { type: "t", value: 0, texture: null },
-		"tNormal": { type: "t", value: 2, texture: null },
-		"tAO": { type: "t", value: 3, texture: null },
+				"tDiffuse": { type: "t", value: 0, texture: null },
+				"tNormal": { type: "t", value: 2, texture: null },
+				"tAO": { type: "t", value: 3, texture: null },
 
-		"uNormalScale": { type: "f", value: 1.0 },
+				"uNormalScale": { type: "f", value: 1.0 },
 
-		"tDisplacement": { type: "t", value: 4, texture: null },
-		"uDisplacementBias": { type: "f", value: -0.5 },
-		"uDisplacementScale": { type: "f", value: 2.5 },
+				"tDisplacement": { type: "t", value: 4, texture: null },
+				"uDisplacementBias": { type: "f", value: -0.5 },
+				"uDisplacementScale": { type: "f", value: 2.5 },
 
-		"uPointLightPos": { type: "v3", value: new THREE.Vector3() },
-		"uPointLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+				"uPointLightPos": { type: "v3", value: new THREE.Vector3() },
+				"uPointLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
 
-		"uDirLightPos":	{ type: "v3", value: new THREE.Vector3() },
-		"uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+				"uDirLightPos":	{ type: "v3", value: new THREE.Vector3() },
+				"uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
 
-		"uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) },
+				"uAmbientLightColor": { type: "c", value: new THREE.Color( 0x050505 ) },
 
-		"uDiffuseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
-		"uSpecularColor": { type: "c", value: new THREE.Color( 0x111111 ) },
-		"uAmbientColor": { type: "c", value: new THREE.Color( 0x050505 ) },
-		"uShininess": { type: "f", value: 30 }
+				"uDiffuseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) },
+				"uSpecularColor": { type: "c", value: new THREE.Color( 0x111111 ) },
+				"uAmbientColor": { type: "c", value: new THREE.Color( 0x050505 ) },
+				"uShininess": { type: "f", value: 30 }
 
-		},
+			},
 
-		fragmentShader: [
+			fragmentShader: [
 
-		"uniform vec3 uDirLightPos;",
+				"uniform vec3 uDirLightPos;",
 
-		"uniform vec3 uAmbientLightColor;",
-		"uniform vec3 uDirLightColor;",
-		"uniform vec3 uPointLightColor;",
+				"uniform vec3 uAmbientLightColor;",
+				"uniform vec3 uDirLightColor;",
+				"uniform vec3 uPointLightColor;",
 
-		"uniform vec3 uAmbientColor;",
-		"uniform vec3 uDiffuseColor;",
-		"uniform vec3 uSpecularColor;",
-		"uniform float uShininess;",
+				"uniform vec3 uAmbientColor;",
+				"uniform vec3 uDiffuseColor;",
+				"uniform vec3 uSpecularColor;",
+				"uniform float uShininess;",
 
-		"uniform bool enableDiffuse;",
-		"uniform bool enableAO;",
+				"uniform bool enableDiffuse;",
+				"uniform bool enableAO;",
 
-		"uniform sampler2D tDiffuse;",
-		"uniform sampler2D tNormal;",
-		"uniform sampler2D tAO;",
+				"uniform sampler2D tDiffuse;",
+				"uniform sampler2D tNormal;",
+				"uniform sampler2D tAO;",
 
-		"uniform float uNormalScale;",
+				"uniform float uNormalScale;",
 
-		"varying vec3 vTangent;",
-		"varying vec3 vBinormal;",
-		"varying vec3 vNormal;",
-		"varying vec2 vUv;",
+				"varying vec3 vTangent;",
+				"varying vec3 vBinormal;",
+				"varying vec3 vNormal;",
+				"varying vec2 vUv;",
 
-		"varying vec3 vPointLightVector;",
-		"varying vec3 vViewPosition;",
+				"varying vec3 vPointLightVector;",
+				"varying vec3 vViewPosition;",
 
-		"void main() {",
+				"void main() {",
 
-			"vec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );",
-			"vec3 aoTex = vec3( 1.0, 1.0, 1.0 );",
+					"vec3 diffuseTex = vec3( 1.0, 1.0, 1.0 );",
+					"vec3 aoTex = vec3( 1.0, 1.0, 1.0 );",
 
-			"vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;",
-			"normalTex.xy *= uNormalScale;",
-			"normalTex = normalize( normalTex );",
+					"vec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;",
+					"normalTex.xy *= uNormalScale;",
+					"normalTex = normalize( normalTex );",
 
-			"if( enableDiffuse )",
-				"diffuseTex = texture2D( tDiffuse, vUv ).xyz;",
+					"if( enableDiffuse )",
+						"diffuseTex = texture2D( tDiffuse, vUv ).xyz;",
 
-			"if( enableAO )",
-				"aoTex = texture2D( tAO, vUv ).xyz;",
+					"if( enableAO )",
+						"aoTex = texture2D( tAO, vUv ).xyz;",
 
-			"mat3 tsb = mat3( vTangent, vBinormal, vNormal );",
-			"vec3 finalNormal = tsb * normalTex;",
+					"mat3 tsb = mat3( vTangent, vBinormal, vNormal );",
+					"vec3 finalNormal = tsb * normalTex;",
 
-			"vec3 normal = normalize( finalNormal );",
-			"vec3 viewPosition = normalize( vViewPosition );",
+					"vec3 normal = normalize( finalNormal );",
+					"vec3 viewPosition = normalize( vViewPosition );",
 
-			// point light
+					// point light
 
-			"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );",
-			"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
+					"vec4 pointDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );",
+					"vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
 
-			"vec3 pointVector = normalize( vPointLightVector );",
-			"vec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );",
+					"vec3 pointVector = normalize( vPointLightVector );",
+					"vec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );",
 
-			"float pointDotNormalHalf = dot( normal, pointHalfVector );",
-			"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
+					"float pointDotNormalHalf = dot( normal, pointHalfVector );",
+					"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 
-			"float pointSpecularWeight = 0.0;",
-			"if ( pointDotNormalHalf >= 0.0 )",
-				"pointSpecularWeight = pow( pointDotNormalHalf, uShininess );",
+					"float pointSpecularWeight = 0.0;",
+					"if ( pointDotNormalHalf >= 0.0 )",
+						"pointSpecularWeight = pow( pointDotNormalHalf, uShininess );",
 
-			"pointDiffuse  += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;",
-			"pointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;",
+					"pointDiffuse  += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;",
+					"pointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;",
 
-			// directional light
+					// directional light
 
-			"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );",
-			"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
+					"vec4 dirDiffuse  = vec4( 0.0, 0.0, 0.0, 0.0 );",
+					"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );",
 
-			"vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );",
+					"vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );",
 
-			"vec3 dirVector = normalize( lDirection.xyz );",
-			"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );",
+					"vec3 dirVector = normalize( lDirection.xyz );",
+					"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );",
 
-			"float dirDotNormalHalf = dot( normal, dirHalfVector );",
-			"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
+					"float dirDotNormalHalf = dot( normal, dirHalfVector );",
+					"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );",
 
-			"float dirSpecularWeight = 0.0;",
-			"if ( dirDotNormalHalf >= 0.0 )",
-				"dirSpecularWeight = pow( dirDotNormalHalf, uShininess );",
+					"float dirSpecularWeight = 0.0;",
+					"if ( dirDotNormalHalf >= 0.0 )",
+						"dirSpecularWeight = pow( dirDotNormalHalf, uShininess );",
 
-			"dirDiffuse  += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;",
-			"dirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;",
+					"dirDiffuse  += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;",
+					"dirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;",
 
-			// all lights contribution summation
+					// all lights contribution summation
 
-			"vec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );",
-			"totalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );",
-			"totalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );",
+					"vec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );",
+					"totalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );",
+					"totalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );",
 
-			"gl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );",
+					"gl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );",
 
-		"}"
-		].join("\n"),
+				"}"
 
-		vertexShader: [
+			].join("\n"),
 
-		"attribute vec4 tangent;",
+			vertexShader: [
 
-		"uniform vec3 uPointLightPos;",
+				"attribute vec4 tangent;",
 
-		"#ifdef VERTEX_TEXTURES",
+				"uniform vec3 uPointLightPos;",
 
-			"uniform sampler2D tDisplacement;",
-			"uniform float uDisplacementScale;",
-			"uniform float uDisplacementBias;",
+				"#ifdef VERTEX_TEXTURES",
 
-		"#endif",
+					"uniform sampler2D tDisplacement;",
+					"uniform float uDisplacementScale;",
+					"uniform float uDisplacementBias;",
 
-		"varying vec3 vTangent;",
-		"varying vec3 vBinormal;",
-		"varying vec3 vNormal;",
-		"varying vec2 vUv;",
+				"#endif",
 
-		"varying vec3 vPointLightVector;",
-		"varying vec3 vViewPosition;",
+				"varying vec3 vTangent;",
+				"varying vec3 vBinormal;",
+				"varying vec3 vNormal;",
+				"varying vec2 vUv;",
 
-		"void main() {",
+				"varying vec3 vPointLightVector;",
+				"varying vec3 vViewPosition;",
 
-			"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
-			"vViewPosition = cameraPosition - mPosition.xyz;",
+				"void main() {",
 
-			"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
-			"vNormal = normalize( normalMatrix * normal );",
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+					"vViewPosition = cameraPosition - mPosition.xyz;",
 
-			// tangent and binormal vectors
+					"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",
+					"vNormal = normalize( normalMatrix * normal );",
 
-			"vTangent = normalize( normalMatrix * tangent.xyz );",
+					// tangent and binormal vectors
 
-			"vBinormal = cross( vNormal, vTangent ) * tangent.w;",
-			"vBinormal = normalize( vBinormal );",
+					"vTangent = normalize( normalMatrix * tangent.xyz );",
 
-			"vUv = uv;",
+					"vBinormal = cross( vNormal, vTangent ) * tangent.w;",
+					"vBinormal = normalize( vBinormal );",
 
-			// point light
+					"vUv = uv;",
 
-			"vec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );",
-			"vPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
+					// point light
 
-			// displacement mapping
+					"vec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );",
+					"vPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
 
-			"#ifdef VERTEX_TEXTURES",
+					// displacement mapping
 
-				"vec3 dv = texture2D( tDisplacement, uv ).xyz;",
-				"float df = uDisplacementScale * dv.x + uDisplacementBias;",
-				"vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;",
-				"gl_Position = projectionMatrix * displacedPosition;",
+					"#ifdef VERTEX_TEXTURES",
 
-			"#else",
+						"vec3 dv = texture2D( tDisplacement, uv ).xyz;",
+						"float df = uDisplacementScale * dv.x + uDisplacementBias;",
+						"vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;",
+						"gl_Position = projectionMatrix * displacedPosition;",
 
-				"gl_Position = projectionMatrix * mvPosition;",
+					"#else",
 
-			"#endif",
+						"gl_Position = projectionMatrix * mvPosition;",
 
-		"}"
+					"#endif",
 
-		].join("\n")
+				"}"
+
+			].join("\n")
 
 		},
 
 		/* -------------------------------------------------------------------------
 		//	Cube map shader
 		 ------------------------------------------------------------------------- */
-		
+
 		'cube': {
 
-		uniforms: { "tCube": { type: "t", value: 1, texture: null } },
+			uniforms: { "tCube": { type: "t", value: 1, texture: null } },
 
-		vertexShader: [
+			vertexShader: [
 
-		"varying vec3 vViewPosition;",
+				"varying vec3 vViewPosition;",
 
-		"void main() {",
+				"void main() {",
 
-			"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
-			"vViewPosition = cameraPosition - mPosition.xyz;",
+					"vec4 mPosition = objectMatrix * vec4( position, 1.0 );",
+					"vViewPosition = cameraPosition - mPosition.xyz;",
 
-			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+					"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
 
-		"}"
+				"}"
 
-		].join("\n"),
+			].join("\n"),
 
-		fragmentShader: [
+			fragmentShader: [
 
-		"uniform samplerCube tCube;",
+				"uniform samplerCube tCube;",
 
-		"varying vec3 vViewPosition;",
+				"varying vec3 vViewPosition;",
 
-		"void main() {",
+				"void main() {",
 
-			"vec3 wPos = cameraPosition - vViewPosition;",
-			"gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );",
+					"vec3 wPos = cameraPosition - vViewPosition;",
+					"gl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );",
 
-		"}"
+				"}"
 
-		].join("\n")
+			].join("\n")
 
 		},
 
 		/* ------------------------------------------------------------------------
-		//	Convolution shader 
+		//	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: [] }
-		},
+			uniforms: {
 
-		vertexShader: [
+				"tDiffuse" : { type: "t", value: 0, texture: null },
+				"uImageIncrement" : { type: "v2", value: new THREE.Vector2( 0.001953125, 0.0 ) },
+				"cKernel" : { type: "fv1", value: [] }
 
-		"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"),
+			vertexShader: [
 
-		fragmentShader: [
+				"varying vec2 vUv;",
 
-		"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 kMaxKernelSize ) kernelSize = kMaxKernelSize;
 		halfWidth = ( kernelSize - 1 ) * 0.5
-		
+
 		values = new Array( kernelSize );
 		sum = 0.0;
-		for( i = 0; i < kernelSize; ++i ) {
-		
+		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;
-		
+
+		for ( i = 0; i < kernelSize; ++i ) values[ i ] /= sum;
+
 		return values;
 
 	}
diff --git a/src/extras/cameras/PathCamera.js b/src/extras/cameras/PathCamera.js
index e4f51924..385180e5 100644
--- a/src/extras/cameras/PathCamera.js
+++ b/src/extras/cameras/PathCamera.js
@@ -10,19 +10,19 @@
 
  *  waypoints: ,	// [ [x,y,z], [x,y,z] ... ]
  *  duration: , 	// seconds
- 
+
  *  useConstantSpeed: ,
  *  resamplingCoef: ,
- 
+
  *  createDebugPath: ,
  *  createDebugDummy: ,
- 
+
  *  lookSpeed: ,
  *  lookVertical: ,
  *  lookHorizontal: ,
  *  verticalAngleMap: { srcRange: [ ,  ], dstRange: [ ,  ] }
  *  horizontalAngleMap: { srcRange: [ ,  ], dstRange: [ ,  ] }
- 
+
  *  domElement: ,
  * }
  */
@@ -32,13 +32,13 @@ THREE.PathCamera = function ( parameters ) {
 	THREE.Camera.call( this, parameters.fov, parameters.aspect, parameters.near, parameters.far, parameters.target );
 
 	this.id = "PathCamera" + THREE.PathCameraIdCounter ++;
-	
+
 	this.duration = 10 * 1000; // milliseconds
 	this.waypoints = [];
-	
+
 	this.useConstantSpeed = true;
 	this.resamplingCoef = 50;
-	
+
 	this.debugPath = new THREE.Object3D();
 	this.debugDummy = new THREE.Object3D();
 
@@ -56,7 +56,7 @@ THREE.PathCamera = function ( parameters ) {
 
 		if ( parameters.duration !== undefined ) this.duration = parameters.duration * 1000;
 		if ( parameters.waypoints !== undefined ) this.waypoints = parameters.waypoints;
-		
+
 		if ( parameters.useConstantSpeed !== undefined ) this.useConstantSpeed = parameters.useConstantSpeed;
 		if ( parameters.resamplingCoef !== undefined ) this.resamplingCoef = parameters.resamplingCoef;
 
@@ -93,7 +93,7 @@ THREE.PathCamera = function ( parameters ) {
 	this.update = function ( parentMatrixWorld, forceUpdate, camera ) {
 
 		var srcRange, dstRange;
-		
+
 		if( this.lookHorizontal ) this.lon += this.mouseX * this.lookSpeed;
 		if( this.lookVertical )   this.lat -= this.mouseY * this.lookSpeed;
 
@@ -105,29 +105,29 @@ THREE.PathCamera = function ( parameters ) {
 
 		this.phi = normalize_angle_rad( this.phi );
 
-		// constrain vertical look angle 
-		
+		// constrain vertical look angle
+
 		srcRange = this.verticalAngleMap.srcRange;
 		dstRange = this.verticalAngleMap.dstRange;
-		
-		this.phi = map_linear( this.phi, srcRange[ 0 ], srcRange[ 1 ], 
-										 dstRange[ 0 ], dstRange[ 1 ] );
+
+		this.phi = map_linear( this.phi, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
 
 		// constrain horizontal look angle
-		
+
 		srcRange = this.horizontalAngleMap.srcRange;
 		dstRange = this.horizontalAngleMap.dstRange;
-		
-		this.theta = map_linear( this.theta, srcRange[ 0 ], srcRange[ 1 ], 
-										     dstRange[ 0 ], dstRange[ 1 ] );
-		
+
+		this.theta = map_linear( this.theta, srcRange[ 0 ], srcRange[ 1 ], dstRange[ 0 ], dstRange[ 1 ] );
+
 		var targetPosition = this.target.position,
 			position = this.position;
-/*
+
+		/*
 		targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
 		targetPosition.y = position.y + 100 * Math.cos( this.phi );
 		targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
-*/
+		*/
+
 		targetPosition.x = 100 * Math.sin( this.phi ) * Math.cos( this.theta );
 		targetPosition.y = 100 * Math.cos( this.phi );
 		targetPosition.z = 100 * Math.sin( this.phi ) * Math.sin( this.theta );
@@ -135,42 +135,42 @@ THREE.PathCamera = function ( parameters ) {
 		this.supr.update.call( this, parentMatrixWorld, forceUpdate, camera );
 
 	};
-	
+
 	this.onMouseMove = function ( event ) {
 
 		this.mouseX = event.clientX - this.windowHalfX;
 		this.mouseY = event.clientY - this.windowHalfY;
 
 	};
-	
+
 	// utils
-	
+
 	function normalize_angle_rad( a ) {
-		
+
 		var b = a % PI2;
 		return b >= 0 ? b : b + PI2;
 
 	};
-	
+
 	function cap( x, a, b ) {
-	
+
 		return ( x < a ) ? a : ( ( x > b ) ? b : x );
 
 	};
-	
+
 	function map_linear( x, sa, sb, ea, eb ) {
-		
+
 		return ( x  - sa ) * ( eb - ea ) / ( sb - sa ) + ea;
-		
+
 	};
 
 
 	function distance( a, b ) {
-	
+
 		var dx = a[ 0 ] - b[ 0 ],
 			dy = a[ 1 ] - b[ 1 ],
 			dz = a[ 2 ] - b[ 2 ];
-		
+
 		return Math.sqrt( dx * dx + dy * dy + dz * dz );
 
 	};
@@ -197,7 +197,7 @@ THREE.PathCamera = function ( parameters ) {
 
 		};
 
-		var i, 
+		var i,
 			parentAnimation, childAnimation,
 			path = spline.getControlPointsArray(),
 			sl = spline.getLength(),
@@ -205,23 +205,23 @@ THREE.PathCamera = function ( parameters ) {
 			t = 0,
 			first = 0,
 			last  = pl - 1;
-		
+
 		parentAnimation = { parent: -1, keys: [] };
 		parentAnimation.keys[ first ] = { time: 0,        pos: path[ first ], rot: [ 0, 0, 0, 1 ], scl: [ 1, 1, 1 ] };
 		parentAnimation.keys[ last  ] = { time: duration, pos: path[ last ],  rot: [ 0, 0, 0, 1 ], scl: [ 1, 1, 1 ] };
-		
+
 		for ( i = 1; i < pl - 1; i++ ) {
 
 			// real distance (approximation via linear segments)
-			
+
 			t = duration * sl.chunks[ i ] / sl.total;
-			
+
 			// equal distance
-			
-			//t = duration * ( i / pl );			
-			
+
+			//t = duration * ( i / pl );
+
 			// linear distance
-			
+
 			//t += duration * distance( path[ i ], path[ i - 1 ] ) / sl.total;
 
 			parentAnimation.keys[ i ] = { time: t, pos: path[ i ] };
@@ -231,28 +231,28 @@ THREE.PathCamera = function ( parameters ) {
 		animationData.hierarchy[ 0 ] = parentAnimation;
 
 		THREE.AnimationHandler.add( animationData );
-		
+
 		return new THREE.Animation( parent, name, THREE.AnimationHandler.CATMULLROM_FORWARD, false );
 
 	};
 
 
 	function createSplineGeometry( spline, n_sub ) {
-	
+
 		var i, index, position,
 			geometry = new THREE.Geometry();
-		
+
 		for ( i = 0; i < spline.points.length * n_sub; i ++ ) {
-		
+
 			index = i / ( spline.points.length * n_sub );
 			position = spline.getPoint( index );
-			
+
 			geometry.vertices[ i ] = new THREE.Vertex( new THREE.Vector3( position.x, position.y, position.z ) );
 
 		}
-		
+
 		return geometry;
-	
+
 	};
 
 	function createPath( parent, spline ) {
@@ -262,57 +262,57 @@ THREE.PathCamera = function ( parameters ) {
 			lineMat = new THREE.LineBasicMaterial( { color: 0xff0000, linewidth: 3 } );
 			lineObj = new THREE.Line( lineGeo, lineMat );
 			particleObj = new THREE.ParticleSystem( particleGeo, new THREE.ParticleBasicMaterial( { color: 0xffaa00, size: 3 } ) );
-			
+
 		lineObj.scale.set( 1, 1, 1 );
 		parent.addChild( lineObj );
 
 		particleObj.scale.set( 1, 1, 1 );
 		parent.addChild( particleObj );
-			
+
 		var waypoint,
 			geo = new Sphere( 1, 16, 8 ),
 			mat = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
-		
-		for( i = 0; i < spline.points.length; i++ ) {
-			
+
+		for ( i = 0; i < spline.points.length; i++ ) {
+
 			waypoint = new THREE.Mesh( geo, mat );
 			waypoint.position.copy( spline.points[ i ] );
 			waypoint.updateMatrix();
 			parent.addChild( waypoint );
-			
+
 		}
 
 	};
 
 	// constructor
-	
+
 	this.spline = new THREE.Spline();
 	this.spline.initFromArray( this.waypoints );
 
 	if ( this.useConstantSpeed ) {
-		
+
 		this.spline.reparametrizeByArcLength( this.resamplingCoef );
 
 	}
-	
+
 	if ( this.createDebugDummy ) {
 
 		var dummyParentMaterial = new THREE.MeshLambertMaterial( { color: 0x0077ff } ),
 		dummyChildMaterial  = new THREE.MeshLambertMaterial( { color: 0x00ff00 } ),
-		dummyParentGeo = new Cube( 10, 10, 20 ),
-		dummyChildGeo  = new Cube( 2, 2, 10 );
+		dummyParentGeo = new THREE.Cube( 10, 10, 20 ),
+		dummyChildGeo  = new THREE.Cube( 2, 2, 10 );
 
 		this.animationParent = new THREE.Mesh( dummyParentGeo, dummyParentMaterial );
 
 		var dummyChild = new THREE.Mesh( dummyChildGeo, dummyChildMaterial );
 		dummyChild.position.set( 0, 10, 0 );
-		
+
 		this.animation = initAnimationPath( this.animationParent, this.spline, this.id, this.duration );
 
 		this.animationParent.addChild( this );
 		this.animationParent.addChild( this.target );
 		this.animationParent.addChild( dummyChild );
-		
+
 	} else {
 
 		this.animation = initAnimationPath( this.animationParent, this.spline, this.id, this.duration );
@@ -322,17 +322,17 @@ THREE.PathCamera = function ( parameters ) {
 	}
 
 	if ( this.createDebugPath ) {
-		
+
 		createPath( this.debugPath, this.spline );
 
 	}
 
-	this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );	
-	
+	this.domElement.addEventListener( 'mousemove', bind( this, this.onMouseMove ), false );
+
 };
 
 THREE.PathCamera.prototype = new THREE.Camera();
 THREE.PathCamera.prototype.constructor = THREE.PathCamera;
 THREE.PathCamera.prototype.supr = THREE.Camera.prototype;
 
-THREE.PathCameraIdCounter = 0;
\ No newline at end of file
+THREE.PathCameraIdCounter = 0;
diff --git a/src/extras/cameras/QuakeCamera.js b/src/extras/cameras/QuakeCamera.js
index 08b3e785..9d9a319d 100644
--- a/src/extras/cameras/QuakeCamera.js
+++ b/src/extras/cameras/QuakeCamera.js
@@ -20,7 +20,7 @@
  *  constrainVertical: ,
  *  verticalMin: ,
  *  verticalMax: ,
- 
+
  *  heightSpeed: ,
  *  heightCoef: ,
  *  heightMin: ,
@@ -50,7 +50,7 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.constrainVertical = false;
 	this.verticalMin = 0;
 	this.verticalMax = 3.14;
-	
+
 	this.domElement = document;
 
 	if ( parameters ) {
@@ -68,7 +68,7 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( parameters.heightCoef !== undefined ) this.heightCoef = parameters.heightCoef;
 		if ( parameters.heightMin !== undefined ) this.heightMin = parameters.heightMin;
 		if ( parameters.heightMax !== undefined ) this.heightMax = parameters.heightMax;
-		
+
 		if ( parameters.constrainVertical !== undefined ) this.constrainVertical = parameters.constrainVertical;
 		if ( parameters.verticalMin !== undefined ) this.verticalMin = parameters.verticalMin;
 		if ( parameters.verticalMax !== undefined ) this.verticalMax = parameters.verticalMax;
@@ -160,7 +160,7 @@ THREE.QuakeCamera = function ( parameters ) {
 
 			case 39: /*right*/
 			case 68: /*D*/ this.moveRight = true; break;
-			
+
 			case 81: this.freeze = !this.freeze; break;
 
 		}
@@ -190,44 +190,44 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.update = function() {
 
 		if ( !this.freeze ) {
-			
+
 
 			if ( this.heightSpeed ) {
-	
+
 				var y = clamp( this.position.y, this.heightMin, this.heightMax ),
 					delta = y - this.heightMin;
-	
+
 				this.autoSpeedFactor = delta * this.heightCoef;
-	
+
 			} else {
-	
+
 				this.autoSpeedFactor = 0.0;
-	
+
 			}
-	
+
 			if ( this.moveForward || this.autoForward ) this.translateZ( - ( this.movementSpeed + this.autoSpeedFactor ) );
 			if ( this.moveBackward ) this.translateZ( this.movementSpeed );
 			if ( this.moveLeft ) this.translateX( - this.movementSpeed );
 			if ( this.moveRight ) this.translateX( this.movementSpeed );
-	
+
 			var actualLookSpeed = this.lookSpeed;
-	
+
 			if ( !this.activeLook ) {
-	
+
 				actualLookSpeed = 0;
-	
+
 			}
-	
+
 			this.lon += this.mouseX * actualLookSpeed;
 			if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed;
-	
+
 			this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
 			this.phi = ( 90 - this.lat ) * Math.PI / 180;
 			this.theta = this.lon * Math.PI / 180;
-	
+
 			var targetPosition = this.target.position,
 				position = this.position;
-	
+
 			targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
 			targetPosition.y = position.y + 100 * Math.cos( this.phi );
 			targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
@@ -243,9 +243,9 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( this.constrainVertical ) {
 
 			this.phi = map_linear( this.phi, 0, 3.14, this.verticalMin, this.verticalMax );
-			
+
 		}
-		
+
 		var targetPosition = this.target.position,
 			position = this.position;
 
@@ -277,11 +277,11 @@ THREE.QuakeCamera = function ( parameters ) {
 	};
 
 	function map_linear( x, sa, sb, ea, eb ) {
-		
+
 		return ( x  - sa ) * ( eb - ea ) / ( sb - sa ) + ea;
-		
+
 	};
-	
+
 	function clamp_bottom( x, a ) {
 
 		return x < a ? a : x;
diff --git a/src/extras/geometries/Cube.js b/src/extras/geometries/Cube.js
index 622835ea..121de59c 100644
--- a/src/extras/geometries/Cube.js
+++ b/src/extras/geometries/Cube.js
@@ -3,10 +3,10 @@
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as
  */
 
-var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, flipped, sides ) {
+THREE.Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, flipped, sides ) {
 
 	THREE.Geometry.call( this );
-	
+
 	var scope = this,
 	width_half = width / 2,
 	height_half = height / 2,
@@ -106,7 +106,7 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segme
 			}
 
 		}
-		
+
 		for( iy = 0; iy < gridY; iy++ ) {
 
 			for( ix = 0; ix < gridX; ix++ ) {
@@ -182,5 +182,5 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segme
 
 };
 
-Cube.prototype = new THREE.Geometry();
-Cube.prototype.constructor = Cube;
+THREE.Cube.prototype = new THREE.Geometry();
+THREE.Cube.prototype.constructor = THREE.Cube;
diff --git a/src/extras/geometries/Cylinder.js b/src/extras/geometries/Cylinder.js
index 5d6a1c8f..e6930dcb 100644
--- a/src/extras/geometries/Cylinder.js
+++ b/src/extras/geometries/Cylinder.js
@@ -4,7 +4,7 @@
  * @author fuzzthink
  */
 
-var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) {
+THREE.Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) {
 
 	THREE.Geometry.call( this );
 
@@ -119,5 +119,5 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 };
 
-Cylinder.prototype = new THREE.Geometry();
-Cylinder.prototype.constructor = Cylinder;
+THREE.Cylinder.prototype = new THREE.Geometry();
+THREE.Cylinder.prototype.constructor = THREE.Cylinder;
diff --git a/src/extras/geometries/Icosahedron.js b/src/extras/geometries/Icosahedron.js
index bb90dd16..3abf1940 100644
--- a/src/extras/geometries/Icosahedron.js
+++ b/src/extras/geometries/Icosahedron.js
@@ -6,7 +6,7 @@
  * so it draws the entire texture on the seam-faces, I think...
  */
 
-var Icosahedron = function ( subdivisions ) {
+THREE.Icosahedron = function ( subdivisions ) {
 
 	var scope = this;
 	var tempScope = new THREE.Geometry();
@@ -173,5 +173,5 @@ var Icosahedron = function ( subdivisions ) {
 
 }
 
-Icosahedron.prototype = new THREE.Geometry();
-Icosahedron.prototype.constructor = Icosahedron;
+THREE.Icosahedron.prototype = new THREE.Geometry();
+THREE.Icosahedron.prototype.constructor = THREE.Icosahedron;
diff --git a/src/extras/geometries/Lathe.js b/src/extras/geometries/Lathe.js
index 4e950f24..f2bb47cc 100644
--- a/src/extras/geometries/Lathe.js
+++ b/src/extras/geometries/Lathe.js
@@ -2,7 +2,7 @@
  * @author astrodud / http://astrodud.isgreat.org/
  */
 
-function Lathe( points, steps, angle ) {
+THREE.Lathe = function ( points, steps, angle ) {
 
 	THREE.Geometry.call( this );
 
@@ -67,5 +67,5 @@ function Lathe( points, steps, angle ) {
 
 };
 
-Lathe.prototype = new THREE.Geometry();
-Lathe.prototype.constructor = Lathe;
+THREE.Lathe.prototype = new THREE.Geometry();
+THREE.Lathe.prototype.constructor = THREE.Lathe;
diff --git a/src/extras/geometries/Plane.js b/src/extras/geometries/Plane.js
index 433341fb..17cc4687 100644
--- a/src/extras/geometries/Plane.js
+++ b/src/extras/geometries/Plane.js
@@ -3,7 +3,7 @@
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as
  */
 
-var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
+THREE.Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
 
 	THREE.Geometry.call( this );
 
@@ -30,7 +30,7 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
 		}
 
 	}
-	
+
 	for( iy = 0; iy < gridY; iy++ ) {
 
 		for( ix = 0; ix < gridX; ix++ ) {
@@ -57,5 +57,5 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
 
 };
 
-Plane.prototype = new THREE.Geometry();
-Plane.prototype.constructor = Plane;
+THREE.Plane.prototype = new THREE.Geometry();
+THREE.Plane.prototype.constructor = THREE.Plane;
diff --git a/src/extras/geometries/Sphere.js b/src/extras/geometries/Sphere.js
index cf25cb04..f9e6bc60 100644
--- a/src/extras/geometries/Sphere.js
+++ b/src/extras/geometries/Sphere.js
@@ -3,7 +3,7 @@
  * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Sphere.as
  */
 
-var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
+THREE.Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 	THREE.Geometry.call( this );
 
@@ -111,5 +111,5 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 };
 
-Sphere.prototype = new THREE.Geometry();
-Sphere.prototype.constructor = Sphere;
+THREE.Sphere.prototype = new THREE.Geometry();
+THREE.Sphere.prototype.constructor = THREE.Sphere;
diff --git a/src/extras/geometries/Torus.js b/src/extras/geometries/Torus.js
index a4bb2e1b..926aadc9 100644
--- a/src/extras/geometries/Torus.js
+++ b/src/extras/geometries/Torus.js
@@ -3,7 +3,9 @@
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888
  */
 
-var Torus = function ( radius, tube, segmentsR, segmentsT ) {
+THREE.Torus = function ( radius, tube, segmentsR, segmentsT ) {
+
+	THREE.Geometry.call( this );
 
 	var scope = this;
 
@@ -13,8 +15,6 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 	this.segmentsT = segmentsT || 6;
 
 	var temp_uv = [];
-	
-	THREE.Geometry.call( this );
 
 	for ( var j = 0; j <= this.segmentsR; ++j ) {
 
@@ -74,5 +74,5 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 
 };
 
-Torus.prototype = new THREE.Geometry();
-Torus.prototype.constructor = Torus;
+THREE.Torus.prototype = new THREE.Geometry();
+THREE.Torus.prototype.constructor = THREE.Torus;
diff --git a/src/extras/geometries/TorusKnot.js b/src/extras/geometries/TorusKnot.js
index 8f4090df..1475a9e2 100644
--- a/src/extras/geometries/TorusKnot.js
+++ b/src/extras/geometries/TorusKnot.js
@@ -3,10 +3,11 @@
  * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  */
 
-var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) {
+THREE.TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) {
+
+	THREE.Geometry.call( this );
 
 	var scope = this;
-	THREE.Geometry.call( this );
 
 	this.radius = radius || 200;
 	this.tube = tube || 40;
@@ -103,5 +104,5 @@ var TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale
 
 };
 
-TorusKnot.prototype = new THREE.Geometry();
-TorusKnot.prototype.constructor = TorusKnot;
+THREE.TorusKnot.prototype = new THREE.Geometry();
+THREE.TorusKnot.prototype.constructor = THREE.TorusKnot;
diff --git a/src/extras/io/BinaryLoader.js b/src/extras/io/BinaryLoader.js
index c5112324..fe4597ea 100644
--- a/src/extras/io/BinaryLoader.js
+++ b/src/extras/io/BinaryLoader.js
@@ -5,7 +5,7 @@
 THREE.BinaryLoader = function ( showStatus ) {
 
 	THREE.Loader.call( this, showStatus );
-	
+
 };
 
 THREE.BinaryLoader.prototype = new THREE.Loader();
@@ -24,21 +24,21 @@ THREE.BinaryLoader.prototype = {
 	//		- texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
 
 	load: function( parameters ) {
-	
+
 		// #1 load JS part via web worker
 
 		//  This isn't really necessary, JS part is tiny,
 		//  could be done by more ordinary means.
 
 		var url = parameters.model,
-			callback = parameters.callback, 
+			callback = parameters.callback,
 		    texture_path = parameters.texture_path ? parameters.texture_path : THREE.Loader.prototype.extractUrlbase( url ),
 			bin_path = parameters.bin_path ? parameters.bin_path : THREE.Loader.prototype.extractUrlbase( url ),
 
 			s = (new Date).getTime(),
 			worker = new Worker( url ),
 			callback_progress = this.showProgress ? THREE.Loader.prototype.updateProgress : null;
-		
+
 		worker.onmessage = function( event ) {
 
 			var materials = event.data.materials,
@@ -47,8 +47,8 @@ THREE.BinaryLoader.prototype = {
 			// #2 load BIN part via Ajax
 
 			//  For some reason it is faster doing loading from here than from within the worker.
-			//  Maybe passing of ginormous string as message between threads is costly? 
-			//  Also, worker loading huge data by Ajax still freezes browser. Go figure, 
+			//  Maybe passing of ginormous string as message between threads is costly?
+			//  Also, worker loading huge data by Ajax still freezes browser. Go figure,
 			//  worker with baked ascii JSON data keeps browser more responsive.
 
 			THREE.BinaryLoader.prototype.loadAjaxBuffers( buffers, materials, callback, bin_path, texture_path, callback_progress );
@@ -79,9 +79,9 @@ THREE.BinaryLoader.prototype = {
 			url = bin_path + "/" + buffers;
 
 		var length = 0;
-		
+
 		xhr.onreadystatechange = function() {
-			
+
 			if ( xhr.readyState == 4 ) {
 
 				if ( xhr.status == 200 || xhr.status == 0 ) {
@@ -93,27 +93,27 @@ THREE.BinaryLoader.prototype = {
 					alert( "Couldn't load [" + url + "] [" + xhr.status + "]" );
 
 				}
-						
+
 			} else if ( xhr.readyState == 3 ) {
-				
+
 				if ( callback_progress ) {
-				
+
 					if ( length == 0 ) {
-						
+
 						length = xhr.getResponseHeader( "Content-Length" );
-						
+
 					}
-					
+
 					callback_progress( { total: length, loaded: xhr.responseText.length } );
-					
+
 				}
-				
+
 			} else if ( xhr.readyState == 2 ) {
-				
+
 				length = xhr.getResponseHeader( "Content-Length" );
-				
+
 			}
-			
+
 		}
 
 		xhr.open("GET", url, true);
@@ -130,7 +130,7 @@ THREE.BinaryLoader.prototype = {
 			//var s = (new Date).getTime();
 
 			var scope = this,
-				currentOffset = 0, 
+				currentOffset = 0,
 				md,
 				normals = [],
 				uvs = [],
@@ -152,14 +152,14 @@ THREE.BinaryLoader.prototype = {
 			currentOffset += md.header_bytes;
 
 			// cache offsets
-			
-			tri_b   = md.vertex_index_bytes, 
-			tri_c   = md.vertex_index_bytes*2, 
+
+			tri_b   = md.vertex_index_bytes,
+			tri_c   = md.vertex_index_bytes*2,
 			tri_m   = md.vertex_index_bytes*3,
 			tri_na  = md.vertex_index_bytes*3 + md.material_index_bytes,
 			tri_nb  = md.vertex_index_bytes*3 + md.material_index_bytes + md.normal_index_bytes,
 			tri_nc  = md.vertex_index_bytes*3 + md.material_index_bytes + md.normal_index_bytes*2,
-		
+
 			quad_b  = md.vertex_index_bytes,
 			quad_c  = md.vertex_index_bytes*2,
 			quad_d  = md.vertex_index_bytes*3,
@@ -168,16 +168,16 @@ THREE.BinaryLoader.prototype = {
 			quad_nb = md.vertex_index_bytes*4 + md.material_index_bytes + md.normal_index_bytes,
 			quad_nc = md.vertex_index_bytes*4 + md.material_index_bytes + md.normal_index_bytes*2,
 			quad_nd = md.vertex_index_bytes*4 + md.material_index_bytes + md.normal_index_bytes*3,
-		
+
 			tri_uvb = md.uv_index_bytes,
 			tri_uvc = md.uv_index_bytes * 2,
-		
+
 			quad_uvb = md.uv_index_bytes,
 			quad_uvc = md.uv_index_bytes * 2,
 			quad_uvd = md.uv_index_bytes * 3;
-			
+
 			// buffers sizes
-			
+
 			tri_size =  md.vertex_index_bytes * 3 + md.material_index_bytes;
 			quad_size = md.vertex_index_bytes * 4 + md.material_index_bytes;
 
@@ -190,18 +190,18 @@ THREE.BinaryLoader.prototype = {
 			len_quad_smooth    = md.nquad_smooth    * ( quad_size + md.normal_index_bytes * 4 );
 			len_quad_flat_uv   = md.nquad_flat_uv   * ( quad_size + md.uv_index_bytes * 4 );
 			len_quad_smooth_uv = md.nquad_smooth_uv * ( quad_size + md.normal_index_bytes * 4 + md.uv_index_bytes * 4 );
-			
+
 			// read buffers
-			
+
 			currentOffset += init_vertices( currentOffset );
 			currentOffset += init_normals( currentOffset );
 			currentOffset += init_uvs( currentOffset );
 
-			start_tri_flat 		= currentOffset; 
+			start_tri_flat 		= currentOffset;
 			start_tri_smooth    = start_tri_flat    + len_tri_flat;
 			start_tri_flat_uv   = start_tri_smooth  + len_tri_smooth;
 			start_tri_smooth_uv = start_tri_flat_uv + len_tri_flat_uv;
-			
+
 			start_quad_flat     = start_tri_smooth_uv + len_tri_smooth_uv;
 			start_quad_smooth   = start_quad_flat     + len_quad_flat;
 			start_quad_flat_uv  = start_quad_smooth   + len_quad_smooth;
@@ -209,7 +209,7 @@ THREE.BinaryLoader.prototype = {
 
 			// have to first process faces with uvs
 			// so that face and uv indices match
-			
+
 			init_triangles_flat_uv( start_tri_flat_uv );
 			init_triangles_smooth_uv( start_tri_smooth_uv );
 
@@ -217,7 +217,7 @@ THREE.BinaryLoader.prototype = {
 			init_quads_smooth_uv( start_quad_smooth_uv );
 
 			// now we can process untextured faces
-			
+
 			init_triangles_flat( start_tri_flat );
 			init_triangles_smooth( start_tri_smooth );
 
@@ -366,7 +366,7 @@ THREE.BinaryLoader.prototype = {
 
 			function init_vertices( start ) {
 
-				var i, x, y, z, 
+				var i, x, y, z,
 					stride = md.vertex_coordinate_bytes * 3,
 					end = start + md.nvertices * stride;
 
@@ -386,7 +386,7 @@ THREE.BinaryLoader.prototype = {
 
 			function init_normals( start ) {
 
-				var i, x, y, z, 
+				var i, x, y, z,
 					stride = md.normal_coordinate_bytes * 3,
 					end = start + md.nnormals * stride;
 
@@ -406,7 +406,7 @@ THREE.BinaryLoader.prototype = {
 
 			function init_uvs( start ) {
 
-				var i, u, v, 
+				var i, u, v,
 					stride = md.uv_coordinate_bytes * 2,
 					end = start + md.nuvs * stride;
 
@@ -418,11 +418,11 @@ THREE.BinaryLoader.prototype = {
 					uvs.push( u, v );
 
 				}
-				
+
 				return md.nuvs * stride;
 
-			}			
-			
+			}
+
 			function add_tri( i ) {
 
 				var a, b, c, m;
@@ -648,7 +648,7 @@ THREE.BinaryLoader.prototype = {
 
 			function init_quads_smooth_uv( start ) {
 
-				var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4, 
+				var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4,
 					stride =  offset + md.uv_index_bytes * 4,
 					end = start + md.nquad_smooth_uv * stride;
 
@@ -678,7 +678,7 @@ THREE.BinaryLoader.prototype = {
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
 
 	},
-	
+
 	f3: function( scope, a, b, c, mi ) {
 
 		var material = scope.materials[ mi ];
@@ -708,9 +708,9 @@ THREE.BinaryLoader.prototype = {
 			ncy = normals[ nc*3 + 1 ],
 			ncz = normals[ nc*3 + 2 ];
 
-		scope.faces.push( new THREE.Face3( a, b, c, 
-						  [new THREE.Vector3( nax, nay, naz ), 
-						   new THREE.Vector3( nbx, nby, nbz ), 
+		scope.faces.push( new THREE.Face3( a, b, c,
+						  [new THREE.Vector3( nax, nay, naz ),
+						   new THREE.Vector3( nbx, nby, nbz ),
 						   new THREE.Vector3( ncx, ncy, ncz )],
 						  null,
 						  material ) );
@@ -737,9 +737,9 @@ THREE.BinaryLoader.prototype = {
 			ndz = normals[ nd*3 + 2 ];
 
 		scope.faces.push( new THREE.Face4( a, b, c, d,
-						  [new THREE.Vector3( nax, nay, naz ), 
-						   new THREE.Vector3( nbx, nby, nbz ), 
-						   new THREE.Vector3( ncx, ncy, ncz ), 
+						  [new THREE.Vector3( nax, nay, naz ),
+						   new THREE.Vector3( nbx, nby, nbz ),
+						   new THREE.Vector3( ncx, ncy, ncz ),
 						   new THREE.Vector3( ndx, ndy, ndz )],
 						  null,
 						  material ) );
@@ -767,4 +767,4 @@ THREE.BinaryLoader.prototype = {
 
 	}
 
-};	
\ No newline at end of file
+};
diff --git a/src/extras/io/JSONLoader.js b/src/extras/io/JSONLoader.js
index f0094999..b36f5af2 100644
--- a/src/extras/io/JSONLoader.js
+++ b/src/extras/io/JSONLoader.js
@@ -77,9 +77,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 		var i, j, fi,
 
 		offset, zLength, nVertices,
-		
+
 		colorIndex, normalIndex, uvIndex, materialIndex,
-		
+
 		type,
 		isQuad, 
 		hasMaterial, 
@@ -88,7 +88,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 		hasFaceColor, hasFaceVertexColor,
 
 		vertex, face, color, normal,
-		
+
 		uvLayer, uvs, u, v,
 
 		faces = json.faces,
@@ -97,7 +97,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 		colors = json.colors,
 
 		scale = ( json.scale !== undefined ) ? json.scale : 1.0,
-		
+
 		nUvLayers = 0;
 
 		// disregard empty arrays
@@ -293,7 +293,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 		if ( json.skinWeights ) {
 
-			for( i = 0, l = json.skinWeights.length; i < l; i += 2 ) {
+			for ( i = 0, l = json.skinWeights.length; i < l; i += 2 ) {
 
 				x = json.skinWeights[ i     ];
 				y = json.skinWeights[ i + 1 ];
@@ -308,7 +308,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 		if ( json.skinIndices ) {
 
-			for( i = 0, l = json.skinIndices.length; i < l; i += 2 ) {
+			for ( i = 0, l = json.skinIndices.length; i < l; i += 2 ) {
 
 				a = json.skinIndices[ i     ];
 				b = json.skinIndices[ i + 1 ];
@@ -328,11 +328,11 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 	function init_morphing() {
 
-		if( json.morphTargets !== undefined ) {
+		if ( json.morphTargets !== undefined ) {
 
 			var i, l, v, vl, dstVertices, srcVertices;
 
-			for( i = 0, l = json.morphTargets.length; i < l; i++ ) {
+			for ( i = 0, l = json.morphTargets.length; i < l; i++ ) {
 
 				geometry.morphTargets[ i ] = {};
 				geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
@@ -350,12 +350,12 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 			} 
 
 		}
-		
-		if( json.morphColors !== undefined ) {
+
+		if ( json.morphColors !== undefined ) {
 
 			var i, l, c, cl, dstColors, srcColors, color;
 
-			for( i = 0, l = json.morphColors.length; i < l; i++ ) {
+			for ( i = 0, l = json.morphColors.length; i < l; i++ ) {
 
 				geometry.morphColors[ i ] = {};
 				geometry.morphColors[ i ].name = json.morphColors[ i ].name;
@@ -364,7 +364,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 				dstColors = geometry.morphColors[ i ].colors;
 				srcColors = json.morphColors [ i ].colors;
 
-				for( c = 0, cl = srcColors.length; c < cl; c += 3 ) {
+				for ( c = 0, cl = srcColors.length; c < cl; c += 3 ) {
 
 					color = new THREE.Color( 0xffaa00 );
 					color.setRGB( srcColors[ v ], srcColors[ v + 1 ], srcColors[ v + 2 ] );
diff --git a/src/extras/io/SceneLoader.js b/src/extras/io/SceneLoader.js
index 71c3f976..041c375f 100644
--- a/src/extras/io/SceneLoader.js
+++ b/src/extras/io/SceneLoader.js
@@ -2,18 +2,18 @@
  * @author alteredq / http://alteredqualia.com/
  */
 
-THREE.SceneLoader = function ( ) {
+THREE.SceneLoader = function () {
 };
 
 THREE.SceneLoader.prototype = {
 
-	load : function( url, callback_sync, callback_async, callback_progress ) {
+	load : function ( url, callback_sync, callback_async, callback_progress ) {
 
 		var worker = new Worker( url );
 		worker.postMessage( 0 );
 
 		var urlBase = THREE.Loader.prototype.extractUrlbase( url );
-		
+
 		worker.onmessage = function( event ) {
 
 			var dg, dm, dd, dl, dc, df, dt,
@@ -66,21 +66,21 @@ THREE.SceneLoader.prototype = {
 					result.scene.updateMatrix();
 
 			}
-			
+
 			function get_url( source_url, url_type ) {
-				
+
 				if ( url_type == "relativeToHTML" ) {
-					
+
 					return source_url;
-					
+
 				} else {
-					
+
 					return urlBase + "/" + source_url;
 
 				}
 
 			};
-			
+
 			function handle_objects() {
 
 				for( dd in data.objects ) {
@@ -144,7 +144,7 @@ THREE.SceneLoader.prototype = {
 							}
 
 						}
-						
+
 
 					}
 
@@ -232,14 +232,14 @@ THREE.SceneLoader.prototype = {
 			// lights
 
 			var hex, intensity;
-			
-			for( dl in data.lights ) {
+
+			for ( dl in data.lights ) {
 
 				l = data.lights[ dl ];
 
 				hex = ( l.color !== undefined ) ? l.color : 0xffffff;
 				intensity = ( l.intensity !== undefined ) ? l.intensity : 1;
-				
+
 				if ( l.type == "directional" ) {
 
 					p = l.direction;
@@ -325,39 +325,39 @@ THREE.SceneLoader.prototype = {
 			}
 
 			total_models = counter_models;
-			
-			for( dg in data.geometries ) {
+
+			for ( dg in data.geometries ) {
 
 				g = data.geometries[ dg ];
 
 				if ( g.type == "cube" ) {
 
-					geometry = new Cube( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides );
+					geometry = new THREE.Cube( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "plane" ) {
 
-					geometry = new Plane( g.width, g.height, g.segmentsWidth, g.segmentsHeight );
+					geometry = new THREE.Plane( g.width, g.height, g.segmentsWidth, g.segmentsHeight );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "sphere" ) {
 
-					geometry = new Sphere( g.radius, g.segmentsWidth, g.segmentsHeight );
+					geometry = new THREE.Sphere( g.radius, g.segmentsWidth, g.segmentsHeight );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "cylinder" ) {
 
-					geometry = new Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
+					geometry = new THREE.Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "torus" ) {
 
-					geometry = new Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
+					geometry = new THREE.Torus( g.radius, g.tube, g.segmentsR, g.segmentsT );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "icosahedron" ) {
 
-					geometry = new Icosahedron( g.subdivisions );
+					geometry = new THREE.Icosahedron( g.subdivisions );
 					result.geometries[ dg ] = geometry;
 
 				} else if ( g.type == "bin_mesh" ) {
@@ -407,22 +407,22 @@ THREE.SceneLoader.prototype = {
 					tt.mapping = new THREE[ tt.mapping ]();
 
 				}
-				
+
 				if( tt.url instanceof Array ) {
-				
+
 					var url_array = [];
-					
+
 					for( var i = 0; i < tt.url.length; i ++ ) {
-					
+
 						url_array[ i ] = get_url( tt.url[ i ], data.urlBaseType );
-						
+
 					}
-					
-					texture = ImageUtils.loadTextureCube( url_array, tt.mapping, callback_texture );
+
+					texture = THREE.ImageUtils.loadTextureCube( url_array, tt.mapping, callback_texture );
 
 				} else {
-					
-					texture = ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callback_texture );
+
+					texture = THREE.ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callback_texture );
 
 					if ( THREE[ tt.minFilter ] != undefined )
 						texture.minFilter = THREE[ tt.minFilter ];
@@ -438,11 +438,11 @@ THREE.SceneLoader.prototype = {
 
 			// materials
 
-			for( dm in data.materials ) {
+			for ( dm in data.materials ) {
 
 				m = data.materials[ dm ];
 
-				for( pp in m.parameters ) {
+				for ( pp in m.parameters ) {
 
 					if ( pp == "envMap" || pp == "map" || pp == "lightMap" ) {
 
diff --git a/src/extras/objects/MarchingCubes.js b/src/extras/objects/MarchingCubes.js
index a229ab84..f7942a6b 100644
--- a/src/extras/objects/MarchingCubes.js
+++ b/src/extras/objects/MarchingCubes.js
@@ -7,39 +7,31 @@
 
 // do not crash if somebody includes the file in oldie browser
 
-if ( !window.Int32Array ) {
-  
-	window.Int32Array = Array;
-	window.Float32Array = Array;
-
-}
-
-
 THREE.MarchingCubes = function ( resolution, materials ) {
 
 	THREE.Object3D.call( this );
 
-	this.materials = materials instanceof Array ? materials : [ materials ];	
+	this.materials = materials instanceof Array ? materials : [ materials ];
 
 	// functions have to be object properties
 	// prototype functions kill performance
 	// (tested and it was 4x slower !!!)
-	
+
 	this.init = function( resolution ) {
-	
+
 		// parameters
-		
+
 		this.isolation = 80.0;
-		
+
 		// size of field, 32 is pushing it in Javascript :)
-		
+
 		this.size = resolution;
 		this.size2 = this.size * this.size;
 		this.size3 = this.size2 * this.size;
 		this.halfsize = this.size / 2.0;
-		
+
 		// deltas
-		
+
 		this.delta = 2.0 / this.size;
 		this.yd = this.size;
 		this.zd = this.size2;
@@ -48,98 +40,98 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 		this.normal_cache = new Float32Array( this.size3 * 3 );
 
 		// temp buffers used in polygonize
-		
+
 		this.vlist = new Float32Array( 12 * 3 );
 		this.nlist = new Float32Array( 12 * 3 );
-		
+
 		this.firstDraw = true;
-		
+
 		// immediate render mode simulator
-		
+
 		this.maxCount = 4096; // TODO: find the fastest size for this buffer
 		this.count = 0;
 		this.hasPos = false;
 		this.hasNormal = false;
-		
+
 		this.positionArray = new Float32Array( this.maxCount * 3 );
 		this.normalArray   = new Float32Array( this.maxCount * 3 );		
-		
+
 	};
 
 	///////////////////////
 	// Polygonization
 	///////////////////////
-	
+
 	this.lerp = function( a, b, t ) { return a + ( b - a ) * t; };
 
 	this.VIntX = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
 
 		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
 		nc = this.normal_cache;
-		
+
 		pout[ offset ] 	   = x + mu * this.delta;
 		pout[ offset + 1 ] = y;
 		pout[ offset + 2 ] = z;
-		
+
 		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q + 3 ], mu );
 		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q + 4 ], mu );
 		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q + 5 ], mu );
-		
+
 	};
 
 	this.VIntY = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
-		
+
 		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
 		nc = this.normal_cache;
-		
+
 		pout[ offset ] 	   = x;
 		pout[ offset + 1 ] = y + mu * this.delta;
 		pout[ offset + 2 ] = z;
-		
+
 		var q2 = q + this.yd * 3;
 
 		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q2 ],     mu );
 		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q2 + 1 ], mu );
 		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q2 + 2 ], mu );
-		
+
 	};
 
 	this.VIntZ = function( q, pout, nout, offset, isol, x, y, z, valp1, valp2 ) {
-		
+
 		var mu = ( isol - valp1 ) / ( valp2 - valp1 ),
 		nc = this.normal_cache;
-		
+
 		pout[ offset ] 	   = x;
 		pout[ offset + 1 ] = y;
 		pout[ offset + 2 ] = z + mu * this.delta;
-		
+
 		var q2 = q + this.zd * 3;
-		
+
 		nout[ offset ] 	   = this.lerp( nc[ q ],     nc[ q2 ],     mu );
 		nout[ offset + 1 ] = this.lerp( nc[ q + 1 ], nc[ q2 + 1 ], mu );
 		nout[ offset + 2 ] = this.lerp( nc[ q + 2 ], nc[ q2 + 2 ], mu );
-		
+
 	};
 
 	this.compNorm = function( q ) {
 
 		var q3 = q * 3;
-		
+
 		if ( this.normal_cache [ q3 ] == 0.0 ) {
-			
+
 			this.normal_cache[ q3     ] = this.field[ q - 1  ] 	    - this.field[ q + 1 ];
 			this.normal_cache[ q3 + 1 ] = this.field[ q - this.yd ] - this.field[ q + this.yd ];
 			this.normal_cache[ q3 + 2 ] = this.field[ q - this.zd ] - this.field[ q + this.zd ];
-			
+
 		}
-		
-	};	
-	
+
+	};
+
 	// Returns total number of triangles. Fills triangles.
 	// (this is where most of time is spent - it's inner work of O(n3) loop )
-	
+
 	this.polygonize = function( fx, fy, fz, q, isol, render_callback ) {
-		
+
 		// cache indices
 		var q1 = q + 1,
 			qy = q + this.yd,
@@ -158,7 +150,6 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 			field5 = this.field[ q1z ],
 			field6 = this.field[ qyz ],
 			field7 = this.field[ q1yz ];
-		
 
 		if ( field0 < isol ) cubeindex |= 1;
 		if ( field1 < isol ) cubeindex |= 2;
@@ -170,7 +161,7 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 		if ( field7 < isol ) cubeindex |= 64;
 
 		// if cube is entirely in/out of the surface - bail, nothing to draw
-		
+
 		var bits = THREE.edgeTable[ cubeindex ];
 		if ( bits == 0 ) return 0;
 
@@ -178,121 +169,121 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 			fx2 = fx + d, 
 			fy2 = fy + d, 
 			fz2 = fz + d;
-		
+
 		// top of the cube
-		
+
 		if ( bits & 1 ) { 
-			
-			this.compNorm( q );      
-			this.compNorm( q1 );       
+
+			this.compNorm( q );
+			this.compNorm( q1 );
 			this.VIntX( q * 3, this.vlist, this.nlist, 0, isol, fx, fy, fz, field0, field1 );
-			
+
 		};
-		
+
 		if ( bits & 2 ) { 
-			
+
 			this.compNorm( q1 );  
 			this.compNorm( q1y );  
 			this.VIntY( q1 * 3, this.vlist, this.nlist, 3, isol, fx2, fy, fz, field1, field3 );
-			
+
 		};
-		
+
 		if ( bits & 4 ) { 
-			
+
 			this.compNorm( qy ); 
 			this.compNorm( q1y );  
 			this.VIntX( qy * 3, this.vlist, this.nlist, 6, isol, fx, fy2, fz, field2, field3 ); 
-			
+
 		};
-		
+
 		if ( bits & 8 ) { 
-			
-			this.compNorm( q );      
-			this.compNorm( qy );      
+
+			this.compNorm( q );
+			this.compNorm( qy );
 			this.VIntY( q * 3, this.vlist, this.nlist, 9, isol, fx, fy, fz, field0, field2 );
-			
+
 		};
 
 		// bottom of the cube
-			
+
 		if ( bits & 16 )  { 
-			
-			this.compNorm( qz );      
-			this.compNorm( q1z );      
+
+			this.compNorm( qz );
+			this.compNorm( q1z );
 			this.VIntX( qz * 3, this.vlist, this.nlist, 12, isol, fx, fy, fz2, field4, field5 ); 
-			
+
 		};
-		
+
 		if ( bits & 32 )  { 
-			
+
 			this.compNorm( q1z );  
 			this.compNorm( q1yz ); 
 			this.VIntY( q1z * 3,  this.vlist, this.nlist, 15, isol, fx2, fy, fz2, field5, field7 ); 
-			
+
 		};
-		
-		if ( bits & 64 )  { 
-			
-			this.compNorm( qyz ); 
-			this.compNorm( q1yz ); 
+
+		if ( bits & 64 ) {
+
+			this.compNorm( qyz );
+			this.compNorm( q1yz );
 			this.VIntX( qyz * 3, this.vlist, this.nlist, 18, isol, fx, fy2, fz2, field6, field7 ); 
-			
+
 		};
-		
-		if ( bits & 128 ) { 
-			
-			this.compNorm( qz );      
-			this.compNorm( qyz );     
+
+		if ( bits & 128 ) {
+
+			this.compNorm( qz );
+			this.compNorm( qyz );
 			this.VIntY( qz * 3,  this.vlist, this.nlist, 21, isol, fx, fy, fz2, field4, field6 ); 
-			
+
 		};
-			
+
 		// vertical lines of the cube
-			
-		if ( bits & 256 )  { 
-			
-			this.compNorm( q );          
-			this.compNorm( qz );          
+
+		if ( bits & 256 ) {
+
+			this.compNorm( q );
+			this.compNorm( qz );
 			this.VIntZ( q * 3, this.vlist, this.nlist, 24, isol, fx, fy, fz, field0, field4 );
-			
+
 		};
-		
-		if ( bits & 512 )  { 
-			
-			this.compNorm( q1 );      
-			this.compNorm( q1z );      
+
+		if ( bits & 512 ) {
+
+			this.compNorm( q1 );
+			this.compNorm( q1z );
 			this.VIntZ( q1 * 3,  this.vlist, this.nlist, 27, isol, fx2, fy,  fz, field1, field5 ); 
-			
+
 		};
-		
-		if ( bits & 1024 ) { 
-			
-			this.compNorm( q1y ); 
-			this.compNorm( q1yz ); 
+
+		if ( bits & 1024 ) {
+
+			this.compNorm( q1y );
+			this.compNorm( q1yz );
 			this.VIntZ( q1y * 3, this.vlist, this.nlist, 30, isol, fx2, fy2, fz, field3, field7 ); 
-			
+
 		};
-		
+
 		if ( bits & 2048 ) { 
-			
-			this.compNorm( qy );     
-			this.compNorm( qyz );     
+
+			this.compNorm( qy );
+			this.compNorm( qyz );
 			this.VIntZ( qy * 3, this.vlist, this.nlist, 33, isol, fx,  fy2, fz, field2, field6 ); 
-			
+
 		};
 
 		cubeindex <<= 4;  // re-purpose cubeindex into an offset into triTable
-		
+
 		var o1, o2, o3, numtris = 0, i = 0;
-			
+
 		// here is where triangles are created
 
 		while ( THREE.triTable[ cubeindex + i ] != -1 ) {
-	  
+
 			o1 = cubeindex + i;
 			o2 = o1 + 1;
 			o3 = o1 + 2;
-			
+
 			this.posnormtriv( this.vlist, this.nlist,
 							  3 * THREE.triTable[ o1 ],
 							  3 * THREE.triTable[ o2 ],
@@ -301,248 +292,251 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 
 			i += 3;
 			numtris ++;
-		
+
 		}
 
 		return numtris;
-		
+
 	};
 
 	/////////////////////////////////////
 	// Immediate render mode simulator
 	/////////////////////////////////////
-	
+
 	this.posnormtriv = function( pos, norm, o1, o2, o3, render_callback ) {
-		
+
 		var c = this.count * 3;
-		
-		this.positionArray[ c ] 	= pos[ o1 ];
+
+		this.positionArray[ c ] = pos[ o1 ];
 		this.positionArray[ c + 1 ] = pos[ o1 + 1 ];
 		this.positionArray[ c + 2 ] = pos[ o1 + 2 ];
-		  
+
 		this.positionArray[ c + 3 ] = pos[ o2 ];
 		this.positionArray[ c + 4 ] = pos[ o2 + 1 ];
 		this.positionArray[ c + 5 ] = pos[ o2 + 2 ];
-		  
+
 		this.positionArray[ c + 6 ] = pos[ o3 ];
 		this.positionArray[ c + 7 ] = pos[ o3 + 1 ];
 		this.positionArray[ c + 8 ] = pos[ o3 + 2 ];
-		  
-		this.normalArray[ c ] 	  = norm[ o1 ]; 
+
+		this.normalArray[ c ] = norm[ o1 ]; 
 		this.normalArray[ c + 1 ] = norm[ o1 + 1 ];
 		this.normalArray[ c + 2 ] = norm[ o1 + 2 ];
-		  
+
 		this.normalArray[ c + 3 ] = norm[ o2 ]; 
 		this.normalArray[ c + 4 ] = norm[ o2 + 1 ];
 		this.normalArray[ c + 5 ] = norm[ o2 + 2 ];
-		  
+
 		this.normalArray[ c + 6 ] = norm[ o3 ]; 
 		this.normalArray[ c + 7 ] = norm[ o3 + 1 ];
 		this.normalArray[ c + 8 ] = norm[ o3 + 2 ];
-		
+
 		this.hasPos = true;
 		this.hasNormal = true;
-		
+
 		this.count += 3;
-		
+
 		if ( this.count >= this.maxCount - 3 ) {
-		
+
 			render_callback( this );
-		
+
 		}
-		
+
 	};
 
 	this.begin = function( ) {
-		
+
 		this.count = 0;
 		this.hasPos = false;
 		this.hasNormal = false;
-	  
+
 	};
 
 	this.end = function( render_callback ) {
-		
+
 		if ( this.count == 0 )
 			return;
-		
+
 		for ( var i = this.count * 3; i < this.positionArray.length; i++ )
 			this.positionArray[ i ] = 0.0;
-		
+
 		render_callback( this );
-		
+
 	};
 
 	/////////////////////////////////////
 	// Metaballs
 	/////////////////////////////////////
-	
+
 	// Adds a reciprocal ball (nice and blobby) that, to be fast, fades to zero after
 	// a fixed distance, determined by strength and subtract.
 
 	this.addBall = function( ballx, bally, ballz, strength, subtract ) {
-		
+
 		// Let's solve the equation to find the radius:
 		// 1.0 / (0.000001 + radius^2) * strength - subtract = 0
 		// strength / (radius^2) = subtract
 		// strength = subtract * radius^2
 		// radius^2 = strength / subtract
 		// radius = sqrt(strength / subtract)
-		
+
 		var radius = this.size * Math.sqrt( strength / subtract ),
 			zs = ballz * this.size,
 			ys = bally * this.size,
 			xs = ballx * this.size;
-		
+
 		var min_z = Math.floor( zs - radius ); if ( min_z < 1 ) min_z = 1;
 		var max_z = Math.floor( zs + radius ); if ( max_z > this.size - 1 ) max_z = this.size - 1;
 		var min_y = Math.floor( ys - radius ); if ( min_y < 1 ) min_y = 1;
 		var max_y = Math.floor( ys + radius ); if ( max_y > this.size - 1 ) max_y = this.size - 1;
 		var min_x = Math.floor( xs - radius ); if ( min_x < 1  ) min_x = 1;
 		var max_x = Math.floor( xs + radius ); if ( max_x > this.size - 1 ) max_x = this.size - 1;
-		
+
 
 		// Don't polygonize in the outer layer because normals aren't
 		// well-defined there.
 
 		var x, y, z, y_offset, z_offset, fx, fy, fz, fz2, fy2, val;
-		
+
 		for ( z = min_z; z < max_z; z++ ) {
-	  
+
 			z_offset = this.size2 * z,
 			fz = z / this.size - ballz,
 			fz2 = fz * fz;
-			
+
 			for ( y = min_y; y < max_y; y++ ) {
-			
+
 				y_offset = z_offset + this.size * y;
 				fy = y / this.size - bally;
 				fy2 = fy * fy;
-				
+
 				for ( x = min_x; x < max_x; x++ ) {
-					
+
 					fx = x / this.size - ballx;
 					val = strength / ( 0.000001 + fx*fx + fy2 + fz2 ) - subtract;
 					if ( val > 0.0 ) this.field[ y_offset + x ] += val;
-					
+
 				}
-				
+
 			}
-			
+
 		}
-		
+
 	};
 
 	this.addPlaneX = function( strength, subtract ) {
-		
+
 		var x, y, z, xx, val, xdiv, cxy,
-			
+
 			// cache attribute lookups
 			size = this.size,
 			yd = this.yd,
 			zd = this.zd,
 			field = this.field,
-			
+
 			dist = size * Math.sqrt( strength / subtract );
-		
+
 		if ( dist > size ) dist = size;
-		
+
 		for ( x = 0; x < dist; x++ ) {
-			
+
 			xdiv = x / size;
 			xx = xdiv * xdiv;
 			val = strength / ( 0.0001 + xx ) - subtract;
-			
+
 			if ( val > 0.0 ) {
-				
+
 				for ( y = 0; y < size; y++ ) {
-					
+
 					cxy = x + y * yd;
-					
-					for ( z = 0; z < size; z++ )
+
+					for ( z = 0; z < size; z++ ) {
+
 						field[ zd * z + cxy ] += val;
-					
+
+					}
+
 				}
-				
+
 			}
-			
+
 		}
 
 	};
 
 	this.addPlaneY = function( strength, subtract ) {
-		
+
 		var x, y, z, yy, val, ydiv, cy, cxy,
-			
+
 			// cache attribute lookups
 			size = this.size,
 			yd = this.yd,
 			zd = this.zd,
 			field = this.field,
-			
+
 			dist = size * Math.sqrt( strength / subtract );
-		
+
 		if ( dist > size ) dist = size;
-		
+
 		for ( y = 0; y < dist; y++ ) {
-			
+
 			ydiv = y / size;
 			yy = ydiv * ydiv;
 			val = strength / ( 0.0001 + yy ) - subtract;
-			
+
 			if ( val > 0.0 ) {
-				
+
 				cy = y * yd;
-				
+
 				for ( x = 0; x < size; x++ ) {
-					
+
 					cxy = cy + x;
-					
+
 					for ( z = 0; z < size; z++ )
 						field[ zd * z + cxy ] += val;
-					
+
 				}
-				
+
 			}
-			
+
 		}
 
 	};
 
 	this.addPlaneZ = function( strength, subtract ) {
-		
+
 		var x, y, z, zz, val, zdiv, cz, cyz;
-		
+
 			// cache attribute lookups
 			size = this.size,
 			yd = this.yd,
 			zd = this.zd,
 			field = this.field,
-		
+
 			dist = size * Math.sqrt( strength / subtract );
-		
+
 		if ( dist > size ) dist = size;
-		
+
 		for ( z = 0; z < dist; z++ ) {
-		
+
 			zdiv = z / size;
 			zz = zdiv * zdiv;
 			val = strength / ( 0.0001 + zz ) - subtract;
 			if ( val > 0.0 ) {
-		
+
 				cz = zd * z;
-				
+
 				for ( y = 0; y < size; y++ ) {
-						
+
 						cyz = cz + y * yd;
-					
-						for ( x = 0; x < size; x++ )					
+
+						for ( x = 0; x < size; x++ )
 							field[ cyz + x ] += val;
-					
+
 				}
-				
+
 			}
-			
+
 		}
 
 	};
@@ -552,71 +546,72 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 	/////////////////////////////////////
 
 	this.reset = function() {
-		
+
 		var i;
-		
+
 		// wipe the normal cache
-		
+
 		for ( i = 0; i < this.size3; i++ ) {
-			
+
 			this.normal_cache[ i * 3 ] = 0.0;
 			this.field[ i ] = 0.0;
-			
-		}		
+
+		}
 
 	};
-	
-	this.render = function( render_callback ) {		
-		
+
+	this.render = function( render_callback ) {
+
 		this.begin();
-		
+
 		// Triangulate. Yeah, this is slow.
-		
+
 		var q, x, y, z, fx, fy, fz, y_offset, z_offset, smin2 = this.size - 2;
-		
+
 		for ( z = 1; z < smin2; z++ ) {
-			
+
 			z_offset = this.size2 * z;
 			fz = ( z - this.halfsize ) / this.halfsize; //+ 1
-			
+
 			for ( y = 1; y < smin2; y++ ) {
-			
+
 				y_offset = z_offset + this.size * y;
 				fy = ( y - this.halfsize ) / this.halfsize; //+ 1
-		
+
 				for ( x = 1; x < smin2; x++ ) {
-					
+
 					fx = ( x - this.halfsize ) / this.halfsize; //+ 1
 					q = y_offset + x;
-					
+
 					this.polygonize( fx, fy, fz, q, this.isolation, render_callback );
-				
+
 				}
-				
+
 			}
+
 		}
-		
+
 		this.end( render_callback );
-	
+
 	};
-	
+
 	this.generateGeometry = function() {
-		
+
 		var start = 0, geo = new THREE.Geometry();
 		var normals = [];
-		
+
 		var geo_callback = function( object ) {
-			
+
 			var i, x, y, z, vertex, position, normal, 
 				face, a, b, c, na, nb, nc;
-			
-			
-			for( i = 0; i < object.count; i++ ) {
-				
+
+
+			for ( i = 0; i < object.count; i++ ) {
+
 				a = i * 3;
 				b = a + 1;
 				c = a + 2;
-				
+
 				x = object.positionArray[ a ];
 				y = object.positionArray[ b ];
 				z = object.positionArray[ c ];
@@ -627,18 +622,18 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 				z = object.normalArray[ c ];
 				normal = new THREE.Vector3( x, y, z );
 				normal.normalize();
-				
+
 				vertex = new THREE.Vertex( position );
-				
+
 				geo.vertices.push( vertex );
 				normals.push( normal );
-				
+
 			}
-			
+
 			nfaces = object.count / 3;
-			
-			for( i = 0; i < nfaces; i++ ) {
-				
+
+			for ( i = 0; i < nfaces; i++ ) {
+
 				a = ( start + i ) * 3;
 				b = a + 1;
 				c = a + 2;
@@ -646,26 +641,26 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 				na = normals[ a ];
 				nb = normals[ b ];
 				nc = normals[ c ];
-				
+
 				face = new THREE.Face3( a, b, c, [ na, nb, nc ] );
-				
+
 				geo.faces.push( face );
-				
+
 			}
-			
+
 			start += nfaces;
 			object.count = 0;
-			
+
 		};
-		
+
 		this.render( geo_callback );
-		
+
 		// console.log( "generated " + geo.faces.length + " triangles" );
-		
+
 		return geo;
-		
+
 	};
-	
+
 	this.init( resolution );
 
 };
diff --git a/src/materials/Uniforms.js b/src/materials/Uniforms.js
deleted file mode 100644
index d38a4229..00000000
--- a/src/materials/Uniforms.js
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * @author alteredq / http://alteredqualia.com/
- */
- 
-var Uniforms = {
-
-	clone: function( uniforms_src ) {
-
-		var u, p, parameter, parameter_src, uniforms_dst = {};
-
-		for ( u in uniforms_src ) {
-
-			uniforms_dst[ u ] = {};
-
-			for ( p in uniforms_src[ u ] ) {
-
-				parameter_src = uniforms_src[ u ][ p ];
-
-				if ( parameter_src instanceof THREE.Color ||
-					 parameter_src instanceof THREE.Vector3 ||
-					 parameter_src instanceof THREE.Texture ) {
-
-					uniforms_dst[ u ][ p ] = parameter_src.clone();
-
-				} else {
-
-					uniforms_dst[ u ][ p ] = parameter_src;
-
-				}
-
-			}
-
-		}
-
-		return uniforms_dst;
-
-	},
-
-	merge: function( uniforms ) {
-
-		var u, p, tmp, merged = {};
-
-		for( u = 0; u < uniforms.length; u++ ) {
-
-			tmp = this.clone( uniforms[ u ] );
-
-			for ( p in tmp ) {
-
-				merged[ p ] = tmp[ p ];
-
-			}
-
-		}
-
-		return merged;
-
-	}
-
-};
diff --git a/src/objects/ShadowVolume.js b/src/objects/ShadowVolume.js
index 4f2c76cd..c582ee25 100644
--- a/src/objects/ShadowVolume.js
+++ b/src/objects/ShadowVolume.js
@@ -3,18 +3,18 @@
  */
 
 THREE.ShadowVolume = function( meshOrGeometry, isStatic ) {
-	
+
 	if( meshOrGeometry instanceof THREE.Mesh ) {
-		
+
 	 	THREE.Mesh.call( this, meshOrGeometry.geometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] );
 		meshOrGeometry.addChild( this );
-		
+
 	} else {
-		
+
 	 	THREE.Mesh.call( this, meshOrGeometry, isStatic ? [ new THREE.ShadowVolumeDynamicMaterial() ] : [ new THREE.ShadowVolumeDynamicMaterial() ] );
-		
+
 	}
- 
+
 	this.calculateShadowVolumeGeometry();
 
 };
@@ -29,60 +29,60 @@ THREE.ShadowVolume.prototype.supr        = THREE.Mesh.prototype;
  */
 
 THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function() {
-	
-	if( this.geometry.edges && this.geometry.edges.length ) {
-	
+
+	if ( this.geometry.edges && this.geometry.edges.length ) {
+
 		var f, fl, face, faceA, faceB, faceAIndex, faceBIndex, vertexA, vertexB;
 		var faceACombination, faceBCombination;
 		var faceAvertexAIndex, faceAvertexBIndex, faceBvertexAIndex, faceBvertexBIndex;
 		var e, el, edge, temp;
-	
+
 		var newGeometry = new THREE.Geometry();
 		var vertices = newGeometry.vertices = this.geometry.vertices;
 		var faces = newGeometry.faces = this.geometry.faces;
 		var edges = newGeometry.egdes = this.geometry.edges;
 		var edgeFaces = newGeometry.edgeFaces = [];
-		
+
 		var vertexOffset = 0;
 		var vertexOffsetPerFace = [];
-	
+
 		for( f = 0, fl = faces.length; f < fl; f++ ) {
-			
+
 			face = faces[ f ];
-			
+
 			// calculate faces vertex offset
-		
+
 			vertexOffsetPerFace.push( vertexOffset );
 			vertexOffset += face instanceof THREE.Face3 ? 3 : 4;
-	
+
 			// set vertex normals to face normal
-			
+
 			face.vertexNormals[ 0 ] = face.normal;
 			face.vertexNormals[ 1 ] = face.normal;
 			face.vertexNormals[ 2 ] = face.normal;
-			
+
 			if( face instanceof THREE.Face4 ) face.vertexNormals[ 3 ] = face.normal;
-			
-		}	
-		
-	
+
+		}
+
+
 		// setup edge faces
-		
+
 		for( e = 0, el = edges.length; e < el; e++ ) {
-			
+
 			edge = edges[ e ];
-			
+
 			faceA = edge.faces[ 0 ];
 			faceB = edge.faces[ 1 ];
-			
+
 			faceAIndex = edge.faceIndices[ 0 ];
 			faceBIndex = edge.faceIndices[ 1 ];
-			
+
 			vertexA = edge.vertexIndices[ 0 ];
 			vertexB = edge.vertexIndices[ 1 ];
-			
+
 			// find combination and processed vertex index (vertices are split up by renderer)
-			
+
 			     if( faceA.a === vertexA ) { faceACombination = "a"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 0; }
 			else if( faceA.b === vertexA ) { faceACombination = "b"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 1; }
 			else if( faceA.c === vertexA ) { faceACombination = "c"; faceAvertexAIndex = vertexOffsetPerFace[ faceAIndex ] + 2; }
@@ -103,109 +103,109 @@ THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry = function() {
 			else if( faceB.c === vertexB ) { faceBCombination += "c"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 2; }
 			else if( faceB.d === vertexB ) { faceBCombination += "d"; faceBvertexBIndex = vertexOffsetPerFace[ faceBIndex ] + 3; }
 
-			if( faceACombination === "ac" || 
+			if( faceACombination === "ac" ||
 				faceACombination === "ad" ||
 				faceACombination === "ca" ||
 				faceACombination === "da" ) {
-				
+
 				if( faceAvertexAIndex > faceAvertexBIndex ) {
-					
+
 					temp = faceAvertexAIndex;
 					faceAvertexAIndex = faceAvertexBIndex;
 					faceAvertexBIndex = temp;
-					
-				} 
-				
+
+				}
+
 			} else {
-				
+
 				if( faceAvertexAIndex < faceAvertexBIndex ) {
-					
+
 					temp = faceAvertexAIndex;
 					faceAvertexAIndex = faceAvertexBIndex;
 					faceAvertexBIndex = temp;
-					
-				} 
-				
+
+				}
+
 			}
 
-			if( faceBCombination === "ac" || 
+			if( faceBCombination === "ac" ||
 				faceBCombination === "ad" ||
 				faceBCombination === "ca" ||
 				faceBCombination === "da" ) {
 
 				if( faceBvertexAIndex > faceBvertexBIndex ) {
-					
+
 					temp = faceBvertexAIndex;
 					faceBvertexAIndex = faceBvertexBIndex;
 					faceBvertexBIndex = temp;
-					
+
 				}
 
 			} else {
-				
+
 				if( faceBvertexAIndex < faceBvertexBIndex ) {
-					
+
 					temp = faceBvertexAIndex;
 					faceBvertexAIndex = faceBvertexBIndex;
 					faceBvertexBIndex = temp;
-					
+
 				}
-				
+
 			}
 
-			
+
 
 			face = new THREE.Face4( faceAvertexAIndex, faceAvertexBIndex, faceBvertexAIndex, faceBvertexBIndex );
 			face.normal.set( 1, 0, 0 );
-			edgeFaces.push( face );		
-			
+			edgeFaces.push( face );
+
 		}
-		
+
 		this.geometry = newGeometry;
-		
+
 	} else {
-	
+
 		this.calculateShadowVolumeGeometryWithoutEdgeInfo( this.geometry );
-		
+
 	}
 }
 
 
 THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo = function( originalGeometry ) {
-	
+
 	// create geometry
-	
+
 	this.geometry = new THREE.Geometry();
 	this.geometry.boundingSphere = originalGeometry.boundingSphere;
 	this.geometry.edgeFaces = [];
-		
+
 	// copy vertices / faces from original mesh
-	
+
 	var vertexTypes = this.geometry.vertexTypes;
 	var vertices    = this.geometry.vertices;
 	var	faces       = this.geometry.faces;
 	var edgeFaces   = this.geometry.edgeFaces;
 
-	var originalFaces    = originalGeometry.faces;	
+	var originalFaces    = originalGeometry.faces;
 	var originalVertices = originalGeometry.vertices;
 	var	fl               = originalFaces.length;
-	
+
 	var	originalFace, face, i, f, n, vertex, numVertices;
 	var indices = [ "a", "b", "c", "d" ];
 
 
 	for( f = 0; f < fl; f++ ) {
-		
+
 		numVertices = vertices.length;
 		originalFace = originalFaces[ f ];
 
 		if ( originalFace instanceof THREE.Face4 ) {
-			
+
 			n = 4;
 			face = new THREE.Face4( numVertices, numVertices + 1, numVertices + 2, numVertices + 3 );
-		
+
 		} else {
-			
+
           	n = 3;
 			face = new THREE.Face3( numVertices, numVertices + 1, numVertices + 2 );
 
@@ -216,28 +216,28 @@ THREE.ShadowVolume.prototype.calculateShadowVolumeGeometryWithoutEdgeInfo = func
 
 
 		for( i = 0; i < n; i++ ) {
-			
+
 			vertex = originalVertices[ originalFace[ indices[ i ]]];
 			vertices.push( new THREE.Vertex( vertex.position.clone()));
-		
+
 		}
 
 	}
-	
+
 
 	// calculate edge faces
 
 	var result, faceA, faceB, v, vl;
-	
+
 	for( var fa = 0; fa < originalFaces.length - 1; fa++ ) {
-		
+
 		faceA = faces[ fa ];
-		
+
 		for( var fb = fa + 1; fb < originalFaces.length; fb++ ) {
-			
+
 			faceB = faces[ fb ];
 			result = this.facesShareEdge( vertices, faceA, faceB );
-			
+
 			if( result !== undefined ) {
 
 				numVertices = vertices.length;
@@ -270,32 +270,32 @@ THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB )
 		a, b,
 		numMatches = 0,
 		indices = [ "a", "b", "c", "d" ];
-	
+
 	if( faceA instanceof THREE.Face4 ) indicesA = 4;
 	else                               indicesA = 3;
-	
+
 	if( faceB instanceof THREE.Face4 ) indicesB = 4;
 	else                               indicesB = 3;
-	
-	
+
+
 	for( a = 0; a < indicesA; a++ ) {
-		
+
 		indexA  = faceA[ indices[ a ] ];
 		vertexA = vertices[ indexA ];
-	
+
 		for( b = 0; b < indicesB; b++ ) {
 
 			indexB  = faceB[ indices[ b ] ];
 			vertexB = vertices[ indexB ];
-			
+
 			if( Math.abs( vertexA.position.x - vertexB.position.x ) < 0.0001 &&
 				Math.abs( vertexA.position.y - vertexB.position.y ) < 0.0001 &&
 				Math.abs( vertexA.position.z - vertexB.position.z ) < 0.0001 ) {
-			
+
 				numMatches++;
-				
+
 				if( numMatches === 1 ) {
-					
+
  					savedVertexA = vertexA;
  					savedVertexB = vertexB;
 					savedIndexA  = indexA;
@@ -303,15 +303,15 @@ THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB )
 					indexLetters = indices[ a ];
 
 				}
-				
+
 				if( numMatches === 2 ) {
 
 					indexLetters += indices[ a ];
-					
+
 					if( indexLetters === "ad" || indexLetters === "ac" ) {
-						
+
 						return {
-							
+
 							faces   	: [ faceA, faceB ],
 							vertices	: [ savedVertexA, savedVertexB, vertexB, vertexA  ],
 							indices		: [ savedIndexA,  savedIndexB,  indexB,  indexA   ],
@@ -321,9 +321,9 @@ THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB )
 						};
 
 					} else {
-						
+
 						return {
-							
+
 							faces   	: [ faceA, faceB ],
 							vertices	: [ savedVertexA, vertexA, vertexB, savedVertexB ],
 							indices		: [ savedIndexA,  indexA,  indexB,  savedIndexB  ],
@@ -333,13 +333,13 @@ THREE.ShadowVolume.prototype.facesShareEdge = function( vertices, faceA, faceB )
 						};
 
 					}
-					
+
 				}
-				
+
 			}
-			
+
 		}
-		
+
 	}
 
 	return undefined;
diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js
index 7b117b2e..17f9b83f 100644
--- a/src/objects/SkinnedMesh.js
+++ b/src/objects/SkinnedMesh.js
@@ -2,14 +2,6 @@
  * @author mikael emtinger / http://gomo.se/
  */
 
-// do not crash if somebody includes the file in oldie browser
-
-if ( !window.Float32Array ) {
-
-	window.Float32Array = Array;
-
-}
-
 THREE.SkinnedMesh = function( geometry, materials ) {
 
 	THREE.Mesh.call( this, geometry, materials );
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index 70c26137..54d78d97 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -69,21 +69,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	},
 
-	// parameters defaults
 
-	stencil = true,
-	antialias = true,
-	clearColor = new THREE.Color( 0x000000 ),
-	clearAlpha = 0;
+	// parameters
 
-	if ( parameters ) {
+	parameters = parameters || {};
 
-		if ( parameters.stencil != undefined ) stencil = parameters.stencil;
-		if ( parameters.antialias !== undefined ) antialias = parameters.antialias;
-		if ( parameters.clearColor !== undefined ) clearColor.setHex( parameters.clearColor );
-		if ( parameters.clearAlpha !== undefined ) clearAlpha = parameters.clearAlpha;
+	stencil = parameters.stencil !== undefined ? parameters.stencil : true;
+	antialias = parameters.antialias !== undefined ? parameters.antialias : false;
+	clearColor = parameters.clearColor !== undefined ? new THREE.Color( parameters.clearColor ) : new THREE.Color( 0x000000 );
+	clearAlpha = parameters.clearAlpha !== undefined ? parameters.clearAlpha : 0;
 
-	}
 
 	this.maxMorphTargets = 8;
 	this.domElement = _canvas;
@@ -183,7 +178,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_gl.texParameteri( _gl.TEXTURE_2D, _gl.TEXTURE_MIN_FILTER, _gl.NEAREST );
 
 	if( _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ) <= 0 ) {
-		
+
 		_lensFlare.hasVertexTexture = false;
 
 		_lensFlare.program = _gl.createProgram();
@@ -191,16 +186,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.attachShader( _lensFlare.program, getShader( "vertex",   THREE.ShaderLib.lensFlare.vertexShader   ));
 		_gl.linkProgram( _lensFlare.program );
 
-		
+
 	} else {
 
 		_lensFlare.hasVertexTexture = true;
-		
+
 		_lensFlare.program = _gl.createProgram();
 		_gl.attachShader( _lensFlare.program, getShader( "fragment", THREE.ShaderLib.lensFlareVertexTexture.fragmentShader ));
 		_gl.attachShader( _lensFlare.program, getShader( "vertex",   THREE.ShaderLib.lensFlareVertexTexture.vertexShader   ));
 		_gl.linkProgram( _lensFlare.program );
-		
+
 	}
 
 	_lensFlare.attributes = {};
@@ -2058,7 +2053,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	function setMaterialShaders( material, shaders ) {
 
-		material.uniforms = Uniforms.clone( shaders.uniforms );
+		material.uniforms = THREE.UniformsUtils.clone( shaders.uniforms );
 		material.vertexShader = shaders.vertexShader;
 		material.fragmentShader = shaders.fragmentShader;
 
@@ -4323,7 +4318,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 		cacheUniformLocations( program, identifiers );
-		
+
 		// cache attributes locations
 
 		identifiers = [
diff --git a/src/renderers/WebGLShaders.js b/src/renderers/WebGLShaders.js
index 17bd19b4..18cabf8b 100644
--- a/src/renderers/WebGLShaders.js
+++ b/src/renderers/WebGLShaders.js
@@ -513,6 +513,62 @@ THREE.ShaderChunk = {
 
 };
 
+THREE.UniformsUtils = {
+
+	merge: function ( uniforms ) {
+
+		var u, p, tmp, merged = {};
+
+		for ( u = 0; u < uniforms.length; u++ ) {
+
+			tmp = this.clone( uniforms[ u ] );
+
+			for ( p in tmp ) {
+
+				merged[ p ] = tmp[ p ];
+
+			}
+
+		}
+
+		return merged;
+
+	},
+
+	clone: function ( uniforms_src ) {
+
+		var u, p, parameter, parameter_src, uniforms_dst = {};
+
+		for ( u in uniforms_src ) {
+
+			uniforms_dst[ u ] = {};
+
+			for ( p in uniforms_src[ u ] ) {
+
+				parameter_src = uniforms_src[ u ][ p ];
+
+				if ( parameter_src instanceof THREE.Color ||
+					 parameter_src instanceof THREE.Vector3 ||
+					 parameter_src instanceof THREE.Texture ) {
+
+					uniforms_dst[ u ][ p ] = parameter_src.clone();
+
+				} else {
+
+					uniforms_dst[ u ][ p ] = parameter_src;
+
+				}
+
+			}
+
+		}
+
+		return uniforms_dst;
+
+	}
+
+};
+
 THREE.UniformsLib = {
 
 	common: {
@@ -997,8 +1053,7 @@ THREE.ShaderLib = {
 
 	'lambert': {
 
-		uniforms: Uniforms.merge( [ THREE.UniformsLib[ "common" ],
-									THREE.UniformsLib[ "lights" ] ] ),
+		uniforms: THREE.UniformsUtils.merge( [ THREE.UniformsLib[ "common" ], THREE.UniformsLib[ "lights" ] ] ),
 
 		fragmentShader: [
 
@@ -1064,15 +1119,17 @@ THREE.ShaderLib = {
 
 	'phong': {
 
-		uniforms: Uniforms.merge( [ THREE.UniformsLib[ "common" ],
-									THREE.UniformsLib[ "lights" ],
+		uniforms: THREE.UniformsUtils.merge( [
 
-									{ "ambient"  : { type: "c", value: new THREE.Color( 0x050505 ) },
-									  "specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
-									  "shininess": { type: "f", value: 30 }
-									}
+			THREE.UniformsLib[ "common" ],
+			THREE.UniformsLib[ "lights" ],
+			{
+				"ambient"  : { type: "c", value: new THREE.Color( 0x050505 ) },
+				"specular" : { type: "c", value: new THREE.Color( 0x111111 ) },
+				"shininess": { type: "f", value: 30 }
+			}
 
-								] ),
+		] ),
 
 		fragmentShader: [
 
diff --git a/utils/build.py b/utils/build.py
index a410c5b1..8452b5df 100644
--- a/utils/build.py
+++ b/utils/build.py
@@ -53,7 +53,6 @@ COMMON_FILES = [
 'materials/ParticleCanvasMaterial.js',
 'materials/ParticleDOMMaterial.js',
 'materials/Texture.js',
-'materials/Uniforms.js',
 'objects/Particle.js',
 'objects/ParticleSystem.js',
 'objects/Line.js',
@@ -278,7 +277,6 @@ WEBGL_FILES = [
 'materials/ParticleBasicMaterial.js',
 'materials/ShadowVolumeDynamicMaterial.js',
 'materials/Texture.js',
-'materials/Uniforms.js',
 'objects/Particle.js',
 'objects/ParticleSystem.js',
 'objects/Line.js',