Browse Source

Merged with MrDoob

Mikael Emtinger 14 years ago
parent
commit
3536f3f2f5
71 changed files with 3765 additions and 1399 deletions
  1. 95 97
      build/Three.js
  2. 76 76
      build/custom/ThreeCanvas.js
  3. 2 3
      build/custom/ThreeDOM.js
  4. 16 15
      build/custom/ThreeExtras.js
  5. 4 4
      build/custom/ThreeSVG.js
  6. 122 118
      build/custom/ThreeWebGL.js
  7. 1 2
      examples/canvas_interactive_cubes.html
  8. 4 5
      examples/canvas_lights_pointlights.html
  9. 4 5
      examples/canvas_lights_pointlights_smooth.html
  10. 7 8
      examples/canvas_lines.html
  11. 7 8
      examples/canvas_lines_sphere.html
  12. 1 2
      examples/canvas_materials.html
  13. 7 8
      examples/canvas_materials_video.html
  14. 1 2
      examples/canvas_particles_floor.html
  15. 1 2
      examples/canvas_particles_random.html
  16. 7 8
      examples/canvas_particles_waves.html
  17. 1 1
      examples/canvas_performance.html
  18. 1 1
      examples/js/Detector.js
  19. 1 1
      examples/misc_sound.html
  20. 4 0
      examples/misc_ubiquity_test.html
  21. 45 0
      examples/obj/blenderscene/scene.Cube.js
  22. 30 0
      examples/obj/blenderscene/scene.Monkey.js
  23. 45 0
      examples/obj/blenderscene/scene.Plane.js
  24. BIN
      examples/obj/blenderscene/scene.blend
  25. 440 0
      examples/obj/blenderscene/scene.js
  26. BIN
      examples/obj/cubecolors/cube_fvc.blend
  27. 13 15
      examples/obj/cubecolors/cube_fvc.js
  28. 4 5
      examples/obj/cubecolors/cubecolors.js
  29. 9 11
      examples/obj/female02/Female02_bin.js
  30. 8 8
      examples/obj/female02/Female02_slim.js
  31. 3 3
      examples/obj/leeperrysmith/LeePerrySmith.js
  32. 4 6
      examples/obj/lucy/Lucy100k_bin.js
  33. 3 3
      examples/obj/lucy/Lucy100k_slim.js
  34. 8 10
      examples/obj/male02/Male02_bin.js
  35. 7 7
      examples/obj/male02/Male02_slim.js
  36. 4 6
      examples/obj/ninja/NinjaLo_bin.js
  37. 4 6
      examples/obj/torus/Torus_bin.js
  38. 3 3
      examples/obj/torus/Torus_slim.js
  39. 4 6
      examples/obj/walt/WaltHead_bin.js
  40. 3 3
      examples/obj/walt/WaltHead_slim.js
  41. 5 2
      examples/scenes/test_scene.js
  42. 2 85
      examples/webgl_geometry_minecraft.html
  43. 4 4
      examples/webgl_lights_pointlights.html
  44. 1 1
      examples/webgl_lines_colors.html
  45. 14 12
      examples/webgl_materials_cubemap.html
  46. 1 2
      examples/webgl_materials_video.html
  47. 1 1
      examples/webgl_particles_billboards.html
  48. 1 1
      examples/webgl_particles_billboards_colors.html
  49. 1 2
      examples/webgl_performance.html
  50. 1 1
      examples/webgl_postprocessing.html
  51. 1 2
      examples/webgl_postprocessing_dof.html
  52. 2 3
      examples/webgl_ribbons.html
  53. 9 3
      examples/webgl_sandbox.html
  54. 563 0
      examples/webgl_scene_test_blender.html
  55. 1 1
      examples/webgl_stencil.html
  56. 7 18
      src/cameras/Camera.js
  57. 63 16
      src/extras/SceneUtils.js
  58. 243 250
      src/extras/io/JSONLoader.js
  59. 37 34
      src/extras/io/Loader.js
  60. 2 1
      src/lights/DirectionalLight.js
  61. 2 1
      src/lights/PointLight.js
  62. 3 3
      src/materials/Material.js
  63. 24 35
      src/renderers/CanvasRenderer.js
  64. 340 280
      src/renderers/WebGLRenderer.js
  65. 76 64
      src/renderers/WebGLShaders.js
  66. 2 0
      utils/build.py
  67. 97 12
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py
  68. 723 70
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py
  69. 501 0
      utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py
  70. 16 18
      utils/exporters/convert_obj_three.py
  71. 23 19
      utils/exporters/max/ThreeJSExporter.ms

File diff suppressed because it is too large
+ 95 - 97
build/Three.js


+ 76 - 76
build/custom/ThreeCanvas.js

@@ -1,6 +1,6 @@
 // ThreeCanvas.js r37 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,j,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);j=a*6-g;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
+THREE.Color.prototype={autoUpdate:!0,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex;this.__styleString=a.__styleString},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var e,d,f,g,i,h;if(c==0)e=d=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:e=h;d=c;f=a;break;case 2:e=a;d=c;f=b;break;case 3:e=a;d=h;f=c;break;case 4:e=b;d=a;f=c;break;case 5:e=c;d=a;
 f=h;break;case 6:case 0:e=c;d=b;f=a}}this.r=e;this.g=d;this.b=f;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*
 255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
@@ -12,79 +12,78 @@ this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setPosit
 1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,e){this.set(a||0,b||0,c||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(E,q,C,F){F=F.clone().subSelf(q);C=C.clone().subSelf(q);var S=E.clone().subSelf(q);E=F.dot(F);q=F.dot(C);F=F.dot(S);var K=C.dot(C);C=C.dot(S);S=1/(E*K-q*q);K=(K*F-q*C)*S;E=(E*C-q*F)*S;return K>0&&E>0&&K+E<1}var c,e,d,f,g,j,h,i,l,m,
-p,n=a.geometry,v=n.vertices,A=[];c=0;for(e=n.faces.length;c<e;c++){d=n.faces[c];m=this.origin.clone();p=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(v[d.a].position.clone());g=h.multiplyVector3(v[d.b].position.clone());j=h.multiplyVector3(v[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(v[d.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(d.normal.clone());l=p.dot(i);if(l<0){i=i.dot((new THREE.Vector3).sub(f,m))/l;m=m.addSelf(p.multiplyScalar(i));
-if(d instanceof THREE.Face3){if(b(m,f,g,j)){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};A.push(d)}}else if(d instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,j,h))){d={distance:this.origin.distanceTo(m),point:m,face:d,object:a};A.push(d)}}}return A}};
-THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,f,g,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,i,l,m){j=!1;b=h;c=i;e=l;d=m;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;e=h;d=i}else{b=b<h?b:h;c=c<i?c:i;e=e>h?e:h;d=d>i?d:i}a()};
-this.add3Points=function(h,i,l,m,p,n){if(j){j=!1;b=h<l?h<p?h:p:l<p?l:p;c=i<m?i<n?i:n:m<n?m:n;e=h>l?h>p?h:p:l>p?l:p;d=i>m?i>n?i:n:m>n?m:n}else{b=h<l?h<p?h<b?h:b:p<b?p:b:l<p?l<b?l:b:p<b?p:b;c=i<m?i<n?i<c?i:c:n<c?n:c:m<n?m<c?m:c:n<c?n:c;e=h>l?h>p?h>e?h:e:p>e?p:e:l>p?l>e?l:e:p>e?p:e;d=i>m?i>n?i>d?i:d:n>d?n:d:m>n?m>d?m:d:n>d?n:d}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
-e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;d=e=c=b=0;a()};this.isEmpty=function(){return j}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(G,B,z,D){D=D.clone().subSelf(B);z=z.clone().subSelf(B);var I=G.clone().subSelf(B);G=D.dot(D);B=D.dot(z);D=D.dot(I);var H=z.dot(z);z=z.dot(I);I=1/(G*H-B*B);H=(H*D-B*z)*I;G=(G*z-B*D)*I;return H>0&&G>0&&H+G<1}var c,e,d,f,g,i,h,j,k,n,
+p,o=a.geometry,v=o.vertices,y=[];c=0;for(e=o.faces.length;c<e;c++){d=o.faces[c];n=this.origin.clone();p=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(v[d.a].position.clone());g=h.multiplyVector3(v[d.b].position.clone());i=h.multiplyVector3(v[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(v[d.d].position.clone()):null;j=a.matrixRotationWorld.multiplyVector3(d.normal.clone());k=p.dot(j);if(k<0){j=j.dot((new THREE.Vector3).sub(f,n))/k;n=n.addSelf(p.multiplyScalar(j));
+if(d instanceof THREE.Face3){if(b(n,f,g,i)){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};y.push(d)}}else if(d instanceof THREE.Face4&&(b(n,f,g,h)||b(n,g,i,h))){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};y.push(d)}}}return y}};
+THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,k,n){i=!1;b=h;c=j;e=k;d=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
+this.add3Points=function(h,j,k,n,p,o){if(i){i=!1;b=h<k?h<p?h:p:k<p?k:p;c=j<n?j<o?j:o:n<o?n:o;e=h>k?h>p?h:p:k>p?k:p;d=j>n?j>o?j:o:n>o?n:o}else{b=h<k?h<p?h<b?h:b:p<b?p:b:k<p?k<b?k:b:p<b?p:b;c=j<n?j<o?j<c?j:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;e=h>k?h>p?h>e?h:e:p>e?p:e:k>p?k>e?k:e:p>e?p:e;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
+e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,e,d,f,g,j,h,i,l,m,p,n,v,A){this.set(a||1,b||0,c||0,e||0,d||0,f||1,g||0,j||0,h||0,i||0,l||1,m||0,p||0,n||0,v||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,e,d,f,g,j,h,i,l,m,p,n,v,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=l;this.n34=m;this.n41=p;this.n42=n;this.n43=v;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__v1,
+THREE.Matrix4=function(a,b,c,e,d,f,g,i,h,j,k,n,p,o,v,y){this.set(a||1,b||0,c||0,e||0,d||0,f||1,g||0,i||0,h||0,j||0,k||1,n||0,p||0,o||0,v||0,y||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,e,d,f,g,i,h,j,k,n,p,o,v,y){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=k;this.n34=n;this.n41=p;this.n42=o;this.n43=v;this.n44=y;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__v1,
 d=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(f.length()===0)f.z=1;e.cross(c,f).normalize();if(e.length()===0){f.x+=1.0E-4;e.cross(c,f).normalize()}d.cross(f,e).normalize();this.n11=e.x;this.n12=d.x;this.n13=f.x;this.n21=e.y;this.n22=d.y;this.n23=f.y;this.n31=e.z;this.n32=d.z;this.n33=f.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*
 e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*d;return a},rotateAxis:function(a){var b=a.x,c=a.y,e=a.z;a.x=b*this.n11+c*this.n12+e*this.n13;a.y=b*this.n21+c*this.n22+e*this.n23;a.z=b*this.n31+c*this.n32+e*this.n33;a.normalize();
-return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,l=a.n31,m=a.n32,p=a.n33,n=a.n34,v=a.n41,A=a.n42,E=a.n43,q=a.n44,C=b.n11,F=b.n12,S=b.n13,K=b.n14,r=b.n21,R=b.n22,
-J=b.n23,O=b.n24,P=b.n31,z=b.n32,u=b.n33,T=b.n34;this.n11=c*C+e*r+d*P;this.n12=c*F+e*R+d*z;this.n13=c*S+e*J+d*u;this.n14=c*K+e*O+d*T+f;this.n21=g*C+j*r+h*P;this.n22=g*F+j*R+h*z;this.n23=g*S+j*J+h*u;this.n24=g*K+j*O+h*T+i;this.n31=l*C+m*r+p*P;this.n32=l*F+m*R+p*z;this.n33=l*S+m*J+p*u;this.n34=l*K+m*O+p*T+n;this.n41=v*C+A*r+E*P;this.n42=v*F+A*R+E*z;this.n43=v*S+A*J+E*u;this.n44=v*K+A*O+E*T+q;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=
-this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
-this.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,l=this.n33,m=this.n34,p=this.n41,n=this.n42,v=this.n43,A=this.n44;return e*g*i*p-c*j*i*p-e*f*l*p+b*j*l*p+c*f*m*p-b*g*m*p-e*g*h*n+c*j*h*n+e*d*l*n-a*j*l*n-c*d*m*n+a*g*m*n+e*f*h*v-b*j*h*v-e*d*i*v+a*j*i*v+b*d*m*v-a*f*m*v-c*f*h*A+b*g*h*A+c*d*i*A-a*g*i*A-b*d*l*A+a*f*l*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,p=a.n33,o=a.n34,v=a.n41,y=a.n42,G=a.n43,B=a.n44,z=b.n11,D=b.n12,I=b.n13,H=b.n14,q=b.n21,aa=b.n22,
+K=b.n23,P=b.n24,Q=b.n31,w=b.n32,s=b.n33,L=b.n34;this.n11=c*z+e*q+d*Q;this.n12=c*D+e*aa+d*w;this.n13=c*I+e*K+d*s;this.n14=c*H+e*P+d*L+f;this.n21=g*z+i*q+h*Q;this.n22=g*D+i*aa+h*w;this.n23=g*I+i*K+h*s;this.n24=g*H+i*P+h*L+j;this.n31=k*z+n*q+p*Q;this.n32=k*D+n*aa+p*w;this.n33=k*I+n*K+p*s;this.n34=k*H+n*P+p*L+o;this.n41=v*z+y*q+G*Q;this.n42=v*D+y*aa+G*w;this.n43=v*I+y*K+G*s;this.n44=v*H+y*P+G*L+B;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;
+c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=
+this.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,k=this.n33,n=this.n34,p=this.n41,o=this.n42,v=this.n43,y=this.n44;return e*g*j*p-c*i*j*p-e*f*k*p+b*i*k*p+c*f*n*p-b*g*n*p-e*g*h*o+c*i*h*o+e*d*k*o-a*i*k*o-c*d*n*o+a*g*n*o+e*f*h*v-b*i*h*v-e*d*j*v+a*i*j*v+b*d*n*v-a*f*n*v-c*f*h*y+b*g*h*y+c*d*j*y-a*g*j*y-b*d*k*y+a*f*k*y},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=
 this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;
 this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=
 this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,
-b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),d=1-c,f=a.x,g=a.y,j=a.z,h=d*f,i=d*g;this.set(h*
-f+c,h*g-e*j,h*j+e*g,0,h*g+e*j,i*g+c,i*j-e*f,0,h*j-e*g,i*j+e*f,d*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,j=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=j*f+a*e;this.n22=-j*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,e=a.z,d=a.w,f=b+b,g=c+c,j=e+e;a=b*f;var h=b*g;b*=j;var i=c*g;c*=j;e*=j;f*=d;g*=d;d*=j;this.n11=1-(i+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
+b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),d=1-c,f=a.x,g=a.y,i=a.z,h=d*f,j=d*g;this.set(h*
+f+c,h*g-e*i,h*i+e*g,0,h*g+e*i,j*g+c,j*i-e*f,0,h*i-e*g,j*i+e*f,d*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,i=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=i*f+a*e;this.n22=-i*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d;return this},setRotationFromQuaternion:function(a){var b=
+a.x,c=a.y,e=a.z,d=a.w,f=b+b,g=c+c,i=e+e;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;e*=i;f*=d;g*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=
 a.n34},extractRotation:function(a,b){var c=1/b.x,e=1/b.y,d=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*d;this.n23=a.n23*d;this.n33=a.n33*d}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,l=a.n31,m=a.n32,p=a.n33,n=a.n34,v=a.n41,A=a.n42,E=a.n43,q=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*n*A-i*p*A+i*m*E-j*n*E-h*m*q+j*p*q;b.n12=f*p*A-d*n*A-f*m*E+e*n*E+d*m*q-e*p*q;b.n13=d*i*A-f*h*A+f*j*E-e*i*E-d*j*q+e*h*q;b.n14=f*h*m-d*i*m-f*j*p+e*i*p+d*j*n-e*h*n;b.n21=i*p*v-h*n*v-i*l*E+g*n*E+h*l*q-g*p*q;b.n22=d*n*v-f*p*v+f*l*E-c*n*E-d*l*q+c*p*q;b.n23=f*h*v-d*i*v-f*g*E+c*i*E+d*g*q-c*h*q;
-b.n24=d*i*l-f*h*l+f*g*p-c*i*p-d*g*n+c*h*n;b.n31=j*n*v-i*m*v+i*l*A-g*n*A-j*l*q+g*m*q;b.n32=f*m*v-e*n*v-f*l*A+c*n*A+e*l*q-c*m*q;b.n33=d*i*v-f*j*v+f*g*A-c*i*A-e*g*q+c*j*q;b.n34=f*j*l-e*i*l-f*g*m+c*i*m+e*g*n-c*j*n;b.n41=h*m*v-j*p*v-h*l*A+g*p*A+j*l*E-g*m*E;b.n42=e*p*v-d*m*v+d*l*A-c*p*A-e*l*E+c*m*E;b.n43=d*j*v-e*h*v-d*g*A+c*h*A+e*g*E-c*j*E;b.n44=e*h*l-d*j*l+d*g*m-c*h*m-e*g*p+c*j*p;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*l;c[8]=a*m;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,k=a.n31,n=a.n32,p=a.n33,o=a.n34,v=a.n41,y=a.n42,G=a.n43,B=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*y-j*p*y+j*n*G-i*o*G-h*n*B+i*p*B;b.n12=f*p*y-d*o*y-f*n*G+e*o*G+d*n*B-e*p*B;b.n13=d*j*y-f*h*y+f*i*G-e*j*G-d*i*B+e*h*B;b.n14=f*h*n-d*j*n-f*i*p+e*j*p+d*i*o-e*h*o;b.n21=j*p*v-h*o*v-j*k*G+g*o*G+h*k*B-g*p*B;b.n22=d*o*v-f*p*v+f*k*G-c*o*G-d*k*B+c*p*B;b.n23=f*h*v-d*j*v-f*g*G+c*j*G+d*g*B-c*h*B;
+b.n24=d*j*k-f*h*k+f*g*p-c*j*p-d*g*o+c*h*o;b.n31=i*o*v-j*n*v+j*k*y-g*o*y-i*k*B+g*n*B;b.n32=f*n*v-e*o*v-f*k*y+c*o*y+e*k*B-c*n*B;b.n33=d*j*v-f*i*v+f*g*y-c*j*y-e*g*B+c*i*B;b.n34=f*i*k-e*j*k-f*g*n+c*j*n+e*g*o-c*i*o;b.n41=h*n*v-i*p*v-h*k*y+g*p*y+i*k*G-g*n*G;b.n42=e*p*v-d*n*v+d*k*y-c*p*y-e*k*G+c*n*G;b.n43=d*i*v-e*h*v-d*g*y+c*h*y+e*g*G-c*i*G;b.n44=e*h*k-d*i*k+d*g*n-c*h*n-e*g*p+c*i*p;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*k;c[8]=a*n;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
-THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,j,h,i;g=new THREE.Matrix4;j=b-a;h=c-e;i=f-d;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((b+a)/j);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+e)/h);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+d)/i);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==
 undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);if(this.scale.x!==1||this.scale.y!==
 1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}this.matrixWorldNeedsUpdate=!0},update:function(a,b,c){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||b){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;b=!0}a=0;for(var e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,
 b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?e:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,j=e*d;this.w=g*f-j*c;this.x=g*c+j*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,j=a.z;a=a.w;this.x=b*a+d*f+c*j-e*g;this.y=c*a+d*g+e*f-b*j;this.z=e*a+d*j+b*g-c*f;this.w=d*a-b*f-c*g-e*j;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,j=this.z,h=this.w,i=h*c+g*d-j*e,l=h*e+j*c-f*d,m=h*d+f*e-g*c;c=-f*c-g*e-j*d;b.x=i*h+c*-f+l*-j-m*-g;b.y=l*h+c*-g+m*-f-i*-j;b.z=m*h+c*-j+i*-g-l*-f;return b}};
+THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
+-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,k=h*e+i*c-f*d,n=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+k*-i-n*-g;b.y=k*h+c*-g+n*-f-j*-i;b.z=n*h+c*-i+j*-g-k*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,f,g,j=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){f=this.faces[e];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.vertexNormals.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];j.sub(g.position,c.position);h.sub(b.position,c.position);j.crossSelf(h)}j.isZero()||
-j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,e,d,f,g,i=new THREE.Vector3,h=new THREE.Vector3;e=0;for(d=this.faces.length;e<d;e++){f=this.faces[e];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.vertexNormals.length;b<c;b++)i.addSelf(f.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];i.sub(g.position,c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||
+i.normalize();f.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){e[c.a].addSelf(c.normal);e[c.b].addSelf(c.normal);e[c.c].addSelf(c.normal);e[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(e[c.a]);
-c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(L,U,x,G,w,D,I){j=L.vertices[U].position;h=L.vertices[x].position;i=L.vertices[G].position;l=g[w];m=g[D];p=g[I];n=h.x-j.x;v=i.x-j.x;A=h.y-j.y;E=i.y-j.y;q=h.z-j.z;C=i.z-j.z;F=m.u-l.u;S=p.u-l.u;K=m.v-l.v;r=p.v-l.v;R=1/(F*r-S*K);z.set((r*
-n-K*v)*R,(r*A-K*E)*R,(r*q-K*C)*R);u.set((F*v-S*n)*R,(F*E-S*A)*R,(F*C-S*q)*R);O[U].addSelf(z);O[x].addSelf(z);O[G].addSelf(z);P[U].addSelf(u);P[x].addSelf(u);P[G].addSelf(u)}var b,c,e,d,f,g,j,h,i,l,m,p,n,v,A,E,q,C,F,S,K,r,R,J,O=[],P=[],z=new THREE.Vector3,u=new THREE.Vector3,T=new THREE.Vector3,W=new THREE.Vector3,$=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){O[b]=new THREE.Vector3;P[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];g=this.faceVertexUvs[0][b];
-if(f instanceof THREE.Face3)a(this,f.a,f.b,f.c,0,1,2);else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3)}}var X=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++){$.copy(f.vertexNormals[e]);d=f[X[e]];J=O[d];T.copy(J);T.subSelf($.multiplyScalar($.dot(J))).normalize();W.cross(f.vertexNormals[e],J);d=W.dot(P[d]);d=d<0?-1:1;f.vertexTangents[e]=new THREE.Vector4(T.x,T.y,T.z,d)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
+c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(e[c.a]);c.vertexNormals[1].copy(e[c.b]);c.vertexNormals[2].copy(e[c.c]);c.vertexNormals[3].copy(e[c.d])}}},computeTangents:function(){function a(M,T,U,C,A,F,E){i=M.vertices[T].position;h=M.vertices[U].position;j=M.vertices[C].position;k=g[A];n=g[F];p=g[E];o=h.x-i.x;v=j.x-i.x;y=h.y-i.y;G=j.y-i.y;B=h.z-i.z;z=j.z-i.z;D=n.u-k.u;I=p.u-k.u;H=n.v-k.v;q=p.v-k.v;aa=1/(D*q-I*H);w.set((q*
+o-H*v)*aa,(q*y-H*G)*aa,(q*B-H*z)*aa);s.set((D*v-I*o)*aa,(D*G-I*y)*aa,(D*z-I*B)*aa);P[T].addSelf(w);P[U].addSelf(w);P[C].addSelf(w);Q[T].addSelf(s);Q[U].addSelf(s);Q[C].addSelf(s)}var b,c,e,d,f,g,i,h,j,k,n,p,o,v,y,G,B,z,D,I,H,q,aa,K,P=[],Q=[],w=new THREE.Vector3,s=new THREE.Vector3,L=new THREE.Vector3,W=new THREE.Vector3,X=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){P[b]=new THREE.Vector3;Q[b]=new THREE.Vector3}b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];g=this.faceVertexUvs[0][b];
+if(f instanceof THREE.Face3)a(this,f.a,f.b,f.c,0,1,2);else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3)}}var Y=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){f=this.faces[b];for(e=0;e<f.vertexNormals.length;e++){X.copy(f.vertexNormals[e]);d=f[Y[e]];K=P[d];L.copy(K);L.subSelf(X.multiplyScalar(X.dot(K))).normalize();W.cross(f.vertexNormals[e],K);d=W.dot(Q[d]);d=d<0?-1:1;f.vertexTangents[e]=new THREE.Vector4(L.x,L.y,L.z,d)}}this.hasTangents=!0},computeBoundingBox:function(){var a;
 if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
 THREE.AnimationHandler=function(){var a=[],b={},c={};c.update=function(d){for(var f=0;f<a.length;f++)a[f].update(d)};c.addToUpdate=function(d){a.indexOf(d)===-1&&a.push(d)};c.removeFromUpdate=function(d){d=a.indexOf(d);d!==-1&&a.splice(d,1)};c.add=function(d){b[d.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+d.name+" already exists in library. Overwriting.");b[d.name]=d;if(d.initialized!==!0){for(var f=0;f<d.hierarchy.length;f++){for(var g=0;g<d.hierarchy[f].keys.length;g++){if(d.hierarchy[f].keys[g].time<
-0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var j=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){j={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++){var i=d.hierarchy[f].keys[g].morphTargets[h];j[i]=-1}d.hierarchy[f].usedMorphTargets=j;for(g=0;g<d.hierarchy[f].keys.length;g++){var l=
-{};for(i in j){for(h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++)if(d.hierarchy[f].keys[g].morphTargets[h]===i){l[i]=d.hierarchy[f].keys[g].morphTargetsInfluences[h];break}h===d.hierarchy[f].keys[g].morphTargets.length&&(l[i]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=l}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
+0)d.hierarchy[f].keys[g].time=0;if(d.hierarchy[f].keys[g].rot!==undefined&&!(d.hierarchy[f].keys[g].rot instanceof THREE.Quaternion)){var i=d.hierarchy[f].keys[g].rot;d.hierarchy[f].keys[g].rot=new THREE.Quaternion(i[0],i[1],i[2],i[3])}}if(d.hierarchy[f].keys[0].morphTargets!==undefined){i={};for(g=0;g<d.hierarchy[f].keys.length;g++)for(var h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++){var j=d.hierarchy[f].keys[g].morphTargets[h];i[j]=-1}d.hierarchy[f].usedMorphTargets=i;for(g=0;g<d.hierarchy[f].keys.length;g++){var k=
+{};for(j in i){for(h=0;h<d.hierarchy[f].keys[g].morphTargets.length;h++)if(d.hierarchy[f].keys[g].morphTargets[h]===j){k[j]=d.hierarchy[f].keys[g].morphTargetsInfluences[h];break}h===d.hierarchy[f].keys[g].morphTargets.length&&(k[j]=0)}d.hierarchy[f].keys[g].morphTargetsInfluences=k}}for(g=1;g<d.hierarchy[f].keys.length;g++)if(d.hierarchy[f].keys[g].time===d.hierarchy[f].keys[g-1].time){d.hierarchy[f].keys.splice(g,1);g--}for(g=1;g<d.hierarchy[f].keys.length;g++)d.hierarchy[f].keys[g].index=g}g=parseInt(d.length*
 d.fps,10);d.JIT={};d.JIT.hierarchy=[];for(f=0;f<d.hierarchy.length;f++)d.JIT.hierarchy.push(Array(g));d.initialized=!0}};c.get=function(d){if(typeof d==="string")if(b[d])return b[d];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+d);return null}};c.parse=function(d){var f=[];if(d instanceof THREE.SkinnedMesh)for(var g=0;g<d.bones.length;g++)f.push(d.bones[g]);else e(d,f);return f};var e=function(d,f){f.push(d);for(var g=0;g<d.children.length;g++)e(d.children[g],f)};c.LINEAR=
 0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=2;return c}();THREE.Animation=function(a,b,c,e){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=c!==undefined?c:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=b!==undefined?b:0;var c,e=this.hierarchy.length,d;for(c=0;c<e;c++){d=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)d.useQuaternion=!0;d.matrixAutoUpdate=!0;if(d.animationCache===undefined){d.animationCache={};d.animationCache.prevKey={pos:0,rot:0,scl:0};d.animationCache.nextKey={pos:0,rot:0,scl:0};d.animationCache.originalMatrix=
 d instanceof THREE.Bone?d.skinMatrix:d.matrix}var f=d.animationCache.prevKey;d=d.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];d.pos=this.getNextKeyWith("pos",c,1);d.rot=this.getNextKeyWith("rot",c,1);d.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,f,g,j,h,i,l=this.data.JIT.hierarchy,m,p;this.currentTime+=a*this.timeScale;p=this.currentTime;m=this.currentTime%=this.data.length;i=parseInt(Math.min(m*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,v=this.hierarchy.length;n<v;n++){a=this.hierarchy[n];h=a.animationCache;if(this.JITCompile&&l[n][i]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=l[n][i];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
-!1}else{a.matrix=l[n][i];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var A=0;A<3;A++){c=b[A];g=h.prevKey[c];j=h.nextKey[c];if(j.time<=p){if(m<p)if(this.loop){g=this.data.hierarchy[n].keys[0];for(j=this.getNextKeyWith(c,n,1);j.time<m;){g=j;j=this.getNextKeyWith(c,n,j.index+1)}}else{this.stop();return}else{do{g=j;j=this.getNextKeyWith(c,n,j.index+1)}while(j.time<
-m)}h.prevKey[c]=g;h.nextKey[c]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(m-g.time)/(j.time-g.time);d=g[c];f=j[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+n);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",n,j.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&l[0][i]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)l[n][i]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,f,g,j,h,i;d=(a.length-1)*b;f=Math.floor(d);d-=f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];j=a[c[1]];h=a[c[2]];i=a[c[3]];c=d*d;g=d*c;e[0]=this.interpolate(f[0],j[0],h[0],i[0],d,c,g);e[1]=this.interpolate(f[1],j[1],h[1],i[1],d,c,g);e[2]=this.interpolate(f[2],j[2],h[2],i[2],d,c,g);return e};
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,f,g,i,h,j,k=this.data.JIT.hierarchy,n,p;this.currentTime+=a*this.timeScale;p=this.currentTime;n=this.currentTime%=this.data.length;j=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,v=this.hierarchy.length;o<v;o++){a=this.hierarchy[o];h=a.animationCache;if(this.JITCompile&&k[o][j]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
+!1}else{a.matrix=k[o][j];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var y=0;y<3;y++){c=b[y];g=h.prevKey[c];i=h.nextKey[c];if(i.time<=p){if(n<p)if(this.loop){g=this.data.hierarchy[o].keys[0];for(i=this.getNextKeyWith(c,o,1);i.time<n;){g=i;i=this.getNextKeyWith(c,o,i.index+1)}}else{this.stop();return}else{do{g=i;i=this.getNextKeyWith(c,o,i.index+1)}while(i.time<
+n)}h.prevKey[c]=g;h.nextKey[c]=i}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-g.time)/(i.time-g.time);d=g[c];f=i[c];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);e=e<0?0:1}if(c==="pos"){c=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",o,g.index-1).pos;this.points[1]=d;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",o,i.index+1).pos;e=e*0.33+0.33;d=this.interpolateCatmullRom(this.points,e);c.x=d[0];c.y=d[1];c.z=d[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(c==="scl"){c=a.scale;c.x=d[0]+(f[0]-d[0])*e;c.y=d[1]+(f[1]-d[1])*e;c.z=d[2]+(f[2]-d[2])*e}}}}if(this.JITCompile&&k[0][j]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o<this.hierarchy.length;o++)k[o][j]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],e=[],d,f,g,i,h,j;d=(a.length-1)*b;f=Math.floor(d);d-=f;c[0]=f==0?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];i=a[c[1]];h=a[c[2]];j=a[c[3]];c=d*d;g=d*c;e[0]=this.interpolate(f[0],i[0],h[0],j[0],d,c,g);e[1]=this.interpolate(f[1],i[1],h[1],j[1],d,c,g);e[2]=this.interpolate(f[2],i[2],h[2],j[2],d,c,g);return e};
 THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*f+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<e.length-1?c:e.length-1;else c%=e.length;for(;c<e.length;c++)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
 THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
