From 348bb3be59f95de37b3ad2bfd3f6dc3381d081e8 Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sun, 20 Mar 2011 21:48:50 +0000 Subject: [PATCH] Merging with alteredq's branch. --- build/Three.js | 527 ++++++++++++------------ examples/obj/female02/Female02_bin.js | 4 +- examples/obj/female02/Female02_slim.js | 4 +- examples/obj/lucy/Lucy100k_bin.js | 4 +- examples/obj/lucy/Lucy100k_slim.js | 4 +- examples/obj/male02/Male02_bin.js | 4 +- examples/obj/male02/Male02_slim.js | 4 +- examples/obj/ninja/NinjaLo_bin.js | 4 +- examples/obj/torus/Torus_bin.js | 4 +- examples/obj/torus/Torus_slim.js | 4 +- examples/obj/walt/WaltHead_bin.js | 4 +- examples/obj/walt/WaltHead_slim.js | 4 +- examples/webgl_geometry_large_mesh.html | 109 ++++- examples/webgl_objconvert_test.html | 91 +++- src/core/Face3.js | 2 +- src/core/Face4.js | 2 +- src/extras/geometries/Sphere.js | 2 +- src/extras/io/BinaryLoader.js | 3 +- src/extras/io/JSONLoader.js | 12 +- src/extras/io/Loader.js | 16 +- src/renderers/WebGLRenderer.js | 25 +- utils/build.py | 1 + utils/exporters/convert_obj_three.py | 8 +- 23 files changed, 531 insertions(+), 311 deletions(-) diff --git a/build/Three.js b/build/Three.js index 9c0552d1..b6a7909c 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,6 +1,6 @@ // Three.js r36 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; -THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,f,g,h,m,j;if(b==0)d=f=g=0;else{h=Math.floor(a*6);m=a*6-h;a=b*(1-c);j=b*(1-c*m);c=b*(1-c*(1-m));switch(h){case 1:d=j;f=b;g=a;break;case 2:d=a;f=b;g=c;break;case 3:d=a;f=j;g=b;break;case 4:d=c;f=a;g=b;break;case 5:d=b;f=a;g=j;break;case 6:case 0:d=b;f=c;g=a}}this.r=d;this.g=f;this.b=g;if(this.autoUpdate){this.updateHex(); +THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=k;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex(); this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}}; THREE.Vector2=function(a,c){this.set(a||0,c||0)}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.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,c,b,d){this.set(a||0,c||0,b||0,d||1)}; THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.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,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.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,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,f=[];a=0;for(c=d.length;a0&&E>0&&R+E<1}var b,d,f,g,h,m,j,n,p,v, -u,o=a.geometry,x=o.vertices,B=[];b=0;for(d=o.faces.length;bj?d:j;f=f>n?f:n}a()}; -this.add3Points=function(j,n,p,v,u,o){if(m){m=!1;c=jp?j>u?j:u:p>u?p:u;f=n>v?n>o?n:o:v>o?v:o}else{c=jp?j>u?j>d?j:d:u>d?u:d:p>u?p>d?p:d:u>d?u:d;f=n>v?n>o?n>f?n:f:o>f?o:f:v>o?v>f?v:f:o>f?o:f}a()};this.addRectangle=function(j){if(m){m=!1;c=j.getLeft();b=j.getTop();d=j.getRight();f=j.getBottom()}else{c=cj.getRight()? -d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){c-=j;b-=j;d+=j;f+=j;a()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();b=b>j.getTop()?b:j.getTop();d=d=0&&Math.min(f,j.getBottom())-Math.max(b,j.getTop())>=0};this.empty=function(){m=!0;f=d=b=c=0;a()};this.isEmpty=function(){return m}}; +THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a0&&K>0&&R+K<1}var b,d,e,g,h,j,k,n,w,y, +x,t=a.geometry,A=t.vertices,G=[];b=0;for(d=t.faces.length;bk?d:k;e=e>n?e:n}a()}; +this.add3Points=function(k,n,w,y,x,t){if(j){j=!1;c=kw?k>x?k:x:w>x?w:x;e=n>y?n>t?n:t:y>t?y:t}else{c=kw?k>x?k>d?k:d:x>d?x:d:w>x?w>d?w:d:x>d?x:d;e=n>y?n>t?n>e?n:e:t>e?t:e:y>t?y>e?y:e:t>e?t:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? +d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,b,d,f,g,h,m,j,n,p,v,u,o,x,B){this.set(a||1,c||0,b||0,d||0,f||0,g||1,h||0,m||0,j||0,n||0,p||1,v||0,u||0,o||0,x||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,c,b,d,f,g,h,m,j,n,p,v,u,o,x,B){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=m;this.n31=j;this.n32=n;this.n33=p;this.n34=v;this.n41=u;this.n42=o;this.n43=x;this.n44=B;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,c,b){var d=THREE.Matrix4.__v1, -f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,f=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*f;a.y=(this.n21*c+this.n22*b+this.n23* -d+this.n24)*f;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,f=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*f;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*f;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*f;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize(); -return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,m=a.n22,j=a.n23,n=a.n24,p=a.n31,v=a.n32,u=a.n33,o=a.n34,x=a.n41,B=a.n42,E=a.n43,w=a.n44,M=c.n11,J=c.n12,N=c.n13,R=c.n14,da=c.n21,O=c.n22, -e=c.n23,Y=c.n24,V=c.n31,ma=c.n32,ka=c.n33,K=c.n34;this.n11=b*M+d*da+f*V;this.n12=b*J+d*O+f*ma;this.n13=b*N+d*e+f*ka;this.n14=b*R+d*Y+f*K+g;this.n21=h*M+m*da+j*V;this.n22=h*J+m*O+j*ma;this.n23=h*N+m*e+j*ka;this.n24=h*R+m*Y+j*K+n;this.n31=p*M+v*da+u*V;this.n32=p*J+v*O+u*ma;this.n33=p*N+v*e+u*ka;this.n34=p*R+v*Y+u*K+o;this.n41=x*M+B*da+E*V;this.n42=x*J+B*O+E*ma;this.n43=x*N+B*e+E*ka;this.n44=x*R+B*Y+E*K+w;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]= -this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return 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,c=this.n12,b=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,m=this.n24,j=this.n31,n=this.n32,p=this.n33,v=this.n34,u=this.n41,o=this.n42,x=this.n43,B=this.n44;return d*h*n*u-b*m*n*u-d*g*p*u+c*m*p*u+b*g*v*u-c*h*v*u-d*h*j*o+b*m*j*o+d*f*p*o-a*m*p*o-b*f*v*o+a*h*v*o+d*g*j*x-c*m*j*x-d*f*n*x+a*m*n*x+c*f*v*x-a*g*v*x-b*g*j*B+c*h*j*B+b*f*n*B-a*h*n*B-c*f*p*B+a*g*p*B},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,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this}, -setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),f=1-b,g=a.x,h=a.y,m= -a.z,j=f*g,n=f*h;this.set(j*g+b,j*h-d*m,j*m+d*h,0,j*h+d*m,n*h+b,n*m-d*g,0,j*m-d*h,n*m+d*g,f*m*m+b,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 c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var f=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,m=c*b;this.n11=f*g;this.n12=-f*d;this.n13=b;this.n21=m*g+a*d;this.n22=-m*d+a*g;this.n23=-c*f;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*f;return this}, -setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,f=a.w,g=c+c,h=b+b,m=d+d;a=c*g;var j=c*h;c*=m;var n=b*h;b*=m;d*=m;g*=f;h*=f;f*=m;this.n11=1-(n+d);this.n12=j-f;this.n13=c+h;this.n21=j+f;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14= -a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,f=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}}; -THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,m=a.n22,j=a.n23,n=a.n24,p=a.n31,v=a.n32,u=a.n33,o=a.n34,x=a.n41,B=a.n42,E=a.n43,w=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=j*o*B-n*u*B+n*v*E-m*o*E-j*v*w+m*u*w;c.n12=g*u*B-f*o*B-g*v*E+d*o*E+f*v*w-d*u*w;c.n13=f*n*B-g*j*B+g*m*E-d*n*E-f*m*w+d*j*w;c.n14=g*j*v-f*n*v-g*m*u+d*n*u+f*m*o-d*j*o;c.n21=n*u*x-j*o*x-n*p*E+h*o*E+j*p*w-h*u*w;c.n22=f*o*x-g*u*x+g*p*E-b*o*E-f*p*w+b*u*w;c.n23=g*j*x-f*n*x-g*h*E+b*n*E+f*h*w-b*j*w; -c.n24=f*n*p-g*j*p+g*h*u-b*n*u-f*h*o+b*j*o;c.n31=m*o*x-n*v*x+n*p*B-h*o*B-m*p*w+h*v*w;c.n32=g*v*x-d*o*x-g*p*B+b*o*B+d*p*w-b*v*w;c.n33=f*n*x-g*m*x+g*h*B-b*n*B-d*h*w+b*m*w;c.n34=g*m*p-d*n*p-g*h*v+b*n*v+d*h*o-b*m*o;c.n41=j*v*x-m*u*x-j*p*B+h*u*B+m*p*E-h*v*E;c.n42=d*u*x-f*v*x+f*p*B-b*u*B-d*p*E+b*v*E;c.n43=f*m*x-d*j*x-f*h*B+b*j*B+d*h*E-b*m*E;c.n44=d*j*p-f*m*p+f*h*v-b*j*v-d*h*u+b*m*u;c.multiplyScalar(1/a.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,m=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,v=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*f;b[2]=a*g;b[3]=a*h;b[4]=a*m;b[5]=a*j;b[6]=a*n;b[7]=a*p;b[8]=a*v;return c}; -THREE.Matrix4.makeFrustum=function(a,c,b,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*f/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var f;a=b*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,b,d)}; -THREE.Matrix4.makeOrtho=function(a,c,b,d,f,g){var h,m,j,n;h=new THREE.Matrix4;m=c-a;j=b-d;n=g-f;h.n11=2/m;h.n12=0;h.n13=0;h.n14=-((c+a)/m);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((b+d)/j);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+f)/n);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,n,w,y,x,t,A,G){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,n||0,w||1,y||0,x||0,t||0,A||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,n,w,y,x,t,A,G){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=n;this.n33=w;this.n34=y;this.n41=x;this.n42=t;this.n43=A;this.n44=G;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,c,b){var d=THREE.Matrix4.__v1, +e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,c).normalize();if(g.length()===0)g.z=1;d.cross(b,g).normalize();if(d.length()===0){g.x+=1.0E-4;d.cross(b,g).normalize()}e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23* +d+this.n24)*e;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize(); +return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,w=a.n31,y=a.n32,x=a.n33,t=a.n34,A=a.n41,G=a.n42,K=a.n43,F=a.n44,J=c.n11,z=c.n12,H=c.n13,R=c.n14,$=c.n21,W=c.n22, +f=c.n23,ga=c.n24,S=c.n31,Z=c.n32,ma=c.n33,N=c.n34;this.n11=b*J+d*$+e*S;this.n12=b*z+d*W+e*Z;this.n13=b*H+d*f+e*ma;this.n14=b*R+d*ga+e*N+g;this.n21=h*J+j*$+k*S;this.n22=h*z+j*W+k*Z;this.n23=h*H+j*f+k*ma;this.n24=h*R+j*ga+k*N+n;this.n31=w*J+y*$+x*S;this.n32=w*z+y*W+x*Z;this.n33=w*H+y*f+x*ma;this.n34=w*R+y*ga+x*N+t;this.n41=A*J+G*$+K*S;this.n42=A*z+G*W+K*Z;this.n43=A*H+G*f+K*ma;this.n44=A*R+G*ga+K*N+F;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31; +b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return 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,c=this.n12,b=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,n=this.n32,w=this.n33,y=this.n34,x=this.n41,t=this.n42,A=this.n43,G=this.n44;return d*h*n*x-b*j*n*x-d*g*w*x+c*j*w*x+b*g*y*x-c*h*y*x-d*h*k*t+b*j*k*t+d*e*w*t-a*j*w*t-b*e*y*t+a*h*y*t+d*g*k*A-c*j*k*A-d*e*n*A+a*j*n*A+c*e*y*A-a*g*y*A-b*g*k*G+c*h*k*G+b*e*n*G-a*h*n*G-c*e*w*G+a*g*w*G},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,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a, +c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,j=a.z,k=e*g,n=e*h;this.set(k* +g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,n*h+b,n*j-d*g,0,k*j-d*h,n*j+d*g,e*j*j+b,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 c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e;return this},setRotationFromQuaternion:function(a){var c= +a.x,b=a.y,d=a.z,e=a.w,g=c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var n=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(n+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+n);return this},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34= +a.n34},extractRotation:function(a,c){var b=1/c.x,d=1/c.y,e=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; +THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,n=a.n24,w=a.n31,y=a.n32,x=a.n33,t=a.n34,A=a.n41,G=a.n42,K=a.n43,F=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*t*G-n*x*G+n*y*K-j*t*K-k*y*F+j*x*F;c.n12=g*x*G-e*t*G-g*y*K+d*t*K+e*y*F-d*x*F;c.n13=e*n*G-g*k*G+g*j*K-d*n*K-e*j*F+d*k*F;c.n14=g*k*y-e*n*y-g*j*x+d*n*x+e*j*t-d*k*t;c.n21=n*x*A-k*t*A-n*w*K+h*t*K+k*w*F-h*x*F;c.n22=e*t*A-g*x*A+g*w*K-b*t*K-e*w*F+b*x*F;c.n23=g*k*A-e*n*A-g*h*K+b*n*K+e*h*F-b*k*F; +c.n24=e*n*w-g*k*w+g*h*x-b*n*x-e*h*t+b*k*t;c.n31=j*t*A-n*y*A+n*w*G-h*t*G-j*w*F+h*y*F;c.n32=g*y*A-d*t*A-g*w*G+b*t*G+d*w*F-b*y*F;c.n33=e*n*A-g*j*A+g*h*G-b*n*G-d*h*F+b*j*F;c.n34=g*j*w-d*n*w-g*h*y+b*n*y+d*h*t-b*j*t;c.n41=k*y*A-j*x*A-k*w*G+h*x*G+j*w*K-h*y*K;c.n42=d*x*A-e*y*A+e*w*G-b*x*G-d*w*K+b*y*K;c.n43=e*j*A-d*k*A-e*h*G+b*k*G+d*h*K-b*j*K;c.n44=d*k*w-e*j*w+e*h*y-b*k*y-d*h*x+b*j*x;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,w=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*n;b[7]=a*w;b[8]=a*y;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)}; +THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,n;h=new THREE.Matrix4;j=c-a;k=b-d;n=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/n;h.n34=-((g+e)/n);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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,c){this.matrix.rotateAxis(c);this.position.addSelf(c.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 c=this;c instanceof THREE.Scene===!1&&c!==undefined;)c=c.parent;c!==undefined&&c.addChildRecurse(a)}},removeChild:function(a){var c=this.children.indexOf(a);if(c!==-1){a.parent=undefined;this.children.splice(c,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,c,b){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||c){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;c=!0}a=0;for(var d=this.children.length;a=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*f+c.w*d;b.x=a.x*f+c.x*d;b.y=a.y*f+c.y*d;b.z=a.z*f+c.z*d;return b}; -THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; -THREE.Face3=function(a,c,b,d,f,g){this.a=a;this.b=c;this.c=b;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.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; -THREE.Face4=function(a,c,b,d,f,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;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.Quaternion.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},setFromEuler:function(a){var c=0.5*Math.PI/360,b=a.x*c,d=a.y*c,e=a.z*c;a=Math.cos(d);d=Math.sin(d);c=Math.cos(-e);e=Math.sin(-e);var g=Math.cos(b);b=Math.sin(b);var h=a*c,j=d*e;this.w=h*g-j*b;this.x=h*b+j*g;this.y=d*c*g+a*e*b;this.z=a*e*g-d*c*b;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 c=this.x,b=this.y,d=this.z,e=this.w,g=a.x,h=a.y,j=a.z;a=a.w;this.x=c*a+e*g+b*j-d*h;this.y=b*a+e*h+d*g-c*j;this.z=d*a+e*j+c*h-b*g;this.w=e*a-c*g-b*h-d*j;return this}, +multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,e=a.z,g=this.x,h=this.y,j=this.z,k=this.w,n=k*b+h*e-j*d,w=k*d+j*b-g*e,y=k*e+g*d-h*b;b=-g*b-h*d-j*e;c.x=n*k+b*-g+w*-j-y*-h;c.y=w*k+b*-h+y*-g-n*-j;c.z=y*k+b*-j+n*-h-w*-g;return c}}; +THREE.Quaternion.slerp=function(a,c,b,d){var e=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;if(Math.abs(e)>=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.0010){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Face3=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(a,c,b,d,e,g,h){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.set(a||0,c||0)}; +THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;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,c,b;a=0;for(c=this.faces.length;a0){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 c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;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,c=0,b=this.vertices.length;cthis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];p=this.points[b[1]]; -v=this.points[b[2]];u=this.points[b[3]];m=h*h;j=h*m;d.x=c(n.x,p.x,v.x,u.x,h,m,j);d.y=c(n.y,p.y,v.y,u.y,h,m,j);d.z=c(n.z,p.z,v.z,u.z,h,m,j);return d};this.getControlPointsArray=function(){var o,x,B=this.points.length,E=[];for(o=0;o0){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 c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]= +a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;cthis.points.length-2?g:g+1;b[3]=g>this.points.length-3?g:g+2;n=this.points[b[0]];w=this.points[b[1]]; +y=this.points[b[2]];x=this.points[b[3]];j=h*h;k=h*j;d.x=c(n.x,w.x,y.x,x.x,h,j,k);d.y=c(n.y,w.y,y.y,x.y,h,j,k);d.z=c(n.z,w.z,y.z,x.z,h,j,k);return d};this.getControlPointsArray=function(){var t,A,G=this.points.length,K=[];for(t=0;t1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+o);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",o,h.index-1).pos;this.points[1]=f;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",o,m.index+1).pos;d=d*0.33+0.33;f=this.interpolateCatmullRom(this.points,d);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b=== -"rot")THREE.Quaternion.slerp(f,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=f[0]+(g[0]-f[0])*d;b.y=f[1]+(g[1]-f[1])*d;b.z=f[2]+(g[2]-f[2])*d}}}}if(this.JITCompile&&p[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;oa.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];m=a[b[1]];j=a[b[2]];n=a[b[3]];b=f*f;h=f*b;d[0]=this.interpolate(g[0],m[0],j[0],n[0],f,b,h);d[1]=this.interpolate(g[1],m[1],j[1],n[1],f,b,h);d[2]=this.interpolate(g[2],m[2],j[2],n[2],f,b,h);return d}; -THREE.Animation.prototype.interpolate=function(a,c,b,d,f,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+t);d=d<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",t,h.index-1).pos;this.points[1]=e;this.points[2]=g;this.points[3]=this.getNextKeyWith("pos",t,j.index+1).pos;d=d*0.33+0.33;e=this.interpolateCatmullRom(this.points,d);b.x=e[0];b.y=e[1];b.z=e[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){d=this.interpolateCatmullRom(this.points,d*1.01);this.target.set(d[0],d[1],d[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();d=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,d,0)}}}else if(b=== +"rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&w[0][n]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;ta.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];j=a[b[1]];k=a[b[2]];n=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],n[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],n[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],n[2],e,b,h);return d}; +THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; -THREE.Camera=function(a,c,b,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; +THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype; THREE.Camera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.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,c,b){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);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixWorldNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate= !1;c=!0;THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse)}}for(a=0;a=0&&ka>=0&&K>=0&&ea>=0)return!0;else if(ma<0&&ka<0||K<0&&ea<0)return!1;else{if(ma<0)Y=Math.max(Y,ma/(ma-ka));else ka<0&&(V=Math.min(V,ma/(ma-ka)));if(K<0)Y=Math.max(Y,K/(K-ea));else ea<0&&(V=Math.min(V,K/(K-ea)));if(Vma&&fa.z0&& -E.z<1){u=x[o]=x[o]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=ja.rotation.z;u.scale.x=ja.scale.x*Math.abs(u.x-(E.x+e.projectionMatrix.n11)/(E.w+e.projectionMatrix.n14));u.scale.y=ja.scale.y*Math.abs(u.y-(E.y+e.projectionMatrix.n22)/(E.w+e.projectionMatrix.n24));u.materials=ja.materials;V.push(u);o++}}}}Y&&V.sort(a);return V};this.unprojectVector=function(O,e){var Y=e.matrixWorld.clone();Y.multiplySelf(THREE.Matrix4.makeInvert(e.projectionMatrix));Y.multiplyVector3(O); -return O}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,m){b=h;d=m;f=b/2;g=d/2};this.render=function(h,m){var j,n,p,v,u,o,x,B;a=c.projectScene(h,m);j=0;for(n=a.length;j0){Q.r+=va.r*ca;Q.g+=va.g*ca;Q.b+=va.b*ca}}else if(ca instanceof THREE.PointLight){t.sub(ca.position,$);t.normalize();ca=ga.dot(t)*sa;if(ca>0){Q.r+=va.r*ca;Q.g+=va.g*ca;Q.b+=va.b*ca}}}}function za(I,$,ga){if(ga.opacity!=0){a(ga.opacity); -c(ga.blending);var Q,X,ca,va,sa,ua;if(ga instanceof THREE.ParticleBasicMaterial){if(ga.map){va=ga.map.image;sa=va.width>>1;ua=va.height>>1;X=$.scale.x*m;ca=$.scale.y*j;ga=X*sa;Q=ca*ua;U.set(I.x-ga,I.y-Q,I.x+ga,I.y+Q);if(ta.instersects(U)){n.save();n.translate(I.x,I.y);n.rotate(-$.rotation);n.scale(X,-ca);n.translate(-sa,-ua);n.drawImage(va,0,0);n.restore()}}}else if(ga instanceof THREE.ParticleCircleMaterial){if(qa){Ba.r=k.r+y.r+z.r;Ba.g=k.g+y.g+z.g;Ba.b=k.b+y.b+z.b;V.r=ga.color.r*Ba.r;V.g=ga.color.g* -Ba.g;V.b=ga.color.b*Ba.b;V.updateStyleString()}else V.__styleString=ga.color.__styleString;ga=$.scale.x*m;Q=$.scale.y*j;U.set(I.x-ga,I.y-Q,I.x+ga,I.y+Q);if(ta.instersects(U)){X=V.__styleString;if(B!=X)n.fillStyle=B=X;n.save();n.translate(I.x,I.y);n.rotate(-$.rotation);n.scale(ga,Q);n.beginPath();n.arc(0,0,1,0,q,!0);n.closePath();n.fill();n.restore()}}}}function Ea(I,$,ga,Q){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);n.beginPath();n.moveTo(I.positionScreen.x,I.positionScreen.y);n.lineTo($.positionScreen.x, -$.positionScreen.y);n.closePath();if(Q instanceof THREE.LineBasicMaterial){V.__styleString=Q.color.__styleString;I=Q.linewidth;if(E!=I)n.lineWidth=E=I;I=V.__styleString;if(x!=I)n.strokeStyle=x=I;n.stroke();U.inflate(Q.linewidth*2)}}}function ra(I,$,ga,Q,X,ca){if(X.opacity!=0){a(X.opacity);c(X.blending);N=I.positionScreen.x;R=I.positionScreen.y;da=$.positionScreen.x;O=$.positionScreen.y;e=ga.positionScreen.x;Y=ga.positionScreen.y;n.beginPath();n.moveTo(N,R);n.lineTo(da,O);n.lineTo(e,Y);n.lineTo(N, -R);n.closePath();if(X instanceof THREE.MeshBasicMaterial)if(X.map)X.map.mapping instanceof THREE.UVMapping&&Ma(N,R,da,O,e,Y,X.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v);else if(X.envMap){if(X.envMap.mapping instanceof THREE.SphericalReflectionMapping){I=W.matrixWorldInverse;t.copy(Q.vertexNormalsWorld[0]);na=(t.x*I.n11+t.y*I.n12+t.z*I.n13)*0.5+0.5;ja=-(t.x*I.n21+t.y*I.n22+t.z*I.n23)*0.5+0.5;t.copy(Q.vertexNormalsWorld[1]);wa=(t.x*I.n11+t.y*I.n12+t.z*I.n13)*0.5+0.5; -Ga=-(t.x*I.n21+t.y*I.n22+t.z*I.n23)*0.5+0.5;t.copy(Q.vertexNormalsWorld[2]);la=(t.x*I.n11+t.y*I.n12+t.z*I.n13)*0.5+0.5;aa=-(t.x*I.n21+t.y*I.n22+t.z*I.n23)*0.5+0.5;Ma(N,R,da,O,e,Y,X.envMap.image,na,ja,wa,Ga,la,aa)}}else X.wireframe?Na(X.color.__styleString,X.wireframeLinewidth):L(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){X.map.mapping instanceof THREE.UVMapping&&Ma(N,R,da,O,e,Y,X.map.image,Q.uvs[0].u,Q.uvs[0].v,Q.uvs[1].u,Q.uvs[1].v,Q.uvs[2].u,Q.uvs[2].v); -c(THREE.SubtractiveBlending)}if(qa)if(!X.wireframe&&X.shading==THREE.SmoothShading&&Q.vertexNormalsWorld.length==3){ma.r=ka.r=K.r=k.r;ma.g=ka.g=K.g=k.g;ma.b=ka.b=K.b=k.b;pa(ca,Q.v1.positionWorld,Q.vertexNormalsWorld[0],ma);pa(ca,Q.v2.positionWorld,Q.vertexNormalsWorld[1],ka);pa(ca,Q.v3.positionWorld,Q.vertexNormalsWorld[2],K);ea.r=(ka.r+K.r)*0.5;ea.g=(ka.g+K.g)*0.5;ea.b=(ka.b+K.b)*0.5;Ca=La(ma,ka,K,ea);Ma(N,R,da,O,e,Y,Ca,0,0,1,0,0,1)}else{Ba.r=k.r;Ba.g=k.g;Ba.b=k.b;pa(ca,Q.centroidWorld,Q.normalWorld, -Ba);V.r=X.color.r*Ba.r;V.g=X.color.g*Ba.g;V.b=X.color.b*Ba.b;V.updateStyleString();X.wireframe?Na(V.__styleString,X.wireframeLinewidth):L(V.__styleString)}else X.wireframe?Na(X.color.__styleString,X.wireframeLinewidth):L(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){Ha=W.near;fa=W.far;ma.r=ma.g=ma.b=1-Fa(I.positionScreen.z,Ha,fa);ka.r=ka.g=ka.b=1-Fa($.positionScreen.z,Ha,fa);K.r=K.g=K.b=1-Fa(ga.positionScreen.z,Ha,fa);ea.r=(ka.r+K.r)*0.5;ea.g=(ka.g+K.g)*0.5;ea.b=(ka.b+K.b)* -0.5;Ca=La(ma,ka,K,ea);Ma(N,R,da,O,e,Y,Ca,0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){V.r=Pa(Q.normalWorld.x);V.g=Pa(Q.normalWorld.y);V.b=Pa(Q.normalWorld.z);V.updateStyleString();X.wireframe?Na(V.__styleString,X.wireframeLinewidth):L(V.__styleString)}}}function Na(I,$){if(x!=I)n.strokeStyle=x=I;if(E!=$)n.lineWidth=E=$;n.stroke();U.inflate($*2)}function L(I){if(B!=I)n.fillStyle=B=I;n.fill()}function Ma(I,$,ga,Q,X,ca,va,sa,ua,Da,ya,Ta,Qa){var Ja,Ua;Ja=va.width-1;Ua=va.height-1;sa*=Ja; -ua*=Ua;Da*=Ja;ya*=Ua;Ta*=Ja;Qa*=Ua;ga-=I;Q-=$;X-=I;ca-=$;Da-=sa;ya-=ua;Ta-=sa;Qa-=ua;Ja=Da*Qa-Ta*ya;if(Ja!=0){Ua=1/Ja;Ja=(Qa*ga-ya*X)*Ua;ya=(Qa*Q-ya*ca)*Ua;ga=(Da*X-Ta*ga)*Ua;Q=(Da*ca-Ta*Q)*Ua;I=I-Ja*sa-ga*ua;$=$-ya*sa-Q*ua;n.save();n.transform(Ja,ya,ga,Q,I,$);n.clip();n.drawImage(va,0,0);n.restore()}}function La(I,$,ga,Q){var X=~~(I.r*255),ca=~~(I.g*255);I=~~(I.b*255);var va=~~($.r*255),sa=~~($.g*255);$=~~($.b*255);var ua=~~(ga.r*255),Da=~~(ga.g*255);ga=~~(ga.b*255);var ya=~~(Q.r*255),Ta=~~(Q.g* -255);Q=~~(Q.b*255);S[0]=X<0?0:X>255?255:X;S[1]=ca<0?0:ca>255?255:ca;S[2]=I<0?0:I>255?255:I;S[4]=va<0?0:va>255?255:va;S[5]=sa<0?0:sa>255?255:sa;S[6]=$<0?0:$>255?255:$;S[8]=ua<0?0:ua>255?255:ua;S[9]=Da<0?0:Da>255?255:Da;S[10]=ga<0?0:ga>255?255:ga;S[12]=ya<0?0:ya>255?255:ya;S[13]=Ta<0?0:Ta>255?255:Ta;S[14]=Q<0?0:Q>255?255:Q;A.putImageData(C,0,0);H.drawImage(D,0,0);return G}function Fa(I,$,ga){I=(I-$)/(ga-$);return I*I*(3-2*I)}function Pa(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ra(I,$){var ga=$.x- -I.x,Q=$.y-I.y,X=1/Math.sqrt(ga*ga+Q*Q);ga*=X;Q*=X;$.x+=ga;$.y+=Q;I.x-=ga;I.y-=Q}var T,Z,P,Aa,Ia,Va,Ka,F;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,j);b=d.projectScene(oa,W,this.sortElements);(qa=oa.lights.length>0)&&ha(oa);T=0;for(Z=b.length;T0){wa.r+=aa.color.r*ta;wa.g+=aa.color.g*ta;wa.b+=aa.color.b*ta}}else if(aa instanceof THREE.PointLight){Y.sub(aa.position,ja.centroidWorld);Y.normalize();ta=ja.normalWorld.dot(Y)*aa.intensity;if(ta>0){wa.r+=aa.color.r*ta;wa.g+=aa.color.g*ta;wa.b+=aa.color.b*ta}}}}function c(na,ja,wa, -Ga,la,aa){K=d(ea++);K.setAttribute("d","M "+na.positionScreen.x+" "+na.positionScreen.y+" L "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(la instanceof THREE.MeshBasicMaterial)J.__styleString=la.color.__styleString;else if(la instanceof THREE.MeshLambertMaterial)if(M){N.r=R.r;N.g=R.g;N.b=R.b;a(aa,Ga,N);J.r=la.color.r*N.r;J.g=la.color.g*N.g;J.b=la.color.b*N.b;J.updateStyleString()}else J.__styleString=la.color.__styleString;else if(la instanceof -THREE.MeshDepthMaterial){e=1-la.__2near/(la.__farPlusNear-Ga.z*la.__farMinusNear);J.setRGB(e,e,e)}else la instanceof THREE.MeshNormalMaterial&&J.setRGB(f(Ga.normalWorld.x),f(Ga.normalWorld.y),f(Ga.normalWorld.z));la.wireframe?K.setAttribute("style","fill: none; stroke: "+J.__styleString+"; stroke-width: "+la.wireframeLinewidth+"; stroke-opacity: "+la.opacity+"; stroke-linecap: "+la.wireframeLinecap+"; stroke-linejoin: "+la.wireframeLinejoin):K.setAttribute("style","fill: "+J.__styleString+"; fill-opacity: "+ -la.opacity);m.appendChild(K)}function b(na,ja,wa,Ga,la,aa,ta){K=d(ea++);K.setAttribute("d","M "+na.positionScreen.x+" "+na.positionScreen.y+" L "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+" L "+Ga.positionScreen.x+","+Ga.positionScreen.y+"z");if(aa instanceof THREE.MeshBasicMaterial)J.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshLambertMaterial)if(M){N.r=R.r;N.g=R.g;N.b=R.b;a(ta,la,N);J.r=aa.color.r*N.r;J.g=aa.color.g*N.g; -J.b=aa.color.b*N.b;J.updateStyleString()}else J.__styleString=aa.color.__styleString;else if(aa instanceof THREE.MeshDepthMaterial){e=1-aa.__2near/(aa.__farPlusNear-la.z*aa.__farMinusNear);J.setRGB(e,e,e)}else aa instanceof THREE.MeshNormalMaterial&&J.setRGB(f(la.normalWorld.x),f(la.normalWorld.y),f(la.normalWorld.z));aa.wireframe?K.setAttribute("style","fill: none; stroke: "+J.__styleString+"; stroke-width: "+aa.wireframeLinewidth+"; stroke-opacity: "+aa.opacity+"; stroke-linecap: "+aa.wireframeLinecap+ -"; stroke-linejoin: "+aa.wireframeLinejoin):K.setAttribute("style","fill: "+J.__styleString+"; fill-opacity: "+aa.opacity);m.appendChild(K)}function d(na){if(V[na]==null){V[na]=document.createElementNS("http://www.w3.org/2000/svg","path");Ca==0&&V[na].setAttribute("shape-rendering","crispEdges")}return V[na]}function f(na){return na<0?Math.min((1+na)*0.5,0.5):0.5+Math.min(na*0.5,0.5)}var g=null,h=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,n,p,v,u,o,x,B,E= -new THREE.Rectangle,w=new THREE.Rectangle,M=!1,J=new THREE.Color(16777215),N=new THREE.Color(16777215),R=new THREE.Color(0),da=new THREE.Color(0),O=new THREE.Color(0),e,Y=new THREE.Vector3,V=[],ma=[],ka=[],K,ea,Ha,fa,Ca=1;this.domElement=m;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(na){switch(na){case "high":Ca=1;break;case "low":Ca=0}};this.setSize=function(na,ja){j=na;n=ja;p=j/2;v=n/2;m.setAttribute("viewBox",-p+" "+-v+" "+j+" "+n);m.setAttribute("width", -j);m.setAttribute("height",n);E.set(-p,-v,p,v)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render=function(na,ja){var wa,Ga,la,aa,ta,xa,U,qa;this.autoClear&&this.clear();g=h.projectScene(na,ja,this.sortElements);fa=Ha=ea=0;if(M=na.lights.length>0){U=na.lights;R.setRGB(0,0,0);da.setRGB(0,0,0);O.setRGB(0,0,0);wa=0;for(Ga=U.length;wa=0&&ra>=0&&na>=0&&wa>=0)return!0;else if(ta<0&&ra<0||na<0&&wa<0)return!1;else{if(ta<0)ma=Math.max(ma,ta/(ta-ra));else ra<0&&(N=Math.min(N,ta/(ta-ra)));if(na<0)ma=Math.max(ma,na/(na-wa));else wa<0&&(N=Math.min(N,na/(na-wa)));if(Nta&&h.positionScreen.z0&&z.z<1){F[K]=F[K]||new THREE.RenderableParticle;K++;G=partile;G.x=z.x/z.w;G.y=z.y/z.w;G.z=z.z;G.rotation=X.rotation.z;G.scale.x=X.scale.x* +Math.abs(G.x-(z.x+Z.projectionMatrix.n11)/(z.w+Z.projectionMatrix.n14));G.scale.y=X.scale.y*Math.abs(G.y-(z.y+Z.projectionMatrix.n22)/(z.w+Z.projectionMatrix.n24));G.materials=X.materials;N.push(G)}}}}ma&&N.sort(c);return N}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,n,w,y,x,t,A,G;a=c.projectScene(h,j);k=0;for(n=a.length;k0){O.r+=Ia.r*Aa;O.g+=Ia.g*Aa;O.b+=Ia.b*Aa}}else if(Aa instanceof THREE.PointLight){q.sub(Aa.position,E);q.normalize();Aa=Y.dot(q)*qa;if(Aa>0){O.r+=Ia.r*Aa;O.g+=Ia.g*Aa;O.b+=Ia.b*Aa}}}}function La(M,E,Y){if(Y.opacity!=0){a(Y.opacity); +c(Y.blending);var O,fa,Aa,Ia,qa,Ba;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){Ia=Y.map.image;qa=Ia.width>>1;Ba=Ia.height>>1;fa=E.scale.x*j;Aa=E.scale.y*k;Y=fa*qa;O=Aa*Ba;ea.set(M.x-Y,M.y-O,M.x+Y,M.y+O);if(sa.instersects(ea)){n.save();n.translate(M.x,M.y);n.rotate(-E.rotation);n.scale(fa,-Aa);n.translate(-qa,-Ba);n.drawImage(Ia,0,0);n.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(pa){za.r=m.r+C.r+p.r;za.g=m.g+C.g+p.g;za.b=m.b+C.b+p.b;S.r=Y.color.r*za.r;S.g=Y.color.g* +za.g;S.b=Y.color.b*za.b;S.updateStyleString()}else S.__styleString=Y.color.__styleString;Y=E.scale.x*j;O=E.scale.y*k;ea.set(M.x-Y,M.y-O,M.x+Y,M.y+O);if(sa.instersects(ea)){fa=S.__styleString;if(G!=fa)n.fillStyle=G=fa;n.save();n.translate(M.x,M.y);n.rotate(-E.rotation);n.scale(Y,O);n.beginPath();n.arc(0,0,1,0,o,!0);n.closePath();n.fill();n.restore()}}}}function Pa(M,E,Y,O){if(O.opacity!=0){a(O.opacity);c(O.blending);n.beginPath();n.moveTo(M.positionScreen.x,M.positionScreen.y);n.lineTo(E.positionScreen.x, +E.positionScreen.y);n.closePath();if(O instanceof THREE.LineBasicMaterial){S.__styleString=O.color.__styleString;M=O.linewidth;if(K!=M)n.lineWidth=K=M;M=S.__styleString;if(A!=M)n.strokeStyle=A=M;n.stroke();ea.inflate(O.linewidth*2)}}}function Na(M,E,Y,O,fa,Aa){if(fa.opacity!=0){a(fa.opacity);c(fa.blending);H=M.positionScreen.x;R=M.positionScreen.y;$=E.positionScreen.x;W=E.positionScreen.y;f=Y.positionScreen.x;ga=Y.positionScreen.y;n.beginPath();n.moveTo(H,R);n.lineTo($,W);n.lineTo(f,ga);n.lineTo(H, +R);n.closePath();if(fa instanceof THREE.MeshBasicMaterial)if(fa.map)fa.map.mapping instanceof THREE.UVMapping&&Oa(H,R,$,W,f,ga,fa.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else if(fa.envMap){if(fa.envMap.mapping instanceof THREE.SphericalReflectionMapping){M=U.matrixWorldInverse;q.copy(O.vertexNormalsWorld[0]);ha=(q.x*M.n11+q.y*M.n12+q.z*M.n13)*0.5+0.5;oa=-(q.x*M.n21+q.y*M.n22+q.z*M.n23)*0.5+0.5;q.copy(O.vertexNormalsWorld[1]);ia=(q.x*M.n11+q.y*M.n12+q.z*M.n13)* +0.5+0.5;xa=-(q.x*M.n21+q.y*M.n22+q.z*M.n23)*0.5+0.5;q.copy(O.vertexNormalsWorld[2]);X=(q.x*M.n11+q.y*M.n12+q.z*M.n13)*0.5+0.5;da=-(q.x*M.n21+q.y*M.n22+q.z*M.n23)*0.5+0.5;Oa(H,R,$,W,f,ga,fa.envMap.image,ha,oa,ia,xa,X,da)}}else fa.wireframe?Fa(fa.color.__styleString,fa.wireframeLinewidth):P(fa.color.__styleString);else if(fa instanceof THREE.MeshLambertMaterial){if(fa.map&&!fa.wireframe){fa.map.mapping instanceof THREE.UVMapping&&Oa(H,R,$,W,f,ga,fa.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v, +O.uvs[2].u,O.uvs[2].v);c(THREE.SubtractiveBlending)}if(pa)if(!fa.wireframe&&fa.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){Z.r=ma.r=N.r=m.r;Z.g=ma.g=N.g=m.g;Z.b=ma.b=N.b=m.b;ja(Aa,O.v1.positionWorld,O.vertexNormalsWorld[0],Z);ja(Aa,O.v2.positionWorld,O.vertexNormalsWorld[1],ma);ja(Aa,O.v3.positionWorld,O.vertexNormalsWorld[2],N);ta.r=(ma.r+N.r)*0.5;ta.g=(ma.g+N.g)*0.5;ta.b=(ma.b+N.b)*0.5;wa=Ga(Z,ma,N,ta);Oa(H,R,$,W,f,ga,wa,0,0,1,0,0,1)}else{za.r=m.r;za.g=m.g;za.b=m.b;ja(Aa,O.centroidWorld, +O.normalWorld,za);S.r=fa.color.r*za.r;S.g=fa.color.g*za.g;S.b=fa.color.b*za.b;S.updateStyleString();fa.wireframe?Fa(S.__styleString,fa.wireframeLinewidth):P(S.__styleString)}else fa.wireframe?Fa(fa.color.__styleString,fa.wireframeLinewidth):P(fa.color.__styleString)}else if(fa instanceof THREE.MeshDepthMaterial){ra=U.near;na=U.far;Z.r=Z.g=Z.b=1-Ra(M.positionScreen.z,ra,na);ma.r=ma.g=ma.b=1-Ra(E.positionScreen.z,ra,na);N.r=N.g=N.b=1-Ra(Y.positionScreen.z,ra,na);ta.r=(ma.r+N.r)*0.5;ta.g=(ma.g+N.g)* +0.5;ta.b=(ma.b+N.b)*0.5;wa=Ga(Z,ma,N,ta);Oa(H,R,$,W,f,ga,wa,0,0,1,0,0,1)}else if(fa instanceof THREE.MeshNormalMaterial){S.r=V(O.normalWorld.x);S.g=V(O.normalWorld.y);S.b=V(O.normalWorld.z);S.updateStyleString();fa.wireframe?Fa(S.__styleString,fa.wireframeLinewidth):P(S.__styleString)}}}function Fa(M,E){if(A!=M)n.strokeStyle=A=M;if(K!=E)n.lineWidth=K=E;n.stroke();ea.inflate(E*2)}function P(M){if(G!=M)n.fillStyle=G=M;n.fill()}function Oa(M,E,Y,O,fa,Aa,Ia,qa,Ba,Ca,ya,Da,Ha){var Xa,Sa;Xa=Ia.width-1; +Sa=Ia.height-1;qa*=Xa;Ba*=Sa;Ca*=Xa;ya*=Sa;Da*=Xa;Ha*=Sa;Y-=M;O-=E;fa-=M;Aa-=E;Ca-=qa;ya-=Ba;Da-=qa;Ha-=Ba;Xa=Ca*Ha-Da*ya;if(Xa!=0){Sa=1/Xa;Xa=(Ha*Y-ya*fa)*Sa;ya=(Ha*O-ya*Aa)*Sa;Y=(Ca*fa-Da*Y)*Sa;O=(Ca*Aa-Da*O)*Sa;M=M-Xa*qa-Y*Ba;E=E-ya*qa-O*Ba;n.save();n.transform(Xa,ya,Y,O,M,E);n.clip();n.drawImage(Ia,0,0);n.restore()}}function Ga(M,E,Y,O){var fa=~~(M.r*255),Aa=~~(M.g*255);M=~~(M.b*255);var Ia=~~(E.r*255),qa=~~(E.g*255);E=~~(E.b*255);var Ba=~~(Y.r*255),Ca=~~(Y.g*255);Y=~~(Y.b*255);var ya=~~(O.r* +255),Da=~~(O.g*255);O=~~(O.b*255);T[0]=fa<0?0:fa>255?255:fa;T[1]=Aa<0?0:Aa>255?255:Aa;T[2]=M<0?0:M>255?255:M;T[4]=Ia<0?0:Ia>255?255:Ia;T[5]=qa<0?0:qa>255?255:qa;T[6]=E<0?0:E>255?255:E;T[8]=Ba<0?0:Ba>255?255:Ba;T[9]=Ca<0?0:Ca>255?255:Ca;T[10]=Y<0?0:Y>255?255:Y;T[12]=ya<0?0:ya>255?255:ya;T[13]=Da<0?0:Da>255?255:Da;T[14]=O<0?0:O>255?255:O;B.putImageData(I,0,0);L.drawImage(D,0,0);return Q}function Ra(M,E,Y){M=(M-E)/(Y-E);return M*M*(3-2*M)}function V(M){M=(M+1)*0.5;return M<0?0:M>1?1:M}function ca(M, +E){var Y=E.x-M.x,O=E.y-M.y,fa=1/Math.sqrt(Y*Y+O*O);Y*=fa;O*=fa;E.x+=Y;E.y+=O;M.x-=Y;M.y-=O}var aa,Ja,va,Va,Ma,Ta,Ka,Qa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,j,k);b=d.projectScene(la,U,this.sortElements);(pa=la.lights.length>0)&&ua(la);aa=0;for(Ja=b.length;aa0){ia.r+=da.color.r*sa;ia.g+=da.color.g*sa;ia.b+=da.color.b*sa}}else if(da instanceof THREE.PointLight){ga.sub(da.position,oa.centroidWorld);ga.normalize();sa=oa.normalWorld.dot(ga)*da.intensity;if(sa>0){ia.r+=da.color.r*sa;ia.g+=da.color.g*sa;ia.b+=da.color.b*sa}}}}function c(ha,oa,ia, +xa,X,da){N=d(ta++);N.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");if(X instanceof THREE.MeshBasicMaterial)z.__styleString=X.color.__styleString;else if(X instanceof THREE.MeshLambertMaterial)if(J){H.r=R.r;H.g=R.g;H.b=R.b;a(da,xa,H);z.r=X.color.r*H.r;z.g=X.color.g*H.g;z.b=X.color.b*H.b;z.updateStyleString()}else z.__styleString=X.color.__styleString;else if(X instanceof THREE.MeshDepthMaterial){f= +1-X.__2near/(X.__farPlusNear-xa.z*X.__farMinusNear);z.setRGB(f,f,f)}else X instanceof THREE.MeshNormalMaterial&&z.setRGB(e(xa.normalWorld.x),e(xa.normalWorld.y),e(xa.normalWorld.z));X.wireframe?N.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+X.wireframeLinewidth+"; stroke-opacity: "+X.opacity+"; stroke-linecap: "+X.wireframeLinecap+"; stroke-linejoin: "+X.wireframeLinejoin):N.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+X.opacity);j.appendChild(N)} +function b(ha,oa,ia,xa,X,da,sa){N=d(ta++);N.setAttribute("d","M "+ha.positionScreen.x+" "+ha.positionScreen.y+" L "+oa.positionScreen.x+" "+oa.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(da instanceof THREE.MeshBasicMaterial)z.__styleString=da.color.__styleString;else if(da instanceof THREE.MeshLambertMaterial)if(J){H.r=R.r;H.g=R.g;H.b=R.b;a(sa,X,H);z.r=da.color.r*H.r;z.g=da.color.g*H.g;z.b=da.color.b*H.b;z.updateStyleString()}else z.__styleString= +da.color.__styleString;else if(da instanceof THREE.MeshDepthMaterial){f=1-da.__2near/(da.__farPlusNear-X.z*da.__farMinusNear);z.setRGB(f,f,f)}else da instanceof THREE.MeshNormalMaterial&&z.setRGB(e(X.normalWorld.x),e(X.normalWorld.y),e(X.normalWorld.z));da.wireframe?N.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+da.wireframeLinewidth+"; stroke-opacity: "+da.opacity+"; stroke-linecap: "+da.wireframeLinecap+"; stroke-linejoin: "+da.wireframeLinejoin):N.setAttribute("style", +"fill: "+z.__styleString+"; fill-opacity: "+da.opacity);j.appendChild(N)}function d(ha){if(S[ha]==null){S[ha]=document.createElementNS("http://www.w3.org/2000/svg","path");wa==0&&S[ha].setAttribute("shape-rendering","crispEdges")}return S[ha]}function e(ha){return ha<0?Math.min((1+ha)*0.5,0.5):0.5+Math.min(ha*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,n,w,y,x,t,A,G,K=new THREE.Rectangle,F=new THREE.Rectangle,J=!1,z=new THREE.Color(16777215), +H=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0),W=new THREE.Color(0),f,ga=new THREE.Vector3,S=[],Z=[],ma=[],N,ta,ra,na,wa=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ha){switch(ha){case "high":wa=1;break;case "low":wa=0}};this.setSize=function(ha,oa){k=ha;n=oa;w=k/2;y=n/2;j.setAttribute("viewBox",-w+" "+-y+" "+k+" "+n);j.setAttribute("width",k);j.setAttribute("height",n);K.set(-w,-y,w,y)};this.clear=function(){for(;j.childNodes.length> +0;)j.removeChild(j.childNodes[0])};this.render=function(ha,oa){var ia,xa,X,da,sa,Ea,ea,pa;this.autoClear&&this.clear();g=h.projectScene(ha,oa,this.sortElements);na=ra=ta=0;if(J=ha.lights.length>0){ea=ha.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);W.setRGB(0,0,0);ia=0;for(xa=ea.length;iaS){G=H;S=C[G]}e.bindBuffer(e.ARRAY_BUFFER,t.__webGLMorphTargetsBuffers[G]);e.vertexAttribPointer(y["morphTarget"+z],3,e.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[z]=S;A[G]= -1;S=-1;z++}}e.uniform1fv(q.program.uniforms.morphTargetInfluences,D.__webGLMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,t.__webGLVertexBuffer);e.vertexAttribPointer(k.position,3,e.FLOAT,!1,0,0)}if(k.color>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLColorBuffer);e.vertexAttribPointer(k.color,3,e.FLOAT,!1,0,0)}if(k.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLNormalBuffer);e.vertexAttribPointer(k.normal,3,e.FLOAT,!1,0,0)}if(k.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLTangentBuffer); -e.vertexAttribPointer(k.tangent,4,e.FLOAT,!1,0,0)}if(k.uv>=0)if(t.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLUVBuffer);e.vertexAttribPointer(k.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(k.uv)}else e.disableVertexAttribArray(k.uv);if(k.uv2>=0)if(t.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLUV2Buffer);e.vertexAttribPointer(k.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(k.uv2)}else e.disableVertexAttribArray(k.uv2);if(q.skinning&&k.skinVertexA>=0&&k.skinVertexB>=0&&k.skinIndex>= -0&&k.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinVertexABuffer);e.vertexAttribPointer(k.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinVertexBBuffer);e.vertexAttribPointer(k.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinIndicesBuffer);e.vertexAttribPointer(k.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinWeightsBuffer);e.vertexAttribPointer(k.skinWeight,4,e.FLOAT,!1,0,0)}if(D instanceof THREE.Mesh)if(q.wireframe){e.lineWidth(q.wireframeLinewidth); -e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.__webGLLineBuffer);e.drawElements(e.LINES,t.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,t.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(D instanceof THREE.Line){D=D.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(q.linewidth);e.drawArrays(D,0,t.__webGLLineCount)}else if(D instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,t.__webGLParticleCount);else D instanceof THREE.Ribbon&& -e.drawArrays(e.TRIANGLE_STRIP,0,t.__webGLVertexCount)}}function g(k,y){if(!k.__webGLVertexBuffer)k.__webGLVertexBuffer=e.createBuffer();if(!k.__webGLNormalBuffer)k.__webGLNormalBuffer=e.createBuffer();if(k.hasPos){e.bindBuffer(e.ARRAY_BUFFER,k.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,k.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.position);e.vertexAttribPointer(y.attributes.position,3,e.FLOAT,!1,0,0)}if(k.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,k.__webGLNormalBuffer); -e.bufferData(e.ARRAY_BUFFER,k.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.normal);e.vertexAttribPointer(y.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,k.count);k.count=0}function h(k){if(ka!=k.doubleSided){k.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ka=k.doubleSided}if(K!=k.flipSided){k.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);K=k.flipSided}}function m(k){if(Ha!=k){k?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);Ha=k}}function j(k){wa[0].set(k.n41- -k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);wa[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);wa[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+k.n23,k.n44+k.n24);wa[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);wa[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);wa[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);var y;for(k=0;k<6;k++){y=wa[k];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}function n(k){for(var y=k.matrixWorld,z=-k.geometry.boundingSphere.radius*Math.max(k.scale.x, -Math.max(k.scale.y,k.scale.z)),q=0;q<6;q++){k=wa[q].x*y.n14+wa[q].y*y.n24+wa[q].z*y.n34+wa[q].w;if(k<=z)return!1}return!0}function p(k,y){k.list[k.count]=y;k.count+=1}function v(k){var y,z,q=k.object,t=k.opaque,D=k.transparent;D.count=0;k=t.count=0;for(y=q.materials.length;k65535){H[S].counter+=1;G=H[S].hash+"_"+H[S].counter;k.geometryGroups[G]==undefined&&(k.geometryGroups[G]={faces:[],materials:C,vertices:0,numMorphTargets:ia})}k.geometryGroups[G].faces.push(t);k.geometryGroups[G].vertices+=A}}function E(k,y,z){k.push({buffer:y,object:z,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function w(k){if(k!=ea){switch(k){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR, -e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}ea=k}}function M(k,y,z){if((z.width&z.width-1)==0&&(z.height&z.height-1)==0){e.texParameteri(k,e.TEXTURE_WRAP_S,da(y.wrapS));e.texParameteri(k,e.TEXTURE_WRAP_T,da(y.wrapT));e.texParameteri(k, -e.TEXTURE_MAG_FILTER,da(y.magFilter));e.texParameteri(k,e.TEXTURE_MIN_FILTER,da(y.minFilter));e.generateMipmap(k)}else{e.texParameteri(k,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(k,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(k,e.TEXTURE_MAG_FILTER,R(y.magFilter));e.texParameteri(k,e.TEXTURE_MIN_FILTER,R(y.minFilter))}}function J(k){if(k&&!k.__webGLFramebuffer){k.__webGLFramebuffer=e.createFramebuffer();k.__webGLRenderbuffer=e.createRenderbuffer();k.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER, -k.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,k.width,k.height);e.bindTexture(e.TEXTURE_2D,k.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,da(k.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,da(k.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,da(k.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,da(k.minFilter));e.texImage2D(e.TEXTURE_2D,0,da(k.format),k.width,k.height,0,da(k.format),da(k.type),null);e.bindFramebuffer(e.FRAMEBUFFER, -k.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,k.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,k.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var y,z;if(k){y=k.__webGLFramebuffer;z=k.width;k=k.height}else{y=null;z=na;k=ja}if(y!=V){e.bindFramebuffer(e.FRAMEBUFFER,y);e.viewport(fa,Ca,z,k);V=y}}function N(k,y){var z;if(k=="fragment")z= -e.createShader(e.FRAGMENT_SHADER);else k=="vertex"&&(z=e.createShader(e.VERTEX_SHADER));e.shaderSource(z,y);e.compileShader(z);if(!e.getShaderParameter(z,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(z));return null}return z}function R(k){switch(k){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return e.LINEAR}}function da(k){switch(k){case THREE.RepeatWrapping:return e.REPEAT; -case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE; -case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var O=document.createElement("canvas"), -e,Y=null,V=null,ma=this,ka=null,K=null,ea=null,Ha=null,fa=0,Ca=0,na=0,ja=0,wa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,la=new Float32Array(16),aa=new Float32Array(16),ta=new THREE.Vector4,xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},U=!0,qa=new THREE.Color(0),Ba=0;if(a){if(a.antialias!==undefined)U=a.antialias;a.clearColor!==undefined&&qa.setHex(a.clearColor); -if(a.clearAlpha!==undefined)Ba=a.clearAlpha}this.maxMorphTargets=8;this.domElement=O;this.autoClear=!0;this.sortObjects=!0;(function(k,y,z){try{if(!(e=O.getContext("experimental-webgl",{antialias:k})))throw"Error creating WebGL context.";}catch(q){console.error(q)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(y.r,y.g,y.b,z);_cullEnabled= -!0})(U,qa,Ba);this.context=e;this.setSize=function(k,y){O.width=k;O.height=y;this.setViewport(0,0,O.width,O.height)};this.setViewport=function(k,y,z,q){fa=k;Ca=y;na=z;ja=q;e.viewport(fa,Ca,na,ja)};this.setScissor=function(k,y,z,q){e.scissor(k,y,z,q)};this.enableScissorTest=function(k){k?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(k){e.depthMask(k)};this.setClearColorHex=function(k,y){var z=new THREE.Color(k);e.clearColor(z.r,z.g,z.b,y)};this.setClearColor= -function(k,y){e.clearColor(k.r,k.g,k.b,y)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(k,y,z,q){var t,D,A;if(k instanceof THREE.MeshDepthMaterial)b(k,THREE.ShaderLib.depth);else if(k instanceof THREE.MeshNormalMaterial)b(k,THREE.ShaderLib.normal);else if(k instanceof THREE.MeshBasicMaterial)b(k,THREE.ShaderLib.basic);else if(k instanceof THREE.MeshLambertMaterial)b(k,THREE.ShaderLib.lambert);else if(k instanceof THREE.MeshPhongMaterial)b(k,THREE.ShaderLib.phong); -else if(k instanceof THREE.LineBasicMaterial)b(k,THREE.ShaderLib.basic);else k instanceof THREE.ParticleBasicMaterial&&b(k,THREE.ShaderLib.particle_basic);var C,S,G,H;A=G=H=0;for(C=y.length;A0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,"#define MAX_BONES "+C.maxBones,C.map?"#define USE_MAP":"",C.envMap?"#define USE_ENVMAP":"",C.lightMap?"#define USE_LIGHTMAP":"",C.vertexColors?"#define USE_COLOR":"",C.skinning?"#define USE_SKINNING":"",C.morphTargets?"#define USE_MORPHTARGETS": -"",C.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -e.attachShader(z,N("fragment",A+H));e.attachShader(z,N("vertex",C+y));e.linkProgram(z);e.getProgramParameter(z,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(z,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");z.uniforms={};z.attributes={};k.program=z;z=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in k.uniforms)z.push(t); -t=k.program;H=0;for(y=z.length;H=0&&e.enableVertexAttribArray(D.color);D.normal>=0&&e.enableVertexAttribArray(D.normal); -D.tangent>=0&&e.enableVertexAttribArray(D.tangent);if(k.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){e.enableVertexAttribArray(D.skinVertexA);e.enableVertexAttribArray(D.skinVertexB);e.enableVertexAttribArray(D.skinIndex);e.enableVertexAttribArray(D.skinWeight)}if(k.morphTargets){k.numSupportedMorphTargets=0;if(D.morphTarget0>=0){e.enableVertexAttribArray(D.morphTarget0);k.numSupportedMorphTargets++}if(D.morphTarget1>=0){e.enableVertexAttribArray(D.morphTarget1); -k.numSupportedMorphTargets++}if(D.morphTarget2>=0){e.enableVertexAttribArray(D.morphTarget2);k.numSupportedMorphTargets++}if(D.morphTarget3>=0){e.enableVertexAttribArray(D.morphTarget3);k.numSupportedMorphTargets++}if(D.morphTarget4>=0){e.enableVertexAttribArray(D.morphTarget4);k.numSupportedMorphTargets++}if(D.morphTarget5>=0){e.enableVertexAttribArray(D.morphTarget5);k.numSupportedMorphTargets++}if(D.morphTarget6>=0){e.enableVertexAttribArray(D.morphTarget6);k.numSupportedMorphTargets++}if(D.morphTarget7>= -0){e.enableVertexAttribArray(D.morphTarget7);k.numSupportedMorphTargets++}q.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(t=0;t0||ha.faceVertexUvs.length> -0)A.__uvArray=new Float32Array(C*2);if(ha.faceUvs.length>1||ha.faceVertexUvs.length>1)A.__uv2Array=new Float32Array(C*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){A.__skinVertexAArray=new Float32Array(C*4);A.__skinVertexBArray=new Float32Array(C*4);A.__skinIndexArray=new Float32Array(C*4);A.__skinWeightArray=new Float32Array(C*4)}A.__faceArray=new Uint16Array(S*3);A.__lineArray=new Uint16Array(oa*2);if(A.numMorphTargets){G=void 0;ha=void 0;A.__morphTargetsArrays=[];G=0;for(ha= -A.numMorphTargets;G=0;t--){q=z.__webglObjects[t].object;y==q&&z.__webglObjects.splice(t,1)}k.__objectsRemoved.splice(0,1)}y=0;for(z=k.__webglObjects.length;y0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,ga,C)}if(ab&&ia>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Q,C)}if(db){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Qa,C);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ja,C)}if(F>0){e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexABuffer); -e.bufferData(e.ARRAY_BUFFER,sa,C);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ua,C);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,Da,C);e.bindBuffer(e.ARRAY_BUFFER,A.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ya,C)}}}t.__dirtyVertices=!1;t.__dirtyMorphTargets=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(q instanceof THREE.Ribbon){t=q.geometry;if(t.__dirtyVertices|| -t.__dirtyColors){q=t;D=e.DYNAMIC_DRAW;G=void 0;G=void 0;ha=void 0;A=void 0;H=q.vertices;C=q.colors;ia=H.length;S=C.length;W=q.__vertexArray;oa=q.__colorArray;pa=q.__dirtyColors;if(q.__dirtyVertices){for(G=0;G0}}; -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,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,f=b.length;for(d=0;dT){Q=L;T=I[Q]}f.bindBuffer(f.ARRAY_BUFFER,q.__webGLMorphTargetsBuffers[Q]);f.vertexAttribPointer(C["morphTarget"+p],3,f.FLOAT,!1,0,0);D.__webGLMorphTargetInfluences[p]=T;B[Q]= +1;T=-1;p++}}f.uniform1fv(o.program.uniforms.morphTargetInfluences,D.__webGLMorphTargetInfluences)}else{f.bindBuffer(f.ARRAY_BUFFER,q.__webGLVertexBuffer);f.vertexAttribPointer(m.position,3,f.FLOAT,!1,0,0)}if(m.color>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLColorBuffer);f.vertexAttribPointer(m.color,3,f.FLOAT,!1,0,0)}if(m.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLNormalBuffer);f.vertexAttribPointer(m.normal,3,f.FLOAT,!1,0,0)}if(m.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLTangentBuffer); +f.vertexAttribPointer(m.tangent,4,f.FLOAT,!1,0,0)}if(m.uv>=0)if(q.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUVBuffer);f.vertexAttribPointer(m.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv)}else f.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(q.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLUV2Buffer);f.vertexAttribPointer(m.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(m.uv2)}else f.disableVertexAttribArray(m.uv2);if(o.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>= +0&&m.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);f.vertexAttribPointer(m.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);f.vertexAttribPointer(m.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);f.vertexAttribPointer(m.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);f.vertexAttribPointer(m.skinWeight,4,f.FLOAT,!1,0,0)}if(D instanceof THREE.Mesh)if(o.wireframe){f.lineWidth(o.wireframeLinewidth); +f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);f.drawElements(f.LINES,q.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,q.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(D instanceof THREE.Line){D=D.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(o.linewidth);f.drawArrays(D,0,q.__webGLLineCount)}else if(D instanceof THREE.ParticleSystem)f.drawArrays(f.POINTS,0,q.__webGLParticleCount);else D instanceof THREE.Ribbon&& +f.drawArrays(f.TRIANGLE_STRIP,0,q.__webGLVertexCount)}}function g(m,C){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=f.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=f.createBuffer();if(m.hasPos){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,m.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.position);f.vertexAttribPointer(C.attributes.position,3,f.FLOAT,!1,0,0)}if(m.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,m.__webGLNormalBuffer); +f.bufferData(f.ARRAY_BUFFER,m.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(C.attributes.normal);f.vertexAttribPointer(C.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,m.count);m.count=0}function h(m){if(ma!=m.doubleSided){m.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);ma=m.doubleSided}if(N!=m.flipSided){m.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);N=m.flipSided}}function j(m){if(ra!=m){m?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);ra=m}}function k(m){ia[0].set(m.n41- +m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);ia[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);ia[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);ia[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);ia[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);ia[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var C;for(m=0;m<6;m++){C=ia[m];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function n(m){for(var C=m.matrixWorld,p=-m.geometry.boundingSphere.radius*Math.max(m.scale.x, +Math.max(m.scale.y,m.scale.z)),o=0;o<6;o++){m=ia[o].x*C.n14+ia[o].y*C.n24+ia[o].z*C.n34+ia[o].w;if(m<=p)return!1}return!0}function w(m,C){m.list[m.count]=C;m.count+=1}function y(m){var C,p,o=m.object,q=m.opaque,D=m.transparent;D.count=0;m=q.count=0;for(C=o.materials.length;m65535){L[T].counter+=1;Q=L[T].hash+"_"+L[T].counter;m.geometryGroups[Q]==undefined&&(m.geometryGroups[Q]={faces:[],materials:I,vertices:0,numMorphTargets:ka})}m.geometryGroups[Q].faces.push(q);m.geometryGroups[Q].vertices+=B}}function K(m,C,p){m.push({buffer:C,object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(m){if(m!=ta){switch(m){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR, +f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ta=m}}function J(m,C,p){if((p.width&p.width-1)==0&&(p.height&p.height-1)==0){f.texParameteri(m,f.TEXTURE_WRAP_S,$(C.wrapS));f.texParameteri(m,f.TEXTURE_WRAP_T,$(C.wrapT));f.texParameteri(m,f.TEXTURE_MAG_FILTER, +$(C.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,$(C.minFilter));f.generateMipmap(m)}else{f.texParameteri(m,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(m,f.TEXTURE_MAG_FILTER,R(C.magFilter));f.texParameteri(m,f.TEXTURE_MIN_FILTER,R(C.minFilter))}}function z(m){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=f.createFramebuffer();m.__webGLRenderbuffer=f.createRenderbuffer();m.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER, +m.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,m.width,m.height);f.bindTexture(f.TEXTURE_2D,m.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,$(m.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,$(m.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,$(m.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,$(m.minFilter));f.texImage2D(f.TEXTURE_2D,0,$(m.format),m.width,m.height,0,$(m.format),$(m.type),null);f.bindFramebuffer(f.FRAMEBUFFER, +m.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,m.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,m.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var C,p;if(m){C=m.__webGLFramebuffer;p=m.width;m=m.height}else{C=null;p=ha;m=oa}if(C!=S){f.bindFramebuffer(f.FRAMEBUFFER,C);f.viewport(na,wa,p,m);S=C}}function H(m,C){var p;if(m=="fragment")p= +f.createShader(f.FRAGMENT_SHADER);else m=="vertex"&&(p=f.createShader(f.VERTEX_SHADER));f.shaderSource(p,C);f.compileShader(p);if(!f.getShaderParameter(p,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(p));return null}return p}function R(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;case THREE.LinearFilter:case THREE.LinearMipMapNearestFilter:case THREE.LinearMipMapLinearFilter:return f.LINEAR}}function $(m){switch(m){case THREE.RepeatWrapping:return f.REPEAT; +case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE; +case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var W=document.createElement("canvas"), +f,ga=null,S=null,Z=this,ma=null,N=null,ta=null,ra=null,na=0,wa=0,ha=0,oa=0,ia=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Matrix4,X=new Float32Array(16),da=new Float32Array(16),sa=new THREE.Vector4,Ea={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}},ea=!0,pa=new THREE.Color(0),za=0;if(a){if(a.antialias!==undefined)ea=a.antialias;a.clearColor!==undefined&&pa.setHex(a.clearColor); +if(a.clearAlpha!==undefined)za=a.clearAlpha}this.maxMorphTargets=8;this.domElement=W;this.autoClear=!0;this.sortObjects=!0;(function(m,C,p){try{if(!(f=W.getContext("experimental-webgl",{antialias:m})))throw"Error creating WebGL context.";}catch(o){console.error(o)}f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(C.r,C.g,C.b,p);_cullEnabled= +!0})(ea,pa,za);this.context=f;this.setSize=function(m,C){W.width=m;W.height=C;this.setViewport(0,0,W.width,W.height)};this.setViewport=function(m,C,p,o){na=m;wa=C;ha=p;oa=o;f.viewport(na,wa,ha,oa)};this.setScissor=function(m,C,p,o){f.scissor(m,C,p,o)};this.enableScissorTest=function(m){m?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){f.depthMask(m)};this.setClearColorHex=function(m,C){var p=new THREE.Color(m);f.clearColor(p.r,p.g,p.b,C)};this.setClearColor= +function(m,C){f.clearColor(m.r,m.g,m.b,C)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,C,p,o){var q,D,B;if(m instanceof THREE.MeshDepthMaterial)b(m,THREE.ShaderLib.depth);else if(m instanceof THREE.MeshNormalMaterial)b(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)b(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)b(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)b(m,THREE.ShaderLib.phong); +else if(m instanceof THREE.LineBasicMaterial)b(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&b(m,THREE.ShaderLib.particle_basic);var I,T,Q,L;B=Q=L=0;for(I=C.length;B0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+I.maxDirLights,"#define MAX_POINT_LIGHTS "+I.maxPointLights,"#define MAX_BONES "+I.maxBones,I.map?"#define USE_MAP":"",I.envMap?"#define USE_ENVMAP":"",I.lightMap?"#define USE_LIGHTMAP":"",I.vertexColors?"#define USE_COLOR":"",I.skinning?"#define USE_SKINNING":"",I.morphTargets?"#define USE_MORPHTARGETS": +"",I.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +f.attachShader(p,H("fragment",B+L));f.attachShader(p,H("vertex",I+C));f.linkProgram(p);f.getProgramParameter(p,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};m.program=p;p=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in m.uniforms)p.push(q); +q=m.program;L=0;for(C=p.length;L=0&&f.enableVertexAttribArray(D.color);D.normal>=0&&f.enableVertexAttribArray(D.normal); +D.tangent>=0&&f.enableVertexAttribArray(D.tangent);if(m.skinning&&D.skinVertexA>=0&&D.skinVertexB>=0&&D.skinIndex>=0&&D.skinWeight>=0){f.enableVertexAttribArray(D.skinVertexA);f.enableVertexAttribArray(D.skinVertexB);f.enableVertexAttribArray(D.skinIndex);f.enableVertexAttribArray(D.skinWeight)}if(m.morphTargets){m.numSupportedMorphTargets=0;if(D.morphTarget0>=0){f.enableVertexAttribArray(D.morphTarget0);m.numSupportedMorphTargets++}if(D.morphTarget1>=0){f.enableVertexAttribArray(D.morphTarget1); +m.numSupportedMorphTargets++}if(D.morphTarget2>=0){f.enableVertexAttribArray(D.morphTarget2);m.numSupportedMorphTargets++}if(D.morphTarget3>=0){f.enableVertexAttribArray(D.morphTarget3);m.numSupportedMorphTargets++}if(D.morphTarget4>=0){f.enableVertexAttribArray(D.morphTarget4);m.numSupportedMorphTargets++}if(D.morphTarget5>=0){f.enableVertexAttribArray(D.morphTarget5);m.numSupportedMorphTargets++}if(D.morphTarget6>=0){f.enableVertexAttribArray(D.morphTarget6);m.numSupportedMorphTargets++}if(D.morphTarget7>= +0){f.enableVertexAttribArray(D.morphTarget7);m.numSupportedMorphTargets++}o.__webGLMorphTargetInfluences=new Float32Array(this.maxMorphTargets);for(q=0;q +0||ua.faceVertexUvs.length>0)B.__uvArray=new Float32Array(I*2);if(ua.faceUvs.length>1||ua.faceVertexUvs.length>1)B.__uv2Array=new Float32Array(I*2)}if(Q.geometry.skinWeights.length&&Q.geometry.skinIndices.length){B.__skinVertexAArray=new Float32Array(I*4);B.__skinVertexBArray=new Float32Array(I*4);B.__skinIndexArray=new Float32Array(I*4);B.__skinWeightArray=new Float32Array(I*4)}B.__faceArray=new Uint16Array(T*3);B.__lineArray=new Uint16Array(la*2);if(B.numMorphTargets){Q=void 0;ua=void 0;B.__morphTargetsArrays= +[];Q=0;for(ua=B.numMorphTargets;Q=0;q--){o=p.__webglObjects[q].object;C==o&&p.__webglObjects.splice(q,1)}m.__objectsRemoved.splice(0,1)}C=0;for(p=m.__webglObjects.length;C0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,fa,I)}if(db&&La>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Aa,I)}if(fb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +B.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Sa,I);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,B.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Wa,I)}if(E>0){f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,Ca,I);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,ya,I);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Da,I);f.bindBuffer(f.ARRAY_BUFFER,B.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER, +Ha,I)}}}q.__dirtyVertices=!1;q.__dirtyMorphTargets=!1;q.__dirtyElements=!1;q.__dirtyUvs=!1;q.__dirtyNormals=!1;q.__dirtyTangents=!1;q.__dirtyColors=!1}else if(o instanceof THREE.Ribbon){q=o.geometry;if(q.__dirtyVertices||q.__dirtyColors){o=q;D=f.DYNAMIC_DRAW;Q=void 0;Q=void 0;ua=void 0;B=void 0;L=o.vertices;I=o.colors;ka=L.length;T=I.length;U=o.__vertexArray;la=o.__colorArray;ja=o.__dirtyColors;if(o.__dirtyVertices){for(Q=0;Q0}}; +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,c,b){b&&a.update(undefined,!1,c);b=a.sounds;var d,e=b.length;for(d=0;d25&&(g=25);f=(g-1)*0.5;b=Array(g);for(c=d=0;c25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c=0?u:u+f;u=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange; -this.phi=(this.phi-u[0])*(o[1]-o[0])/(u[1]-u[0])+o[0];u=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;this.theta=(this.theta-u[0])*(o[1]-o[0])/(u[1]-u[0])+o[0];u=this.target.position;u.x=100*Math.sin(this.phi)*Math.cos(this.theta);u.y=100*Math.cos(this.phi);u.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,p,v)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); -this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),m=new Cube(10,10,20),j=new Cube(2,2,10);this.animationParent=new THREE.Mesh(m,a);a=new THREE.Mesh(j,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= -c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,p){return function(){p.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -var Cube=function(a,c,b,d,f,g,h,m,j){function n(E,w,M,J,N,R,da,O){var e,Y,V=d||1,ma=f||1,ka=N/2,K=R/2,ea=p.vertices.length;if(E=="x"&&w=="y"||E=="y"&&w=="x")e="z";else if(E=="x"&&w=="z"||E=="z"&&w=="x"){e="y";ma=g||1}else if(E=="z"&&w=="y"||E=="y"&&w=="z"){e="x";V=g||1}var Ha=V+1,fa=ma+1;N/=V;var Ca=R/ma;for(Y=0;Y0){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(f||0)); -for(d=a+a/2;d<2*a;d++)m.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; -var Icosahedron=function(a){function c(v,u,o){var x=Math.sqrt(v*v+u*u+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(v/x,u/x,o/x)))-1}function b(v,u,o,x){x.faces.push(new THREE.Face3(v,u,o))}function d(v,u){var o=f.vertices[v].position,x=f.vertices[u].position;return c((o.x+x.x)/2,(o.y+x.y)/2,(o.z+x.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, -1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a=0?x:x+e;x=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange; +this.phi=(this.phi-x[0])*(t[1]-t[0])/(x[1]-x[0])+t[0];x=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;this.theta=(this.theta-x[0])*(t[1]-t[0])/(x[1]-x[0])+t[0];x=this.target.position;x.x=100*Math.sin(this.phi)*Math.cos(this.theta);x.y=100*Math.cos(this.phi);x.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,n,w,y)};this.onMouseMove=function(n){this.mouseX=n.clientX-this.windowHalfX;this.mouseY=n.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints); +this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new Cube(10,10,20),k=new Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation= +c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(n,w){return function(){w.apply(n,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; +var Cube=function(a,c,b,d,e,g,h,j,k){function n(K,F,J,z,H,R,$,W){var f,ga,S=d||1,Z=e||1,ma=H/2,N=R/2,ta=w.vertices.length;if(K=="x"&&F=="y"||K=="y"&&F=="x")f="z";else if(K=="x"&&F=="z"||K=="z"&&F=="x"){f="y";Z=g||1}else if(K=="z"&&F=="y"||K=="y"&&F=="z"){f="x";S=g||1}var ra=S+1,na=Z+1;H/=S;var wa=R/Z;for(ga=0;ga0){h(0,0,-n-(g||0));for(d=a;d0){h(0,0,n+(e||0)); +for(d=a+a/2;d<2*a;d++)j.faces.push(new THREE.Face4(2*a+1,(2*d-2*a+2)%a+a,(2*d-2*a+1)%a+a,(2*d-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder; +var Icosahedron=function(a){function c(y,x,t){var A=Math.sqrt(y*y+x*x+t*t);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(y/A,x/A,t/A)))-1}function b(y,x,t,A){A.faces.push(new THREE.Face3(y,x,t))}function d(y,x){var t=e.vertices[y].position,A=e.vertices[x].position;return c((t.x+A.x)/2,(t.y+A.y)/2,(t.z+A.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0, +1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,g);b(0,5,1,g);b(0,1,7,g);b(0,7,10,g);b(0,10,11,g);b(1,5,9,g);b(5,11,4,g);b(11,10,2,g);b(10,7,6,g);b(7,1,8,g);b(3,9,4,g);b(3,4,2,g);b(3,2,6,g);b(3,6,8,g);b(3,8,9,g);b(4,9,5,g);b(2,4,11,g);b(6,2,10,g);b(8,6,7,g);b(9,8,1,g);for(a=0;a0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,m,u)))-1);n.push(p)}c.push(n)}var o,x,B;f=c.length;for(b=0;b0)for(d=0;d1){o=this.vertices[h].position.clone(); -x=this.vertices[j].position.clone();B=this.vertices[n].position.clone();o.normalize();x.normalize();B.normalize();this.faces.push(new THREE.Face3(h,j,n,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([p,v,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= -1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,f,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var TorusKnot=function(a,c,b,d,f,g,h){function m(v,u,o,x,B,E){u=o/x*v;o=Math.cos(u);return new THREE.Vector3(B*(2+o)*0.5*Math.cos(v),B*(2+o)*Math.sin(v)*0.5,E*B*Math.sin(u)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=f||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,x)))-1);n.push(w)}c.push(n)}var t,A,G;e=c.length;for(b=0;b0)for(d=0;d1){t=this.vertices[h].position.clone();A=this.vertices[k].position.clone();G=this.vertices[n].position.clone();t.normalize();A.normalize();G.normalize();this.faces.push(new THREE.Face3(h,k,n,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(G.x,G.y,G.z)]));this.faceVertexUvs[0].push([w,y,K])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry; +Sphere.prototype.constructor=Sphere; +var Torus=function(a,c,b,d){this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){d=b/this.segmentsT*2*Math.PI;var e=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b= +1;b<=this.segmentsT;++b){d=(this.segmentsT+1)*c+b;e=(this.segmentsT+1)*c+b-1;var g=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; +var TorusKnot=function(a,c,b,d,e,g,h){function j(y,x,t,A,G,K){x=t/A*y;t=Math.cos(x);return new THREE.Vector3(G*(2+t)*0.5*Math.cos(y),G*(2+t)*Math.sin(y)*0.5,K*G*Math.sin(x)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=d||8;this.p=e||2;this.q=g||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;d=new THREE.Vector3;g=new THREE.Vector3;for(a=0;a>7)-127;q|=(B&127)<<16|D<<8;if(q==0&&T==-127)return 0;return(1-2*(I>>7))*(1+q*Math.pow(2,-23))*Math.pow(2,T)}function j(p,o){var q=w(p,o),D=w(p,o+1),B=w(p,o+2);return(w(p,o+3)<<24)+(B<<16)+(D<<8)+q}function k(p,o){var q=w(p,o);return(w(p,o+1)<<8)+q}function n(p,o){var q=w(p,o);return q>127?q-256:q}function w(p, +o){return p.charCodeAt(o)&255}function y(p){var o,q,D;o=j(a,p);q=j(a,p+$);D=j(a,p+W);p=k(a,p+f);THREE.BinaryLoader.prototype.f3(F,o,q,D,p)}function x(p){var o,q,D,B,I,T;o=j(a,p);q=j(a,p+$);D=j(a,p+W);B=k(a,p+f);I=j(a,p+ga);T=j(a,p+S);p=j(a,p+Z);THREE.BinaryLoader.prototype.f3n(F,H,o,q,D,B,I,T,p)}function t(p){var o,q,D,B;o=j(a,p);q=j(a,p+ma);D=j(a,p+N);B=j(a,p+ta);p=k(a,p+ra);THREE.BinaryLoader.prototype.f4(F,o,q,D,B,p)}function A(p){var o,q,D,B,I,T,Q,L;o=j(a,p);q=j(a,p+ma);D=j(a,p+N);B=j(a,p+ta); +I=k(a,p+ra);T=j(a,p+na);Q=j(a,p+wa);L=j(a,p+ha);p=j(a,p+oa);THREE.BinaryLoader.prototype.f4n(F,H,o,q,D,B,I,T,Q,L,p)}function G(p){var o,q;o=j(a,p);q=j(a,p+ia);p=j(a,p+xa);THREE.BinaryLoader.prototype.uv3(F.uvs,R[o*2],R[o*2+1],R[q*2],R[q*2+1],R[p*2],R[p*2+1])}function K(p){var o,q,D;o=j(a,p);q=j(a,p+X);D=j(a,p+da);p=j(a,p+sa);THREE.BinaryLoader.prototype.uv4(F.uvs,R[o*2],R[o*2+1],R[q*2],R[q*2+1],R[D*2],R[D*2+1],R[p*2],R[p*2+1])}var F=this,J=0,z,H=[],R=[],$,W,f,ga,S,Z,ma,N,ta,ra,na,wa,ha,oa,ia,xa,X, +da,sa,Ea,ea,pa,za,m,C;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,d,g);z={signature:a.substr(J,8),header_bytes:w(a,J+8),vertex_coordinate_bytes:w(a,J+9),normal_coordinate_bytes:w(a,J+10),uv_coordinate_bytes:w(a,J+11),vertex_index_bytes:w(a,J+12),normal_index_bytes:w(a,J+13),uv_index_bytes:w(a,J+14),material_index_bytes:w(a,J+15),nvertices:j(a,J+16),nnormals:j(a,J+16+4),nuvs:j(a,J+16+8),ntri_flat:j(a,J+16+12),ntri_smooth:j(a,J+16+16),ntri_flat_uv:j(a,J+16+20),ntri_smooth_uv:j(a, +J+16+24),nquad_flat:j(a,J+16+28),nquad_smooth:j(a,J+16+32),nquad_flat_uv:j(a,J+16+36),nquad_smooth_uv:j(a,J+16+40)};J+=z.header_bytes;$=z.vertex_index_bytes;W=z.vertex_index_bytes*2;f=z.vertex_index_bytes*3;ga=z.vertex_index_bytes*3+z.material_index_bytes;S=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;Z=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*2;ma=z.vertex_index_bytes;N=z.vertex_index_bytes*2;ta=z.vertex_index_bytes*3;ra=z.vertex_index_bytes*4;na=z.vertex_index_bytes* +4+z.material_index_bytes;wa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;ha=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;oa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;ia=z.uv_index_bytes;xa=z.uv_index_bytes*2;X=z.uv_index_bytes;da=z.uv_index_bytes*2;sa=z.uv_index_bytes*3;g=z.vertex_index_bytes*3+z.material_index_bytes;C=z.vertex_index_bytes*4+z.material_index_bytes;Ea=z.ntri_flat*g;ea=z.ntri_smooth*(g+z.normal_index_bytes*3); +pa=z.ntri_flat_uv*(g+z.uv_index_bytes*3);za=z.ntri_smooth_uv*(g+z.normal_index_bytes*3+z.uv_index_bytes*3);m=z.nquad_flat*C;g=z.nquad_smooth*(C+z.normal_index_bytes*4);C=z.nquad_flat_uv*(C+z.uv_index_bytes*4);J+=function(p){for(var o,q,D,B=z.vertex_coordinate_bytes*3,I=p+z.nvertices*B;p=this.maxCount-3&&m(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(j=this.size-1);var u=Math.floor(n-m);u<1&&(u=1);n=Math.floor(n+m);n>this.size-1&&(n=this.size-1);var o=Math.floor(p-m);o<1&&(o=1);m=Math.floor(p+m); -m>this.size-1&&(m=this.size-1);for(var x,B,E,w,M,J;v0&&(this.field[E+x]+=w)}}}};this.addPlaneX=function(b,d){var f,g,h,m,j,n=this.size,p=this.yd,v=this.zd,u=this.field,o=n*Math.sqrt(b/d);o>n&&(o=n);for(f=0;f0)for(g=0;gp&&(x=p);for(g=0;g0){j=g*v;for(f=0;fsize&&(dist=size);for(h=0;h0){j=zd*h;for(g=0;g= +this.maxCount-3&&j(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(k=this.size-1);var x=Math.floor(n-j);x<1&&(x=1);n=Math.floor(n+j);n>this.size-1&&(n=this.size-1);var t=Math.floor(w- +j);t<1&&(t=1);j=Math.floor(w+j);j>this.size-1&&(j=this.size-1);for(var A,G,K,F,J,z;y0&&(this.field[K+A]+=F)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,n=this.size,w=this.yd,y=this.zd,x=this.field,t=n*Math.sqrt(b/d);t>n&&(t=n);for(e=0;e0)for(g=0;gw&&(A=w);for(g=0;g0){k=g*y;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -77,10 +161,10 @@ var render_canvas = 1, render_gl = 1; var has_gl = 0; - var bcanvas = document.getElementById("rcanvas"); - var bwebgl = document.getElementById("rwebgl"); + var bcanvas = document.getElementById( "rcanvas" ); + var bwebgl = document.getElementById( "rwebgl" ); - document.addEventListener('mousemove', onDocumentMouseMove, false); + document.addEventListener( 'mousemove', onDocumentMouseMove, false ); init(); animate(); @@ -107,8 +191,8 @@ function init() { - container = document.createElement('div'); - document.body.appendChild(container); + container = document.createElement( 'div' ); + document.body.appendChild( container ); camera = new THREE.Camera( 50, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 100000 ); camera.position.z = 1500; @@ -141,7 +225,7 @@ lightMesh.position = pointLight.position; lightMesh.overdraw = true; lightMesh.updateMatrix(); - scene.addObject(lightMesh); + scene.addObject( lightMesh ); if ( render_gl ) { @@ -169,17 +253,18 @@ stats.domElement.style.zIndex = 100; container.appendChild( stats.domElement ); - bcanvas.addEventListener("click", toggleCanvas, false); - bwebgl.addEventListener("click", toggleWebGL, false); + bcanvas.addEventListener( "click", toggleCanvas, false ); + bwebgl.addEventListener( "click", toggleWebGL, false ); - loader = new THREE.Loader( true ); + //loader = new THREE.BinaryLoader( true ); + loader = new THREE.JSONLoader( true ); document.body.appendChild( loader.statusDomElement ); var s = (new Date).getTime(), callback = function( geometry ) { createScene( geometry, s ) }; - //loader.loadAscii( { model: 'obj/lucy/Lucy100k_slim.js', callback: callback } ); - loader.loadBinary( { model: 'obj/lucy/Lucy100k_bin.js', callback: callback } ); + loader.load( { model: 'obj/lucy/Lucy100k_slim.js', callback: callback } ); + //loader.load( { model: 'obj/lucy/Lucy100k_bin.js', callback: callback } ); } diff --git a/examples/webgl_objconvert_test.html b/examples/webgl_objconvert_test.html index 57bad541..5c5cd5b4 100644 --- a/examples/webgl_objconvert_test.html +++ b/examples/webgl_objconvert_test.html @@ -42,8 +42,91 @@

 
+
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
 		
 		
 		