-!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
-THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};
-THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position)}a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0;for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};
+THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;
+THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.MultiplyBlending=3;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
 THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;
@@ -124,41 +123,42 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);if(b!==-1){this.objects.splice(b,1);this.__objectsRemoved.push(a)}}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var z=h[j]=h[j]||new THREE.RenderableVertex;j++;return z}function b(z,u){return u.z-z.z}function c(z,u){var T=0,W=1,$=z.z+z.w,X=u.z+u.w,L=-z.z+z.w,U=-u.z+u.w;if($>=0&&X>=0&&L>=0&&U>=0)return!0;else if($<0&&X<0||L<0&&U<0)return!1;else{if($<0)T=Math.max(T,$/($-X));else X<0&&(W=Math.min(W,$/($-X)));if(L<0)T=Math.max(T,L/(L-U));else U<0&&(W=Math.min(W,L/(L-U)));if(W<T)return!1;else{z.lerpSelf(u,T);u.lerpSelf(z,1-W);return!0}}}var e,d,f=[],g,j,h=[],i,l,m=[],p,n=
-[],v,A,E=[],q,C,F=[],S=new THREE.Vector4,K=new THREE.Vector4,r=new THREE.Matrix4,R=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],O=new THREE.Vector4,P=new THREE.Vector4;this.projectVector=function(z,u){r.multiply(u.projectionMatrix,u.matrixWorldInverse);r.multiplyVector3(z);return z};this.unprojectVector=function(z,u){r.multiply(u.matrixWorld,THREE.Matrix4.makeInvert(u.projectionMatrix));r.multiplyVector3(z);return z};
-this.projectObjects=function(z,u,T){u=[];var W,$,X;d=0;$=z.objects;z=0;for(W=$.length;z<W;z++){X=$[z];var L;if(!(L=!X.visible))if(L=X instanceof THREE.Mesh){a:{L=void 0;for(var U=X.matrixWorld,x=-X.geometry.boundingSphere.radius*Math.max(X.scale.x,Math.max(X.scale.y,X.scale.z)),G=0;G<6;G++){L=J[G].x*U.n14+J[G].y*U.n24+J[G].z*U.n34+J[G].w;if(L<=x){L=!1;break a}}L=!0}L=!L}if(!L){L=f[d]=f[d]||new THREE.RenderableObject;d++;e=L;S.copy(X.position);r.multiplyVector3(S);e.object=X;e.z=S.z;u.push(e)}}T&&
-u.sort(b);return u};this.projectScene=function(z,u,T){var W=[],$=u.near,X=u.far,L,U,x,G,w,D,I,Y,ca,Q,aa,Ca,Ha,Ia,ma,Da,ta;C=A=p=l=0;u.matrixAutoUpdate&&u.updateMatrix();z.update(undefined,!1,u);r.multiply(u.projectionMatrix,u.matrixWorldInverse);J[0].set(r.n41-r.n11,r.n42-r.n12,r.n43-r.n13,r.n44-r.n14);J[1].set(r.n41+r.n11,r.n42+r.n12,r.n43+r.n13,r.n44+r.n14);J[2].set(r.n41+r.n21,r.n42+r.n22,r.n43+r.n23,r.n44+r.n24);J[3].set(r.n41-r.n21,r.n42-r.n22,r.n43-r.n23,r.n44-r.n24);J[4].set(r.n41-r.n31,r.n42-
-r.n32,r.n43-r.n33,r.n44-r.n34);J[5].set(r.n41+r.n31,r.n42+r.n32,r.n43+r.n33,r.n44+r.n34);for(L=0;L<6;L++){ca=J[L];ca.divideScalar(Math.sqrt(ca.x*ca.x+ca.y*ca.y+ca.z*ca.z))}ca=this.projectObjects(z,u,!0);z=0;for(L=ca.length;z<L;z++){Q=ca[z].object;if(Q.visible){aa=Q.matrixWorld;Ca=Q.matrixRotationWorld;Ha=Q.materials;Ia=Q.overdraw;j=0;if(Q instanceof THREE.Mesh){ma=Q.geometry;G=ma.vertices;Da=ma.faces;ma=ma.faceVertexUvs;U=0;for(x=G.length;U<x;U++){g=a();g.positionWorld.copy(G[U].position);aa.multiplyVector3(g.positionWorld);
-g.positionScreen.copy(g.positionWorld);r.multiplyVector4(g.positionScreen);g.positionScreen.x/=g.positionScreen.w;g.positionScreen.y/=g.positionScreen.w;g.visible=g.positionScreen.z>$&&g.positionScreen.z<X}G=0;for(U=Da.length;G<U;G++){x=Da[G];if(x instanceof THREE.Face3){w=h[x.a];D=h[x.b];I=h[x.c];if(w.visible&&D.visible&&I.visible&&(Q.doubleSided||Q.flipSided!=(I.positionScreen.x-w.positionScreen.x)*(D.positionScreen.y-w.positionScreen.y)-(I.positionScreen.y-w.positionScreen.y)*(D.positionScreen.x-
-w.positionScreen.x)<0)){Y=m[l]=m[l]||new THREE.RenderableFace3;l++;i=Y;i.v1.copy(w);i.v2.copy(D);i.v3.copy(I)}else continue}else if(x instanceof THREE.Face4){w=h[x.a];D=h[x.b];I=h[x.c];Y=h[x.d];if(w.visible&&D.visible&&I.visible&&Y.visible&&(Q.doubleSided||Q.flipSided!=((Y.positionScreen.x-w.positionScreen.x)*(D.positionScreen.y-w.positionScreen.y)-(Y.positionScreen.y-w.positionScreen.y)*(D.positionScreen.x-w.positionScreen.x)<0||(D.positionScreen.x-I.positionScreen.x)*(Y.positionScreen.y-I.positionScreen.y)-
-(D.positionScreen.y-I.positionScreen.y)*(Y.positionScreen.x-I.positionScreen.x)<0))){ta=n[p]=n[p]||new THREE.RenderableFace4;p++;i=ta;i.v1.copy(w);i.v2.copy(D);i.v3.copy(I);i.v4.copy(Y)}else continue}i.normalWorld.copy(x.normal);Ca.multiplyVector3(i.normalWorld);i.centroidWorld.copy(x.centroid);aa.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);r.multiplyVector3(i.centroidScreen);I=x.vertexNormals;w=0;for(D=I.length;w<D;w++){Y=i.vertexNormalsWorld[w];Y.copy(I[w]);Ca.multiplyVector3(Y)}w=
-0;for(D=ma.length;w<D;w++)if(ta=ma[w][G]){I=0;for(Y=ta.length;I<Y;I++)i.uvs[w][I]=ta[I]}i.meshMaterials=Ha;i.faceMaterials=x.materials;i.overdraw=Ia;i.z=i.centroidScreen.z;W.push(i)}}else if(Q instanceof THREE.Line){R.multiply(r,aa);G=Q.geometry.vertices;w=a();w.positionScreen.copy(G[0].position);R.multiplyVector4(w.positionScreen);U=1;for(x=G.length;U<x;U++){w=a();w.positionScreen.copy(G[U].position);R.multiplyVector4(w.positionScreen);D=h[j-2];O.copy(w.positionScreen);P.copy(D.positionScreen);if(c(O,
-P)){O.multiplyScalar(1/O.w);P.multiplyScalar(1/P.w);aa=E[A]=E[A]||new THREE.RenderableLine;A++;v=aa;v.v1.positionScreen.copy(O);v.v2.positionScreen.copy(P);v.z=Math.max(O.z,P.z);v.materials=Q.materials;W.push(v)}}}else if(Q instanceof THREE.Particle){K.set(Q.position.x,Q.position.y,Q.position.z,1);r.multiplyVector4(K);K.z/=K.w;if(K.z>0&&K.z<1){aa=F[C]=F[C]||new THREE.RenderableParticle;C++;q=aa;q.x=K.x/K.w;q.y=K.y/K.w;q.z=K.z;q.rotation=Q.rotation.z;q.scale.x=Q.scale.x*Math.abs(q.x-(K.x+u.projectionMatrix.n11)/
-(K.w+u.projectionMatrix.n14));q.scale.y=Q.scale.y*Math.abs(q.y-(K.y+u.projectionMatrix.n22)/(K.w+u.projectionMatrix.n24));q.materials=Q.materials;W.push(q)}}}}T&&W.sort(b);return W}};
-THREE.CanvasRenderer=function(){function a(ba){if(p!=ba)i.globalAlpha=p=ba}function b(ba){if(n!=ba){switch(ba){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}n=ba}}var c=null,e=new THREE.Projector,d=document.createElement("canvas"),f,g,j,h,i=d.getContext("2d"),l=new THREE.Color(0),m=0,p=1,n=0,v=null,A=null,E=1,q,C,F,S,K=new THREE.RenderableVertex,
-r=new THREE.RenderableVertex,R,J,O,P,z,u,T,W,$,X,L,U,x=new THREE.Color,G=new THREE.Color,w=new THREE.Color,D=new THREE.Color,I=new THREE.Color,Y,ca,Q,aa,Ca,Ha,Ia,ma,Da,ta,ya=new THREE.Rectangle,ha=new THREE.Rectangle,ga=new THREE.Rectangle,Oa=!1,da=new THREE.Color,fa=new THREE.Color,za=new THREE.Color,Aa=new THREE.Color,Z=new THREE.Vector3,Ja,Ka,Va,ia,La,Pa,Ea=16;Ja=document.createElement("canvas");Ja.width=Ja.height=2;Ka=Ja.getContext("2d");Ka.fillStyle="rgba(0,0,0,1)";Ka.fillRect(0,0,2,2);Va=Ka.getImageData(0,
-0,2,2);ia=Va.data;La=document.createElement("canvas");La.width=La.height=Ea;Pa=La.getContext("2d");Pa.translate(-Ea/2,-Ea/2);Pa.scale(Ea,Ea);Ea--;this.domElement=d;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ba,ja){f=ba;g=ja;j=f/2;h=g/2;d.width=f;d.height=g;ya.set(-j,-h,j,h);p=1;n=0;A=v=null;E=1};this.setClearColor=function(ba,ja){l=ba;m=ja};this.setClearColorHex=function(ba,ja){l.setHex(ba);m=ja};this.clear=function(){i.setTransform(1,0,0,-1,j,h);if(!ha.isEmpty()){ha.inflate(1);
-ha.minSelf(ya);if(l.hex==0&&m==0)i.clearRect(ha.getX(),ha.getY(),ha.getWidth(),ha.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(l.r*255)+","+Math.floor(l.g*255)+","+Math.floor(l.b*255)+","+m+")";i.fillRect(ha.getX(),ha.getY(),ha.getWidth(),ha.getHeight())}ha.empty()}};this.render=function(ba,ja){function Ya(k){var B,t,s,M=k.lights;fa.setRGB(0,0,0);za.setRGB(0,0,0);Aa.setRGB(0,0,0);k=0;for(B=M.length;k<B;k++){t=M[k];s=t.color;if(t instanceof THREE.AmbientLight){fa.r+=
-s.r;fa.g+=s.g;fa.b+=s.b}else if(t instanceof THREE.DirectionalLight){za.r+=s.r;za.g+=s.g;za.b+=s.b}else if(t instanceof THREE.PointLight){Aa.r+=s.r;Aa.g+=s.g;Aa.b+=s.b}}}function oa(k,B,t,s){var M,H,y,o,V=k.lights;k=0;for(M=V.length;k<M;k++){H=V[k];y=H.color;o=H.intensity;if(H instanceof THREE.DirectionalLight){H=t.dot(H.position)*o;if(H>0){s.r+=y.r*H;s.g+=y.g*H;s.b+=y.b*H}}else if(H instanceof THREE.PointLight){Z.sub(H.position,B);Z.normalize();H=t.dot(Z)*o;if(H>0){s.r+=y.r*H;s.g+=y.g*H;s.b+=y.b*
-H}}}}function Za(k,B,t){a(t.opacity);b(t.blending);var s,M,H,y,o,V;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){y=t.map.image;o=y.width>>1;V=y.height>>1;t=B.scale.x*j;H=B.scale.y*h;s=t*o;M=H*V;ga.set(k.x-s,k.y-M,k.x+s,k.y+M);if(ya.instersects(ga)){i.save();i.translate(k.x,k.y);i.rotate(-B.rotation);i.scale(t,-H);i.translate(-o,-V);i.drawImage(y,0,0);i.restore()}}}else if(t instanceof THREE.ParticleCanvasMaterial){if(Oa){da.r=fa.r+za.r+Aa.r;da.g=fa.g+za.g+Aa.g;da.b=fa.b+za.b+Aa.b;x.r=t.color.r*
-da.r;x.g=t.color.g*da.g;x.b=t.color.b*da.b;x.updateStyleString()}else x.__styleString=t.color.__styleString;s=B.scale.x*j;M=B.scale.y*h;ga.set(k.x-s,k.y-M,k.x+s,k.y+M);if(ya.instersects(ga)){i.save();i.translate(k.x,k.y);i.rotate(-B.rotation);i.scale(s,M);t.program(i,x);i.restore()}}}function $a(k,B,t,s){a(s.opacity);b(s.blending);i.beginPath();i.moveTo(k.positionScreen.x,k.positionScreen.y);i.lineTo(B.positionScreen.x,B.positionScreen.y);i.closePath();if(s instanceof THREE.LineBasicMaterial){x.__styleString=
-s.color.__styleString;k=s.linewidth;if(E!=k)i.lineWidth=E=k;k=x.__styleString;if(v!=k)i.strokeStyle=v=k;i.stroke();ga.inflate(s.linewidth*2)}}function Qa(k,B,t,s,M,H,y,o,V){a(o.opacity);b(o.blending);R=k.positionScreen.x;J=k.positionScreen.y;O=B.positionScreen.x;P=B.positionScreen.y;z=t.positionScreen.x;u=t.positionScreen.y;Ma(R,J,O,P,z,u);if(o instanceof THREE.MeshBasicMaterial)if(o.map){if(o.map.mapping instanceof THREE.UVMapping){aa=y.uvs[0];pa(R,J,O,P,z,u,o.map.image,aa[s].u,aa[s].v,aa[M].u,aa[M].v,
-aa[H].u,aa[H].v)}}else if(o.envMap){if(o.envMap.mapping instanceof THREE.SphericalReflectionMapping){k=ja.matrixWorldInverse;Z.copy(y.vertexNormalsWorld[0]);Ca=(Z.x*k.n11+Z.y*k.n12+Z.z*k.n13)*0.5+0.5;Ha=-(Z.x*k.n21+Z.y*k.n22+Z.z*k.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[1]);Ia=(Z.x*k.n11+Z.y*k.n12+Z.z*k.n13)*0.5+0.5;ma=-(Z.x*k.n21+Z.y*k.n22+Z.z*k.n23)*0.5+0.5;Z.copy(y.vertexNormalsWorld[2]);Da=(Z.x*k.n11+Z.y*k.n12+Z.z*k.n13)*0.5+0.5;ta=-(Z.x*k.n21+Z.y*k.n22+Z.z*k.n23)*0.5+0.5;pa(R,J,O,P,z,u,o.envMap.image,
-Ca,Ha,Ia,ma,Da,ta)}}else o.wireframe?ua(o.color.__styleString,o.wireframeLinewidth):va(o.color.__styleString);else if(o instanceof THREE.MeshLambertMaterial){if(o.map&&!o.wireframe){if(o.map.mapping instanceof THREE.UVMapping){aa=y.uvs[0];pa(R,J,O,P,z,u,o.map.image,aa[s].u,aa[s].v,aa[M].u,aa[M].v,aa[H].u,aa[H].v)}b(THREE.SubtractiveBlending)}if(Oa)if(!o.wireframe&&o.shading==THREE.SmoothShading&&y.vertexNormalsWorld.length==3){G.r=w.r=D.r=fa.r;G.g=w.g=D.g=fa.g;G.b=w.b=D.b=fa.b;oa(V,y.v1.positionWorld,
-y.vertexNormalsWorld[0],G);oa(V,y.v2.positionWorld,y.vertexNormalsWorld[1],w);oa(V,y.v3.positionWorld,y.vertexNormalsWorld[2],D);I.r=(w.r+D.r)*0.5;I.g=(w.g+D.g)*0.5;I.b=(w.b+D.b)*0.5;Q=Ra(G,w,D,I);pa(R,J,O,P,z,u,Q,0,0,1,0,0,1)}else{da.r=fa.r;da.g=fa.g;da.b=fa.b;oa(V,y.centroidWorld,y.normalWorld,da);x.r=o.color.r*da.r;x.g=o.color.g*da.g;x.b=o.color.b*da.b;x.updateStyleString();o.wireframe?ua(x.__styleString,o.wireframeLinewidth):va(x.__styleString)}else o.wireframe?ua(o.color.__styleString,o.wireframeLinewidth):
-va(o.color.__styleString)}else if(o instanceof THREE.MeshDepthMaterial){Y=ja.near;ca=ja.far;G.r=G.g=G.b=1-Ba(k.positionScreen.z,Y,ca);w.r=w.g=w.b=1-Ba(B.positionScreen.z,Y,ca);D.r=D.g=D.b=1-Ba(t.positionScreen.z,Y,ca);I.r=(w.r+D.r)*0.5;I.g=(w.g+D.g)*0.5;I.b=(w.b+D.b)*0.5;Q=Ra(G,w,D,I);pa(R,J,O,P,z,u,Q,0,0,1,0,0,1)}else if(o instanceof THREE.MeshNormalMaterial){x.r=Fa(y.normalWorld.x);x.g=Fa(y.normalWorld.y);x.b=Fa(y.normalWorld.z);x.updateStyleString();o.wireframe?ua(x.__styleString,o.wireframeLinewidth):
-va(x.__styleString)}}function Wa(k,B,t,s,M,H,y,o,V){a(o.opacity);b(o.blending);if(o.map||o.envMap){Qa(k,B,s,0,1,3,y,o,V);Qa(M,t,H,1,2,3,y,o,V)}else{R=k.positionScreen.x;J=k.positionScreen.y;O=B.positionScreen.x;P=B.positionScreen.y;z=t.positionScreen.x;u=t.positionScreen.y;T=s.positionScreen.x;W=s.positionScreen.y;$=M.positionScreen.x;X=M.positionScreen.y;L=H.positionScreen.x;U=H.positionScreen.y;if(o instanceof THREE.MeshBasicMaterial){Sa(R,J,O,P,z,u,T,W);o.wireframe?ua(o.color.__styleString,o.wireframeLinewidth):
-va(o.color.__styleString)}else if(o instanceof THREE.MeshLambertMaterial)if(Oa)if(!o.wireframe&&o.shading==THREE.SmoothShading&&y.vertexNormalsWorld.length==4){G.r=w.r=D.r=I.r=fa.r;G.g=w.g=D.g=I.g=fa.g;G.b=w.b=D.b=I.b=fa.b;oa(V,y.v1.positionWorld,y.vertexNormalsWorld[0],G);oa(V,y.v2.positionWorld,y.vertexNormalsWorld[1],w);oa(V,y.v4.positionWorld,y.vertexNormalsWorld[3],D);oa(V,y.v3.positionWorld,y.vertexNormalsWorld[2],I);Q=Ra(G,w,D,I);Ma(R,J,O,P,T,W);pa(R,J,O,P,T,W,Q,0,0,1,0,0,1);Ma($,X,z,u,L,U);
-pa($,X,z,u,L,U,Q,1,0,1,1,0,1)}else{da.r=fa.r;da.g=fa.g;da.b=fa.b;oa(V,y.centroidWorld,y.normalWorld,da);x.r=o.color.r*da.r;x.g=o.color.g*da.g;x.b=o.color.b*da.b;x.updateStyleString();Sa(R,J,O,P,z,u,T,W);o.wireframe?ua(x.__styleString,o.wireframeLinewidth):va(x.__styleString)}else{Sa(R,J,O,P,z,u,T,W);o.wireframe?ua(o.color.__styleString,o.wireframeLinewidth):va(o.color.__styleString)}else if(o instanceof THREE.MeshNormalMaterial){x.r=Fa(y.normalWorld.x);x.g=Fa(y.normalWorld.y);x.b=Fa(y.normalWorld.z);
-x.updateStyleString();Sa(R,J,O,P,z,u,T,W);o.wireframe?ua(x.__styleString,o.wireframeLinewidth):va(x.__styleString)}else if(o instanceof THREE.MeshDepthMaterial){Y=ja.near;ca=ja.far;G.r=G.g=G.b=1-Ba(k.positionScreen.z,Y,ca);w.r=w.g=w.b=1-Ba(B.positionScreen.z,Y,ca);D.r=D.g=D.b=1-Ba(s.positionScreen.z,Y,ca);I.r=I.g=I.b=1-Ba(t.positionScreen.z,Y,ca);Q=Ra(G,w,D,I);Ma(R,J,O,P,T,W);pa(R,J,O,P,T,W,Q,0,0,1,0,0,1);Ma($,X,z,u,L,U);pa($,X,z,u,L,U,Q,1,0,1,1,0,1)}}}function Ma(k,B,t,s,M,H){i.beginPath();i.moveTo(k,
-B);i.lineTo(t,s);i.lineTo(M,H);i.lineTo(k,B);i.closePath()}function Sa(k,B,t,s,M,H,y,o){i.beginPath();i.moveTo(k,B);i.lineTo(t,s);i.lineTo(M,H);i.lineTo(y,o);i.lineTo(k,B);i.closePath()}function ua(k,B){if(v!=k)i.strokeStyle=v=k;if(E!=B)i.lineWidth=E=B;i.stroke();ga.inflate(B*2)}function va(k){if(A!=k)i.fillStyle=A=k;i.fill()}function pa(k,B,t,s,M,H,y,o,V,qa,ka,ra,Na){var na,sa;na=y.width-1;sa=y.height-1;o*=na;V*=sa;qa*=na;ka*=sa;ra*=na;Na*=sa;t-=k;s-=B;M-=k;H-=B;qa-=o;ka-=V;ra-=o;Na-=V;na=qa*Na-
-ra*ka;if(na!=0){sa=1/na;na=(Na*t-ka*M)*sa;ka=(Na*s-ka*H)*sa;t=(qa*M-ra*t)*sa;s=(qa*H-ra*s)*sa;k=k-na*o-t*V;B=B-ka*o-s*V;i.save();i.transform(na,ka,t,s,k,B);i.clip();i.drawImage(y,0,0);i.restore()}}function Ra(k,B,t,s){var M=~~(k.r*255),H=~~(k.g*255);k=~~(k.b*255);var y=~~(B.r*255),o=~~(B.g*255);B=~~(B.b*255);var V=~~(t.r*255),qa=~~(t.g*255);t=~~(t.b*255);var ka=~~(s.r*255),ra=~~(s.g*255);s=~~(s.b*255);ia[0]=M<0?0:M>255?255:M;ia[1]=H<0?0:H>255?255:H;ia[2]=k<0?0:k>255?255:k;ia[4]=y<0?0:y>255?255:y;
-ia[5]=o<0?0:o>255?255:o;ia[6]=B<0?0:B>255?255:B;ia[8]=V<0?0:V>255?255:V;ia[9]=qa<0?0:qa>255?255:qa;ia[10]=t<0?0:t>255?255:t;ia[12]=ka<0?0:ka>255?255:ka;ia[13]=ra<0?0:ra>255?255:ra;ia[14]=s<0?0:s>255?255:s;Ka.putImageData(Va,0,0);Pa.drawImage(Ja,0,0);return La}function Ba(k,B,t){k=(k-B)/(t-B);return k*k*(3-2*k)}function Fa(k){k=(k+1)*0.5;return k<0?0:k>1?1:k}function wa(k,B){var t=B.x-k.x,s=B.y-k.y,M=1/Math.sqrt(t*t+s*s);t*=M;s*=M;B.x+=t;B.y+=s;k.x-=t;k.y-=s}var Ta,Xa,N,la,xa,Ga,Ua,ea;this.autoClear?
-this.clear():i.setTransform(1,0,0,-1,j,h);c=e.projectScene(ba,ja,this.sortElements);(Oa=ba.lights.length>0)&&Ya(ba);Ta=0;for(Xa=c.length;Ta<Xa;Ta++){N=c[Ta];ga.empty();if(N instanceof THREE.RenderableParticle){q=N;q.x*=j;q.y*=h;la=0;for(xa=N.materials.length;la<xa;){ea=N.materials[la++];ea.opacity!=0&&Za(q,N,ea,ba)}}else if(N instanceof THREE.RenderableLine){q=N.v1;C=N.v2;q.positionScreen.x*=j;q.positionScreen.y*=h;C.positionScreen.x*=j;C.positionScreen.y*=h;ga.addPoint(q.positionScreen.x,q.positionScreen.y);
-ga.addPoint(C.positionScreen.x,C.positionScreen.y);if(ya.instersects(ga)){la=0;for(xa=N.materials.length;la<xa;){ea=N.materials[la++];ea.opacity!=0&&$a(q,C,N,ea,ba)}}}else if(N instanceof THREE.RenderableFace3){q=N.v1;C=N.v2;F=N.v3;q.positionScreen.x*=j;q.positionScreen.y*=h;C.positionScreen.x*=j;C.positionScreen.y*=h;F.positionScreen.x*=j;F.positionScreen.y*=h;if(N.overdraw){wa(q.positionScreen,C.positionScreen);wa(C.positionScreen,F.positionScreen);wa(F.positionScreen,q.positionScreen)}ga.add3Points(q.positionScreen.x,
-q.positionScreen.y,C.positionScreen.x,C.positionScreen.y,F.positionScreen.x,F.positionScreen.y);if(ya.instersects(ga)){la=0;for(xa=N.meshMaterials.length;la<xa;){ea=N.meshMaterials[la++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ua=N.faceMaterials.length;Ga<Ua;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&Qa(q,C,F,0,1,2,N,ea,ba)}else ea.opacity!=0&&Qa(q,C,F,0,1,2,N,ea,ba)}}}else if(N instanceof THREE.RenderableFace4){q=N.v1;C=N.v2;F=N.v3;S=N.v4;q.positionScreen.x*=j;q.positionScreen.y*=h;C.positionScreen.x*=
-j;C.positionScreen.y*=h;F.positionScreen.x*=j;F.positionScreen.y*=h;S.positionScreen.x*=j;S.positionScreen.y*=h;K.positionScreen.copy(C.positionScreen);r.positionScreen.copy(S.positionScreen);if(N.overdraw){wa(q.positionScreen,C.positionScreen);wa(C.positionScreen,S.positionScreen);wa(S.positionScreen,q.positionScreen);wa(F.positionScreen,K.positionScreen);wa(F.positionScreen,r.positionScreen)}ga.addPoint(q.positionScreen.x,q.positionScreen.y);ga.addPoint(C.positionScreen.x,C.positionScreen.y);ga.addPoint(F.positionScreen.x,
-F.positionScreen.y);ga.addPoint(S.positionScreen.x,S.positionScreen.y);if(ya.instersects(ga)){la=0;for(xa=N.meshMaterials.length;la<xa;){ea=N.meshMaterials[la++];if(ea instanceof THREE.MeshFaceMaterial){Ga=0;for(Ua=N.faceMaterials.length;Ga<Ua;)(ea=N.faceMaterials[Ga++])&&ea.opacity!=0&&Wa(q,C,F,S,K,r,N,ea,ba)}else ea.opacity!=0&&Wa(q,C,F,S,K,r,N,ea,ba)}}}ha.addRectangle(ga)}i.setTransform(1,0,0,1,0,0)}};
+THREE.Projector=function(){function a(){var w=h[i]=h[i]||new THREE.RenderableVertex;i++;return w}function b(w,s){return s.z-w.z}function c(w,s){var L=0,W=1,X=w.z+w.w,Y=s.z+s.w,M=-w.z+w.w,T=-s.z+s.w;if(X>=0&&Y>=0&&M>=0&&T>=0)return!0;else if(X<0&&Y<0||M<0&&T<0)return!1;else{if(X<0)L=Math.max(L,X/(X-Y));else Y<0&&(W=Math.min(W,X/(X-Y)));if(M<0)L=Math.max(L,M/(M-T));else T<0&&(W=Math.min(W,M/(M-T)));if(W<L)return!1;else{w.lerpSelf(s,L);s.lerpSelf(w,1-W);return!0}}}var e,d,f=[],g,i,h=[],j,k,n=[],p,o=
+[],v,y,G=[],B,z,D=[],I=new THREE.Vector4,H=new THREE.Vector4,q=new THREE.Matrix4,aa=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],P=new THREE.Vector4,Q=new THREE.Vector4;this.projectVector=function(w,s){q.multiply(s.projectionMatrix,s.matrixWorldInverse);q.multiplyVector3(w);return w};this.unprojectVector=function(w,s){q.multiply(s.matrixWorld,THREE.Matrix4.makeInvert(s.projectionMatrix));q.multiplyVector3(w);return w};
+this.projectObjects=function(w,s,L){s=[];var W,X,Y;d=0;X=w.objects;w=0;for(W=X.length;w<W;w++){Y=X[w];var M;if(!(M=!Y.visible))if(M=Y instanceof THREE.Mesh){a:{M=void 0;for(var T=Y.matrixWorld,U=-Y.geometry.boundingSphere.radius*Math.max(Y.scale.x,Math.max(Y.scale.y,Y.scale.z)),C=0;C<6;C++){M=K[C].x*T.n14+K[C].y*T.n24+K[C].z*T.n34+K[C].w;if(M<=U){M=!1;break a}}M=!0}M=!M}if(!M){M=f[d]=f[d]||new THREE.RenderableObject;d++;e=M;I.copy(Y.position);q.multiplyVector3(I);e.object=Y;e.z=I.z;s.push(e)}}L&&
+s.sort(b);return s};this.projectScene=function(w,s,L){var W=[],X=s.near,Y=s.far,M,T,U,C,A,F,E,S,ba,R,da,ea,Fa,Ga,na,Ba,ua;z=y=p=k=0;s.matrixAutoUpdate&&s.updateMatrix();w.update(undefined,!1,s);q.multiply(s.projectionMatrix,s.matrixWorldInverse);K[0].set(q.n41-q.n11,q.n42-q.n12,q.n43-q.n13,q.n44-q.n14);K[1].set(q.n41+q.n11,q.n42+q.n12,q.n43+q.n13,q.n44+q.n14);K[2].set(q.n41+q.n21,q.n42+q.n22,q.n43+q.n23,q.n44+q.n24);K[3].set(q.n41-q.n21,q.n42-q.n22,q.n43-q.n23,q.n44-q.n24);K[4].set(q.n41-q.n31,q.n42-
+q.n32,q.n43-q.n33,q.n44-q.n34);K[5].set(q.n41+q.n31,q.n42+q.n32,q.n43+q.n33,q.n44+q.n34);for(M=0;M<6;M++){ba=K[M];ba.divideScalar(Math.sqrt(ba.x*ba.x+ba.y*ba.y+ba.z*ba.z))}ba=this.projectObjects(w,s,!0);w=0;for(M=ba.length;w<M;w++){R=ba[w].object;if(R.visible){da=R.matrixWorld;ea=R.matrixRotationWorld;Fa=R.materials;Ga=R.overdraw;i=0;if(R instanceof THREE.Mesh){na=R.geometry;C=na.vertices;Ba=na.faces;na=na.faceVertexUvs;T=0;for(U=C.length;T<U;T++){g=a();g.positionWorld.copy(C[T].position);da.multiplyVector3(g.positionWorld);
+g.positionScreen.copy(g.positionWorld);q.multiplyVector4(g.positionScreen);g.positionScreen.x/=g.positionScreen.w;g.positionScreen.y/=g.positionScreen.w;g.visible=g.positionScreen.z>X&&g.positionScreen.z<Y}C=0;for(T=Ba.length;C<T;C++){U=Ba[C];if(U instanceof THREE.Face3){A=h[U.a];F=h[U.b];E=h[U.c];if(A.visible&&F.visible&&E.visible&&(R.doubleSided||R.flipSided!=(E.positionScreen.x-A.positionScreen.x)*(F.positionScreen.y-A.positionScreen.y)-(E.positionScreen.y-A.positionScreen.y)*(F.positionScreen.x-
+A.positionScreen.x)<0)){S=n[k]=n[k]||new THREE.RenderableFace3;k++;j=S;j.v1.copy(A);j.v2.copy(F);j.v3.copy(E)}else continue}else if(U instanceof THREE.Face4){A=h[U.a];F=h[U.b];E=h[U.c];S=h[U.d];if(A.visible&&F.visible&&E.visible&&S.visible&&(R.doubleSided||R.flipSided!=((S.positionScreen.x-A.positionScreen.x)*(F.positionScreen.y-A.positionScreen.y)-(S.positionScreen.y-A.positionScreen.y)*(F.positionScreen.x-A.positionScreen.x)<0||(F.positionScreen.x-E.positionScreen.x)*(S.positionScreen.y-E.positionScreen.y)-
+(F.positionScreen.y-E.positionScreen.y)*(S.positionScreen.x-E.positionScreen.x)<0))){ua=o[p]=o[p]||new THREE.RenderableFace4;p++;j=ua;j.v1.copy(A);j.v2.copy(F);j.v3.copy(E);j.v4.copy(S)}else continue}j.normalWorld.copy(U.normal);ea.multiplyVector3(j.normalWorld);j.centroidWorld.copy(U.centroid);da.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);q.multiplyVector3(j.centroidScreen);E=U.vertexNormals;A=0;for(F=E.length;A<F;A++){S=j.vertexNormalsWorld[A];S.copy(E[A]);ea.multiplyVector3(S)}A=
+0;for(F=na.length;A<F;A++)if(ua=na[A][C]){E=0;for(S=ua.length;E<S;E++)j.uvs[A][E]=ua[E]}j.meshMaterials=Fa;j.faceMaterials=U.materials;j.overdraw=Ga;j.z=j.centroidScreen.z;W.push(j)}}else if(R instanceof THREE.Line){aa.multiply(q,da);C=R.geometry.vertices;A=a();A.positionScreen.copy(C[0].position);aa.multiplyVector4(A.positionScreen);T=1;for(U=C.length;T<U;T++){A=a();A.positionScreen.copy(C[T].position);aa.multiplyVector4(A.positionScreen);F=h[i-2];P.copy(A.positionScreen);Q.copy(F.positionScreen);
+if(c(P,Q)){P.multiplyScalar(1/P.w);Q.multiplyScalar(1/Q.w);da=G[y]=G[y]||new THREE.RenderableLine;y++;v=da;v.v1.positionScreen.copy(P);v.v2.positionScreen.copy(Q);v.z=Math.max(P.z,Q.z);v.materials=R.materials;W.push(v)}}}else if(R instanceof THREE.Particle){H.set(R.position.x,R.position.y,R.position.z,1);q.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){da=D[z]=D[z]||new THREE.RenderableParticle;z++;B=da;B.x=H.x/H.w;B.y=H.y/H.w;B.z=H.z;B.rotation=R.rotation.z;B.scale.x=R.scale.x*Math.abs(B.x-(H.x+s.projectionMatrix.n11)/
+(H.w+s.projectionMatrix.n14));B.scale.y=R.scale.y*Math.abs(B.y-(H.y+s.projectionMatrix.n22)/(H.w+s.projectionMatrix.n24));B.materials=R.materials;W.push(B)}}}}L&&W.sort(b);return W}};
+THREE.CanvasRenderer=function(){function a(Z){if(o!=Z)k.globalAlpha=o=Z}function b(Z){if(v!=Z){switch(Z){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}v=Z}}function c(Z){if(y!=Z)k.strokeStyle=y=Z}var e=null,d=new THREE.Projector,f=document.createElement("canvas"),g,i,h,j,k=f.getContext("2d"),n=new THREE.Color(0),p=0,o=1,v=0,y=null,G=null,
+B=1,z,D,I,H,q=new THREE.RenderableVertex,aa=new THREE.RenderableVertex,K,P,Q,w,s,L,W,X,Y,M,T,U,C=new THREE.Color,A=new THREE.Color,F=new THREE.Color,E=new THREE.Color,S=new THREE.Color,ba,R,da,ea,Fa,Ga,na,Ba,ua,Wa,za=new THREE.Rectangle,ia=new THREE.Rectangle,fa=new THREE.Rectangle,Ua=!1,ha=new THREE.Color,ga=new THREE.Color,Ma=new THREE.Color,Na=new THREE.Color,$=new THREE.Vector3,Ha,Ia,Va,ja,Ja,Oa,Ca=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ia=Ha.getContext("2d");Ia.fillStyle=
+"rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Va=Ia.getImageData(0,0,2,2);ja=Va.data;Ja=document.createElement("canvas");Ja.width=Ja.height=Ca;Oa=Ja.getContext("2d");Oa.translate(-Ca/2,-Ca/2);Oa.scale(Ca,Ca);Ca--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(Z,ka){g=Z;i=ka;h=g/2;j=i/2;f.width=g;f.height=i;za.set(-h,-j,h,j);o=1;v=0;G=y=null;B=1};this.setClearColor=function(Z,ka){n=Z;p=ka};this.setClearColorHex=function(Z,ka){n.setHex(Z);p=ka};this.clear=
+function(){k.setTransform(1,0,0,-1,h,j);if(!ia.isEmpty()){ia.inflate(1);ia.minSelf(za);if(n.hex==0&&p==0)k.clearRect(ia.getX(),ia.getY(),ia.getWidth(),ia.getHeight());else{b(THREE.NormalBlending);a(1);k.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+p+")";k.fillRect(ia.getX(),ia.getY(),ia.getWidth(),ia.getHeight())}ia.empty()}};this.render=function(Z,ka){function Za(l){var x,t,r,N=l.lights;ga.setRGB(0,0,0);Ma.setRGB(0,0,0);Na.setRGB(0,0,0);l=0;for(x=N.length;l<
+x;l++){t=N[l];r=t.color;if(t instanceof THREE.AmbientLight){ga.r+=r.r;ga.g+=r.g;ga.b+=r.b}else if(t instanceof THREE.DirectionalLight){Ma.r+=r.r;Ma.g+=r.g;Ma.b+=r.b}else if(t instanceof THREE.PointLight){Na.r+=r.r;Na.g+=r.g;Na.b+=r.b}}}function pa(l,x,t,r){var N,J,u,m,V=l.lights;l=0;for(N=V.length;l<N;l++){J=V[l];u=J.color;if(J instanceof THREE.DirectionalLight){m=t.dot(J.position);if(!(m<=0)){m*=J.intensity;r.r+=u.r*m;r.g+=u.g*m;r.b+=u.b*m}}else if(J instanceof THREE.PointLight){m=t.dot($.sub(J.position,
+x).normalize());if(!(m<=0)){m*=J.distance==0?1:1-Math.min(x.distanceTo(J.position)/J.distance,1);if(m!=0){m*=J.intensity;r.r+=u.r*m;r.g+=u.g*m;r.b+=u.b*m}}}}}function $a(l,x,t){a(t.opacity);b(t.blending);var r,N,J,u,m,V;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){u=t.map.image;m=u.width>>1;V=u.height>>1;t=x.scale.x*h;J=x.scale.y*j;r=t*m;N=J*V;fa.set(l.x-r,l.y-N,l.x+r,l.y+N);if(za.instersects(fa)){k.save();k.translate(l.x,l.y);k.rotate(-x.rotation);k.scale(t,-J);k.translate(-m,-V);k.drawImage(u,
+0,0);k.restore()}}}else if(t instanceof THREE.ParticleCanvasMaterial){r=x.scale.x*h;N=x.scale.y*j;fa.set(l.x-r,l.y-N,l.x+r,l.y+N);if(za.instersects(fa)){c(t.color.__styleString);J=t.color.__styleString;if(G!=J)k.fillStyle=G=J;k.save();k.translate(l.x,l.y);k.rotate(-x.rotation);k.scale(r,N);t.program(k);k.restore()}}}function ab(l,x,t,r){a(r.opacity);b(r.blending);k.beginPath();k.moveTo(l.positionScreen.x,l.positionScreen.y);k.lineTo(x.positionScreen.x,x.positionScreen.y);k.closePath();if(r instanceof
+THREE.LineBasicMaterial){C.__styleString=r.color.__styleString;l=r.linewidth;if(B!=l)k.lineWidth=B=l;c(C.__styleString);k.stroke();fa.inflate(r.linewidth*2)}}function Pa(l,x,t,r,N,J,u,m,V){a(m.opacity);b(m.blending);K=l.positionScreen.x;P=l.positionScreen.y;Q=x.positionScreen.x;w=x.positionScreen.y;s=t.positionScreen.x;L=t.positionScreen.y;Ka(K,P,Q,w,s,L);if(m instanceof THREE.MeshBasicMaterial)if(m.map){if(m.map.mapping instanceof THREE.UVMapping){ea=u.uvs[0];qa(K,P,Q,w,s,L,m.map.image,ea[r].u,ea[r].v,
+ea[N].u,ea[N].v,ea[J].u,ea[J].v)}}else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=ka.matrixWorldInverse;$.copy(u.vertexNormalsWorld[0]);Fa=($.x*l.n11+$.y*l.n12+$.z*l.n13)*0.5+0.5;Ga=-($.x*l.n21+$.y*l.n22+$.z*l.n23)*0.5+0.5;$.copy(u.vertexNormalsWorld[1]);na=($.x*l.n11+$.y*l.n12+$.z*l.n13)*0.5+0.5;Ba=-($.x*l.n21+$.y*l.n22+$.z*l.n23)*0.5+0.5;$.copy(u.vertexNormalsWorld[2]);ua=($.x*l.n11+$.y*l.n12+$.z*l.n13)*0.5+0.5;Wa=-($.x*l.n21+$.y*l.n22+$.z*l.n23)*0.5+0.5;qa(K,
+P,Q,w,s,L,m.envMap.image,Fa,Ga,na,Ba,ua,Wa)}}else m.wireframe?va(m.color.__styleString,m.wireframeLinewidth):wa(m.color.__styleString);else if(m instanceof THREE.MeshLambertMaterial){if(m.map&&!m.wireframe){if(m.map.mapping instanceof THREE.UVMapping){ea=u.uvs[0];qa(K,P,Q,w,s,L,m.map.image,ea[r].u,ea[r].v,ea[N].u,ea[N].v,ea[J].u,ea[J].v)}b(THREE.SubtractiveBlending)}if(Ua)if(!m.wireframe&&m.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3){A.r=F.r=E.r=ga.r;A.g=F.g=E.g=ga.g;A.b=F.b=E.b=
+ga.b;pa(V,u.v1.positionWorld,u.vertexNormalsWorld[0],A);pa(V,u.v2.positionWorld,u.vertexNormalsWorld[1],F);pa(V,u.v3.positionWorld,u.vertexNormalsWorld[2],E);S.r=(F.r+E.r)*0.5;S.g=(F.g+E.g)*0.5;S.b=(F.b+E.b)*0.5;da=Qa(A,F,E,S);qa(K,P,Q,w,s,L,da,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;pa(V,u.centroidWorld,u.normalWorld,ha);C.r=m.color.r*ha.r;C.g=m.color.g*ha.g;C.b=m.color.b*ha.b;C.updateStyleString();m.wireframe?va(C.__styleString,m.wireframeLinewidth):wa(C.__styleString)}else m.wireframe?
+va(m.color.__styleString,m.wireframeLinewidth):wa(m.color.__styleString)}else if(m instanceof THREE.MeshDepthMaterial){ba=ka.near;R=ka.far;A.r=A.g=A.b=1-Aa(l.positionScreen.z,ba,R);F.r=F.g=F.b=1-Aa(x.positionScreen.z,ba,R);E.r=E.g=E.b=1-Aa(t.positionScreen.z,ba,R);S.r=(F.r+E.r)*0.5;S.g=(F.g+E.g)*0.5;S.b=(F.b+E.b)*0.5;da=Qa(A,F,E,S);qa(K,P,Q,w,s,L,da,0,0,1,0,0,1)}else if(m instanceof THREE.MeshNormalMaterial){C.r=Da(u.normalWorld.x);C.g=Da(u.normalWorld.y);C.b=Da(u.normalWorld.z);C.updateStyleString();
+m.wireframe?va(C.__styleString,m.wireframeLinewidth):wa(C.__styleString)}}function Xa(l,x,t,r,N,J,u,m,V){a(m.opacity);b(m.blending);if(m.map||m.envMap){Pa(l,x,r,0,1,3,u,m,V);Pa(N,t,J,1,2,3,u,m,V)}else{K=l.positionScreen.x;P=l.positionScreen.y;Q=x.positionScreen.x;w=x.positionScreen.y;s=t.positionScreen.x;L=t.positionScreen.y;W=r.positionScreen.x;X=r.positionScreen.y;Y=N.positionScreen.x;M=N.positionScreen.y;T=J.positionScreen.x;U=J.positionScreen.y;if(m instanceof THREE.MeshBasicMaterial){Ra(K,P,
+Q,w,s,L,W,X);m.wireframe?va(m.color.__styleString,m.wireframeLinewidth):wa(m.color.__styleString)}else if(m instanceof THREE.MeshLambertMaterial)if(Ua)if(!m.wireframe&&m.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==4){A.r=F.r=E.r=S.r=ga.r;A.g=F.g=E.g=S.g=ga.g;A.b=F.b=E.b=S.b=ga.b;pa(V,u.v1.positionWorld,u.vertexNormalsWorld[0],A);pa(V,u.v2.positionWorld,u.vertexNormalsWorld[1],F);pa(V,u.v4.positionWorld,u.vertexNormalsWorld[3],E);pa(V,u.v3.positionWorld,u.vertexNormalsWorld[2],S);da=
+Qa(A,F,E,S);Ka(K,P,Q,w,W,X);qa(K,P,Q,w,W,X,da,0,0,1,0,0,1);Ka(Y,M,s,L,T,U);qa(Y,M,s,L,T,U,da,1,0,1,1,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;pa(V,u.centroidWorld,u.normalWorld,ha);C.r=m.color.r*ha.r;C.g=m.color.g*ha.g;C.b=m.color.b*ha.b;C.updateStyleString();Ra(K,P,Q,w,s,L,W,X);m.wireframe?va(C.__styleString,m.wireframeLinewidth):wa(C.__styleString)}else{Ra(K,P,Q,w,s,L,W,X);m.wireframe?va(m.color.__styleString,m.wireframeLinewidth):wa(m.color.__styleString)}else if(m instanceof THREE.MeshNormalMaterial){C.r=
+Da(u.normalWorld.x);C.g=Da(u.normalWorld.y);C.b=Da(u.normalWorld.z);C.updateStyleString();Ra(K,P,Q,w,s,L,W,X);m.wireframe?va(C.__styleString,m.wireframeLinewidth):wa(C.__styleString)}else if(m instanceof THREE.MeshDepthMaterial){ba=ka.near;R=ka.far;A.r=A.g=A.b=1-Aa(l.positionScreen.z,ba,R);F.r=F.g=F.b=1-Aa(x.positionScreen.z,ba,R);E.r=E.g=E.b=1-Aa(r.positionScreen.z,ba,R);S.r=S.g=S.b=1-Aa(t.positionScreen.z,ba,R);da=Qa(A,F,E,S);Ka(K,P,Q,w,W,X);qa(K,P,Q,w,W,X,da,0,0,1,0,0,1);Ka(Y,M,s,L,T,U);qa(Y,M,
+s,L,T,U,da,1,0,1,1,0,1)}}}function Ka(l,x,t,r,N,J){k.beginPath();k.moveTo(l,x);k.lineTo(t,r);k.lineTo(N,J);k.lineTo(l,x);k.closePath()}function Ra(l,x,t,r,N,J,u,m){k.beginPath();k.moveTo(l,x);k.lineTo(t,r);k.lineTo(N,J);k.lineTo(u,m);k.lineTo(l,x);k.closePath()}function va(l,x){c(l);if(B!=x)k.lineWidth=B=x;k.stroke();fa.inflate(x*2)}function wa(l){if(G!=l)k.fillStyle=G=l;k.fill()}function qa(l,x,t,r,N,J,u,m,V,ra,la,sa,La){var oa,ta;oa=u.width-1;ta=u.height-1;m*=oa;V*=ta;ra*=oa;la*=ta;sa*=oa;La*=ta;
+t-=l;r-=x;N-=l;J-=x;ra-=m;la-=V;sa-=m;La-=V;oa=ra*La-sa*la;if(oa!=0){ta=1/oa;oa=(La*t-la*N)*ta;la=(La*r-la*J)*ta;t=(ra*N-sa*t)*ta;r=(ra*J-sa*r)*ta;l=l-oa*m-t*V;x=x-la*m-r*V;k.save();k.transform(oa,la,t,r,l,x);k.clip();k.drawImage(u,0,0);k.restore()}}function Qa(l,x,t,r){var N=~~(l.r*255),J=~~(l.g*255);l=~~(l.b*255);var u=~~(x.r*255),m=~~(x.g*255);x=~~(x.b*255);var V=~~(t.r*255),ra=~~(t.g*255);t=~~(t.b*255);var la=~~(r.r*255),sa=~~(r.g*255);r=~~(r.b*255);ja[0]=N<0?0:N>255?255:N;ja[1]=J<0?0:J>255?255:
+J;ja[2]=l<0?0:l>255?255:l;ja[4]=u<0?0:u>255?255:u;ja[5]=m<0?0:m>255?255:m;ja[6]=x<0?0:x>255?255:x;ja[8]=V<0?0:V>255?255:V;ja[9]=ra<0?0:ra>255?255:ra;ja[10]=t<0?0:t>255?255:t;ja[12]=la<0?0:la>255?255:la;ja[13]=sa<0?0:sa>255?255:sa;ja[14]=r<0?0:r>255?255:r;Ia.putImageData(Va,0,0);Oa.drawImage(Ha,0,0);return Ja}function Aa(l,x,t){l=(l-x)/(t-x);return l*l*(3-2*l)}function Da(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function xa(l,x){var t=x.x-l.x,r=x.y-l.y,N=1/Math.sqrt(t*t+r*r);t*=N;r*=N;x.x+=t;x.y+=r;l.x-=
+t;l.y-=r}var Sa,Ya,O,ma,ya,Ea,Ta,ca;this.autoClear?this.clear():k.setTransform(1,0,0,-1,h,j);e=d.projectScene(Z,ka,this.sortElements);(Ua=Z.lights.length>0)&&Za(Z);Sa=0;for(Ya=e.length;Sa<Ya;Sa++){O=e[Sa];fa.empty();if(O instanceof THREE.RenderableParticle){z=O;z.x*=h;z.y*=j;ma=0;for(ya=O.materials.length;ma<ya;){ca=O.materials[ma++];ca.opacity!=0&&$a(z,O,ca,Z)}}else if(O instanceof THREE.RenderableLine){z=O.v1;D=O.v2;z.positionScreen.x*=h;z.positionScreen.y*=j;D.positionScreen.x*=h;D.positionScreen.y*=
+j;fa.addPoint(z.positionScreen.x,z.positionScreen.y);fa.addPoint(D.positionScreen.x,D.positionScreen.y);if(za.instersects(fa)){ma=0;for(ya=O.materials.length;ma<ya;){ca=O.materials[ma++];ca.opacity!=0&&ab(z,D,O,ca,Z)}}}else if(O instanceof THREE.RenderableFace3){z=O.v1;D=O.v2;I=O.v3;z.positionScreen.x*=h;z.positionScreen.y*=j;D.positionScreen.x*=h;D.positionScreen.y*=j;I.positionScreen.x*=h;I.positionScreen.y*=j;if(O.overdraw){xa(z.positionScreen,D.positionScreen);xa(D.positionScreen,I.positionScreen);
+xa(I.positionScreen,z.positionScreen)}fa.add3Points(z.positionScreen.x,z.positionScreen.y,D.positionScreen.x,D.positionScreen.y,I.positionScreen.x,I.positionScreen.y);if(za.instersects(fa)){ma=0;for(ya=O.meshMaterials.length;ma<ya;){ca=O.meshMaterials[ma++];if(ca instanceof THREE.MeshFaceMaterial){Ea=0;for(Ta=O.faceMaterials.length;Ea<Ta;)(ca=O.faceMaterials[Ea++])&&ca.opacity!=0&&Pa(z,D,I,0,1,2,O,ca,Z)}else ca.opacity!=0&&Pa(z,D,I,0,1,2,O,ca,Z)}}}else if(O instanceof THREE.RenderableFace4){z=O.v1;
+D=O.v2;I=O.v3;H=O.v4;z.positionScreen.x*=h;z.positionScreen.y*=j;D.positionScreen.x*=h;D.positionScreen.y*=j;I.positionScreen.x*=h;I.positionScreen.y*=j;H.positionScreen.x*=h;H.positionScreen.y*=j;q.positionScreen.copy(D.positionScreen);aa.positionScreen.copy(H.positionScreen);if(O.overdraw){xa(z.positionScreen,D.positionScreen);xa(D.positionScreen,H.positionScreen);xa(H.positionScreen,z.positionScreen);xa(I.positionScreen,q.positionScreen);xa(I.positionScreen,aa.positionScreen)}fa.addPoint(z.positionScreen.x,
+z.positionScreen.y);fa.addPoint(D.positionScreen.x,D.positionScreen.y);fa.addPoint(I.positionScreen.x,I.positionScreen.y);fa.addPoint(H.positionScreen.x,H.positionScreen.y);if(za.instersects(fa)){ma=0;for(ya=O.meshMaterials.length;ma<ya;){ca=O.meshMaterials[ma++];if(ca instanceof THREE.MeshFaceMaterial){Ea=0;for(Ta=O.faceMaterials.length;Ea<Ta;)(ca=O.faceMaterials[Ea++])&&ca.opacity!=0&&Xa(z,D,I,H,q,aa,O,ca,Z)}else ca.opacity!=0&&Xa(z,D,I,H,q,aa,O,ca,Z)}}}ia.addRectangle(fa)}k.setTransform(1,0,0,
+1,0,0)}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var e,d=c.length;for(e=0;e<d;e++){a=c[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 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};

+ 2 - 3
build/custom/ThreeDOM.js

@@ -71,9 +71,8 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,g,f){a=(c-a)*0.5;e=(e-b
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
 THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
-!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
-THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position)}a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0;for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};
+THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.matrixAutoUpdate=!1};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;b=!0}var e,d=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(e=0;e<d;e++){a=this.children[e];a instanceof THREE.Bone?a.update(this.skinMatrix,b,c):a.update(this.matrixWorld,!0,c)}}else for(e=0;e<d;e++)this.children[e].update(this.skinMatrix,
 b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);if(!(a instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};
 THREE.Sound=function(a,b,c,e){THREE.Object3D.call(this);this.isLoaded=!1;this.isAddedToDOM=!1;this.isPlaying=!1;this.duration=-1;this.radius=b!==undefined?Math.abs(b):100;this.volume=Math.min(1,Math.max(0,c!==undefined?c:1));this.domElement=document.createElement("audio");this.domElement.volume=0;this.domElement.pan=0;this.domElement.loop=e!==undefined?e:!0;this.sources=a instanceof Array?a:[a];var d;c=this.sources.length;for(a=0;a<c;a++){b=this.sources[a];b.toLowerCase();if(b.indexOf(".mp3")!==-1)d=

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


+ 4 - 4
build/custom/ThreeSVG.js

@@ -80,10 +80,10 @@ THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==undefined)return e[c];return this.data.hierarchy[b].keys[e.length-1]};
 THREE.Camera=function(a,b,c,e,d){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=e||2E3;this.target=d||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};THREE.Camera.prototype.updateMatrix=function(){this.update(undefined,!0)};
-THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=
-!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;
-THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
+THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);this.matrix.setPosition(this.position)}a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0;for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};
+THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1;this.distance=c||0};THREE.DirectionalLight.prototype=new THREE.Light;
+THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1;this.distance=c||0};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.NoShading=0;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;
+THREE.MultiplyBlending=3;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth=
 a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};
 THREE.MeshBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.envMap=this.lightMap=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=0.98;this.fog=!0;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.depthTest=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=!1;this.skinning=!1;this.morphTargets=!1;