@@ -192,12 +275,12 @@
 				bcanvas.addEventListener("click", toggleCanvas, false);
 				bwebgl.addEventListener("click", toggleWebGL, false);
 
-				var loader = new THREE.Loader(),
+				var loader = new THREE.JSONLoader(),
 					callbackMale   = function( geometry ) { createScene( geometry,  90, 50, FLOOR, 105 ) },
 					callbackFemale = function( geometry ) { createScene( geometry, -80, 50, FLOOR, 0 ) };
 
-				loader.loadAscii( { model: "obj/male02/Male02_slim.js", callback: callbackMale } );
-				loader.loadAscii( { model: "obj/female02/Female02_slim.js", callback: callbackFemale } );
+				//loader.load( { model: "obj/male02/Male02_slim.js", callback: callbackMale } );
+				//loader.load( { model: "obj/female02/Female02_slim.js", callback: callbackFemale } );
 
 				//loader.loadBinary( { model: "obj/male02/Male02_bin.js", callback: callbackMale } );
 				//loader.loadBinary( { model: "obj/female02/Female02_bin.js", callback: callbackFemale } );
diff --git a/src/core/Face3.js b/src/core/Face3.js
index 3fbcf71a..14571393 100644
--- a/src/core/Face3.js
+++ b/src/core/Face3.js
@@ -10,7 +10,7 @@ THREE.Face3 = function ( a, b, c, normal, color, materials ) {
 	this.c = c;
 
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
-	this.vertexNormals = normal instanceof Array ? normal : [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
+	this.vertexNormals = normal instanceof Array ? normal : [ ];
 
 	this.color = color instanceof THREE.Color ? color : new THREE.Color();
 	this.vertexColors = color instanceof Array ? color : [];
diff --git a/src/core/Face4.js b/src/core/Face4.js
index b3bdef55..24a15f0f 100644
--- a/src/core/Face4.js
+++ b/src/core/Face4.js
@@ -11,7 +11,7 @@ THREE.Face4 = function ( a, b, c, d, normal, color, materials ) {
 	this.d = d;
 
 	this.normal = normal instanceof THREE.Vector3 ? normal : new THREE.Vector3();
-	this.vertexNormals = normal instanceof Array ? normal : [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ];
+	this.vertexNormals = normal instanceof Array ? normal : [ ];
 
 	this.color = color instanceof THREE.Color ? color : new THREE.Color();
 	this.vertexColors = color instanceof Array ? color : [];
diff --git a/src/extras/geometries/Sphere.js b/src/extras/geometries/Sphere.js
index 0a9a08e1..b710c739 100644
--- a/src/extras/geometries/Sphere.js
+++ b/src/extras/geometries/Sphere.js
@@ -6,7 +6,7 @@
 var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 
 	THREE.Geometry.call( this );
-
+	
 	var gridX = segmentsWidth || 8,
 	gridY = segmentsHeight || 6;
 
diff --git a/src/extras/io/BinaryLoader.js b/src/extras/io/BinaryLoader.js
index 3a3057a9..bc3b91ed 100644
--- a/src/extras/io/BinaryLoader.js
+++ b/src/extras/io/BinaryLoader.js
@@ -37,7 +37,7 @@ THREE.BinaryLoader.prototype = {
 
 			s = (new Date).getTime(),
 			worker = new Worker( url ),
-			callback_progress = this.showProgress ? THREE.LoaderOld.prototype.updateProgress : null;
+			callback_progress = this.showProgress ? THREE.Loader.prototype.updateProgress : null;
 		
 		worker.onmessage = function( event ) {
 
@@ -765,5 +765,4 @@ THREE.BinaryLoader.prototype = {
 
 	}
 
-
 };	
\ No newline at end of file
diff --git a/src/extras/io/JSONLoader.js b/src/extras/io/JSONLoader.js
index cd117056..b26c8554 100644
--- a/src/extras/io/JSONLoader.js
+++ b/src/extras/io/JSONLoader.js
@@ -24,6 +24,8 @@ THREE.JSONLoader.prototype = {
 
 	load: function ( parameters ) {
 
+		console.log( parameters );
+		
 		var url = parameters.model,
 			callback = parameters.callback, 
 		    texture_path = parameters.texture_path ? parameters.texture_path : THREE.Loader.prototype.extractUrlbase( url ),
@@ -33,6 +35,8 @@ THREE.JSONLoader.prototype = {
 		
 		worker.onmessage = function( event ) {
 			
+			console.log( event.data );
+			
 			THREE.JSONLoader.prototype.createModel( event.data, callback, texture_path );
 
 		};
@@ -296,12 +300,12 @@ THREE.JSONLoader.prototype = {
 				
 			};
 			
-			Model.prototype = new THREE.Geometry();
-			Model.prototype.constructor = Model;
+		};
 
-			callback( new Model( texture_path ) );
+		Model.prototype = new THREE.Geometry();
+		Model.prototype.constructor = Model;
 
-		}
+		callback( new Model( texture_path ) );
 
 	}
 
diff --git a/src/extras/io/Loader.js b/src/extras/io/Loader.js
index 2c83aebf..875aa341 100644
--- a/src/extras/io/Loader.js
+++ b/src/extras/io/Loader.js
@@ -4,17 +4,17 @@
 
 THREE.Loader = function ( showStatus ) {
 
-	this.showStatus = showStatus;
-	this.statusDomElement = showStatus ? this.addStatusElement() : null;
+	this.showStatus = showStatus;	
+	this.statusDomElement = showStatus ? THREE.Loader.prototype.addStatusElement() : null;
 
 };
 
 THREE.Loader.prototype = {
 
 	addStatusElement: function ( ) {
-
+		
 		var e = document.createElement( "div" );
-
+		
 		e.style.fontSize = "0.8em"; 
 		e.style.textAlign = "left";
 		e.style.background = "#b00"; 
@@ -25,13 +25,13 @@ THREE.Loader.prototype = {
 		e.style.right = "0px"; 
 		e.style.top = "0px"; 
 		e.style.zIndex = 1000;
-
+		
 		e.innerHTML = "Loading ...";
-
+		
 		return e;
-
+		
 	},
-
+	
 	updateProgress: function ( progress ) {
 
 		var message = "Loaded ";
diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js
index cd44ce86..6e07a0f3 100644
--- a/src/renderers/WebGLRenderer.js
+++ b/src/renderers/WebGLRenderer.js
@@ -355,11 +355,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 		
-		materials = unrollGroupMaterials( geometryGroup, object );
+		materials = unrollGroupMaterials( geometryGroup, object );		
 		
 		uvType = bufferGuessUVType( materials, geometryGroup, object );
-		vertexColorType = bufferGuessVertexColorType( materials, geometryGroup, object );
 		normalType = bufferGuessNormalType( materials, geometryGroup, object );
+		vertexColorType = bufferGuessVertexColorType( materials, geometryGroup, object );
+
+		console.log(uvType, normalType, vertexColorType, geometry, materials );
 
 		geometryGroup.__vertexArray = new Float32Array( nvertices * 3 );
 		
@@ -382,7 +384,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		}
 
 		if ( uvType ) {
-		
+			
 			if ( geometry.faceUvs.length > 0 || geometry.faceVertexUvs.length > 0 ) {
 			
 				geometryGroup.__uvArray = new Float32Array( nvertices * 2 );
@@ -437,6 +439,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		var f, fl, fi, face, 
 			vertexNormals, faceNormal, normal,
 			vertexColors, faceColor,
+			uvType, vertexColorType, normalType,
 			uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4,
 			c1, c2, c3, c4,
 			sw1, sw2, sw3, sw4,
@@ -480,6 +483,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 		needsSmoothNormals = geometryGroup.__needsSmoothNormals,
 		
 		vertexColorType = geometryGroup.__vertexColorType,
+		uvType = geometryGroup.__uvType,
+		normalType = geometryGroup.__normalType,
 
 		geometry = object.geometry, // this is shared for all chunks
 
@@ -729,7 +734,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if ( dirtyNormals ) {
+				if ( dirtyNormals && normalType ) {
 
 					if ( vertexNormals.length == 3 && needsSmoothNormals ) {
 
@@ -761,7 +766,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if ( dirtyUvs && uv !== undefined ) {
+				if ( dirtyUvs && uv !== undefined && uvType ) {
 
 					for ( i = 0; i < 3; i ++ ) {
 
@@ -776,7 +781,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if ( dirtyUvs && uv2 !== undefined ) {
+				if ( dirtyUvs && uv2 !== undefined && uvType ) {
 
 					for ( i = 0; i < 3; i ++ ) {
 
@@ -1059,7 +1064,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if( dirtyNormals ) {
+				if( dirtyNormals && normalType ) {
 
 					if ( vertexNormals.length == 4 && needsSmoothNormals ) {
 
@@ -1091,7 +1096,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if ( dirtyUvs && uv !== undefined ) {
+				if ( dirtyUvs && uv !== undefined && uvType ) {
 
 					for ( i = 0; i < 4; i ++ ) {
 
@@ -1106,7 +1111,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				}
 
-				if ( dirtyUvs && uv2 !== undefined ) {
+				if ( dirtyUvs && uv2 !== undefined && uvType ) {
 
 					for ( i = 0; i < 4; i ++ ) {
 
@@ -3445,6 +3450,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			material, meshMaterial,
 			materials = [];
 		
+		console.log( "unrollGroupMaterials", object.materials, geometryGroup );
+		
 		for ( m = 0, ml = object.materials.length; m < ml; m++ ) {
 
 			meshMaterial = object.materials[ m ];
diff --git a/utils/build.py b/utils/build.py
index 44c53678..d6c531f2 100644
--- a/utils/build.py
+++ b/utils/build.py
@@ -95,6 +95,7 @@ EXTRAS_FILES = [
 'extras/geometries/TorusKnot.js',
 'extras/io/Loader.js',
 'extras/io/JSONLoader.js',
+'extras/io/BinaryLoader.js',
 'extras/objects/MarchingCubes.js'
 ]
 
diff --git a/utils/exporters/convert_obj_three.py b/utils/exporters/convert_obj_three.py
index 9a95bac1..fac4e3f4 100644
--- a/utils/exporters/convert_obj_three.py
+++ b/utils/exporters/convert_obj_three.py
@@ -156,6 +156,7 @@ TEMPLATE_FILE_ASCII = u"""\
 
 
 var model = {
+
     'version' : 2,
     
     'materials': [%(materials)s],
@@ -171,7 +172,8 @@ var model = {
     'faces': [%(faces)s],
 
     'end': (new Date).getTime()
-    }
+    
+};
     
 postMessage( model );
 """
@@ -187,6 +189,7 @@ TEMPLATE_FILE_BIN = u"""\
 
 
 var model = {
+
     'version' : 1,
 
     'materials': [%(materials)s],
@@ -194,7 +197,8 @@ var model = {
     'buffers': '%(buffers)s',
 
     'end': (new Date).getTime()
-    }
+    
+};
     
 postMessage( model );
 """