File diff suppressed because it is too large
+ 122 - 118
build/custom/ThreeWebGL.js


+ 1 - 2
examples/canvas_interactive_cubes.html

@@ -69,9 +69,8 @@
 				particleMaterial = new THREE.ParticleCanvasMaterial( {
 
 					color: 0x000000,
-					program: function ( context, color ) {
+					program: function ( context ) {
 
-						context.fillStyle = color.__styleString;
 						context.beginPath();
 						context.arc( 0, 0, 1, 0, PI2, true );
 						context.closePath();

+ 4 - 5
examples/canvas_lights_pointlights.html

@@ -64,19 +64,18 @@
 
 				scene.addLight( new THREE.AmbientLight( 0x00020 ) );
 
-				light1 = new THREE.PointLight( 0xff0040 );
+				light1 = new THREE.PointLight( 0xff0040, 1, 50 );
 				scene.addLight( light1 );
 
-				light2 = new THREE.PointLight( 0x0040ff );
+				light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
 				scene.addLight( light2 );
 
-				light3 = new THREE.PointLight( 0x80ff80 );
+				light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
 				scene.addLight( light3 );
 
 				var PI2 = Math.PI * 2;
-				var program = function ( context, color ) {
+				var program = function ( context ) {
 
-					context.fillStyle = color.__styleString;
 					context.beginPath();
 					context.arc( 0, 0, 1, 0, PI2, true );
 					context.closePath();

+ 4 - 5
examples/canvas_lights_pointlights_smooth.html

@@ -64,19 +64,18 @@
 
 				scene.addLight( new THREE.AmbientLight( 0x00020 ) );
 
-				light1 = new THREE.PointLight( 0xff0040 );
+				light1 = new THREE.PointLight( 0xff0040, 1, 50 );
 				scene.addLight( light1 );
 
-				light2 = new THREE.PointLight( 0x0040ff );
+				light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
 				scene.addLight( light2 );
 
-				light3 = new THREE.PointLight( 0x80ff80 );
+				light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
 				scene.addLight( light3 );
 
 				var PI2 = Math.PI * 2;
-				var program = function ( context, color ) {
+				var program = function ( context ) {
 
-					context.fillStyle = color.__styleString;
 					context.beginPath();
 					context.arc( 0, 0, 1, 0, PI2, true );
 					context.closePath();

+ 7 - 8
examples/canvas_lines.html

@@ -60,16 +60,15 @@
 				var PI2 = Math.PI * 2;
 				var material = new THREE.ParticleCanvasMaterial( {
 
-							color: 0xffffff,
-							program: function ( context, color ) {
+					color: 0xffffff,
+					program: function ( context ) {
 
-								context.fillStyle = color.__styleString;
-								context.beginPath();
-								context.arc( 0, 0, 1, 0, PI2, true );
-								context.closePath();
-								context.fill();
+						context.beginPath();
+						context.arc( 0, 0, 1, 0, PI2, true );
+						context.closePath();
+						context.fill();
 
-							}
+					}
 
 				} );
 

+ 7 - 8
examples/canvas_lines_sphere.html

@@ -63,16 +63,15 @@
 				var PI2 = Math.PI * 2;
 				var material = new THREE.ParticleCanvasMaterial( {
 
-							color: 0xffffff,
-							program: function ( context, color ) {
+					color: 0xffffff,
+					program: function ( context ) {
 
-								context.fillStyle = color.__styleString;
-								context.beginPath();
-								context.arc( 0, 0, 1, 0, PI2, true );
-								context.closePath();
-								context.fill();
+						context.beginPath();
+						context.arc( 0, 0, 1, 0, PI2, true );
+						context.closePath();
+						context.fill();
 
-							}
+					}
 
 				} );
 

+ 1 - 2
examples/canvas_materials.html

@@ -112,9 +112,8 @@
 				}
 
 				var PI2 = Math.PI * 2;
-				var program = function ( context, color ) {
+				var program = function ( context ) {
 
-					context.fillStyle = color.__styleString;
 					context.beginPath();
 					context.arc( 0, 0, 1, 0, PI2, true );
 					context.closePath();

+ 7 - 8
examples/canvas_materials_video.html

@@ -128,16 +128,15 @@
 				var PI2 = Math.PI * 2;
 				var material = new THREE.ParticleCanvasMaterial( {
 
-							color: 0x0808080,
-							program: function ( context, color ) {
+					color: 0x0808080,
+					program: function ( context ) {
 
-								context.fillStyle = color.__styleString;
-								context.beginPath();
-								context.arc( 0, 0, 1, 0, PI2, true );
-								context.closePath();
-								context.fill();
+						context.beginPath();
+						context.arc( 0, 0, 1, 0, PI2, true );
+						context.closePath();
+						context.fill();
 
-							}
+					}
 
 				} );
 

+ 1 - 2
examples/canvas_particles_floor.html

@@ -53,9 +53,8 @@
 				var material = new THREE.ParticleCanvasMaterial( {
 
 					color: 0xffffff,
-					program: function ( context, color ) {
+					program: function ( context ) {
 
-						context.fillStyle = color.__styleString;
 						context.beginPath();
 						context.arc( 0, 0, 1, 0, PI2, true );
 						context.closePath();

+ 1 - 2
examples/canvas_particles_random.html

@@ -46,9 +46,8 @@
 				scene = new THREE.Scene();
 
 				var PI2 = Math.PI * 2;
-				var program = function ( context, color ) {
+				var program = function ( context ) {
 
-					context.fillStyle = color.__styleString;
 					context.beginPath();
 					context.arc( 0, 0, 1, 0, PI2, true );
 					context.closePath();

+ 7 - 8
examples/canvas_particles_waves.html

@@ -54,16 +54,15 @@
 				var PI2 = Math.PI * 2;
 				var material = new THREE.ParticleCanvasMaterial( {
 
-							color: 0xffffff,
-							program: function ( context, color ) {
+					color: 0xffffff,
+					program: function ( context ) {
 
-								context.strokeStyle = color.__styleString;
-								context.beginPath();
-								context.arc( 0, 0, 1, 0, PI2, true );
-								context.closePath();
-								context.stroke();
+						context.beginPath();
+						context.arc( 0, 0, 1, 0, PI2, true );
+						context.closePath();
+						context.stroke();
 
-							}
+					}
 
 				} );
 

+ 1 - 1
examples/canvas_performance.html

@@ -100,7 +100,7 @@
 				directionalLight.position.z = 0;
 				scene.addLight( directionalLight );
 
-				var pointLight = new THREE.PointLight( 0xff0000, 1 );
+				var pointLight = new THREE.PointLight( 0xff0000, 1, 500 );
 				scene.addLight( pointLight );
 
 				renderer = new THREE.CanvasRenderer();

+ 1 - 1
examples/js/Detector.js

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

+ 1 - 1
examples/misc_sound.html

@@ -137,7 +137,7 @@
 				scene.addObject( mesh );
 
 
-				renderer = new THREE.WebGLRenderer( { clearColor: 0x000000, clearAlpha: 1 } );
+				renderer = new THREE.WebGLRenderer( { clearColor: 0x000000, clearAlpha: 1, antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 				soundRenderer = new THREE.SoundRenderer();

+ 4 - 0
examples/misc_ubiquity_test.html

@@ -51,6 +51,7 @@
 		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ShadowVolumeDynamicMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
@@ -66,6 +67,7 @@
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
 		<script type="text/javascript" src="../src/objects/LOD.js"></script>
+		<script type="text/javascript" src="../src/objects/ShadowVolume.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -97,6 +99,8 @@
 		<script type="text/javascript" src="../src/extras/geometries/Torus.js"></script>
 		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
 
 		<script type="text/javascript" src="obj/Qrcode.js"></script>

+ 45 - 0
examples/obj/blenderscene/scene.Cube.js

@@ -0,0 +1,45 @@
+/*
+ * File generated with Blender 2.56 Exporter
+ * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/
+ *
+ * vertices: 8
+ * faces: 6
+ * normals: 0
+ * uvs: 0
+ * colors: 0
+ * materials: 1
+ *
+ */
+
+var model = {
+
+    "version" : 2,
+    
+    "materials": [	{
+	"DbgColor" : 15658734,
+	"DbgIndex" : 0,
+	"DbgName" : "Material",
+	"colorAmbient" : [0.0, 0.0, 0.0],
+	"colorDiffuse" : [0.6400000190734865, 0.10179081114814892, 0.126246120426746],
+	"colorSpecular" : [0.5, 0.5, 0.5],
+	"shading" : "Phong",
+	"specularCoef" : 50,
+	"transparency" : 1.0,
+	"vertexColors" : false
+	}],
+
+    "vertices": [1.000000,-1.000000,-1.000000,1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,-1.000000,1.000000,1.000000,-1.000000,0.999999,1.000000,1.000001,-1.000000,1.000000,1.000000,-1.000000,1.000000,-1.000000],
+
+    "morphTargets": [],
+
+    "normals": [],
+
+    "colors": [],
+
+    "uvs": [[]],
+
+    "faces": [3,0,1,2,3,0,3,4,7,6,5,0,3,0,4,5,1,0,3,1,5,6,2,0,3,2,6,7,3,0,3,4,0,3,7,0]
+
+};
+
+postMessage( model );

File diff suppressed because it is too large
+ 30 - 0
examples/obj/blenderscene/scene.Monkey.js


+ 45 - 0
examples/obj/blenderscene/scene.Plane.js

@@ -0,0 +1,45 @@
+/*
+ * File generated with Blender 2.56 Exporter
+ * https://github.com/mrdoob/three.js/tree/master/utils/exporters/blender/
+ *
+ * vertices: 4
+ * faces: 1
+ * normals: 0
+ * uvs: 0
+ * colors: 0
+ * materials: 1
+ *
+ */
+
+var model = {
+
+    "version" : 2,
+    
+    "materials": [	{
+	"DbgColor" : 15658734,
+	"DbgIndex" : 0,
+	"DbgName" : "Material.001",
+	"colorAmbient" : [0.0, 0.0, 0.0],
+	"colorDiffuse" : [0.14462547517754842, 0.6400000190734865, 0.24541190036254967],
+	"colorSpecular" : [0.5, 0.5, 0.5],
+	"shading" : "Phong",
+	"specularCoef" : 50,
+	"transparency" : 1.0,
+	"vertexColors" : false
+	}],
+
+    "vertices": [1.000000,-0.000000,-1.000000,1.000000,0.000000,1.000000,-1.000000,0.000000,1.000000,-1.000000,-0.000000,-1.000000],
+
+    "morphTargets": [],
+
+    "normals": [],
+
+    "colors": [],
+
+    "uvs": [[]],
+
+    "faces": [3,0,3,2,1,0]
+
+};
+
+postMessage( model );

BIN
examples/obj/blenderscene/scene.blend


+ 440 - 0
examples/obj/blenderscene/scene.js

@@ -0,0 +1,440 @@
+// Converted from: scene.blend
+//  File generated with Blender 2.56 Exporter
+//  https://github.com/alteredq/three.js/tree/master/utils/exporters/blender/
+
+
+var scene = {
+
+"type" : "scene",
+"urlBaseType" : "relativeToScene",
+
+
+"objects" : 
+{
+    "Cube.006" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ 10.623673, 3.370784, -0.321692 ],
+        "rotation"  : [ 0.005265, -0.056306, 4.717181 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 8.310000, 4.930000, 0.120000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.018" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 1.702659, 0.680278, 5.860421 ],
+        "rotation"  : [ 1.413516, 0.081378, -3.204182 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.017" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 0.081295, 0.639505, 5.808783 ],
+        "rotation"  : [ 1.413516, 0.081378, -3.204182 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.016" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -1.569030, 0.619385, 5.747240 ],
+        "rotation"  : [ 1.413516, 0.081378, -3.204182 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.015" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -3.129120, 0.552267, 5.709269 ],
+        "rotation"  : [ 1.413516, 0.081378, -3.204182 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.014" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -6.386331, 0.382167, 3.004400 ],
+        "rotation"  : [ 1.646237, -0.058425, -1.670593 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.013" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -6.499331, 0.471640, 1.593073 ],
+        "rotation"  : [ 1.646237, -0.058425, -1.670593 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.012" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -6.629794, 0.533840, 0.234131 ],
+        "rotation"  : [ 1.646237, -0.058425, -1.670593 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.011" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -6.713673, 0.629835, -1.008146 ],
+        "rotation"  : [ 1.646237, -0.058425, -1.670593 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 0.435837, 0.435837, 0.435837 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.010" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -2.010442, 1.387332, 24.343616 ],
+        "rotation"  : [ 1.520470, 0.191726, -3.004622 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 9.160007, 9.160007, 9.160008 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.009" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -4.292194, 1.826282, -7.975398 ],
+        "rotation"  : [ 1.594819, 0.080713, -0.213986 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.008" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 2.151757, 1.891882, -8.065320 ],
+        "rotation"  : [ 1.594819, 0.080713, -0.213986 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.007" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -0.712512, 2.115002, -8.097841 ],
+        "rotation"  : [ 1.594819, 0.080713, -0.213986 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube.005" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ -1.000975, 1.319482, -8.755547 ],
+        "rotation"  : [ 0.000000, 0.000000, -0.000000 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 6.130000, 1.690000, 0.070000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube.004" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ 2.484517, 2.724846, 7.486932 ],
+        "rotation"  : [ 0.220417, -0.075224, 0.181029 ],
+        "quaternion": [ 0.988791, 0.112836, 0.027288, -0.093898 ],
+        "scale"	    : [ 0.350000, 3.310000, 0.890000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.006" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 7.724935, 1.694883, -7.123103 ],
+        "rotation"  : [ 1.835590, 0.083161, -2.048913 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.005" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -6.334642, 0.566791, -6.636147 ],
+        "rotation"  : [ 1.327136, -0.032561, -4.135900 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.004" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -5.384042, 0.444915, 6.194087 ],
+        "rotation"  : [ 0.991213, 0.181430, -5.246078 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.003" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 3.147747, 1.014840, 4.230884 ],
+        "rotation"  : [ 1.719311, -0.307044, -3.355401 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.002" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -2.668043, 3.008879, 2.153389 ],
+        "rotation"  : [ 1.881970, 0.457870, 4.066133 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube.003" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ -3.031251, 0.702044, 1.943665 ],
+        "rotation"  : [ -1.300741, -1.330343, 3.282723 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 1.781142, 0.231142, 0.361142 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey.001" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ 1.245307, 0.620196, -0.137285 ],
+        "rotation"  : [ 2.339869, -0.286025, -1.394760 ],
+        "quaternion": [ -0.587711, 0.550951, 0.566613, 0.173203 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Monkey" : {
+        "geometry"  : "geo_Monkey",
+        "groups"    : [  ],
+        "materials" : [ "Material.002" ],
+        "position"  : [ -0.282500, 1.813606, -4.272932 ],
+        "rotation"  : [ 0.646062, -0.219349, -0.010569 ],
+        "quaternion": [ 0.942751, 0.314982, 0.105460, -0.029764 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube.002" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ 0.042212, 5.536832, -0.199037 ],
+        "rotation"  : [ 0.000000, 0.000000, -0.000000 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube.001" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ -0.395497, 1.009696, -3.944532 ],
+        "rotation"  : [ 0.000000, 0.000000, -0.000000 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Plane" : {
+        "geometry"  : "geo_Plane",
+        "groups"    : [  ],
+        "materials" : [ "Material.001" ],
+        "position"  : [ 0.000000, 0.000000, 0.118260 ],
+        "rotation"  : [ 0.000000, 0.000000, -0.000000 ],
+        "quaternion": [ 1.000000, 0.000000, 0.000000, 0.000000 ],
+        "scale"	    : [ 7.922787, 7.922787, 7.922787 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    },
+
+    "Cube" : {
+        "geometry"  : "geo_Cube",
+        "groups"    : [  ],
+        "materials" : [ "Material" ],
+        "position"  : [ 3.651978, 1.071144, 0.000000 ],
+        "rotation"  : [ 0.220417, -0.075224, 0.181029 ],
+        "quaternion": [ 0.988791, 0.112836, 0.027288, -0.093898 ],
+        "scale"	    : [ 1.000000, 1.000000, 1.000000 ],
+        "visible"       : true,
+        "castsShadow"   : false,
+        "meshCollider"  : false
+    }
+},
+
+
+"geometries" : 
+{
+    "geo_Cube" : {
+        "type" : "ascii_mesh",
+        "url"  : "scene.Cube.js"
+    },
+
+    "geo_Monkey" : {
+        "type" : "ascii_mesh",
+        "url"  : "scene.Monkey.js"
+    },
+
+    "geo_Plane" : {
+        "type" : "ascii_mesh",
+        "url"  : "scene.Plane.js"
+    }
+},
+
+
+"materials" : 
+{
+    "Material" : {
+        "type": "MeshPhongMaterial",
+        "parameters": { color: 10688800, opacity: 1.00, ambient: 0, specular: 8355711, shininess: 50.0 } 
+    },
+
+    "Material.001" : {
+        "type": "MeshPhongMaterial",
+        "parameters": { color: 2401086, opacity: 1.00, ambient: 0, specular: 8355711, shininess: 50.0 } 
+    },
+
+    "Material.002" : {
+        "type": "MeshPhongMaterial",
+        "parameters": { color: 10711076, opacity: 1.00, ambient: 0, specular: 8355711, shininess: 50.0 } 
+    }
+},
+
+
+"cameras" : 
+{
+    "default_camera" : {
+        "type"  : "perspective",
+        "fov"   : 60.000000,
+        "aspect": 1.333000,
+        "near"  : 1.000000,
+        "far"   : 10000.000000,
+        "position": [ 0.000000, 0.000000, 10.000000 ],
+        "target"  : [ 0.000000, 0.000000, 0.000000 ]
+    }
+},
+
+
+"lights" : 
+{
+	"default_light": {
+		"type"		 : "directional",
+		"direction"	 : [ 0.000000, 1.000000, 1.000000 ],
+		"color" 	 : 16777215,
+		"intensity"	 : 0.80
+	}
+},
+
+
+"defaults" : 
+{
+    "bgcolor" : [ 0.000000, 0.000000, 0.000000 ],
+    "bgalpha" : 1.000000,
+    "camera"  : "default_camera"
+}
+
+}
+
+postMessage( scene );
+

BIN
examples/obj/cubecolors/cube_fvc.blend


+ 13 - 15
examples/obj/cubecolors/cube_fvc.js

@@ -4,7 +4,7 @@
  *
  * vertices: 8
  * faces: 6
- * normals: 8
+ * normals: 0
  * uvs: 0
  * colors: 22
  * materials: 1
@@ -13,35 +13,33 @@
 
 var model = {
 
-    'version' : 2,
+    "version" : 2,
     
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "Material",
 	"colorAmbient" : [0.0, 0.0, 0.0],
-	"colorDiffuse" : [1, 1, 1],
+	"colorDiffuse" : [0.800000011920929, 0.800000011920929, 0.800000011920929],
 	"colorSpecular" : [0.5, 0.5, 0.5],
-	"shading" : "Basic",
+	"shading" : "Phong",
 	"specularCoef" : 50,
 	"transparency" : 1.0,
 	"vertexColors" : true
 	}],
 
-    'vertices': [1.000000,-1.000000,-1.000000,1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,-1.000000,1.000000,1.000000,-1.000000,0.999999,1.000000,1.000000,-1.000000,1.000000,0.999999,-1.000000,1.000000,-1.000000],
+    "vertices": [1.000000,-1.000000,-1.000000,1.000000,-1.000000,1.000000,-1.000000,-1.000000,1.000000,-1.000000,-1.000000,-1.000000,1.000000,1.000000,-1.000000,0.999999,1.000000,1.000000,-1.000000,1.000000,0.999999,-1.000000,1.000000,-1.000000],
 
-    'morphTargets': [],
+    "morphTargets": [],
 
-    'normals': [0.577349,-0.577349,-0.577349,0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,-0.577349,0.577349,0.577349,-0.577349,-0.577349,0.577349,-0.577349,-0.577349,0.577349,0.577349,0.577349,0.577349,0.577349],
+    "normals": [],
 
-    'colors': [0xffffff,0xffe18d,0xffe190,0x80fff7,0xe7df1b,0x6f62ff,0xfd17db,0xff0007,0x101d0e,0x5c00a3,0xd1ffb4,0x8a0079,0x797eed,0x6758ff,0xfff5de,0x3f3cff,0xb6b4ff,0x1dffef,0x101e1d,0x8a9190,0xd0ffaf,0x4c5555],
+    "colors": [16777215,16769421,16769424,8454135,15195931,7299839,16586715,16711687,1056014,6029475,13762484,9044089,7962349,6772991,16774622,4144383,11973887,1966063,1056285,9081232,13696943,5002581],
 
-    'uvs': [[]],
+    "uvs": [[]],
 
-    'faces': [163,0,1,2,3,0,0,1,2,3,0,1,2,3,163,4,7,6,5,0,4,5,6,7,4,5,6,7,163,0,4,5,1,0,0,4,7,1,0,8,9,10,163,1,5,6,2,0,1,7,6,2,0,11,12,13,163,2,6,7,3,0,2,6,5,3,14,15,16,17,163,4,0,3,7,0,4,0,3,5,18,19,20,21],
+    "faces": [131,0,1,2,3,0,0,1,2,3,131,4,7,6,5,0,4,5,6,7,131,0,4,5,1,0,0,8,9,10,131,1,5,6,2,0,0,11,12,13,131,2,6,7,3,0,14,15,16,17,131,4,0,3,7,0,18,19,20,21]
 
-    'end': (new Date).getTime()
-
-}
+};
 
 postMessage( model );

File diff suppressed because it is too large
+ 4 - 5
examples/obj/cubecolors/cubecolors.js


+ 9 - 11
examples/obj/female02/Female02_bin.js

@@ -9,10 +9,10 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "_03_-_Default1noCulli__03_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -26,7 +26,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0xee0000,
+	"DbgColor" : 15597568,
 	"DbgIndex" : 1,
 	"DbgName" : "_02_-_Default1noCulli__02_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -40,7 +40,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0x00ee00,
+	"DbgColor" : 60928,
 	"DbgIndex" : 2,
 	"DbgName" : "FrontColorNoCullingID__02_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -54,7 +54,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0x0000ee,
+	"DbgColor" : 238,
 	"DbgIndex" : 3,
 	"DbgName" : "FrontColorNoCullingID__03_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -68,7 +68,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0xeeee00,
+	"DbgColor" : 15658496,
 	"DbgIndex" : 4,
 	"DbgName" : "_01_-_Default1noCulli__01_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -82,7 +82,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0x00eeee,
+	"DbgColor" : 61166,
 	"DbgIndex" : 5,
 	"DbgName" : "FrontColorNoCullingID__01_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -95,10 +95,8 @@ var model = {
 	"transparency" : 1.0
 	}],
 
-    'buffers': 'Female02_bin.bin',
+    "buffers": "Female02_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

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


File diff suppressed because it is too large
+ 3 - 3
examples/obj/leeperrysmith/LeePerrySmith.js


+ 4 - 6
examples/obj/lucy/Lucy100k_bin.js

@@ -9,18 +9,16 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "default"
 	}],
 
-    'buffers': 'Lucy100k_bin.bin',
+    "buffers": "Lucy100k_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

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


+ 8 - 10
examples/obj/male02/Male02_bin.js

@@ -9,10 +9,10 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "male-02-1noCullingID_male-02-1noCulling.JP",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -26,7 +26,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0xee0000,
+	"DbgColor" : 15597568,
 	"DbgIndex" : 1,
 	"DbgName" : "orig_02_-_Defaul1noCu_orig_02_-_Defaul1noCu",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -40,7 +40,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0x00ee00,
+	"DbgColor" : 60928,
 	"DbgIndex" : 2,
 	"DbgName" : "FrontColorNoCullingID_orig_02_-_Defaul1noCu",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -54,7 +54,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0x0000ee,
+	"DbgColor" : 238,
 	"DbgIndex" : 3,
 	"DbgName" : "_01_-_Default1noCulli__01_-_Default1noCulli",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -68,7 +68,7 @@ var model = {
 	},
 
 	{
-	"DbgColor" : 0xeeee00,
+	"DbgColor" : 15658496,
 	"DbgIndex" : 4,
 	"DbgName" : "FrontColorNoCullingID_male-02-1noCulling.JP",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -81,10 +81,8 @@ var model = {
 	"transparency" : 1.0
 	}],
 
-    'buffers': 'Male02_bin.bin',
+    "buffers": "Male02_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

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


+ 4 - 6
examples/obj/ninja/NinjaLo_bin.js

@@ -9,18 +9,16 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "default"
 	}],
 
-    'buffers': 'NinjaLo_bin.bin',
+    "buffers": "NinjaLo_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

+ 4 - 6
examples/obj/torus/Torus_bin.js

@@ -9,18 +9,16 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "(null)"
 	}],
 
-    'buffers': 'Torus_bin.bin',
+    "buffers": "Torus_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

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


+ 4 - 6
examples/obj/walt/WaltHead_bin.js

@@ -9,10 +9,10 @@
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [	{
-	"DbgColor" : 0xeeeeee,
+    "materials": [	{
+	"DbgColor" : 15658734,
 	"DbgIndex" : 0,
 	"DbgName" : "lambert2SG.001",
 	"colorAmbient" : [0.0, 0.0, 0.0],
@@ -24,10 +24,8 @@ var model = {
 	"transparency" : 1.0
 	}],
 
-    'buffers': 'WaltHead_bin.bin',
+    "buffers": "WaltHead_bin.bin"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );

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


+ 5 - 2
examples/scenes/test_scene.js

@@ -1,5 +1,8 @@
 var scene = {
 	
+"type"		  :	"scene",
+"urlBaseType" : "relativeToHTML",
+	
 "objects": 
 {	
 	"cube1" : {
@@ -393,14 +396,14 @@ var scene = {
 	"light1": {
 		"type"		 : "directional",
 		"direction"	 : [0,1,1],
-		"color" 	 : [1,1,1],
+		"color" 	 : 0xffffff,
 		"intensity"	 : 0.8
 	},
 
 	"light2": {
 		"type"	  : "point",
 		"position": [0,0,0],
-		"color"   : [1,1,1]
+		"color"   : 0xffffff
 	}
 	
 },

+ 2 - 85
examples/webgl_geometry_minecraft.html

@@ -39,92 +39,9 @@
 
 		<div id="container"><br /><br /><br /><br /><br />Generating world...</div>
 		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - <a href="http://www.minecraft.net/" target="_blank">minecraft</a> demo. featuring <a href="http://painterlypack.net/" target="_blank">painterly pack</a><br />(left click: forward, right click: backward)</div>
-<!--
+
 		<script type="text/javascript" src="../build/Three.js"></script>
--->
-		<script type="text/javascript" src="../src/Three.js"></script>
-		<script type="text/javascript" src="../src/core/Color.js"></script>
-		<script type="text/javascript" src="../src/core/Vector2.js"></script>
-		<script type="text/javascript" src="../src/core/Vector3.js"></script>
-		<script type="text/javascript" src="../src/core/Vector4.js"></script>
-		<script type="text/javascript" src="../src/core/Ray.js"></script>
-		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
-		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
-		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
-		<script type="text/javascript" src="../src/core/Object3D.js"></script>
-		<script type="text/javascript" src="../src/core/Quaternion.js"></script>
-		<script type="text/javascript" src="../src/core/Vertex.js"></script>
-		<script type="text/javascript" src="../src/core/Face3.js"></script>
-		<script type="text/javascript" src="../src/core/Face4.js"></script>
-		<script type="text/javascript" src="../src/core/UV.js"></script>
-		<script type="text/javascript" src="../src/core/Geometry.js"></script>
-		<script type="text/javascript" src="../src/core/Spline.js"></script>
-		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
-		<script type="text/javascript" src="../src/animation/Animation.js"></script>
-		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
-		<script type="text/javascript" src="../src/lights/Light.js"></script>
-		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
-		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
-		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
-		<script type="text/javascript" src="../src/materials/Material.js"></script>
-		<script type="text/javascript" src="../src/materials/Mappings.js"></script>
-		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshLambertMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/Texture.js"></script>
-		<script type="text/javascript" src="../src/materials/RenderTarget.js"></script>
-		<script type="text/javascript" src="../src/materials/Uniforms.js"></script>
-		<script type="text/javascript" src="../src/objects/Particle.js"></script>
-		<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
-		<script type="text/javascript" src="../src/objects/Line.js"></script>
-		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
-		<script type="text/javascript" src="../src/objects/Bone.js"></script>
-		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
-		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
-		<script type="text/javascript" src="../src/objects/Sound.js"></script>
-		<script type="text/javascript" src="../src/objects/LOD.js"></script>
-		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
-		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
-		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
-		<script type="text/javascript" src="../src/renderers/Projector.js"></script>
-		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
-		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableVertex.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
-		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
-		<script type="text/javascript" src="../src/extras/cameras/QuakeCamera.js"></script>
-		<script type="text/javascript" src="../src/extras/cameras/PathCamera.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Cube.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Cylinder.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Icosahedron.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Lathe.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Plane.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Sphere.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/Torus.js"></script>
-		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
-		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
-		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
-		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
-		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
-		
+
 		<script type="text/javascript" src="js/ImprovedNoise.js"></script>
 
 		<script type="text/javascript" src="js/Detector.js"></script>

+ 4 - 4
examples/webgl_lights_pointlights.html

@@ -64,7 +64,7 @@
 
 				var container = document.getElementById( 'container' );
 
-				camera = new THREE.Camera( 65, window.innerWidth / window.innerHeight, 1, 1000 );
+				camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 1000 );
 				camera.position.z = 100;
 
 				scene = new THREE.Scene();
@@ -98,13 +98,13 @@
 
 				scene.addLight( new THREE.AmbientLight( 0x00000 ) );
 
-				light1 = new THREE.PointLight( 0xff0040 );
+				light1 = new THREE.PointLight( 0xff0040, 1, 50 );
 				scene.addLight( light1 );
 
-				light2 = new THREE.PointLight( 0x0040ff );
+				light2 = new THREE.PointLight( 0x0040ff, 1, 50 );
 				scene.addLight( light2 );
 
-				light3 = new THREE.PointLight( 0x80ff80 );
+				light3 = new THREE.PointLight( 0x80ff80, 1, 50 );
 				scene.addLight( light3 );
 
 				var sphere = new Sphere( 0.5, 16, 8 );

+ 1 - 1
examples/webgl_lines_colors.html

@@ -77,7 +77,7 @@
 
 				scene = new THREE.Scene();
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.autoClear = false;
 				container.appendChild( renderer.domElement );

+ 14 - 12
examples/webgl_materials_cubemap.html

@@ -48,7 +48,7 @@
 
 			var container, stats;
 
-			var camera, scene, webglRenderer;
+			var camera, scene, renderer;
 			var cameraCube, sceneCube;
 
 			var mesh, zmesh, lightMesh, geometry;
@@ -73,10 +73,10 @@
 				container = document.createElement('div');
 				document.body.appendChild(container);
 
-				camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 100000 );
+				camera = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 5000 );
 				camera.position.z = 2000;
 
-				cameraCube = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 100000 );
+				cameraCube = new THREE.Camera( 50, window.innerWidth / window.innerHeight, 1, 100 );
 
 				scene = new THREE.Scene();
 				sceneCube = new THREE.Scene();
@@ -112,13 +112,13 @@
 				var cubeMaterial2 = new THREE.MeshLambertMaterial( { color: 0xffee00, envMap: refractionCube, refractionRatio: 0.95 } );
 				var cubeMaterial1 = new THREE.MeshLambertMaterial( { color: 0xffffff, envMap: reflectionCube } )
 
-				SceneUtils.addPanoramaCubeWebGL( sceneCube, 100000, reflectionCube );
+				SceneUtils.addPanoramaCubeWebGL( sceneCube, 10, reflectionCube );
 
-				webglRenderer = new THREE.WebGLRenderer();
-				webglRenderer.setSize( window.innerWidth, window.innerHeight );
-				webglRenderer.autoClear = false;
-				//webglRenderer.setFaceCulling( 0 );
-				container.appendChild( webglRenderer.domElement );
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( window.innerWidth, window.innerHeight );
+				renderer.autoClear = false;
+				//renderer.setFaceCulling( 0 );
+				container.appendChild( renderer.domElement );
 
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
@@ -178,9 +178,11 @@
 				lightMesh.position.x = 1500 * Math.cos( timer );
 				lightMesh.position.z = 1500 * Math.sin( timer );
 
-				webglRenderer.clear();
-				webglRenderer.render( sceneCube, cameraCube );
-				webglRenderer.render( scene, camera );
+				renderer.clear();
+				renderer.enableDepthBufferWrite( false );
+				renderer.render( sceneCube, cameraCube );
+				renderer.enableDepthBufferWrite( true );
+				renderer.render( scene, camera );
 
 			}
 

+ 1 - 2
examples/webgl_materials_video.html

@@ -91,7 +91,7 @@
 				light.position.normalize();
 				scene.addLight( light );
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 				container.appendChild( renderer.domElement );
@@ -138,7 +138,6 @@
 					material = materials[ cube_count ];
 
 					material.program = material_base.program;
-					material.uniforms = Uniforms.clone( THREE.ShaderLib[ 'lambert' ].uniforms );
 
 					material.hue = i/xgrid;
 					material.saturation = j/ygrid;

+ 1 - 1
examples/webgl_particles_billboards.html

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

+ 1 - 1
examples/webgl_particles_billboards_colors.html

@@ -85,7 +85,7 @@
 
 				geometry.colors = colors;
 
-				material = new THREE.ParticleBasicMaterial( { size: 85, map: sprite, blending: THREE.BillboardBlending, vertexColors: true } );
+				material = new THREE.ParticleBasicMaterial( { size: 85, map: sprite, vertexColors: true } );
 				material.color.setHSV( 1.0, 0.2, 0.8 );
 
 				particles = new THREE.ParticleSystem( geometry, material );

+ 1 - 2
examples/webgl_performance.html

@@ -16,8 +16,7 @@
 	<body>
 
 		<script type="text/javascript" src="../build/Three.js"></script>
-		
-		
+
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 1 - 1
examples/webgl_postprocessing.html

@@ -184,7 +184,7 @@
 				quadScreen.position.z = -100;
 				sceneScreen.addObject( quadScreen );
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.autoClear = false;
 				container.appendChild( renderer.domElement );

+ 1 - 2
examples/webgl_postprocessing_dof.html

@@ -86,7 +86,7 @@
 				scene.addLight( light );
 				*/
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, height );
 				container.appendChild( renderer.domElement );
 
@@ -135,7 +135,6 @@
 
 					materials[c] = new THREE.MeshBasicMaterial( parameters );
 					materials[c].program = material_base.program;
-					materials[c].uniforms = Uniforms.clone( THREE.ShaderLib[ 'basic' ].uniforms );
 
 					if ( singleMaterial )
 						mesh = new THREE.Mesh( geo, zmaterial );

+ 2 - 3
examples/webgl_ribbons.html

@@ -71,7 +71,7 @@
 				scene = new THREE.Scene();
 				scene.fog = new THREE.FogExp2( 0x000000, 0.0016 );
 
-				renderer = new THREE.WebGLRenderer();
+				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				container.appendChild( renderer.domElement );
 
@@ -130,12 +130,11 @@
 
 					materials[c] = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } );
 					materials[c].program = material_base.program;
-					materials[c].uniforms = Uniforms.clone( THREE.ShaderLib[ 'basic' ].uniforms );
 
 					ribbon = new THREE.Ribbon( i % 2 ? geometry : geometry2, materials[c] );
 					ribbon.rotation.x = 0;
 					ribbon.rotation.y = 1.57;
-					ribbon.rotation.z = 3.14;	
+					ribbon.rotation.z = 3.14;
 
 					x = 40 * ( i - xgrid/2 );
 					y = 40 * ( j - ygrid/2 );

+ 9 - 3
examples/webgl_sandbox.html

@@ -69,8 +69,9 @@
 		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ShadowVolumeDynamicMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
-		<script type="text/javascript" src="../src/materials/ParticleCircleMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
 		<script type="text/javascript" src="../src/materials/Texture.js"></script>
 		<script type="text/javascript" src="../src/materials/RenderTarget.js"></script>
@@ -84,6 +85,7 @@
 		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
 		<script type="text/javascript" src="../src/objects/Sound.js"></script>
 		<script type="text/javascript" src="../src/objects/LOD.js"></script>
+		<script type="text/javascript" src="../src/objects/ShadowVolume.js"></script>
 		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
 		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
 		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
@@ -94,8 +96,10 @@
 		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
 		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
 		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
-		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableVertex.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
 		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
 		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
@@ -113,8 +117,10 @@
 		<script type="text/javascript" src="../src/extras/geometries/Torus.js"></script>
 		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
 		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
 		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
-		
+
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
 

+ 563 - 0
examples/webgl_scene_test_blender.html

@@ -0,0 +1,563 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js webgl - io - scene loader [blender]</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				background:#000;
+				color:#fff;
+				padding:0;
+				margin:0;
+				overflow:hidden;
+				font-family:georgia;
+				text-align:center;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+				font-family: Monospace;
+				font-size: 13px;
+				text-align: center;
+				z-index:100;
+			}
+
+			#progress {
+				color:red;
+				top:7em;
+				width: 100%;
+				font-size:3em;
+				font-variant:small-caps;
+				font-weight:bold;
+				position:absolute;
+				z-index:100;
+				text-align: center;
+				text-shadow: #000 0px 0px 10px;
+				display:none;
+			}
+
+			#start {
+				color:#fff;
+				text-shadow: #000 0px 0px 2px;
+				padding:0.1em 0.3em;
+				width:3em;
+				text-align: center;
+				display:none;
+			}
+
+			.shadow {
+				-moz-box-shadow: 0px 0px 5px #000;
+				-webkit-box-shadow: 0px 0px 5px #000;
+				box-shadow: 0px 0px 5px #000;
+			}
+
+			#progressbar {
+				text-align: center;
+				background: white;
+				width: 250px;
+				height: 10px;
+			}
+
+			#bar {
+				background:#d00;
+				width:50px;
+				height:10px;
+			}
+
+			.enabled {
+				color: lime!important;
+				cursor:pointer;
+			}
+
+			.enabled:hover {
+				text-shadow: #0f0 0px 0px 5px !important;
+			}
+
+			.disabled {
+				background:gray;
+				cursor:default;
+			}
+
+			a { color:red }
+			canvas { pointer-events:none; z-index:10; }
+			#log { position:absolute; top:0; display:block; text-align:left; z-index:1000; pointer-events:none; }
+
+			#scene_explorer {
+				background:transparent;
+				color:#fff;
+				width:200px;
+				position:absolute;
+				text-align:left;
+				top:0px;
+				z-index:200;
+				overflow:auto;
+			}
+
+			#section_exp {
+				background:rgba(0,0,50,0.5);
+				padding:0.5em 0;
+				display:none;
+			}
+
+			#scene_explorer h3 {
+				font-size:1em;
+				padding:0;
+				margin:0;
+				color:orange;
+			}
+
+			#scene_explorer a {
+				color:#555;
+				font-weight:bold;
+				text-decoration:none;
+				font-size:1.2em;
+				font-family:Monospace;
+			}
+			#scene_explorer a:hover {
+				background:#555;
+				color:rgba(0,0,50,1);
+			}
+
+			.part {
+				display:none;
+				padding:0 0 0.5em 2em;
+			}
+
+		</style>
+	</head>
+
+	<body>
+		<div id="info">
+			<a href="http://github.com/mrdoob/three.js">three.js</a> - scene loader test [blender]
+		</div>
+
+		<div id="scene_explorer">
+			<a id="plus_exp" href="#">[+]</a>
+			<div id="section_exp"></div>
+		</div>
+
+		<div id="progress">
+			<span id="message">Loading ...</span>
+
+			<center>
+				<div id="progressbar" class="shadow"><div id="bar" class="shadow"></div></div>
+				<div id="start" class="disabled">Start</div>
+			</center>
+		</div>
+
+		<pre id="log"></pre>
+<!--
+		<script type="text/javascript" src="../build/Three.js"></script>
+-->
+
+		<script type="text/javascript" src="../src/Three.js"></script>
+		<script type="text/javascript" src="../src/core/Color.js"></script>
+		<script type="text/javascript" src="../src/core/Vector2.js"></script>
+		<script type="text/javascript" src="../src/core/Vector3.js"></script>
+		<script type="text/javascript" src="../src/core/Vector4.js"></script>
+		<script type="text/javascript" src="../src/core/Ray.js"></script>
+		<script type="text/javascript" src="../src/core/Rectangle.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix3.js"></script>
+		<script type="text/javascript" src="../src/core/Matrix4.js"></script>
+		<script type="text/javascript" src="../src/core/Object3D.js"></script>
+		<script type="text/javascript" src="../src/core/Quaternion.js"></script>
+		<script type="text/javascript" src="../src/core/Vertex.js"></script>
+		<script type="text/javascript" src="../src/core/Face3.js"></script>
+		<script type="text/javascript" src="../src/core/Face4.js"></script>
+		<script type="text/javascript" src="../src/core/UV.js"></script>
+		<script type="text/javascript" src="../src/core/Geometry.js"></script>
+		<script type="text/javascript" src="../src/core/Spline.js"></script>
+		<script type="text/javascript" src="../src/animation/AnimationHandler.js"></script>
+		<script type="text/javascript" src="../src/animation/Animation.js"></script>
+		<script type="text/javascript" src="../src/cameras/Camera.js"></script>
+		<script type="text/javascript" src="../src/lights/Light.js"></script>
+		<script type="text/javascript" src="../src/lights/AmbientLight.js"></script>
+		<script type="text/javascript" src="../src/lights/DirectionalLight.js"></script>
+		<script type="text/javascript" src="../src/lights/PointLight.js"></script>
+		<script type="text/javascript" src="../src/materials/Material.js"></script>
+		<script type="text/javascript" src="../src/materials/Mappings.js"></script>
+		<script type="text/javascript" src="../src/materials/LineBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshLambertMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshPhongMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshDepthMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshNormalMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshFaceMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/MeshShaderMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ShadowVolumeDynamicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleBasicMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleCanvasMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/ParticleDOMMaterial.js"></script>
+		<script type="text/javascript" src="../src/materials/Texture.js"></script>
+		<script type="text/javascript" src="../src/materials/RenderTarget.js"></script>
+		<script type="text/javascript" src="../src/materials/Uniforms.js"></script>
+		<script type="text/javascript" src="../src/objects/Particle.js"></script>
+		<script type="text/javascript" src="../src/objects/ParticleSystem.js"></script>
+		<script type="text/javascript" src="../src/objects/Line.js"></script>
+		<script type="text/javascript" src="../src/objects/Mesh.js"></script>
+		<script type="text/javascript" src="../src/objects/Bone.js"></script>
+		<script type="text/javascript" src="../src/objects/SkinnedMesh.js"></script>
+		<script type="text/javascript" src="../src/objects/Ribbon.js"></script>
+		<script type="text/javascript" src="../src/objects/Sound.js"></script>
+		<script type="text/javascript" src="../src/objects/LOD.js"></script>
+		<script type="text/javascript" src="../src/objects/ShadowVolume.js"></script>
+		<script type="text/javascript" src="../src/scenes/Scene.js"></script>
+		<script type="text/javascript" src="../src/scenes/Fog.js"></script>
+		<script type="text/javascript" src="../src/scenes/FogExp2.js"></script>
+		<script type="text/javascript" src="../src/renderers/Projector.js"></script>
+		<script type="text/javascript" src="../src/renderers/DOMRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/CanvasRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/SVGRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLShaders.js"></script>
+		<script type="text/javascript" src="../src/renderers/WebGLRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/SoundRenderer.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableVertex.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace3.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableFace4.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableObject.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableParticle.js"></script>
+		<script type="text/javascript" src="../src/renderers/renderables/RenderableLine.js"></script>
+		<script type="text/javascript" src="../src/extras/GeometryUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/ImageUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/SceneUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/ShaderUtils.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/QuakeCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/cameras/PathCamera.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Cube.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Cylinder.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Icosahedron.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Lathe.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Plane.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Sphere.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/Torus.js"></script>
+		<script type="text/javascript" src="../src/extras/geometries/TorusKnot.js"></script>
+		<script type="text/javascript" src="../src/extras/io/Loader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/JSONLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/io/BinaryLoader.js"></script>
+		<script type="text/javascript" src="../src/extras/objects/MarchingCubes.js"></script>
+		
+		<script type="text/javascript" src="js/Detector.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script type="text/javascript">
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var SCREEN_WIDTH = window.innerWidth;
+			var SCREEN_HEIGHT = window.innerHeight;
+
+			var container,stats;
+
+			var camera, scene, loaded;
+			var renderer;
+
+			var mesh, zmesh, geometry;
+
+			var mouseX = 0, mouseY = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+
+			init();
+			animate();
+
+			function $( id ) {
+
+				return document.getElementById( id );
+
+			}
+
+			function handle_update( result, pieces ) {
+
+				refreshSceneView( result );
+				renderer.initWebGLObjects( result.scene );
+
+				var m, material, count = 0;
+
+				for ( m in result.materials ) {
+
+					material = result.materials[ m ];
+					if ( ! ( material instanceof THREE.MeshFaceMaterial ) ) {
+
+						if( !material.program ) {
+
+							console.log(m);
+							renderer.initMaterial( material, result.scene.lights, result.scene.fog );
+
+							count += 1;
+							if( count > pieces ) {
+
+								//console.log("xxxxxxxxx");
+								break;
+
+							}
+
+						}
+
+					}
+
+				}
+
+			}
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				var loadScene = createLoadScene();
+				scene  = loadScene.scene;
+				camera = loadScene.camera;
+
+				renderer = new THREE.WebGLRenderer();
+				renderer.setSize( SCREEN_WIDTH, SCREEN_HEIGHT );
+				renderer.domElement.style.position = "relative";
+				container.appendChild( renderer.domElement );
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				stats.domElement.style.right = '0px';
+				stats.domElement.style.zIndex = 100;
+				container.appendChild( stats.domElement );
+
+				$( "start" ).addEventListener( 'click', onStartClick, false );
+
+				var callback_progress = function( progress, result ) {
+
+					var bar = 250,
+						total = progress.total_models + progress.total_textures,
+						loaded = progress.loaded_models + progress.loaded_textures;
+
+					if ( total )
+						bar = Math.floor( bar * loaded / total );
+
+					$( "bar" ).style.width = bar + "px";
+
+					count = 0;
+					for ( var m in result.materials ) count++;
+
+					handle_update( result, Math.floor( count/total ) );
+
+				}
+
+				var callback_sync = function( result ) {
+
+					/*
+
+					// uncomment to see progressive scene loading
+
+					scene = result.scene;
+					camera = result.currentCamera;
+
+					camera.aspect = window.innerWidth / window.innerHeight;
+					camera.updateProjectionMatrix();
+
+					renderer.setClearColor( result.bgColor, result.bgAlpha );
+
+					*/
+
+					//handle_update( result, 1 );
+
+				}
+
+				var callback_async = function( result ) {
+
+					loaded = result;
+
+					$( "message" ).style.display = "none";
+					$( "progressbar" ).style.display = "none";
+					$( "start" ).style.display = "block";
+					$( "start" ).className = "enabled";
+
+					handle_update( result, 1 );
+
+				}
+
+				$( "progress" ).style.display = "block";
+				SceneUtils.loadScene( "obj/blenderscene/scene.js", callback_sync, callback_async, callback_progress );
+
+				$( "plus_exp" ).addEventListener( 'click', createToggle( "exp" ), false );
+
+			}
+
+			function setButtonActive( id ) {
+
+				$( "start" ).style.backgroundColor = "green";
+
+			}
+
+			function onStartClick() {
+
+				$( "progress" ).style.display = "none";
+
+				scene = loaded.scene;
+				camera = loaded.currentCamera;
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+				renderer.setClearColor( loaded.bgColor, loaded.bgAlpha );
+
+			}
+
+			function onDocumentMouseMove(event) {
+
+				mouseX = ( event.clientX - windowHalfX );
+				mouseY = ( event.clientY - windowHalfY );
+
+			}
+
+			function createLoadScene() {
+
+				var result = {
+
+					scene:  new THREE.Scene(),
+					camera: new THREE.Camera( 65, window.innerWidth / window.innerHeight, 1, 1000 )
+
+				};
+
+				result.camera.position.z = 100;
+
+				var object, geometry, material, light, count = 500, range = 200;
+
+				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
+				geometry = new Cube( 5, 5, 5 );
+
+				for( var i = 0; i < count; i++ ) {
+
+					object = new THREE.Mesh( geometry, material );
+					object.position.x = ( Math.random() - 0.5 ) * range;
+					object.position.y = ( Math.random() - 0.5 ) * range;
+					object.position.z = ( Math.random() - 0.5 ) * range;
+					object.rotation.x = Math.random() * 6;
+					object.rotation.y = Math.random() * 6;
+					object.rotation.z = Math.random() * 6;
+					object.matrixAutoUpdate = false;
+					object.updateMatrix();
+					result.scene.addObject( object );
+
+				}
+
+				result.scene.matrixAutoUpdate = false;
+
+				light = new THREE.PointLight( 0xffffff );
+				result.scene.addLight( light );
+
+				light = new THREE.DirectionalLight( 0x111111 );
+				light.position.x = 1;
+				result.scene.addLight( light );
+
+				return result;
+
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				camera.position.x += ( mouseX - camera.position.x ) * .001;
+				camera.position.y += ( - mouseY - camera.position.y ) * .001;
+
+				renderer.render( scene, camera );
+
+			}
+
+			function log( text ) {
+
+				var e = $("log");
+				e.innerHTML = text + "<br/>" + e.innerHTML;
+
+			}
+
+			// Scene explorer user interface
+
+			function toggle( id ) {
+
+				var scn = $( "section_" + id ).style,
+					btn = $( "plus_" + id );
+
+				if ( scn.display == "block" ) {
+
+					scn.display = "none";
+					btn.innerHTML = "[+]";
+
+				}
+				else {
+
+					scn.display = "block";
+					btn.innerHTML = "[-]";
+
+				}
+
+			}
+
+			function createToggle( label ) { return function() { toggle( label ) } };
+
+			function refreshSceneView( result ) {
+
+				$( "section_exp" ).innerHTML = generateSceneView( result );
+
+				var config = [ "obj", "geo", "mat", "tex", "lit", "cam" ];
+
+				for ( var i = 0; i < config.length; i++ )
+					$( "plus_" + config[i] ).addEventListener( 'click', createToggle( config[i] ), false );
+
+			}
+
+			function generateSection( label, id, objects ) {
+
+				var html = "";
+
+				html += "<h3><a id='plus_" + id + "' href='#'>[+]</a> " + label + "</h3>";
+				html += "<div id='section_" + id + "' class='part'>";
+
+				for( var o in objects ) {
+
+					html += o + "<br/>";
+
+				}
+				html += "</div>";
+
+				return html;
+
+			}
+
+			function generateSceneView( result ) {
+
+				var config = [
+				[ "Objects",    "obj", result.objects ],
+				[ "Geometries", "geo", result.geometries ],
+				[ "Materials",  "mat", result.materials ],
+				[ "Textures",   "tex", result.textures ],
+				[ "Lights",     "lit", result.lights ],
+				[ "Cameras",    "cam", result.cameras ]
+				];
+
+				var html = "";
+
+				for ( var i = 0; i < config.length; i++ )
+					html += generateSection( config[i][0], config[i][1], config[i][2] );
+
+				return html;
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 1 - 1
examples/webgl_stencil.html

@@ -1,7 +1,7 @@
 <!DOCTYPE HTML>
 <html lang="en">
 	<head>
-		<title>three.js - webgl</title>
+		<title>three.js webgl - stencil shadow</title>
 		<meta charset="utf-8">
 		<style type="text/css">
 			body {

+ 7 - 18
src/cameras/Camera.js

@@ -77,30 +77,19 @@ THREE.Camera.prototype.update = function ( parentMatrixWorld, forceUpdate, camer
 
 	} else {
 
-		if ( this.matrixAutoUpdate ) {
+		if ( parentMatrixWorld ) {
 
-			forceUpdate |= this.updateMatrix();
-
-		}
-
-		if ( forceUpdate || this.matrixWorldNeedsUpdate ) {
-
-			if ( parentMatrixWorld ) {
-
-				this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
-
-			} else {
+			this.matrixWorld.multiply( parentMatrixWorld, this.matrix );
 
-				this.matrixWorld.copy( this.matrix );
+		} else {
 
-			}
+			this.matrixWorld.copy( this.matrix );
 
-			this.matrixWorldNeedsUpdate = false;
-			forceUpdate = true;
+		}
 
-			THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse );
+		THREE.Matrix4.makeInvert( this.matrixWorld, this.matrixWorldInverse );
 
-		}
+		forceUpdate = true;
 
 	}
 

+ 63 - 16
src/extras/SceneUtils.js

@@ -9,6 +9,8 @@ var SceneUtils = {
 		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,
@@ -41,6 +43,20 @@ var SceneUtils = {
 
 			};
 
+			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 ) {
@@ -62,11 +78,33 @@ var SceneUtils = {
 
 							p = o.position;
 							r = o.rotation;
+							q = o.quaternion;
 							s = o.scale;
-
+							
+							// turn off quaternions, for the moment
+							
+							q = 0;
+
+							if ( materials.length == 0 ) {
+								
+								materials[ 0 ] = new THREE.MeshFaceMaterial();
+								
+							}
+							
 							object = new THREE.Mesh( geometry, materials );
 							object.position.set( p[0], p[1], p[2] );
-							object.rotation.set( r[0], r[1], r[2] );
+							
+							if ( q ) {
+								
+								object.quaternion.set( q[0], q[1], q[2], q[3] );
+								object.useQuaternion = true;
+								
+							} else {
+
+								object.rotation.set( r[0], r[1], r[2] );
+								
+							}
+							
 							object.scale.set( s[0], s[1], s[2] );
 							object.visible = o.visible;
 
@@ -161,15 +199,20 @@ var SceneUtils = {
 
 			// lights
 
+			var hex, intensity;
+			
 			for( dl in data.lights ) {
 
 				l = data.lights[ dl ];
 
+				hex = ( l.color !== undefined ) ? l.color : 0xffffff;
+				intensity = ( l.intensity !== undefined ) ? l.intensity : 1;
+				
 				if ( l.type == "directional" ) {
 
 					p = l.direction;
 
-					light = new THREE.DirectionalLight();
+					light = new THREE.DirectionalLight( hex, intensity );
 					light.position.set( p[0], p[1], p[2] );
 					light.position.normalize();
 
@@ -177,15 +220,11 @@ var SceneUtils = {
 
 					p = l.position;
 
-					light = new THREE.PointLight();
+					light = new THREE.PointLight( hex, intensity );
 					light.position.set( p[0], p[1], p[2] );
 
 				}
 
-				c = l.color;
-				i = l.intensity || 1;
-				light.color.setRGB( c[0] * i, c[1] * i, c[2] * i );
-
 				result.scene.addLight( light );
 
 				result.lights[ dl ] = light;
@@ -254,7 +293,7 @@ var SceneUtils = {
 			}
 
 			total_models = counter_models;
-
+			
 			for( dg in data.geometries ) {
 
 				g = data.geometries[ dg ];
@@ -291,13 +330,13 @@ var SceneUtils = {
 
 				} else if ( g.type == "bin_mesh" ) {
 
-					binLoader.load( { model: g.url,
+					binLoader.load( { model: get_url( g.url, data.urlBaseType ),
 									  callback: create_callback( dg )
 									} );
 
 				} else if ( g.type == "ascii_mesh" ) {
 
-					jsonLoader.load( { model: g.url,
+					jsonLoader.load( { model: get_url( g.url, data.urlBaseType ),
 									   callback: create_callback( dg )
 									} );
 
@@ -336,14 +375,22 @@ var SceneUtils = {
 					tt.mapping = new THREE[ tt.mapping ]();
 
 				}
-
+				
 				if( tt.url instanceof Array ) {
-
-					texture = ImageUtils.loadTextureCube( tt.url, tt.mapping, callback_texture );
+				
+					var url_array = [];
+					
+					for( var i = 0; i < tt.url.length; i ++ ) {
+					
+						url_array[ i ] = get_url( tt.url[ i ], data.urlBaseType );
+						
+					}
+					
+					texture = ImageUtils.loadTextureCube( url_array, tt.mapping, callback_texture );
 
 				} else {
-
-					texture = ImageUtils.loadTexture( tt.url, tt.mapping, callback_texture );
+					
+					texture = ImageUtils.loadTexture( get_url( tt.url, data.urlBaseType ), tt.mapping, callback_texture );
 
 					if ( THREE[ tt.minFilter ] != undefined )
 						texture.minFilter = THREE[ tt.minFilter ];

+ 243 - 250
src/extras/io/JSONLoader.js

@@ -6,7 +6,7 @@
 THREE.JSONLoader = function ( showStatus ) {
 
 	THREE.Loader.call( this, showStatus );
-	
+
 };
 
 THREE.JSONLoader.prototype = new THREE.Loader();
@@ -14,342 +14,335 @@ THREE.JSONLoader.prototype.constructor = THREE.JSONLoader;
 THREE.JSONLoader.prototype.supr = THREE.Loader.prototype;
 
 
-THREE.JSONLoader.prototype = {
+/**
+ * Load models generated by slim OBJ converter with ASCII option (converter_obj_three_slim.py -t ascii)
+ *  - parameters
+ *  - model (required)
+ *  - callback (required)
+ *  - texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
+ */
 
-	// Load models generated by slim OBJ converter with ASCII option (converter_obj_three_slim.py -t ascii)
-	//  - parameters
-	//		- model (required)
-	//		- callback (required)
-	//		- texture_path (optional: if not specified, textures will be assumed to be in the same folder as JS model file)
+THREE.JSONLoader.prototype.load = function ( parameters ) {
 
-	load: function ( parameters ) {
-		
-		var url = parameters.model,
-			callback = parameters.callback, 
-		    texture_path = parameters.texture_path ? parameters.texture_path : THREE.Loader.prototype.extractUrlbase( url ),
-		
-			s = (new Date).getTime(),
-			worker = new Worker( url );
-		
-		worker.onmessage = function( event ) {
-			
-			THREE.JSONLoader.prototype.createModel( event.data, callback, texture_path );
+	var scope = this,
+		url = parameters.model,
+		callback = parameters.callback, 
+		texture_path = parameters.texture_path ? parameters.texture_path : this.extractUrlbase( url ),
+		worker = new Worker( url );
 
-		};
+	worker.onmessage = function ( event ) {
 
-		worker.postMessage( s );
+		scope.createModel( event.data, callback, texture_path );
+		scope.onLoadComplete();
 
-	},
-	
-	createModel: function ( json, callback, texture_path ) {
+	};
 
-		var Model = function ( texture_path ) {
+	this.onLoadStart();
+	worker.postMessage( new Date().getTime() );
 
-			var scope = this;
+};
 
-			THREE.Geometry.call( this );
+THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path ) {
 
-			THREE.Loader.prototype.init_materials( scope, json.materials, texture_path );
-			
-			parse();
-			init_skin();
-			init_morphing();
+	var scope = this,
+	geometry = new THREE.Geometry();
 
-			this.computeCentroids();
-			this.computeFaceNormals();
-			
-			function parse() {
+	this.init_materials( geometry, json.materials, texture_path );
 
-				if ( json.version === undefined || json.version != 2 ) {
+	parse();
 
-					console.error( 'Deprecated file format.' );
-					return;
+	init_skin();
+	init_morphing();
 
-				}
-	
-				function isBitSet( value, position ) {
-					
-					return value & ( 1 << position );
-
-				};
-				
-				var i, j, fi,
-				
-				offset, zLength,
-
-				type,
-				isQuad, 
-				hasMaterial, 
-				hasFaceUv, hasFaceVertexUv,
-				hasFaceNormal, hasFaceVertexNormal,
-				hasFaceColor, hasFaceVertexColor,
-
-				vertex, face,
-				
-				faces = json.faces,
-				vertices = json.vertices,
-				normals = json.normals,
-				colors = json.colors,
-
-				nUvLayers = 0;
-				
-				// disregard empty arrays
-				
-				for ( i = 0; i < json.uvs.length; i++ ) {
-					
-					if ( json.uvs[ i ].length ) nUvLayers ++;
+	geometry.computeCentroids();
+	geometry.computeFaceNormals();
 
-				}
-				
-				for ( i = 0; i < nUvLayers; i++ ) {
+	function parse() {
 
-					scope.faceUvs[ i ] = [];
-					scope.faceVertexUvs[ i ] = [];
+		if ( json.version === undefined || json.version != 2 ) {
 
-				}
+			console.error( 'Deprecated file format.' );
+			return;
 
-				offset = 0;
-				zLength = vertices.length;
-				
-				while ( offset < zLength ) {
+		}
 
-					vertex = new THREE.Vertex();
-					
-					vertex.position.x = vertices[ offset ++ ];
-					vertex.position.y = vertices[ offset ++ ];
-					vertex.position.z = vertices[ offset ++ ];
+		function isBitSet( value, position ) {
 
-					scope.vertices.push( vertex );
+			return value & ( 1 << position );
 
-				}
-				
-				offset = 0;
-				zLength = faces.length;
+		};
 
-				while ( offset < zLength ) {
+		var i, j, fi,
 
-					type = faces[ offset ++ ];
+		offset, zLength,
 
-					
-					isQuad          	= isBitSet( type, 0 );
-					hasMaterial         = isBitSet( type, 1 );
-					hasFaceUv           = isBitSet( type, 2 );
-					hasFaceVertexUv     = isBitSet( type, 3 );
-					hasFaceNormal       = isBitSet( type, 4 );
-					hasFaceVertexNormal = isBitSet( type, 5 );
-					hasFaceColor	    = isBitSet( type, 6 );
-					hasFaceVertexColor  = isBitSet( type, 7 );
+		type,
+		isQuad, 
+		hasMaterial, 
+		hasFaceUv, hasFaceVertexUv,
+		hasFaceNormal, hasFaceVertexNormal,
+		hasFaceColor, hasFaceVertexColor,
 
-					//console.log("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
+		vertex, face,
 
-					if ( isQuad ) {
+		faces = json.faces,
+		vertices = json.vertices,
+		normals = json.normals,
+		colors = json.colors,
 
-						face = new THREE.Face4();
-						
-						face.a = faces[ offset ++ ];
-						face.b = faces[ offset ++ ];
-						face.c = faces[ offset ++ ];
-						face.d = faces[ offset ++ ];
+		nUvLayers = 0;
 
-						nVertices = 4;
+		// disregard empty arrays
 
-					} else {
+		for ( i = 0; i < json.uvs.length; i++ ) {
 
-						face = new THREE.Face3();
-					
-						face.a = faces[ offset ++ ];
-						face.b = faces[ offset ++ ];
-						face.c = faces[ offset ++ ];
+			if ( json.uvs[ i ].length ) nUvLayers ++;
 
-						nVertices = 3;
+		}
 
-					}
-					
-					if ( hasMaterial ) {
+		for ( i = 0; i < nUvLayers; i++ ) {
 
-						materialIndex = faces[ offset ++ ];
-						face.materials = scope.materials[ materialIndex ];
+			geometry.faceUvs[ i ] = [];
+			geometry.faceVertexUvs[ i ] = [];
 
-					}
+		}
 
-					if ( hasFaceUv ) {
+		offset = 0;
+		zLength = vertices.length;
 
-						for ( i = 0; i < nUvLayers; i++ ) {
+		while ( offset < zLength ) {
 
-							uvLayer = json.uvs[ i ];
+			vertex = new THREE.Vertex();
 
-							uvIndex = faces[ offset ++ ];
+			vertex.position.x = vertices[ offset ++ ];
+			vertex.position.y = vertices[ offset ++ ];
+			vertex.position.z = vertices[ offset ++ ];
 
-							u = uvLayer[ uvIndex * 2 ];
-							v = uvLayer[ uvIndex * 2 + 1 ];
+			geometry.vertices.push( vertex );
 
-							scope.faceUvs[ i ].push( new THREE.UV( u, v ) );
+		}
 
-						}
+		offset = 0;
+		zLength = faces.length;
 
-					}
+		while ( offset < zLength ) {
 
-					if ( hasFaceVertexUv ) {
+			type = faces[ offset ++ ];
 
-						for ( i = 0; i < nUvLayers; i++ ) {
-							
-							uvLayer = json.uvs[ i ];
 
-							uvs = [];
+			isQuad          	= isBitSet( type, 0 );
+			hasMaterial         = isBitSet( type, 1 );
+			hasFaceUv           = isBitSet( type, 2 );
+			hasFaceVertexUv     = isBitSet( type, 3 );
+			hasFaceNormal       = isBitSet( type, 4 );
+			hasFaceVertexNormal = isBitSet( type, 5 );
+			hasFaceColor	    = isBitSet( type, 6 );
+			hasFaceVertexColor  = isBitSet( type, 7 );
 
-							for ( j = 0; j < nVertices; j ++ ) {
+			//console.log("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor);
 
-								uvIndex = faces[ offset ++ ];
+			if ( isQuad ) {
 
-								u = uvLayer[ uvIndex * 2 ];
-								v = uvLayer[ uvIndex * 2 + 1 ];
+				face = new THREE.Face4();
 
-								uvs[ j ] = new THREE.UV( u, v );
+				face.a = faces[ offset ++ ];
+				face.b = faces[ offset ++ ];
+				face.c = faces[ offset ++ ];
+				face.d = faces[ offset ++ ];
 
-							}
+				nVertices = 4;
 
-							// to get face <=> uv index correspondence
-							
-							fi = scope.faces.length;
-							scope.faceVertexUvs[ i ][ fi ] = uvs;
+			} else {
 
-						}
+				face = new THREE.Face3();
 
-					}
+				face.a = faces[ offset ++ ];
+				face.b = faces[ offset ++ ];
+				face.c = faces[ offset ++ ];
 
-					if ( hasFaceNormal ) {
+				nVertices = 3;
 
-						normalIndex = faces[ offset ++ ] * 3;
+			}
 
-						normal = new THREE.Vector3();
-						
-						normal.x = normals[ normalIndex ++ ];
-						normal.y = normals[ normalIndex ++ ];
-						normal.z = normals[ normalIndex ];
+			if ( hasMaterial ) {
 
-						face.normal = normal;
+				materialIndex = faces[ offset ++ ];
+				face.materials = geometry.materials[ materialIndex ];
 
-					}
+			}
+
+			// to get face <=> uv index correspondence
 
-					if ( hasFaceVertexNormal ) {
+			fi = geometry.faces.length;
 
-						for ( i = 0; i < nVertices; i++ ) {
+			if ( hasFaceUv ) {
 
-							normalIndex = faces[ offset ++ ] * 3;
+				for ( i = 0; i < nUvLayers; i++ ) {
 
-							normal = new THREE.Vector3();
-							
-							normal.x = normals[ normalIndex ++ ];
-							normal.y = normals[ normalIndex ++ ];
-							normal.z = normals[ normalIndex ];
+					uvLayer = json.uvs[ i ];
 
-							face.vertexNormals.push( normal );
+					uvIndex = faces[ offset ++ ];
 
-						}
+					u = uvLayer[ uvIndex * 2 ];
+					v = uvLayer[ uvIndex * 2 + 1 ];
 
-					}
+					geometry.faceUvs[ i ][ fi ] = new THREE.UV( u, v );
 
-				
-					if ( hasFaceColor ) {
+				}
 
-						color = new THREE.Color( faces[ offset ++ ] );
-						face.color = color;
+			}
 
-					}
+			if ( hasFaceVertexUv ) {
+
+				for ( i = 0; i < nUvLayers; i++ ) {
+
+					uvLayer = json.uvs[ i ];
 
-					
-					if ( hasFaceVertexColor ) {
+					uvs = [];
 
-						for ( i = 0; i < nVertices; i++ ) {
+					for ( j = 0; j < nVertices; j ++ ) {
 
-							colorIndex = faces[ offset ++ ];
-							
-							color = new THREE.Color( colors[ colorIndex ] );
-							face.vertexColors.push( color );
-							
-						}
+						uvIndex = faces[ offset ++ ];
+
+						u = uvLayer[ uvIndex * 2 ];
+						v = uvLayer[ uvIndex * 2 + 1 ];
+
+						uvs[ j ] = new THREE.UV( u, v );
 
 					}
 
-					scope.faces.push( face );
+					geometry.faceVertexUvs[ i ][ fi ] = uvs;
 
 				}
 
-			};
-			
-			function init_skin() {
-				
-				var i, l, x, y, z, w, a, b, c, d;
+			}
 
-				if ( json.skinWeights ) {
-					
-					for( i = 0, l = json.skinWeights.length; i < l; i += 2 ) {
+			if ( hasFaceNormal ) {
 
-						x = json.skinWeights[ i     ];
-						y = json.skinWeights[ i + 1 ];
-						z = 0;
-						w = 0;
-						
-						scope.skinWeights.push( new THREE.Vector4( x, y, z, w ) );
+				normalIndex = faces[ offset ++ ] * 3;
+
+				normal = new THREE.Vector3();
+
+				normal.x = normals[ normalIndex ++ ];
+				normal.y = normals[ normalIndex ++ ];
+				normal.z = normals[ normalIndex ];
+
+				face.normal = normal;
+
+			}
+
+			if ( hasFaceVertexNormal ) {
+
+				for ( i = 0; i < nVertices; i++ ) {
+
+					normalIndex = faces[ offset ++ ] * 3;
+
+					normal = new THREE.Vector3();
+
+					normal.x = normals[ normalIndex ++ ];
+					normal.y = normals[ normalIndex ++ ];
+					normal.z = normals[ normalIndex ];
+
+					face.vertexNormals.push( normal );
 
-					}
-					
 				}
-				
-				if ( json.skinIndices ) {
-					
-					for( i = 0, l = json.skinIndices.length; i < l; i += 2 ) {
 
-						a = json.skinIndices[ i     ];
-						b = json.skinIndices[ i + 1 ];
-						c = 0;
-						d = 0;
+			}
 
-						scope.skinIndices.push( new THREE.Vector4( a, b, c, d ) );
 
-					}
-				
+			if ( hasFaceColor ) {
+
+				color = new THREE.Color( faces[ offset ++ ] );
+				face.color = color;
+
+			}
+
+
+			if ( hasFaceVertexColor ) {
+
+				for ( i = 0; i < nVertices; i++ ) {
+
+					colorIndex = faces[ offset ++ ];
+
+					color = new THREE.Color( colors[ colorIndex ] );
+					face.vertexColors.push( color );
+
 				}
-				
-				scope.bones = json.bones;
-				scope.animation = json.animation;
-				
-			};
-			
-			function init_morphing() {
-
-				if( json.morphTargets !== undefined ) {
-					
-					var i, l, v, vl;
-					
-					for( i = 0, l = json.morphTargets.length; i < l; i++ ) {
-						
-						scope.morphTargets[ i ] = {};
-						scope.morphTargets[ i ].name = json.morphTargets[ i ].name;
-						scope.morphTargets[ i ].vertices = [];
-						
-						dstVertices = scope.morphTargets[ i ].vertices;
-						srcVertices = json.morphTargets [ i ].vertices;
-
-						for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
-
-							dstVertices.push( new THREE.Vertex( new THREE.Vector3( srcVertices[ v ], srcVertices[ v + 1 ], srcVertices[ v + 2 ] ) ) );
-
-						}
-						
-					} 
-					
+
+			}
+
+			geometry.faces.push( face );
+
+		}
+
+	};
+
+	function init_skin() {
+
+		var i, l, x, y, z, w, a, b, c, d;
+
+		if ( json.skinWeights ) {
+
+			for( i = 0, l = json.skinWeights.length; i < l; i += 2 ) {
+
+				x = json.skinWeights[ i     ];
+				y = json.skinWeights[ i + 1 ];
+				z = 0;
+				w = 0;
+
+				geometry.skinWeights.push( new THREE.Vector4( x, y, z, w ) );
+
+			}
+
+		}
+
+		if ( json.skinIndices ) {
+
+			for( i = 0, l = json.skinIndices.length; i < l; i += 2 ) {
+
+				a = json.skinIndices[ i     ];
+				b = json.skinIndices[ i + 1 ];
+				c = 0;
+				d = 0;
+
+				geometry.skinIndices.push( new THREE.Vector4( a, b, c, d ) );
+
+			}
+
+		}
+
+		geometry.bones = json.bones;
+		geometry.animation = json.animation;
+
+	};
+
+	function init_morphing() {
+
+		if( json.morphTargets !== undefined ) {
+
+			var i, l, v, vl;
+
+			for( i = 0, l = json.morphTargets.length; i < l; i++ ) {
+
+				geometry.morphTargets[ i ] = {};
+				geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
+				geometry.morphTargets[ i ].vertices = [];
+
+				dstVertices = geometry.morphTargets[ i ].vertices;
+				srcVertices = json.morphTargets [ i ].vertices;
+
+				for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
+
+					dstVertices.push( new THREE.Vertex( new THREE.Vector3( srcVertices[ v ], srcVertices[ v + 1 ], srcVertices[ v + 2 ] ) ) );
+
 				}
 
-			};
-			
-		};
+			} 
 
-		Model.prototype = new THREE.Geometry();
-		Model.prototype.constructor = Model;
+		}
 
-		callback( new Model( texture_path ) );
+	};
 
-	}
+	callback( geometry );
 
-};
+}

+ 37 - 34
src/extras/io/Loader.js

@@ -4,34 +4,38 @@
 
 THREE.Loader = function ( showStatus ) {
 
-	this.showStatus = showStatus;	
+	this.showStatus = showStatus;
 	this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null;
 
+	this.onLoadStart = function () {};
+	this.onLoadProgress = function() {};
+	this.onLoadComplete = function () {};
+
 };
 
 THREE.Loader.prototype = {
 
-	addStatusElement: function ( ) {
-		
+	addStatusElement: function () {
+
 		var e = document.createElement( "div" );
-		
-		e.style.fontSize = "0.8em"; 
-		e.style.textAlign = "left";
-		e.style.background = "#b00"; 
-		e.style.color = "#fff"; 
-		e.style.width = "140px"; 
-		e.style.padding = "0.25em 0.25em 0.25em 0.5em"; 
+
 		e.style.position = "absolute"; 
 		e.style.right = "0px"; 
 		e.style.top = "0px"; 
+		e.style.fontSize = "0.8em"; 
+		e.style.textAlign = "left";
+		e.style.background = "rgba(0,0,0,0.25)"; 
+		e.style.color = "#fff"; 
+		e.style.width = "120px"; 
+		e.style.padding = "0.5em 0.5em 0.5em 0.5em"; 
 		e.style.zIndex = 1000;
-		
+
 		e.innerHTML = "Loading ...";
-		
+
 		return e;
-		
+
 	},
-	
+
 	updateProgress: function ( progress ) {
 
 		var message = "Loaded ";
@@ -50,13 +54,13 @@ THREE.Loader.prototype = {
 		this.statusDomElement.innerHTML = message;
 
 	},
-	
+
 	extractUrlbase: function( url ) {
-		
+
 		var chunks = url.split( "/" );
 		chunks.pop();
 		return chunks.join( "/" );
-		
+
 	},
 
 	init_materials: function( scope, materials, texture_path ) {
@@ -88,9 +92,9 @@ THREE.Loader.prototype = {
 		}
 
 		function load_image( where, url ) {
-			
+
 			var image = new Image();
-			
+
 			image.onload = function () {
 
 				if ( !is_pow2( this.width ) || !is_pow2( this.height ) ) {
@@ -113,20 +117,21 @@ THREE.Loader.prototype = {
 			};
 
 			image.src = url;
-			
+
 		}
-		
+
 		var material, mtype, mpars, texture, color;
 
 		// defaults
-		
+
 		mtype = "MeshLambertMaterial";
-		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, vertexColors: m.vertexColors ? THREE.VertexColors : false };
+
+		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, vertexColors: m.vertexColors ? THREE.VertexColors : false, wireframe: m.wireframe };
 		
 		// parameters from model file
-		
+
 		if ( m.shading ) {
-			
+
 			if ( m.shading == "Phong" ) mtype = "MeshPhongMaterial";
 			else if ( m.shading == "Basic" ) mtype = "MeshBasicMaterial";
 
@@ -135,10 +140,10 @@ THREE.Loader.prototype = {
 		if ( m.mapDiffuse && texture_path ) {
 
 			texture = document.createElement( 'canvas' );
-			
+
 			mpars.map = new THREE.Texture( texture );
 			mpars.map.sourceFile = m.mapDiffuse;
-			
+
 			load_image( mpars.map, texture_path + "/" + m.mapDiffuse );
 
 		} else if ( m.colorDiffuse ) {
@@ -156,20 +161,18 @@ THREE.Loader.prototype = {
 		if ( m.mapLightmap && texture_path ) {
 
 			texture = document.createElement( 'canvas' );
-			
+
 			mpars.lightMap = new THREE.Texture( texture );
 			mpars.lightMap.sourceFile = m.mapLightmap;
-			
+
 			load_image( mpars.lightMap, texture_path + "/" + m.mapLightmap );
 
 		}
-		
+
 		material = new THREE[ mtype ]( mpars );
 
 		return material;
 
-	}	
-	
-};
-	
+	}
 
+};

+ 2 - 1
src/lights/DirectionalLight.js

@@ -2,12 +2,13 @@
  * @author mr.doob / http://mrdoob.com/
  */
 
-THREE.DirectionalLight = function ( hex, intensity ) {
+THREE.DirectionalLight = function ( hex, intensity, distance ) {
 
 	THREE.Light.call( this, hex );
 
 	this.position = new THREE.Vector3( 0, 1, 0 );
 	this.intensity = intensity || 1;
+	this.distance = distance || 0;
 
 };
 

+ 2 - 1
src/lights/PointLight.js

@@ -2,12 +2,13 @@
  * @author mr.doob / http://mrdoob.com/
  */
 
-THREE.PointLight = function ( hex, intensity ) {
+THREE.PointLight = function ( hex, intensity, distance ) {
 
 	THREE.Light.call( this, hex );
 
 	this.position = new THREE.Vector3();
 	this.intensity = intensity || 1;
+	this.distance = distance || 0;
 
 };
 

+ 3 - 3
src/materials/Material.js

@@ -13,8 +13,8 @@ THREE.VertexColors = 2;
 THREE.NormalBlending = 0;
 THREE.AdditiveBlending = 1;
 THREE.SubtractiveBlending = 2;
-THREE.BillboardBlending = 3;
-THREE.ReverseSubtractiveBlending = 4;
-THREE.AdditiveAlphaBlending = 5;
+THREE.MultiplyBlending = 3;
+THREE.AdditiveAlphaBlending = 4;
+
 
 THREE.MaterialCounter = { value: 0 };

+ 24 - 35
src/renderers/CanvasRenderer.js

@@ -358,12 +358,16 @@ THREE.CanvasRenderer = function () {
 
 				} else if ( light instanceof THREE.DirectionalLight ) {
 
+					// for particles
+
 					_directionalLights.r += lightColor.r;
 					_directionalLights.g += lightColor.g;
 					_directionalLights.b += lightColor.b;
 
 				} else if ( light instanceof THREE.PointLight ) {
 
+					// for particles
+
 					_pointLights.r += lightColor.r;
 					_pointLights.g += lightColor.g;
 					_pointLights.b += lightColor.b;
@@ -376,41 +380,41 @@ THREE.CanvasRenderer = function () {
 
 		function calculateLight( scene, position, normal, color ) {
 
-			var l, ll, light, lightColor, lightIntensity,
+			var l, ll, light, lightColor,
 			amount, lights = scene.lights;
 
 			for ( l = 0, ll = lights.length; l < ll; l ++ ) {
 
 				light = lights[ l ];
 				lightColor = light.color;
-				lightIntensity = light.intensity;
 
 				if ( light instanceof THREE.DirectionalLight ) {
 
-					amount = normal.dot( light.position ) * lightIntensity;
+					amount = normal.dot( light.position );
 
-					if ( amount > 0 ) {
+					if ( amount <= 0 ) continue;
 
-						color.r += lightColor.r * amount;
-						color.g += lightColor.g * amount;
-						color.b += lightColor.b * amount;
+					amount *= light.intensity;
 
-					}
+					color.r += lightColor.r * amount;
+					color.g += lightColor.g * amount;
+					color.b += lightColor.b * amount;
 
 				} else if ( light instanceof THREE.PointLight ) {
 
-					_vector3.sub( light.position, position );
-					_vector3.normalize();
+					amount = normal.dot( _vector3.sub( light.position, position ).normalize() );
 
-					amount = normal.dot( _vector3 ) * lightIntensity;
+					if ( amount <= 0 ) continue;
 
-					if ( amount > 0 ) {
+					amount *= light.distance == 0 ? 1 : 1 - Math.min( position.distanceTo( light.position ) / light.distance, 1 );
 
-						color.r += lightColor.r * amount;
-						color.g += lightColor.g * amount;
-						color.b += lightColor.b * amount;
+					if ( amount == 0 ) continue;
 
-					}
+					amount *= light.intensity;
+
+					color.r += lightColor.r * amount;
+					color.g += lightColor.g * amount;
+					color.b += lightColor.b * amount;
 
 				}
 
@@ -475,24 +479,6 @@ THREE.CanvasRenderer = function () {
 
 			} else if ( material instanceof THREE.ParticleCanvasMaterial ) {
 
-				if ( _enableLighting ) {
-
-					_light.r = _ambientLight.r + _directionalLights.r + _pointLights.r;
-					_light.g = _ambientLight.g + _directionalLights.g + _pointLights.g;
-					_light.b = _ambientLight.b + _directionalLights.b + _pointLights.b;
-
-					_color.r = material.color.r * _light.r;
-					_color.g = material.color.g * _light.g;
-					_color.b = material.color.b * _light.b;
-
-					_color.updateStyleString();
-
-				} else {
-
-					_color.__styleString = material.color.__styleString;
-
-				}
-
 				width = element.scale.x * _canvasWidthHalf;
 				height = element.scale.y * _canvasHeightHalf;
 
@@ -504,12 +490,15 @@ THREE.CanvasRenderer = function () {
 
 				}
 
+				setStrokeStyle( material.color.__styleString );
+				setFillStyle( material.color.__styleString );
+
 				_context.save();
 				_context.translate( v1.x, v1.y );
 				_context.rotate( - element.rotation );
 				_context.scale( width, height );
 
-				material.program( _context, _color );
+				material.program( _context );
 
 				_context.restore();
 

File diff suppressed because it is too large
+ 340 - 280
src/renderers/WebGLRenderer.js


+ 76 - 64
src/renderers/WebGLShaders.js

@@ -240,9 +240,10 @@ THREE.ShaderChunk = {
 
 		"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];",
 		"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];",
+		"uniform float pointLightDistance[ MAX_POINT_LIGHTS ];",
 
 		"#ifdef PHONG",
-			"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];",
+			"varying vec4 vPointLight[ MAX_POINT_LIGHTS ];",
 		"#endif",
 
 	"#endif"
@@ -275,18 +276,27 @@ THREE.ShaderChunk = {
 
 		"#if MAX_POINT_LIGHTS > 0",
 
-		"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
+			"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
 
-			"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
-			"vec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );",
-			"float pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );",
-			"vLightWeighting += pointLightColor[ i ] * pointLightWeighting;",
+				"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );",
 
-			"#ifdef PHONG",
-				"vPointLightVector[ i ] = pointLightVector;",
-			"#endif",
+				"vec3 lVector = lPosition.xyz - mvPosition.xyz;",
 
-		"}",
+				"float lDistance = 1.0;",
+
+				"if ( pointLightDistance[ i ] > 0.0 )",
+					"lDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );",
+
+				"lVector = normalize( lVector );",
+
+				"float pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );",
+				"vLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;",
+
+				"#ifdef PHONG",
+					"vPointLight[ i ] = vec4( lVector, lDistance );",
+				"#endif",
+
+			"}",
 
 		"#endif",
 
@@ -301,7 +311,7 @@ THREE.ShaderChunk = {
 	"#endif",
 
 	"#if MAX_POINT_LIGHTS > 0",
-		"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];",
+		"varying vec4 vPointLight[ MAX_POINT_LIGHTS ];",
 	"#endif",
 
 	"varying vec3 vViewPosition;",
@@ -322,22 +332,24 @@ THREE.ShaderChunk = {
 		"vec4 pointDiffuse  = vec4( 0.0 );",
 		"vec4 pointSpecular = vec4( 0.0 );",
 
-		"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {",
+		"for ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {",
 
-			"vec3 pointVector = normalize( vPointLightVector[ i ] );",
-			"vec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );",
+			"vec3 pointVector = normalize( vPointLight[ i ].xyz );",
+			"vec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );",
+			"float pointDistance = vPointLight[ i ].w;",
 
 			"float pointDotNormalHalf = dot( normal, pointHalfVector );",
 			"float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );",
 
 			"float pointSpecularWeight = 0.0;",
+
 			"if ( pointDotNormalHalf >= 0.0 )",
 				"pointSpecularWeight = pow( pointDotNormalHalf, shininess );",
 
-			"pointDiffuse  += mColor * pointDiffuseWeight;",
-			"pointSpecular += mSpecular * pointSpecularWeight;",
+			"pointDiffuse  += mColor * pointDiffuseWeight * pointDistance;",
+			"pointSpecular += mSpecular * pointSpecularWeight * pointDistance;",
 
-			"}",
+		"}",
 
 	"#endif",
 
@@ -455,7 +467,7 @@ THREE.ShaderChunk = {
 	].join("\n"),
 
 	// morphing
-	
+
 	morphtarget_pars_vertex: [
 
 	"#ifdef USE_MORPHTARGETS",
@@ -480,23 +492,23 @@ THREE.ShaderChunk = {
 		"morphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];",
 		"morphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];",
 		"morphed += position;",
-		
+
 		"gl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );",
 
 	"#endif"
 
 	].join("\n"),
-	
+
 	default_vertex : [
-	
+
 	"#ifndef USE_MORPHTARGETS",
 	"#ifndef USE_SKINNING",
-		
+
 		"gl_Position = projectionMatrix * mvPosition;",
 
 	"#endif",
 	"#endif"
-	
+
 	].join("\n")
 
 };
@@ -505,50 +517,51 @@ THREE.UniformsLib = {
 
 	common: {
 
-	"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
-	"opacity" : { type: "f", value: 1.0 },
-	"map"     : { type: "t", value: 0, texture: null },
+		"diffuse" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
+		"opacity" : { type: "f", value: 1.0 },
+		"map" : { type: "t", value: 0, texture: null },
 
-	"lightMap"       : { type: "t", value: 2, texture: null },
+		"lightMap" : { type: "t", value: 2, texture: null },
 
-	"envMap" 		  : { type: "t", value: 1, texture: null },
-	"useRefract"	  : { type: "i", value: 0 },
-	"reflectivity"    : { type: "f", value: 1.0 },
-	"refractionRatio": { type: "f", value: 0.98 },
-	"combine"		  : { type: "i", value: 0 },
+		"envMap" : { type: "t", value: 1, texture: null },
+		"useRefract" : { type: "i", value: 0 },
+		"reflectivity" : { type: "f", value: 1.0 },
+		"refractionRatio" : { type: "f", value: 0.98 },
+		"combine" : { type: "i", value: 0 },
 
-	"fogDensity": { type: "f", value: 0.00025 },
-	"fogNear"	: { type: "f", value: 1 },
-	"fogFar"	: { type: "f", value: 2000 },
-	"fogColor"	: { type: "c", value: new THREE.Color( 0xffffff ) },
-	
-	"morphTargetInfluences" : { type: "f", value: 0 }
+		"fogDensity" : { type: "f", value: 0.00025 },
+		"fogNear" : { type: "f", value: 1 },
+		"fogFar" : { type: "f", value: 2000 },
+		"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) },
+
+		"morphTargetInfluences" : { type: "f", value: 0 }
 
 	},
 
 	lights: {
 
-	"enableLighting" 			: { type: "i", value: 1 },
-	"ambientLightColor" 		: { type: "fv", value: [] },
-	"directionalLightDirection" : { type: "fv", value: [] },
-	"directionalLightColor" 	: { type: "fv", value: [] },
-	"pointLightPosition"		: { type: "fv", value: [] },
-	"pointLightColor"			: { type: "fv", value: [] }
+		"enableLighting" : { type: "i", value: 1 },
+		"ambientLightColor" : { type: "fv", value: [] },
+		"directionalLightDirection" : { type: "fv", value: [] },
+		"directionalLightColor" : { type: "fv", value: [] },
+		"pointLightColor" : { type: "fv", value: [] },
+		"pointLightPosition" : { type: "fv", value: [] },
+		"pointLightDistance" : { type: "fv1", value: [] }
 
 	},
 
 	particle: {
 
-	"psColor"   : { type: "c", value: new THREE.Color( 0xeeeeee ) },
-	"opacity" : { type: "f", value: 1.0 },
-	"size" 	  : { type: "f", value: 1.0 },
-	"scale"   : { type: "f", value: 1.0 },
-	"map"     : { type: "t", value: 0, texture: null },
+		"psColor" : { type: "c", value: new THREE.Color( 0xeeeeee ) },
+		"opacity" : { type: "f", value: 1.0 },
+		"size" : { type: "f", value: 1.0 },
+		"scale" : { type: "f", value: 1.0 },
+		"map" : { type: "t", value: 0, texture: null },
 
-	"fogDensity": { type: "f", value: 0.00025 },
-	"fogNear"	: { type: "f", value: 1 },
-	"fogFar"	: { type: "f", value: 2000 },
-	"fogColor"	: { type: "c", value: new THREE.Color( 0xffffff ) }
+		"fogDensity" : { type: "f", value: 0.00025 },
+		"fogNear" : { type: "f", value: 1 },
+		"fogFar" : { type: "f", value: 2000 },
+		"fogColor" : { type: "c", value: new THREE.Color( 0xffffff ) }
 
 	}
 
@@ -607,46 +620,45 @@ THREE.ShaderLib = {
 
 
 	'shadowPost': {
-		
+
 		vertexShader: [
-		
+
 			"uniform 	mat4 	projectionMatrix;",
 			"attribute 	vec3 	position;",
-	
+
 			"void main(void)",
 			"{",
 				"gl_Position = projectionMatrix * vec4( position, 1.0 );",
 			"}"
 
 		].join( "\n" ),
-		
+
 		fragmentShader: [
-		
+
 			"#ifdef GL_ES",
 				"precision highp float;",
 			"#endif",		
 
 			"uniform 	float 	darkness;",
 
-	
 			"void main( void )",
 			"{",
 				"gl_FragColor = vec4( 0, 0, 0, darkness );",
 			"}"
 
 		].join( "\n" )
-		
+
 	},
 
 
 	'shadowVolumeDynamic': {
-		
+
 		uniforms: { "directionalLightDirection": { type: "fv", value: [] }},
 
 		vertexShader: [
 
 			"uniform 	vec3 	directionalLightDirection;",
-	
+
 			"void main() {",
 
 				"vec4 pos      = objectMatrix * vec4( position, 1.0 );",
@@ -666,7 +678,7 @@ THREE.ShaderLib = {
 			"}"
 
 		].join( "\n" )
-	},		
+	},
 
 
 	'depth': {
@@ -787,7 +799,7 @@ THREE.ShaderLib = {
 				THREE.ShaderChunk[ "skinning_vertex" ],
 				THREE.ShaderChunk[ "morphtarget_vertex" ],
 				THREE.ShaderChunk[ "default_vertex" ],
-				
+
 			"}"
 
 		].join("\n")

+ 2 - 0
utils/build.py

@@ -271,6 +271,7 @@ WEBGL_FILES = [
 'materials/MeshFaceMaterial.js',
 'materials/MeshShaderMaterial.js',
 'materials/ParticleBasicMaterial.js',
+'materials/ShadowVolumeDynamicMaterial.js',
 'materials/Texture.js',
 'materials/RenderTarget.js',
 'materials/Uniforms.js',
@@ -283,6 +284,7 @@ WEBGL_FILES = [
 'objects/Ribbon.js',
 'objects/Sound.js',
 'objects/LOD.js',
+'objects/ShadowVolume.js',
 'scenes/Scene.js',
 'scenes/Fog.js',
 'scenes/FogExp2.js',

+ 97 - 12
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py

@@ -16,32 +16,102 @@
 #
 # ##### END GPL LICENSE BLOCK #####
 
-# To support reload properly, try to access a package var, if it's there, reload everything
+# ################################################################
+# Init
+# ################################################################
+
+# To support reload properly, try to access a package var, 
+# if it's there, reload everything
 
 if "bpy" in locals():
     import imp
     if "export_threejs" in locals():
         imp.reload(export_threejs)
+    if "import_threejs" in locals():
+        imp.reload(import_threejs)
 
 import bpy
 from bpy.props import *
-from io_utils import ExportHelper
+from io_utils import ExportHelper, ImportHelper
+
+
+# ################################################################
+# Custom properties
+# ################################################################
+
+bpy.types.Object.THREE_castsShadow = bpy.props.BoolProperty()
+bpy.types.Object.THREE_meshCollider = bpy.props.BoolProperty()
+
+class OBJECT_PT_hello( bpy.types.Panel ):
+    
+    bl_label = "THREE"
+    bl_space_type = "PROPERTIES"
+    bl_region_type = "WINDOW"
+    bl_context = "object"
+ 
+    def draw(self, context):
+        layout = self.layout
+        obj = context.object
+        
+        row = layout.row()
+        row.label(text="Selected object: " + obj.name )
 
+        row = layout.row()
+        row.prop( obj, "THREE_castsShadow", text="Casts shadow" )
+
+        row = layout.row()
+        row.prop( obj, "THREE_meshCollider", text="Mesh collider" )
+
+        
+# ################################################################
+# Importer
+# ################################################################
+
+class ImportTHREEJS(bpy.types.Operator, ImportHelper):
+    '''Load a Three.js ASCII JSON model'''
+    bl_idname = "import.threejs"
+    bl_label = "Import Three.js"
+
+    filename_ext = ".js"
+    filter_glob = StringProperty(default="*.js", options={'HIDDEN'})
+
+    option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True)
+    recalculate_normals = BoolProperty(name="Recalculate normals", description="Recalculate vertex normals", default=True)
+    
+    def execute(self, context):
+        import io_mesh_threejs.import_threejs
+        return io_mesh_threejs.import_threejs.load(self, context, **self.properties)
+
+
+    def draw(self, context):
+        layout = self.layout
+
+        row = layout.row()
+        row.prop(self.properties, "option_flip_yz")
+
+        row = layout.row()
+        row.prop(self.properties, "recalculate_normals")
+
+
+# ################################################################
+# Exporter
+# ################################################################
 
 class ExportTHREEJS(bpy.types.Operator, ExportHelper):
-    '''Export selected object for Three.js (ASCII JSON format).'''
+    '''Export selected object / scene for Three.js (ASCII JSON format).'''
     bl_idname = "export.threejs"
     bl_label = "Export Three.js"
 
     filename_ext = ".js"
 
-    use_modifiers = BoolProperty(name="Apply Modifiers", description="Apply modifiers to the exported mesh", default=True)
+    option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True)
     use_normals = BoolProperty(name="Normals", description="Export normals", default=True)
     use_colors = BoolProperty(name="Colors", description="Export vertex colors", default=True)
     use_uv_coords = BoolProperty(name="UVs", description="Export texture coordinates", default=True)
+    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=True)
 
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
-    align_model = EnumProperty(name="Align model", description="Align model", items=align_types, default="Center")
+    align_model = EnumProperty(name="Align model", description="Align model", items=align_types, default="None")
 
     @classmethod
     def poll(cls, context):
@@ -61,28 +131,43 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
         layout = self.layout
 
         row = layout.row()
-        row.prop(self.properties, "use_modifiers")
+        row.prop(self.properties, "option_export_scene")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "option_flip_yz")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "align_model")
+        layout.separator()
+
         row = layout.row()
         row.prop(self.properties, "use_normals")
         row = layout.row()
         row.prop(self.properties, "use_colors")
         row = layout.row()
         row.prop(self.properties, "use_uv_coords")
-        row = layout.row()
-        row.prop(self.properties, "align_model")
 
 
-def menu_func(self, context):
+# ################################################################
+# Common
+# ################################################################
+
+def menu_func_export(self, context):
     default_path = bpy.data.filepath.replace(".blend", ".js")
     self.layout.operator(ExportTHREEJS.bl_idname, text="Three.js (.js)").filepath = default_path
 
+def menu_func_import(self, context):
+    self.layout.operator(ImportTHREEJS.bl_idname, text="Three.js (.js)")
 
 def register():
-    bpy.types.INFO_MT_file_export.append(menu_func)
-
+    bpy.types.INFO_MT_file_export.append(menu_func_export)
+    bpy.types.INFO_MT_file_import.append(menu_func_import)
 
 def unregister():
-    bpy.types.INFO_MT_file_export.remove(menu_func)
+    bpy.types.INFO_MT_file_export.remove(menu_func_export)
+    bpy.types.INFO_MT_file_import.remove(menu_func_import)
 
 if __name__ == "__main__":
     register()

+ 723 - 70
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py

@@ -23,9 +23,8 @@
 Blender exporter for Three.js (ASCII JSON format).
 
 TODO
-    - model alignment
+    - export scene
     - copy used images to folder where exported file goes
-    - export all selected meshes
     - binary format
 """
 
@@ -42,14 +41,155 @@ import random
 # Configuration
 # #####################################################
 
-# default colors for debugging (each material gets one distinct color):
+DEFAULTS = {
+"bgcolor" : [0, 0, 0],
+"bgalpha" : 1.0,
+
+"camera"  : 
+    {
+        "name" : "default_camera",
+        "type" : "perspective",
+        "near" : 1,
+        "far"  : 10000,
+        "fov"  : 60,
+        "aspect": 1.333,
+        "position" : [0, 0, 10],
+        "target"   : [0, 0, 0]
+    },
+
+"light" :
+ {
+    "name"       : "default_light",
+    "type"       : "directional",
+    "direction"	 : [0,1,1],
+    "color" 	 : [1,1,1],
+    "intensity"	 : 0.8
+ }
+}
+
+# default colors for debugging (each material gets one distinct color): 
 # white, red, green, blue, yellow, cyan, magenta
 COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
 
 
 # #####################################################
-# Templates
+# Templates - scene
 # #####################################################
+
+TEMPLATE_SCENE_ASCII = """\
+// Converted from: %(fname)s
+//  File generated with Blender 2.56 Exporter
+//  https://github.com/alteredq/three.js/tree/master/utils/exporters/blender/
+
+
+var scene = {
+
+"type" : "scene",
+"urlBaseType" : "relativeToScene",
+
+%(sections)s
+
+"defaults" : 
+{
+    "bgcolor" : %(bgcolor)s,
+    "bgalpha" : %(bgalpha)f,
+    "camera"  : %(defcamera)s
+}
+
+}
+
+postMessage( scene );
+
+"""
+
+TEMPLATE_SECTION = """
+"%s" : 
+{
+%s
+},
+"""
+
+TEMPLATE_OBJECT = """\
+    %(object_id)s : {
+        "geometry"  : %(geometry_id)s,
+        "groups"    : [ %(group_id)s ],
+        "materials" : [ %(material_id)s ],
+        "position"  : %(position)s,
+        "rotation"  : %(rotation)s,
+        "quaternion": %(quaternion)s,
+        "scale"	    : %(scale)s,
+        "visible"       : true,
+        "castsShadow"   : %(castsShadow)s,
+        "meshCollider"  : %(meshCollider)s
+    }"""
+
+TEMPLATE_GEOMETRY = """\
+    %(geometry_id)s : {
+        "type" : "ascii_mesh",
+        "url"  : %(model_file)s
+    }"""
+
+TEMPLATE_TEXTURE = """\
+    %(texture_id)s : {
+        "url": %(texture_file)s
+    }"""
+
+TEMPLATE_MATERIAL_SCENE = """\
+    %(material_id)s : {
+        "type": %(type)s,
+        "parameters": { %(parameters)s } 
+    }"""
+
+TEMPLATE_CAMERA_PERSPECTIVE = """\
+    %(camera_id)s : {
+        "type"  : "perspective",
+        "fov"   : %(fov)f,
+        "aspect": %(aspect)f,
+        "near"  : %(near)f,
+        "far"   : %(far)f,
+        "position": %(position)s,
+        "target"  : %(target)s
+    }"""
+
+TEMPLATE_CAMERA_ORTHO = """\
+    %(camera_id)s: {
+        "type"  : "ortho",
+        "left"  : %(left)f,
+        "right" : %(right)f,
+        "top"   : %(top)f,
+        "bottom": %(bottom)f,
+        "near"  : %(near)f,
+        "far"   : %(far)f,
+        "position": %(position)s,
+        "target"  : %(target)s
+    }"""
+
+TEMPLATE_LIGHT_DIRECTIONAL = """\
+	%(light_id)s: {
+		"type"		 : "directional",
+		"direction"	 : %(direction)s,
+		"color" 	 : %(color)d,
+		"intensity"	 : %(intensity).2f
+	}"""
+
+TEMPLATE_LIGHT_POINT = """\
+	%(light_id)s: {
+		"type"	     : "point",
+		"position"   : %(position)s,
+		"color"      : %(color)d,
+		"intensity"	 : %(intensity).3f
+	}"""
+
+TEMPLATE_VEC4 = '[ %f, %f, %f, %f ]'
+TEMPLATE_VEC3 = '[ %f, %f, %f ]'
+TEMPLATE_VEC2 = '[ %f, %f ]'
+TEMPLATE_STRING = '"%s"'
+TEMPLATE_HEX = "0x%06x"
+
+# #####################################################
+# Templates - model
+# #####################################################
+
 TEMPLATE_FILE_ASCII = """\
 /*
  * File generated with Blender 2.56 Exporter
@@ -66,25 +206,23 @@ TEMPLATE_FILE_ASCII = """\
 
 var model = {
 
-    'version' : 2,
+    "version" : 2,
     
-    'materials': [%(materials)s],
+    "materials": [%(materials)s],
 
-    'vertices': [%(vertices)s],
+    "vertices": [%(vertices)s],
 
-    'morphTargets': [],
+    "morphTargets": [],
 
-    'normals': [%(normals)s],
+    "normals": [%(normals)s],
 
-    'colors': [%(colors)s],
+    "colors": [%(colors)s],
 
-    'uvs': [[%(uvs)s]],
+    "uvs": [[%(uvs)s]],
 
-    'faces': [%(faces)s],
+    "faces": [%(faces)s]
 
-    'end': (new Date).getTime()
-
-}
+};
 
 postMessage( model );
 """
@@ -93,13 +231,18 @@ TEMPLATE_VERTEX = "%f,%f,%f"
 
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
-TEMPLATE_C = "0x%06x"
+#TEMPLATE_C = "0x%06x"
+TEMPLATE_C = "%d"
 
 # #####################################################
 # Utils
 # #####################################################
+
+def veckey3(x,y,z):
+    return round(x, 6), round(y, 6), round(z, 6)
+
 def veckey3d(v):
-    return round(v.x, 6), round(v.y, 6), round(v.z, 6)
+    return veckey3(v.x, v.y, v.z)
 
 def veckey2d(v):
     return round(v[0], 6), round(v[1], 6)
@@ -107,8 +250,13 @@ def veckey2d(v):
 def get_normal_indices(v, normals, mesh):
     n = []
     mv = mesh.vertices
+
     for i in v:
-        n.append( normals[veckey3d(mv[i].normal)] )
+        normal = mv[i].normal        
+        key = veckey3d(normal)
+        
+        n.append( normals[key] )
+
     return n
 
 def get_uv_indices(face_index, uvs, mesh):
@@ -127,9 +275,40 @@ def get_color_indices(face_index, colors, mesh):
         c.append( colors[hexcolor(i)] )
     return c
 
+def rgb2int(rgb):
+    color = (int(rgb[0]*255) << 16) + (int(rgb[1]*255) << 8) + int(rgb[2]*255);
+    return color
+
+# #####################################################
+# Utils - files
+# #####################################################
+
+def write_file(fname, content):
+    out = open(fname, "w")
+    out.write(content)
+    out.close()
+
+def ensure_folder_exist(foldername):
+    """Create folder (with whole path) if it doesn't exist yet."""
+    
+    if not os.access(foldername, os.R_OK|os.W_OK|os.X_OK):
+        os.makedirs(foldername)
+
+def ensure_extension(filepath, extension):
+    if not filepath.lower().endswith(extension):
+        filepath += extension
+    return filepath
+    
+def generate_mesh_filename(meshname, filepath):
+    normpath = os.path.normpath(filepath)
+    path, ext = os.path.splitext(normpath)
+    return "%s.%s%s" % (path, meshname, ext)
+    
+    
 # #####################################################
-# Alignment
+# Utils - alignment
 # #####################################################
+
 def bbox(vertices):
     """Compute bounding box of vertex array.
     """
@@ -206,8 +385,9 @@ def bottom(vertices):
     translate(vertices, [-cx,-cy,-cz])
 
 # #####################################################
-# Elements
+# Elements rendering 
 # #####################################################
+
 def hexcolor(c):
     return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
     
@@ -223,6 +403,10 @@ def generate_vertex_color(c):
 def generate_uv(uv):
     return TEMPLATE_UV % (uv[0], 1.0 - uv[1])
 
+# #####################################################
+# Model exporter - faces
+# #####################################################
+
 def setBit(value, position, on):
     if on:
         mask = 1 << position
@@ -231,7 +415,7 @@ def setBit(value, position, on):
         mask = ~(1 << position)
         return (value & mask)    
     
-def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords):
+def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz):
     isTriangle = ( len(f.vertices) == 3 )
     
     if isTriangle:
@@ -304,8 +488,9 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
 
 
 # #####################################################
-# Normals
+# Model exporter - normals
 # #####################################################
+
 def extract_vertex_normals(mesh, use_normals):
     if not use_normals:
         return {}, 0
@@ -315,7 +500,10 @@ def extract_vertex_normals(mesh, use_normals):
 
     for f in mesh.faces:
         for v in f.vertices:
-            key = veckey3d(mesh.vertices[v].normal)
+            
+            normal = mesh.vertices[v].normal            
+            key = veckey3d(normal)
+                
             if key not in normals:
                 normals[key] = count
                 count += 1
@@ -327,14 +515,15 @@ def generate_normals(normals, use_normals):
         return ""
 
     chunks = []
-    for key, index in sorted(normals.items(), key=operator.itemgetter(1)):
+    for key, index in sorted(normals.items(), key = operator.itemgetter(1)):
         chunks.append(key)
 
     return ",".join(generate_normal(n) for n in chunks)
 
 # #####################################################
-# Vertex colors
+# Model exporter - vertex colors
 # #####################################################
+
 def extract_vertex_colors(mesh, use_colors):
     
     if not use_colors:
@@ -369,8 +558,9 @@ def generate_vertex_colors(colors, use_colors):
     return ",".join(generate_vertex_color(c) for c in chunks)
 
 # #####################################################
-# UVs
+# Model exporter - UVs
 # #####################################################
+
 def extract_uvs(mesh, use_uv_coords):
 
     if not use_uv_coords:
@@ -403,8 +593,9 @@ def generate_uvs(uvs, use_uv_coords):
     return ",".join(generate_uv(n) for n in chunks)
 
 # #####################################################
-# Materials
+# Model exporter - materials
 # #####################################################
+
 def generate_color(i):
     """Generate hex color corresponding to integer.
 
@@ -415,9 +606,11 @@ def generate_color(i):
     """
 
     if i < len(COLORS):
-        return "0x%06x" % COLORS[i]
+        #return "0x%06x" % COLORS[i]
+        return COLORS[i]
     else:
-        return "0x%06x" % int(0xffffff * random.random())
+        #return "0x%06x" % int(0xffffff * random.random())
+        return int(0xffffff * random.random())
 
 def generate_mtl(materials):
     """Generate dummy materials.
@@ -427,10 +620,10 @@ def generate_mtl(materials):
     for m in materials:
         index = materials[m]
         mtl[m] = {
-            'DbgName': m,
-            'DbgIndex': index,
-            'DbgColor': generate_color(index),
-            'vertexColors' : False
+            "DbgName": m,
+            "DbgIndex": index,
+            "DbgColor": generate_color(index),
+            "vertexColors" : False
         }
     return mtl
 
@@ -441,7 +634,7 @@ def value2string(v):
         return str(v).lower()
     return str(v)
 
-def generate_materials(mtl, materials, use_colors):
+def generate_materials(mtl, materials, use_colors, draw_type):
     """Generate JS array of materials objects
     """
 
@@ -458,6 +651,10 @@ def generate_materials(mtl, materials, use_colors):
         mtl[m]['DbgColor'] = generate_color(index)
         mtl[m]['vertexColors'] = use_colors
 
+        if draw_type in [ "BOUNDS", "WIRE" ]:
+            mtl[m]['wireframe'] = True
+            mtl[m]['DbgColor'] = 0xff0000
+            
         mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
         mtl_string = "\t{\n%s\n\t}" % mtl_raw
         mtl_array.append([index, mtl_string])
@@ -505,7 +702,7 @@ def extract_materials(mesh, scene):
 
     return materials
 
-def generate_materials_string(mesh, scene, use_colors):
+def generate_materials_string(mesh, scene, use_colors, draw_type):
 
     random.seed(42) # to get well defined color order for debug materials
 
@@ -522,19 +719,22 @@ def generate_materials_string(mesh, scene, use_colors):
         materials = { 'default':0 }
 
     # default dummy materials
+    
     mtl = generate_mtl(materials)
 
     # extract real materials from the mesh
+    
     mtl.update(extract_materials(mesh, scene))
 
-    return generate_materials(mtl, materials, use_colors)
+    return generate_materials(mtl, materials, use_colors, draw_type)
 
 # #####################################################
-# ASCII exporter
+# ASCII model generator
 # #####################################################
-def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model):
 
-    vertices = mesh.vertices[:]
+def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, draw_type):
+
+    vertices = mesh.vertices[:]    
 
     if align_model == 1:
         center(vertices)
@@ -547,7 +747,7 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     colors, ncolor = extract_vertex_colors(mesh, use_colors)
     uvs, nuv = extract_uvs(mesh, use_uv_coords)
 
-    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors)
+    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
     
     text = TEMPLATE_FILE_ASCII % {
     "nvertex"   : len(mesh.vertices),
@@ -565,46 +765,38 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
 
     "vertices"      : ",".join(generate_vertex(v) for v in vertices),
 
-    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords) for i, f in enumerate(mesh.faces))
+    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz) for i, f in enumerate(mesh.faces))
 
     }
 
     return text
 
+    
 # #####################################################
-# Main
+# Model exporter - export single mesh
 # #####################################################
-def save(operator, context, filepath="", use_modifiers=True, use_normals=True, use_colors=True, use_uv_coords=True, align_model=1):
 
-    def rvec3d(v):
-        return round(v[0], 6), round(v[1], 6), round(v[2], 6)
+def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, flipyz, export_single_model):
+    """Export single mesh"""
 
-    def rvec2d(v):
-        return round(v[0], 6), round(v[1], 6)
 
-    scene = context.scene
-    obj = context.object
+    # collapse modifiers into mesh
+    
+    mesh = obj.create_mesh(scene, True, 'RENDER')        
 
-    if not filepath.lower().endswith('.js'):
-        filepath += '.js'
+    if not mesh:
+        raise Exception("Error, could not get mesh data from object [%s]" % obj.name)
 
-    if not obj:
-        raise Exception("Error, Select 1 active object")
+    # that's what Blender's native export_obj.py does
+    # to flip YZ
 
-    if scene.objects.active:
-        bpy.ops.object.mode_set(mode='OBJECT')
+    X_ROT = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')
 
-    if use_modifiers:
-        mesh = obj.create_mesh(scene, True, 'PREVIEW')
+    if export_single_model:
+        mesh.transform(X_ROT * obj.matrix_world)
     else:
-        mesh = obj.data
+        mesh.transform(X_ROT)
 
-    if not mesh:
-        raise Exception("Error, could not get mesh data from active object")
-
-    # that's what Blender's native export_obj.py does
-    x_rot = mathutils.Matrix.Rotation(-math.pi/2, 4, 'X')
-    mesh.transform(x_rot * obj.matrix_world)
     mesh.calc_normals()
 
     faceUV = (len(mesh.uv_textures) > 0)
@@ -627,14 +819,475 @@ def save(operator, context, filepath="", use_modifiers=True, use_normals=True, u
         if not active_col_layer:
             use_colors = False
 
-    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model)
-    file = open(filepath, 'w')
-    file.write(text)
-    file.close()
+    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, obj.draw_type)    
+    write_file(filepath, text)
+
+    # remove temp mesh
+
+    bpy.data.meshes.remove(mesh)
 
     print("writing", filepath, "done")
+    
+    
+# #####################################################
+# Scene exporter - render elements
+# #####################################################
+
+def generate_vec4(vec):
+    return TEMPLATE_VEC4 % (vec[0], vec[1], vec[2], vec[3])
+
+def generate_vec3(vec):
+    return TEMPLATE_VEC3 % (vec[0], vec[1], vec[2])
+
+def generate_vec2(vec):
+    return TEMPLATE_VEC2 % (vec[0], vec[1])
+
+def generate_hex(number):
+    return TEMPLATE_HEX % number
+    
+def generate_string(s):
+    return TEMPLATE_STRING % s
+    
+def generate_string_list(src_list):
+    return ", ".join(generate_string(item) for item in src_list)
+    
+def generate_section(label, content):
+    return TEMPLATE_SECTION % (label, content)
+    
+def get_mesh_filename(mesh):
+    object_id = mesh["data"]["name"]
+    filename = "%s.js" % sanitize(object_id)
+    return filename
+    
+def generate_material_id_list(materials):
+    chunks = []
+    for material in materials:
+        chunks.append(material.name)
+    
+    return chunks
+    
+def generate_group_id_list(obj):
+    chunks = []
+    
+    for group in bpy.data.groups:
+        if obj.name in group.objects:
+            chunks.append(group.name)
+        
+    return chunks
+    
+def generate_bool_property(property):
+    if property:
+        return "true"
+    return "false"
+    
+# #####################################################
+# Scene exporter - objects
+# #####################################################
+
+def generate_objects(data):
+    chunks = []
+    
+    for obj in data["objects"]:
+        if obj.type == "MESH":
+            object_id = obj.name
+            
+            if len(obj.modifiers) > 0:
+                geo_name = obj.name
+            else:
+                geo_name = obj.data.name
+
+            geometry_id = "geo_%s" % geo_name
+            
+            material_ids = generate_material_id_list(obj.material_slots)
+            group_ids = generate_group_id_list(obj)
+
+            #position = obj.location
+            #rotation = obj.rotation_euler
+            scale = obj.scale
+            quaternion = obj.rotation_quaternion
+            
+            position = [obj.location.x, obj.location.z, -obj.location.y]
+            rotation = [obj.rotation_euler.x, -obj.rotation_euler.y, -obj.rotation_euler.z]
+            #quaternion = obj.rotation_euler.to_quat()
+            scale = [obj.scale.x, obj.scale.z, obj.scale.y]
+            
+            material_string = ""
+            if len(material_ids) > 0:
+                material_string = generate_string_list(material_ids)
+
+            group_string = ""
+            if len(group_ids) > 0:
+                group_string = generate_string_list(group_ids)
+
+            castsShadow = generate_bool_property(obj.THREE_castsShadow)
+            meshCollider = generate_bool_property(obj.THREE_meshCollider)            
+                
+            object_string = TEMPLATE_OBJECT % {
+            "object_id"   : generate_string(object_id),
+            "geometry_id" : generate_string(geometry_id),
+            "group_id"    : group_string,
+            "material_id" : material_string,
+            "position"    : generate_vec3(position),
+            "rotation"    : generate_vec3(rotation),
+            "quaternion"  : generate_vec4(quaternion),
+            "scale"       : generate_vec3(scale),
+            "castsShadow"  : castsShadow,
+            "meshCollider" : meshCollider
+            }
+            chunks.append(object_string)
+        
+    return ",\n\n".join(chunks)
+    
+# #####################################################
+# Scene exporter - geometries
+# #####################################################
+
+def generate_geometries(data):
+    chunks = []
+    
+    geo_set = set()
+    
+    for obj in data["objects"]:
+        if obj.type == "MESH":
+            
+            if len(obj.modifiers) > 0:
+                name = obj.name
+            else:
+                name = obj.data.name
+            
+            if name not in geo_set:
+
+                geometry_id = "geo_%s" % name
+                model_filename = os.path.basename(generate_mesh_filename(name, data["filepath"]))
+                
+                geometry_string = TEMPLATE_GEOMETRY % {
+                "geometry_id" : generate_string(geometry_id),
+                "model_file"  : generate_string(model_filename)
+                }
+                chunks.append(geometry_string)
+                
+                geo_set.add(name)
+        
+    return ",\n\n".join(chunks)
+    
+# #####################################################
+# Scene exporter - textures
+# #####################################################
+
+def generate_textures_scene(data):
+    chunks = []
+    
+    # TODO: extract just textures actually used by some objects in the scene
+    
+    for img in bpy.data.images:
+        
+        texture_id = img.name
+        texture_file = extract_texture_filename(img)
+    
+        texture_string = TEMPLATE_TEXTURE % {
+        "texture_id"   : generate_string(texture_id),
+        "texture_file" : generate_string(texture_file)
+        }
+        chunks.append(texture_string)
+
+    return ",\n\n".join(chunks)
+
+def extract_texture_filename(image):
+    fn = bpy.path.abspath(image.filepath)
+    fn = os.path.normpath(fn)
+    fn_strip = os.path.basename(fn)
+    return fn_strip
+    
+# #####################################################
+# Scene exporter - materials
+# #####################################################
+
+def extract_material_data(m):
+    world = bpy.context.scene.world
+    
+    material = { 'name': m.name }
+    
+    material['colorDiffuse'] = [m.diffuse_intensity * m.diffuse_color[0],
+                                m.diffuse_intensity * m.diffuse_color[1],
+                                m.diffuse_intensity * m.diffuse_color[2]]
+
+    material['colorSpecular'] = [m.specular_intensity * m.specular_color[0],
+                                 m.specular_intensity * m.specular_color[1],
+                                 m.specular_intensity * m.specular_color[2]]
+
+    material['colorAmbient'] = [m.ambient * world.ambient_color[0],
+                                m.ambient * world.ambient_color[1],
+                                m.ambient * world.ambient_color[2]]
+
+    material['transparency'] = m.alpha
 
-    if use_modifiers:
-        bpy.data.meshes.remove(mesh)
+    # not sure about mapping values to Blinn-Phong shader
+    # Blender uses INT from [1,511] with default 0
+    # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness
 
+    material["specularCoef"] = m.specular_hardness
+
+    material['mapDiffuse'] = ""
+    material['mapLight'] = ""
+    material['mapNormal'] = ""    
+        
+    # just take first textures of each, for the moment three.js materials can't handle more
+
+    for i in range(len(m.texture_slots)):
+        ts = m.texture_slots[i]
+        if ts:
+            t = ts.texture
+            if ts.use and t.type == 'IMAGE':
+                name = t.image.name
+
+                if t.use_normal_map:
+                    material['mapNormal'] = name
+                else:
+                    if not material['mapDiffuse']:
+                        material['mapDiffuse'] = name
+                    else:
+                        material['mapLight'] = name
+                
+                if material['mapDiffuse'] and material['mapNormal'] and material['mapLight']:
+                    break
+        
+    if m.specular_intensity > 0.0 and (m.specular_color[0] > 0 or m.specular_color[1] > 0 or m.specular_color[2] > 0):
+        material['shading'] = "Phong"
+    else:
+        material['shading'] = "Lambert"
+        
+    return material
+    
+def generate_material_string(material):
+    type_map = {
+    "Lambert"   : "MeshLambertMaterial",
+    "Phong"     : "MeshPhongMaterial"
+    }
+    
+    material_id = material["name"]
+    shading = material["shading"]
+    material_type = type_map.get(shading, "MeshBasicMaterial")
+
+    #parameters = "color: %s" % generate_hex(rgb2int(material["colorDiffuse"]))
+    parameters = "color: %d" % rgb2int(material["colorDiffuse"])
+    parameters += ", opacity: %.2f" % material["transparency"]
+
+    if shading == "Phong":
+        #parameters += ", ambient: %s" % generate_hex(rgb2int(material["colorAmbient"]))
+        #parameters += ", specular: %s" % generate_hex(rgb2int(material["colorSpecular"]))
+        parameters += ", ambient: %d" % rgb2int(material["colorAmbient"])
+        parameters += ", specular: %d" % rgb2int(material["colorSpecular"])
+        parameters += ", shininess: %.1f" % material["specularCoef"]
+
+    colorMap = material['mapDiffuse']
+    lightMap = material['mapLight']
+    normalMap  = material['mapNormal']
+
+    if colorMap:
+        parameters += ", map: %s" % generate_string(colorMap)
+    if lightMap:
+        parameters += ", lightMap: %s" % generate_string(lightMap)
+    if normalMap:
+        parameters += ", normalMap: %s" % generate_string(normalMap)
+
+    material_string = TEMPLATE_MATERIAL_SCENE % {
+    "material_id" : generate_string(material_id),
+    "type"        : generate_string(material_type),
+    "parameters"  : parameters
+    }
+    
+    return material_string
+    
+def generate_materials_scene(data):
+    chunks = []
+
+    # TODO: extract just materials actually used by some objects in the scene
+    
+    for m in bpy.data.materials:
+        material = extract_material_data(m)
+        material_string = generate_material_string(material)
+        chunks.append(material_string)
+
+    return ",\n\n".join(chunks)
+
+# #####################################################
+# Scene exporter - cameras
+# #####################################################
+
+def generate_cameras(data):
+    cameras = data.get("cameras", [])
+    if not cameras:
+        cameras.append(DEFAULTS["camera"])
+        
+    chunks = []
+    for camera in cameras:
+
+        if camera["type"] == "perspective":
+            camera_string = TEMPLATE_CAMERA_PERSPECTIVE % {
+            "camera_id" : generate_string(camera["name"]),
+            "fov"       : camera["fov"],
+            "aspect"    : camera["aspect"],
+            "near"      : camera["near"],
+            "far"       : camera["far"],
+            "position"  : generate_vec3(camera["position"]),
+            "target"    : generate_vec3(camera["target"])
+            }
+
+        elif camera["type"] == "ortho":
+            camera_string = TEMPLATE_CAMERA_ORTHO % {
+            "camera_id" : generate_string(camera["name"]),
+            "left"      : camera["left"],
+            "right"     : camera["right"],
+            "top"       : camera["top"],
+            "bottom"    : camera["bottom"],
+            "near"      : camera["near"],
+            "far"       : camera["far"],
+            "position"  : generate_vec3(camera["position"]),
+            "target"    : generate_vec3(camera["target"])
+            }
+            
+        chunks.append(camera_string)
+        
+    return ",\n\n".join(chunks)
+
+# #####################################################
+# Scene exporter - lights
+# #####################################################
+
+def generate_lights(data):
+    lights = data.get("lights", [])
+    if not lights:
+        lights.append(DEFAULTS["light"])
+        
+    chunks = []
+    for light in lights:
+
+        if light["type"] == "directional":
+            light_string = TEMPLATE_LIGHT_DIRECTIONAL % {
+            "light_id"      : generate_string(light["name"]),
+            "direction"     : generate_vec3(light["direction"]),
+            #"color"         : generate_hex(rgb2int(light["color"])),
+            "color"         : rgb2int(light["color"]),
+            "intensity"     : light["intensity"]
+            }
+
+        elif light["type"] == "point":
+            light_string = TEMPLATE_LIGHT_POINT % {
+            "light_id"      : generate_string(light["name"]),
+            "position"      : generate_vec3(light["position"]),
+            #"color"         : generate_hex(rgb2int(light["color"])),
+            "color"         : rgb2int(light["color"]),
+            "intensity"     : light["intensity"]
+            }
+            
+        chunks.append(light_string)
+            
+    return ",\n\n".join(chunks)
+
+# #####################################################
+# Scene exporter - generate ASCII scene
+# #####################################################
+
+def generate_ascii_scene(data):
+    objects = generate_objects(data)
+    geometries = generate_geometries(data)
+    textures = generate_textures_scene(data)
+    materials = generate_materials_scene(data)
+    cameras = generate_cameras(data)
+    lights = generate_lights(data)
+    
+    sections = [
+    ["objects",    objects],
+    ["geometries", geometries],
+    ["textures",   textures],
+    ["materials",  materials],
+    ["cameras",    cameras],
+    ["lights",     lights]
+    ]
+    
+    chunks = []
+    for label, content in sections:
+        if content:
+            chunks.append(generate_section(label, content))
+
+    sections_string = "\n".join(chunks)
+    
+    default_camera = "default_camera"
+    
+    parameters = {
+    "fname"     : data["source_file"],
+    "sections"  : sections_string,
+    "bgcolor"   : generate_vec3(DEFAULTS["bgcolor"]),
+    "bgalpha"   : DEFAULTS["bgalpha"],
+    "defcamera" : generate_string(default_camera)
+    }
+
+    text = TEMPLATE_SCENE_ASCII % parameters
+    
+    return text
+    
+def export_scene(scene, filepath, flipyz):
+
+    source_file = os.path.basename(bpy.data.filepath)
+
+    scene_text = ""
+    data = {
+    "scene"       : scene,
+    "objects"     : scene.objects,
+    "source_file" : source_file,
+    "filepath"    : filepath,
+    "flipyz"      : flipyz
+    }
+    scene_text += generate_ascii_scene(data)
+    
+    write_file(filepath, scene_text)
+
+# #####################################################
+# Main
+# #####################################################
+
+def save(operator, context, filepath = "", option_flip_yz = True, use_normals = True, use_colors = True, use_uv_coords = True, align_model = 0, option_export_scene = True):
+
+    filepath = ensure_extension(filepath, '.js')
+
+    scene = context.scene
+
+    if scene.objects.active:
+        bpy.ops.object.mode_set(mode='OBJECT')
+
+    if option_export_scene:
+
+        export_scene(scene, filepath, option_flip_yz)
+
+        geo_set = set()
+        
+        for obj in scene.objects:
+            if obj.type == "MESH":
+                
+                # create extra copy of geometry with applied modifiers
+                # (if they exist)
+                
+                if len(obj.modifiers) > 0:
+                    name = obj.name
+                    
+                # otherwise can share geometry
+
+                else:
+                    name = obj.data.name
+
+                if name not in geo_set:
+                    fname = generate_mesh_filename(name, filepath)
+                    export_mesh(obj, scene, fname, use_normals, use_colors, use_uv_coords, 0, option_flip_yz, False)
+                    
+                    geo_set.add(name)
+
+    else:
+
+        obj = context.object
+        if not obj:
+            raise Exception("Error, Select 1 active object or select 'export scene'")
+
+        export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, option_flip_yz, True)
+
+    
     return {'FINISHED'}

+ 501 - 0
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py

@@ -0,0 +1,501 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# Based on import_obj.py
+# Contributors: alteredq
+
+
+"""
+Blender importer for Three.js (ASCII JSON format).
+
+"""
+
+import os
+import time
+import json
+import bpy
+import mathutils
+from mathutils.geometry import tesselate_polygon
+from io_utils import load_image, unpack_list, unpack_face_list
+
+# #####################################################
+# Generators
+# #####################################################
+
+def create_mesh_object(name, vertices, face_data, flipYZ, recalculate_normals):
+
+    faces   = face_data["faces"]
+    vertexNormals = face_data["vertexNormals"]
+    vertexColors = face_data["vertexColors"]
+    vertexUVs = face_data["vertexUVs"]
+    
+    edges = []
+    
+    # Create a new mesh
+    
+    me = bpy.data.meshes.new(name)
+    me.from_pydata(vertices, edges, faces)
+    
+    # Handle normals
+    
+    if not recalculate_normals:
+        me.update(calc_edges = True)
+    
+    if face_data["hasVertexNormals"]:
+        
+        print("setting vertex normals")
+        
+        for fi in range(len(faces)):
+
+            if vertexNormals[fi]:
+
+                #print("setting face %i with %i vertices" % (fi, len(normals[fi])))
+
+                # if me.update() is called after setting vertex normals
+                # setting face.use_smooth overrides these normals
+                #  - this fixes weird shading artefacts (seems to come from sharing 
+                #    of vertices between faces, didn't find a way how to set vertex normals
+                #    per face use of vertex as opposed to per vertex), 
+                #  - probably this just overrides all custom vertex normals
+                #  - to preserve vertex normals from the original data
+                #    call me.update() before setting them
+                
+                me.faces[fi].use_smooth = True
+                
+                if not recalculate_normals:
+                    for j in range(len(vertexNormals[fi])):
+                        
+                        vertexNormal = vertexNormals[fi][j]
+                    
+                        x = vertexNormal[0]
+                        y = vertexNormal[1]
+                        z = vertexNormal[2]
+                        
+                        if flipYZ:
+                            tmp = y
+                            y = z
+                            z = tmp
+
+                            # flip normals (this make them look consistent with the original before export)
+
+                            x = -x
+                            y = -y
+                            z = -z
+
+                        vi = me.faces[fi].vertices[j]
+                        
+                        me.vertices[vi].normal.x = x
+                        me.vertices[vi].normal.y = y
+                        me.vertices[vi].normal.z = z
+      
+    if recalculate_normals:
+        me.update(calc_edges = True)
+
+    # Handle colors
+    
+    if face_data["hasVertexColors"]:
+
+        print("setting vertex colors")
+
+        me.vertex_colors.new("vertex_color_layer_0")
+        
+        for fi in range(len(faces)):
+
+            if vertexColors[fi]:
+                
+                face_colors = me.vertex_colors[0].data[fi]
+                face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
+                
+                for vi in range(len(vertexColors[fi])):
+                    
+                    r = vertexColors[fi][vi][0]
+                    g = vertexColors[fi][vi][1]
+                    b = vertexColors[fi][vi][2]
+                
+                    face_colors[vi].r = r
+                    face_colors[vi].g = g
+                    face_colors[vi].b = b
+
+
+    # Handle uvs
+    
+    if face_data["hasVertexUVs"]:
+
+        print("setting vertex uvs")
+        
+        for li, layer in enumerate(vertexUVs):
+
+            me.uv_textures.new("uv_layer_%d" % li)
+
+            for fi in range(len(faces)):
+
+                if layer[fi]:
+                    
+                    face_uvs = me.uv_textures[li].data[fi]
+                    face_uvs = face_uvs.uv1, face_uvs.uv2, face_uvs.uv3, face_uvs.uv4
+                    
+                    for vi in range(len(layer[fi])):
+                        
+                        u = layer[fi][vi][0]
+                        v = layer[fi][vi][1]
+                    
+                        face_uvs[vi].x = u
+                        face_uvs[vi].y = 1.0 - v
+
+
+    # Create a new object
+    
+    ob = bpy.data.objects.new(name, me) 
+    ob.data = me                                # link the mesh data to the object
+
+    scene = bpy.context.scene                   # get the current scene
+    scene.objects.link(ob)                      # link the object into the scene
+
+    ob.location = scene.cursor_location         # position object at 3d-cursor
+    
+    
+# #####################################################
+# Faces
+# #####################################################
+
+def extract_faces(data):
+    
+    result = {
+    "faces"         : [],
+    "materials"     : [],
+    "faceUVs"       : [],
+    "vertexUVs"     : [],
+    "faceNormals"   : [],
+    "vertexNormals" : [],
+    "faceColors"    : [],
+    "vertexColors"  : [],
+    
+    "hasVertexNormals"  : False,
+    "hasVertexUVs"      : False,
+    "hasVertexColors"   : False
+    }
+    
+    faces = data.get("faces", [])
+    normals = data.get("normals", [])
+    colors = data.get("colors", [])
+
+    offset = 0
+    zLength = len(faces)
+
+    # disregard empty arrays
+
+    nUvLayers = 0
+
+    for layer in data["uvs"]:
+
+        if len(layer) > 0:
+            nUvLayers += 1
+            result["faceUVs"].append([])
+            result["vertexUVs"].append([])
+
+
+    while ( offset < zLength ):
+
+        type = faces[ offset ]
+        offset += 1
+
+        isQuad          	= isBitSet( type, 0 )
+        hasMaterial         = isBitSet( type, 1 )
+        hasFaceUv           = isBitSet( type, 2 )
+        hasFaceVertexUv     = isBitSet( type, 3 )
+        hasFaceNormal       = isBitSet( type, 4 )
+        hasFaceVertexNormal = isBitSet( type, 5 )
+        hasFaceColor	    = isBitSet( type, 6 )
+        hasFaceVertexColor  = isBitSet( type, 7 )
+
+        #print("type", type, "bits", isQuad, hasMaterial, hasFaceUv, hasFaceVertexUv, hasFaceNormal, hasFaceVertexNormal, hasFaceColor, hasFaceVertexColor)
+
+        result["hasVertexUVs"] = result["hasVertexUVs"] or hasFaceVertexUv
+        result["hasVertexNormals"] = result["hasVertexNormals"] or hasFaceVertexNormal
+        result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor
+        
+        # vertices
+        
+        if isQuad:
+
+            a = faces[ offset ]
+            offset += 1
+            
+            b = faces[ offset ]
+            offset += 1
+            
+            c = faces[ offset ]
+            offset += 1
+            
+            d = faces[ offset ]
+            offset += 1
+            
+            face = [a, b, c, d]
+
+            nVertices = 4
+
+        else:
+
+            a = faces[ offset ]
+            offset += 1
+            
+            b = faces[ offset ]
+            offset += 1
+            
+            c = faces[ offset ]
+            offset += 1
+
+            face = [a, b, c]
+            
+            nVertices = 3
+
+        result["faces"].append(face)
+
+        # material
+        
+        if hasMaterial:
+
+            materialIndex = faces[ offset ]
+            offset += 1
+        
+        else:
+
+            materialIndex = -1
+
+        result["materials"].append(materialIndex)
+
+        # uvs
+
+        for i in range(nUvLayers):
+
+            faceUv = None
+            
+            if hasFaceUv:
+                
+                uvLayer = data["uvs"][ i ]
+
+                uvIndex = faces[ offset ]
+                offset += 1
+
+                u = uvLayer[ uvIndex * 2 ]
+                v = uvLayer[ uvIndex * 2 + 1 ]
+
+                faceUv = [u, v]
+                
+            result["faceUVs"][i].append(faceUv)
+
+
+            if hasFaceVertexUv:
+
+                uvLayer = data["uvs"][ i ]
+
+                vertexUvs = []
+
+                for j in range(nVertices):
+
+                    uvIndex = faces[ offset ]
+                    offset += 1
+
+                    u = uvLayer[ uvIndex * 2 ]
+                    v = uvLayer[ uvIndex * 2 + 1 ]
+
+                    vertexUvs.append([u, v])
+
+            result["vertexUVs"][i].append(vertexUvs)
+
+
+        if hasFaceNormal:
+
+            normalIndex = faces[ offset ] * 3
+            offset += 1
+
+            x = normals[ normalIndex ]
+            y = normals[ normalIndex + 1 ]
+            z = normals[ normalIndex + 2 ]
+
+            faceNormal = [x, y, z]
+            
+        else:
+
+            faceNormal = None
+        
+        result["faceNormals"].append(faceNormal)
+
+
+        if hasFaceVertexNormal:
+
+            vertexNormals = []
+            
+            for j in range(nVertices):
+
+                normalIndex = faces[ offset ] * 3
+                offset += 1
+
+                x = normals[ normalIndex ]
+                y = normals[ normalIndex + 1 ]
+                z = normals[ normalIndex + 2 ]
+                
+                vertexNormals.append( [x, y, z] )
+
+
+        else:
+
+            vertexNormals = None
+        
+        result["vertexNormals"].append(vertexNormals)
+
+
+        if hasFaceColor:
+
+            colorIndex = faces[ offset ]
+            offset += 1
+            
+            faceColor = hexToTuple( colors[ colorIndex ] )
+
+        else:
+            
+            faceColor = None
+
+        result["faceColors"].append(faceColor)
+
+
+        if hasFaceVertexColor:
+
+            vertexColors = []
+
+            for j in range(nVertices):
+
+                colorIndex = faces[ offset ]
+                offset += 1
+
+                color = hexToTuple( colors[ colorIndex ] )
+                vertexColors.append( color )
+
+        else:
+            
+            vertexColors = None
+            
+        result["vertexColors"].append(vertexColors)
+
+
+    return result
+    
+# #####################################################
+# Utils
+# #####################################################
+
+def hexToTuple( hexColor ):
+    r = (( hexColor >> 16 ) & 0xff) / 255.0
+    g = (( hexColor >> 8 ) & 0xff) / 255.0
+    b = ( hexColor & 0xff) / 255.0
+    return (r, g, b)
+    
+def isBitSet(value, position):
+    return value & ( 1 << position )
+    
+def splitArray(data, chunkSize):
+    result = []
+    chunk = []
+    for i in range(len(data)):
+        if i > 0 and i % chunkSize == 0:
+            result.append(chunk)
+            chunk = []
+        chunk.append(data[i])
+    result.append(chunk)
+    return result
+
+
+def extract_json_string(text):
+    marker_begin = "var model ="
+    marker_end = "postMessage"
+    
+    start = text.find(marker_begin) + len(marker_begin)
+    end = text.find(marker_end)
+    end = text.rfind("}", start, end)
+    return text[start:end+1].strip()
+
+def get_name(filepath):
+    return os.path.splitext(os.path.basename(filepath))[0]
+    
+# #####################################################
+# Parser
+# #####################################################
+
+def load(operator, context, filepath, option_flip_yz = True, recalculate_normals = True):
+    
+    print('\nimporting %r' % filepath)
+
+    time_main = time.time()
+
+    print("\tparsing JSON file...")
+    
+    time_sub = time.time()
+
+    file = open(filepath, 'rU')
+    rawcontent = file.read()
+    file.close()
+
+    json_string = extract_json_string(rawcontent)
+    data = json.loads( json_string )
+    
+    time_new = time.time()
+
+    print('parsing %.4f sec' % (time_new - time_sub))
+    
+    time_sub = time_new
+
+    # flip YZ
+    
+    vertices = splitArray(data["vertices"], 3)
+    
+    if option_flip_yz:
+        vertices[:] = [(v[0], v[2], v[1]) for v in vertices]        
+
+    # extract faces
+    
+    face_data = extract_faces(data)
+    
+    # deselect all
+
+    bpy.ops.object.select_all(action='DESELECT')
+
+    nfaces = len(face_data["faces"])
+    nvertices = len(vertices)
+    nnormals = len(data.get("normals", [])) / 3
+    ncolors = len(data.get("colors", [])) / 3
+    nuvs = len(data.get("uvs", [])) / 2
+    nmaterials = len(data.get("materials", []))
+    
+    print('\tbuilding geometry...\n\tfaces:%i, vertices:%i, vertex normals: %i, vertex uvs: %i, vertex colors: %i, materials: %i ...' % ( 
+        nfaces, nvertices, nnormals, nuvs, ncolors, nmaterials ))
+
+    # Create new obj
+    
+    create_mesh_object(get_name(filepath), vertices, face_data, option_flip_yz, recalculate_normals)
+
+    scene = bpy.context.scene 
+    scene.update()
+
+    time_new = time.time()
+
+    print('finished importing: %r in %.4f sec.' % (filepath, (time_new - time_main)))
+    return {'FINISHED'}
+
+
+if __name__ == "__main__":
+    register()

+ 16 - 18
utils/exporters/convert_obj_three.py

@@ -158,24 +158,22 @@ TEMPLATE_FILE_ASCII = u"""\
 
 var model = {
 
-    'version' : 2,
+    "version" : 2,
     
-    'materials': [%(materials)s],
+    "materials": [%(materials)s],
 
-    'vertices': [%(vertices)s],
+    "vertices": [%(vertices)s],
 
-    'morphTargets': [%(morphTargets)s],
+    "morphTargets": [%(morphTargets)s],
 
-    'normals': [%(normals)s],
+    "normals": [%(normals)s],
 
-    'uvs': [[%(uvs)s]],
+    "uvs": [[%(uvs)s]],
 
-    'faces': [%(faces)s],
+    "faces": [%(faces)s]
 
-    'end': (new Date).getTime()
-    
 };
-    
+
 postMessage( model );
 """
 
@@ -191,14 +189,12 @@ TEMPLATE_FILE_BIN = u"""\
 
 var model = {
 
-    'version' : 1,
+    "version" : 1,
 
-    'materials': [%(materials)s],
+    "materials": [%(materials)s],
 
-    'buffers': '%(buffers)s',
+    "buffers": "%(buffers)s"
 
-    'end': (new Date).getTime()
-    
 };
     
 postMessage( model );
@@ -209,7 +205,7 @@ TEMPLATE_VERTEX = "%f,%f,%f"
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
 
-TEMPLATE_MORPH = "\t{ 'name': '%s', 'vertices': [%s] }"
+TEMPLATE_MORPH = '\t{ "name": "%s", "vertices": [%s] }'
 
 # #####################################################
 # Utils
@@ -670,9 +666,11 @@ def generate_color(i):
     """
     
     if i < len(COLORS):
-        return "0x%06x" % COLORS[i]
+        #return "0x%06x" % COLORS[i]
+        return COLORS[i]
     else:
-        return "0x%06x" % int(0xffffff * random.random())
+        #return "0x%06x" % int(0xffffff * random.random())
+        return int(0xffffff * random.random())
         
 def value2string(v):
     if type(v)==str and v[0:2] != "0x":

+ 23 - 19
utils/exporters/max/ThreeJSExporter.ms

@@ -40,7 +40,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	-- User interface
 
 
-	group "ThreeJSExporter  v0.5"
+	group "ThreeJSExporter  v0.6"
 	(
 
 		label msg "Exports selected meshes in Three.js ascii JSON format" align:#left
@@ -73,7 +73,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function DumpVertices src = 
 	(
 
-		Format "'vertices': [" to:ostream
+		Format "\"vertices\": [" to:ostream
 
 		num = src.count
 
@@ -121,7 +121,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function DumpColors src useColors = 
 	(
 
-		Format "'colors': [" to:ostream
+		Format "\"colors\": [" to:ostream
 
 		num = src.count
 
@@ -139,9 +139,11 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				
 				hexNum = ( bit.shift r 16 ) + ( bit.shift g 8 ) + b
 				
-				hexColor = formattedPrint hexNum format:"#x"
-				
-				Format "%" hexColor to:ostream
+				-- hexColor = formattedPrint hexNum format:"#x"
+				-- Format "%" hexColor to:ostream
+
+				decColor = formattedPrint hexNum format:"#d"
+				Format "%" decColor to:ostream
 				
 				if i < num then Format "," to:ostream
 
@@ -159,7 +161,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function DumpNormals src = 
 	(
 
-		Format "'normals': [" to:ostream
+		Format "\"normals\": [" to:ostream
 
 		num = src.count
 
@@ -209,7 +211,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function DumpUvs src = 
 	(
 
-		Format "'uvs': [[" to:ostream
+		Format "\"uvs\": [[" to:ostream
 
 		num = src.count
 
@@ -250,7 +252,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function DumpFaces src useColors = 
 	(
 
-		Format "'faces': [" to:ostream
+		Format "\"faces\": [" to:ostream
 		
 		num = src.count
 
@@ -422,7 +424,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		fg = formattedPrint g format:".4f"
 		fb = formattedPrint b format:".4f"
 
-		Format "'%'  : [%, %, %],\n" label fr fg fb to:ostream
+		Format "\"%\"  : [%, %, %],\n" label fr fg fb to:ostream
 
 	)	
 
@@ -440,7 +442,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			(
 
 				fname = filenameFromPath bm.filename
-				Format "'%'    : '%',\n" label fname to:ostream
+				Format "\"%\"    : \"%\",\n" label fname to:ostream
 
 			)
 
@@ -454,7 +456,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 	function ExportMaterials zmaterials zcolors = 
 	(
 
-		Format "'materials': [\n" to:ostream
+		Format "\"materials\": [\n" to:ostream
 
 		totalMaterials = zmaterials.count
 
@@ -466,14 +468,14 @@ rollout ThreeJSExporter "ThreeJSExporter"
 
 			-- debug
 
-			Format "'DbgIndex' : %,\n" (i-1) to:ostream
+			Format "\"DbgIndex\" : %,\n" (i-1) to:ostream
 
 			if classof mat != BooleanClass then
 			(
 
 				useVertexColors = zcolors[i]
 				
-				Format "'DbgName'  : '%',\n" mat.name to:ostream
+				Format "\"DbgName\"  : \"%\",\n" mat.name to:ostream
 				
 				-- colors
 
@@ -484,8 +486,8 @@ rollout ThreeJSExporter "ThreeJSExporter"
 				t = mat.opacity / 100
 				s = mat.glossiness
 				
-				Format "'transparency'  : %,\n" t to:ostream
-				Format "'specularCoef'  : %,\n" s to:ostream
+				Format "\"transparency\"  : %,\n" t to:ostream
+				Format "\"specularCoef\"  : %,\n" s to:ostream
 
 				-- maps
 
@@ -499,13 +501,15 @@ rollout ThreeJSExporter "ThreeJSExporter"
 			else 
 			(
 				
-				Format "'DbgName'  : '%',\n" "dummy" to:ostream
+				useVertexColors = false
+				
+				Format "\"DbgName\"  : \"%\",\n" "dummy" to:ostream
 				
 				DumpColor red "colorDiffuse"
 				
 			)
 				
-			Format "'vertexColors' : %\n" useVertexColors to:ostream
+			Format "\"vertexColors\" : %\n" useVertexColors to:ostream
 			Format "}" to:ostream
 
 			if ( i < totalMaterials ) then Format "," to:ostream
@@ -1001,7 +1005,7 @@ rollout ThreeJSExporter "ThreeJSExporter"
 		-- Dump model
 
 		Format "\n\nvar model = {\n\n" to:ostream
-		Format "'version' :2,\n\n" to:ostream
+		Format "\"version\" :2,\n\n" to:ostream
 
 		-- Dump all materials in the scene
 

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