Browse Source

Minor refactoring and clean up.

Mr.doob 14 years ago
parent
commit
27dc056af4

+ 183 - 186
build/Three.js

@@ -4,44 +4,41 @@ THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;th
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
-THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
-this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
-this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
+b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
+a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(G,v,I,o){o=o.clone().subSelf(v);I=I.clone().subSelf(v);var M=G.clone().subSelf(v);G=o.dot(o);v=o.dot(I);o=o.dot(M);var e=I.dot(I);I=I.dot(M);M=1/(G*e-v*v);e=(e*o-v*I)*M;G=(G*I-v*o)*M;return e>0&&G>0&&e+G<1}var c,d,f,g,h,k,j,m,n,w,
-q,p=a.geometry,x=p.vertices,A=[];c=0;for(d=p.faces.length;c<d;c++){f=p.faces[c];w=this.origin.clone();q=this.direction.clone();j=a.globalMatrix;j.extractRotationMatrix(a.matrixRotation);g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;m=a.matrixRotation.multiplyVector3(f.normal.clone());n=q.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(g,
-w))/n;w=w.addSelf(q.multiplyScalar(m));if(f instanceof THREE.Face3){if(b(w,g,h,k)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}else if(f instanceof THREE.Face4&&(b(w,g,h,j)||b(w,h,k,j))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}}return A}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(G,v,H,o){o=o.clone().subSelf(v);H=H.clone().subSelf(v);var M=G.clone().subSelf(v);G=o.dot(o);v=o.dot(H);o=o.dot(M);var e=H.dot(H);H=H.dot(M);M=1/(G*e-v*v);e=(e*o-v*H)*M;G=(G*H-v*o)*M;return e>0&&G>0&&e+G<1}var c,d,f,g,h,k,j,m,n,w,
+u,p=a.geometry,x=p.vertices,A=[];c=0;for(d=p.faces.length;c<d;c++){f=p.faces[c];w=this.origin.clone();u=this.direction.clone();j=a.globalMatrix;g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;m=a.matrixRotation.multiplyVector3(f.normal.clone());n=u.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(g,w))/n;w=w.addSelf(u.multiplyScalar(m));if(f instanceof
+THREE.Face3){if(b(w,g,h,k)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}else if(f instanceof THREE.Face4&&(b(w,g,h,j)||b(w,h,k,j))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}}return A}};
 THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,m,n,w){k=!1;b=j;c=m;d=n;f=w;a()};this.addPoint=function(j,m){if(k){k=!1;b=j;c=m;d=j;f=m}else{b=b<j?b:j;c=c<m?c:m;d=d>j?d:j;f=f>m?f:m}a()};
 THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,m,n,w){k=!1;b=j;c=m;d=n;f=w;a()};this.addPoint=function(j,m){if(k){k=!1;b=j;c=m;d=j;f=m}else{b=b<j?b:j;c=c<m?c:m;d=d>j?d:j;f=f>m?f:m}a()};
-this.add3Points=function(j,m,n,w,q,p){if(k){k=!1;b=j<n?j<q?j:q:n<q?n:q;c=m<w?m<p?m:p:w<p?w:p;d=j>n?j>q?j:q:n>q?n:q;f=m>w?m>p?m:p:w>p?w:p}else{b=j<n?j<q?j<b?j:b:q<b?q:b:n<q?n<b?n:b:q<b?q:b;c=m<w?m<p?m<c?m:c:p<c?p:c:w<p?w<c?w:c:p<c?p:c;d=j>n?j>q?j>d?j:d:q>d?q:d:n>q?n>d?n:d:q>d?q:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
+this.add3Points=function(j,m,n,w,u,p){if(k){k=!1;b=j<n?j<u?j:u:n<u?n:u;c=m<w?m<p?m:p:w<p?w:p;d=j>n?j>u?j:u:n>u?n:u;f=m>w?m>p?m:p:w>p?w:p}else{b=j<n?j<u?j<b?j:b:u<b?u:b:n<u?n<b?n:b:u<b?u:b;c=m<w?m<p?m<c?m:c:p<c?p:c:w<p?w<c?w:c:p<c?p:c;d=j>n?j>u?j>d?j:d:u>d?u:d:n>u?n>d?n:d:u>d?u:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
 d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();d=d<j.getRight()?d:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=d=c=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+
 d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();d=d<j.getRight()?d:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=d=c=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+
 b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+g+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+g+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,m,n,w,q,p,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=f||0;this.n22=g||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=n||1;this.n34=w||0;this.n41=q||0;this.n42=p||0;this.n43=x||0;this.n44=A||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,d,f,g,h,k,j,m,n,w,q,p,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=n;this.n34=w;this.n41=q;this.n42=p;this.n43=x;this.n44=A;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
-this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
-a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
-a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,q=a.n33,p=a.n34,x=a.n41,A=a.n42,G=a.n43,v=a.n44,I=b.n11,o=b.n12,M=b.n13,e=b.n14,ea=b.n21,O=b.n22,P=b.n23,W=b.n24,S=b.n31,aa=b.n32,ba=b.n33,H=b.n34,V=b.n41,la=b.n42,Y=b.n43,ka=b.n44;this.n11=c*I+d*ea+f*S+g*V;this.n12=c*o+d*O+f*aa+g*la;this.n13=c*M+d*P+f*ba+g*Y;this.n14=c*e+d*W+f*H+g*ka;this.n21=h*I+k*ea+j*S+m*V;this.n22=h*o+k*O+j*aa+m*la;
-this.n23=h*M+k*P+j*ba+m*Y;this.n24=h*e+k*W+j*H+m*ka;this.n31=n*I+w*ea+q*S+p*V;this.n32=n*o+w*O+q*aa+p*la;this.n33=n*M+w*P+q*ba+p*Y;this.n34=n*e+w*W+q*H+p*ka;this.n41=x*I+A*ea+G*S+v*V;this.n42=x*o+A*O+G*aa+v*la;this.n43=x*M+A*P+G*ba+v*Y;this.n44=x*e+A*W+G*H+v*ka;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,n=a.n24,w=a.n31,q=a.n32,p=a.n33,x=a.n34,A=a.n41,G=a.n42,v=a.n43;a=a.n44;var I=b.n11,o=b.n12,M=b.n13,e=b.n14,ea=b.n21,O=b.n22,P=b.n23,W=
-b.n24,S=b.n31,aa=b.n32,ba=b.n33,H=b.n34,V=b.n41,la=b.n42,Y=b.n43;b=b.n44;this.n11=d*I+f*ea+g*S+h*V;this.n12=d*o+f*O+g*aa+h*la;this.n13=d*M+f*P+g*ba+h*Y;this.n14=d*e+f*W+g*H+h*b;this.n21=k*I+j*ea+m*S+n*V;this.n22=k*o+j*O+m*aa+n*la;this.n23=k*M+j*P+m*ba+n*Y;this.n24=k*e+j*W+m*H+n*b;this.n31=w*I+q*ea+p*S+x*V;this.n32=w*o+q*O+p*aa+x*la;this.n33=w*M+q*P+p*ba+x*Y;this.n34=w*e+q*W+p*H+x*b;this.n41=A*I+G*ea+v*S+a*V;this.n42=A*o+G*O+v*aa+a*la;this.n43=A*M+G*P+v*ba+a*Y;this.n44=A*e+G*W+v*H+a*b;c[0]=this.n11;
-c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,n=this.n32,w=this.n33,q=this.n34,p=this.n41,x=this.n42,A=this.n43,G=this.n44,v=a.n11,I=a.n21,o=a.n31,M=a.n41,e=a.n12,ea=a.n22,O=a.n32,P=a.n42,W=
-a.n13,S=a.n23,aa=a.n33,ba=a.n43,H=a.n14,V=a.n24,la=a.n34;a=a.n44;this.n11=b*v+c*I+d*o+f*M;this.n12=b*e+c*ea+d*O+f*P;this.n13=b*W+c*S+d*aa+f*ba;this.n14=b*H+c*V+d*la+f*a;this.n21=g*v+h*I+k*o+j*M;this.n22=g*e+h*ea+k*O+j*P;this.n23=g*W+h*S+k*aa+j*ba;this.n24=g*H+h*V+k*la+j*a;this.n31=m*v+n*I+w*o+q*M;this.n32=m*e+n*ea+w*O+q*P;this.n33=m*W+n*S+w*aa+q*ba;this.n34=m*H+n*V+w*la+q*a;this.n41=p*v+x*I+A*o+G*M;this.n42=p*e+x*ea+A*O+G*P;this.n43=p*W+x*S+A*aa+G*ba;this.n44=p*H+x*V+A*la+G*a;return this},multiplyScalar:function(a){this.n11*=
-a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,n=this.n33,w=this.n34,q=this.n41,p=this.n42,x=this.n43,A=this.n44;return d*h*m*q-c*k*m*q-d*g*n*q+b*k*n*q+c*g*w*q-b*h*w*q-d*h*j*p+c*k*j*p+d*f*n*p-a*k*n*p-c*f*w*p+a*h*w*p+
-d*g*j*x-b*k*j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*A+b*h*j*A+c*f*m*A-a*h*m*A-b*f*n*A+a*g*n*A},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=
-this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);
-return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*
-g,m=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*d;this.n13=c;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-b*f;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=
-a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+d);this.n12=j-f;this.n13=b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;
-a.n14=0;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},extractPositionVector:function(a){a.x=this.n14;a.y=this.n24;a.z=this.n34},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
-THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
+THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,m,n,w,u,p,x,A){this.set(a||1,b||0,c||0,d||0,f||0,g||1,h||0,k||0,j||0,m||0,n||1,w||0,u||0,p||0,x||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,f,g,h,k,j,m,n,w,u,p,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=n;this.n34=w;this.n41=u;this.n42=p;this.n43=x;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=g.x;this.n32=g.y;this.n33=g.z;this.n34=-g.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=
+(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*
+f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,u=a.n33,p=a.n34,x=a.n41,A=a.n42,G=a.n43,v=a.n44,H=b.n11,o=b.n12,M=b.n13,e=b.n14,da=b.n21,O=b.n22,
+P=b.n23,V=b.n24,S=b.n31,Z=b.n32,ea=b.n33,J=b.n34;this.n11=c*H+d*da+f*S;this.n12=c*o+d*O+f*Z;this.n13=c*M+d*P+f*ea;this.n14=c*e+d*V+f*J+g;this.n21=h*H+k*da+j*S;this.n22=h*o+k*O+j*Z;this.n23=h*M+k*P+j*ea;this.n24=h*e+k*V+j*J+m;this.n31=n*H+w*da+u*S;this.n32=n*o+w*O+u*Z;this.n33=n*M+w*P+u*ea;this.n34=n*e+w*V+u*J+p;this.n41=x*H+A*da+G*S;this.n42=x*o+A*O+G*Z;this.n43=x*M+A*P+G*ea;this.n44=x*e+A*V+G*J+v;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,
+n=a.n24,w=a.n31,u=a.n32,p=a.n33,x=a.n34,A=a.n41,G=a.n42,v=a.n43;a=a.n44;var H=b.n11,o=b.n12,M=b.n13,e=b.n14,da=b.n21,O=b.n22,P=b.n23,V=b.n24,S=b.n31,Z=b.n32,ea=b.n33,J=b.n34,$=b.n41,ta=b.n42,aa=b.n43;b=b.n44;this.n11=d*H+f*da+g*S+h*$;this.n12=d*o+f*O+g*Z+h*ta;this.n13=d*M+f*P+g*ea+h*aa;this.n14=d*e+f*V+g*J+h*b;this.n21=k*H+j*da+m*S+n*$;this.n22=k*o+j*O+m*Z+n*ta;this.n23=k*M+j*P+m*ea+n*aa;this.n24=k*e+j*V+m*J+n*b;this.n31=w*H+u*da+p*S+x*$;this.n32=w*o+u*O+p*Z+x*ta;this.n33=w*M+u*P+p*ea+x*aa;this.n34=
+w*e+u*V+p*J+x*b;this.n41=A*H+G*da+v*S+a*$;this.n42=A*o+G*O+v*Z+a*ta;this.n43=A*M+G*P+v*ea+a*aa;this.n44=A*e+G*V+v*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,n=this.n32,
+w=this.n33,u=this.n34,p=this.n41,x=this.n42,A=this.n43,G=this.n44,v=a.n11,H=a.n21,o=a.n31,M=a.n12,e=a.n22,da=a.n32,O=a.n13,P=a.n23,V=a.n33,S=a.n14,Z=a.n24;a=a.n34;this.n11=b*v+c*H+d*o;this.n12=b*M+c*e+d*da;this.n13=b*O+c*P+d*V;this.n14=b*S+c*Z+d*a+f;this.n21=g*v+h*H+k*o;this.n22=g*M+h*e+k*da;this.n23=g*O+h*P+k*V;this.n24=g*S+h*Z+k*a+j;this.n31=m*v+n*H+w*o;this.n32=m*M+n*e+w*da;this.n33=m*O+n*P+w*V;this.n34=m*S+n*Z+w*a+u;this.n41=p*v+x*H+A*o;this.n42=p*M+x*e+A*da;this.n43=p*O+x*P+A*V;this.n44=p*S+
+x*Z+A*a+G;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,n=this.n33,w=this.n34,u=this.n41,p=this.n42,x=this.n43,A=this.n44;return d*h*m*u-c*k*m*u-d*g*n*u+b*k*n*u+c*g*
+w*u-b*h*w*u-d*h*j*p+c*k*j*p+d*f*n*p-a*k*n*p-c*f*w*p+a*h*w*p+d*g*j*x-b*k*j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*A+b*h*j*A+c*f*m*A-a*h*m*A-b*f*n*A+a*g*n*A},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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.flattenToArray(this.flat);return flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,
+b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,
+0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,m=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=
+a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*d;this.n13=c;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-b*f;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+d);this.n12=j-f;this.n13=
+b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+
+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,q=a.n33,p=a.n34,x=a.n41,A=a.n42,G=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*p*A-m*q*A+m*w*G-k*p*G-j*w*v+k*q*v;b.n12=g*q*A-f*p*A-g*w*G+d*p*G+f*w*v-d*q*v;b.n13=f*m*A-g*j*A+g*k*G-d*m*G-f*k*v+d*j*v;b.n14=g*j*w-f*m*w-g*k*q+d*m*q+f*k*p-d*j*p;b.n21=m*q*x-j*p*x-m*n*G+h*p*G+j*n*v-h*q*v;b.n22=f*p*x-g*q*x+g*n*G-c*p*G-f*n*v+c*q*v;b.n23=g*j*x-f*m*x-g*h*G+c*m*G+f*h*v-c*j*v;
-b.n24=f*m*n-g*j*n+g*h*q-c*m*q-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*A-h*p*A-k*n*v+h*w*v;b.n32=g*w*x-d*p*x-g*n*A+c*p*A+d*n*v-c*w*v;b.n33=f*m*x-g*k*x+g*h*A-c*m*A-d*h*v+c*k*v;b.n34=g*k*n-d*m*n-g*h*w+c*m*w+d*h*p-c*k*p;b.n41=j*w*x-k*q*x-j*n*A+h*q*A+k*n*G-h*w*G;b.n42=d*q*x-f*w*x+f*n*A-c*q*A-d*n*G+c*w*G;b.n43=f*k*x-d*j*x-f*h*A+c*j*A+d*h*G-c*k*G;b.n44=d*j*n-f*k*n+f*h*w-c*j*w-d*h*q+c*k*q;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,u=a.n33,p=a.n34,x=a.n41,A=a.n42,G=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*p*A-m*u*A+m*w*G-k*p*G-j*w*v+k*u*v;b.n12=g*u*A-f*p*A-g*w*G+d*p*G+f*w*v-d*u*v;b.n13=f*m*A-g*j*A+g*k*G-d*m*G-f*k*v+d*j*v;b.n14=g*j*w-f*m*w-g*k*u+d*m*u+f*k*p-d*j*p;b.n21=m*u*x-j*p*x-m*n*G+h*p*G+j*n*v-h*u*v;b.n22=f*p*x-g*u*x+g*n*G-c*p*G-f*n*v+c*u*v;b.n23=g*j*x-f*m*x-g*h*G+c*m*G+f*h*v-c*j*v;
+b.n24=f*m*n-g*j*n+g*h*u-c*m*u-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*A-h*p*A-k*n*v+h*w*v;b.n32=g*w*x-d*p*x-g*n*A+c*p*A+d*n*v-c*w*v;b.n33=f*m*x-g*k*x+g*h*A-c*m*A-d*h*v+c*k*v;b.n34=g*k*n-d*m*n-g*h*w+c*m*w+d*h*p-c*k*p;b.n41=j*w*x-k*u*x-j*n*A+h*u*A+k*n*G-h*w*G;b.n42=d*u*x-f*w*x+f*n*A-c*u*A-d*n*G+c*w*G;b.n43=f*k*x-d*j*x-f*h*A+c*j*A+d*h*G-c*k*G;b.n44=d*j*n-f*k*n+f*h*w-c*j*w-d*h*u+c*k*u;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*n;c[8]=a*w;return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*n;c[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);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,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);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,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+f)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+f)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
@@ -54,7 +51,7 @@ THREE.Quaternion.prototype.set=function(a,b,c,d){this.x=a;this.y=b;this.z=c;this
 THREE.Quaternion.prototype.calculateW=function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this};THREE.Quaternion.prototype.inverse=function(){this.x*=-1;this.y*=-1;this.z*=-1;return this};THREE.Quaternion.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)};
 THREE.Quaternion.prototype.calculateW=function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this};THREE.Quaternion.prototype.inverse=function(){this.x*=-1;this.y*=-1;this.z*=-1;return this};THREE.Quaternion.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)};
 THREE.Quaternion.prototype.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};THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=b*a+f*g+c*k-d*h;this.y=c*a+f*h+d*g-b*k;this.z=d*a+f*k+b*h-c*g;this.w=f*a-b*g-c*h-d*k;return this};
 THREE.Quaternion.prototype.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};THREE.Quaternion.prototype.multiplySelf=function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=b*a+f*g+c*k-d*h;this.y=c*a+f*h+d*g-b*k;this.z=d*a+f*k+b*h-c*g;this.w=f*a-b*g-c*h-d*k;return this};
 THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*c+h*f-k*d,n=j*d+k*c-g*f,w=j*f+g*d-h*c;c=-g*c-h*d-k*f;b.x=m*j+c*-g+n*-k-w*-h;b.y=n*j+c*-h+w*-g-m*-k;b.z=w*j+c*-k+m*-h-n*-g;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
 THREE.Quaternion.prototype.multiplyVector3=function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*c+h*f-k*d,n=j*d+k*c-g*f,w=j*f+g*d-h*c;c=-g*c-h*d-k*f;b.x=m*j+c*-g+n*-k-w*-h;b.y=n*j+c*-h+w*-g-m*-k;b.z=w*j+c*-k+m*-h-n*-g;return b};THREE.Quaternion.prototype.toMatrix3=function(){};THREE.Quaternion.prototype.toMatrix4=function(){};
-THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.0010){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};
+THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
 THREE.Face3=function(a,b,c,d,f){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face3=function(a,b,c,d,f){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}};
 THREE.Face4=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
@@ -63,10 +60,10 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)k.addSelf(g.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)k.addSelf(g.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(H,V,la,Y,ka,ia,ga){g=H.vertices[V].position;h=H.vertices[la].position;k=H.vertices[Y].position;j=f[ka];m=f[ia];n=f[ga];w=h.x-g.x;q=k.x-g.x;p=h.y-g.y;x=
-k.y-g.y;A=h.z-g.z;G=k.z-g.z;v=m.u-j.u;I=n.u-j.u;o=m.v-j.v;M=n.v-j.v;e=1/(v*M-I*o);P.set((M*w-o*q)*e,(M*p-o*x)*e,(M*A-o*G)*e);W.set((v*q-I*w)*e,(v*x-I*p)*e,(v*G-I*A)*e);ea[V].addSelf(P);ea[la].addSelf(P);ea[Y].addSelf(P);O[V].addSelf(W);O[la].addSelf(W);O[Y].addSelf(W)}var b,c,d,f,g,h,k,j,m,n,w,q,p,x,A,G,v,I,o,M,e,ea=[],O=[],P=new THREE.Vector3,W=new THREE.Vector3,S=new THREE.Vector3,aa=new THREE.Vector3,ba=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ea[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(J,$,ta,aa,la,ia,ga){g=J.vertices[$].position;h=J.vertices[ta].position;k=J.vertices[aa].position;j=f[la];m=f[ia];n=f[ga];w=h.x-g.x;u=k.x-g.x;p=h.y-g.y;
+x=k.y-g.y;A=h.z-g.z;G=k.z-g.z;v=m.u-j.u;H=n.u-j.u;o=m.v-j.v;M=n.v-j.v;e=1/(v*M-H*o);P.set((M*w-o*u)*e,(M*p-o*x)*e,(M*A-o*G)*e);V.set((v*u-H*w)*e,(v*x-H*p)*e,(v*G-H*A)*e);da[$].addSelf(P);da[ta].addSelf(P);da[aa].addSelf(P);O[$].addSelf(V);O[ta].addSelf(V);O[aa].addSelf(V)}var b,c,d,f,g,h,k,j,m,n,w,u,p,x,A,G,v,H,o,M,e,da=[],O=[],P=new THREE.Vector3,V=new THREE.Vector3,S=new THREE.Vector3,Z=new THREE.Vector3,ea=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){da[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
 0;for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
 0;for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){ba.copy(this.vertices[b].normal);d=ea[b];S.copy(d);S.subSelf(ba.multiplyScalar(ba.dot(d))).normalize();aa.cross(this.vertices[b].normal,d);d=aa.dot(O[b]);d=d<0?-1:1;this.vertices[b].tangent.set(S.x,S.y,S.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){ea.copy(this.vertices[b].normal);d=da[b];S.copy(d);S.subSelf(ea.multiplyScalar(ea.dot(d))).normalize();Z.cross(this.vertices[b].normal,d);d=Z.dot(O[b]);d=d<0?-1:1;this.vertices[b].tangent.set(S.x,S.y,S.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var w=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?w.push("undefined"):w.push(n[b].id);return w.join("_")}var b,c,d,f,g,h,k,j,m={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];
 this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var w=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?w.push("undefined"):w.push(n[b].id);return w.join("_")}var b,c,d,f,g,h,k,j,m={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];
 h=g.materials;k=a(h);m[k]==undefined&&(m[k]={hash:k,counter:0});j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0});g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+
 h=g.materials;k=a(h);m[k]==undefined&&(m[k]={hash:k,counter:0});j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0});g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}},toString:function(){return"THREE.Geometry ( vertices: "+
@@ -74,11 +71,11 @@ this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdC
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var d=0;d<a.length;d++)a[d].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var d=0;d<c.hierarchy.length;d++)for(var f=0;f<c.hierarchy[d].keys.length;f++){if(c.hierarchy[d].keys[f].time<0)c.hierarchy[d].keys[f].time=0;c.hierarchy[d].keys[f].index=f;if(c.hierarchy[d].keys[f].rot!==undefined&&!(c.hierarchy[d].keys[f].rot instanceof
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var d=0;d<a.length;d++)a[d].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var d=0;d<c.hierarchy.length;d++)for(var f=0;f<c.hierarchy[d].keys.length;f++){if(c.hierarchy[d].keys[f].time<0)c.hierarchy[d].keys[f].time=0;c.hierarchy[d].keys[f].index=f;if(c.hierarchy[d].keys[f].rot!==undefined&&!(c.hierarchy[d].keys[f].rot instanceof
 THREE.Quaternion)){var g=c.hierarchy[d].keys[f].rot;c.hierarchy[d].keys[f].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}f=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(d=0;d<c.hierarchy.length;d++)c.JIT.hierarchy.push(Array(f));c.initialized=!0}};return b}();
 THREE.Quaternion)){var g=c.hierarchy[d].keys[f].rot;c.hierarchy[d].keys[f].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}f=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(d=0;d<c.hierarchy.length;d++)c.JIT.hierarchy.push(Array(f));c.initialized=!0}};return b}();
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
-THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.0010;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].matrixAutoUpdate=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
+THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.001;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].matrixAutoUpdate=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
-THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.0010-this.startTime+this.offset,m=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.0010-j;j=(new Date).getTime()*0.0010-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,w=this.hierarchy.length;n<w;n++){g=this.hierarchy[n];if(k[n][h]!==
-undefined){g.skinMatrix=k[n][h];g.matrixAutoUpdate=!1;g.matrixNeedsUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,n*16)}else for(var q=0;q<3;q++){c=a[q];d=g.prevKey[c];f=g.nextKey[c];if(f.time<m){if(j<m)if(this.loop){d=this.data.hierarchy[n].keys[0];f=this.getNextKeyWith(c,n,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,n,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.matrixAutoUpdate=!0;g.matrixNeedsUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];f=
-f[c];if(c==="rot"){if(b<0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][h]=this.hierarchy[n].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
+THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.001-this.startTime+this.offset,m=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.001-j;j=(new Date).getTime()*0.001-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,w=this.hierarchy.length;n<w;n++){g=this.hierarchy[n];if(k[n][h]!==undefined){g.skinMatrix=
+k[n][h];g.matrixAutoUpdate=!1;g.matrixNeedsUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,n*16)}else for(var u=0;u<3;u++){c=a[u];d=g.prevKey[c];f=g.nextKey[c];if(f.time<m){if(j<m)if(this.loop){d=this.data.hierarchy[n].keys[0];f=this.getNextKeyWith(c,n,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,n,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.matrixAutoUpdate=!0;g.matrixNeedsUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];f=f[c];if(c==="rot"){if(b<
+0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][h]=this.hierarchy[n].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys;c<d.length;c++)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys;c<d.length;c++)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Camera=function(a,b,c,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=f||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=
 THREE.Camera=function(a,b,c,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=f||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=
 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);if(h)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);if(h)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
@@ -87,7 +84,7 @@ THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatri
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
 THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,f=this.inverseMatrix,g=a.boundRadius*a.boundRadiusScale,h=f.n31*b+f.n32*c+f.n33*d+f.n34;if(h-g>-this.near)return!1;if(h+g<-this.far)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY;
 THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,f=this.inverseMatrix,g=a.boundRadius*a.boundRadiusScale,h=f.n31*b+f.n32*c+f.n33*d+f.n34;if(h-g>-this.near)return!1;if(h+g<-this.far)return!1;h-=g;var k=this.projectionMatrix,j=1/(k.n43*h),m=j*this.screenCenterX,n=(f.n11*b+f.n12*c+f.n13*d+f.n14)*k.n11*m;g=k.n11*g*m;if(n+g<-this.screenCenterX)return!1;if(n-g>this.screenCenterX)return!1;b=(f.n21*b+f.n22*c+f.n23*d+f.n24)*k.n22*j*this.screenCenterY;
 if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,g);return!0};function bind(a,b){return function(){b.apply(a,arguments)}}
 if(b+g<-this.screenCenterY)return!1;if(b-g>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,g);return!0};function bind(a,b){return function(){b.apply(a,arguments)}}
-THREE.QuakeCamera=function(a){THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movement_speed=1;this.look_speed=0.0050;this.nofly=!1;this.look_vertical=!0;this.domElement=document;if(a){if(a.movement_speed!==undefined)this.movement_speed=a.movement_speed;if(a.look_speed!==undefined)this.look_speed=a.look_speed;if(a.nofly!==undefined)this.nofly=a.nofly;if(a.look_vertical!==undefined)this.look_vertical=a.look_vertical;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=
+THREE.QuakeCamera=function(a){THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movement_speed=1;this.look_speed=0.005;this.nofly=!1;this.look_vertical=!0;this.domElement=document;if(a){if(a.movement_speed!==undefined)this.movement_speed=a.movement_speed;if(a.look_speed!==undefined)this.look_speed=a.look_speed;if(a.nofly!==undefined)this.nofly=a.nofly;if(a.look_vertical!==undefined)this.look_vertical=a.look_vertical;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=
 this.phy=this.lon=this.lat=this.mouseY=this.mouseX=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=
 this.phy=this.lon=this.lat=this.mouseY=this.mouseX=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}};this.onMouseMove=
 function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=
 function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=
 function(){this.moveForward&&this.translateZ(-this.movement_speed,this.nofly);this.moveBackward&&this.translateZ(this.movement_speed,this.nofly);this.moveLeft&&this.translateX(-this.movement_speed,this.nofly);this.moveRight&&this.translateX(this.movement_speed,this.nofly);this.lon+=this.mouseX*this.look_speed;this.look_vertical&&(this.lat-=this.mouseY*this.look_speed);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,
 function(){this.moveForward&&this.translateZ(-this.movement_speed,this.nofly);this.moveBackward&&this.translateZ(this.movement_speed,this.nofly);this.moveLeft&&this.translateX(-this.movement_speed,this.nofly);this.moveRight&&this.translateX(this.movement_speed,this.nofly);this.lon+=this.mouseX*this.look_speed;this.look_vertical&&(this.lat-=this.mouseY*this.look_speed);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,
@@ -153,118 +150,118 @@ THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.O
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(O,P){return P.z-O.z}function b(O,P){var W=0,S=1,aa=O.z+O.w,ba=P.z+P.w,H=-O.z+O.w,V=-P.z+P.w;if(aa>=0&&ba>=0&&H>=0&&V>=0)return!0;else if(aa<0&&ba<0||H<0&&V<0)return!1;else{if(aa<0)W=Math.max(W,aa/(aa-ba));else ba<0&&(S=Math.min(S,aa/(aa-ba)));if(H<0)W=Math.max(W,H/(H-V));else V<0&&(S=Math.min(S,H/(H-V)));if(S<W)return!1;else{O.lerpSelf(P,W);P.lerpSelf(O,1-S);return!0}}}var c,d,f=[],g,h,k,j=[],m,n,w=[],q,p,x=[],A=new THREE.Vector4,G=new THREE.Vector4,v=new THREE.Matrix4,
-I=new THREE.Matrix4,o=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,e=new THREE.Vector4,ea;this.projectObjects=function(O,P,W){P=[];var S,aa,ba;d=0;aa=O.objects;O=0;for(S=aa.length;O<S;O++){ba=aa[O];var H;if(!(H=!ba.visible))if(H=ba instanceof THREE.Mesh){a:{H=void 0;for(var V=ba.globalMatrix,la=-ba.geometry.boundingSphere.radius*Math.max(ba.scale.x,Math.max(ba.scale.y,ba.scale.z)),Y=0;Y<6;Y++){H=o[Y].x*V.n14+o[Y].y*
-V.n24+o[Y].z*V.n34+o[Y].w;if(H<=la){H=!1;break a}}H=!0}H=!H}if(!H){c=f[d]=f[d]||new THREE.RenderableObject;A.copy(ba.position);v.multiplyVector3(A);c.object=ba;c.z=A.z;P.push(c);d++}}W&&P.sort(a);return P};this.projectScene=function(O,P,W){var S=[],aa=P.near,ba=P.far,H,V,la,Y,ka,ia,ga,ua,xa,l,y,B,t,u,E,C;k=n=p=0;P.matrixAutoUpdate&&P.update();v.multiply(P.projectionMatrix,P.globalMatrix);o[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);o[1].set(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+v.n14);
-o[2].set(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);o[3].set(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);o[4].set(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);o[5].set(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);for(H=0;H<6;H++){ia=o[H];ia.divideScalar(Math.sqrt(ia.x*ia.x+ia.y*ia.y+ia.z*ia.z))}O.update(undefined,!1,P);ia=this.projectObjects(O,P,!0);O=0;for(H=ia.length;O<H;O++){ga=ia[O].object;if(ga.visible){ga.matrixAutoUpdate&&ga.updateMatrix();ua=ga.globalMatrix;y=ga.matrixRotation;
-xa=ga.materials;l=ga.overdraw;if(ga instanceof THREE.Mesh){B=ga.geometry;t=B.vertices;V=0;for(la=t.length;V<la;V++){u=t[V];u.positionWorld.copy(u.position);ua.multiplyVector3(u.positionWorld);Y=u.positionScreen;Y.copy(u.positionWorld);v.multiplyVector4(Y);Y.x/=Y.w;Y.y/=Y.w;u.__visible=Y.z>aa&&Y.z<ba}B=B.faces;V=0;for(la=B.length;V<la;V++){u=B[V];if(u instanceof THREE.Face3){Y=t[u.a];ka=t[u.b];E=t[u.c];if(Y.__visible&&ka.__visible&&E.__visible&&(ga.doubleSided||ga.flipSided!=(E.positionScreen.x-Y.positionScreen.x)*
-(ka.positionScreen.y-Y.positionScreen.y)-(E.positionScreen.y-Y.positionScreen.y)*(ka.positionScreen.x-Y.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Y.positionWorld);g.v2.positionWorld.copy(ka.positionWorld);g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(Y.positionScreen);g.v2.positionScreen.copy(ka.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(u.normal);y.multiplyVector3(g.normalWorld);g.centroidWorld.copy(u.centroid);
-ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);E=u.vertexNormals;ea=g.vertexNormalsWorld;Y=0;for(ka=E.length;Y<ka;Y++){C=ea[Y]=ea[Y]||new THREE.Vector3;C.copy(E[Y]);y.multiplyVector3(C)}g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=u.materials;g.overdraw=l;if(ga.geometry.uvs[V]){g.uvs[0]=ga.geometry.uvs[V][0];g.uvs[1]=ga.geometry.uvs[V][1];g.uvs[2]=ga.geometry.uvs[V][2]}S.push(g);k++}}else if(u instanceof THREE.Face4){Y=t[u.a];
-ka=t[u.b];E=t[u.c];C=t[u.d];if(Y.__visible&&ka.__visible&&E.__visible&&C.__visible&&(ga.doubleSided||ga.flipSided!=((C.positionScreen.x-Y.positionScreen.x)*(ka.positionScreen.y-Y.positionScreen.y)-(C.positionScreen.y-Y.positionScreen.y)*(ka.positionScreen.x-Y.positionScreen.x)<0||(ka.positionScreen.x-E.positionScreen.x)*(C.positionScreen.y-E.positionScreen.y)-(ka.positionScreen.y-E.positionScreen.y)*(C.positionScreen.x-E.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Y.positionWorld);
-g.v2.positionWorld.copy(ka.positionWorld);g.v3.positionWorld.copy(C.positionWorld);g.v1.positionScreen.copy(Y.positionScreen);g.v2.positionScreen.copy(ka.positionScreen);g.v3.positionScreen.copy(C.positionScreen);g.normalWorld.copy(u.normal);y.multiplyVector3(g.normalWorld);g.centroidWorld.copy(u.centroid);ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=u.materials;g.overdraw=l;
-if(ga.geometry.uvs[V]){g.uvs[0]=ga.geometry.uvs[V][0];g.uvs[1]=ga.geometry.uvs[V][1];g.uvs[2]=ga.geometry.uvs[V][3]}S.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(ka.positionWorld);h.v2.positionWorld.copy(E.positionWorld);h.v3.positionWorld.copy(C.positionWorld);h.v1.positionScreen.copy(ka.positionScreen);h.v2.positionScreen.copy(E.positionScreen);h.v3.positionScreen.copy(C.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);
-h.z=h.centroidScreen.z;h.meshMaterials=xa;h.faceMaterials=u.materials;h.overdraw=l;if(ga.geometry.uvs[V]){h.uvs[0]=ga.geometry.uvs[V][1];h.uvs[1]=ga.geometry.uvs[V][2];h.uvs[2]=ga.geometry.uvs[V][3]}S.push(h);k++}}}}else if(ga instanceof THREE.Line){I.multiply(v,ua);t=ga.geometry.vertices;u=t[0];u.positionScreen.copy(u.position);I.multiplyVector4(u.positionScreen);V=1;for(la=t.length;V<la;V++){Y=t[V];Y.positionScreen.copy(Y.position);I.multiplyVector4(Y.positionScreen);ka=t[V-1];M.copy(Y.positionScreen);
-e.copy(ka.positionScreen);if(b(M,e)){M.multiplyScalar(1/M.w);e.multiplyScalar(1/e.w);m=w[n]=w[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(M);m.v2.positionScreen.copy(e);m.z=Math.max(M.z,e.z);m.materials=ga.materials;S.push(m);n++}}}else if(ga instanceof THREE.Particle){G.set(ga.position.x,ga.position.y,ga.position.z,1);v.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){q=x[p]=x[p]||new THREE.RenderableParticle;q.x=G.x/G.w;q.y=G.y/G.w;q.z=G.z;q.rotation=ga.rotation.z;q.scale.x=ga.scale.x*Math.abs(q.x-
-(G.x+P.projectionMatrix.n11)/(G.w+P.projectionMatrix.n14));q.scale.y=ga.scale.y*Math.abs(q.y-(G.y+P.projectionMatrix.n22)/(G.w+P.projectionMatrix.n24));q.materials=ga.materials;S.push(q);p++}}}}W&&S.sort(a);return S};this.unprojectVector=function(O,P){var W=THREE.Matrix4.makeInvert(P.globalMatrix);W.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));W.multiplyVector3(O);return O}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,n,w,q,p,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){q=a[j];if(q instanceof THREE.RenderableParticle){x=q.x*f+f;A=q.y*g+g;n=0;for(w=q.material.length;n<w;n++){p=q.material[n];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=x+"px";p.style.top=A+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ha){if(q!=ha)m.globalAlpha=q=ha}function b(ha){if(p!=ha){switch(ha){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ha}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,m=f.getContext("2d"),n=new THREE.Color(0),w=0,q=1,p=0,x=null,A=null,G=1,v,I,o,M,e,ea,O,P,W,S=new THREE.Color,
-aa=new THREE.Color,ba=new THREE.Color,H=new THREE.Color,V=new THREE.Color,la,Y,ka,ia,ga,ua,xa,l,y,B=new THREE.Rectangle,t=new THREE.Rectangle,u=new THREE.Rectangle,E=!1,C=new THREE.Color,J=new THREE.Color,L=new THREE.Color,z=new THREE.Color,D=Math.PI*2,F=new THREE.Vector3,T,Q,fa,ma,ra,oa,na=16;T=document.createElement("canvas");T.width=T.height=2;Q=T.getContext("2d");Q.fillStyle="rgba(0,0,0,1)";Q.fillRect(0,0,2,2);fa=Q.getImageData(0,0,2,2);ma=fa.data;ra=document.createElement("canvas");ra.width=
-ra.height=na;oa=ra.getContext("2d");oa.translate(-na/2,-na/2);oa.scale(na,na);na--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ha,Ca){g=ha;h=Ca;k=g/2;j=h/2;f.width=g;f.height=h;B.set(-k,-j,k,j);q=1;p=0;A=x=null;G=1};this.setClearColor=function(ha,Ca){n=ha;w=Ca;t.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(ha,Ca){n.setHex(ha);w=Ca;t.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=
-function(){m.setTransform(1,0,0,-1,k,j);if(!t.isEmpty()){t.inflate(1);t.minSelf(B);if(n.hex==0&&w==0)m.clearRect(t.getX(),t.getY(),t.getWidth(),t.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+w+")";m.fillRect(t.getX(),t.getY(),t.getWidth(),t.getHeight())}t.empty()}};this.render=function(ha,Ca){function R(K){var ja,ca,U,X=K.lights;J.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);K=0;for(ja=X.length;K<ja;K++){ca=
-X[K];U=ca.color;if(ca instanceof THREE.AmbientLight){J.r+=U.r;J.g+=U.g;J.b+=U.b}else if(ca instanceof THREE.DirectionalLight){L.r+=U.r;L.g+=U.g;L.b+=U.b}else if(ca instanceof THREE.PointLight){z.r+=U.r;z.g+=U.g;z.b+=U.b}}}function Ga(K,ja,ca,U){var X,qa,Da,Ea,Ia=K.lights;K=0;for(X=Ia.length;K<X;K++){qa=Ia[K];Da=qa.color;Ea=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ca.dot(qa.position)*Ea;if(qa>0){U.r+=Da.r*qa;U.g+=Da.g*qa;U.b+=Da.b*qa}}else if(qa instanceof THREE.PointLight){F.sub(qa.position,
-ja);F.normalize();qa=ca.dot(F)*Ea;if(qa>0){U.r+=Da.r*qa;U.g+=Da.g*qa;U.b+=Da.b*qa}}}}function Ha(K,ja,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var U,X,qa,Da,Ea,Ia;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map){Da=ca.map.image;Ea=Da.width>>1;Ia=Da.height>>1;X=ja.scale.x*k;qa=ja.scale.y*j;ca=X*Ea;U=qa*Ia;u.set(K.x-ca,K.y-U,K.x+ca,K.y+U);if(B.instersects(u)){m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(X,-qa);m.translate(-Ea,-Ia);m.drawImage(Da,0,0);m.restore()}}}else if(ca instanceof
-THREE.ParticleCircleMaterial){if(E){C.r=J.r+L.r+z.r;C.g=J.g+L.g+z.g;C.b=J.b+L.b+z.b;S.r=ca.color.r*C.r;S.g=ca.color.g*C.g;S.b=ca.color.b*C.b;S.updateStyleString()}else S.__styleString=ca.color.__styleString;ca=ja.scale.x*k;U=ja.scale.y*j;u.set(K.x-ca,K.y-U,K.x+ca,K.y+U);if(B.instersects(u)){X=S.__styleString;if(A!=X)m.fillStyle=A=X;m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(ca,U);m.beginPath();m.arc(0,0,1,0,D,!0);m.closePath();m.fill();m.restore()}}}}function La(K,ja,ca,U){if(U.opacity!=
-0){a(U.opacity);b(U.blending);m.beginPath();m.moveTo(K.positionScreen.x,K.positionScreen.y);m.lineTo(ja.positionScreen.x,ja.positionScreen.y);m.closePath();if(U instanceof THREE.LineBasicMaterial){S.__styleString=U.color.__styleString;K=U.linewidth;if(G!=K)m.lineWidth=G=K;K=S.__styleString;if(x!=K)m.strokeStyle=x=K;m.stroke();u.inflate(U.linewidth*2)}}}function da(K,ja,ca,U,X,qa){if(X.opacity!=0){a(X.opacity);b(X.blending);M=K.positionScreen.x;e=K.positionScreen.y;ea=ja.positionScreen.x;O=ja.positionScreen.y;
-P=ca.positionScreen.x;W=ca.positionScreen.y;m.beginPath();m.moveTo(M,e);m.lineTo(ea,O);m.lineTo(P,W);m.lineTo(M,e);m.closePath();if(X instanceof THREE.MeshBasicMaterial)if(X.map)X.map.mapping instanceof THREE.UVMapping&&sa(M,e,ea,O,P,W,X.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(X.env_map){if(X.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=Ca.globalMatrix;F.copy(U.vertexNormalsWorld[0]);ia=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;ga=-(F.x*
-K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[1]);ua=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;xa=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[2]);l=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;y=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;sa(M,e,ea,O,P,W,X.env_map.image,ia,ga,ua,xa,l,y)}}else X.wireframe?Z(X.color.__styleString,X.wireframe_linewidth):$(X.color.__styleString);else if(X instanceof THREE.MeshLambertMaterial){if(X.map&&!X.wireframe){X.map.mapping instanceof
-THREE.UVMapping&&sa(M,e,ea,O,P,W,X.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!X.wireframe&&X.shading==THREE.SmoothShading&&U.vertexNormalsWorld.length==3){aa.r=ba.r=H.r=J.r;aa.g=ba.g=H.g=J.g;aa.b=ba.b=H.b=J.b;Ga(qa,U.v1.positionWorld,U.vertexNormalsWorld[0],aa);Ga(qa,U.v2.positionWorld,U.vertexNormalsWorld[1],ba);Ga(qa,U.v3.positionWorld,U.vertexNormalsWorld[2],H);V.r=(ba.r+H.r)*0.5;V.g=(ba.g+H.g)*0.5;V.b=(ba.b+H.b)*0.5;ka=Ja(aa,
-ba,H,V);sa(M,e,ea,O,P,W,ka,0,0,1,0,0,1)}else{C.r=J.r;C.g=J.g;C.b=J.b;Ga(qa,U.centroidWorld,U.normalWorld,C);S.r=X.color.r*C.r;S.g=X.color.g*C.g;S.b=X.color.b*C.b;S.updateStyleString();X.wireframe?Z(S.__styleString,X.wireframe_linewidth):$(S.__styleString)}else X.wireframe?Z(X.color.__styleString,X.wireframe_linewidth):$(X.color.__styleString)}else if(X instanceof THREE.MeshDepthMaterial){la=Ca.near;Y=Ca.far;aa.r=aa.g=aa.b=1-Aa(K.positionScreen.z,la,Y);ba.r=ba.g=ba.b=1-Aa(ja.positionScreen.z,la,Y);
-H.r=H.g=H.b=1-Aa(ca.positionScreen.z,la,Y);V.r=(ba.r+H.r)*0.5;V.g=(ba.g+H.g)*0.5;V.b=(ba.b+H.b)*0.5;ka=Ja(aa,ba,H,V);sa(M,e,ea,O,P,W,ka,0,0,1,0,0,1)}else if(X instanceof THREE.MeshNormalMaterial){S.r=N(U.normalWorld.x);S.g=N(U.normalWorld.y);S.b=N(U.normalWorld.z);S.updateStyleString();X.wireframe?Z(S.__styleString,X.wireframe_linewidth):$(S.__styleString)}}}function Z(K,ja){if(x!=K)m.strokeStyle=x=K;if(G!=ja)m.lineWidth=G=ja;m.stroke();u.inflate(ja*2)}function $(K){if(A!=K)m.fillStyle=A=K;m.fill()}
-function sa(K,ja,ca,U,X,qa,Da,Ea,Ia,Ma,Ka,Fa,Sa){var Na,Oa;Na=Da.width-1;Oa=Da.height-1;Ea*=Na;Ia*=Oa;Ma*=Na;Ka*=Oa;Fa*=Na;Sa*=Oa;ca-=K;U-=ja;X-=K;qa-=ja;Ma-=Ea;Ka-=Ia;Fa-=Ea;Sa-=Ia;Na=Ma*Sa-Fa*Ka;if(Na!=0){Oa=1/Na;Na=(Sa*ca-Ka*X)*Oa;Ka=(Sa*U-Ka*qa)*Oa;ca=(Ma*X-Fa*ca)*Oa;U=(Ma*qa-Fa*U)*Oa;K=K-Na*Ea-ca*Ia;ja=ja-Ka*Ea-U*Ia;m.save();m.transform(Na,Ka,ca,U,K,ja);m.clip();m.drawImage(Da,0,0);m.restore()}}function Ja(K,ja,ca,U){var X=~~(K.r*255),qa=~~(K.g*255);K=~~(K.b*255);var Da=~~(ja.r*255),Ea=~~(ja.g*
-255);ja=~~(ja.b*255);var Ia=~~(ca.r*255),Ma=~~(ca.g*255);ca=~~(ca.b*255);var Ka=~~(U.r*255),Fa=~~(U.g*255);U=~~(U.b*255);ma[0]=X<0?0:X>255?255:X;ma[1]=qa<0?0:qa>255?255:qa;ma[2]=K<0?0:K>255?255:K;ma[4]=Da<0?0:Da>255?255:Da;ma[5]=Ea<0?0:Ea>255?255:Ea;ma[6]=ja<0?0:ja>255?255:ja;ma[8]=Ia<0?0:Ia>255?255:Ia;ma[9]=Ma<0?0:Ma>255?255:Ma;ma[10]=ca<0?0:ca>255?255:ca;ma[12]=Ka<0?0:Ka>255?255:Ka;ma[13]=Fa<0?0:Fa>255?255:Fa;ma[14]=U<0?0:U>255?255:U;Q.putImageData(fa,0,0);oa.drawImage(T,0,0);return ra}function Aa(K,
-ja,ca){K=(K-ja)/(ca-ja);return K*K*(3-2*K)}function N(K){K=(K+1)*0.5;return K<0?0:K>1?1:K}function Ba(K,ja){var ca=ja.x-K.x,U=ja.y-K.y,X=1/Math.sqrt(ca*ca+U*U);ca*=X;U*=X;ja.x+=ca;ja.y+=U;K.x-=ca;K.y-=U}var Pa,Ta,ta,pa,za,wa,ya,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(ha,Ca,this.sortElements);(E=ha.lights.length>0)&&R(ha);Pa=0;for(Ta=c.length;Pa<Ta;Pa++){ta=c[Pa];u.empty();if(ta instanceof THREE.RenderableParticle){v=ta;v.x*=k;v.y*=j;pa=0;for(za=ta.materials.length;pa<
-za;pa++)Ha(v,ta,ta.materials[pa],ha)}else if(ta instanceof THREE.RenderableLine){v=ta.v1;I=ta.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;u.addPoint(v.positionScreen.x,v.positionScreen.y);u.addPoint(I.positionScreen.x,I.positionScreen.y);if(B.instersects(u)){pa=0;for(za=ta.materials.length;pa<za;)La(v,I,ta,ta.materials[pa++],ha)}}else if(ta instanceof THREE.RenderableFace3){v=ta.v1;I=ta.v2;o=ta.v3;v.positionScreen.x*=k;v.positionScreen.y*=j;I.positionScreen.x*=
-k;I.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(ta.overdraw){Ba(v.positionScreen,I.positionScreen);Ba(I.positionScreen,o.positionScreen);Ba(o.positionScreen,v.positionScreen)}u.add3Points(v.positionScreen.x,v.positionScreen.y,I.positionScreen.x,I.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(B.instersects(u)){pa=0;for(za=ta.meshMaterials.length;pa<za;){va=ta.meshMaterials[pa++];if(va instanceof THREE.MeshFaceMaterial){wa=0;for(ya=ta.faceMaterials.length;wa<ya;)(va=
-ta.faceMaterials[wa++])&&da(v,I,o,ta,va,ha)}else da(v,I,o,ta,va,ha)}}}t.addRectangle(u)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(ia,ga,ua){var xa,l,y,B;xa=0;for(l=ia.lights.length;xa<l;xa++){y=ia.lights[xa];if(y instanceof THREE.DirectionalLight){B=ga.normalWorld.dot(y.position)*y.intensity;if(B>0){ua.r+=y.color.r*B;ua.g+=y.color.g*B;ua.b+=y.color.b*B}}else if(y instanceof THREE.PointLight){W.sub(y.position,ga.centroidWorld);W.normalize();B=ga.normalWorld.dot(W)*y.intensity;if(B>0){ua.r+=y.color.r*B;ua.g+=y.color.g*B;ua.b+=y.color.b*B}}}}function b(ia,ga,ua,xa,l,y){H=d(V++);H.setAttribute("d",
-"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)o.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(y,xa,M);o.r=l.color.r*M.r;o.g=l.color.g*M.g;o.b=l.color.b*M.b;o.updateStyleString()}else o.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){P=1-l.__2near/(l.__farPlusNear-
-xa.z*l.__farMinusNear);o.setRGB(P,P,P)}else l instanceof THREE.MeshNormalMaterial&&o.setRGB(f(xa.normalWorld.x),f(xa.normalWorld.y),f(xa.normalWorld.z));l.wireframe?H.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+l.wireframe_linewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframe_linecap+"; stroke-linejoin: "+l.wireframe_linejoin):H.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+l.opacity);k.appendChild(H)}function c(ia,ga,ua,xa,
-l,y,B){H=d(V++);H.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)o.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(B,l,M);o.r=y.color.r*M.r;o.g=y.color.g*M.g;o.b=y.color.b*M.b;o.updateStyleString()}else o.__styleString=y.color.__styleString;
-else if(y instanceof THREE.MeshDepthMaterial){P=1-y.__2near/(y.__farPlusNear-l.z*y.__farMinusNear);o.setRGB(P,P,P)}else y instanceof THREE.MeshNormalMaterial&&o.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));y.wireframe?H.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):H.setAttribute("style","fill: "+o.__styleString+
-"; fill-opacity: "+y.opacity);k.appendChild(H)}function d(ia){if(S[ia]==null){S[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");ka==0&&S[ia].setAttribute("shape-rendering","crispEdges")}return S[ia]}function f(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,n,w,q,p,x,A,G=new THREE.Rectangle,v=new THREE.Rectangle,I=!1,o=new THREE.Color(16777215),M=new THREE.Color(16777215),
-e=new THREE.Color(0),ea=new THREE.Color(0),O=new THREE.Color(0),P,W=new THREE.Vector3,S=[],aa=[],ba=[],H,V,la,Y,ka=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":ka=1;break;case "low":ka=0}};this.setSize=function(ia,ga){j=ia;m=ga;n=j/2;w=m/2;k.setAttribute("viewBox",-n+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);G.set(-n,-w,n,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
-this.render=function(ia,ga){var ua,xa,l,y,B,t,u,E;this.autoClear&&this.clear();g=h.projectScene(ia,ga,this.sortElements);Y=la=V=0;if(I=ia.lights.length>0){u=ia.lights;e.setRGB(0,0,0);ea.setRGB(0,0,0);O.setRGB(0,0,0);ua=0;for(xa=u.length;ua<xa;ua++){l=u[ua];y=l.color;if(l instanceof THREE.AmbientLight){e.r+=y.r;e.g+=y.g;e.b+=y.b}else if(l instanceof THREE.DirectionalLight){ea.r+=y.r;ea.g+=y.g;ea.b+=y.b}else if(l instanceof THREE.PointLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}}}ua=0;for(xa=g.length;ua<xa;ua++){u=
-g[ua];v.empty();if(u instanceof THREE.RenderableParticle){q=u;q.x*=n;q.y*=-w;l=0;for(y=u.materials.length;l<y;l++)if(E=u.materials[l]){B=q;t=u;var C=la++;if(aa[C]==null){aa[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");ka==0&&aa[C].setAttribute("shape-rendering","crispEdges")}H=aa[C];H.setAttribute("cx",B.x);H.setAttribute("cy",B.y);H.setAttribute("r",t.scale.x*n);if(E instanceof THREE.ParticleCircleMaterial){if(I){M.r=e.r+ea.r+O.r;M.g=e.g+ea.g+O.g;M.b=e.b+ea.b+O.b;o.r=E.color.r*
-M.r;o.g=E.color.g*M.g;o.b=E.color.b*M.b;o.updateStyleString()}else o=E.color;H.setAttribute("style","fill: "+o.__styleString)}k.appendChild(H)}}else if(u instanceof THREE.RenderableLine){q=u.v1;p=u.v2;q.positionScreen.x*=n;q.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;v.addPoint(q.positionScreen.x,q.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);if(G.instersects(v)){l=0;for(y=u.materials.length;l<y;)if(E=u.materials[l++]){B=q;t=p;C=Y++;if(ba[C]==null){ba[C]=
-document.createElementNS("http://www.w3.org/2000/svg","line");ka==0&&ba[C].setAttribute("shape-rendering","crispEdges")}H=ba[C];H.setAttribute("x1",B.positionScreen.x);H.setAttribute("y1",B.positionScreen.y);H.setAttribute("x2",t.positionScreen.x);H.setAttribute("y2",t.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){o.__styleString=E.color.__styleString;H.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+
-E.linecap+"; stroke-linejoin: "+E.linejoin);k.appendChild(H)}}}}else if(u instanceof THREE.RenderableFace3){q=u.v1;p=u.v2;x=u.v3;q.positionScreen.x*=n;q.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;v.addPoint(q.positionScreen.x,q.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(v)){l=0;for(y=u.meshMaterials.length;l<y;){E=u.meshMaterials[l++];if(E instanceof
-THREE.MeshFaceMaterial){B=0;for(t=u.faceMaterials.length;B<t;)(E=u.faceMaterials[B++])&&b(q,p,x,u,E,ia)}else E&&b(q,p,x,u,E,ia)}}}else if(u instanceof THREE.RenderableFace4){q=u.v1;p=u.v2;x=u.v3;A=u.v4;q.positionScreen.x*=n;q.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;A.positionScreen.x*=n;A.positionScreen.y*=-w;v.addPoint(q.positionScreen.x,q.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,
-x.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(v)){l=0;for(y=u.meshMaterials.length;l<y;){E=u.meshMaterials[l++];if(E instanceof THREE.MeshFaceMaterial){B=0;for(t=u.faceMaterials.length;B<t;)(E=u.faceMaterials[B++])&&c(q,p,x,A,u,E,ia)}else E&&c(q,p,x,A,u,E,ia)}}}}}};
-THREE.WebGLRenderer=function(a){function b(l,y,B){var t,u,E,C=l.vertices,J=C.length,L=l.colors,z=L.length,D=l.__vertexArray,F=l.__colorArray,T=l.__sortArray,Q=l.__dirtyVertices,fa=l.__dirtyColors;if(B.sortParticles){V.multiplySelf(B.globalMatrix);for(t=0;t<J;t++){u=C[t].position;ia.copy(u);V.multiplyVector3(ia);T[t]=[ia.z,t]}T.sort(function(ma,ra){return ra[0]-ma[0]});for(t=0;t<J;t++){u=C[T[t][1]].position;E=t*3;D[E]=u.x;D[E+1]=u.y;D[E+2]=u.z}for(t=0;t<z;t++){E=t*3;color=L[T[t][1]];F[E]=color.r;F[E+
-1]=color.g;F[E+2]=color.b}}else{if(Q)for(t=0;t<J;t++){u=C[t].position;E=t*3;D[E]=u.x;D[E+1]=u.y;D[E+2]=u.z}if(fa)for(t=0;t<z;t++){color=L[t];E=t*3;F[E]=color.r;F[E+1]=color.g;F[E+2]=color.b}}if(Q||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,D,y)}if(fa||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,F,y)}}function c(l,y){l.fragment_shader=y.fragment_shader;l.vertex_shader=y.vertex_shader;l.uniforms=
-Uniforms.clone(y.uniforms)}function d(l,y,B,t,u){t.program||P.initMaterial(t,y,B);var E=t.program,C=E.uniforms,J=t.uniforms;if(E!=ea){e.useProgram(E);ea=E;e.uniformMatrix4fv(C.projectionMatrix,!1,la)}if(B&&(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial||t instanceof THREE.LineBasicMaterial||t instanceof THREE.ParticleBasicMaterial)){J.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){J.fogNear.value=B.near;J.fogFar.value=
-B.far}else if(B instanceof THREE.FogExp2)J.fogDensity.value=B.density}if(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial){var L,z,D=0,F=0,T=0,Q,fa,ma,ra=P.lights,oa=ra.directional.colors,na=ra.directional.positions,ha=ra.point.colors,Ca=ra.point.positions,R=0,Ga=0;B=z=z=0;for(L=y.length;B<L;B++){z=y[B];Q=z.color;fa=z.position;ma=z.intensity;if(z instanceof THREE.AmbientLight){D+=Q.r;F+=Q.g;T+=Q.b}else if(z instanceof THREE.DirectionalLight){z=R*3;oa[z]=Q.r*ma;oa[z+1]=
-Q.g*ma;oa[z+2]=Q.b*ma;na[z]=fa.x;na[z+1]=fa.y;na[z+2]=fa.z;R+=1}else if(z instanceof THREE.PointLight){z=Ga*3;ha[z]=Q.r*ma;ha[z+1]=Q.g*ma;ha[z+2]=Q.b*ma;Ca[z]=fa.x;Ca[z+1]=fa.y;Ca[z+2]=fa.z;Ga+=1}}for(B=R*3;B<oa.length;B++)oa[B]=0;for(B=Ga*3;B<ha.length;B++)ha[B]=0;ra.point.length=Ga;ra.directional.length=R;ra.ambient[0]=D;ra.ambient[1]=F;ra.ambient[2]=T;y=P.lights;J.enableLighting.value=y.directional.length+y.point.length;J.ambientLightColor.value=y.ambient;J.directionalLightColor.value=y.directional.colors;
-J.directionalLightDirection.value=y.directional.positions;J.pointLightColor.value=y.point.colors;J.pointLightPosition.value=y.point.positions}if(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial){J.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);J.opacity.value=t.opacity;J.map.texture=t.map;J.light_map.texture=t.light_map;J.env_map.texture=t.env_map;J.reflectivity.value=t.reflectivity;J.refraction_ratio.value=
-t.refraction_ratio;J.combine.value=t.combine;J.useRefract.value=t.env_map&&t.env_map.mapping instanceof THREE.CubeRefractionMapping}if(t instanceof THREE.LineBasicMaterial){J.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);J.opacity.value=t.opacity}else if(t instanceof THREE.ParticleBasicMaterial){J.psColor.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);J.opacity.value=t.opacity;J.size.value=t.size;J.map.texture=t.map}else if(t instanceof
-THREE.MeshPhongMaterial){J.ambient.value.setRGB(t.ambient.r,t.ambient.g,t.ambient.b);J.specular.value.setRGB(t.specular.r,t.specular.g,t.specular.b);J.shininess.value=t.shininess}else if(t instanceof THREE.MeshDepthMaterial){J.mNear.value=l.near;J.mFar.value=l.far;J.opacity.value=t.opacity}else if(t instanceof THREE.MeshNormalMaterial)J.opacity.value=t.opacity;for(var Ha in J)if(D=E.uniforms[Ha]){B=J[Ha];L=B.type;y=B.value;if(L=="i")e.uniform1i(D,y);else if(L=="f")e.uniform1f(D,y);else if(L=="fv1")e.uniform1fv(D,
+THREE.Projector=function(){function a(O,P){return P.z-O.z}function b(O,P){var V=0,S=1,Z=O.z+O.w,ea=P.z+P.w,J=-O.z+O.w,$=-P.z+P.w;if(Z>=0&&ea>=0&&J>=0&&$>=0)return!0;else if(Z<0&&ea<0||J<0&&$<0)return!1;else{if(Z<0)V=Math.max(V,Z/(Z-ea));else ea<0&&(S=Math.min(S,Z/(Z-ea)));if(J<0)V=Math.max(V,J/(J-$));else $<0&&(S=Math.min(S,J/(J-$)));if(S<V)return!1;else{O.lerpSelf(P,V);P.lerpSelf(O,1-S);return!0}}}var c,d,f=[],g,h,k,j=[],m,n,w=[],u,p,x=[],A=new THREE.Vector4,G=new THREE.Vector4,v=new THREE.Matrix4,
+H=new THREE.Matrix4,o=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,e=new THREE.Vector4,da;this.projectObjects=function(O,P,V){P=[];var S,Z,ea;d=0;Z=O.objects;O=0;for(S=Z.length;O<S;O++){ea=Z[O];var J;if(!(J=!ea.visible))if(J=ea instanceof THREE.Mesh){a:{J=void 0;for(var $=ea.globalMatrix,ta=-ea.geometry.boundingSphere.radius*Math.max(ea.scale.x,Math.max(ea.scale.y,ea.scale.z)),aa=0;aa<6;aa++){J=o[aa].x*$.n14+o[aa].y*
+$.n24+o[aa].z*$.n34+o[aa].w;if(J<=ta){J=!1;break a}}J=!0}J=!J}if(!J){c=f[d]=f[d]||new THREE.RenderableObject;A.copy(ea.position);v.multiplyVector3(A);c.object=ea;c.z=A.z;P.push(c);d++}}V&&P.sort(a);return P};this.projectScene=function(O,P,V){var S=[],Z=P.near,ea=P.far,J,$,ta,aa,la,ia,ga,ua,xa,l,y,B,q,t,E,C;k=n=p=0;P.matrixAutoUpdate&&P.update();v.multiply(P.projectionMatrix,P.globalMatrix);o[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);o[1].set(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,v.n44+
+v.n14);o[2].set(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);o[3].set(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);o[4].set(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);o[5].set(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);for(J=0;J<6;J++){ia=o[J];ia.divideScalar(Math.sqrt(ia.x*ia.x+ia.y*ia.y+ia.z*ia.z))}O.update(undefined,!1,P);ia=this.projectObjects(O,P,!0);O=0;for(J=ia.length;O<J;O++){ga=ia[O].object;if(ga.visible){ga.matrixAutoUpdate&&ga.updateMatrix();ua=ga.globalMatrix;y=ga.matrixRotation;
+xa=ga.materials;l=ga.overdraw;if(ga instanceof THREE.Mesh){B=ga.geometry;q=B.vertices;$=0;for(ta=q.length;$<ta;$++){t=q[$];t.positionWorld.copy(t.position);ua.multiplyVector3(t.positionWorld);aa=t.positionScreen;aa.copy(t.positionWorld);v.multiplyVector4(aa);aa.x/=aa.w;aa.y/=aa.w;t.__visible=aa.z>Z&&aa.z<ea}B=B.faces;$=0;for(ta=B.length;$<ta;$++){t=B[$];if(t instanceof THREE.Face3){aa=q[t.a];la=q[t.b];E=q[t.c];if(aa.__visible&&la.__visible&&E.__visible&&(ga.doubleSided||ga.flipSided!=(E.positionScreen.x-
+aa.positionScreen.x)*(la.positionScreen.y-aa.positionScreen.y)-(E.positionScreen.y-aa.positionScreen.y)*(la.positionScreen.x-aa.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(aa.positionWorld);g.v2.positionWorld.copy(la.positionWorld);g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(aa.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(t.normal);y.multiplyVector3(g.normalWorld);
+g.centroidWorld.copy(t.centroid);ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);E=t.vertexNormals;da=g.vertexNormalsWorld;aa=0;for(la=E.length;aa<la;aa++){C=da[aa]=da[aa]||new THREE.Vector3;C.copy(E[aa]);y.multiplyVector3(C)}g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=t.materials;g.overdraw=l;if(ga.geometry.uvs[$]){g.uvs[0]=ga.geometry.uvs[$][0];g.uvs[1]=ga.geometry.uvs[$][1];g.uvs[2]=ga.geometry.uvs[$][2]}S.push(g);k++}}else if(t instanceof
+THREE.Face4){aa=q[t.a];la=q[t.b];E=q[t.c];C=q[t.d];if(aa.__visible&&la.__visible&&E.__visible&&C.__visible&&(ga.doubleSided||ga.flipSided!=((C.positionScreen.x-aa.positionScreen.x)*(la.positionScreen.y-aa.positionScreen.y)-(C.positionScreen.y-aa.positionScreen.y)*(la.positionScreen.x-aa.positionScreen.x)<0||(la.positionScreen.x-E.positionScreen.x)*(C.positionScreen.y-E.positionScreen.y)-(la.positionScreen.y-E.positionScreen.y)*(C.positionScreen.x-E.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;
+g.v1.positionWorld.copy(aa.positionWorld);g.v2.positionWorld.copy(la.positionWorld);g.v3.positionWorld.copy(C.positionWorld);g.v1.positionScreen.copy(aa.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(C.positionScreen);g.normalWorld.copy(t.normal);y.multiplyVector3(g.normalWorld);g.centroidWorld.copy(t.centroid);ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=
+xa;g.faceMaterials=t.materials;g.overdraw=l;if(ga.geometry.uvs[$]){g.uvs[0]=ga.geometry.uvs[$][0];g.uvs[1]=ga.geometry.uvs[$][1];g.uvs[2]=ga.geometry.uvs[$][3]}S.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(la.positionWorld);h.v2.positionWorld.copy(E.positionWorld);h.v3.positionWorld.copy(C.positionWorld);h.v1.positionScreen.copy(la.positionScreen);h.v2.positionScreen.copy(E.positionScreen);h.v3.positionScreen.copy(C.positionScreen);h.normalWorld.copy(g.normalWorld);
+h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=xa;h.faceMaterials=t.materials;h.overdraw=l;if(ga.geometry.uvs[$]){h.uvs[0]=ga.geometry.uvs[$][1];h.uvs[1]=ga.geometry.uvs[$][2];h.uvs[2]=ga.geometry.uvs[$][3]}S.push(h);k++}}}}else if(ga instanceof THREE.Line){H.multiply(v,ua);q=ga.geometry.vertices;t=q[0];t.positionScreen.copy(t.position);H.multiplyVector4(t.positionScreen);$=1;for(ta=q.length;$<ta;$++){aa=q[$];aa.positionScreen.copy(aa.position);
+H.multiplyVector4(aa.positionScreen);la=q[$-1];M.copy(aa.positionScreen);e.copy(la.positionScreen);if(b(M,e)){M.multiplyScalar(1/M.w);e.multiplyScalar(1/e.w);m=w[n]=w[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(M);m.v2.positionScreen.copy(e);m.z=Math.max(M.z,e.z);m.materials=ga.materials;S.push(m);n++}}}else if(ga instanceof THREE.Particle){G.set(ga.position.x,ga.position.y,ga.position.z,1);v.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){u=x[p]=x[p]||new THREE.RenderableParticle;u.x=G.x/
+G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=ga.rotation.z;u.scale.x=ga.scale.x*Math.abs(u.x-(G.x+P.projectionMatrix.n11)/(G.w+P.projectionMatrix.n14));u.scale.y=ga.scale.y*Math.abs(u.y-(G.y+P.projectionMatrix.n22)/(G.w+P.projectionMatrix.n24));u.materials=ga.materials;S.push(u);p++}}}}V&&S.sort(a);return S};this.unprojectVector=function(O,P){var V=THREE.Matrix4.makeInvert(P.globalMatrix);V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(O);return O}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,n,w,u,p,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){u=a[j];if(u instanceof THREE.RenderableParticle){x=u.x*f+f;A=u.y*g+g;n=0;for(w=u.material.length;n<w;n++){p=u.material[n];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=x+"px";p.style.top=A+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ha){if(u!=ha)m.globalAlpha=u=ha}function b(ha){if(p!=ha){switch(ha){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ha}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,m=f.getContext("2d"),n=new THREE.Color(0),w=0,u=1,p=0,x=null,A=null,G=1,v,H,o,M,e,da,O,P,V,S=new THREE.Color,
+Z=new THREE.Color,ea=new THREE.Color,J=new THREE.Color,$=new THREE.Color,ta,aa,la,ia,ga,ua,xa,l,y,B=new THREE.Rectangle,q=new THREE.Rectangle,t=new THREE.Rectangle,E=!1,C=new THREE.Color,I=new THREE.Color,L=new THREE.Color,z=new THREE.Color,D=Math.PI*2,F=new THREE.Vector3,T,Q,fa,ka,qa,na,ma=16;T=document.createElement("canvas");T.width=T.height=2;Q=T.getContext("2d");Q.fillStyle="rgba(0,0,0,1)";Q.fillRect(0,0,2,2);fa=Q.getImageData(0,0,2,2);ka=fa.data;qa=document.createElement("canvas");qa.width=
+qa.height=ma;na=qa.getContext("2d");na.translate(-ma/2,-ma/2);na.scale(ma,ma);ma--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ha,Ca){g=ha;h=Ca;k=g/2;j=h/2;f.width=g;f.height=h;B.set(-k,-j,k,j);u=1;p=0;A=x=null;G=1};this.setClearColor=function(ha,Ca){n=ha;w=Ca;q.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(ha,Ca){n.setHex(ha);w=Ca;q.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=
+function(){m.setTransform(1,0,0,-1,k,j);if(!q.isEmpty()){q.inflate(1);q.minSelf(B);if(n.hex==0&&w==0)m.clearRect(q.getX(),q.getY(),q.getWidth(),q.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+w+")";m.fillRect(q.getX(),q.getY(),q.getWidth(),q.getHeight())}q.empty()}};this.render=function(ha,Ca){function R(K){var ja,ba,U,W=K.lights;I.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);K=0;for(ja=W.length;K<ja;K++){ba=
+W[K];U=ba.color;if(ba instanceof THREE.AmbientLight){I.r+=U.r;I.g+=U.g;I.b+=U.b}else if(ba instanceof THREE.DirectionalLight){L.r+=U.r;L.g+=U.g;L.b+=U.b}else if(ba instanceof THREE.PointLight){z.r+=U.r;z.g+=U.g;z.b+=U.b}}}function Ga(K,ja,ba,U){var W,pa,Da,Ea,Ia=K.lights;K=0;for(W=Ia.length;K<W;K++){pa=Ia[K];Da=pa.color;Ea=pa.intensity;if(pa instanceof THREE.DirectionalLight){pa=ba.dot(pa.position)*Ea;if(pa>0){U.r+=Da.r*pa;U.g+=Da.g*pa;U.b+=Da.b*pa}}else if(pa instanceof THREE.PointLight){F.sub(pa.position,
+ja);F.normalize();pa=ba.dot(F)*Ea;if(pa>0){U.r+=Da.r*pa;U.g+=Da.g*pa;U.b+=Da.b*pa}}}}function Ha(K,ja,ba){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);var U,W,pa,Da,Ea,Ia;if(ba instanceof THREE.ParticleBasicMaterial){if(ba.map){Da=ba.map.image;Ea=Da.width>>1;Ia=Da.height>>1;W=ja.scale.x*k;pa=ja.scale.y*j;ba=W*Ea;U=pa*Ia;t.set(K.x-ba,K.y-U,K.x+ba,K.y+U);if(B.instersects(t)){m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(W,-pa);m.translate(-Ea,-Ia);m.drawImage(Da,0,0);m.restore()}}}else if(ba instanceof
+THREE.ParticleCircleMaterial){if(E){C.r=I.r+L.r+z.r;C.g=I.g+L.g+z.g;C.b=I.b+L.b+z.b;S.r=ba.color.r*C.r;S.g=ba.color.g*C.g;S.b=ba.color.b*C.b;S.updateStyleString()}else S.__styleString=ba.color.__styleString;ba=ja.scale.x*k;U=ja.scale.y*j;t.set(K.x-ba,K.y-U,K.x+ba,K.y+U);if(B.instersects(t)){W=S.__styleString;if(A!=W)m.fillStyle=A=W;m.save();m.translate(K.x,K.y);m.rotate(-ja.rotation);m.scale(ba,U);m.beginPath();m.arc(0,0,1,0,D,!0);m.closePath();m.fill();m.restore()}}}}function La(K,ja,ba,U){if(U.opacity!=
+0){a(U.opacity);b(U.blending);m.beginPath();m.moveTo(K.positionScreen.x,K.positionScreen.y);m.lineTo(ja.positionScreen.x,ja.positionScreen.y);m.closePath();if(U instanceof THREE.LineBasicMaterial){S.__styleString=U.color.__styleString;K=U.linewidth;if(G!=K)m.lineWidth=G=K;K=S.__styleString;if(x!=K)m.strokeStyle=x=K;m.stroke();t.inflate(U.linewidth*2)}}}function ca(K,ja,ba,U,W,pa){if(W.opacity!=0){a(W.opacity);b(W.blending);M=K.positionScreen.x;e=K.positionScreen.y;da=ja.positionScreen.x;O=ja.positionScreen.y;
+P=ba.positionScreen.x;V=ba.positionScreen.y;m.beginPath();m.moveTo(M,e);m.lineTo(da,O);m.lineTo(P,V);m.lineTo(M,e);m.closePath();if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.mapping instanceof THREE.UVMapping&&ra(M,e,da,O,P,V,W.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(W.env_map){if(W.env_map.mapping instanceof THREE.SphericalReflectionMapping){K=Ca.globalMatrix;F.copy(U.vertexNormalsWorld[0]);ia=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;ga=-(F.x*
+K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[1]);ua=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;xa=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;F.copy(U.vertexNormalsWorld[2]);l=(F.x*K.n11+F.y*K.n12+F.z*K.n13)*0.5+0.5;y=-(F.x*K.n21+F.y*K.n22+F.z*K.n23)*0.5+0.5;ra(M,e,da,O,P,V,W.env_map.image,ia,ga,ua,xa,l,y)}}else W.wireframe?X(W.color.__styleString,W.wireframe_linewidth):Y(W.color.__styleString);else if(W instanceof THREE.MeshLambertMaterial){if(W.map&&!W.wireframe){W.map.mapping instanceof
+THREE.UVMapping&&ra(M,e,da,O,P,V,W.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!W.wireframe&&W.shading==THREE.SmoothShading&&U.vertexNormalsWorld.length==3){Z.r=ea.r=J.r=I.r;Z.g=ea.g=J.g=I.g;Z.b=ea.b=J.b=I.b;Ga(pa,U.v1.positionWorld,U.vertexNormalsWorld[0],Z);Ga(pa,U.v2.positionWorld,U.vertexNormalsWorld[1],ea);Ga(pa,U.v3.positionWorld,U.vertexNormalsWorld[2],J);$.r=(ea.r+J.r)*0.5;$.g=(ea.g+J.g)*0.5;$.b=(ea.b+J.b)*0.5;la=Ja(Z,ea,
+J,$);ra(M,e,da,O,P,V,la,0,0,1,0,0,1)}else{C.r=I.r;C.g=I.g;C.b=I.b;Ga(pa,U.centroidWorld,U.normalWorld,C);S.r=W.color.r*C.r;S.g=W.color.g*C.g;S.b=W.color.b*C.b;S.updateStyleString();W.wireframe?X(S.__styleString,W.wireframe_linewidth):Y(S.__styleString)}else W.wireframe?X(W.color.__styleString,W.wireframe_linewidth):Y(W.color.__styleString)}else if(W instanceof THREE.MeshDepthMaterial){ta=Ca.near;aa=Ca.far;Z.r=Z.g=Z.b=1-Aa(K.positionScreen.z,ta,aa);ea.r=ea.g=ea.b=1-Aa(ja.positionScreen.z,ta,aa);J.r=
+J.g=J.b=1-Aa(ba.positionScreen.z,ta,aa);$.r=(ea.r+J.r)*0.5;$.g=(ea.g+J.g)*0.5;$.b=(ea.b+J.b)*0.5;la=Ja(Z,ea,J,$);ra(M,e,da,O,P,V,la,0,0,1,0,0,1)}else if(W instanceof THREE.MeshNormalMaterial){S.r=N(U.normalWorld.x);S.g=N(U.normalWorld.y);S.b=N(U.normalWorld.z);S.updateStyleString();W.wireframe?X(S.__styleString,W.wireframe_linewidth):Y(S.__styleString)}}}function X(K,ja){if(x!=K)m.strokeStyle=x=K;if(G!=ja)m.lineWidth=G=ja;m.stroke();t.inflate(ja*2)}function Y(K){if(A!=K)m.fillStyle=A=K;m.fill()}function ra(K,
+ja,ba,U,W,pa,Da,Ea,Ia,Ma,Ka,Fa,Sa){var Na,Oa;Na=Da.width-1;Oa=Da.height-1;Ea*=Na;Ia*=Oa;Ma*=Na;Ka*=Oa;Fa*=Na;Sa*=Oa;ba-=K;U-=ja;W-=K;pa-=ja;Ma-=Ea;Ka-=Ia;Fa-=Ea;Sa-=Ia;Na=Ma*Sa-Fa*Ka;if(Na!=0){Oa=1/Na;Na=(Sa*ba-Ka*W)*Oa;Ka=(Sa*U-Ka*pa)*Oa;ba=(Ma*W-Fa*ba)*Oa;U=(Ma*pa-Fa*U)*Oa;K=K-Na*Ea-ba*Ia;ja=ja-Ka*Ea-U*Ia;m.save();m.transform(Na,Ka,ba,U,K,ja);m.clip();m.drawImage(Da,0,0);m.restore()}}function Ja(K,ja,ba,U){var W=~~(K.r*255),pa=~~(K.g*255);K=~~(K.b*255);var Da=~~(ja.r*255),Ea=~~(ja.g*255);ja=~~(ja.b*
+255);var Ia=~~(ba.r*255),Ma=~~(ba.g*255);ba=~~(ba.b*255);var Ka=~~(U.r*255),Fa=~~(U.g*255);U=~~(U.b*255);ka[0]=W<0?0:W>255?255:W;ka[1]=pa<0?0:pa>255?255:pa;ka[2]=K<0?0:K>255?255:K;ka[4]=Da<0?0:Da>255?255:Da;ka[5]=Ea<0?0:Ea>255?255:Ea;ka[6]=ja<0?0:ja>255?255:ja;ka[8]=Ia<0?0:Ia>255?255:Ia;ka[9]=Ma<0?0:Ma>255?255:Ma;ka[10]=ba<0?0:ba>255?255:ba;ka[12]=Ka<0?0:Ka>255?255:Ka;ka[13]=Fa<0?0:Fa>255?255:Fa;ka[14]=U<0?0:U>255?255:U;Q.putImageData(fa,0,0);na.drawImage(T,0,0);return qa}function Aa(K,ja,ba){K=(K-
+ja)/(ba-ja);return K*K*(3-2*K)}function N(K){K=(K+1)*0.5;return K<0?0:K>1?1:K}function Ba(K,ja){var ba=ja.x-K.x,U=ja.y-K.y,W=1/Math.sqrt(ba*ba+U*U);ba*=W;U*=W;ja.x+=ba;ja.y+=U;K.x-=ba;K.y-=U}var Pa,Ta,sa,oa,za,wa,ya,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(ha,Ca,this.sortElements);(E=ha.lights.length>0)&&R(ha);Pa=0;for(Ta=c.length;Pa<Ta;Pa++){sa=c[Pa];t.empty();if(sa instanceof THREE.RenderableParticle){v=sa;v.x*=k;v.y*=j;oa=0;for(za=sa.materials.length;oa<za;oa++)Ha(v,
+sa,sa.materials[oa],ha)}else if(sa instanceof THREE.RenderableLine){v=sa.v1;H=sa.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;H.positionScreen.x*=k;H.positionScreen.y*=j;t.addPoint(v.positionScreen.x,v.positionScreen.y);t.addPoint(H.positionScreen.x,H.positionScreen.y);if(B.instersects(t)){oa=0;for(za=sa.materials.length;oa<za;)La(v,H,sa,sa.materials[oa++],ha)}}else if(sa instanceof THREE.RenderableFace3){v=sa.v1;H=sa.v2;o=sa.v3;v.positionScreen.x*=k;v.positionScreen.y*=j;H.positionScreen.x*=k;
+H.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(sa.overdraw){Ba(v.positionScreen,H.positionScreen);Ba(H.positionScreen,o.positionScreen);Ba(o.positionScreen,v.positionScreen)}t.add3Points(v.positionScreen.x,v.positionScreen.y,H.positionScreen.x,H.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(B.instersects(t)){oa=0;for(za=sa.meshMaterials.length;oa<za;){va=sa.meshMaterials[oa++];if(va instanceof THREE.MeshFaceMaterial){wa=0;for(ya=sa.faceMaterials.length;wa<ya;)(va=
+sa.faceMaterials[wa++])&&ca(v,H,o,sa,va,ha)}else ca(v,H,o,sa,va,ha)}}}q.addRectangle(t)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ia,ga,ua){var xa,l,y,B;xa=0;for(l=ia.lights.length;xa<l;xa++){y=ia.lights[xa];if(y instanceof THREE.DirectionalLight){B=ga.normalWorld.dot(y.position)*y.intensity;if(B>0){ua.r+=y.color.r*B;ua.g+=y.color.g*B;ua.b+=y.color.b*B}}else if(y instanceof THREE.PointLight){V.sub(y.position,ga.centroidWorld);V.normalize();B=ga.normalWorld.dot(V)*y.intensity;if(B>0){ua.r+=y.color.r*B;ua.g+=y.color.g*B;ua.b+=y.color.b*B}}}}function b(ia,ga,ua,xa,l,y){J=d($++);J.setAttribute("d",
+"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)o.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(H){M.r=e.r;M.g=e.g;M.b=e.b;a(y,xa,M);o.r=l.color.r*M.r;o.g=l.color.g*M.g;o.b=l.color.b*M.b;o.updateStyleString()}else o.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){P=1-l.__2near/(l.__farPlusNear-
+xa.z*l.__farMinusNear);o.setRGB(P,P,P)}else l instanceof THREE.MeshNormalMaterial&&o.setRGB(f(xa.normalWorld.x),f(xa.normalWorld.y),f(xa.normalWorld.z));l.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+l.wireframe_linewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframe_linecap+"; stroke-linejoin: "+l.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+l.opacity);k.appendChild(J)}function c(ia,ga,ua,xa,
+l,y,B){J=d($++);J.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)o.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(H){M.r=e.r;M.g=e.g;M.b=e.b;a(B,l,M);o.r=y.color.r*M.r;o.g=y.color.g*M.g;o.b=y.color.b*M.b;o.updateStyleString()}else o.__styleString=y.color.__styleString;
+else if(y instanceof THREE.MeshDepthMaterial){P=1-y.__2near/(y.__farPlusNear-l.z*y.__farMinusNear);o.setRGB(P,P,P)}else y instanceof THREE.MeshNormalMaterial&&o.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));y.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+
+"; fill-opacity: "+y.opacity);k.appendChild(J)}function d(ia){if(S[ia]==null){S[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");la==0&&S[ia].setAttribute("shape-rendering","crispEdges")}return S[ia]}function f(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,n,w,u,p,x,A,G=new THREE.Rectangle,v=new THREE.Rectangle,H=!1,o=new THREE.Color(16777215),M=new THREE.Color(16777215),
+e=new THREE.Color(0),da=new THREE.Color(0),O=new THREE.Color(0),P,V=new THREE.Vector3,S=[],Z=[],ea=[],J,$,ta,aa,la=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":la=1;break;case "low":la=0}};this.setSize=function(ia,ga){j=ia;m=ga;n=j/2;w=m/2;k.setAttribute("viewBox",-n+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);G.set(-n,-w,n,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
+this.render=function(ia,ga){var ua,xa,l,y,B,q,t,E;this.autoClear&&this.clear();g=h.projectScene(ia,ga,this.sortElements);aa=ta=$=0;if(H=ia.lights.length>0){t=ia.lights;e.setRGB(0,0,0);da.setRGB(0,0,0);O.setRGB(0,0,0);ua=0;for(xa=t.length;ua<xa;ua++){l=t[ua];y=l.color;if(l instanceof THREE.AmbientLight){e.r+=y.r;e.g+=y.g;e.b+=y.b}else if(l instanceof THREE.DirectionalLight){da.r+=y.r;da.g+=y.g;da.b+=y.b}else if(l instanceof THREE.PointLight){O.r+=y.r;O.g+=y.g;O.b+=y.b}}}ua=0;for(xa=g.length;ua<xa;ua++){t=
+g[ua];v.empty();if(t instanceof THREE.RenderableParticle){u=t;u.x*=n;u.y*=-w;l=0;for(y=t.materials.length;l<y;l++)if(E=t.materials[l]){B=u;q=t;var C=ta++;if(Z[C]==null){Z[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");la==0&&Z[C].setAttribute("shape-rendering","crispEdges")}J=Z[C];J.setAttribute("cx",B.x);J.setAttribute("cy",B.y);J.setAttribute("r",q.scale.x*n);if(E instanceof THREE.ParticleCircleMaterial){if(H){M.r=e.r+da.r+O.r;M.g=e.g+da.g+O.g;M.b=e.b+da.b+O.b;o.r=E.color.r*
+M.r;o.g=E.color.g*M.g;o.b=E.color.b*M.b;o.updateStyleString()}else o=E.color;J.setAttribute("style","fill: "+o.__styleString)}k.appendChild(J)}}else if(t instanceof THREE.RenderableLine){u=t.v1;p=t.v2;u.positionScreen.x*=n;u.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);if(G.instersects(v)){l=0;for(y=t.materials.length;l<y;)if(E=t.materials[l++]){B=u;q=p;C=aa++;if(ea[C]==null){ea[C]=
+document.createElementNS("http://www.w3.org/2000/svg","line");la==0&&ea[C].setAttribute("shape-rendering","crispEdges")}J=ea[C];J.setAttribute("x1",B.positionScreen.x);J.setAttribute("y1",B.positionScreen.y);J.setAttribute("x2",q.positionScreen.x);J.setAttribute("y2",q.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){o.__styleString=E.color.__styleString;J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+
+E.linecap+"; stroke-linejoin: "+E.linejoin);k.appendChild(J)}}}}else if(t instanceof THREE.RenderableFace3){u=t.v1;p=t.v2;x=t.v3;u.positionScreen.x*=n;u.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(G.instersects(v)){l=0;for(y=t.meshMaterials.length;l<y;){E=t.meshMaterials[l++];if(E instanceof
+THREE.MeshFaceMaterial){B=0;for(q=t.faceMaterials.length;B<q;)(E=t.faceMaterials[B++])&&b(u,p,x,t,E,ia)}else E&&b(u,p,x,t,E,ia)}}}else if(t instanceof THREE.RenderableFace4){u=t.v1;p=t.v2;x=t.v3;A=t.v4;u.positionScreen.x*=n;u.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;A.positionScreen.x*=n;A.positionScreen.y*=-w;v.addPoint(u.positionScreen.x,u.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,
+x.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(v)){l=0;for(y=t.meshMaterials.length;l<y;){E=t.meshMaterials[l++];if(E instanceof THREE.MeshFaceMaterial){B=0;for(q=t.faceMaterials.length;B<q;)(E=t.faceMaterials[B++])&&c(u,p,x,A,t,E,ia)}else E&&c(u,p,x,A,t,E,ia)}}}}}};
+THREE.WebGLRenderer=function(a){function b(l,y,B){var q,t,E,C=l.vertices,I=C.length,L=l.colors,z=L.length,D=l.__vertexArray,F=l.__colorArray,T=l.__sortArray,Q=l.__dirtyVertices,fa=l.__dirtyColors;if(B.sortParticles){$.multiplySelf(B.globalMatrix);for(q=0;q<I;q++){t=C[q].position;ia.copy(t);$.multiplyVector3(ia);T[q]=[ia.z,q]}T.sort(function(ka,qa){return qa[0]-ka[0]});for(q=0;q<I;q++){t=C[T[q][1]].position;E=q*3;D[E]=t.x;D[E+1]=t.y;D[E+2]=t.z}for(q=0;q<z;q++){E=q*3;color=L[T[q][1]];F[E]=color.r;F[E+
+1]=color.g;F[E+2]=color.b}}else{if(Q)for(q=0;q<I;q++){t=C[q].position;E=q*3;D[E]=t.x;D[E+1]=t.y;D[E+2]=t.z}if(fa)for(q=0;q<z;q++){color=L[q];E=q*3;F[E]=color.r;F[E+1]=color.g;F[E+2]=color.b}}if(Q||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,D,y)}if(fa||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,F,y)}}function c(l,y){l.fragment_shader=y.fragment_shader;l.vertex_shader=y.vertex_shader;l.uniforms=
+Uniforms.clone(y.uniforms)}function d(l,y,B,q,t){q.program||P.initMaterial(q,y,B);var E=q.program,C=E.uniforms,I=q.uniforms;if(E!=da){e.useProgram(E);da=E;e.uniformMatrix4fv(C.projectionMatrix,!1,ta)}if(B&&(q instanceof THREE.MeshBasicMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshPhongMaterial||q instanceof THREE.LineBasicMaterial||q instanceof THREE.ParticleBasicMaterial)){I.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){I.fogNear.value=B.near;I.fogFar.value=
+B.far}else if(B instanceof THREE.FogExp2)I.fogDensity.value=B.density}if(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial){var L,z,D=0,F=0,T=0,Q,fa,ka,qa=P.lights,na=qa.directional.colors,ma=qa.directional.positions,ha=qa.point.colors,Ca=qa.point.positions,R=0,Ga=0;B=z=z=0;for(L=y.length;B<L;B++){z=y[B];Q=z.color;fa=z.position;ka=z.intensity;if(z instanceof THREE.AmbientLight){D+=Q.r;F+=Q.g;T+=Q.b}else if(z instanceof THREE.DirectionalLight){z=R*3;na[z]=Q.r*ka;na[z+1]=
+Q.g*ka;na[z+2]=Q.b*ka;ma[z]=fa.x;ma[z+1]=fa.y;ma[z+2]=fa.z;R+=1}else if(z instanceof THREE.PointLight){z=Ga*3;ha[z]=Q.r*ka;ha[z+1]=Q.g*ka;ha[z+2]=Q.b*ka;Ca[z]=fa.x;Ca[z+1]=fa.y;Ca[z+2]=fa.z;Ga+=1}}for(B=R*3;B<na.length;B++)na[B]=0;for(B=Ga*3;B<ha.length;B++)ha[B]=0;qa.point.length=Ga;qa.directional.length=R;qa.ambient[0]=D;qa.ambient[1]=F;qa.ambient[2]=T;y=P.lights;I.enableLighting.value=y.directional.length+y.point.length;I.ambientLightColor.value=y.ambient;I.directionalLightColor.value=y.directional.colors;
+I.directionalLightDirection.value=y.directional.positions;I.pointLightColor.value=y.point.colors;I.pointLightPosition.value=y.point.positions}if(q instanceof THREE.MeshBasicMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshPhongMaterial){I.diffuse.value.setRGB(q.color.r*q.opacity,q.color.g*q.opacity,q.color.b*q.opacity);I.opacity.value=q.opacity;I.map.texture=q.map;I.light_map.texture=q.light_map;I.env_map.texture=q.env_map;I.reflectivity.value=q.reflectivity;I.refraction_ratio.value=
+q.refraction_ratio;I.combine.value=q.combine;I.useRefract.value=q.env_map&&q.env_map.mapping instanceof THREE.CubeRefractionMapping}if(q instanceof THREE.LineBasicMaterial){I.diffuse.value.setRGB(q.color.r*q.opacity,q.color.g*q.opacity,q.color.b*q.opacity);I.opacity.value=q.opacity}else if(q instanceof THREE.ParticleBasicMaterial){I.psColor.value.setRGB(q.color.r*q.opacity,q.color.g*q.opacity,q.color.b*q.opacity);I.opacity.value=q.opacity;I.size.value=q.size;I.map.texture=q.map}else if(q instanceof
+THREE.MeshPhongMaterial){I.ambient.value.setRGB(q.ambient.r,q.ambient.g,q.ambient.b);I.specular.value.setRGB(q.specular.r,q.specular.g,q.specular.b);I.shininess.value=q.shininess}else if(q instanceof THREE.MeshDepthMaterial){I.mNear.value=l.near;I.mFar.value=l.far;I.opacity.value=q.opacity}else if(q instanceof THREE.MeshNormalMaterial)I.opacity.value=q.opacity;for(var Ha in I)if(D=E.uniforms[Ha]){B=I[Ha];L=B.type;y=B.value;if(L=="i")e.uniform1i(D,y);else if(L=="f")e.uniform1f(D,y);else if(L=="fv1")e.uniform1fv(D,
 y);else if(L=="fv")e.uniform3fv(D,y);else if(L=="v2")e.uniform2f(D,y.x,y.y);else if(L=="v3")e.uniform3f(D,y.x,y.y,y.z);else if(L=="c")e.uniform3f(D,y.r,y.g,y.b);else if(L=="t"){e.uniform1i(D,y);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(B.needsUpdate){if(!B.image.__webGLTextureCube)B.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);
 y);else if(L=="fv")e.uniform3fv(D,y);else if(L=="v2")e.uniform2f(D,y.x,y.y);else if(L=="v3")e.uniform3f(D,y.x,y.y,y.z);else if(L=="c")e.uniform3f(D,y.r,y.g,y.b);else if(L=="t"){e.uniform1i(D,y);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(B.needsUpdate){if(!B.image.__webGLTextureCube)B.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);
 e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(L=0;L<6;++L)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+L,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image[L]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+y);e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{if(B.needsUpdate){if(B.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
 e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(L=0;L<6;++L)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+L,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image[L]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+y);e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{if(B.needsUpdate){if(B.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
 B.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(B.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(B.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(B.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(B.min_filter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}else{B.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);e.texImage2D(e.TEXTURE_2D,
 B.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(B.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(B.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(B.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(B.min_filter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}else{B.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);e.texImage2D(e.TEXTURE_2D,
 0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(B.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(B.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(B.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(B.min_filter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null);B.__wasSetOnce=!0}B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+y);e.bindTexture(e.TEXTURE_2D,B.__webGLTexture)}}}e.uniformMatrix4fv(C.modelViewMatrix,
 0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(B.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(B.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(B.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(B.min_filter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null);B.__wasSetOnce=!0}B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+y);e.bindTexture(e.TEXTURE_2D,B.__webGLTexture)}}}e.uniformMatrix4fv(C.modelViewMatrix,
-!1,u._modelViewMatrixArray);e.uniformMatrix3fv(C.normalMatrix,!1,u._normalMatrixArray);(t instanceof THREE.MeshShaderMaterial||t instanceof THREE.MeshPhongMaterial||t.env_map)&&e.uniform3f(C.cameraPosition,l.position.x,l.position.y,l.position.z);(t instanceof THREE.MeshShaderMaterial||t.env_map||t.skinning)&&e.uniformMatrix4fv(C.objectMatrix,!1,u._objectMatrixArray);(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshShaderMaterial||t.skinning)&&e.uniformMatrix4fv(C.viewMatrix,
-!1,ka);if(t.skinning){e.uniformMatrix4fv(C.cameraInverseMatrix,!1,Y);e.uniformMatrix4fv(C.boneGlobalMatrices,!1,u.boneMatrices)}return E}function f(l,y,B,t,u,E){l=d(l,y,B,t,E).attributes;e.bindBuffer(e.ARRAY_BUFFER,u.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,3,
-e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(u.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(u.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);
-if(t.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,u.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,u.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,u.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,u.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,
-4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(t.wireframe){e.lineWidth(t.wireframe_linewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);e.drawElements(e.LINES,u.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,u.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(t.linewidth);e.drawArrays(E,0,u.__webGLLineCount)}else if(E instanceof
-THREE.ParticleSystem)e.drawArrays(e.POINTS,0,u.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,u.__webGLVertexCount)}function g(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.position);e.vertexAttribPointer(y.attributes.position,
-3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.normal);e.vertexAttribPointer(y.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(W!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);W=l.doubleSided}if(S!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);S=l.flipSided}}function k(l){if(ba!=
-l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ba=l}}function j(l){H[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);H[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);H[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);H[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);H[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);H[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<6;l++){y=H[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}
-function m(l){for(var y=l.globalMatrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),t=0;t<6;t++){l=H[t].x*y.n14+H[t].y*y.n24+H[t].z*y.n34+H[t].w;if(l<=B)return!1}return!0}function n(l,y){l.list[l.count]=y;l.count+=1}function w(l){var y,B,t=l.object,u=l.opaque,E=l.transparent;E.count=0;l=u.count=0;for(y=t.materials.length;l<y;l++){B=t.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?n(E,B):n(u,B)}}function q(l){var y,B,t,u,E=l.object,C=
-l.buffer,J=l.opaque,L=l.transparent;L.count=0;l=J.count=0;for(t=E.materials.length;l<t;l++){y=E.materials[l];if(y instanceof THREE.MeshFaceMaterial){y=0;for(B=C.materials.length;y<B;y++)(u=C.materials[y])&&(u.opacity&&u.opacity<1||u.blending!=THREE.NormalBlending?n(L,u):n(J,u))}else{u=y;u.opacity&&u.opacity<1||u.blending!=THREE.NormalBlending?n(L,u):n(J,u)}}}function p(l,y){return y.z-l.z}function x(l,y,B,t,u){if(y[B]==undefined){l.push({buffer:t,object:u,opaque:{list:[],count:0},transparent:{list:[],
-count:0}});y[B]=1}}function A(l,y){l._modelViewMatrix.multiplyToArray(y.globalMatrix,l.globalMatrix,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function G(l){if(l!=aa){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);
-break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}aa=l}}function v(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,
+!1,t._modelViewMatrixArray);e.uniformMatrix3fv(C.normalMatrix,!1,t._normalMatrixArray);(q instanceof THREE.MeshShaderMaterial||q instanceof THREE.MeshPhongMaterial||q.env_map)&&e.uniform3f(C.cameraPosition,l.position.x,l.position.y,l.position.z);(q instanceof THREE.MeshShaderMaterial||q.env_map||q.skinning)&&e.uniformMatrix4fv(C.objectMatrix,!1,t._objectMatrixArray);(q instanceof THREE.MeshPhongMaterial||q instanceof THREE.MeshLambertMaterial||q instanceof THREE.MeshShaderMaterial||q.skinning)&&e.uniformMatrix4fv(C.viewMatrix,
+!1,la);if(q.skinning){e.uniformMatrix4fv(C.cameraInverseMatrix,!1,aa);e.uniformMatrix4fv(C.boneGlobalMatrices,!1,t.boneMatrices)}return E}function f(l,y,B,q,t,E){l=d(l,y,B,q,E).attributes;e.bindBuffer(e.ARRAY_BUFFER,t.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,
+3,e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(t.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(t.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);
+if(q.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,t.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,
+4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(q.wireframe){e.lineWidth(q.wireframe_linewidth);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(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(q.linewidth);e.drawArrays(E,0,t.__webGLLineCount)}else if(E instanceof
+THREE.ParticleSystem)e.drawArrays(e.POINTS,0,t.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,t.__webGLVertexCount)}function g(l,y){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.position);e.vertexAttribPointer(y.attributes.position,
+3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(y.attributes.normal);e.vertexAttribPointer(y.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(V!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);V=l.doubleSided}if(S!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);S=l.flipSided}}function k(l){if(ea!=
+l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ea=l}}function j(l){J[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);J[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);J[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);J[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);J[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);J[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var y;for(l=0;l<6;l++){y=J[l];y.divideScalar(Math.sqrt(y.x*y.x+y.y*y.y+y.z*y.z))}}
+function m(l){for(var y=l.globalMatrix,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),q=0;q<6;q++){l=J[q].x*y.n14+J[q].y*y.n24+J[q].z*y.n34+J[q].w;if(l<=B)return!1}return!0}function n(l,y){l.list[l.count]=y;l.count+=1}function w(l){var y,B,q=l.object,t=l.opaque,E=l.transparent;E.count=0;l=t.count=0;for(y=q.materials.length;l<y;l++){B=q.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?n(E,B):n(t,B)}}function u(l){var y,B,q,t,E=l.object,C=
+l.buffer,I=l.opaque,L=l.transparent;L.count=0;l=I.count=0;for(q=E.materials.length;l<q;l++){y=E.materials[l];if(y instanceof THREE.MeshFaceMaterial){y=0;for(B=C.materials.length;y<B;y++)(t=C.materials[y])&&(t.opacity&&t.opacity<1||t.blending!=THREE.NormalBlending?n(L,t):n(I,t))}else{t=y;t.opacity&&t.opacity<1||t.blending!=THREE.NormalBlending?n(L,t):n(I,t)}}}function p(l,y){return y.z-l.z}function x(l,y,B,q,t){if(y[B]==undefined){l.push({buffer:q,object:t,opaque:{list:[],count:0},transparent:{list:[],
+count:0}});y[B]=1}}function A(l,y){l._modelViewMatrix.multiplyToArray(y.globalMatrix,l.globalMatrix,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function G(l){if(l!=Z){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);
+break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Z=l}}function v(l,y){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,
 l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(l.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(l.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(l.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(l.min_filter));e.texImage2D(e.TEXTURE_2D,0,o(l.format),l.width,l.height,0,o(l.format),o(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);
 l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(l.wrap_s));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(l.wrap_t));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(l.mag_filter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(l.min_filter));e.texImage2D(e.TEXTURE_2D,0,o(l.format),l.width,l.height,0,o(l.format),o(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);
-e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var B,t,u;if(l){B=l.__webGLFramebuffer;t=l.width;u=l.height}else{B=null;t=M.width;u=M.height}if(B!=O){e.bindFramebuffer(e.FRAMEBUFFER,B);e.viewport(0,0,t,u);y&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);O=B}}function I(l,y){var B;if(l=="fragment")B=e.createShader(e.FRAGMENT_SHADER);else l==
+e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var B,q,t;if(l){B=l.__webGLFramebuffer;q=l.width;t=l.height}else{B=null;q=M.width;t=M.height}if(B!=O){e.bindFramebuffer(e.FRAMEBUFFER,B);e.viewport(0,0,q,t);y&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);O=B}}function H(l,y){var B;if(l=="fragment")B=e.createShader(e.FRAGMENT_SHADER);else l==
 "vertex"&&(B=e.createShader(e.VERTEX_SHADER));e.shaderSource(B,y);e.compileShader(B);if(!e.getShaderParameter(B,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(B));return null}return B}function o(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;
 "vertex"&&(B=e.createShader(e.VERTEX_SHADER));e.shaderSource(B,y);e.compileShader(B);if(!e.getShaderParameter(B,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(B));return null}return B}function o(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;
 case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;
 case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;
-case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),e,ea=null,O=null,P=this,W=null,S=null,aa=null,ba=null,H=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],V=new THREE.Matrix4,la=new Float32Array(16),Y=new Float32Array(16),ka=new Float32Array(16),ia=new THREE.Vector4,ga=
-!0,ua=new THREE.Color(0),xa=0;if(a){if(a.antialias!==undefined)ga=a.antialias;a.clearColor!==undefined&&ua.setHex(a.clearColor);if(a.clearAlpha!==undefined)xa=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!1;(function(l,y,B){try{e=M.getContext("experimental-webgl",{antialias:l})}catch(t){console.log(t)}if(!e)throw"cannot create webgl context";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);
+case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),e,da=null,O=null,P=this,V=null,S=null,Z=null,ea=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],$=new THREE.Matrix4,ta=new Float32Array(16),aa=new Float32Array(16),la=new Float32Array(16),ia=new THREE.Vector4,ga=
+!0,ua=new THREE.Color(0),xa=0;if(a){if(a.antialias!==undefined)ga=a.antialias;a.clearColor!==undefined&&ua.setHex(a.clearColor);if(a.clearAlpha!==undefined)xa=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!1;(function(l,y,B){try{e=M.getContext("experimental-webgl",{antialias:l})}catch(q){console.log(q)}if(!e)throw"cannot create webgl context";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,B);_cullEnabled=!0})(ga,ua,xa);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){M.width=l;M.height=y;e.viewport(0,0,M.width,M.height)};this.setClearColorHex=function(l,y){var B=new THREE.Color(l);e.clearColor(B.r,B.g,B.b,y)};this.setClearColor=function(l,y){e.clearColor(l.r,l.g,l.b,y)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|
 e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(y.r,y.g,y.b,B);_cullEnabled=!0})(ga,ua,xa);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,y){M.width=l;M.height=y;e.viewport(0,0,M.width,M.height)};this.setClearColorHex=function(l,y){var B=new THREE.Color(l);e.clearColor(B.r,B.g,B.b,y)};this.setClearColor=function(l,y){e.clearColor(l.r,l.g,l.b,y)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|
-e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,y,B){var t,u;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof
-THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var E,C,J,L;u=J=L=0;for(E=y.length;u<E;u++){C=y[u];C instanceof THREE.DirectionalLight&&J++;C instanceof THREE.PointLight&&L++}if(L+J<=4)y=J;else{y=Math.ceil(4*J/(L+J));L=4-y}u={directional:y,point:L};L=l.fragment_shader;y=l.vertex_shader;E={fog:B,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,skinning:l.skinning,maxDirLights:u.directional,maxPointLights:u.point};B=e.createProgram();u=["#ifdef GL_ES\nprecision highp float;\n#endif",
+e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,y,B){var q,t;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof
+THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var E,C,I,L;t=I=L=0;for(E=y.length;t<E;t++){C=y[t];C instanceof THREE.DirectionalLight&&I++;C instanceof THREE.PointLight&&L++}if(L+I<=4)y=I;else{y=Math.ceil(4*I/(L+I));L=4-y}t={directional:y,point:L};L=l.fragment_shader;y=l.vertex_shader;E={fog:B,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,skinning:l.skinning,maxDirLights:t.directional,maxPointLights:t.point};B=e.createProgram();t=["#ifdef GL_ES\nprecision highp float;\n#endif",
 "#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+
 "#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+
 E.maxPointLights,E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
 E.maxPointLights,E.map?"#define USE_MAP":"",E.env_map?"#define USE_ENVMAP":"",E.light_map?"#define USE_LIGHTMAP":"",E.vertex_colors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-e.attachShader(B,I("fragment",u+L));e.attachShader(B,I("vertex",E+y));e.linkProgram(B);e.getProgramParameter(B,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(B,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(t in l.uniforms)B.push(t);t=l.program;L=0;for(y=B.length;L<
-y;L++){u=B[L];t.uniforms[u]=e.getUniformLocation(t,u)}t=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];L=0;for(y=B.length;L<y;L++){u=B[L];t.attributes[u]=e.getAttribLocation(t,u)}t=l.program.attributes;e.enableVertexAttribArray(t.position);t.color>=0&&e.enableVertexAttribArray(t.color);t.normal>=0&&e.enableVertexAttribArray(t.normal);t.tangent>=0&&e.enableVertexAttribArray(t.tangent);if(l.skinning&&t.skinVertexA>=0&&t.skinVertexB>=
-0&&t.skinIndex>=0&&t.skinWeight>=0){e.enableVertexAttribArray(t.skinVertexA);e.enableVertexAttribArray(t.skinVertexB);e.enableVertexAttribArray(t.skinIndex);e.enableVertexAttribArray(t.skinWeight)}};this.render=function(l,y,B,t){var u,E,C,J,L,z,D,F,T=l.lights,Q=l.fog;y.matrixAutoUpdate&&y.update();y.globalMatrix.flattenToArray(ka);y.projectionMatrix.flattenToArray(la);y.inverseMatrix.flattenToArray(Y);V.multiply(y.projectionMatrix,y.globalMatrix);j(V);THREE.AnimationHandler&&THREE.AnimationHandler.update();
-l.update(undefined,!1,y);this.initWebGLObjects(l,y);v(B,t!==undefined?t:!0);this.autoClear&&this.clear();L=l.__webGLObjects.length;for(t=0;t<L;t++){u=l.__webGLObjects[t];D=u.object;if(D.visible)if(!(D instanceof THREE.Mesh)||m(D)){D.globalMatrix.flattenToArray(D._objectMatrixArray);A(D,y);q(u);u.render=!0;if(this.sortObjects){ia.copy(D.position);V.multiplyVector3(ia);u.z=ia.z}}else u.render=!1;else u.render=!1}this.sortObjects&&l.__webGLObjects.sort(p);z=l.__webGLObjectsImmediate.length;for(t=0;t<
-z;t++){u=l.__webGLObjectsImmediate[t];D=u.object;if(D.visible){D.matrixAutoUpdate&&D.globalMatrix.flattenToArray(D._objectMatrixArray);A(D,y);w(u)}}G(THREE.NormalBlending);for(t=0;t<L;t++){u=l.__webGLObjects[t];if(u.render){D=u.object;F=u.buffer;C=u.opaque;h(D);for(u=0;u<C.count;u++){J=C.list[u];k(J.depth_test);f(y,T,Q,J,F,D)}}}for(t=0;t<z;t++){u=l.__webGLObjectsImmediate[t];D=u.object;if(D.visible){C=u.opaque;h(D);for(u=0;u<C.count;u++){J=C.list[u];k(J.depth_test);E=d(y,T,Q,J,D);D.render(function(fa){g(fa,
-E)})}}}for(t=0;t<L;t++){u=l.__webGLObjects[t];if(u.render){D=u.object;F=u.buffer;C=u.transparent;h(D);for(u=0;u<C.count;u++){J=C.list[u];G(J.blending);k(J.depth_test);f(y,T,Q,J,F,D)}}}for(t=0;t<z;t++){u=l.__webGLObjectsImmediate[t];D=u.object;if(D.visible){C=u.transparent;h(D);for(u=0;u<C.count;u++){J=C.list[u];G(J.blending);k(J.depth_test);E=d(y,T,Q,J,D);D.render(function(fa){g(fa,E)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);
-e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,y){var B,t,u;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}B=0;for(t=l.objects.length;B<t;B++){u=l.objects[B];var E=l,C=y,J=void 0,L=void 0,z=void 0,D=void 0;L=u.geometry;if(E.__webGLObjectsMap[u.id]==undefined){E.__webGLObjectsMap[u.id]={};u._modelViewMatrix=new THREE.Matrix4;u._normalMatrixArray=new Float32Array(9);u._modelViewMatrixArray=new Float32Array(16);
-u._objectMatrixArray=new Float32Array(16);u.globalMatrix.flattenToArray(u._objectMatrixArray)}D=E.__webGLObjectsMap[u.id];objlist=E.__webGLObjects;if(u instanceof THREE.Mesh){for(J in L.geometryChunks){z=L.geometryChunks[J];if(!z.__webGLVertexBuffer){C=z;C.__webGLVertexBuffer=e.createBuffer();C.__webGLNormalBuffer=e.createBuffer();C.__webGLTangentBuffer=e.createBuffer();C.__webGLColorBuffer=e.createBuffer();C.__webGLUVBuffer=e.createBuffer();C.__webGLUV2Buffer=e.createBuffer();C.__webGLSkinVertexABuffer=
-e.createBuffer();C.__webGLSkinVertexBBuffer=e.createBuffer();C.__webGLSkinIndicesBuffer=e.createBuffer();C.__webGLSkinWeightsBuffer=e.createBuffer();C.__webGLFaceBuffer=e.createBuffer();C.__webGLLineBuffer=e.createBuffer();C=z;var F=u,T=void 0,Q=void 0,fa=0,ma=E=0,ra=F.geometry.faces,oa=C.faces;T=0;for(Q=oa.length;T<Q;T++){fi=oa[T];face=ra[fi];if(face instanceof THREE.Face3){fa+=3;E+=1;ma+=3}else if(face instanceof THREE.Face4){fa+=4;E+=2;ma+=4}}C.__vertexArray=new Float32Array(fa*3);C.__normalArray=
-new Float32Array(fa*3);C.__tangentArray=new Float32Array(fa*4);C.__colorArray=new Float32Array(fa*3);C.__uvArray=new Float32Array(fa*2);C.__uv2Array=new Float32Array(fa*2);C.__skinVertexAArray=new Float32Array(fa*4);C.__skinVertexBArray=new Float32Array(fa*4);C.__skinIndexArray=new Float32Array(fa*4);C.__skinWeightArray=new Float32Array(fa*4);C.__faceArray=new Uint16Array(E*3);C.__lineArray=new Uint16Array(ma*2);Q=T=C;fa=void 0;ra=void 0;var na=void 0,ha=void 0;na=void 0;oa=!1;fa=0;for(ra=F.materials.length;fa<
-ra;fa++){na=F.materials[fa];if(na instanceof THREE.MeshFaceMaterial){na=0;for(ha=Q.materials.length;na<ha;na++)if(Q.materials[na]&&Q.materials[na].shading!=undefined&&Q.materials[na].shading==THREE.SmoothShading){oa=!0;break}}else if(na&&na.shading!=undefined&&na.shading==THREE.SmoothShading){oa=!0;break}if(oa)break}T.__needsSmoothNormals=oa;C.__webGLFaceCount=E*3;C.__webGLLineCount=ma*2;L.__dirtyVertices=!0;L.__dirtyElements=!0;L.__dirtyUvs=!0;L.__dirtyNormals=!0;L.__dirtyTangents=!0;L.__dirtyColors=
-!0}if(L.__dirtyVertices||L.__dirtyElements||L.__dirtyUvs||L.__dirtyNormals||L.__dirtyColors||L.__dirtyTangents){C=z;E=e.DYNAMIC_DRAW;ma=void 0;T=void 0;var Ca=void 0,R=void 0,Ga=void 0,Ha=void 0,La=void 0;Ca=void 0;var da=void 0,Z=void 0,$=void 0,sa=void 0;da=void 0;Z=void 0;$=void 0;R=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;R=void 0;Ha=void 0;
-Ga=void 0;La=void 0;var Ja=ha=na=oa=ra=fa=F=Q=0,Aa=0,N=0,Ba=C.__vertexArray,Pa=C.__uvArray,Ta=C.__uv2Array,ta=C.__normalArray,pa=C.__tangentArray,za=C.__colorArray,wa=C.__skinVertexAArray,ya=C.__skinVertexBArray,va=C.__skinIndexArray,K=C.__skinWeightArray,ja=C.__faceArray,ca=C.__lineArray,U=C.__needsSmoothNormals,X=u.geometry,qa=X.__dirtyVertices,Da=X.__dirtyElements,Ea=X.__dirtyUvs,Ia=X.__dirtyNormals,Ma=X.__dirtyTangents,Ka=X.__dirtyColors,Fa=X.vertices,Sa=C.faces,Na=X.faces,Oa=X.uvs,Xa=X.uvs2,
-Qa=X.colors,Ua=X.skinVerticesA,Va=X.skinVerticesB,Wa=X.skinIndices,Ra=X.skinWeights;ma=0;for(T=Sa.length;ma<T;ma++){Ca=Sa[ma];R=Na[Ca];La=Oa[Ca];Ca=Xa[Ca];Ga=R.vertexNormals;Ha=R.normal;if(R instanceof THREE.Face3){if(qa){da=Fa[R.a].position;Z=Fa[R.b].position;$=Fa[R.c].position;Ba[F]=da.x;Ba[F+1]=da.y;Ba[F+2]=da.z;Ba[F+3]=Z.x;Ba[F+4]=Z.y;Ba[F+5]=Z.z;Ba[F+6]=$.x;Ba[F+7]=$.y;Ba[F+8]=$.z;F+=9}if(Ra.length){da=Ra[R.a];Z=Ra[R.b];$=Ra[R.c];K[N]=da.x;K[N+1]=da.y;K[N+2]=da.z;K[N+3]=da.w;K[N+4]=Z.x;K[N+5]=
-Z.y;K[N+6]=Z.z;K[N+7]=Z.w;K[N+8]=$.x;K[N+9]=$.y;K[N+10]=$.z;K[N+11]=$.w;da=Wa[R.a];Z=Wa[R.b];$=Wa[R.c];va[N]=da.x;va[N+1]=da.y;va[N+2]=da.z;va[N+3]=da.w;va[N+4]=Z.x;va[N+5]=Z.y;va[N+6]=Z.z;va[N+7]=Z.w;va[N+8]=$.x;va[N+9]=$.y;va[N+10]=$.z;va[N+11]=$.w;da=Ua[R.a];Z=Ua[R.b];$=Ua[R.c];wa[N]=da.x;wa[N+1]=da.y;wa[N+2]=da.z;wa[N+3]=1;wa[N+4]=Z.x;wa[N+5]=Z.y;wa[N+6]=Z.z;wa[N+7]=1;wa[N+8]=$.x;wa[N+9]=$.y;wa[N+10]=$.z;wa[N+11]=1;da=Va[R.a];Z=Va[R.b];$=Va[R.c];ya[N]=da.x;ya[N+1]=da.y;ya[N+2]=da.z;ya[N+3]=1;
-ya[N+4]=Z.x;ya[N+5]=Z.y;ya[N+6]=Z.z;ya[N+7]=1;ya[N+8]=$.x;ya[N+9]=$.y;ya[N+10]=$.z;ya[N+11]=1;N+=12}if(Ka&&Qa.length){da=Qa[R.a];Z=Qa[R.b];$=Qa[R.c];za[Aa]=da.r;za[Aa+1]=da.g;za[Aa+2]=da.b;za[Aa+3]=Z.r;za[Aa+4]=Z.g;za[Aa+5]=Z.b;za[Aa+6]=$.r;za[Aa+7]=$.g;za[Aa+8]=$.b;Aa+=9}if(Ma&&X.hasTangents){da=Fa[R.a].tangent;Z=Fa[R.b].tangent;$=Fa[R.c].tangent;pa[ha]=da.x;pa[ha+1]=da.y;pa[ha+2]=da.z;pa[ha+3]=da.w;pa[ha+4]=Z.x;pa[ha+5]=Z.y;pa[ha+6]=Z.z;pa[ha+7]=Z.w;pa[ha+8]=$.x;pa[ha+9]=$.y;pa[ha+10]=$.z;pa[ha+
-11]=$.w;ha+=12}if(Ia)if(Ga.length==3&&U)for(R=0;R<3;R++){Ha=Ga[R];ta[na]=Ha.x;ta[na+1]=Ha.y;ta[na+2]=Ha.z;na+=3}else for(R=0;R<3;R++){ta[na]=Ha.x;ta[na+1]=Ha.y;ta[na+2]=Ha.z;na+=3}if(Ea&&La)for(R=0;R<3;R++){Ga=La[R];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(R=0;R<3;R++){La=Ca[R];Ta[ra]=La.u;Ta[ra+1]=La.v;ra+=2}if(Da){ja[oa]=Q;ja[oa+1]=Q+1;ja[oa+2]=Q+2;oa+=3;ca[Ja]=Q;ca[Ja+1]=Q+1;ca[Ja+2]=Q;ca[Ja+3]=Q+2;ca[Ja+4]=Q+1;ca[Ja+5]=Q+2;Ja+=6;Q+=3}}else if(R instanceof THREE.Face4){if(qa){da=Fa[R.a].position;
-Z=Fa[R.b].position;$=Fa[R.c].position;sa=Fa[R.d].position;Ba[F]=da.x;Ba[F+1]=da.y;Ba[F+2]=da.z;Ba[F+3]=Z.x;Ba[F+4]=Z.y;Ba[F+5]=Z.z;Ba[F+6]=$.x;Ba[F+7]=$.y;Ba[F+8]=$.z;Ba[F+9]=sa.x;Ba[F+10]=sa.y;Ba[F+11]=sa.z;F+=12}if(Ra.length){da=Ra[R.a];Z=Ra[R.b];$=Ra[R.c];sa=Ra[R.d];K[N]=da.x;K[N+1]=da.y;K[N+2]=da.z;K[N+3]=da.w;K[N+4]=Z.x;K[N+5]=Z.y;K[N+6]=Z.z;K[N+7]=Z.w;K[N+8]=$.x;K[N+9]=$.y;K[N+10]=$.z;K[N+11]=$.w;K[N+12]=sa.x;K[N+13]=sa.y;K[N+14]=sa.z;K[N+15]=sa.w;da=Wa[R.a];Z=Wa[R.b];$=Wa[R.c];sa=Wa[R.d];va[N]=
-da.x;va[N+1]=da.y;va[N+2]=da.z;va[N+3]=da.w;va[N+4]=Z.x;va[N+5]=Z.y;va[N+6]=Z.z;va[N+7]=Z.w;va[N+8]=$.x;va[N+9]=$.y;va[N+10]=$.z;va[N+11]=$.w;va[N+12]=sa.x;va[N+13]=sa.y;va[N+14]=sa.z;va[N+15]=sa.w;da=Ua[R.a];Z=Ua[R.b];$=Ua[R.c];sa=Ua[R.d];wa[N]=da.x;wa[N+1]=da.y;wa[N+2]=da.z;wa[N+3]=1;wa[N+4]=Z.x;wa[N+5]=Z.y;wa[N+6]=Z.z;wa[N+7]=1;wa[N+8]=$.x;wa[N+9]=$.y;wa[N+10]=$.z;wa[N+11]=1;wa[N+12]=sa.x;wa[N+13]=sa.y;wa[N+14]=sa.z;wa[N+15]=1;da=Va[R.a];Z=Va[R.b];$=Va[R.c];sa=Va[R.d];ya[N]=da.x;ya[N+1]=da.y;ya[N+
-2]=da.z;ya[N+3]=1;ya[N+4]=Z.x;ya[N+5]=Z.y;ya[N+6]=Z.z;ya[N+7]=1;ya[N+8]=$.x;ya[N+9]=$.y;ya[N+10]=$.z;ya[N+11]=1;ya[N+12]=sa.x;ya[N+13]=sa.y;ya[N+14]=sa.z;ya[N+15]=1;N+=16}if(Ka&&Qa.length){da=Qa[R.a];Z=Qa[R.b];$=Qa[R.c];sa=Qa[R.d];za[Aa]=da.r;za[Aa+1]=da.g;za[Aa+2]=da.b;za[Aa+3]=Z.r;za[Aa+4]=Z.g;za[Aa+5]=Z.b;za[Aa+6]=$.r;za[Aa+7]=$.g;za[Aa+8]=$.b;za[Aa+9]=sa.r;za[Aa+10]=sa.g;za[Aa+11]=sa.b;Aa+=12}if(Ma&&X.hasTangents){da=Fa[R.a].tangent;Z=Fa[R.b].tangent;$=Fa[R.c].tangent;R=Fa[R.d].tangent;pa[ha]=
-da.x;pa[ha+1]=da.y;pa[ha+2]=da.z;pa[ha+3]=da.w;pa[ha+4]=Z.x;pa[ha+5]=Z.y;pa[ha+6]=Z.z;pa[ha+7]=Z.w;pa[ha+8]=$.x;pa[ha+9]=$.y;pa[ha+10]=$.z;pa[ha+11]=$.w;pa[ha+12]=R.x;pa[ha+13]=R.y;pa[ha+14]=R.z;pa[ha+15]=R.w;ha+=16}if(Ia)if(Ga.length==4&&U)for(R=0;R<4;R++){Ha=Ga[R];ta[na]=Ha.x;ta[na+1]=Ha.y;ta[na+2]=Ha.z;na+=3}else for(R=0;R<4;R++){ta[na]=Ha.x;ta[na+1]=Ha.y;ta[na+2]=Ha.z;na+=3}if(Ea&&La)for(R=0;R<4;R++){Ga=La[R];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(R=0;R<4;R++){La=Ca[R];Ta[ra]=La.u;Ta[ra+
-1]=La.v;ra+=2}if(Da){ja[oa]=Q;ja[oa+1]=Q+1;ja[oa+2]=Q+2;ja[oa+3]=Q;ja[oa+4]=Q+2;ja[oa+5]=Q+3;oa+=6;ca[Ja]=Q;ca[Ja+1]=Q+1;ca[Ja+2]=Q;ca[Ja+3]=Q+3;ca[Ja+4]=Q+1;ca[Ja+5]=Q+2;ca[Ja+6]=Q+2;ca[Ja+7]=Q+3;Ja+=8;Q+=4}}}if(qa){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,E)}if(Ka&&Qa.length){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,za,E)}if(Ia){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,ta,E)}if(Ma&&
-X.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,pa,E)}if(Ea&&fa>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,E)}if(Ea&&ra>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ta,E)}if(Da){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ja,E);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ca,E)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,
-C.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,wa,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ya,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,va,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,K,E)}}x(objlist,D,J,z,u)}L.__dirtyVertices=!1;L.__dirtyElements=!1;L.__dirtyUvs=!1;L.__dirtyNormals=!1;L.__dirtyTangents=!1;L.__dirtyColors=!1}else if(u instanceof THREE.Ribbon){if(!L.__webGLVertexBuffer){J=
-L;J.__webGLVertexBuffer=e.createBuffer();J.__webGLColorBuffer=e.createBuffer();J=L;z=J.vertices.length;J.__vertexArray=new Float32Array(z*3);J.__colorArray=new Float32Array(z*3);J.__webGLVertexCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}if(L.__dirtyVertices||L.__dirtyColors){J=L;z=e.DYNAMIC_DRAW;Q=void 0;Q=void 0;F=void 0;C=void 0;fa=J.vertices;E=J.colors;ra=fa.length;ma=E.length;oa=J.__vertexArray;T=J.__colorArray;na=J.__dirtyColors;if(J.__dirtyVertices){for(Q=0;Q<ra;Q++){F=fa[Q].position;C=
-Q*3;oa[C]=F.x;oa[C+1]=F.y;oa[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,J.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,oa,z)}if(na){for(Q=0;Q<ma;Q++){color=E[Q];C=Q*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,J.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,z)}}x(objlist,D,0,L,u);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(u instanceof THREE.Line){if(!L.__webGLVertexBuffer){J=L;J.__webGLVertexBuffer=e.createBuffer();J.__webGLColorBuffer=e.createBuffer();J=L;z=J.vertices.length;
-J.__vertexArray=new Float32Array(z*3);J.__colorArray=new Float32Array(z*3);J.__webGLLineCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}if(L.__dirtyVertices||L.__dirtyColors){J=L;z=e.DYNAMIC_DRAW;Q=void 0;Q=void 0;F=void 0;C=void 0;fa=J.vertices;E=J.colors;ra=fa.length;ma=E.length;oa=J.__vertexArray;T=J.__colorArray;na=J.__dirtyColors;if(J.__dirtyVertices){for(Q=0;Q<ra;Q++){F=fa[Q].position;C=Q*3;oa[C]=F.x;oa[C+1]=F.y;oa[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,J.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,
-oa,z)}if(na){for(Q=0;Q<ma;Q++){color=E[Q];C=Q*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,J.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,z)}}x(objlist,D,0,L,u);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(u instanceof THREE.ParticleSystem){if(!L.__webGLVertexBuffer){J=L;J.__webGLVertexBuffer=e.createBuffer();J.__webGLColorBuffer=e.createBuffer();J=L;z=J.vertices.length;J.__vertexArray=new Float32Array(z*3);J.__colorArray=new Float32Array(z*3);J.__sortArray=[];
-J.__webGLParticleCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}(L.__dirtyVertices||L.__dirtyColors||u.sortParticles)&&b(L,e.DYNAMIC_DRAW,u,C);x(objlist,D,0,L,u);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&u instanceof THREE.MarchingCubes){L=D;if(L[0]==undefined){E.__webGLObjectsImmediate.push({object:u,opaque:{list:[],count:0},transparent:{list:[],count:0}});L[0]=1}}}};this.removeObject=function(l,y){var B,t;for(B=l.__webGLObjects.length-1;B>=0;B--){t=l.__webGLObjects[B].object;
-y==t&&l.__webGLObjects.splice(B,1)}};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+e.attachShader(B,H("fragment",t+L));e.attachShader(B,H("vertex",E+y));e.linkProgram(B);e.getProgramParameter(B,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(B,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(q in l.uniforms)B.push(q);q=l.program;L=0;for(y=B.length;L<
+y;L++){t=B[L];q.uniforms[t]=e.getUniformLocation(q,t)}q=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];L=0;for(y=B.length;L<y;L++){t=B[L];q.attributes[t]=e.getAttribLocation(q,t)}q=l.program.attributes;e.enableVertexAttribArray(q.position);q.color>=0&&e.enableVertexAttribArray(q.color);q.normal>=0&&e.enableVertexAttribArray(q.normal);q.tangent>=0&&e.enableVertexAttribArray(q.tangent);if(l.skinning&&q.skinVertexA>=0&&q.skinVertexB>=
+0&&q.skinIndex>=0&&q.skinWeight>=0){e.enableVertexAttribArray(q.skinVertexA);e.enableVertexAttribArray(q.skinVertexB);e.enableVertexAttribArray(q.skinIndex);e.enableVertexAttribArray(q.skinWeight)}};this.render=function(l,y,B,q){var t,E,C,I,L,z,D,F,T=l.lights,Q=l.fog;y.matrixAutoUpdate&&y.update();y.globalMatrix.flattenToArray(la);y.projectionMatrix.flattenToArray(ta);y.inverseMatrix.flattenToArray(aa);$.multiply(y.projectionMatrix,y.globalMatrix);j($);THREE.AnimationHandler&&THREE.AnimationHandler.update();
+l.update(undefined,!1,y);this.initWebGLObjects(l,y);v(B,q!==undefined?q:!0);this.autoClear&&this.clear();L=l.__webGLObjects.length;for(q=0;q<L;q++){t=l.__webGLObjects[q];D=t.object;if(D.visible)if(!(D instanceof THREE.Mesh)||m(D)){D.globalMatrix.flattenToArray(D._objectMatrixArray);A(D,y);u(t);t.render=!0;if(this.sortObjects){ia.copy(D.position);$.multiplyVector3(ia);t.z=ia.z}}else t.render=!1;else t.render=!1}this.sortObjects&&l.__webGLObjects.sort(p);z=l.__webGLObjectsImmediate.length;for(q=0;q<
+z;q++){t=l.__webGLObjectsImmediate[q];D=t.object;if(D.visible){D.matrixAutoUpdate&&D.globalMatrix.flattenToArray(D._objectMatrixArray);A(D,y);w(t)}}G(THREE.NormalBlending);for(q=0;q<L;q++){t=l.__webGLObjects[q];if(t.render){D=t.object;F=t.buffer;C=t.opaque;h(D);for(t=0;t<C.count;t++){I=C.list[t];k(I.depth_test);f(y,T,Q,I,F,D)}}}for(q=0;q<z;q++){t=l.__webGLObjectsImmediate[q];D=t.object;if(D.visible){C=t.opaque;h(D);for(t=0;t<C.count;t++){I=C.list[t];k(I.depth_test);E=d(y,T,Q,I,D);D.render(function(fa){g(fa,
+E)})}}}for(q=0;q<L;q++){t=l.__webGLObjects[q];if(t.render){D=t.object;F=t.buffer;C=t.transparent;h(D);for(t=0;t<C.count;t++){I=C.list[t];G(I.blending);k(I.depth_test);f(y,T,Q,I,F,D)}}}for(q=0;q<z;q++){t=l.__webGLObjectsImmediate[q];D=t.object;if(D.visible){C=t.transparent;h(D);for(t=0;t<C.count;t++){I=C.list[t];G(I.blending);k(I.depth_test);E=d(y,T,Q,I,D);D.render(function(fa){g(fa,E)})}}}if(B&&B.min_filter!==THREE.NearestFilter&&B.min_filter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);
+e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,y){var B,q,t;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}B=0;for(q=l.objects.length;B<q;B++){t=l.objects[B];var E=l,C=y,I=void 0,L=void 0,z=void 0,D=void 0;L=t.geometry;if(E.__webGLObjectsMap[t.id]==undefined){E.__webGLObjectsMap[t.id]={};t._modelViewMatrix=new THREE.Matrix4;t._normalMatrixArray=new Float32Array(9);t._modelViewMatrixArray=new Float32Array(16);
+t._objectMatrixArray=new Float32Array(16);t.globalMatrix.flattenToArray(t._objectMatrixArray)}D=E.__webGLObjectsMap[t.id];objlist=E.__webGLObjects;if(t instanceof THREE.Mesh){for(I in L.geometryChunks){z=L.geometryChunks[I];if(!z.__webGLVertexBuffer){C=z;C.__webGLVertexBuffer=e.createBuffer();C.__webGLNormalBuffer=e.createBuffer();C.__webGLTangentBuffer=e.createBuffer();C.__webGLColorBuffer=e.createBuffer();C.__webGLUVBuffer=e.createBuffer();C.__webGLUV2Buffer=e.createBuffer();C.__webGLSkinVertexABuffer=
+e.createBuffer();C.__webGLSkinVertexBBuffer=e.createBuffer();C.__webGLSkinIndicesBuffer=e.createBuffer();C.__webGLSkinWeightsBuffer=e.createBuffer();C.__webGLFaceBuffer=e.createBuffer();C.__webGLLineBuffer=e.createBuffer();C=z;var F=t,T=void 0,Q=void 0,fa=0,ka=E=0,qa=F.geometry.faces,na=C.faces;T=0;for(Q=na.length;T<Q;T++){fi=na[T];face=qa[fi];if(face instanceof THREE.Face3){fa+=3;E+=1;ka+=3}else if(face instanceof THREE.Face4){fa+=4;E+=2;ka+=4}}C.__vertexArray=new Float32Array(fa*3);C.__normalArray=
+new Float32Array(fa*3);C.__tangentArray=new Float32Array(fa*4);C.__colorArray=new Float32Array(fa*3);C.__uvArray=new Float32Array(fa*2);C.__uv2Array=new Float32Array(fa*2);C.__skinVertexAArray=new Float32Array(fa*4);C.__skinVertexBArray=new Float32Array(fa*4);C.__skinIndexArray=new Float32Array(fa*4);C.__skinWeightArray=new Float32Array(fa*4);C.__faceArray=new Uint16Array(E*3);C.__lineArray=new Uint16Array(ka*2);Q=T=C;fa=void 0;qa=void 0;var ma=void 0,ha=void 0;ma=void 0;na=!1;fa=0;for(qa=F.materials.length;fa<
+qa;fa++){ma=F.materials[fa];if(ma instanceof THREE.MeshFaceMaterial){ma=0;for(ha=Q.materials.length;ma<ha;ma++)if(Q.materials[ma]&&Q.materials[ma].shading!=undefined&&Q.materials[ma].shading==THREE.SmoothShading){na=!0;break}}else if(ma&&ma.shading!=undefined&&ma.shading==THREE.SmoothShading){na=!0;break}if(na)break}T.__needsSmoothNormals=na;C.__webGLFaceCount=E*3;C.__webGLLineCount=ka*2;L.__dirtyVertices=!0;L.__dirtyElements=!0;L.__dirtyUvs=!0;L.__dirtyNormals=!0;L.__dirtyTangents=!0;L.__dirtyColors=
+!0}if(L.__dirtyVertices||L.__dirtyElements||L.__dirtyUvs||L.__dirtyNormals||L.__dirtyColors||L.__dirtyTangents){C=z;E=e.DYNAMIC_DRAW;ka=void 0;T=void 0;var Ca=void 0,R=void 0,Ga=void 0,Ha=void 0,La=void 0;Ca=void 0;var ca=void 0,X=void 0,Y=void 0,ra=void 0;ca=void 0;X=void 0;Y=void 0;R=void 0;ca=void 0;X=void 0;Y=void 0;ra=void 0;ca=void 0;X=void 0;Y=void 0;ra=void 0;ca=void 0;X=void 0;Y=void 0;ra=void 0;ca=void 0;X=void 0;Y=void 0;ra=void 0;ca=void 0;X=void 0;Y=void 0;ra=void 0;R=void 0;Ha=void 0;
+Ga=void 0;La=void 0;var Ja=ha=ma=na=qa=fa=F=Q=0,Aa=0,N=0,Ba=C.__vertexArray,Pa=C.__uvArray,Ta=C.__uv2Array,sa=C.__normalArray,oa=C.__tangentArray,za=C.__colorArray,wa=C.__skinVertexAArray,ya=C.__skinVertexBArray,va=C.__skinIndexArray,K=C.__skinWeightArray,ja=C.__faceArray,ba=C.__lineArray,U=C.__needsSmoothNormals,W=t.geometry,pa=W.__dirtyVertices,Da=W.__dirtyElements,Ea=W.__dirtyUvs,Ia=W.__dirtyNormals,Ma=W.__dirtyTangents,Ka=W.__dirtyColors,Fa=W.vertices,Sa=C.faces,Na=W.faces,Oa=W.uvs,Xa=W.uvs2,
+Qa=W.colors,Ua=W.skinVerticesA,Va=W.skinVerticesB,Wa=W.skinIndices,Ra=W.skinWeights;ka=0;for(T=Sa.length;ka<T;ka++){Ca=Sa[ka];R=Na[Ca];La=Oa[Ca];Ca=Xa[Ca];Ga=R.vertexNormals;Ha=R.normal;if(R instanceof THREE.Face3){if(pa){ca=Fa[R.a].position;X=Fa[R.b].position;Y=Fa[R.c].position;Ba[F]=ca.x;Ba[F+1]=ca.y;Ba[F+2]=ca.z;Ba[F+3]=X.x;Ba[F+4]=X.y;Ba[F+5]=X.z;Ba[F+6]=Y.x;Ba[F+7]=Y.y;Ba[F+8]=Y.z;F+=9}if(Ra.length){ca=Ra[R.a];X=Ra[R.b];Y=Ra[R.c];K[N]=ca.x;K[N+1]=ca.y;K[N+2]=ca.z;K[N+3]=ca.w;K[N+4]=X.x;K[N+5]=
+X.y;K[N+6]=X.z;K[N+7]=X.w;K[N+8]=Y.x;K[N+9]=Y.y;K[N+10]=Y.z;K[N+11]=Y.w;ca=Wa[R.a];X=Wa[R.b];Y=Wa[R.c];va[N]=ca.x;va[N+1]=ca.y;va[N+2]=ca.z;va[N+3]=ca.w;va[N+4]=X.x;va[N+5]=X.y;va[N+6]=X.z;va[N+7]=X.w;va[N+8]=Y.x;va[N+9]=Y.y;va[N+10]=Y.z;va[N+11]=Y.w;ca=Ua[R.a];X=Ua[R.b];Y=Ua[R.c];wa[N]=ca.x;wa[N+1]=ca.y;wa[N+2]=ca.z;wa[N+3]=1;wa[N+4]=X.x;wa[N+5]=X.y;wa[N+6]=X.z;wa[N+7]=1;wa[N+8]=Y.x;wa[N+9]=Y.y;wa[N+10]=Y.z;wa[N+11]=1;ca=Va[R.a];X=Va[R.b];Y=Va[R.c];ya[N]=ca.x;ya[N+1]=ca.y;ya[N+2]=ca.z;ya[N+3]=1;
+ya[N+4]=X.x;ya[N+5]=X.y;ya[N+6]=X.z;ya[N+7]=1;ya[N+8]=Y.x;ya[N+9]=Y.y;ya[N+10]=Y.z;ya[N+11]=1;N+=12}if(Ka&&Qa.length){ca=Qa[R.a];X=Qa[R.b];Y=Qa[R.c];za[Aa]=ca.r;za[Aa+1]=ca.g;za[Aa+2]=ca.b;za[Aa+3]=X.r;za[Aa+4]=X.g;za[Aa+5]=X.b;za[Aa+6]=Y.r;za[Aa+7]=Y.g;za[Aa+8]=Y.b;Aa+=9}if(Ma&&W.hasTangents){ca=Fa[R.a].tangent;X=Fa[R.b].tangent;Y=Fa[R.c].tangent;oa[ha]=ca.x;oa[ha+1]=ca.y;oa[ha+2]=ca.z;oa[ha+3]=ca.w;oa[ha+4]=X.x;oa[ha+5]=X.y;oa[ha+6]=X.z;oa[ha+7]=X.w;oa[ha+8]=Y.x;oa[ha+9]=Y.y;oa[ha+10]=Y.z;oa[ha+
+11]=Y.w;ha+=12}if(Ia)if(Ga.length==3&&U)for(R=0;R<3;R++){Ha=Ga[R];sa[ma]=Ha.x;sa[ma+1]=Ha.y;sa[ma+2]=Ha.z;ma+=3}else for(R=0;R<3;R++){sa[ma]=Ha.x;sa[ma+1]=Ha.y;sa[ma+2]=Ha.z;ma+=3}if(Ea&&La)for(R=0;R<3;R++){Ga=La[R];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(R=0;R<3;R++){La=Ca[R];Ta[qa]=La.u;Ta[qa+1]=La.v;qa+=2}if(Da){ja[na]=Q;ja[na+1]=Q+1;ja[na+2]=Q+2;na+=3;ba[Ja]=Q;ba[Ja+1]=Q+1;ba[Ja+2]=Q;ba[Ja+3]=Q+2;ba[Ja+4]=Q+1;ba[Ja+5]=Q+2;Ja+=6;Q+=3}}else if(R instanceof THREE.Face4){if(pa){ca=Fa[R.a].position;
+X=Fa[R.b].position;Y=Fa[R.c].position;ra=Fa[R.d].position;Ba[F]=ca.x;Ba[F+1]=ca.y;Ba[F+2]=ca.z;Ba[F+3]=X.x;Ba[F+4]=X.y;Ba[F+5]=X.z;Ba[F+6]=Y.x;Ba[F+7]=Y.y;Ba[F+8]=Y.z;Ba[F+9]=ra.x;Ba[F+10]=ra.y;Ba[F+11]=ra.z;F+=12}if(Ra.length){ca=Ra[R.a];X=Ra[R.b];Y=Ra[R.c];ra=Ra[R.d];K[N]=ca.x;K[N+1]=ca.y;K[N+2]=ca.z;K[N+3]=ca.w;K[N+4]=X.x;K[N+5]=X.y;K[N+6]=X.z;K[N+7]=X.w;K[N+8]=Y.x;K[N+9]=Y.y;K[N+10]=Y.z;K[N+11]=Y.w;K[N+12]=ra.x;K[N+13]=ra.y;K[N+14]=ra.z;K[N+15]=ra.w;ca=Wa[R.a];X=Wa[R.b];Y=Wa[R.c];ra=Wa[R.d];va[N]=
+ca.x;va[N+1]=ca.y;va[N+2]=ca.z;va[N+3]=ca.w;va[N+4]=X.x;va[N+5]=X.y;va[N+6]=X.z;va[N+7]=X.w;va[N+8]=Y.x;va[N+9]=Y.y;va[N+10]=Y.z;va[N+11]=Y.w;va[N+12]=ra.x;va[N+13]=ra.y;va[N+14]=ra.z;va[N+15]=ra.w;ca=Ua[R.a];X=Ua[R.b];Y=Ua[R.c];ra=Ua[R.d];wa[N]=ca.x;wa[N+1]=ca.y;wa[N+2]=ca.z;wa[N+3]=1;wa[N+4]=X.x;wa[N+5]=X.y;wa[N+6]=X.z;wa[N+7]=1;wa[N+8]=Y.x;wa[N+9]=Y.y;wa[N+10]=Y.z;wa[N+11]=1;wa[N+12]=ra.x;wa[N+13]=ra.y;wa[N+14]=ra.z;wa[N+15]=1;ca=Va[R.a];X=Va[R.b];Y=Va[R.c];ra=Va[R.d];ya[N]=ca.x;ya[N+1]=ca.y;ya[N+
+2]=ca.z;ya[N+3]=1;ya[N+4]=X.x;ya[N+5]=X.y;ya[N+6]=X.z;ya[N+7]=1;ya[N+8]=Y.x;ya[N+9]=Y.y;ya[N+10]=Y.z;ya[N+11]=1;ya[N+12]=ra.x;ya[N+13]=ra.y;ya[N+14]=ra.z;ya[N+15]=1;N+=16}if(Ka&&Qa.length){ca=Qa[R.a];X=Qa[R.b];Y=Qa[R.c];ra=Qa[R.d];za[Aa]=ca.r;za[Aa+1]=ca.g;za[Aa+2]=ca.b;za[Aa+3]=X.r;za[Aa+4]=X.g;za[Aa+5]=X.b;za[Aa+6]=Y.r;za[Aa+7]=Y.g;za[Aa+8]=Y.b;za[Aa+9]=ra.r;za[Aa+10]=ra.g;za[Aa+11]=ra.b;Aa+=12}if(Ma&&W.hasTangents){ca=Fa[R.a].tangent;X=Fa[R.b].tangent;Y=Fa[R.c].tangent;R=Fa[R.d].tangent;oa[ha]=
+ca.x;oa[ha+1]=ca.y;oa[ha+2]=ca.z;oa[ha+3]=ca.w;oa[ha+4]=X.x;oa[ha+5]=X.y;oa[ha+6]=X.z;oa[ha+7]=X.w;oa[ha+8]=Y.x;oa[ha+9]=Y.y;oa[ha+10]=Y.z;oa[ha+11]=Y.w;oa[ha+12]=R.x;oa[ha+13]=R.y;oa[ha+14]=R.z;oa[ha+15]=R.w;ha+=16}if(Ia)if(Ga.length==4&&U)for(R=0;R<4;R++){Ha=Ga[R];sa[ma]=Ha.x;sa[ma+1]=Ha.y;sa[ma+2]=Ha.z;ma+=3}else for(R=0;R<4;R++){sa[ma]=Ha.x;sa[ma+1]=Ha.y;sa[ma+2]=Ha.z;ma+=3}if(Ea&&La)for(R=0;R<4;R++){Ga=La[R];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(R=0;R<4;R++){La=Ca[R];Ta[qa]=La.u;Ta[qa+
+1]=La.v;qa+=2}if(Da){ja[na]=Q;ja[na+1]=Q+1;ja[na+2]=Q+2;ja[na+3]=Q;ja[na+4]=Q+2;ja[na+5]=Q+3;na+=6;ba[Ja]=Q;ba[Ja+1]=Q+1;ba[Ja+2]=Q;ba[Ja+3]=Q+3;ba[Ja+4]=Q+1;ba[Ja+5]=Q+2;ba[Ja+6]=Q+2;ba[Ja+7]=Q+3;Ja+=8;Q+=4}}}if(pa){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,E)}if(Ka&&Qa.length){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,za,E)}if(Ia){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,sa,E)}if(Ma&&
+W.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,oa,E)}if(Ea&&fa>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,E)}if(Ea&&qa>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ta,E)}if(Da){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ja,E);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ba,E)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,
+C.__webGLSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,wa,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ya,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,va,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,K,E)}}x(objlist,D,I,z,t)}L.__dirtyVertices=!1;L.__dirtyElements=!1;L.__dirtyUvs=!1;L.__dirtyNormals=!1;L.__dirtyTangents=!1;L.__dirtyColors=!1}else if(t instanceof THREE.Ribbon){if(!L.__webGLVertexBuffer){I=
+L;I.__webGLVertexBuffer=e.createBuffer();I.__webGLColorBuffer=e.createBuffer();I=L;z=I.vertices.length;I.__vertexArray=new Float32Array(z*3);I.__colorArray=new Float32Array(z*3);I.__webGLVertexCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}if(L.__dirtyVertices||L.__dirtyColors){I=L;z=e.DYNAMIC_DRAW;Q=void 0;Q=void 0;F=void 0;C=void 0;fa=I.vertices;E=I.colors;qa=fa.length;ka=E.length;na=I.__vertexArray;T=I.__colorArray;ma=I.__dirtyColors;if(I.__dirtyVertices){for(Q=0;Q<qa;Q++){F=fa[Q].position;C=
+Q*3;na[C]=F.x;na[C+1]=F.y;na[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,I.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,na,z)}if(ma){for(Q=0;Q<ka;Q++){color=E[Q];C=Q*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,I.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,z)}}x(objlist,D,0,L,t);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(t instanceof THREE.Line){if(!L.__webGLVertexBuffer){I=L;I.__webGLVertexBuffer=e.createBuffer();I.__webGLColorBuffer=e.createBuffer();I=L;z=I.vertices.length;
+I.__vertexArray=new Float32Array(z*3);I.__colorArray=new Float32Array(z*3);I.__webGLLineCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}if(L.__dirtyVertices||L.__dirtyColors){I=L;z=e.DYNAMIC_DRAW;Q=void 0;Q=void 0;F=void 0;C=void 0;fa=I.vertices;E=I.colors;qa=fa.length;ka=E.length;na=I.__vertexArray;T=I.__colorArray;ma=I.__dirtyColors;if(I.__dirtyVertices){for(Q=0;Q<qa;Q++){F=fa[Q].position;C=Q*3;na[C]=F.x;na[C+1]=F.y;na[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,I.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,
+na,z)}if(ma){for(Q=0;Q<ka;Q++){color=E[Q];C=Q*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,I.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,z)}}x(objlist,D,0,L,t);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(t instanceof THREE.ParticleSystem){if(!L.__webGLVertexBuffer){I=L;I.__webGLVertexBuffer=e.createBuffer();I.__webGLColorBuffer=e.createBuffer();I=L;z=I.vertices.length;I.__vertexArray=new Float32Array(z*3);I.__colorArray=new Float32Array(z*3);I.__sortArray=[];
+I.__webGLParticleCount=z;L.__dirtyVertices=!0;L.__dirtyColors=!0}(L.__dirtyVertices||L.__dirtyColors||t.sortParticles)&&b(L,e.DYNAMIC_DRAW,t,C);x(objlist,D,0,L,t);L.__dirtyVertices=!1;L.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&t instanceof THREE.MarchingCubes){L=D;if(L[0]==undefined){E.__webGLObjectsImmediate.push({object:t,opaque:{list:[],count:0},transparent:{list:[],count:0}});L[0]=1}}}};this.removeObject=function(l,y){var B,q;for(B=l.__webGLObjects.length-1;B>=0;B--){q=l.__webGLObjects[B].object;
+y==q&&l.__webGLObjects.splice(B,1)}};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",
 envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
 envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
@@ -286,20 +283,20 @@ THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightW
 THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
 THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",
 THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",
 THREE.Snippets.lights_vertex,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragment_shader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",
 THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
 THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};
-THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,f=c.length;for(d=0;d<f;d++){a=c[d];a.globalMatrix.extractPositionVector(this.soundPosition);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
+THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,f=c.length;for(d=0;d<f;d++){a=c[d];this.soundPosition.set(a.globalMatrix.n14,a.globalMatrix.n24,a.globalMatrix.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
-var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var n=0,w=h.length;n<w;n++){var q=new THREE.Vertex(h[n].position.clone());c&&b.localMatrix.multiplyVector3(q.position);g.push(q)}n=0;for(w=j.length;n<w;n++){h=j[n];var p,x=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+
-d,h.b+d,h.c+d,h.d+d));p.centroid.copy(h.centroid);p.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){q=x[c];p.vertexNormals.push(q.clone())}p.materials=h.materials.slice();k.push(p)}n=0;for(w=f.length;n<w;n++){d=f[n];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,
-b);b=f.loadCount=0;for(d=a.length;b<d;++b){f[b]=new Image;f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)};f[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(n in O.objects)if(!H.objects[n]){A=O.objects[n];if(o=H.geometries[A.geometry]){ea=[];for(i=0;i<A.materials.length;i++)ea[i]=H.materials[A.materials[i]];G=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(o,ea);object.position.set(G[0],
-G[1],G[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;H.scene.addObject(object);H.objects[n]=object}}}function h(V){return function(la){H.geometries[V]=la;g();W-=1;k()}}function k(){d({total_models:aa,total_textures:ba,loaded_models:aa-W,loaded_textures:ba-S},H);W==0&&S==0&&c(H)}var j,m,n,w,q,p,x,A,G,v,I,o,M,e,ea,O,P,W,S,aa,ba,H;O=f.data;P=new THREE.Loader;S=W=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
-lights:{},fogs:{}};f=function(){S-=1;k()};for(q in O.cameras){v=O.cameras[q];if(v.type=="perspective")M=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}G=v.position;v=v.target;M.position.set(G[0],G[1],G[2]);M.target.position.set(v[0],v[1],v[2]);H.cameras[q]=M}for(w in O.lights){q=O.lights[w];if(q.type=="directional"){G=q.direction;light=new THREE.DirectionalLight;light.position.set(G[0],
-G[1],G[2]);light.position.normalize()}else if(q.type=="point"){G=q.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}v=q.color;i=q.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);H.scene.addLight(light);H.lights[w]=light}for(p in O.fogs){w=O.fogs[p];if(w.type=="linear")e=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(e=new THREE.FogExp2(0,w.density));v=w.color;e.color.setRGB(v[0],v[1],v[2]);H.fogs[p]=e}if(H.cameras&&O.defaults.camera)H.currentCamera=H.cameras[O.defaults.camera];
-if(H.fogs&&O.defaults.fog)H.scene.fog=H.fogs[O.defaults.fog];v=O.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(v[0],v[1],v[2]);H.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){p=O.geometries[j];if(p.type=="bin_mesh"||p.type=="ascii_mesh")W+=1}aa=W;for(j in O.geometries){p=O.geometries[j];if(p.type=="cube"){o=new Cube(p.width,p.height,p.depth,p.segments_width,p.segments_height,null,p.flipped,p.sides);H.geometries[j]=o}else if(p.type=="plane"){o=new Plane(p.width,p.height,p.segments_width,
-p.segments_height);H.geometries[j]=o}else if(p.type=="sphere"){o=new Sphere(p.radius,p.segments_width,p.segments_height);H.geometries[j]=o}else if(p.type=="cylinder"){o=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);H.geometries[j]=o}else if(p.type=="torus"){o=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);H.geometries[j]=o}else if(p.type=="icosahedron"){o=new Icosahedron(p.subdivisions);H.geometries[j]=o}else if(p.type=="bin_mesh")P.loadBinary({model:p.url,callback:h(j)});
-else p.type=="ascii_mesh"&&P.loadAscii({model:p.url,callback:h(j)})}for(x in O.textures){j=O.textures[x];S+=j.url instanceof Array?j.url.length:1}ba=S;for(x in O.textures){j=O.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)p=ImageUtils.loadTextureCube(j.url,j.mapping,f);else{p=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.min_filter]!=undefined)p.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=undefined)p.mag_filter=
-THREE[j.mag_filter]}H.textures[x]=p}for(m in O.materials){x=O.materials[m];for(I in x.parameters)if(I=="env_map"||I=="map"||I=="light_map")x.parameters[I]=H.textures[x.parameters[I]];else if(I=="shading")x.parameters[I]=x.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")x.parameters[I]=THREE[x.parameters[I]]?THREE[x.parameters[I]]:THREE.NormalBlending;else I=="combine"&&(x.parameters[I]=x.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=
-new THREE[x.type](x.parameters);H.materials[m]=x}g();b(H)}},addMesh:function(a,b,c,d,f,g,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,
+var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var n=0,w=h.length;n<w;n++){var u=new THREE.Vertex(h[n].position.clone());c&&b.localMatrix.multiplyVector3(u.position);g.push(u)}n=0;for(w=j.length;n<w;n++){h=j[n];var p,x=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+
+d,h.b+d,h.c+d,h.d+d));p.centroid.copy(h.centroid);p.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){u=x[c];p.vertexNormals.push(u.clone())}p.materials=h.materials.slice();k.push(p)}n=0;for(w=f.length;n<w;n++){d=f[n];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,
+b);b=f.loadCount=0;for(d=a.length;b<d;++b){f[b]=new Image;f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)};f[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(n in O.objects)if(!J.objects[n]){A=O.objects[n];if(o=J.geometries[A.geometry]){da=[];for(i=0;i<A.materials.length;i++)da[i]=J.materials[A.materials[i]];G=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(o,da);object.position.set(G[0],
+G[1],G[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;J.scene.addObject(object);J.objects[n]=object}}}function h($){return function(ta){J.geometries[$]=ta;g();V-=1;k()}}function k(){d({total_models:Z,total_textures:ea,loaded_models:Z-V,loaded_textures:ea-S},J);V==0&&S==0&&c(J)}var j,m,n,w,u,p,x,A,G,v,H,o,M,e,da,O,P,V,S,Z,ea,J;O=f.data;P=new THREE.Loader;S=V=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
+fogs:{}};f=function(){S-=1;k()};for(u in O.cameras){v=O.cameras[u];if(v.type=="perspective")M=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}G=v.position;v=v.target;M.position.set(G[0],G[1],G[2]);M.target.position.set(v[0],v[1],v[2]);J.cameras[u]=M}for(w in O.lights){u=O.lights[w];if(u.type=="directional"){G=u.direction;light=new THREE.DirectionalLight;light.position.set(G[0],
+G[1],G[2]);light.position.normalize()}else if(u.type=="point"){G=u.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}v=u.color;i=u.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);J.scene.addLight(light);J.lights[w]=light}for(p in O.fogs){w=O.fogs[p];if(w.type=="linear")e=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(e=new THREE.FogExp2(0,w.density));v=w.color;e.color.setRGB(v[0],v[1],v[2]);J.fogs[p]=e}if(J.cameras&&O.defaults.camera)J.currentCamera=J.cameras[O.defaults.camera];
+if(J.fogs&&O.defaults.fog)J.scene.fog=J.fogs[O.defaults.fog];v=O.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(v[0],v[1],v[2]);J.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){p=O.geometries[j];if(p.type=="bin_mesh"||p.type=="ascii_mesh")V+=1}Z=V;for(j in O.geometries){p=O.geometries[j];if(p.type=="cube"){o=new Cube(p.width,p.height,p.depth,p.segments_width,p.segments_height,null,p.flipped,p.sides);J.geometries[j]=o}else if(p.type=="plane"){o=new Plane(p.width,p.height,p.segments_width,
+p.segments_height);J.geometries[j]=o}else if(p.type=="sphere"){o=new Sphere(p.radius,p.segments_width,p.segments_height);J.geometries[j]=o}else if(p.type=="cylinder"){o=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);J.geometries[j]=o}else if(p.type=="torus"){o=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);J.geometries[j]=o}else if(p.type=="icosahedron"){o=new Icosahedron(p.subdivisions);J.geometries[j]=o}else if(p.type=="bin_mesh")P.loadBinary({model:p.url,callback:h(j)});
+else p.type=="ascii_mesh"&&P.loadAscii({model:p.url,callback:h(j)})}for(x in O.textures){j=O.textures[x];S+=j.url instanceof Array?j.url.length:1}ea=S;for(x in O.textures){j=O.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)p=ImageUtils.loadTextureCube(j.url,j.mapping,f);else{p=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.min_filter]!=undefined)p.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=undefined)p.mag_filter=
+THREE[j.mag_filter]}J.textures[x]=p}for(m in O.materials){x=O.materials[m];for(H in x.parameters)if(H=="env_map"||H=="map"||H=="light_map")x.parameters[H]=J.textures[x.parameters[H]];else if(H=="shading")x.parameters[H]=x.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")x.parameters[H]=THREE[x.parameters[H]]?THREE[x.parameters[H]]:THREE.NormalBlending;else H=="combine"&&(x.parameters[H]=x.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=
+new THREE[x.type](x.parameters);J.materials[m]=x}g();b(J)}},addMesh:function(a,b,c,d,f,g,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragment_shader:d.fragment_shader,vertex_shader:d.vertex_shader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,
 b,b,1,1,null,!0),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
 b,b,1,1,null,!0),c);a.addObject(b);return b},addPanoramaCube:function(a,b,c){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,
 b,b,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var d=b/2;b=new Plane(b,b);var f=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
 b,b,1,1,d,!0),new THREE.MeshFaceMaterial);a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var d=b/2;b=new Plane(b,b);var f=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
 SceneUtils.addMesh(a,b,1,0,-d,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 SceneUtils.addMesh(a,b,1,0,-d,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
@@ -311,38 +308,38 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(A,G,v,I,o,M,e,ea){var O,P,W=d||1,S=f||1,aa=W+1,ba=S+1,H=o/2,V=M/2;o/=W;var la=M/S,Y=m.vertices.length;if(A=="x"&&G=="y"||A=="y"&&G=="x")O="z";else if(A=="x"&&G=="z"||A=="z"&&G=="x")O="y";
-else if(A=="z"&&G=="y"||A=="y"&&G=="z")O="x";for(P=0;P<ba;P++)for(M=0;M<aa;M++){var ka=new THREE.Vector3;ka[A]=(M*o-H)*v;ka[G]=(P*la-V)*I;ka[O]=e;m.vertices.push(new THREE.Vertex(ka))}for(P=0;P<S;P++)for(M=0;M<W;M++){m.faces.push(new THREE.Face4(M+aa*P+Y,M+aa*(P+1)+Y,M+1+aa*(P+1)+Y,M+1+aa*P+Y,null,ea));m.uvs.push([new THREE.UV(M/W,P/S),new THREE.UV(M/W,(P+1)/S),new THREE.UV((M+1)/W,(P+1)/S),new THREE.UV((M+1)/W,P/S)])}}THREE.Geometry.call(this);var m=this,n=a/2,w=b/2,q=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(A,G,v,H,o,M,e,da){var O,P,V=d||1,S=f||1,Z=V+1,ea=S+1,J=o/2,$=M/2;o/=V;var ta=M/S,aa=m.vertices.length;if(A=="x"&&G=="y"||A=="y"&&G=="x")O="z";else if(A=="x"&&G=="z"||A=="z"&&G=="x")O="y";
+else if(A=="z"&&G=="y"||A=="y"&&G=="z")O="x";for(P=0;P<ea;P++)for(M=0;M<Z;M++){var la=new THREE.Vector3;la[A]=(M*o-J)*v;la[G]=(P*ta-$)*H;la[O]=e;m.vertices.push(new THREE.Vertex(la))}for(P=0;P<S;P++)for(M=0;M<V;M++){m.faces.push(new THREE.Face4(M+Z*P+aa,M+Z*(P+1)+aa,M+1+Z*(P+1)+aa,M+1+Z*P+aa,null,da));m.uvs.push([new THREE.UV(M/V,P/S),new THREE.UV(M/V,(P+1)/S),new THREE.UV((M+1)/V,(P+1)/S),new THREE.UV((M+1)/V,P/S)])}}THREE.Geometry.call(this);var m=this,n=a/2,w=b/2,u=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
 Array)this.materials=g;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-n,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,n,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,w,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-w,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,
 Array)this.materials=g;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-n,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,n,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,w,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-w,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,
-a,b,q,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-q,this.materials[5]);(function(){for(var A=[],G=[],v=0,I=m.vertices.length;v<I;v++){for(var o=m.vertices[v],M=!1,e=0,ea=A.length;e<ea;e++){var O=A[e];if(o.position.x==O.position.x&&o.position.y==O.position.y&&o.position.z==O.position.z){G[v]=e;M=!0;break}}if(!M){G[v]=A.length;A.push(new THREE.Vertex(o.position.clone()))}}v=0;for(I=m.faces.length;v<I;v++){o=m.faces[v];o.a=G[o.a];o.b=G[o.b];o.c=G[o.c];o.d=G[o.d]}m.vertices=A})();this.computeCentroids();
+a,b,u,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-u,this.materials[5]);(function(){for(var A=[],G=[],v=0,H=m.vertices.length;v<H;v++){for(var o=m.vertices[v],M=!1,e=0,da=A.length;e<da;e++){var O=A[e];if(o.position.x==O.position.x&&o.position.y==O.position.y&&o.position.z==O.position.z){G[v]=e;M=!0;break}}if(!M){G[v]=A.length;A.push(new THREE.Vertex(o.position.clone()))}}v=0;for(H=m.faces.length;v<H;v++){o=m.faces[v];o.a=G[o.a];o.b=G[o.b];o.c=G[o.c];o.d=G[o.d]}m.vertices=A})();this.computeCentroids();
 this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,b,c,d,f){function g(m,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,d+f);for(j=a+a/2;j<
 var Cylinder=function(a,b,c,d,f){function g(m,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,d+f);for(j=a+a/2;j<
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Plane=function(a,b,c,d){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;d=d||1;var k=c+1,j=d+1;a/=c;var m=b/d;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*m-h),0)));for(f=0;f<d;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/d),new THREE.UV(b/c,(f+1)/d),new THREE.UV((b+1)/c,(f+1)/d),new THREE.UV((b+1)/c,f/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 var Plane=function(a,b,c,d){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;d=d||1;var k=c+1,j=d+1;a/=c;var m=b/d;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*m-h),0)));for(f=0;f<d;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/d),new THREE.UV(b/c,(f+1)/d),new THREE.UV((b+1)/c,(f+1)/d),new THREE.UV((b+1)/c,f/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,b,c){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),m=[],n=0;for(d=0;d<g;d++){var w=2*d/g,q=j*Math.sin(w*f);w=j*Math.cos(w*f);(c==0||c==h)&&d>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,q)))-1);m.push(n)}b.push(m)}var p,x,A;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];k=b[c][m?g-1:d];j=b[c-1][m?g-1:d];m=b[c-1][m?
-0:d+1];q=c/(f-1);p=(c-1)/(f-1);x=(d+1)/g;w=d/g;n=new THREE.UV(1-x,q);q=new THREE.UV(1-w,q);w=new THREE.UV(1-w,p);var G=new THREE.UV(1-x,p);if(c<b.length-1){p=this.vertices[h].position.clone();x=this.vertices[k].position.clone();A=this.vertices[j].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,q,w])}if(c>1){p=this.vertices[h].position.clone();
+var Sphere=function(a,b,c){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),m=[],n=0;for(d=0;d<g;d++){var w=2*d/g,u=j*Math.sin(w*f);w=j*Math.cos(w*f);(c==0||c==h)&&d>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(n)}b.push(m)}var p,x,A;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];k=b[c][m?g-1:d];j=b[c-1][m?g-1:d];m=b[c-1][m?
+0:d+1];u=c/(f-1);p=(c-1)/(f-1);x=(d+1)/g;w=d/g;n=new THREE.UV(1-x,u);u=new THREE.UV(1-w,u);w=new THREE.UV(1-w,p);var G=new THREE.UV(1-x,p);if(c<b.length-1){p=this.vertices[h].position.clone();x=this.vertices[k].position.clone();A=this.vertices[j].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,u,w])}if(c>1){p=this.vertices[h].position.clone();
 x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,w,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,w,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var f=b/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([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
 var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var f=b/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([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
 1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;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();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
 1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;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();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var Icosahedron=function(a){function b(w,q,p){var x=Math.sqrt(w*w+q*q+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,q/x,p/x)))-1}function c(w,q,p,x){x.faces.push(new THREE.Face3(w,q,p))}function d(w,q){var p=f.vertices[w].position,x=f.vertices[q].position;return b((p.x+x.x)/2,(p.y+x.y)/2,(p.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;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
+var Icosahedron=function(a){function b(w,u,p){var x=Math.sqrt(w*w+u*u+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,u/x,p/x)))-1}function c(w,u,p,x){x.faces.push(new THREE.Face3(w,u,p))}function d(w,u){var p=f.vertices[w].position,x=f.vertices[u].position;return b((p.x+x.x)/2,(p.y+x.y)/2,(p.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;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),n=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,n,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
 1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),n=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,n,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
 n,m,h);c(j,m,n,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 n,m,h);c(j,m,n,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function LathedObject(a,b,c){THREE.Geometry.call(this);c=c||2*Math.PI;b=c/(b||12);for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;d[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.0010;m+=b){for(k=0;k<d.length;k++)if(m<c){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],
+function LathedObject(a,b,c){THREE.Geometry.call(this);c=c||2*Math.PI;b=c/(b||12);for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;d[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(b),m=0;m<=c+0.001;m+=b){for(k=0;k<d.length;k++)if(m<c){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],
 g[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 g[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;f[g]=this.lerp(n[c],n[c+3],h);f[g+1]=this.lerp(n[c+1],n[c+4],h);f[g+2]=this.lerp(n[c+2],n[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;f[g]=this.lerp(n[c],n[c+3],h);f[g+1]=this.lerp(n[c+1],n[c+4],h);f[g+2]=this.lerp(n[c+2],n[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
 2]=m;d=c+this.yd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
 2]=m;d=c+this.yd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,m=g+this.yd,n=g+this.zd,w=j+this.yd,q=j+this.zd,p=g+this.yd+this.zd,x=j+this.yd+this.zd,A=0,G=this.field[g],v=this.field[j],I=this.field[m],o=this.field[w],M=this.field[n],e=this.field[q],ea=this.field[p],O=this.field[x];G<h&&(A|=1);v<h&&(A|=2);I<h&&(A|=8);o<h&&(A|=4);M<h&&(A|=16);e<h&&(A|=32);ea<h&&(A|=128);O<h&&(A|=64);var P=THREE.edgeTable[A];if(P==0)return 0;
-var W=this.delta,S=c+W,aa=d+W;W=f+W;if(P&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,G,v)}if(P&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,S,d,f,v,o)}if(P&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,aa,f,I,o)}if(P&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,G,I)}if(P&16){this.compNorm(n);this.compNorm(q);this.VIntX(n*3,this.vlist,this.nlist,12,h,c,d,
-W,M,e)}if(P&32){this.compNorm(q);this.compNorm(x);this.VIntY(q*3,this.vlist,this.nlist,15,h,S,d,W,e,O)}if(P&64){this.compNorm(p);this.compNorm(x);this.VIntX(p*3,this.vlist,this.nlist,18,h,c,aa,W,ea,O)}if(P&128){this.compNorm(n);this.compNorm(p);this.VIntY(n*3,this.vlist,this.nlist,21,h,c,d,W,M,ea)}if(P&256){this.compNorm(g);this.compNorm(n);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,G,M)}if(P&512){this.compNorm(j);this.compNorm(q);this.VIntZ(j*3,this.vlist,this.nlist,27,h,S,d,f,v,e)}if(P&1024){this.compNorm(w);
-this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,S,aa,f,o,O)}if(P&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,aa,f,I,ea)}A<<=4;for(h=g=0;THREE.triTable[A+h]!=-1;){c=A+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
+this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,m=g+this.yd,n=g+this.zd,w=j+this.yd,u=j+this.zd,p=g+this.yd+this.zd,x=j+this.yd+this.zd,A=0,G=this.field[g],v=this.field[j],H=this.field[m],o=this.field[w],M=this.field[n],e=this.field[u],da=this.field[p],O=this.field[x];G<h&&(A|=1);v<h&&(A|=2);H<h&&(A|=8);o<h&&(A|=4);M<h&&(A|=16);e<h&&(A|=32);da<h&&(A|=128);O<h&&(A|=64);var P=THREE.edgeTable[A];if(P==0)return 0;
+var V=this.delta,S=c+V,Z=d+V;V=f+V;if(P&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,G,v)}if(P&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,S,d,f,v,o)}if(P&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,Z,f,H,o)}if(P&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,G,H)}if(P&16){this.compNorm(n);this.compNorm(u);this.VIntX(n*3,this.vlist,this.nlist,12,h,c,d,V,
+M,e)}if(P&32){this.compNorm(u);this.compNorm(x);this.VIntY(u*3,this.vlist,this.nlist,15,h,S,d,V,e,O)}if(P&64){this.compNorm(p);this.compNorm(x);this.VIntX(p*3,this.vlist,this.nlist,18,h,c,Z,V,da,O)}if(P&128){this.compNorm(n);this.compNorm(p);this.VIntY(n*3,this.vlist,this.nlist,21,h,c,d,V,M,da)}if(P&256){this.compNorm(g);this.compNorm(n);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,G,M)}if(P&512){this.compNorm(j);this.compNorm(u);this.VIntZ(j*3,this.vlist,this.nlist,27,h,S,d,f,v,e)}if(P&1024){this.compNorm(w);
+this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,S,Z,f,o,O)}if(P&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,Z,f,H,da)}A<<=4;for(h=g=0;THREE.triTable[A+h]!=-1;){c=A+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
 3]=c[g];this.positionArray[j+4]=c[g+1];this.positionArray[j+5]=c[g+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=d[f];this.normalArray[j+1]=d[f+1];this.normalArray[j+2]=d[f+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
 3]=c[g];this.positionArray[j+4]=c[g+1];this.positionArray[j+5]=c[g+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=d[f];this.normalArray[j+1]=d[f+1];this.normalArray[j+2]=d[f+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=d*this.size,n=c*this.size,w=Math.floor(j-k);w<1&&(w=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var q=Math.floor(m-k);q<1&&(q=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k);
-k>this.size-1&&(k=this.size-1);for(var x,A,G,v,I,o;w<j;w++){n=this.size2*w;A=w/this.size-f;I=A*A;for(A=q;A<m;A++){G=n+this.size*A;x=A/this.size-d;o=x*x;for(x=p;x<k;x++){v=x/this.size-c;v=g/(1.0E-6+v*v+o+I)-h;v>0&&(this.field[G+x]+=v)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,n=this.yd,w=this.zd,q=this.field,p=m*Math.sqrt(c/d);p>m&&(p=m);for(f=0;f<p;f++){g=f/m;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=f+g*n;for(h=0;h<m;h++)q[w*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
-h,k,j,m,n=this.size,w=this.yd,q=this.zd,p=this.field,x=n*Math.sqrt(c/d);x>n&&(x=n);for(g=0;g<x;g++){f=g/n;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*w;for(f=0;f<n;f++){m=j+f;for(h=0;h<n;h++)p[q*h+m]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=k}}}};this.reset=function(){var c;
-for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var d,f,g,h,k,j,m,n,w,q=this.size-2;for(h=1;h<q;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<q;g++){n=w+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<q;f++){k=(f-this.halfsize)/this.halfsize;d=n+f;this.polygonize(k,j,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,m,n,w,q;for(g=
-0;g<f.count;g++){m=g*3;w=m+1;q=m+2;h=f.positionArray[m];k=f.positionArray[w];j=f.positionArray[q];n=new THREE.Vector3(h,k,j);h=f.normalArray[m];k=f.normalArray[w];j=f.normalArray[q];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(n,m);d.vertices.push(m)}nfaces=f.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;w=m+1;q=m+2;n=d.vertices[m].normal;h=d.vertices[w].normal;k=d.vertices[q].normal;m=new THREE.Face3(m,w,q,[n,h,k]);d.faces.push(m)}c+=nfaces;f.count=0});d.sortFacesByMaterial();return d};
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=d*this.size,n=c*this.size,w=Math.floor(j-k);w<1&&(w=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var u=Math.floor(m-k);u<1&&(u=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k);
+k>this.size-1&&(k=this.size-1);for(var x,A,G,v,H,o;w<j;w++){n=this.size2*w;A=w/this.size-f;H=A*A;for(A=u;A<m;A++){G=n+this.size*A;x=A/this.size-d;o=x*x;for(x=p;x<k;x++){v=x/this.size-c;v=g/(1.0E-6+v*v+o+H)-h;v>0&&(this.field[G+x]+=v)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,n=this.yd,w=this.zd,u=this.field,p=m*Math.sqrt(c/d);p>m&&(p=m);for(f=0;f<p;f++){g=f/m;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=f+g*n;for(h=0;h<m;h++)u[w*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
+h,k,j,m,n=this.size,w=this.yd,u=this.zd,p=this.field,x=n*Math.sqrt(c/d);x>n&&(x=n);for(g=0;g<x;g++){f=g/n;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*w;for(f=0;f<n;f++){m=j+f;for(h=0;h<n;h++)p[u*h+m]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=k}}}};this.reset=function(){var c;
+for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var d,f,g,h,k,j,m,n,w,u=this.size-2;for(h=1;h<u;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<u;g++){n=w+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<u;f++){k=(f-this.halfsize)/this.halfsize;d=n+f;this.polygonize(k,j,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,m,n,w,u;for(g=
+0;g<f.count;g++){m=g*3;w=m+1;u=m+2;h=f.positionArray[m];k=f.positionArray[w];j=f.positionArray[u];n=new THREE.Vector3(h,k,j);h=f.normalArray[m];k=f.normalArray[w];j=f.normalArray[u];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(n,m);d.vertices.push(m)}nfaces=f.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;w=m+1;u=m+2;n=d.vertices[m].normal;h=d.vertices[w].normal;k=d.vertices[u].normal;m=new THREE.Face3(m,w,u,[n,h,k]);d.faces.push(m)}c+=nfaces;f.count=0});d.sortFacesByMaterial();return d};
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
@@ -372,24 +369,24 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
 b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,c,d)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:
 b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,c,d)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:
 THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,f,d,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,d,f,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;
 THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,f,d,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,d,f,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
-createBinModel:function(a,b,c,d){var f=function(g){function h(z,D){var F=n(z,D),T=n(z,D+1),Q=n(z,D+2),fa=n(z,D+3),ma=(fa<<1&255|Q>>7)-127;F|=(Q&127)<<16|T<<8;if(F==0&&ma==-127)return 0;return(1-2*(fa>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,ma)}function k(z,D){var F=n(z,D),T=n(z,D+1),Q=n(z,D+2);return(n(z,D+3)<<24)+(Q<<16)+(T<<8)+F}function j(z,D){var F=n(z,D);return(n(z,D+1)<<8)+F}function m(z,D){var F=n(z,D);return F>127?F-256:F}function n(z,D){return z.charCodeAt(D)&255}function w(z){var D,F,T;D=
-k(a,z);F=k(a,z+ea);T=k(a,z+O);z=j(a,z+P);THREE.Loader.prototype.f3(v,D,F,T,z)}function q(z){var D,F,T,Q,fa,ma;D=k(a,z);F=k(a,z+ea);T=k(a,z+O);Q=j(a,z+P);fa=k(a,z+W);ma=k(a,z+S);z=k(a,z+aa);THREE.Loader.prototype.f3n(v,M,D,F,T,Q,fa,ma,z)}function p(z){var D,F,T,Q;D=k(a,z);F=k(a,z+ba);T=k(a,z+H);Q=k(a,z+V);z=j(a,z+la);THREE.Loader.prototype.f4(v,D,F,T,Q,z)}function x(z){var D,F,T,Q,fa,ma,ra,oa;D=k(a,z);F=k(a,z+ba);T=k(a,z+H);Q=k(a,z+V);fa=j(a,z+la);ma=k(a,z+Y);ra=k(a,z+ka);oa=k(a,z+ia);z=k(a,z+ga);
-THREE.Loader.prototype.f4n(v,M,D,F,T,Q,fa,ma,ra,oa,z)}function A(z){var D,F;D=k(a,z);F=k(a,z+ua);z=k(a,z+xa);THREE.Loader.prototype.uv3(v.uvs,e[D*2],e[D*2+1],e[F*2],e[F*2+1],e[z*2],e[z*2+1])}function G(z){var D,F,T;D=k(a,z);F=k(a,z+l);T=k(a,z+y);z=k(a,z+B);THREE.Loader.prototype.uv4(v.uvs,e[D*2],e[D*2+1],e[F*2],e[F*2+1],e[T*2],e[T*2+1],e[z*2],e[z*2+1])}var v=this,I=0,o,M=[],e=[],ea,O,P,W,S,aa,ba,H,V,la,Y,ka,ia,ga,ua,xa,l,y,B,t,u,E,C,J,L;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,
-d,g);o={signature:a.substr(I,8),header_bytes:n(a,I+8),vertex_coordinate_bytes:n(a,I+9),normal_coordinate_bytes:n(a,I+10),uv_coordinate_bytes:n(a,I+11),vertex_index_bytes:n(a,I+12),normal_index_bytes:n(a,I+13),uv_index_bytes:n(a,I+14),material_index_bytes:n(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),
-nquad_smooth_uv:k(a,I+16+40)};I+=o.header_bytes;ea=o.vertex_index_bytes;O=o.vertex_index_bytes*2;P=o.vertex_index_bytes*3;W=o.vertex_index_bytes*3+o.material_index_bytes;S=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;aa=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;ba=o.vertex_index_bytes;H=o.vertex_index_bytes*2;V=o.vertex_index_bytes*3;la=o.vertex_index_bytes*4;Y=o.vertex_index_bytes*4+o.material_index_bytes;ka=o.vertex_index_bytes*4+o.material_index_bytes+
-o.normal_index_bytes;ia=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;ga=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;ua=o.uv_index_bytes;xa=o.uv_index_bytes*2;l=o.uv_index_bytes;y=o.uv_index_bytes*2;B=o.uv_index_bytes*3;g=o.vertex_index_bytes*3+o.material_index_bytes;L=o.vertex_index_bytes*4+o.material_index_bytes;t=o.ntri_flat*g;u=o.ntri_smooth*(g+o.normal_index_bytes*3);E=o.ntri_flat_uv*(g+o.uv_index_bytes*3);C=o.ntri_smooth_uv*(g+o.normal_index_bytes*
-3+o.uv_index_bytes*3);J=o.nquad_flat*L;g=o.nquad_smooth*(L+o.normal_index_bytes*4);L=o.nquad_flat_uv*(L+o.uv_index_bytes*4);I+=function(z){for(var D,F,T,Q=o.vertex_coordinate_bytes*3,fa=z+o.nvertices*Q;z<fa;z+=Q){D=h(a,z);F=h(a,z+o.vertex_coordinate_bytes);T=h(a,z+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,D,F,T)}return o.nvertices*Q}(I);I+=function(z){for(var D,F,T,Q=o.normal_coordinate_bytes*3,fa=z+o.nnormals*Q;z<fa;z+=Q){D=m(a,z);F=m(a,z+o.normal_coordinate_bytes);T=m(a,z+o.normal_coordinate_bytes*
-2);M.push(D/127,F/127,T/127)}return o.nnormals*Q}(I);I+=function(z){for(var D,F,T=o.uv_coordinate_bytes*2,Q=z+o.nuvs*T;z<Q;z+=T){D=h(a,z);F=h(a,z+o.uv_coordinate_bytes);e.push(D,F)}return o.nuvs*T}(I);t=I+t;u=t+u;E=u+E;C=E+C;J=C+J;g=J+g;L=g+L;(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes,T=F+o.uv_index_bytes*3,Q=z+o.ntri_flat_uv*T;for(D=z;D<Q;D+=T){w(D);A(D+F)}return Q-z})(u);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,T=F+o.uv_index_bytes*
-3,Q=z+o.ntri_smooth_uv*T;for(D=z;D<Q;D+=T){q(D);A(D+F)}return Q-z})(E);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes,T=F+o.uv_index_bytes*4,Q=z+o.nquad_flat_uv*T;for(D=z;D<Q;D+=T){p(D);G(D+F)}return Q-z})(g);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,T=F+o.uv_index_bytes*4,Q=z+o.nquad_smooth_uv*T;for(D=z;D<Q;D+=T){x(D);G(D+F)}return Q-z})(L);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes,T=z+o.ntri_flat*F;for(D=
-z;D<T;D+=F)w(D);return T-z})(I);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,T=z+o.ntri_smooth*F;for(D=z;D<T;D+=F)q(D);return T-z})(t);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes,T=z+o.nquad_flat*F;for(D=z;D<T;D+=F)p(D);return T-z})(C);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,T=z+o.nquad_smooth*F;for(D=z;D<T;D+=F)x(D);return T-z})(J);this.computeCentroids();this.computeFaceNormals();
+createBinModel:function(a,b,c,d){var f=function(g){function h(z,D){var F=n(z,D),T=n(z,D+1),Q=n(z,D+2),fa=n(z,D+3),ka=(fa<<1&255|Q>>7)-127;F|=(Q&127)<<16|T<<8;if(F==0&&ka==-127)return 0;return(1-2*(fa>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,ka)}function k(z,D){var F=n(z,D),T=n(z,D+1),Q=n(z,D+2);return(n(z,D+3)<<24)+(Q<<16)+(T<<8)+F}function j(z,D){var F=n(z,D);return(n(z,D+1)<<8)+F}function m(z,D){var F=n(z,D);return F>127?F-256:F}function n(z,D){return z.charCodeAt(D)&255}function w(z){var D,F,T;D=
+k(a,z);F=k(a,z+da);T=k(a,z+O);z=j(a,z+P);THREE.Loader.prototype.f3(v,D,F,T,z)}function u(z){var D,F,T,Q,fa,ka;D=k(a,z);F=k(a,z+da);T=k(a,z+O);Q=j(a,z+P);fa=k(a,z+V);ka=k(a,z+S);z=k(a,z+Z);THREE.Loader.prototype.f3n(v,M,D,F,T,Q,fa,ka,z)}function p(z){var D,F,T,Q;D=k(a,z);F=k(a,z+ea);T=k(a,z+J);Q=k(a,z+$);z=j(a,z+ta);THREE.Loader.prototype.f4(v,D,F,T,Q,z)}function x(z){var D,F,T,Q,fa,ka,qa,na;D=k(a,z);F=k(a,z+ea);T=k(a,z+J);Q=k(a,z+$);fa=j(a,z+ta);ka=k(a,z+aa);qa=k(a,z+la);na=k(a,z+ia);z=k(a,z+ga);
+THREE.Loader.prototype.f4n(v,M,D,F,T,Q,fa,ka,qa,na,z)}function A(z){var D,F;D=k(a,z);F=k(a,z+ua);z=k(a,z+xa);THREE.Loader.prototype.uv3(v.uvs,e[D*2],e[D*2+1],e[F*2],e[F*2+1],e[z*2],e[z*2+1])}function G(z){var D,F,T;D=k(a,z);F=k(a,z+l);T=k(a,z+y);z=k(a,z+B);THREE.Loader.prototype.uv4(v.uvs,e[D*2],e[D*2+1],e[F*2],e[F*2+1],e[T*2],e[T*2+1],e[z*2],e[z*2+1])}var v=this,H=0,o,M=[],e=[],da,O,P,V,S,Z,ea,J,$,ta,aa,la,ia,ga,ua,xa,l,y,B,q,t,E,C,I,L;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,
+d,g);o={signature:a.substr(H,8),header_bytes:n(a,H+8),vertex_coordinate_bytes:n(a,H+9),normal_coordinate_bytes:n(a,H+10),uv_coordinate_bytes:n(a,H+11),vertex_index_bytes:n(a,H+12),normal_index_bytes:n(a,H+13),uv_index_bytes:n(a,H+14),material_index_bytes:n(a,H+15),nvertices:k(a,H+16),nnormals:k(a,H+16+4),nuvs:k(a,H+16+8),ntri_flat:k(a,H+16+12),ntri_smooth:k(a,H+16+16),ntri_flat_uv:k(a,H+16+20),ntri_smooth_uv:k(a,H+16+24),nquad_flat:k(a,H+16+28),nquad_smooth:k(a,H+16+32),nquad_flat_uv:k(a,H+16+36),
+nquad_smooth_uv:k(a,H+16+40)};H+=o.header_bytes;da=o.vertex_index_bytes;O=o.vertex_index_bytes*2;P=o.vertex_index_bytes*3;V=o.vertex_index_bytes*3+o.material_index_bytes;S=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Z=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;ea=o.vertex_index_bytes;J=o.vertex_index_bytes*2;$=o.vertex_index_bytes*3;ta=o.vertex_index_bytes*4;aa=o.vertex_index_bytes*4+o.material_index_bytes;la=o.vertex_index_bytes*4+o.material_index_bytes+
+o.normal_index_bytes;ia=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;ga=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;ua=o.uv_index_bytes;xa=o.uv_index_bytes*2;l=o.uv_index_bytes;y=o.uv_index_bytes*2;B=o.uv_index_bytes*3;g=o.vertex_index_bytes*3+o.material_index_bytes;L=o.vertex_index_bytes*4+o.material_index_bytes;q=o.ntri_flat*g;t=o.ntri_smooth*(g+o.normal_index_bytes*3);E=o.ntri_flat_uv*(g+o.uv_index_bytes*3);C=o.ntri_smooth_uv*(g+o.normal_index_bytes*
+3+o.uv_index_bytes*3);I=o.nquad_flat*L;g=o.nquad_smooth*(L+o.normal_index_bytes*4);L=o.nquad_flat_uv*(L+o.uv_index_bytes*4);H+=function(z){for(var D,F,T,Q=o.vertex_coordinate_bytes*3,fa=z+o.nvertices*Q;z<fa;z+=Q){D=h(a,z);F=h(a,z+o.vertex_coordinate_bytes);T=h(a,z+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,D,F,T)}return o.nvertices*Q}(H);H+=function(z){for(var D,F,T,Q=o.normal_coordinate_bytes*3,fa=z+o.nnormals*Q;z<fa;z+=Q){D=m(a,z);F=m(a,z+o.normal_coordinate_bytes);T=m(a,z+o.normal_coordinate_bytes*
+2);M.push(D/127,F/127,T/127)}return o.nnormals*Q}(H);H+=function(z){for(var D,F,T=o.uv_coordinate_bytes*2,Q=z+o.nuvs*T;z<Q;z+=T){D=h(a,z);F=h(a,z+o.uv_coordinate_bytes);e.push(D,F)}return o.nuvs*T}(H);q=H+q;t=q+t;E=t+E;C=E+C;I=C+I;g=I+g;L=g+L;(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes,T=F+o.uv_index_bytes*3,Q=z+o.ntri_flat_uv*T;for(D=z;D<Q;D+=T){w(D);A(D+F)}return Q-z})(t);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,T=F+o.uv_index_bytes*
+3,Q=z+o.ntri_smooth_uv*T;for(D=z;D<Q;D+=T){u(D);A(D+F)}return Q-z})(E);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes,T=F+o.uv_index_bytes*4,Q=z+o.nquad_flat_uv*T;for(D=z;D<Q;D+=T){p(D);G(D+F)}return Q-z})(g);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,T=F+o.uv_index_bytes*4,Q=z+o.nquad_smooth_uv*T;for(D=z;D<Q;D+=T){x(D);G(D+F)}return Q-z})(L);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes,T=z+o.ntri_flat*F;for(D=
+z;D<T;D+=F)w(D);return T-z})(H);(function(z){var D,F=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,T=z+o.ntri_smooth*F;for(D=z;D<T;D+=F)u(D);return T-z})(q);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes,T=z+o.nquad_flat*F;for(D=z;D<T;D+=F)p(D);return T-z})(C);(function(z){var D,F=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,T=z+o.nquad_smooth*F;for(D=z;D<T;D+=F)x(D);return T-z})(I);this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,m,n;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(g,j,m,n)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];n=a.colors[h+2];THREE.Loader.prototype.vc(g,
 this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,m,n;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(g,j,m,n)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];n=a.colors[h+2];THREE.Loader.prototype.vc(g,
-j,m,n)}}})();(function(){function h(x,A){THREE.Loader.prototype.f3(g,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function j(x,A){THREE.Loader.prototype.f4(g,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function n(x,A){var G,v,I,o,M,e,ea,O,P;G=x[A];v=x[A+1];I=x[A+2];o=a.uvs[G*2];ea=a.uvs[G*2+1];M=a.uvs[v*2];O=
-a.uvs[v*2+1];e=a.uvs[I*2];P=a.uvs[I*2+1];THREE.Loader.prototype.uv3(g.uvs,o,ea,M,O,e,P);if(a.uvs2&&a.uvs2.length){o=a.uvs2[G*2];ea=a.uvs2[G*2+1];M=a.uvs2[v*2];O=a.uvs2[v*2+1];e=a.uvs2[I*2];P=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(g.uvs2,o,1-ea,M,1-O,e,1-P)}}function w(x,A){var G,v,I,o,M,e,ea,O,P,W,S,aa;G=x[A];v=x[A+1];I=x[A+2];o=x[A+3];M=a.uvs[G*2];P=a.uvs[G*2+1];e=a.uvs[v*2];W=a.uvs[v*2+1];ea=a.uvs[I*2];S=a.uvs[I*2+1];O=a.uvs[o*2];aa=a.uvs[o*2+1];THREE.Loader.prototype.uv4(g.uvs,M,P,e,W,ea,S,O,
-aa);if(a.uvs2){M=a.uvs2[G*2];P=a.uvs2[G*2+1];e=a.uvs2[v*2];W=a.uvs2[v*2+1];ea=a.uvs2[I*2];S=a.uvs2[I*2+1];O=a.uvs2[o*2];aa=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(g.uvs2,M,1-P,e,1-W,ea,1-S,O,1-aa)}}var q,p;q=0;for(p=a.triangles_uv.length;q<p;q+=7){h(a.triangles_uv,q);n(a.triangles_uv,q+4)}q=0;for(p=a.triangles_n_uv.length;q<p;q+=10){k(a.triangles_n_uv,q);n(a.triangles_n_uv,q+7)}q=0;for(p=a.quads_uv.length;q<p;q+=9){j(a.quads_uv,q);w(a.quads_uv,q+5)}q=0;for(p=a.quads_n_uv.length;q<p;q+=13){m(a.quads_n_uv,
-q);w(a.quads_n_uv,q+9)}q=0;for(p=a.triangles.length;q<p;q+=4)h(a.triangles,q);q=0;for(p=a.triangles_n.length;q<p;q+=7)k(a.triangles_n,q);q=0;for(p=a.quads.length;q<p;q+=5)j(a.quads,q);q=0;for(p=a.quads_n.length;q<p;q+=9)m(a.quads_n,q)})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,m,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,
+j,m,n)}}})();(function(){function h(x,A){THREE.Loader.prototype.f3(g,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function j(x,A){THREE.Loader.prototype.f4(g,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function n(x,A){var G,v,H,o,M,e,da,O,P;G=x[A];v=x[A+1];H=x[A+2];o=a.uvs[G*2];da=a.uvs[G*2+1];M=a.uvs[v*2];O=
+a.uvs[v*2+1];e=a.uvs[H*2];P=a.uvs[H*2+1];THREE.Loader.prototype.uv3(g.uvs,o,da,M,O,e,P);if(a.uvs2&&a.uvs2.length){o=a.uvs2[G*2];da=a.uvs2[G*2+1];M=a.uvs2[v*2];O=a.uvs2[v*2+1];e=a.uvs2[H*2];P=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(g.uvs2,o,1-da,M,1-O,e,1-P)}}function w(x,A){var G,v,H,o,M,e,da,O,P,V,S,Z;G=x[A];v=x[A+1];H=x[A+2];o=x[A+3];M=a.uvs[G*2];P=a.uvs[G*2+1];e=a.uvs[v*2];V=a.uvs[v*2+1];da=a.uvs[H*2];S=a.uvs[H*2+1];O=a.uvs[o*2];Z=a.uvs[o*2+1];THREE.Loader.prototype.uv4(g.uvs,M,P,e,V,da,S,O,Z);
+if(a.uvs2){M=a.uvs2[G*2];P=a.uvs2[G*2+1];e=a.uvs2[v*2];V=a.uvs2[v*2+1];da=a.uvs2[H*2];S=a.uvs2[H*2+1];O=a.uvs2[o*2];Z=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(g.uvs2,M,1-P,e,1-V,da,1-S,O,1-Z)}}var u,p;u=0;for(p=a.triangles_uv.length;u<p;u+=7){h(a.triangles_uv,u);n(a.triangles_uv,u+4)}u=0;for(p=a.triangles_n_uv.length;u<p;u+=10){k(a.triangles_n_uv,u);n(a.triangles_n_uv,u+7)}u=0;for(p=a.quads_uv.length;u<p;u+=9){j(a.quads_uv,u);w(a.quads_uv,u+5)}u=0;for(p=a.quads_n_uv.length;u<p;u+=13){m(a.quads_n_uv,
+u);w(a.quads_n_uv,u+9)}u=0;for(p=a.triangles.length;u<p;u+=4)h(a.triangles,u);u=0;for(p=a.triangles_n.length;u<p;u+=7)k(a.triangles_n,u);u=0;for(p=a.quads.length;u<p;u+=5)j(a.quads,u);u=0;for(p=a.quads_n.length;u<p;u+=9)m(a.quads_n,u)})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,m,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];THREE.Loader.prototype.si(g,
 j,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
 j,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
-c,d)))},vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var m=b[k*3],n=b[k*3+1];k=b[k*3+2];var w=b[j*3],q=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,n,k),new THREE.Vector3(w,
-q,j)],g))},f4n:function(a,b,c,d,f,g,h,k,j,m,n){h=a.materials[h];var w=b[j*3],q=b[j*3+1];j=b[j*3+2];var p=b[m*3],x=b[m*3+1];m=b[m*3+2];var A=b[n*3],G=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,q,j),new THREE.Vector3(p,x,m),new THREE.Vector3(A,G,n)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,
+c,d)))},vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var m=b[k*3],n=b[k*3+1];k=b[k*3+2];var w=b[j*3],u=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,n,k),new THREE.Vector3(w,
+u,j)],g))},f4n:function(a,b,c,d,f,g,h,k,j,m,n){h=a.materials[h];var w=b[j*3],u=b[j*3+1];j=b[j*3+2];var p=b[m*3],x=b[m*3+1];m=b[m*3+2];var A=b[n*3],G=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,u,j),new THREE.Vector3(p,x,m),new THREE.Vector3(A,G,n)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,
 c));m.push(new THREE.UV(d,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var n=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/
 c));m.push(new THREE.UV(d,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var n=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/
 Math.LN2));k.image.width=n;k.image.height=w;k.image.getContext("2d").drawImage(this,0,0,n,w)}else k.image=this;k.needsUpdate=!0};m.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.map_diffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*
 Math.LN2));k.image.width=n;k.image.height=w;k.image.getContext("2d").drawImage(this,0,0,n,w)}else k.image=this;k.needsUpdate=!0};m.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,light_map:null,vertex_colors:a.vertex_colors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.map_diffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.map_diffuse)}else if(a.col_diffuse){h=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*
 255;g.color=h;g.opacity=a.transparency}else if(a.a_dbg_color)g.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");g.light_map=new THREE.Texture(h);d(g.light_map,b+"/"+a.map_lightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
 255;g.color=h;g.opacity=a.transparency}else if(a.a_dbg_color)g.color=a.a_dbg_color;if(a.map_lightmap&&b){h=document.createElement("canvas");g.light_map=new THREE.Texture(h);d(g.light_map,b+"/"+a.map_lightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 61 - 64
build/custom/ThreeCanvas.js

@@ -4,44 +4,41 @@ THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;th
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
-THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
-this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
-this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
+b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
+a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(e,h){return e.distance-h.distance});return f},intersectObject:function(a){function b(r,k,E,D){D=D.clone().subSelf(k);E=E.clone().subSelf(k);var I=r.clone().subSelf(k);r=D.dot(D);k=D.dot(E);D=D.dot(I);var F=E.dot(E);E=E.dot(I);I=1/(r*F-k*k);F=(F*D-k*E)*I;r=(r*E-k*D)*I;return F>0&&r>0&&F+r<1}var c,d,f,e,h,j,g,i,m,n,
-o,p=a.geometry,t=p.vertices,u=[];c=0;for(d=p.faces.length;c<d;c++){f=p.faces[c];n=this.origin.clone();o=this.direction.clone();g=a.globalMatrix;g.extractRotationMatrix(a.matrixRotation);e=g.multiplyVector3(t[f.a].position.clone());h=g.multiplyVector3(t[f.b].position.clone());j=g.multiplyVector3(t[f.c].position.clone());g=f instanceof THREE.Face4?g.multiplyVector3(t[f.d].position.clone()):null;i=a.matrixRotation.multiplyVector3(f.normal.clone());m=o.dot(i);if(m<0){i=i.dot((new THREE.Vector3).sub(e,
-n))/m;n=n.addSelf(o.multiplyScalar(i));if(f instanceof THREE.Face3){if(b(n,e,h,j)){f={distance:this.origin.distanceTo(n),point:n,face:f,object:a};u.push(f)}}else if(f instanceof THREE.Face4&&(b(n,e,h,g)||b(n,h,j,g))){f={distance:this.origin.distanceTo(n),point:n,face:f,object:a};u.push(f)}}}return u}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(e,h){return e.distance-h.distance});return f},intersectObject:function(a){function b(r,k,D,C){C=C.clone().subSelf(k);D=D.clone().subSelf(k);var I=r.clone().subSelf(k);r=C.dot(C);k=C.dot(D);C=C.dot(I);var F=D.dot(D);D=D.dot(I);I=1/(r*F-k*k);F=(F*C-k*D)*I;r=(r*D-k*C)*I;return F>0&&r>0&&F+r<1}var c,d,f,e,h,j,g,i,m,n,
+o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;c<d;c++){f=q.faces[c];n=this.origin.clone();o=this.direction.clone();g=a.globalMatrix;e=g.multiplyVector3(s[f.a].position.clone());h=g.multiplyVector3(s[f.b].position.clone());j=g.multiplyVector3(s[f.c].position.clone());g=f instanceof THREE.Face4?g.multiplyVector3(s[f.d].position.clone()):null;i=a.matrixRotation.multiplyVector3(f.normal.clone());m=o.dot(i);if(m<0){i=i.dot((new THREE.Vector3).sub(e,n))/m;n=n.addSelf(o.multiplyScalar(i));if(f instanceof
+THREE.Face3){if(b(n,e,h,j)){f={distance:this.origin.distanceTo(n),point:n,face:f,object:a};t.push(f)}}else if(f instanceof THREE.Face4&&(b(n,e,h,g)||b(n,h,j,g))){f={distance:this.origin.distanceTo(n),point:n,face:f,object:a};t.push(f)}}}return t}};
 THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b,c,d,f,e,h,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(g,i,m,n){j=!1;b=g;c=i;d=m;f=n;a()};this.addPoint=function(g,i){if(j){j=!1;b=g;c=i;d=g;f=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;f=f>i?f:i}a()};
 THREE.Rectangle=function(){function a(){e=d-b;h=f-c}var b,c,d,f,e,h,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(g,i,m,n){j=!1;b=g;c=i;d=m;f=n;a()};this.addPoint=function(g,i){if(j){j=!1;b=g;c=i;d=g;f=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;f=f>i?f:i}a()};
-this.add3Points=function(g,i,m,n,o,p){if(j){j=!1;b=g<m?g<o?g:o:m<o?m:o;c=i<n?i<p?i:p:n<p?n:p;d=g>m?g>o?g:o:m>o?m:o;f=i>n?i>p?i:p:n>p?n:p}else{b=g<m?g<o?g<b?g:b:o<b?o:b:m<o?m<b?m:b:o<b?o:b;c=i<n?i<p?i<c?i:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c;d=g>m?g>o?g>d?g:d:o>d?o:d:m>o?m>d?m:d:o>d?o:d;f=i>n?i>p?i>f?i:f:p>f?p:f:n>p?n>f?n:f:p>f?p:f}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();f=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
+this.add3Points=function(g,i,m,n,o,q){if(j){j=!1;b=g<m?g<o?g:o:m<o?m:o;c=i<n?i<q?i:q:n<q?n:q;d=g>m?g>o?g:o:m>o?m:o;f=i>n?i>q?i:q:n>q?n:q}else{b=g<m?g<o?g<b?g:b:o<b?o:b:m<o?m<b?m:b:o<b?o:b;c=i<n?i<q?i<c?i:c:q<c?q:c:n<q?n<c?n:c:q<c?q:c;d=g>m?g>o?g>d?g:d:o>d?o:d:m>o?m>d?m:d:o>d?o:d;f=i>n?i>q?i>f?i:f:q>f?q:f:n>q?n>f?n:f:q>f?q:f}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();f=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
 d:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){j=!0;f=d=c=b=0;a()};this.isEmpty=function(){return j};this.toString=function(){return"THREE.Rectangle ( left: "+
 d:g.getRight();f=f>g.getBottom()?f:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;f+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();f=f<g.getBottom()?f:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(f,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){j=!0;f=d=c=b=0;a()};this.isEmpty=function(){return j};this.toString=function(){return"THREE.Rectangle ( left: "+
 b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+e+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 b+", right: "+d+", top: "+c+", bottom: "+f+", width: "+e+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,f,e,h,j,g,i,m,n,o,p,t,u){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=f||0;this.n22=e||1;this.n23=h||0;this.n24=j||0;this.n31=g||0;this.n32=i||0;this.n33=m||1;this.n34=n||0;this.n41=o||0;this.n42=p||0;this.n43=t||0;this.n44=u||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,d,f,e,h,j,g,i,m,n,o,p,t,u){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=h;this.n24=j;this.n31=g;this.n32=i;this.n33=m;this.n34=n;this.n41=o;this.n42=p;this.n43=t;this.n44=u;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,e=THREE.Matrix4.__tmpVec3;e.sub(a,b).normalize();d.cross(c,e).normalize();f.cross(e,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
-this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
-a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
-a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,p=a.n34,t=a.n41,u=a.n42,r=a.n43,k=a.n44,E=b.n11,D=b.n12,I=b.n13,F=b.n14,N=b.n21,B=b.n22,z=b.n23,K=b.n24,x=b.n31,L=b.n32,C=b.n33,w=b.n34,s=b.n41,O=b.n42,v=b.n43,P=b.n44;this.n11=c*E+d*N+f*x+e*s;this.n12=c*D+d*B+f*L+e*O;this.n13=c*I+d*z+f*C+e*v;this.n14=c*F+d*K+f*w+e*P;this.n21=h*E+j*N+g*x+i*s;this.n22=h*D+j*B+g*L+i*O;this.n23=h*I+
-j*z+g*C+i*v;this.n24=h*F+j*K+g*w+i*P;this.n31=m*E+n*N+o*x+p*s;this.n32=m*D+n*B+o*L+p*O;this.n33=m*I+n*z+o*C+p*v;this.n34=m*F+n*K+o*w+p*P;this.n41=t*E+u*N+r*x+k*s;this.n42=t*D+u*B+r*L+k*O;this.n43=t*I+u*z+r*C+k*v;this.n44=t*F+u*K+r*w+k*P;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,e=a.n13,h=a.n14,j=a.n21,g=a.n22,i=a.n23,m=a.n24,n=a.n31,o=a.n32,p=a.n33,t=a.n34,u=a.n41,r=a.n42,k=a.n43;a=a.n44;var E=b.n11,D=b.n12,I=b.n13,F=b.n14,N=b.n21,B=b.n22,z=b.n23,K=b.n24,x=b.n31,L=b.n32,C=b.n33,
-w=b.n34,s=b.n41,O=b.n42,v=b.n43;b=b.n44;this.n11=d*E+f*N+e*x+h*s;this.n12=d*D+f*B+e*L+h*O;this.n13=d*I+f*z+e*C+h*v;this.n14=d*F+f*K+e*w+h*b;this.n21=j*E+g*N+i*x+m*s;this.n22=j*D+g*B+i*L+m*O;this.n23=j*I+g*z+i*C+m*v;this.n24=j*F+g*K+i*w+m*b;this.n31=n*E+o*N+p*x+t*s;this.n32=n*D+o*B+p*L+t*O;this.n33=n*I+o*z+p*C+t*v;this.n34=n*F+o*K+p*w+t*b;this.n41=u*E+r*N+k*x+a*s;this.n42=u*D+r*B+k*L+a*O;this.n43=u*I+r*z+k*C+a*v;this.n44=u*F+r*K+k*w+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=
-this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,e=this.n21,h=this.n22,j=this.n23,g=this.n24,i=this.n31,m=this.n32,n=this.n33,o=this.n34,p=this.n41,t=this.n42,u=this.n43,r=this.n44,k=a.n11,E=a.n21,D=a.n31,I=a.n41,F=a.n12,N=a.n22,B=a.n32,z=a.n42,K=a.n13,x=a.n23,L=a.n33,C=a.n43,w=a.n14,s=a.n24,O=
-a.n34;a=a.n44;this.n11=b*k+c*E+d*D+f*I;this.n12=b*F+c*N+d*B+f*z;this.n13=b*K+c*x+d*L+f*C;this.n14=b*w+c*s+d*O+f*a;this.n21=e*k+h*E+j*D+g*I;this.n22=e*F+h*N+j*B+g*z;this.n23=e*K+h*x+j*L+g*C;this.n24=e*w+h*s+j*O+g*a;this.n31=i*k+m*E+n*D+o*I;this.n32=i*F+m*N+n*B+o*z;this.n33=i*K+m*x+n*L+o*C;this.n34=i*w+m*s+n*O+o*a;this.n41=p*k+t*E+u*D+r*I;this.n42=p*F+t*N+u*B+r*z;this.n43=p*K+t*x+u*L+r*C;this.n44=p*w+t*s+u*O+r*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;
-this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,h=this.n23,j=this.n24,g=this.n31,i=this.n32,m=this.n33,n=this.n34,o=this.n41,p=this.n42,t=this.n43,u=this.n44;return d*h*i*o-c*j*i*o-d*e*m*o+b*j*m*o+c*e*n*o-b*h*n*o-d*h*g*p+c*j*g*p+d*f*m*p-a*j*m*p-c*f*n*p+a*h*n*p+d*e*g*t-b*j*g*t-d*f*i*t+a*j*i*t+b*f*n*
-t-a*e*n*t-c*e*g*u+b*h*g*u+c*f*i*u-a*h*i*u-b*f*m*u+a*e*m*u},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;
-a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,
-0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,h=a.y,j=a.z,g=f*e,i=f*h;this.set(g*e+c,g*h-d*j,g*j+d*h,0,g*h+d*j,
-i*h+c,i*j-d*e,0,g*j-d*h,i*j+d*e,f*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var e=Math.cos(d);d=Math.sin(d);var h=a*c,j=b*c;this.n11=f*e;this.n12=-f*d;this.n13=c;this.n21=j*e+a*d;this.n22=-j*d+a*e;this.n23=-b*f;this.n31=-h*e+b*d;this.n32=h*d+b*e;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=
-a.w,e=b+b,h=c+c,j=d+d;a=b*e;var g=b*h;b*=j;var i=c*h;c*=j;d*=j;e*=f;h*=f;f*=j;this.n11=1-(i+d);this.n12=g-f;this.n13=b+h;this.n21=g+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-h;this.n32=c+e;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;
-a.n22=this.n22;a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},extractPositionVector:function(a){a.x=this.n14;a.y=this.n24;a.z=this.n34},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
+THREE.Matrix4=function(a,b,c,d,f,e,h,j,g,i,m,n,o,q,s,t){this.set(a||1,b||0,c||0,d||0,f||0,e||1,h||0,j||0,g||0,i||0,m||1,n||0,o||0,q||0,s||0,t||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,f,e,h,j,g,i,m,n,o,q,s,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=e;this.n23=h;this.n24=j;this.n31=g;this.n32=i;this.n33=m;this.n34=n;this.n41=o;this.n42=q;this.n43=s;this.n44=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+f=THREE.Matrix4.__tmpVec2,e=THREE.Matrix4.__tmpVec3;e.sub(a,b).normalize();d.cross(c,e).normalize();f.cross(e,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=e.x;this.n32=e.y;this.n33=e.z;this.n34=-e.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=
+(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*
+f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44,D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,
+w=b.n23,K=b.n24,u=b.n31,L=b.n32,E=b.n33,y=b.n34;this.n11=c*D+d*N+f*u;this.n12=c*C+d*A+f*L;this.n13=c*I+d*w+f*E;this.n14=c*F+d*K+f*y+e;this.n21=h*D+j*N+g*u;this.n22=h*C+j*A+g*L;this.n23=h*I+j*w+g*E;this.n24=h*F+j*K+g*y+i;this.n31=m*D+n*N+o*u;this.n32=m*C+n*A+o*L;this.n33=m*I+n*w+o*E;this.n34=m*F+n*K+o*y+q;this.n41=s*D+t*N+r*u;this.n42=s*C+t*A+r*L;this.n43=s*I+t*w+r*E;this.n44=s*F+t*K+r*y+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,e=a.n13,h=a.n14,j=a.n21,g=a.n22,i=a.n23,m=a.n24,
+n=a.n31,o=a.n32,q=a.n33,s=a.n34,t=a.n41,r=a.n42,k=a.n43;a=a.n44;var D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,K=b.n24,u=b.n31,L=b.n32,E=b.n33,y=b.n34,B=b.n41,T=b.n42,x=b.n43;b=b.n44;this.n11=d*D+f*N+e*u+h*B;this.n12=d*C+f*A+e*L+h*T;this.n13=d*I+f*w+e*E+h*x;this.n14=d*F+f*K+e*y+h*b;this.n21=j*D+g*N+i*u+m*B;this.n22=j*C+g*A+i*L+m*T;this.n23=j*I+g*w+i*E+m*x;this.n24=j*F+g*K+i*y+m*b;this.n31=n*D+o*N+q*u+s*B;this.n32=n*C+o*A+q*L+s*T;this.n33=n*I+o*w+q*E+s*x;this.n34=n*F+o*K+q*y+s*b;this.n41=
+t*D+r*N+k*u+a*B;this.n42=t*C+r*A+k*L+a*T;this.n43=t*I+r*w+k*E+a*x;this.n44=t*F+r*K+k*y+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,e=this.n21,h=this.n22,j=this.n23,g=this.n24,i=this.n31,m=this.n32,n=this.n33,o=this.n34,q=this.n41,
+s=this.n42,t=this.n43,r=this.n44,k=a.n11,D=a.n21,C=a.n31,I=a.n12,F=a.n22,N=a.n32,A=a.n13,w=a.n23,K=a.n33,u=a.n14,L=a.n24;a=a.n34;this.n11=b*k+c*D+d*C;this.n12=b*I+c*F+d*N;this.n13=b*A+c*w+d*K;this.n14=b*u+c*L+d*a+f;this.n21=e*k+h*D+j*C;this.n22=e*I+h*F+j*N;this.n23=e*A+h*w+j*K;this.n24=e*u+h*L+j*a+g;this.n31=i*k+m*D+n*C;this.n32=i*I+m*F+n*N;this.n33=i*A+m*w+n*K;this.n34=i*u+m*L+n*a+o;this.n41=q*k+s*D+t*C;this.n42=q*I+s*F+t*N;this.n43=q*A+s*w+t*K;this.n44=q*u+s*L+t*a+r;return this},multiplyScalar:function(a){this.n11*=
+a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,e=this.n22,h=this.n23,j=this.n24,g=this.n31,i=this.n32,m=this.n33,n=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44;return d*h*i*o-c*j*i*o-d*e*m*o+b*j*m*o+c*e*n*o-b*h*n*o-d*h*g*q+c*j*g*q+d*f*m*q-a*j*m*q-c*f*n*q+a*h*n*q+
+d*e*g*s-b*j*g*s-d*f*i*s+a*j*i*s+b*f*n*s-a*e*n*s-c*e*g*t+b*h*g*t+c*f*i*t-a*h*i*t-b*f*m*t+a*e*m*t},transpose:function(){function a(b,c,d){var f=b[c];b[c]=b[d];b[d]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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.flattenToArray(this.flat);return flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=
+this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
+Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,e=a.x,h=a.y,j=a.z,g=f*e,i=f*h;this.set(g*e+c,g*h-d*j,g*j+d*h,0,g*h+d*j,i*h+c,i*j-d*e,0,g*j-d*h,i*j+d*e,f*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=
+a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var e=Math.cos(d);d=Math.sin(d);var h=a*c,j=b*c;this.n11=f*e;this.n12=-f*d;this.n13=c;this.n21=j*e+a*d;this.n22=-j*d+a*e;this.n23=-b*f;this.n31=-h*e+b*d;this.n32=h*d+b*e;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,e=b+b,h=c+c,j=d+d;a=b*e;var g=b*h;b*=j;var i=c*h;c*=j;d*=j;e*=f;h*=f;f*=j;this.n11=1-(i+d);this.n12=g-f;this.n13=b+h;this.n21=g+f;this.n22=1-(a+d);this.n23=c-e;this.n31=b-h;this.n32=
+c+e;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
 THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,p=a.n34,t=a.n41,u=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*p*u-i*o*u+i*n*r-j*p*r-g*n*k+j*o*k;b.n12=e*o*u-f*p*u-e*n*r+d*p*r+f*n*k-d*o*k;b.n13=f*i*u-e*g*u+e*j*r-d*i*r-f*j*k+d*g*k;b.n14=e*g*n-f*i*n-e*j*o+d*i*o+f*j*p-d*g*p;b.n21=i*o*t-g*p*t-i*m*r+h*p*r+g*m*k-h*o*k;b.n22=f*p*t-e*o*t+e*m*r-c*p*r-f*m*k+c*o*k;b.n23=e*g*t-f*i*t-e*h*r+c*i*r+f*h*k-c*g*k;
-b.n24=f*i*m-e*g*m+e*h*o-c*i*o-f*h*p+c*g*p;b.n31=j*p*t-i*n*t+i*m*u-h*p*u-j*m*k+h*n*k;b.n32=e*n*t-d*p*t-e*m*u+c*p*u+d*m*k-c*n*k;b.n33=f*i*t-e*j*t+e*h*u-c*i*u-d*h*k+c*j*k;b.n34=e*j*m-d*i*m-e*h*n+c*i*n+d*h*p-c*j*p;b.n41=g*n*t-j*o*t-g*m*u+h*o*u+j*m*r-h*n*r;b.n42=d*o*t-f*n*t+f*m*u-c*o*u-d*m*r+c*n*r;b.n43=f*j*t-d*g*t-f*h*u+c*g*u+d*h*r-c*j*r;b.n44=d*g*m-f*j*m+f*h*n-c*g*n-d*h*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,e=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,m=a.n31,n=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*q*t-i*o*t+i*n*r-j*q*r-g*n*k+j*o*k;b.n12=e*o*t-f*q*t-e*n*r+d*q*r+f*n*k-d*o*k;b.n13=f*i*t-e*g*t+e*j*r-d*i*r-f*j*k+d*g*k;b.n14=e*g*n-f*i*n-e*j*o+d*i*o+f*j*q-d*g*q;b.n21=i*o*s-g*q*s-i*m*r+h*q*r+g*m*k-h*o*k;b.n22=f*q*s-e*o*s+e*m*r-c*q*r-f*m*k+c*o*k;b.n23=e*g*s-f*i*s-e*h*r+c*i*r+f*h*k-c*g*k;
+b.n24=f*i*m-e*g*m+e*h*o-c*i*o-f*h*q+c*g*q;b.n31=j*q*s-i*n*s+i*m*t-h*q*t-j*m*k+h*n*k;b.n32=e*n*s-d*q*s-e*m*t+c*q*t+d*m*k-c*n*k;b.n33=f*i*s-e*j*s+e*h*t-c*i*t-d*h*k+c*j*k;b.n34=e*j*m-d*i*m-e*h*n+c*i*n+d*h*q-c*j*q;b.n41=g*n*s-j*o*s-g*m*t+h*o*t+j*m*r-h*n*r;b.n42=d*o*s-f*n*s+f*m*t-c*o*t-d*m*r+c*n*r;b.n43=f*j*s-d*g*s-f*h*t+c*g*t+d*h*r-c*j*r;b.n44=d*g*m-f*j*m+f*h*n-c*g*n-d*h*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=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,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*h;c[4]=a*j;c[5]=a*g;c[6]=a*i;c[7]=a*m;c[8]=a*n;return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,e=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,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*e;c[3]=a*h;c[4]=a*j;c[5]=a*g;c[6]=a*i;c[7]=a*m;c[8]=a*n;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,e){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(e+f)/(e-f);h.n34=-2*e*f/(e-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,e){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(e+f)/(e-f);h.n34=-2*e*f/(e-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var h,j,g,i;h=new THREE.Matrix4;j=b-a;g=c-d;i=e-f;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/i;h.n34=-((e+f)/i);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,e){var h,j,g,i;h=new THREE.Matrix4;j=b-a;g=c-d;i=e-f;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/i;h.n34=-((e+f)/i);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
@@ -58,10 +55,10 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,e,h,j=new THREE.Vector3,g=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){e=this.vertices[d];e.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){e=this.faces[d];if(a&&e.vertexNormals.length){j.set(0,0,0);b=0;for(c=e.normal.length;b<c;b++)j.addSelf(e.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[e.a];c=this.vertices[e.b];h=this.vertices[e.c];j.sub(h.position,
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,e,h,j=new THREE.Vector3,g=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){e=this.vertices[d];e.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){e=this.faces[d];if(a&&e.vertexNormals.length){j.set(0,0,0);b=0;for(c=e.normal.length;b<c;b++)j.addSelf(e.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[e.a];c=this.vertices[e.b];h=this.vertices[e.c];j.sub(h.position,
 c.position);g.sub(b.position,c.position);j.crossSelf(g)}j.isZero()||j.normalize();e.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 c.position);g.sub(b.position,c.position);j.crossSelf(g)}j.isZero()||j.normalize();e.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(w,s,O,v,P,Y,J){e=w.vertices[s].position;h=w.vertices[O].position;j=w.vertices[v].position;g=f[P];i=f[Y];m=f[J];n=h.x-e.x;o=j.x-e.x;p=h.y-e.y;t=j.y-e.y;
-u=h.z-e.z;r=j.z-e.z;k=i.u-g.u;E=m.u-g.u;D=i.v-g.v;I=m.v-g.v;F=1/(k*I-E*D);z.set((I*n-D*o)*F,(I*p-D*t)*F,(I*u-D*r)*F);K.set((k*o-E*n)*F,(k*t-E*p)*F,(k*r-E*u)*F);N[s].addSelf(z);N[O].addSelf(z);N[v].addSelf(z);B[s].addSelf(K);B[O].addSelf(K);B[v].addSelf(K)}var b,c,d,f,e,h,j,g,i,m,n,o,p,t,u,r,k,E,D,I,F,N=[],B=[],z=new THREE.Vector3,K=new THREE.Vector3,x=new THREE.Vector3,L=new THREE.Vector3,C=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;B[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(y,B,T,x,P,Y,J){e=y.vertices[B].position;h=y.vertices[T].position;j=y.vertices[x].position;g=f[P];i=f[Y];m=f[J];n=h.x-e.x;o=j.x-e.x;q=h.y-e.y;s=j.y-e.y;
+t=h.z-e.z;r=j.z-e.z;k=i.u-g.u;D=m.u-g.u;C=i.v-g.v;I=m.v-g.v;F=1/(k*I-D*C);w.set((I*n-C*o)*F,(I*q-C*s)*F,(I*t-C*r)*F);K.set((k*o-D*n)*F,(k*s-D*q)*F,(k*r-D*t)*F);N[B].addSelf(w);N[T].addSelf(w);N[x].addSelf(w);A[B].addSelf(K);A[T].addSelf(K);A[x].addSelf(K)}var b,c,d,f,e,h,j,g,i,m,n,o,q,s,t,r,k,D,C,I,F,N=[],A=[],w=new THREE.Vector3,K=new THREE.Vector3,u=new THREE.Vector3,L=new THREE.Vector3,E=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;A[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
 for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){C.copy(this.vertices[b].normal);d=N[b];x.copy(d);x.subSelf(C.multiplyScalar(C.dot(d))).normalize();L.cross(this.vertices[b].normal,d);d=L.dot(B[b]);d=d<0?-1:1;this.vertices[b].tangent.set(x.x,x.y,x.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){E.copy(this.vertices[b].normal);d=N[b];u.copy(d);u.subSelf(E.multiplyScalar(E.dot(d))).normalize();L.cross(this.vertices[b].normal,d);d=L.dot(A[b]);d=d<0?-1:1;this.vertices[b].tangent.set(u.x,u.y,u.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(m){var n=[];b=0;for(c=m.length;b<c;b++)m[b]==undefined?n.push("undefined"):n.push(m[b].id);return n.join("_")}var b,c,d,f,e,h,j,g,i={};d=0;for(f=this.faces.length;d<f;d++){e=this.faces[d];
 this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(m){var n=[];b=0;for(c=m.length;b<c;b++)m[b]==undefined?n.push("undefined"):n.push(m[b].id);return n.join("_")}var b,c,d,f,e,h,j,g,i={};d=0;for(f=this.faces.length;d<f;d++){e=this.faces[d];
 h=e.materials;j=a(h);i[j]==undefined&&(i[j]={hash:j,counter:0});g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});e=e instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+e>65535){i[j].counter+=1;g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=e}},toString:function(){return"THREE.Geometry ( vertices: "+
 h=e.materials;j=a(h);i[j]==undefined&&(i[j]={hash:j,counter:0});g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});e=e instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+e>65535){i[j].counter+=1;g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=e}},toString:function(){return"THREE.Geometry ( vertices: "+
@@ -112,36 +109,36 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(B,z){return z.z-B.z}function b(B,z){var K=0,x=1,L=B.z+B.w,C=z.z+z.w,w=-B.z+B.w,s=-z.z+z.w;if(L>=0&&C>=0&&w>=0&&s>=0)return!0;else if(L<0&&C<0||w<0&&s<0)return!1;else{if(L<0)K=Math.max(K,L/(L-C));else C<0&&(x=Math.min(x,L/(L-C)));if(w<0)K=Math.max(K,w/(w-s));else s<0&&(x=Math.min(x,w/(w-s)));if(x<K)return!1;else{B.lerpSelf(z,K);z.lerpSelf(B,1-x);return!0}}}var c,d,f=[],e,h,j,g=[],i,m,n=[],o,p,t=[],u=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,E=new THREE.Matrix4,
-D=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,F=new THREE.Vector4,N;this.projectObjects=function(B,z,K){z=[];var x,L,C;d=0;L=B.objects;B=0;for(x=L.length;B<x;B++){C=L[B];var w;if(!(w=!C.visible))if(w=C instanceof THREE.Mesh){a:{w=void 0;for(var s=C.globalMatrix,O=-C.geometry.boundingSphere.radius*Math.max(C.scale.x,Math.max(C.scale.y,C.scale.z)),v=0;v<6;v++){w=D[v].x*s.n14+D[v].y*s.n24+D[v].z*s.n34+D[v].w;if(w<=
-O){w=!1;break a}}w=!0}w=!w}if(!w){c=f[d]=f[d]||new THREE.RenderableObject;u.copy(C.position);k.multiplyVector3(u);c.object=C;c.z=u.z;z.push(c);d++}}K&&z.sort(a);return z};this.projectScene=function(B,z,K){var x=[],L=z.near,C=z.far,w,s,O,v,P,Y,J,ja,ka,la,ma,$,Q,H,U,R;j=m=p=0;z.matrixAutoUpdate&&z.update();k.multiply(z.projectionMatrix,z.globalMatrix);D[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);D[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);D[2].set(k.n41+k.n21,k.n42+k.n22,
-k.n43+k.n23,k.n44+k.n24);D[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);D[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);D[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(w=0;w<6;w++){Y=D[w];Y.divideScalar(Math.sqrt(Y.x*Y.x+Y.y*Y.y+Y.z*Y.z))}B.update(undefined,!1,z);Y=this.projectObjects(B,z,!0);B=0;for(w=Y.length;B<w;B++){J=Y[B].object;if(J.visible){J.matrixAutoUpdate&&J.updateMatrix();ja=J.globalMatrix;ma=J.matrixRotation;ka=J.materials;la=J.overdraw;if(J instanceof
-THREE.Mesh){$=J.geometry;Q=$.vertices;s=0;for(O=Q.length;s<O;s++){H=Q[s];H.positionWorld.copy(H.position);ja.multiplyVector3(H.positionWorld);v=H.positionScreen;v.copy(H.positionWorld);k.multiplyVector4(v);v.x/=v.w;v.y/=v.w;H.__visible=v.z>L&&v.z<C}$=$.faces;s=0;for(O=$.length;s<O;s++){H=$[s];if(H instanceof THREE.Face3){v=Q[H.a];P=Q[H.b];U=Q[H.c];if(v.__visible&&P.__visible&&U.__visible&&(J.doubleSided||J.flipSided!=(U.positionScreen.x-v.positionScreen.x)*(P.positionScreen.y-v.positionScreen.y)-
-(U.positionScreen.y-v.positionScreen.y)*(P.positionScreen.x-v.positionScreen.x)<0)){e=g[j]=g[j]||new THREE.RenderableFace3;e.v1.positionWorld.copy(v.positionWorld);e.v2.positionWorld.copy(P.positionWorld);e.v3.positionWorld.copy(U.positionWorld);e.v1.positionScreen.copy(v.positionScreen);e.v2.positionScreen.copy(P.positionScreen);e.v3.positionScreen.copy(U.positionScreen);e.normalWorld.copy(H.normal);ma.multiplyVector3(e.normalWorld);e.centroidWorld.copy(H.centroid);ja.multiplyVector3(e.centroidWorld);
-e.centroidScreen.copy(e.centroidWorld);k.multiplyVector3(e.centroidScreen);U=H.vertexNormals;N=e.vertexNormalsWorld;v=0;for(P=U.length;v<P;v++){R=N[v]=N[v]||new THREE.Vector3;R.copy(U[v]);ma.multiplyVector3(R)}e.z=e.centroidScreen.z;e.meshMaterials=ka;e.faceMaterials=H.materials;e.overdraw=la;if(J.geometry.uvs[s]){e.uvs[0]=J.geometry.uvs[s][0];e.uvs[1]=J.geometry.uvs[s][1];e.uvs[2]=J.geometry.uvs[s][2]}x.push(e);j++}}else if(H instanceof THREE.Face4){v=Q[H.a];P=Q[H.b];U=Q[H.c];R=Q[H.d];if(v.__visible&&
-P.__visible&&U.__visible&&R.__visible&&(J.doubleSided||J.flipSided!=((R.positionScreen.x-v.positionScreen.x)*(P.positionScreen.y-v.positionScreen.y)-(R.positionScreen.y-v.positionScreen.y)*(P.positionScreen.x-v.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(R.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(R.positionScreen.x-U.positionScreen.x)<0))){e=g[j]=g[j]||new THREE.RenderableFace3;e.v1.positionWorld.copy(v.positionWorld);e.v2.positionWorld.copy(P.positionWorld);
-e.v3.positionWorld.copy(R.positionWorld);e.v1.positionScreen.copy(v.positionScreen);e.v2.positionScreen.copy(P.positionScreen);e.v3.positionScreen.copy(R.positionScreen);e.normalWorld.copy(H.normal);ma.multiplyVector3(e.normalWorld);e.centroidWorld.copy(H.centroid);ja.multiplyVector3(e.centroidWorld);e.centroidScreen.copy(e.centroidWorld);k.multiplyVector3(e.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterials=ka;e.faceMaterials=H.materials;e.overdraw=la;if(J.geometry.uvs[s]){e.uvs[0]=J.geometry.uvs[s][0];
-e.uvs[1]=J.geometry.uvs[s][1];e.uvs[2]=J.geometry.uvs[s][3]}x.push(e);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(P.positionWorld);h.v2.positionWorld.copy(U.positionWorld);h.v3.positionWorld.copy(R.positionWorld);h.v1.positionScreen.copy(P.positionScreen);h.v2.positionScreen.copy(U.positionScreen);h.v3.positionScreen.copy(R.positionScreen);h.normalWorld.copy(e.normalWorld);h.centroidWorld.copy(e.centroidWorld);h.centroidScreen.copy(e.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
-ka;h.faceMaterials=H.materials;h.overdraw=la;if(J.geometry.uvs[s]){h.uvs[0]=J.geometry.uvs[s][1];h.uvs[1]=J.geometry.uvs[s][2];h.uvs[2]=J.geometry.uvs[s][3]}x.push(h);j++}}}}else if(J instanceof THREE.Line){E.multiply(k,ja);Q=J.geometry.vertices;H=Q[0];H.positionScreen.copy(H.position);E.multiplyVector4(H.positionScreen);s=1;for(O=Q.length;s<O;s++){v=Q[s];v.positionScreen.copy(v.position);E.multiplyVector4(v.positionScreen);P=Q[s-1];I.copy(v.positionScreen);F.copy(P.positionScreen);if(b(I,F)){I.multiplyScalar(1/
-I.w);F.multiplyScalar(1/F.w);i=n[m]=n[m]||new THREE.RenderableLine;i.v1.positionScreen.copy(I);i.v2.positionScreen.copy(F);i.z=Math.max(I.z,F.z);i.materials=J.materials;x.push(i);m++}}}else if(J instanceof THREE.Particle){r.set(J.position.x,J.position.y,J.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=t[p]=t[p]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=J.rotation.z;o.scale.x=J.scale.x*Math.abs(o.x-(r.x+z.projectionMatrix.n11)/(r.w+z.projectionMatrix.n14));
-o.scale.y=J.scale.y*Math.abs(o.y-(r.y+z.projectionMatrix.n22)/(r.w+z.projectionMatrix.n24));o.materials=J.materials;x.push(o);p++}}}}K&&x.sort(a);return x};this.unprojectVector=function(B,z){var K=THREE.Matrix4.makeInvert(z.globalMatrix);K.multiplySelf(THREE.Matrix4.makeInvert(z.projectionMatrix));K.multiplyVector3(B);return B}};
-THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(p!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}p=V}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),e,h,j,g,i=f.getContext("2d"),m=new THREE.Color(0),n=0,o=1,p=0,t=null,u=null,r=1,k,E,D,I,F,N,B,z,K,x=new THREE.Color,
-L=new THREE.Color,C=new THREE.Color,w=new THREE.Color,s=new THREE.Color,O,v,P,Y,J,ja,ka,la,ma,$=new THREE.Rectangle,Q=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,R=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,S=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas");
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){e=V;h=da;j=e/2;g=h/2;f.width=e;f.height=h;$.set(-j,-g,j,g);o=1;p=0;u=t=null;r=1};this.setClearColor=function(V,da){m=V;n=da;Q.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(V,da){m.setHex(V);n=da;Q.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=
-function(){i.setTransform(1,0,0,-1,j,g);if(!Q.isEmpty()){Q.inflate(1);Q.minSelf($);if(m.hex==0&&n==0)i.clearRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(m.r*255)+","+Math.floor(m.g*255)+","+Math.floor(m.b*255)+","+n+")";i.fillRect(Q.getX(),Q.getY(),Q.getWidth(),Q.getHeight())}Q.empty()}};this.render=function(V,da){function Ma(l){var G,A,q,y=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(G=y.length;l<G;l++){A=
-y[l];q=A.color;if(A instanceof THREE.AmbientLight){aa.r+=q.r;aa.g+=q.g;aa.b+=q.b}else if(A instanceof THREE.DirectionalLight){na.r+=q.r;na.g+=q.g;na.b+=q.b}else if(A instanceof THREE.PointLight){oa.r+=q.r;oa.g+=q.g;oa.b+=q.b}}}function ya(l,G,A,q){var y,M,W,X,Z=l.lights;l=0;for(y=Z.length;l<y;l++){M=Z[l];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=A.dot(M.position)*X;if(M>0){q.r+=W.r*M;q.g+=W.g*M;q.b+=W.b*M}}else if(M instanceof THREE.PointLight){S.sub(M.position,G);S.normalize();
-M=A.dot(S)*X;if(M>0){q.r+=W.r*M;q.g+=W.g*M;q.b+=W.b*M}}}}function Na(l,G,A){if(A.opacity!=0){a(A.opacity);b(A.blending);var q,y,M,W,X,Z;if(A instanceof THREE.ParticleBasicMaterial){if(A.map){W=A.map.image;X=W.width>>1;Z=W.height>>1;y=G.scale.x*j;M=G.scale.y*g;A=y*X;q=M*Z;H.set(l.x-A,l.y-q,l.x+A,l.y+q);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(y,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(A instanceof THREE.ParticleCircleMaterial){if(U){R.r=
-aa.r+na.r+oa.r;R.g=aa.g+na.g+oa.g;R.b=aa.b+na.b+oa.b;x.r=A.color.r*R.r;x.g=A.color.g*R.g;x.b=A.color.b*R.b;x.updateStyleString()}else x.__styleString=A.color.__styleString;A=G.scale.x*j;q=G.scale.y*g;H.set(l.x-A,l.y-q,l.x+A,l.y+q);if($.instersects(H)){y=x.__styleString;if(u!=y)i.fillStyle=u=y;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(A,q);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,A,q){if(q.opacity!=0){a(q.opacity);b(q.blending);i.beginPath();
-i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(q instanceof THREE.LineBasicMaterial){x.__styleString=q.color.__styleString;l=q.linewidth;if(r!=l)i.lineWidth=r=l;l=x.__styleString;if(t!=l)i.strokeStyle=t=l;i.stroke();H.inflate(q.linewidth*2)}}}function Ha(l,G,A,q,y,M){if(y.opacity!=0){a(y.opacity);b(y.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;B=G.positionScreen.y;z=A.positionScreen.x;K=A.positionScreen.y;
-i.beginPath();i.moveTo(I,F);i.lineTo(N,B);i.lineTo(z,K);i.lineTo(I,F);i.closePath();if(y instanceof THREE.MeshBasicMaterial)if(y.map)y.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,B,z,K,y.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(y.env_map){if(y.env_map.mapping instanceof THREE.SphericalReflectionMapping){l=da.globalMatrix;S.copy(q.vertexNormalsWorld[0]);Y=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;J=-(S.x*l.n21+S.y*l.n22+S.z*l.n23)*0.5+0.5;S.copy(q.vertexNormalsWorld[1]);
-ja=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;ka=-(S.x*l.n21+S.y*l.n22+S.z*l.n23)*0.5+0.5;S.copy(q.vertexNormalsWorld[2]);la=(S.x*l.n11+S.y*l.n12+S.z*l.n13)*0.5+0.5;ma=-(S.x*l.n21+S.y*l.n22+S.z*l.n23)*0.5+0.5;ua(I,F,N,B,z,K,y.env_map.image,Y,J,ja,ka,la,ma)}}else y.wireframe?za(y.color.__styleString,y.wireframe_linewidth):Aa(y.color.__styleString);else if(y instanceof THREE.MeshLambertMaterial){if(y.map&&!y.wireframe){y.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,B,z,K,y.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);b(THREE.SubtractiveBlending)}if(U)if(!y.wireframe&&y.shading==THREE.SmoothShading&&q.vertexNormalsWorld.length==3){L.r=C.r=w.r=aa.r;L.g=C.g=w.g=aa.g;L.b=C.b=w.b=aa.b;ya(M,q.v1.positionWorld,q.vertexNormalsWorld[0],L);ya(M,q.v2.positionWorld,q.vertexNormalsWorld[1],C);ya(M,q.v3.positionWorld,q.vertexNormalsWorld[2],w);s.r=(C.r+w.r)*0.5;s.g=(C.g+w.g)*0.5;s.b=(C.b+w.b)*0.5;P=Ia(L,C,w,s);ua(I,F,N,B,z,K,P,0,0,1,0,0,1)}else{R.r=aa.r;R.g=aa.g;R.b=aa.b;ya(M,q.centroidWorld,
-q.normalWorld,R);x.r=y.color.r*R.r;x.g=y.color.g*R.g;x.b=y.color.b*R.b;x.updateStyleString();y.wireframe?za(x.__styleString,y.wireframe_linewidth):Aa(x.__styleString)}else y.wireframe?za(y.color.__styleString,y.wireframe_linewidth):Aa(y.color.__styleString)}else if(y instanceof THREE.MeshDepthMaterial){O=da.near;v=da.far;L.r=L.g=L.b=1-Da(l.positionScreen.z,O,v);C.r=C.g=C.b=1-Da(G.positionScreen.z,O,v);w.r=w.g=w.b=1-Da(A.positionScreen.z,O,v);s.r=(C.r+w.r)*0.5;s.g=(C.g+w.g)*0.5;s.b=(C.b+w.b)*0.5;P=
-Ia(L,C,w,s);ua(I,F,N,B,z,K,P,0,0,1,0,0,1)}else if(y instanceof THREE.MeshNormalMaterial){x.r=Ea(q.normalWorld.x);x.g=Ea(q.normalWorld.y);x.b=Ea(q.normalWorld.z);x.updateStyleString();y.wireframe?za(x.__styleString,y.wireframe_linewidth):Aa(x.__styleString)}}}function za(l,G){if(t!=l)i.strokeStyle=t=l;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(l){if(u!=l)i.fillStyle=u=l;i.fill()}function ua(l,G,A,q,y,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=
-ia;ha*=ea;va*=ia;A-=l;q-=G;y-=l;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*A-ca*y)*ia;ca=(va*q-ca*M)*ia;A=(ga*y-ha*A)*ia;q=(ga*M-ha*q)*ia;l=l-ea*X-A*Z;G=G-ca*X-q*Z;i.save();i.transform(ea,ca,A,q,l,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,G,A,q){var y=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(A.r*255),ga=~~(A.g*255);A=~~(A.b*255);var ca=~~(q.r*255),ha=~~(q.g*255);q=~~(q.b*255);ba[0]=y<0?0:y>255?255:y;ba[1]=
-M<0?0:M>255?255:M;ba[2]=l<0?0:l>255?255:l;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?255:ga;ba[10]=A<0?0:A>255?255:A;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=q<0?0:q>255?255:q;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,G,A){l=(l-G)/(A-G);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,G){var A=G.x-l.x,q=G.y-l.y,y=1/Math.sqrt(A*A+q*q);A*=y;q*=y;G.x+=
-A;G.y+=q;l.x-=A;l.y-=q}var Ba,Ja,T,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,g);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){T=c[Ba];H.empty();if(T instanceof THREE.RenderableParticle){k=T;k.x*=j;k.y*=g;fa=0;for(qa=T.materials.length;fa<qa;fa++)Na(k,T,T.materials[fa],V)}else if(T instanceof THREE.RenderableLine){k=T.v1;E=T.v2;k.positionScreen.x*=j;k.positionScreen.y*=g;E.positionScreen.x*=j;E.positionScreen.y*=g;
-H.addPoint(k.positionScreen.x,k.positionScreen.y);H.addPoint(E.positionScreen.x,E.positionScreen.y);if($.instersects(H)){fa=0;for(qa=T.materials.length;fa<qa;)Oa(k,E,T,T.materials[fa++],V)}}else if(T instanceof THREE.RenderableFace3){k=T.v1;E=T.v2;D=T.v3;k.positionScreen.x*=j;k.positionScreen.y*=g;E.positionScreen.x*=j;E.positionScreen.y*=g;D.positionScreen.x*=j;D.positionScreen.y*=g;if(T.overdraw){Fa(k.positionScreen,E.positionScreen);Fa(E.positionScreen,D.positionScreen);Fa(D.positionScreen,k.positionScreen)}H.add3Points(k.positionScreen.x,
-k.positionScreen.y,E.positionScreen.x,E.positionScreen.y,D.positionScreen.x,D.positionScreen.y);if($.instersects(H)){fa=0;for(qa=T.meshMaterials.length;fa<qa;){wa=T.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=T.faceMaterials.length;Ga<Ka;)(wa=T.faceMaterials[Ga++])&&Ha(k,E,D,T,wa,V)}else Ha(k,E,D,T,wa,V)}}}Q.addRectangle(H)}i.setTransform(1,0,0,1,0,0)}};THREE.RenderableObject=function(){this.z=this.object=null};
+THREE.Projector=function(){function a(A,w){return w.z-A.z}function b(A,w){var K=0,u=1,L=A.z+A.w,E=w.z+w.w,y=-A.z+A.w,B=-w.z+w.w;if(L>=0&&E>=0&&y>=0&&B>=0)return!0;else if(L<0&&E<0||y<0&&B<0)return!1;else{if(L<0)K=Math.max(K,L/(L-E));else E<0&&(u=Math.min(u,L/(L-E)));if(y<0)K=Math.max(K,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(u<K)return!1;else{A.lerpSelf(w,K);w.lerpSelf(A,1-u);return!0}}}var c,d,f=[],e,h,j,g=[],i,m,n=[],o,q,s=[],t=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,D=new THREE.Matrix4,
+C=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,F=new THREE.Vector4,N;this.projectObjects=function(A,w,K){w=[];var u,L,E;d=0;L=A.objects;A=0;for(u=L.length;A<u;A++){E=L[A];var y;if(!(y=!E.visible))if(y=E instanceof THREE.Mesh){a:{y=void 0;for(var B=E.globalMatrix,T=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),x=0;x<6;x++){y=C[x].x*B.n14+C[x].y*B.n24+C[x].z*B.n34+C[x].w;if(y<=
+T){y=!1;break a}}y=!0}y=!y}if(!y){c=f[d]=f[d]||new THREE.RenderableObject;t.copy(E.position);k.multiplyVector3(t);c.object=E;c.z=t.z;w.push(c);d++}}K&&w.sort(a);return w};this.projectScene=function(A,w,K){var u=[],L=w.near,E=w.far,y,B,T,x,P,Y,J,ja,ka,la,ma,$,O,H,U,Q;j=m=q=0;w.matrixAutoUpdate&&w.update();k.multiply(w.projectionMatrix,w.globalMatrix);C[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);C[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);C[2].set(k.n41+k.n21,k.n42+k.n22,
+k.n43+k.n23,k.n44+k.n24);C[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);C[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);C[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(y=0;y<6;y++){Y=C[y];Y.divideScalar(Math.sqrt(Y.x*Y.x+Y.y*Y.y+Y.z*Y.z))}A.update(undefined,!1,w);Y=this.projectObjects(A,w,!0);A=0;for(y=Y.length;A<y;A++){J=Y[A].object;if(J.visible){J.matrixAutoUpdate&&J.updateMatrix();ja=J.globalMatrix;ma=J.matrixRotation;ka=J.materials;la=J.overdraw;if(J instanceof
+THREE.Mesh){$=J.geometry;O=$.vertices;B=0;for(T=O.length;B<T;B++){H=O[B];H.positionWorld.copy(H.position);ja.multiplyVector3(H.positionWorld);x=H.positionScreen;x.copy(H.positionWorld);k.multiplyVector4(x);x.x/=x.w;x.y/=x.w;H.__visible=x.z>L&&x.z<E}$=$.faces;B=0;for(T=$.length;B<T;B++){H=$[B];if(H instanceof THREE.Face3){x=O[H.a];P=O[H.b];U=O[H.c];if(x.__visible&&P.__visible&&U.__visible&&(J.doubleSided||J.flipSided!=(U.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-
+(U.positionScreen.y-x.positionScreen.y)*(P.positionScreen.x-x.positionScreen.x)<0)){e=g[j]=g[j]||new THREE.RenderableFace3;e.v1.positionWorld.copy(x.positionWorld);e.v2.positionWorld.copy(P.positionWorld);e.v3.positionWorld.copy(U.positionWorld);e.v1.positionScreen.copy(x.positionScreen);e.v2.positionScreen.copy(P.positionScreen);e.v3.positionScreen.copy(U.positionScreen);e.normalWorld.copy(H.normal);ma.multiplyVector3(e.normalWorld);e.centroidWorld.copy(H.centroid);ja.multiplyVector3(e.centroidWorld);
+e.centroidScreen.copy(e.centroidWorld);k.multiplyVector3(e.centroidScreen);U=H.vertexNormals;N=e.vertexNormalsWorld;x=0;for(P=U.length;x<P;x++){Q=N[x]=N[x]||new THREE.Vector3;Q.copy(U[x]);ma.multiplyVector3(Q)}e.z=e.centroidScreen.z;e.meshMaterials=ka;e.faceMaterials=H.materials;e.overdraw=la;if(J.geometry.uvs[B]){e.uvs[0]=J.geometry.uvs[B][0];e.uvs[1]=J.geometry.uvs[B][1];e.uvs[2]=J.geometry.uvs[B][2]}u.push(e);j++}}else if(H instanceof THREE.Face4){x=O[H.a];P=O[H.b];U=O[H.c];Q=O[H.d];if(x.__visible&&
+P.__visible&&U.__visible&&Q.__visible&&(J.doubleSided||J.flipSided!=((Q.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(Q.positionScreen.y-x.positionScreen.y)*(P.positionScreen.x-x.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-U.positionScreen.x)<0))){e=g[j]=g[j]||new THREE.RenderableFace3;e.v1.positionWorld.copy(x.positionWorld);e.v2.positionWorld.copy(P.positionWorld);
+e.v3.positionWorld.copy(Q.positionWorld);e.v1.positionScreen.copy(x.positionScreen);e.v2.positionScreen.copy(P.positionScreen);e.v3.positionScreen.copy(Q.positionScreen);e.normalWorld.copy(H.normal);ma.multiplyVector3(e.normalWorld);e.centroidWorld.copy(H.centroid);ja.multiplyVector3(e.centroidWorld);e.centroidScreen.copy(e.centroidWorld);k.multiplyVector3(e.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterials=ka;e.faceMaterials=H.materials;e.overdraw=la;if(J.geometry.uvs[B]){e.uvs[0]=J.geometry.uvs[B][0];
+e.uvs[1]=J.geometry.uvs[B][1];e.uvs[2]=J.geometry.uvs[B][3]}u.push(e);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(P.positionWorld);h.v2.positionWorld.copy(U.positionWorld);h.v3.positionWorld.copy(Q.positionWorld);h.v1.positionScreen.copy(P.positionScreen);h.v2.positionScreen.copy(U.positionScreen);h.v3.positionScreen.copy(Q.positionScreen);h.normalWorld.copy(e.normalWorld);h.centroidWorld.copy(e.centroidWorld);h.centroidScreen.copy(e.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=
+ka;h.faceMaterials=H.materials;h.overdraw=la;if(J.geometry.uvs[B]){h.uvs[0]=J.geometry.uvs[B][1];h.uvs[1]=J.geometry.uvs[B][2];h.uvs[2]=J.geometry.uvs[B][3]}u.push(h);j++}}}}else if(J instanceof THREE.Line){D.multiply(k,ja);O=J.geometry.vertices;H=O[0];H.positionScreen.copy(H.position);D.multiplyVector4(H.positionScreen);B=1;for(T=O.length;B<T;B++){x=O[B];x.positionScreen.copy(x.position);D.multiplyVector4(x.positionScreen);P=O[B-1];I.copy(x.positionScreen);F.copy(P.positionScreen);if(b(I,F)){I.multiplyScalar(1/
+I.w);F.multiplyScalar(1/F.w);i=n[m]=n[m]||new THREE.RenderableLine;i.v1.positionScreen.copy(I);i.v2.positionScreen.copy(F);i.z=Math.max(I.z,F.z);i.materials=J.materials;u.push(i);m++}}}else if(J instanceof THREE.Particle){r.set(J.position.x,J.position.y,J.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=J.rotation.z;o.scale.x=J.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14));
+o.scale.y=J.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=J.materials;u.push(o);q++}}}}K&&u.sort(a);return u};this.unprojectVector=function(A,w){var K=THREE.Matrix4.makeInvert(w.globalMatrix);K.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));K.multiplyVector3(A);return A}};
+THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),e,h,j,g,i=f.getContext("2d"),m=new THREE.Color(0),n=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,K,u=new THREE.Color,
+L=new THREE.Color,E=new THREE.Color,y=new THREE.Color,B=new THREE.Color,T,x,P,Y,J,ja,ka,la,ma,$=new THREE.Rectangle,O=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,Q=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,R=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas");
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){e=V;h=da;j=e/2;g=h/2;f.width=e;f.height=h;$.set(-j,-g,j,g);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){m=V;n=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(V,da){m.setHex(V);n=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=
+function(){i.setTransform(1,0,0,-1,j,g);if(!O.isEmpty()){O.inflate(1);O.minSelf($);if(m.hex==0&&n==0)i.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(m.r*255)+","+Math.floor(m.g*255)+","+Math.floor(m.b*255)+","+n+")";i.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(V,da){function Ma(l){var G,z,p,v=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(G=v.length;l<G;l++){z=
+v[l];p=z.color;if(z instanceof THREE.AmbientLight){aa.r+=p.r;aa.g+=p.g;aa.b+=p.b}else if(z instanceof THREE.DirectionalLight){na.r+=p.r;na.g+=p.g;na.b+=p.b}else if(z instanceof THREE.PointLight){oa.r+=p.r;oa.g+=p.g;oa.b+=p.b}}}function ya(l,G,z,p){var v,M,W,X,Z=l.lights;l=0;for(v=Z.length;l<v;l++){M=Z[l];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=z.dot(M.position)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}else if(M instanceof THREE.PointLight){R.sub(M.position,G);R.normalize();
+M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(l,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p,v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*g;z=v*X;p=M*Z;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r=
+aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;z=G.scale.x*j;p=G.scale.y*g;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath();
+i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString=p.color.__styleString;l=p.linewidth;if(r!=l)i.lineWidth=r=l;l=u.__styleString;if(s!=l)i.strokeStyle=s=l;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(l,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;K=z.positionScreen.y;
+i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,K);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,K,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.env_map){if(v.env_map.mapping instanceof THREE.SphericalReflectionMapping){l=da.globalMatrix;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;J=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]);
+ja=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ka=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ma=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;ua(I,F,N,A,w,K,v.env_map.image,Y,J,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframe_linewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,K,v.map.image,p.uvs[0].u,p.uvs[0].v,
+p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3){L.r=E.r=y.r=aa.r;L.g=E.g=y.g=aa.g;L.b=E.b=y.b=aa.b;ya(M,p.v1.positionWorld,p.vertexNormalsWorld[0],L);ya(M,p.v2.positionWorld,p.vertexNormalsWorld[1],E);ya(M,p.v3.positionWorld,p.vertexNormalsWorld[2],y);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(L,E,y,B);ua(I,F,N,A,w,K,P,0,0,1,0,0,1)}else{Q.r=aa.r;Q.g=aa.g;Q.b=aa.b;ya(M,p.centroidWorld,
+p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframe_linewidth):Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframe_linewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;L.r=L.g=L.b=1-Da(l.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=
+Ia(L,E,y,B);ua(I,F,N,A,w,K,P,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){u.r=Ea(p.normalWorld.x);u.g=Ea(p.normalWorld.y);u.b=Ea(p.normalWorld.z);u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframe_linewidth):Aa(u.__styleString)}}}function za(l,G){if(s!=l)i.strokeStyle=s=l;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(l){if(t!=l)i.fillStyle=t=l;i.fill()}function ua(l,G,z,p,v,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=
+ia;ha*=ea;va*=ia;z-=l;p-=G;v-=l;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*z-ca*v)*ia;ca=(va*p-ca*M)*ia;z=(ga*v-ha*z)*ia;p=(ga*M-ha*p)*ia;l=l-ea*X-z*Z;G=G-ca*X-p*Z;i.save();i.transform(ea,ca,z,p,l,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,G,z,p){var v=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(z.r*255),ga=~~(z.g*255);z=~~(z.b*255);var ca=~~(p.r*255),ha=~~(p.g*255);p=~~(p.b*255);ba[0]=v<0?0:v>255?255:v;ba[1]=
+M<0?0:M>255?255:M;ba[2]=l<0?0:l>255?255:l;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?255:ga;ba[10]=z<0?0:z>255?255:z;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=p<0?0:p>255?255:p;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,G,z){l=(l-G)/(z-G);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,G){var z=G.x-l.x,p=G.y-l.y,v=1/Math.sqrt(z*z+p*p);z*=v;p*=v;G.x+=
+z;G.y+=p;l.x-=z;l.y-=p}var Ba,Ja,S,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,g);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){S=c[Ba];H.empty();if(S instanceof THREE.RenderableParticle){k=S;k.x*=j;k.y*=g;fa=0;for(qa=S.materials.length;fa<qa;fa++)Na(k,S,S.materials[fa],V)}else if(S instanceof THREE.RenderableLine){k=S.v1;D=S.v2;k.positionScreen.x*=j;k.positionScreen.y*=g;D.positionScreen.x*=j;D.positionScreen.y*=g;
+H.addPoint(k.positionScreen.x,k.positionScreen.y);H.addPoint(D.positionScreen.x,D.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.materials.length;fa<qa;)Oa(k,D,S,S.materials[fa++],V)}}else if(S instanceof THREE.RenderableFace3){k=S.v1;D=S.v2;C=S.v3;k.positionScreen.x*=j;k.positionScreen.y*=g;D.positionScreen.x*=j;D.positionScreen.y*=g;C.positionScreen.x*=j;C.positionScreen.y*=g;if(S.overdraw){Fa(k.positionScreen,D.positionScreen);Fa(D.positionScreen,C.positionScreen);Fa(C.positionScreen,k.positionScreen)}H.add3Points(k.positionScreen.x,
+k.positionScreen.y,D.positionScreen.x,D.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.meshMaterials.length;fa<qa;){wa=S.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=S.faceMaterials.length;Ga<Ka;)(wa=S.faceMaterials[Ga++])&&Ha(k,D,C,S,wa,V)}else Ha(k,D,C,S,wa,V)}}}O.addRectangle(H)}i.setTransform(1,0,0,1,0,0)}};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};

+ 40 - 43
build/custom/ThreeDOM.js

@@ -4,44 +4,41 @@ THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;th
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
-THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.x=c*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
-this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
-this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1};
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
+b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,e=this.z;this.set(c*a.z-e*a.y,e*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
+a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1};
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(p,k,C,y){y=y.clone().subSelf(k);C=C.clone().subSelf(k);var F=p.clone().subSelf(k);p=y.dot(y);k=y.dot(C);y=y.dot(F);var G=C.dot(C);C=C.dot(F);F=1/(p*G-k*k);G=(G*y-k*C)*F;p=(p*C-k*y)*F;return G>0&&p>0&&G+p<1}var c,e,d,f,g,i,h,j,m,n,
-l,o=a.geometry,q=o.vertices,r=[];c=0;for(e=o.faces.length;c<e;c++){d=o.faces[c];n=this.origin.clone();l=this.direction.clone();h=a.globalMatrix;h.extractRotationMatrix(a.matrixRotation);f=h.multiplyVector3(q[d.a].position.clone());g=h.multiplyVector3(q[d.b].position.clone());i=h.multiplyVector3(q[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(q[d.d].position.clone()):null;j=a.matrixRotation.multiplyVector3(d.normal.clone());m=l.dot(j);if(m<0){j=j.dot((new THREE.Vector3).sub(f,
-n))/m;n=n.addSelf(l.multiplyScalar(j));if(d instanceof THREE.Face3){if(b(n,f,g,i)){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};r.push(d)}}else if(d instanceof THREE.Face4&&(b(n,f,g,h)||b(n,g,i,h))){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};r.push(d)}}}return r}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,e=a.objects,d=[];a=0;for(b=e.length;a<b;a++){c=e[a];c instanceof THREE.Mesh&&(d=d.concat(this.intersectObject(c)))}d.sort(function(f,g){return f.distance-g.distance});return d},intersectObject:function(a){function b(r,k,B,x){x=x.clone().subSelf(k);B=B.clone().subSelf(k);var F=r.clone().subSelf(k);r=x.dot(x);k=x.dot(B);x=x.dot(F);var G=B.dot(B);B=B.dot(F);F=1/(r*G-k*k);G=(G*x-k*B)*F;r=(r*B-k*x)*F;return G>0&&r>0&&G+r<1}var c,e,d,f,g,i,h,j,m,n,
+l,o=a.geometry,p=o.vertices,q=[];c=0;for(e=o.faces.length;c<e;c++){d=o.faces[c];n=this.origin.clone();l=this.direction.clone();h=a.globalMatrix;f=h.multiplyVector3(p[d.a].position.clone());g=h.multiplyVector3(p[d.b].position.clone());i=h.multiplyVector3(p[d.c].position.clone());h=d instanceof THREE.Face4?h.multiplyVector3(p[d.d].position.clone()):null;j=a.matrixRotation.multiplyVector3(d.normal.clone());m=l.dot(j);if(m<0){j=j.dot((new THREE.Vector3).sub(f,n))/m;n=n.addSelf(l.multiplyScalar(j));if(d instanceof
+THREE.Face3){if(b(n,f,g,i)){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};q.push(d)}}else if(d instanceof THREE.Face4&&(b(n,f,g,h)||b(n,g,i,h))){d={distance:this.origin.distanceTo(n),point:n,face:d,object:a};q.push(d)}}}return q}};
 THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,m,n){i=!1;b=h;c=j;e=m;d=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
 THREE.Rectangle=function(){function a(){f=e-b;g=d-c}var b,c,e,d,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return d};this.set=function(h,j,m,n){i=!1;b=h;c=j;e=m;d=n;a()};this.addPoint=function(h,j){if(i){i=!1;b=h;c=j;e=h;d=j}else{b=b<h?b:h;c=c<j?c:j;e=e>h?e:h;d=d>j?d:j}a()};
 this.add3Points=function(h,j,m,n,l,o){if(i){i=!1;b=h<m?h<l?h:l:m<l?m:l;c=j<n?j<o?j:o:n<o?n:o;e=h>m?h>l?h:l:m>l?m:l;d=j>n?j>o?j:o:n>o?n:o}else{b=h<m?h<l?h<b?h:b:l<b?l:b:m<l?m<b?m:b:l<b?l:b;c=j<n?j<o?j<c?j:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;e=h>m?h>l?h>e?h:e:l>e?l:e:m>l?m>e?m:e:l>e?l:e;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
 this.add3Points=function(h,j,m,n,l,o){if(i){i=!1;b=h<m?h<l?h:l:m<l?m:l;c=j<n?j<o?j:o:n<o?n:o;e=h>m?h>l?h:l:m>l?m:l;d=j>n?j>o?j:o:n>o?n:o}else{b=h<m?h<l?h<b?h:b:l<b?l:b:m<l?m<b?m:b:l<b?l:b;c=j<n?j<o?j<c?j:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c;e=h>m?h>l?h>e?h:e:l>e?l:e:m>l?m>e?m:e:l>e?l:e;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();e=h.getRight();d=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();e=e>h.getRight()?
 e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=c=b=0;a()};this.isEmpty=function(){return i};this.toString=function(){return"THREE.Rectangle ( left: "+
 e:h.getRight();d=d>h.getBottom()?d:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;e+=h;d+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();e=e<h.getRight()?e:h.getRight();d=d<h.getBottom()?d:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(d,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;d=e=c=b=0;a()};this.isEmpty=function(){return i};this.toString=function(){return"THREE.Rectangle ( left: "+
 b+", right: "+e+", top: "+c+", bottom: "+d+", width: "+f+", height: "+g+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
 b+", right: "+e+", top: "+c+", bottom: "+d+", width: "+f+", height: "+g+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,e,d,f,g,i,h,j,m,n,l,o,q,r){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=d||0;this.n22=f||1;this.n23=g||0;this.n24=i||0;this.n31=h||0;this.n32=j||0;this.n33=m||1;this.n34=n||0;this.n41=l||0;this.n42=o||0;this.n43=q||0;this.n44=r||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,e,d,f,g,i,h,j,m,n,l,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=m;this.n34=n;this.n41=l;this.n42=o;this.n43=q;this.n44=r;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,d=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();d.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=d.x;this.n22=d.y;this.n23=d.z;this.n24=-d.dot(a);
-this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
-a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*d;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
-a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,n=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44,C=b.n11,y=b.n12,F=b.n13,G=b.n14,J=b.n21,w=b.n22,u=b.n23,D=b.n24,A=b.n31,E=b.n32,z=b.n33,v=b.n34,t=b.n41,I=b.n42,s=b.n43,H=b.n44;this.n11=c*C+e*J+d*A+f*t;this.n12=c*y+e*w+d*E+f*I;this.n13=c*F+e*u+d*z+f*s;this.n14=c*G+e*D+d*v+f*H;this.n21=g*C+i*J+h*A+j*t;this.n22=g*y+i*w+h*E+j*I;this.n23=g*F+
-i*u+h*z+j*s;this.n24=g*G+i*D+h*v+j*H;this.n31=m*C+n*J+l*A+o*t;this.n32=m*y+n*w+l*E+o*I;this.n33=m*F+n*u+l*z+o*s;this.n34=m*G+n*D+l*v+o*H;this.n41=q*C+r*J+p*A+k*t;this.n42=q*y+r*w+p*E+k*I;this.n43=q*F+r*u+p*z+k*s;this.n44=q*G+r*D+p*v+k*H;return this},multiplyToArray:function(a,b,c){var e=a.n11,d=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,j=a.n23,m=a.n24,n=a.n31,l=a.n32,o=a.n33,q=a.n34,r=a.n41,p=a.n42,k=a.n43;a=a.n44;var C=b.n11,y=b.n12,F=b.n13,G=b.n14,J=b.n21,w=b.n22,u=b.n23,D=b.n24,A=b.n31,E=b.n32,z=b.n33,
-v=b.n34,t=b.n41,I=b.n42,s=b.n43;b=b.n44;this.n11=e*C+d*J+f*A+g*t;this.n12=e*y+d*w+f*E+g*I;this.n13=e*F+d*u+f*z+g*s;this.n14=e*G+d*D+f*v+g*b;this.n21=i*C+h*J+j*A+m*t;this.n22=i*y+h*w+j*E+m*I;this.n23=i*F+h*u+j*z+m*s;this.n24=i*G+h*D+j*v+m*b;this.n31=n*C+l*J+o*A+q*t;this.n32=n*y+l*w+o*E+q*I;this.n33=n*F+l*u+o*z+q*s;this.n34=n*G+l*D+o*v+q*b;this.n41=r*C+p*J+k*A+a*t;this.n42=r*y+p*w+k*E+a*I;this.n43=r*F+p*u+k*z+a*s;this.n44=r*G+p*D+k*v+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=
-this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,d=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,j=this.n31,m=this.n32,n=this.n33,l=this.n34,o=this.n41,q=this.n42,r=this.n43,p=this.n44,k=a.n11,C=a.n21,y=a.n31,F=a.n41,G=a.n12,J=a.n22,w=a.n32,u=a.n42,D=a.n13,A=a.n23,E=a.n33,z=a.n43,v=a.n14,t=a.n24,I=
-a.n34;a=a.n44;this.n11=b*k+c*C+e*y+d*F;this.n12=b*G+c*J+e*w+d*u;this.n13=b*D+c*A+e*E+d*z;this.n14=b*v+c*t+e*I+d*a;this.n21=f*k+g*C+i*y+h*F;this.n22=f*G+g*J+i*w+h*u;this.n23=f*D+g*A+i*E+h*z;this.n24=f*v+g*t+i*I+h*a;this.n31=j*k+m*C+n*y+l*F;this.n32=j*G+m*J+n*w+l*u;this.n33=j*D+m*A+n*E+l*z;this.n34=j*v+m*t+n*I+l*a;this.n41=o*k+q*C+r*y+p*F;this.n42=o*G+q*J+r*w+p*u;this.n43=o*D+q*A+r*E+p*z;this.n44=o*v+q*t+r*I+p*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;
-this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,m=this.n33,n=this.n34,l=this.n41,o=this.n42,q=this.n43,r=this.n44;return e*g*j*l-c*i*j*l-e*f*m*l+b*i*m*l+c*f*n*l-b*g*n*l-e*g*h*o+c*i*h*o+e*d*m*o-a*i*m*o-c*d*n*o+a*g*n*o+e*f*h*q-b*i*h*q-e*d*j*q+a*i*j*q+b*d*n*
-q-a*f*n*q-c*f*h*r+b*g*h*r+c*d*j*r-a*g*j*r-b*d*m*r+a*f*m*r},transpose:function(){function a(b,c,e){var d=b[c];b[c]=b[e];b[e]=d}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;
-a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,
-0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),d=1-c,f=a.x,g=a.y,i=a.z,h=d*f,j=d*g;this.set(h*f+c,h*g-e*i,h*i+e*g,0,h*g+e*i,
-j*g+c,j*i-e*f,0,h*i-e*g,j*i+e*f,d*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,i=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=i*f+a*e;this.n22=-i*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,d=
-a.w,f=b+b,g=c+c,i=e+e;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;e*=i;f*=d;g*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;
-a.n22=this.n22;a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},extractPositionVector:function(a){a.x=this.n14;a.y=this.n24;a.z=this.n34},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
+THREE.Matrix4=function(a,b,c,e,d,f,g,i,h,j,m,n,l,o,p,q){this.set(a||1,b||0,c||0,e||0,d||0,f||1,g||0,i||0,h||0,j||0,m||1,n||0,l||0,o||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,e,d,f,g,i,h,j,m,n,l,o,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=d;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=m;this.n34=n;this.n41=l;this.n42=o;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,
+d=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();d.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=d.x;this.n22=d.y;this.n23=d.z;this.n24=-d.dot(a);this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,d=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*d;a.y=
+(this.n21*b+this.n22*c+this.n23*e+this.n24)*d;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*d;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,d=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*d;a.y=this.n21*b+this.n22*c+this.n23*e+this.n24*d;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*d;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*
+d;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,n=a.n32,l=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44,B=b.n11,x=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,
+t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,y=b.n34;this.n11=c*B+e*I+d*z;this.n12=c*x+e*v+d*D;this.n13=c*F+e*t+d*E;this.n14=c*G+e*C+d*y+f;this.n21=g*B+i*I+h*z;this.n22=g*x+i*v+h*D;this.n23=g*F+i*t+h*E;this.n24=g*G+i*C+h*y+j;this.n31=m*B+n*I+l*z;this.n32=m*x+n*v+l*D;this.n33=m*F+n*t+l*E;this.n34=m*G+n*C+l*y+o;this.n41=p*B+q*I+r*z;this.n42=p*x+q*v+r*D;this.n43=p*F+q*t+r*E;this.n44=p*G+q*C+r*y+k;return this},multiplyToArray:function(a,b,c){var e=a.n11,d=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,j=a.n23,m=a.n24,
+n=a.n31,l=a.n32,o=a.n33,p=a.n34,q=a.n41,r=a.n42,k=a.n43;a=a.n44;var B=b.n11,x=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,y=b.n34,u=b.n41,L=b.n42,s=b.n43;b=b.n44;this.n11=e*B+d*I+f*z+g*u;this.n12=e*x+d*v+f*D+g*L;this.n13=e*F+d*t+f*E+g*s;this.n14=e*G+d*C+f*y+g*b;this.n21=i*B+h*I+j*z+m*u;this.n22=i*x+h*v+j*D+m*L;this.n23=i*F+h*t+j*E+m*s;this.n24=i*G+h*C+j*y+m*b;this.n31=n*B+l*I+o*z+p*u;this.n32=n*x+l*v+o*D+p*L;this.n33=n*F+l*t+o*E+p*s;this.n34=n*G+l*C+o*y+p*b;this.n41=
+q*B+r*I+k*z+a*u;this.n42=q*x+r*v+k*D+a*L;this.n43=q*F+r*t+k*E+a*s;this.n44=q*G+r*C+k*y+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,d=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,j=this.n31,m=this.n32,n=this.n33,l=this.n34,o=this.n41,
+p=this.n42,q=this.n43,r=this.n44,k=a.n11,B=a.n21,x=a.n31,F=a.n12,G=a.n22,I=a.n32,v=a.n13,t=a.n23,C=a.n33,z=a.n14,D=a.n24;a=a.n34;this.n11=b*k+c*B+e*x;this.n12=b*F+c*G+e*I;this.n13=b*v+c*t+e*C;this.n14=b*z+c*D+e*a+d;this.n21=f*k+g*B+i*x;this.n22=f*F+g*G+i*I;this.n23=f*v+g*t+i*C;this.n24=f*z+g*D+i*a+h;this.n31=j*k+m*B+n*x;this.n32=j*F+m*G+n*I;this.n33=j*v+m*t+n*C;this.n34=j*z+m*D+n*a+l;this.n41=o*k+p*B+q*x;this.n42=o*F+p*G+q*I;this.n43=o*v+p*t+q*C;this.n44=o*z+p*D+q*a+r;return this},multiplyScalar:function(a){this.n11*=
+a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,d=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,m=this.n33,n=this.n34,l=this.n41,o=this.n42,p=this.n43,q=this.n44;return e*g*j*l-c*i*j*l-e*f*m*l+b*i*m*l+c*f*n*l-b*g*n*l-e*g*h*o+c*i*h*o+e*d*m*o-a*i*m*o-c*d*n*o+a*g*n*o+
+e*f*h*p-b*i*h*p-e*d*j*p+a*i*j*p+b*d*n*p-a*f*n*p-c*f*h*q+b*g*h*q+c*d*j*q-a*g*j*q-b*d*m*q+a*f*m*q},transpose:function(){function a(b,c,e){var d=b[c];b[c]=b[e];b[e]=d}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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.flattenToArray(this.flat);return flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=
+this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
+Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b),d=1-c,f=a.x,g=a.y,i=a.z,h=d*f,j=d*g;this.set(h*f+c,h*g-e*i,h*i+e*g,0,h*g+e*i,j*g+c,j*i-e*f,0,h*i-e*g,j*i+e*f,d*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=
+a.x,c=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var d=Math.cos(c);c=Math.sin(c);var f=Math.cos(e);e=Math.sin(e);var g=a*c,i=b*c;this.n11=d*f;this.n12=-d*e;this.n13=c;this.n21=i*f+a*e;this.n22=-i*e+a*f;this.n23=-b*d;this.n31=-g*f+b*e;this.n32=g*e+b*f;this.n33=a*d},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,e=a.z,d=a.w,f=b+b,g=c+c,i=e+e;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;e*=i;f*=d;g*=d;d*=i;this.n11=1-(j+e);this.n12=h-d;this.n13=b+g;this.n21=h+d;this.n22=1-(a+e);this.n23=c-f;this.n31=b-g;this.n32=
+c+f;this.n33=1-(a+j)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
 THREE.Matrix4.translationMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.translationMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e};THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,n=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-j*l*r+j*n*p-i*o*p-h*n*k+i*l*k;b.n12=f*l*r-d*o*r-f*n*p+e*o*p+d*n*k-e*l*k;b.n13=d*j*r-f*h*r+f*i*p-e*j*p-d*i*k+e*h*k;b.n14=f*h*n-d*j*n-f*i*l+e*j*l+d*i*o-e*h*o;b.n21=j*l*q-h*o*q-j*m*p+g*o*p+h*m*k-g*l*k;b.n22=d*o*q-f*l*q+f*m*p-c*o*p-d*m*k+c*l*k;b.n23=f*h*q-d*j*q-f*g*p+c*j*p+d*g*k-c*h*k;
-b.n24=d*j*m-f*h*m+f*g*l-c*j*l-d*g*o+c*h*o;b.n31=i*o*q-j*n*q+j*m*r-g*o*r-i*m*k+g*n*k;b.n32=f*n*q-e*o*q-f*m*r+c*o*r+e*m*k-c*n*k;b.n33=d*j*q-f*i*q+f*g*r-c*j*r-e*g*k+c*i*k;b.n34=f*i*m-e*j*m-f*g*n+c*j*n+e*g*o-c*i*o;b.n41=h*n*q-i*l*q-h*m*r+g*l*r+i*m*p-g*n*p;b.n42=e*l*q-d*n*q+d*m*r-c*l*r-e*m*p+c*n*p;b.n43=d*i*q-e*h*q-d*g*r+c*h*r+e*g*p-c*i*p;b.n44=e*h*m-d*i*m+d*g*n-c*h*n-e*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,e=a.n12,d=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,m=a.n31,n=a.n32,l=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*q-j*l*q+j*n*r-i*o*r-h*n*k+i*l*k;b.n12=f*l*q-d*o*q-f*n*r+e*o*r+d*n*k-e*l*k;b.n13=d*j*q-f*h*q+f*i*r-e*j*r-d*i*k+e*h*k;b.n14=f*h*n-d*j*n-f*i*l+e*j*l+d*i*o-e*h*o;b.n21=j*l*p-h*o*p-j*m*r+g*o*r+h*m*k-g*l*k;b.n22=d*o*p-f*l*p+f*m*r-c*o*r-d*m*k+c*l*k;b.n23=f*h*p-d*j*p-f*g*r+c*j*r+d*g*k-c*h*k;
+b.n24=d*j*m-f*h*m+f*g*l-c*j*l-d*g*o+c*h*o;b.n31=i*o*p-j*n*p+j*m*q-g*o*q-i*m*k+g*n*k;b.n32=f*n*p-e*o*p-f*m*q+c*o*q+e*m*k-c*n*k;b.n33=d*j*p-f*i*p+f*g*q-c*j*q-e*g*k+c*i*k;b.n34=f*i*m-e*j*m-f*g*n+c*j*n+e*g*o-c*i*o;b.n41=h*n*p-i*l*p-h*m*q+g*l*q+i*m*r-g*n*r;b.n42=e*l*p-d*n*p+d*m*q-c*l*q-e*m*r+c*n*r;b.n43=d*i*p-e*h*p-d*g*q+c*h*q+e*g*r-c*i*r;b.n44=e*h*m-d*i*m+d*g*n-c*h*n-e*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*m;c[8]=a*n;return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,d=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*d;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*m;c[8]=a*n;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
 THREE.Matrix4.makeFrustum=function(a,b,c,e,d,f){var g;g=new THREE.Matrix4;g.n11=2*d/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*d/(e-c);g.n23=(e+c)/(e-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+d)/(f-d);g.n34=-2*f*d/(f-d);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,e){var d;a=c*Math.tan(a*Math.PI/360);d=-a;return THREE.Matrix4.makeFrustum(d*b,a*b,d,a,c,e)};
 THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Matrix4.makeOrtho=function(a,b,c,e,d,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-e;j=f-d;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+e)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+d)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
@@ -65,18 +62,18 @@ THREE.Particle.prototype.constructor=THREE.Particle;THREE.Scene=function(){THREE
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(w,u){return u.z-w.z}function b(w,u){var D=0,A=1,E=w.z+w.w,z=u.z+u.w,v=-w.z+w.w,t=-u.z+u.w;if(E>=0&&z>=0&&v>=0&&t>=0)return!0;else if(E<0&&z<0||v<0&&t<0)return!1;else{if(E<0)D=Math.max(D,E/(E-z));else z<0&&(A=Math.min(A,E/(E-z)));if(v<0)D=Math.max(D,v/(v-t));else t<0&&(A=Math.min(A,v/(v-t)));if(A<D)return!1;else{w.lerpSelf(u,D);u.lerpSelf(w,1-A);return!0}}}var c,e,d=[],f,g,i,h=[],j,m,n=[],l,o,q=[],r=new THREE.Vector4,p=new THREE.Vector4,k=new THREE.Matrix4,C=new THREE.Matrix4,
-y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4,J;this.projectObjects=function(w,u,D){u=[];var A,E,z;e=0;E=w.objects;w=0;for(A=E.length;w<A;w++){z=E[w];var v;if(!(v=!z.visible))if(v=z instanceof THREE.Mesh){a:{v=void 0;for(var t=z.globalMatrix,I=-z.geometry.boundingSphere.radius*Math.max(z.scale.x,Math.max(z.scale.y,z.scale.z)),s=0;s<6;s++){v=y[s].x*t.n14+y[s].y*t.n24+y[s].z*t.n34+y[s].w;if(v<=
-I){v=!1;break a}}v=!0}v=!v}if(!v){c=d[e]=d[e]||new THREE.RenderableObject;r.copy(z.position);k.multiplyVector3(r);c.object=z;c.z=r.z;u.push(c);e++}}D&&u.sort(a);return u};this.projectScene=function(w,u,D){var A=[],E=u.near,z=u.far,v,t,I,s,H,N,x,P,Q,R,S,O,L,B,K,M;i=m=o=0;u.matrixAutoUpdate&&u.update();k.multiply(u.projectionMatrix,u.globalMatrix);y[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);y[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);y[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
-k.n23,k.n44+k.n24);y[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);y[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);y[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(v=0;v<6;v++){N=y[v];N.divideScalar(Math.sqrt(N.x*N.x+N.y*N.y+N.z*N.z))}w.update(undefined,!1,u);N=this.projectObjects(w,u,!0);w=0;for(v=N.length;w<v;w++){x=N[w].object;if(x.visible){x.matrixAutoUpdate&&x.updateMatrix();P=x.globalMatrix;S=x.matrixRotation;Q=x.materials;R=x.overdraw;if(x instanceof THREE.Mesh){O=
-x.geometry;L=O.vertices;t=0;for(I=L.length;t<I;t++){B=L[t];B.positionWorld.copy(B.position);P.multiplyVector3(B.positionWorld);s=B.positionScreen;s.copy(B.positionWorld);k.multiplyVector4(s);s.x/=s.w;s.y/=s.w;B.__visible=s.z>E&&s.z<z}O=O.faces;t=0;for(I=O.length;t<I;t++){B=O[t];if(B instanceof THREE.Face3){s=L[B.a];H=L[B.b];K=L[B.c];if(s.__visible&&H.__visible&&K.__visible&&(x.doubleSided||x.flipSided!=(K.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(K.positionScreen.y-
-s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(K.positionWorld);f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(K.positionScreen);f.normalWorld.copy(B.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(B.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
-k.multiplyVector3(f.centroidScreen);K=B.vertexNormals;J=f.vertexNormalsWorld;s=0;for(H=K.length;s<H;s++){M=J[s]=J[s]||new THREE.Vector3;M.copy(K[s]);S.multiplyVector3(M)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=B.materials;f.overdraw=R;if(x.geometry.uvs[t]){f.uvs[0]=x.geometry.uvs[t][0];f.uvs[1]=x.geometry.uvs[t][1];f.uvs[2]=x.geometry.uvs[t][2]}A.push(f);i++}}else if(B instanceof THREE.Face4){s=L[B.a];H=L[B.b];K=L[B.c];M=L[B.d];if(s.__visible&&H.__visible&&K.__visible&&M.__visible&&
-(x.doubleSided||x.flipSided!=((M.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(M.positionScreen.y-s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0||(H.positionScreen.x-K.positionScreen.x)*(M.positionScreen.y-K.positionScreen.y)-(H.positionScreen.y-K.positionScreen.y)*(M.positionScreen.x-K.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(M.positionWorld);
-f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(M.positionScreen);f.normalWorld.copy(B.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(B.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=B.materials;f.overdraw=R;if(x.geometry.uvs[t]){f.uvs[0]=x.geometry.uvs[t][0];f.uvs[1]=x.geometry.uvs[t][1];f.uvs[2]=
-x.geometry.uvs[t][3]}A.push(f);i++;g=h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(H.positionWorld);g.v2.positionWorld.copy(K.positionWorld);g.v3.positionWorld.copy(M.positionWorld);g.v1.positionScreen.copy(H.positionScreen);g.v2.positionScreen.copy(K.positionScreen);g.v3.positionScreen.copy(M.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=B.materials;
-g.overdraw=R;if(x.geometry.uvs[t]){g.uvs[0]=x.geometry.uvs[t][1];g.uvs[1]=x.geometry.uvs[t][2];g.uvs[2]=x.geometry.uvs[t][3]}A.push(g);i++}}}}else if(x instanceof THREE.Line){C.multiply(k,P);L=x.geometry.vertices;B=L[0];B.positionScreen.copy(B.position);C.multiplyVector4(B.positionScreen);t=1;for(I=L.length;t<I;t++){s=L[t];s.positionScreen.copy(s.position);C.multiplyVector4(s.positionScreen);H=L[t-1];F.copy(s.positionScreen);G.copy(H.positionScreen);if(b(F,G)){F.multiplyScalar(1/F.w);G.multiplyScalar(1/
-G.w);j=n[m]=n[m]||new THREE.RenderableLine;j.v1.positionScreen.copy(F);j.v2.positionScreen.copy(G);j.z=Math.max(F.z,G.z);j.materials=x.materials;A.push(j);m++}}}else if(x instanceof THREE.Particle){p.set(x.position.x,x.position.y,x.position.z,1);k.multiplyVector4(p);p.z/=p.w;if(p.z>0&&p.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=p.x/p.w;l.y=p.y/p.w;l.z=p.z;l.rotation=x.rotation.z;l.scale.x=x.scale.x*Math.abs(l.x-(p.x+u.projectionMatrix.n11)/(p.w+u.projectionMatrix.n14));l.scale.y=x.scale.y*
-Math.abs(l.y-(p.y+u.projectionMatrix.n22)/(p.w+u.projectionMatrix.n24));l.materials=x.materials;A.push(l);o++}}}}D&&A.sort(a);return A};this.unprojectVector=function(w,u){var D=THREE.Matrix4.makeInvert(u.globalMatrix);D.multiplySelf(THREE.Matrix4.makeInvert(u.projectionMatrix));D.multiplyVector3(w);return w}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,d,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;e=i;d=c/2;f=e/2};this.render=function(g,i){var h,j,m,n,l,o,q,r;a=b.projectScene(g,i);h=0;for(j=a.length;h<j;h++){l=a[h];if(l instanceof THREE.RenderableParticle){q=l.x*d+d;r=l.y*f+f;m=0;for(n=l.material.length;m<n;m++){o=l.material[m];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=q+"px";o.style.top=r+"px"}}}}}};
+THREE.Projector=function(){function a(v,t){return t.z-v.z}function b(v,t){var C=0,z=1,D=v.z+v.w,E=t.z+t.w,y=-v.z+v.w,u=-t.z+t.w;if(D>=0&&E>=0&&y>=0&&u>=0)return!0;else if(D<0&&E<0||y<0&&u<0)return!1;else{if(D<0)C=Math.max(C,D/(D-E));else E<0&&(z=Math.min(z,D/(D-E)));if(y<0)C=Math.max(C,y/(y-u));else u<0&&(z=Math.min(z,y/(y-u)));if(z<C)return!1;else{v.lerpSelf(t,C);t.lerpSelf(v,1-z);return!0}}}var c,e,d=[],f,g,i,h=[],j,m,n=[],l,o,p=[],q=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,B=new THREE.Matrix4,
+x=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],F=new THREE.Vector4,G=new THREE.Vector4,I;this.projectObjects=function(v,t,C){t=[];var z,D,E;e=0;D=v.objects;v=0;for(z=D.length;v<z;v++){E=D[v];var y;if(!(y=!E.visible))if(y=E instanceof THREE.Mesh){a:{y=void 0;for(var u=E.globalMatrix,L=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),s=0;s<6;s++){y=x[s].x*u.n14+x[s].y*u.n24+x[s].z*u.n34+x[s].w;if(y<=
+L){y=!1;break a}}y=!0}y=!y}if(!y){c=d[e]=d[e]||new THREE.RenderableObject;q.copy(E.position);k.multiplyVector3(q);c.object=E;c.z=q.z;t.push(c);e++}}C&&t.sort(a);return t};this.projectScene=function(v,t,C){var z=[],D=t.near,E=t.far,y,u,L,s,H,N,w,P,Q,R,S,O,K,A,J,M;i=m=o=0;t.matrixAutoUpdate&&t.update();k.multiply(t.projectionMatrix,t.globalMatrix);x[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);x[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);x[2].set(k.n41+k.n21,k.n42+k.n22,k.n43+
+k.n23,k.n44+k.n24);x[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);x[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);x[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(y=0;y<6;y++){N=x[y];N.divideScalar(Math.sqrt(N.x*N.x+N.y*N.y+N.z*N.z))}v.update(undefined,!1,t);N=this.projectObjects(v,t,!0);v=0;for(y=N.length;v<y;v++){w=N[v].object;if(w.visible){w.matrixAutoUpdate&&w.updateMatrix();P=w.globalMatrix;S=w.matrixRotation;Q=w.materials;R=w.overdraw;if(w instanceof THREE.Mesh){O=
+w.geometry;K=O.vertices;u=0;for(L=K.length;u<L;u++){A=K[u];A.positionWorld.copy(A.position);P.multiplyVector3(A.positionWorld);s=A.positionScreen;s.copy(A.positionWorld);k.multiplyVector4(s);s.x/=s.w;s.y/=s.w;A.__visible=s.z>D&&s.z<E}O=O.faces;u=0;for(L=O.length;u<L;u++){A=O[u];if(A instanceof THREE.Face3){s=K[A.a];H=K[A.b];J=K[A.c];if(s.__visible&&H.__visible&&J.__visible&&(w.doubleSided||w.flipSided!=(J.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(J.positionScreen.y-
+s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(J.positionWorld);f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(J.positionScreen);f.normalWorld.copy(A.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(A.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
+k.multiplyVector3(f.centroidScreen);J=A.vertexNormals;I=f.vertexNormalsWorld;s=0;for(H=J.length;s<H;s++){M=I[s]=I[s]||new THREE.Vector3;M.copy(J[s]);S.multiplyVector3(M)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=A.materials;f.overdraw=R;if(w.geometry.uvs[u]){f.uvs[0]=w.geometry.uvs[u][0];f.uvs[1]=w.geometry.uvs[u][1];f.uvs[2]=w.geometry.uvs[u][2]}z.push(f);i++}}else if(A instanceof THREE.Face4){s=K[A.a];H=K[A.b];J=K[A.c];M=K[A.d];if(s.__visible&&H.__visible&&J.__visible&&M.__visible&&
+(w.doubleSided||w.flipSided!=((M.positionScreen.x-s.positionScreen.x)*(H.positionScreen.y-s.positionScreen.y)-(M.positionScreen.y-s.positionScreen.y)*(H.positionScreen.x-s.positionScreen.x)<0||(H.positionScreen.x-J.positionScreen.x)*(M.positionScreen.y-J.positionScreen.y)-(H.positionScreen.y-J.positionScreen.y)*(M.positionScreen.x-J.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(s.positionWorld);f.v2.positionWorld.copy(H.positionWorld);f.v3.positionWorld.copy(M.positionWorld);
+f.v1.positionScreen.copy(s.positionScreen);f.v2.positionScreen.copy(H.positionScreen);f.v3.positionScreen.copy(M.positionScreen);f.normalWorld.copy(A.normal);S.multiplyVector3(f.normalWorld);f.centroidWorld.copy(A.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=A.materials;f.overdraw=R;if(w.geometry.uvs[u]){f.uvs[0]=w.geometry.uvs[u][0];f.uvs[1]=w.geometry.uvs[u][1];f.uvs[2]=
+w.geometry.uvs[u][3]}z.push(f);i++;g=h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(H.positionWorld);g.v2.positionWorld.copy(J.positionWorld);g.v3.positionWorld.copy(M.positionWorld);g.v1.positionScreen.copy(H.positionScreen);g.v2.positionScreen.copy(J.positionScreen);g.v3.positionScreen.copy(M.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=A.materials;
+g.overdraw=R;if(w.geometry.uvs[u]){g.uvs[0]=w.geometry.uvs[u][1];g.uvs[1]=w.geometry.uvs[u][2];g.uvs[2]=w.geometry.uvs[u][3]}z.push(g);i++}}}}else if(w instanceof THREE.Line){B.multiply(k,P);K=w.geometry.vertices;A=K[0];A.positionScreen.copy(A.position);B.multiplyVector4(A.positionScreen);u=1;for(L=K.length;u<L;u++){s=K[u];s.positionScreen.copy(s.position);B.multiplyVector4(s.positionScreen);H=K[u-1];F.copy(s.positionScreen);G.copy(H.positionScreen);if(b(F,G)){F.multiplyScalar(1/F.w);G.multiplyScalar(1/
+G.w);j=n[m]=n[m]||new THREE.RenderableLine;j.v1.positionScreen.copy(F);j.v2.positionScreen.copy(G);j.z=Math.max(F.z,G.z);j.materials=w.materials;z.push(j);m++}}}else if(w instanceof THREE.Particle){r.set(w.position.x,w.position.y,w.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){l=p[o]=p[o]||new THREE.RenderableParticle;l.x=r.x/r.w;l.y=r.y/r.w;l.z=r.z;l.rotation=w.rotation.z;l.scale.x=w.scale.x*Math.abs(l.x-(r.x+t.projectionMatrix.n11)/(r.w+t.projectionMatrix.n14));l.scale.y=w.scale.y*
+Math.abs(l.y-(r.y+t.projectionMatrix.n22)/(r.w+t.projectionMatrix.n24));l.materials=w.materials;z.push(l);o++}}}}C&&z.sort(a);return z};this.unprojectVector=function(v,t){var C=THREE.Matrix4.makeInvert(t.globalMatrix);C.multiplySelf(THREE.Matrix4.makeInvert(t.projectionMatrix));C.multiplyVector3(v);return v}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,d,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;e=i;d=c/2;f=e/2};this.render=function(g,i){var h,j,m,n,l,o,p,q;a=b.projectScene(g,i);h=0;for(j=a.length;h<j;h++){l=a[h];if(l instanceof THREE.RenderableParticle){p=l.x*d+d;q=l.y*f+f;m=0;for(n=l.material.length;m<n;m++){o=l.material[m];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=p+"px";o.style.top=q+"px"}}}}}};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};

+ 3 - 3
build/custom/ThreeExtras.js

@@ -7,9 +7,9 @@ fogs:{}};g=function(){I-=1;h()};for(q in A.cameras){w=A.cameras[q];if(w.type=="p
 z[1],z[2]);light.position.normalize()}else if(q.type=="point"){z=q.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}w=q.color;i=q.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);F.scene.addLight(light);F.lights[v]=light}for(n in A.fogs){v=A.fogs[n];if(v.type=="linear")E=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(E=new THREE.FogExp2(0,v.density));w=v.color;E.color.setRGB(w[0],w[1],w[2]);F.fogs[n]=E}if(F.cameras&&A.defaults.camera)F.currentCamera=F.cameras[A.defaults.camera];
 z[1],z[2]);light.position.normalize()}else if(q.type=="point"){z=q.position;light=new THREE.PointLight;light.position.set(z[0],z[1],z[2])}w=q.color;i=q.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);F.scene.addLight(light);F.lights[v]=light}for(n in A.fogs){v=A.fogs[n];if(v.type=="linear")E=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(E=new THREE.FogExp2(0,v.density));w=v.color;E.color.setRGB(w[0],w[1],w[2]);F.fogs[n]=E}if(F.cameras&&A.defaults.camera)F.currentCamera=F.cameras[A.defaults.camera];
 if(F.fogs&&A.defaults.fog)F.scene.fog=F.fogs[A.defaults.fog];w=A.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(w[0],w[1],w[2]);F.bgColorAlpha=A.defaults.bgalpha;for(j in A.geometries){n=A.geometries[j];if(n.type=="bin_mesh"||n.type=="ascii_mesh")H+=1}K=H;for(j in A.geometries){n=A.geometries[j];if(n.type=="cube"){k=new Cube(n.width,n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);F.geometries[j]=k}else if(n.type=="plane"){k=new Plane(n.width,n.height,n.segments_width,
 if(F.fogs&&A.defaults.fog)F.scene.fog=F.fogs[A.defaults.fog];w=A.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(w[0],w[1],w[2]);F.bgColorAlpha=A.defaults.bgalpha;for(j in A.geometries){n=A.geometries[j];if(n.type=="bin_mesh"||n.type=="ascii_mesh")H+=1}K=H;for(j in A.geometries){n=A.geometries[j];if(n.type=="cube"){k=new Cube(n.width,n.height,n.depth,n.segments_width,n.segments_height,null,n.flipped,n.sides);F.geometries[j]=k}else if(n.type=="plane"){k=new Plane(n.width,n.height,n.segments_width,
 n.segments_height);F.geometries[j]=k}else if(n.type=="sphere"){k=new Sphere(n.radius,n.segments_width,n.segments_height);F.geometries[j]=k}else if(n.type=="cylinder"){k=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[j]=k}else if(n.type=="torus"){k=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);F.geometries[j]=k}else if(n.type=="icosahedron"){k=new Icosahedron(n.subdivisions);F.geometries[j]=k}else if(n.type=="bin_mesh")C.loadBinary({model:n.url,callback:e(j)});
 n.segments_height);F.geometries[j]=k}else if(n.type=="sphere"){k=new Sphere(n.radius,n.segments_width,n.segments_height);F.geometries[j]=k}else if(n.type=="cylinder"){k=new Cylinder(n.numSegs,n.topRad,n.botRad,n.height,n.topOffset,n.botOffset);F.geometries[j]=k}else if(n.type=="torus"){k=new Torus(n.radius,n.tube,n.segmentsR,n.segmentsT);F.geometries[j]=k}else if(n.type=="icosahedron"){k=new Icosahedron(n.subdivisions);F.geometries[j]=k}else if(n.type=="bin_mesh")C.loadBinary({model:n.url,callback:e(j)});
-else n.type=="ascii_mesh"&&C.loadAscii({model:n.url,callback:e(j)})}for(p in A.textures){j=A.textures[p];I+=j.url instanceof Array?j.url.length:1}M=I;for(p in A.textures){j=A.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array){n=ImageUtils.loadArray(j.url,g);n=new THREE.Texture(n,j.mapping)}else{n=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)n.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=
-undefined)n.mag_filter=THREE[j.mag_filter]}F.textures[p]=n}for(l in A.materials){p=A.materials[l];for(x in p.parameters)if(x=="env_map"||x=="map"||x=="light_map")p.parameters[x]=F.textures[p.parameters[x]];else if(x=="shading")p.parameters[x]=p.parameters[x]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(x=="blending")p.parameters[x]=THREE[p.parameters[x]]?THREE[p.parameters[x]]:THREE.NormalBlending;else x=="combine"&&(p.parameters[x]=p.parameters[x]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);
-p=new THREE[p.type](p.parameters);F.materials[l]=p}c();d(F)}},addMesh:function(a,d,b,f,g,c,e,h,j,l){d=new THREE.Mesh(d,l);d.scale.x=d.scale.y=d.scale.z=b;d.position.x=f;d.position.y=g;d.position.z=c;d.rotation.x=e;d.rotation.y=h;d.rotation.z=j;a.addObject(d);return d},addPanoramaCubeWebGL:function(a,d,b){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragment_shader:f.fragment_shader,vertex_shader:f.vertex_shader,uniforms:f.uniforms});d=new THREE.Mesh(new Cube(d,
+else n.type=="ascii_mesh"&&C.loadAscii({model:n.url,callback:e(j)})}for(p in A.textures){j=A.textures[p];I+=j.url instanceof Array?j.url.length:1}M=I;for(p in A.textures){j=A.textures[p];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)n=ImageUtils.loadTextureCube(j.url,j.mapping,g);else{n=ImageUtils.loadTexture(j.url,j.mapping,g);if(THREE[j.min_filter]!=undefined)n.min_filter=THREE[j.min_filter];if(THREE[j.mag_filter]!=undefined)n.mag_filter=
+THREE[j.mag_filter]}F.textures[p]=n}for(l in A.materials){p=A.materials[l];for(x in p.parameters)if(x=="env_map"||x=="map"||x=="light_map")p.parameters[x]=F.textures[p.parameters[x]];else if(x=="shading")p.parameters[x]=p.parameters[x]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(x=="blending")p.parameters[x]=THREE[p.parameters[x]]?THREE[p.parameters[x]]:THREE.NormalBlending;else x=="combine"&&(p.parameters[x]=p.parameters[x]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);p=
+new THREE[p.type](p.parameters);F.materials[l]=p}c();d(F)}},addMesh:function(a,d,b,f,g,c,e,h,j,l){d=new THREE.Mesh(d,l);d.scale.x=d.scale.y=d.scale.z=b;d.position.x=f;d.position.y=g;d.position.z=c;d.rotation.x=e;d.rotation.y=h;d.rotation.z=j;a.addObject(d);return d},addPanoramaCubeWebGL:function(a,d,b){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragment_shader:f.fragment_shader,vertex_shader:f.vertex_shader,uniforms:f.uniforms});d=new THREE.Mesh(new Cube(d,
 d,d,1,1,null,!0),b);a.addObject(d);return d},addPanoramaCube:function(a,d,b){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));d=new THREE.Mesh(new Cube(d,
 d,d,1,1,null,!0),b);a.addObject(d);return d},addPanoramaCube:function(a,d,b){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));d=new THREE.Mesh(new Cube(d,
 d,d,1,1,f,!0),new THREE.MeshFaceMaterial);a.addObject(d);return d},addPanoramaCubePlanes:function(a,d,b){var f=d/2;d=new Plane(d,d);var g=Math.PI,c=Math.PI/2;SceneUtils.addMesh(a,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,d,1,-f,0,0,0,c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,d,1,f,0,0,0,-c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,d,1,0,f,0,c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
 d,d,1,1,f,!0),new THREE.MeshFaceMaterial);a.addObject(d);return d},addPanoramaCubePlanes:function(a,d,b){var f=d/2;d=new Plane(d,d);var g=Math.PI,c=Math.PI/2;SceneUtils.addMesh(a,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,d,1,-f,0,0,0,c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,d,1,f,0,0,0,-c,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,d,1,0,f,0,c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));
 SceneUtils.addMesh(a,d,1,0,-f,0,-c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 SceneUtils.addMesh(a,d,1,0,-f,0,-c,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",

+ 72 - 75
build/custom/ThreeSVG.js

@@ -1,50 +1,47 @@
 // ThreeSVG.js r32 - http://github.com/mrdoob/three.js
 // ThreeSVG.js r32 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,h,i,g;if(c==0)d=e=f=0;else{h=Math.floor(a*6);i=a*6-h;a=c*(1-b);g=c*(1-b*i);b=c*(1-b*(1-i));switch(h){case 1:d=g;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=g;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=g;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
+THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,g,i,h;if(c==0)d=e=f=0;else{g=Math.floor(a*6);i=a*6-g;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(g){case 1:d=h;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=h;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=h;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
-THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.x=c*a.z-d*a.y;this.y=d*a.x-b*a.z;this.z=b*a.y-c*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+c*c+a*a)},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
-this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
-this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
+b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
+a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||1};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,h){return f.distance-h.distance});return e},intersectObject:function(a){function b(s,j,I,p){p=p.clone().subSelf(j);I=I.clone().subSelf(j);var z=s.clone().subSelf(j);s=p.dot(p);j=p.dot(I);p=p.dot(z);var D=I.dot(I);I=I.dot(z);z=1/(s*D-j*j);D=(D*p-j*I)*z;s=(s*I-j*p)*z;return D>0&&s>0&&D+s<1}var c,d,e,f,h,i,g,k,n,m,
-l,o=a.geometry,q=o.vertices,u=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();l=this.direction.clone();g=a.globalMatrix;g.extractRotationMatrix(a.matrixRotation);f=g.multiplyVector3(q[e.a].position.clone());h=g.multiplyVector3(q[e.b].position.clone());i=g.multiplyVector3(q[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(q[e.d].position.clone()):null;k=a.matrixRotation.multiplyVector3(e.normal.clone());n=l.dot(k);if(n<0){k=k.dot((new THREE.Vector3).sub(f,
-m))/n;m=m.addSelf(l.multiplyScalar(k));if(e instanceof THREE.Face3){if(b(m,f,h,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};u.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,h,g)||b(m,h,i,g))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};u.push(e)}}}return u}};
-THREE.Rectangle=function(){function a(){f=d-b;h=e-c}var b,c,d,e,f,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,k,n,m){i=!1;b=g;c=k;d=n;e=m;a()};this.addPoint=function(g,k){if(i){i=!1;b=g;c=k;d=g;e=k}else{b=b<g?b:g;c=c<k?c:k;d=d>g?d:g;e=e>k?e:k}a()};
-this.add3Points=function(g,k,n,m,l,o){if(i){i=!1;b=g<n?g<l?g:l:n<l?n:l;c=k<m?k<o?k:o:m<o?m:o;d=g>n?g>l?g:l:n>l?n:l;e=k>m?k>o?k:o:m>o?m:o}else{b=g<n?g<l?g<b?g:b:l<b?l:b:n<l?n<b?n:b:l<b?l:b;c=k<m?k<o?k<c?k:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=g>n?g>l?g>d?g:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=k>m?k>o?k>e?k:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(g){if(i){i=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
-d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i};this.toString=function(){return"THREE.Rectangle ( left: "+
-b+", right: "+d+", top: "+c+", bottom: "+e+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,f,h,i,g,k,n,m,l,o,q,u){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=d||0;this.n21=e||0;this.n22=f||1;this.n23=h||0;this.n24=i||0;this.n31=g||0;this.n32=k||0;this.n33=n||1;this.n34=m||0;this.n41=l||0;this.n42=o||0;this.n43=q||0;this.n44=u||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,b,c,d,e,f,h,i,g,k,n,m,l,o,q,u){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=h;this.n24=i;this.n31=g;this.n32=k;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=u;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=e.x;this.n22=e.y;this.n23=e.z;this.n24=-e.dot(a);
-this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*
-a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*
-a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,i=a.n22,g=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,u=a.n42,s=a.n43,j=a.n44,I=b.n11,p=b.n12,z=b.n13,D=b.n14,M=b.n21,A=b.n22,w=b.n23,J=b.n24,E=b.n31,K=b.n32,H=b.n33,r=b.n34,x=b.n41,O=b.n42,v=b.n43,L=b.n44;this.n11=c*I+d*M+e*E+f*x;this.n12=c*p+d*A+e*K+f*O;this.n13=c*z+d*w+e*H+f*v;this.n14=c*D+d*J+e*r+f*L;this.n21=h*I+i*M+g*E+k*x;this.n22=h*p+i*A+g*K+k*O;this.n23=h*z+
-i*w+g*H+k*v;this.n24=h*D+i*J+g*r+k*L;this.n31=n*I+m*M+l*E+o*x;this.n32=n*p+m*A+l*K+o*O;this.n33=n*z+m*w+l*H+o*v;this.n34=n*D+m*J+l*r+o*L;this.n41=q*I+u*M+s*E+j*x;this.n42=q*p+u*A+s*K+j*O;this.n43=q*z+u*w+s*H+j*v;this.n44=q*D+u*J+s*r+j*L;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,i=a.n21,g=a.n22,k=a.n23,n=a.n24,m=a.n31,l=a.n32,o=a.n33,q=a.n34,u=a.n41,s=a.n42,j=a.n43;a=a.n44;var I=b.n11,p=b.n12,z=b.n13,D=b.n14,M=b.n21,A=b.n22,w=b.n23,J=b.n24,E=b.n31,K=b.n32,H=b.n33,
-r=b.n34,x=b.n41,O=b.n42,v=b.n43;b=b.n44;this.n11=d*I+e*M+f*E+h*x;this.n12=d*p+e*A+f*K+h*O;this.n13=d*z+e*w+f*H+h*v;this.n14=d*D+e*J+f*r+h*b;this.n21=i*I+g*M+k*E+n*x;this.n22=i*p+g*A+k*K+n*O;this.n23=i*z+g*w+k*H+n*v;this.n24=i*D+g*J+k*r+n*b;this.n31=m*I+l*M+o*E+q*x;this.n32=m*p+l*A+o*K+q*O;this.n33=m*z+l*w+o*H+q*v;this.n34=m*D+l*J+o*r+q*b;this.n41=u*I+s*M+j*E+a*x;this.n42=u*p+s*A+j*K+a*O;this.n43=u*z+s*w+j*H+a*v;this.n44=u*D+s*J+j*r+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=
-this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,i=this.n23,g=this.n24,k=this.n31,n=this.n32,m=this.n33,l=this.n34,o=this.n41,q=this.n42,u=this.n43,s=this.n44,j=a.n11,I=a.n21,p=a.n31,z=a.n41,D=a.n12,M=a.n22,A=a.n32,w=a.n42,J=a.n13,E=a.n23,K=a.n33,H=a.n43,r=a.n14,x=a.n24,O=
-a.n34;a=a.n44;this.n11=b*j+c*I+d*p+e*z;this.n12=b*D+c*M+d*A+e*w;this.n13=b*J+c*E+d*K+e*H;this.n14=b*r+c*x+d*O+e*a;this.n21=f*j+h*I+i*p+g*z;this.n22=f*D+h*M+i*A+g*w;this.n23=f*J+h*E+i*K+g*H;this.n24=f*r+h*x+i*O+g*a;this.n31=k*j+n*I+m*p+l*z;this.n32=k*D+n*M+m*A+l*w;this.n33=k*J+n*E+m*K+l*H;this.n34=k*r+n*x+m*O+l*a;this.n41=o*j+q*I+u*p+s*z;this.n42=o*D+q*M+u*A+s*w;this.n43=o*J+q*E+u*K+s*H;this.n44=o*r+q*x+u*O+s*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;
-this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,h=this.n23,i=this.n24,g=this.n31,k=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,u=this.n44;return d*h*k*l-c*i*k*l-d*f*n*l+b*i*n*l+c*f*m*l-b*h*m*l-d*h*g*o+c*i*g*o+d*e*n*o-a*i*n*o-c*e*m*o+a*h*m*o+d*f*g*q-b*i*g*q-d*e*k*q+a*i*k*q+b*e*m*
-q-a*f*m*q-c*f*g*u+b*h*g*u+c*e*k*u-a*h*k*u-b*e*n*u+a*f*n*u},transpose:function(){function a(b,c,d){var e=b[c];b[c]=b[d];b[d]=e}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;
-a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,
-0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,h=a.y,i=a.z,g=e*f,k=e*h;this.set(g*f+c,g*h-d*i,g*i+d*h,0,g*h+d*i,
-k*h+c,k*i-d*f,0,g*i-d*h,k*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var h=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-h*f+b*d;this.n32=h*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=
-a.w,f=b+b,h=c+c,i=d+d;a=b*f;var g=b*h;b*=i;var k=c*h;c*=i;d*=i;f*=e;h*=e;e*=i;this.n11=1-(k+d);this.n12=g-e;this.n13=b+h;this.n21=g+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-h;this.n32=c+f;this.n33=1-(a+k)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;
-a.n22=this.n22;a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},extractPositionVector:function(a){a.x=this.n14;a.y=this.n24;a.z=this.n34},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(t,j,H,p){p=p.clone().subSelf(j);H=H.clone().subSelf(j);var y=t.clone().subSelf(j);t=p.dot(p);j=p.dot(H);p=p.dot(y);var C=H.dot(H);H=H.dot(y);y=1/(t*C-j*j);C=(C*p-j*H)*y;t=(t*H-j*p)*y;return C>0&&t>0&&C+t<1}var c,d,e,f,g,i,h,k,n,m,
+l,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();l=this.direction.clone();h=a.globalMatrix;f=h.multiplyVector3(q[e.a].position.clone());g=h.multiplyVector3(q[e.b].position.clone());i=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;k=a.matrixRotation.multiplyVector3(e.normal.clone());n=l.dot(k);if(n<0){k=k.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(l.multiplyScalar(k));if(e instanceof
+THREE.Face3){if(b(m,f,g,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,i,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}}return s}};
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,k,n,m){i=!1;b=h;c=k;d=n;e=m;a()};this.addPoint=function(h,k){if(i){i=!1;b=h;c=k;d=h;e=k}else{b=b<h?b:h;c=c<k?c:k;d=d>h?d:h;e=e>k?e:k}a()};
+this.add3Points=function(h,k,n,m,l,o){if(i){i=!1;b=h<n?h<l?h:l:n<l?n:l;c=k<m?k<o?k:o:m<o?m:o;d=h>n?h>l?h:l:n>l?n:l;e=k>m?k>o?k:o:m>o?m:o}else{b=h<n?h<l?h<b?h:b:l<b?l:b:n<l?n<b?n:b:l<b?l:b;c=k<m?k<o?k<c?k:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=h>n?h>l?h>d?h:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=k>m?k>o?k>e?k:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i};this.toString=function(){return"THREE.Rectangle ( left: "+
+b+", right: "+d+", top: "+c+", bottom: "+e+", width: "+f+", height: "+g+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
+THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,k,n,m,l,o,q,s){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,k||0,n||1,m||0,l||0,o||0,q||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,k,n,m,l,o,q,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=k;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=d.y;this.n13=d.z;this.n14=-d.dot(a);this.n21=e.x;this.n22=e.y;this.n23=e.z;this.n24=-e.dot(a);this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=
+(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*
+e;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44,H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,
+v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34;this.n11=c*H+d*L+e*E;this.n12=c*p+d*z+e*K;this.n13=c*y+d*v+e*J;this.n14=c*C+d*I+e*u+f;this.n21=g*H+i*L+h*E;this.n22=g*p+i*z+h*K;this.n23=g*y+i*v+h*J;this.n24=g*C+i*I+h*u+k;this.n31=n*H+m*L+l*E;this.n32=n*p+m*z+l*K;this.n33=n*y+m*v+l*J;this.n34=n*C+m*I+l*u+o;this.n41=q*H+s*L+t*E;this.n42=q*p+s*z+t*K;this.n43=q*y+s*v+t*J;this.n44=q*C+s*I+t*u+j;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,k=a.n23,n=a.n24,
+m=a.n31,l=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,j=a.n43;a=a.n44;var H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34,D=b.n41,S=b.n42,x=b.n43;b=b.n44;this.n11=d*H+e*L+f*E+g*D;this.n12=d*p+e*z+f*K+g*S;this.n13=d*y+e*v+f*J+g*x;this.n14=d*C+e*I+f*u+g*b;this.n21=i*H+h*L+k*E+n*D;this.n22=i*p+h*z+k*K+n*S;this.n23=i*y+h*v+k*J+n*x;this.n24=i*C+h*I+k*u+n*b;this.n31=m*H+l*L+o*E+q*D;this.n32=m*p+l*z+o*K+q*S;this.n33=m*y+l*v+o*J+q*x;this.n34=m*C+l*I+o*u+q*b;this.n41=
+s*H+t*L+j*E+a*D;this.n42=s*p+t*z+j*K+a*S;this.n43=s*y+t*v+j*J+a*x;this.n44=s*C+t*I+j*u+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,k=this.n31,n=this.n32,m=this.n33,l=this.n34,o=this.n41,
+q=this.n42,s=this.n43,t=this.n44,j=a.n11,H=a.n21,p=a.n31,y=a.n12,C=a.n22,L=a.n32,z=a.n13,v=a.n23,I=a.n33,E=a.n14,K=a.n24;a=a.n34;this.n11=b*j+c*H+d*p;this.n12=b*y+c*C+d*L;this.n13=b*z+c*v+d*I;this.n14=b*E+c*K+d*a+e;this.n21=f*j+g*H+i*p;this.n22=f*y+g*C+i*L;this.n23=f*z+g*v+i*I;this.n24=f*E+g*K+i*a+h;this.n31=k*j+n*H+m*p;this.n32=k*y+n*C+m*L;this.n33=k*z+n*v+m*I;this.n34=k*E+n*K+m*a+l;this.n41=o*j+q*H+s*p;this.n42=o*y+q*C+s*L;this.n43=o*z+q*v+s*I;this.n44=o*E+q*K+s*a+t;return this},multiplyScalar:function(a){this.n11*=
+a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,k=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,s=this.n44;return d*g*k*l-c*i*k*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+
+d*f*h*q-b*i*h*q-d*e*k*q+a*i*k*q+b*e*m*q-a*f*m*q-c*f*h*s+b*g*h*s+c*e*k*s-a*g*k*s-b*e*n*s+a*f*n*s},transpose:function(){function a(b,c,d){var e=b[c];b[c]=b[d];b[d]=e}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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.flattenToArray(this.flat);return flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=
+this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=
+Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,k=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,k*g+c,k*i-d*f,0,h*i-d*g,k*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=
+a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var k=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(k+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=
+c+f;this.n33=1-(a+k)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};
 THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
 THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,i=a.n22,g=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,u=a.n42,s=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*o*u-k*l*u+k*m*s-i*o*s-g*m*j+i*l*j;b.n12=f*l*u-e*o*u-f*m*s+d*o*s+e*m*j-d*l*j;b.n13=e*k*u-f*g*u+f*i*s-d*k*s-e*i*j+d*g*j;b.n14=f*g*m-e*k*m-f*i*l+d*k*l+e*i*o-d*g*o;b.n21=k*l*q-g*o*q-k*n*s+h*o*s+g*n*j-h*l*j;b.n22=e*o*q-f*l*q+f*n*s-c*o*s-e*n*j+c*l*j;b.n23=f*g*q-e*k*q-f*h*s+c*k*s+e*h*j-c*g*j;
-b.n24=e*k*n-f*g*n+f*h*l-c*k*l-e*h*o+c*g*o;b.n31=i*o*q-k*m*q+k*n*u-h*o*u-i*n*j+h*m*j;b.n32=f*m*q-d*o*q-f*n*u+c*o*u+d*n*j-c*m*j;b.n33=e*k*q-f*i*q+f*h*u-c*k*u-d*h*j+c*i*j;b.n34=f*i*n-d*k*n-f*h*m+c*k*m+d*h*o-c*i*o;b.n41=g*m*q-i*l*q-g*n*u+h*l*u+i*n*s-h*m*s;b.n42=d*l*q-e*m*q+e*n*u-c*l*u-d*n*s+c*m*s;b.n43=e*i*q-d*g*q-e*h*u+c*g*u+d*h*s-c*i*s;b.n44=d*g*n-e*i*n+e*h*m-c*g*m-d*h*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*k;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*h;c[4]=a*i;c[5]=a*g;c[6]=a*k;c[7]=a*n;c[8]=a*m;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(f+e)/(f-e);h.n34=-2*f*e/(f-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var h,i,g,k;h=new THREE.Matrix4;i=b-a;g=c-d;k=f-e;h.n11=2/i;h.n12=0;h.n13=0;h.n14=-((b+a)/i);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/k;h.n34=-((f+e)/k);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*s-k*l*s+k*m*t-i*o*t-h*m*j+i*l*j;b.n12=f*l*s-e*o*s-f*m*t+d*o*t+e*m*j-d*l*j;b.n13=e*k*s-f*h*s+f*i*t-d*k*t-e*i*j+d*h*j;b.n14=f*h*m-e*k*m-f*i*l+d*k*l+e*i*o-d*h*o;b.n21=k*l*q-h*o*q-k*n*t+g*o*t+h*n*j-g*l*j;b.n22=e*o*q-f*l*q+f*n*t-c*o*t-e*n*j+c*l*j;b.n23=f*h*q-e*k*q-f*g*t+c*k*t+e*g*j-c*h*j;
+b.n24=e*k*n-f*h*n+f*g*l-c*k*l-e*g*o+c*h*o;b.n31=i*o*q-k*m*q+k*n*s-g*o*s-i*n*j+g*m*j;b.n32=f*m*q-d*o*q-f*n*s+c*o*s+d*n*j-c*m*j;b.n33=e*k*q-f*i*q+f*g*s-c*k*s-d*g*j+c*i*j;b.n34=f*i*n-d*k*n-f*g*m+c*k*m+d*g*o-c*i*o;b.n41=h*m*q-i*l*q-h*n*s+g*l*s+i*n*t-g*m*t;b.n42=d*l*q-e*m*q+e*n*s-c*l*s-d*n*t+c*m*t;b.n43=e*i*q-d*h*q-e*g*s+c*h*s+d*g*t-c*i*t;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*k;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*k;c[7]=a*n;c[8]=a*m;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,k;g=new THREE.Matrix4;i=b-a;h=c-d;k=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((f+e)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 1;this.visible=!0};
 1;this.visible=!0};
 THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.globalMatrix,b,c)}},updateMatrix:function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.matrixRotation.setRotationFromQuaternion(this.quaternion):this.matrixRotation.setRotationFromEuler(this.rotation);
 THREE.Object3D.prototype={update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0}var d=this.children.length;for(a=0;a<d;a++)this.children[a].update(this.globalMatrix,b,c)}},updateMatrix:function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.matrixRotation.setRotationFromQuaternion(this.quaternion):this.matrixRotation.setRotationFromEuler(this.rotation);
@@ -55,24 +52,24 @@ THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THR
 THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
 THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,h,i=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)i.addSelf(f.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];i.sub(h.position,
-c.position);g.sub(b.position,c.position);i.crossSelf(g)}i.isZero()||i.normalize();f.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,i=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)i.addSelf(f.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];i.sub(g.position,
+c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||i.normalize();f.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(r,x,O,v,L,F,B){f=r.vertices[x].position;h=r.vertices[O].position;i=r.vertices[v].position;g=e[L];k=e[F];n=e[B];m=h.x-f.x;l=i.x-f.x;o=h.y-f.y;q=i.y-f.y;
-u=h.z-f.z;s=i.z-f.z;j=k.u-g.u;I=n.u-g.u;p=k.v-g.v;z=n.v-g.v;D=1/(j*z-I*p);w.set((z*m-p*l)*D,(z*o-p*q)*D,(z*u-p*s)*D);J.set((j*l-I*m)*D,(j*q-I*o)*D,(j*s-I*u)*D);M[x].addSelf(w);M[O].addSelf(w);M[v].addSelf(w);A[x].addSelf(J);A[O].addSelf(J);A[v].addSelf(J)}var b,c,d,e,f,h,i,g,k,n,m,l,o,q,u,s,j,I,p,z,D,M=[],A=[],w=new THREE.Vector3,J=new THREE.Vector3,E=new THREE.Vector3,K=new THREE.Vector3,H=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){M[b]=new THREE.Vector3;A[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(u,D,S,x,N,F,A){f=u.vertices[D].position;g=u.vertices[S].position;i=u.vertices[x].position;h=e[N];k=e[F];n=e[A];m=g.x-f.x;l=i.x-f.x;o=g.y-f.y;q=i.y-f.y;
+s=g.z-f.z;t=i.z-f.z;j=k.u-h.u;H=n.u-h.u;p=k.v-h.v;y=n.v-h.v;C=1/(j*y-H*p);v.set((y*m-p*l)*C,(y*o-p*q)*C,(y*s-p*t)*C);I.set((j*l-H*m)*C,(j*q-H*o)*C,(j*t-H*s)*C);L[D].addSelf(v);L[S].addSelf(v);L[x].addSelf(v);z[D].addSelf(I);z[S].addSelf(I);z[x].addSelf(I)}var b,c,d,e,f,g,i,h,k,n,m,l,o,q,s,t,j,H,p,y,C,L=[],z=[],v=new THREE.Vector3,I=new THREE.Vector3,E=new THREE.Vector3,K=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){L[b]=new THREE.Vector3;z[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){H.copy(this.vertices[b].normal);d=M[b];E.copy(d);E.subSelf(H.multiplyScalar(H.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(A[b]);d=d<0?-1:1;this.vertices[b].tangent.set(E.x,E.y,E.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){J.copy(this.vertices[b].normal);d=L[b];E.copy(d);E.subSelf(J.multiplyScalar(J.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(z[b]);d=d<0?-1:1;this.vertices[b].tangent.set(E.x,E.y,E.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var m=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?m.push("undefined"):m.push(n[b].id);return m.join("_")}var b,c,d,e,f,h,i,g,k={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
-h=f.materials;i=a(h);k[i]==undefined&&(k[i]={hash:i,counter:0});g=k[i].hash+"_"+k[i].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+f>65535){k[i].counter+=1;g=k[i].hash+"_"+k[i].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var m=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?m.push("undefined"):m.push(n[b].id);return m.join("_")}var b,c,d,e,f,g,i,h,k={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
+g=f.materials;i=a(g);k[i]==undefined&&(k[i]={hash:i,counter:0});h=k[i].hash+"_"+k[i].counter;this.geometryChunks[h]==undefined&&(this.geometryChunks[h]={faces:[],materials:g,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+f>65535){k[i].counter+=1;h=k[i].hash+"_"+k[i].counter;this.geometryChunks[h]==undefined&&(this.geometryChunks[h]={faces:[],materials:g,vertices:0})}this.geometryChunks[h].faces.push(d);this.geometryChunks[h].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
-THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=
-0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(h)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};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,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.screenCenterY=this.screenCenterX=0;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=
+0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,b,c)};
-THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,e=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,h=e.n31*b+e.n32*c+e.n33*d+e.n34;if(h-f>-this.near)return!1;if(h+f<-this.far)return!1;h-=f;var i=this.projectionMatrix,g=1/(i.n43*h),k=g*this.screenCenterX,n=(e.n11*b+e.n12*c+e.n13*d+e.n14)*i.n11*k;f=i.n11*f*k;if(n+f<-this.screenCenterX)return!1;if(n-f>this.screenCenterX)return!1;b=(e.n21*b+e.n22*c+e.n23*d+e.n24)*i.n22*g*this.screenCenterY;
-if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(n,b,h,f);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
+THREE.Camera.prototype.frustumContains=function(a){var b=a.globalMatrix.n14,c=a.globalMatrix.n24,d=a.globalMatrix.n34,e=this.inverseMatrix,f=a.boundRadius*a.boundRadiusScale,g=e.n31*b+e.n32*c+e.n33*d+e.n34;if(g-f>-this.near)return!1;if(g+f<-this.far)return!1;g-=f;var i=this.projectionMatrix,h=1/(i.n43*g),k=h*this.screenCenterX,n=(e.n11*b+e.n12*c+e.n13*d+e.n14)*i.n11*k;f=i.n11*f*k;if(n+f<-this.screenCenterX)return!1;if(n-f>this.screenCenterX)return!1;b=(e.n21*b+e.n22*c+e.n23*d+e.n24)*i.n22*h*this.screenCenterY;
+if(b+f<-this.screenCenterY)return!1;if(b-f>this.screenCenterY)return!1;a.screenPosition.set(n,b,g,f);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
 THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth=
@@ -108,32 +105,32 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound3D){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(A,w){return w.z-A.z}function b(A,w){var J=0,E=1,K=A.z+A.w,H=w.z+w.w,r=-A.z+A.w,x=-w.z+w.w;if(K>=0&&H>=0&&r>=0&&x>=0)return!0;else if(K<0&&H<0||r<0&&x<0)return!1;else{if(K<0)J=Math.max(J,K/(K-H));else H<0&&(E=Math.min(E,K/(K-H)));if(r<0)J=Math.max(J,r/(r-x));else x<0&&(E=Math.min(E,r/(r-x)));if(E<J)return!1;else{A.lerpSelf(w,J);w.lerpSelf(A,1-E);return!0}}}var c,d,e=[],f,h,i,g=[],k,n,m=[],l,o,q=[],u=new THREE.Vector4,s=new THREE.Vector4,j=new THREE.Matrix4,I=new THREE.Matrix4,
-p=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],z=new THREE.Vector4,D=new THREE.Vector4,M;this.projectObjects=function(A,w,J){w=[];var E,K,H;d=0;K=A.objects;A=0;for(E=K.length;A<E;A++){H=K[A];var r;if(!(r=!H.visible))if(r=H instanceof THREE.Mesh){a:{r=void 0;for(var x=H.globalMatrix,O=-H.geometry.boundingSphere.radius*Math.max(H.scale.x,Math.max(H.scale.y,H.scale.z)),v=0;v<6;v++){r=p[v].x*x.n14+p[v].y*x.n24+p[v].z*x.n34+p[v].w;if(r<=
-O){r=!1;break a}}r=!0}r=!r}if(!r){c=e[d]=e[d]||new THREE.RenderableObject;u.copy(H.position);j.multiplyVector3(u);c.object=H;c.z=u.z;w.push(c);d++}}J&&w.sort(a);return w};this.projectScene=function(A,w,J){var E=[],K=w.near,H=w.far,r,x,O,v,L,F,B,P,R,C,y,N,Q,t,G,S;i=n=o=0;w.matrixAutoUpdate&&w.update();j.multiply(w.projectionMatrix,w.globalMatrix);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
-j.n23,j.n44+j.n24);p[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);p[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);p[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(r=0;r<6;r++){F=p[r];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}A.update(undefined,!1,w);F=this.projectObjects(A,w,!0);A=0;for(r=F.length;A<r;A++){B=F[A].object;if(B.visible){B.matrixAutoUpdate&&B.updateMatrix();P=B.globalMatrix;y=B.matrixRotation;R=B.materials;C=B.overdraw;if(B instanceof THREE.Mesh){N=
-B.geometry;Q=N.vertices;x=0;for(O=Q.length;x<O;x++){t=Q[x];t.positionWorld.copy(t.position);P.multiplyVector3(t.positionWorld);v=t.positionScreen;v.copy(t.positionWorld);j.multiplyVector4(v);v.x/=v.w;v.y/=v.w;t.__visible=v.z>K&&v.z<H}N=N.faces;x=0;for(O=N.length;x<O;x++){t=N[x];if(t instanceof THREE.Face3){v=Q[t.a];L=Q[t.b];G=Q[t.c];if(v.__visible&&L.__visible&&G.__visible&&(B.doubleSided||B.flipSided!=(G.positionScreen.x-v.positionScreen.x)*(L.positionScreen.y-v.positionScreen.y)-(G.positionScreen.y-
-v.positionScreen.y)*(L.positionScreen.x-v.positionScreen.x)<0)){f=g[i]=g[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(v.positionWorld);f.v2.positionWorld.copy(L.positionWorld);f.v3.positionWorld.copy(G.positionWorld);f.v1.positionScreen.copy(v.positionScreen);f.v2.positionScreen.copy(L.positionScreen);f.v3.positionScreen.copy(G.positionScreen);f.normalWorld.copy(t.normal);y.multiplyVector3(f.normalWorld);f.centroidWorld.copy(t.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
-j.multiplyVector3(f.centroidScreen);G=t.vertexNormals;M=f.vertexNormalsWorld;v=0;for(L=G.length;v<L;v++){S=M[v]=M[v]||new THREE.Vector3;S.copy(G[v]);y.multiplyVector3(S)}f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=t.materials;f.overdraw=C;if(B.geometry.uvs[x]){f.uvs[0]=B.geometry.uvs[x][0];f.uvs[1]=B.geometry.uvs[x][1];f.uvs[2]=B.geometry.uvs[x][2]}E.push(f);i++}}else if(t instanceof THREE.Face4){v=Q[t.a];L=Q[t.b];G=Q[t.c];S=Q[t.d];if(v.__visible&&L.__visible&&G.__visible&&S.__visible&&
-(B.doubleSided||B.flipSided!=((S.positionScreen.x-v.positionScreen.x)*(L.positionScreen.y-v.positionScreen.y)-(S.positionScreen.y-v.positionScreen.y)*(L.positionScreen.x-v.positionScreen.x)<0||(L.positionScreen.x-G.positionScreen.x)*(S.positionScreen.y-G.positionScreen.y)-(L.positionScreen.y-G.positionScreen.y)*(S.positionScreen.x-G.positionScreen.x)<0))){f=g[i]=g[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(v.positionWorld);f.v2.positionWorld.copy(L.positionWorld);f.v3.positionWorld.copy(S.positionWorld);
-f.v1.positionScreen.copy(v.positionScreen);f.v2.positionScreen.copy(L.positionScreen);f.v3.positionScreen.copy(S.positionScreen);f.normalWorld.copy(t.normal);y.multiplyVector3(f.normalWorld);f.centroidWorld.copy(t.centroid);P.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=R;f.faceMaterials=t.materials;f.overdraw=C;if(B.geometry.uvs[x]){f.uvs[0]=B.geometry.uvs[x][0];f.uvs[1]=B.geometry.uvs[x][1];f.uvs[2]=
-B.geometry.uvs[x][3]}E.push(f);i++;h=g[i]=g[i]||new THREE.RenderableFace3;h.v1.positionWorld.copy(L.positionWorld);h.v2.positionWorld.copy(G.positionWorld);h.v3.positionWorld.copy(S.positionWorld);h.v1.positionScreen.copy(L.positionScreen);h.v2.positionScreen.copy(G.positionScreen);h.v3.positionScreen.copy(S.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=R;h.faceMaterials=t.materials;
-h.overdraw=C;if(B.geometry.uvs[x]){h.uvs[0]=B.geometry.uvs[x][1];h.uvs[1]=B.geometry.uvs[x][2];h.uvs[2]=B.geometry.uvs[x][3]}E.push(h);i++}}}}else if(B instanceof THREE.Line){I.multiply(j,P);Q=B.geometry.vertices;t=Q[0];t.positionScreen.copy(t.position);I.multiplyVector4(t.positionScreen);x=1;for(O=Q.length;x<O;x++){v=Q[x];v.positionScreen.copy(v.position);I.multiplyVector4(v.positionScreen);L=Q[x-1];z.copy(v.positionScreen);D.copy(L.positionScreen);if(b(z,D)){z.multiplyScalar(1/z.w);D.multiplyScalar(1/
-D.w);k=m[n]=m[n]||new THREE.RenderableLine;k.v1.positionScreen.copy(z);k.v2.positionScreen.copy(D);k.z=Math.max(z.z,D.z);k.materials=B.materials;E.push(k);n++}}}else if(B instanceof THREE.Particle){s.set(B.position.x,B.position.y,B.position.z,1);j.multiplyVector4(s);s.z/=s.w;if(s.z>0&&s.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=s.x/s.w;l.y=s.y/s.w;l.z=s.z;l.rotation=B.rotation.z;l.scale.x=B.scale.x*Math.abs(l.x-(s.x+w.projectionMatrix.n11)/(s.w+w.projectionMatrix.n14));l.scale.y=B.scale.y*
-Math.abs(l.y-(s.y+w.projectionMatrix.n22)/(s.w+w.projectionMatrix.n24));l.materials=B.materials;E.push(l);o++}}}}J&&E.sort(a);return E};this.unprojectVector=function(A,w){var J=THREE.Matrix4.makeInvert(w.globalMatrix);J.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));J.multiplyVector3(A);return A}};
-THREE.SVGRenderer=function(){function a(F,B,P){var R,C,y,N;R=0;for(C=F.lights.length;R<C;R++){y=F.lights[R];if(y instanceof THREE.DirectionalLight){N=B.normalWorld.dot(y.position)*y.intensity;if(N>0){P.r+=y.color.r*N;P.g+=y.color.g*N;P.b+=y.color.b*N}}else if(y instanceof THREE.PointLight){J.sub(y.position,B.centroidWorld);J.normalize();N=B.normalWorld.dot(J)*y.intensity;if(N>0){P.r+=y.color.r*N;P.g+=y.color.g*N;P.b+=y.color.b*N}}}}function b(F,B,P,R,C,y){r=d(x++);r.setAttribute("d","M "+F.positionScreen.x+
-" "+F.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(I){z.r=D.r;z.g=D.g;z.b=D.b;a(y,R,z);p.r=C.color.r*z.r;p.g=C.color.g*z.g;p.b=C.color.b*z.b;p.updateStyleString()}else p.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){w=1-C.__2near/(C.__farPlusNear-R.z*C.__farMinusNear);
-p.setRGB(w,w,w)}else C instanceof THREE.MeshNormalMaterial&&p.setRGB(e(R.normalWorld.x),e(R.normalWorld.y),e(R.normalWorld.z));C.wireframe?r.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):r.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+C.opacity);i.appendChild(r)}function c(F,B,P,R,C,y,N){r=d(x++);r.setAttribute("d",
-"M "+F.positionScreen.x+" "+F.positionScreen.y+" L "+B.positionScreen.x+" "+B.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)p.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(I){z.r=D.r;z.g=D.g;z.b=D.b;a(N,C,z);p.r=y.color.r*z.r;p.g=y.color.g*z.g;p.b=y.color.b*z.b;p.updateStyleString()}else p.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){w=
-1-y.__2near/(y.__farPlusNear-C.z*y.__farMinusNear);p.setRGB(w,w,w)}else y instanceof THREE.MeshNormalMaterial&&p.setRGB(e(C.normalWorld.x),e(C.normalWorld.y),e(C.normalWorld.z));y.wireframe?r.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):r.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+y.opacity);i.appendChild(r)}
-function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");L==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),g,k,n,m,l,o,q,u,s=new THREE.Rectangle,j=new THREE.Rectangle,I=!1,p=new THREE.Color(16777215),z=new THREE.Color(16777215),D=new THREE.Color(0),M=new THREE.Color(0),A=new THREE.Color(0),
-w,J=new THREE.Vector3,E=[],K=[],H=[],r,x,O,v,L=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":L=1;break;case "low":L=0}};this.setSize=function(F,B){g=F;k=B;n=g/2;m=k/2;i.setAttribute("viewBox",-n+" "+-m+" "+g+" "+k);i.setAttribute("width",g);i.setAttribute("height",k);s.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,B){var P,R,C,y,N,Q,t,G;this.autoClear&&
-this.clear();f=h.projectScene(F,B,this.sortElements);v=O=x=0;if(I=F.lights.length>0){t=F.lights;D.setRGB(0,0,0);M.setRGB(0,0,0);A.setRGB(0,0,0);P=0;for(R=t.length;P<R;P++){C=t[P];y=C.color;if(C instanceof THREE.AmbientLight){D.r+=y.r;D.g+=y.g;D.b+=y.b}else if(C instanceof THREE.DirectionalLight){M.r+=y.r;M.g+=y.g;M.b+=y.b}else if(C instanceof THREE.PointLight){A.r+=y.r;A.g+=y.g;A.b+=y.b}}}P=0;for(R=f.length;P<R;P++){t=f[P];j.empty();if(t instanceof THREE.RenderableParticle){l=t;l.x*=n;l.y*=-m;C=0;
-for(y=t.materials.length;C<y;C++)if(G=t.materials[C]){N=l;Q=t;var S=O++;if(K[S]==null){K[S]=document.createElementNS("http://www.w3.org/2000/svg","circle");L==0&&K[S].setAttribute("shape-rendering","crispEdges")}r=K[S];r.setAttribute("cx",N.x);r.setAttribute("cy",N.y);r.setAttribute("r",Q.scale.x*n);if(G instanceof THREE.ParticleCircleMaterial){if(I){z.r=D.r+M.r+A.r;z.g=D.g+M.g+A.g;z.b=D.b+M.b+A.b;p.r=G.color.r*z.r;p.g=G.color.g*z.g;p.b=G.color.b*z.b;p.updateStyleString()}else p=G.color;r.setAttribute("style",
-"fill: "+p.__styleString)}i.appendChild(r)}}else if(t instanceof THREE.RenderableLine){l=t.v1;o=t.v2;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(s.instersects(j)){C=0;for(y=t.materials.length;C<y;)if(G=t.materials[C++]){N=l;Q=o;S=v++;if(H[S]==null){H[S]=document.createElementNS("http://www.w3.org/2000/svg","line");L==0&&H[S].setAttribute("shape-rendering",
-"crispEdges")}r=H[S];r.setAttribute("x1",N.positionScreen.x);r.setAttribute("y1",N.positionScreen.y);r.setAttribute("x2",Q.positionScreen.x);r.setAttribute("y2",Q.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){p.__styleString=G.color.__styleString;r.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);i.appendChild(r)}}}}else if(t instanceof THREE.RenderableFace3){l=
-t.v1;o=t.v2;q=t.v3;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);if(s.instersects(j)){C=0;for(y=t.meshMaterials.length;C<y;){G=t.meshMaterials[C++];if(G instanceof THREE.MeshFaceMaterial){N=0;for(Q=t.faceMaterials.length;N<Q;)(G=t.faceMaterials[N++])&&b(l,o,q,t,
-G,F)}else G&&b(l,o,q,t,G,F)}}}else if(t instanceof THREE.RenderableFace4){l=t.v1;o=t.v2;q=t.v3;u=t.v4;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;u.positionScreen.x*=n;u.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);j.addPoint(u.positionScreen.x,u.positionScreen.y);if(s.instersects(j)){C=
-0;for(y=t.meshMaterials.length;C<y;){G=t.meshMaterials[C++];if(G instanceof THREE.MeshFaceMaterial){N=0;for(Q=t.faceMaterials.length;N<Q;)(G=t.faceMaterials[N++])&&c(l,o,q,u,t,G,F)}else G&&c(l,o,q,u,t,G,F)}}}}}};THREE.RenderableObject=function(){this.z=this.object=null};
+THREE.Projector=function(){function a(z,v){return v.z-z.z}function b(z,v){var I=0,E=1,K=z.z+z.w,J=v.z+v.w,u=-z.z+z.w,D=-v.z+v.w;if(K>=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(E<I)return!1;else{z.lerpSelf(v,I);v.lerpSelf(z,1-E);return!0}}}var c,d,e=[],f,g,i,h=[],k,n,m=[],l,o,q=[],s=new THREE.Vector4,t=new THREE.Vector4,j=new THREE.Matrix4,H=new THREE.Matrix4,
+p=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],y=new THREE.Vector4,C=new THREE.Vector4,L;this.projectObjects=function(z,v,I){v=[];var E,K,J;d=0;K=z.objects;z=0;for(E=K.length;z<E;z++){J=K[z];var u;if(!(u=!J.visible))if(u=J instanceof THREE.Mesh){a:{u=void 0;for(var D=J.globalMatrix,S=-J.geometry.boundingSphere.radius*Math.max(J.scale.x,Math.max(J.scale.y,J.scale.z)),x=0;x<6;x++){u=p[x].x*D.n14+p[x].y*D.n24+p[x].z*D.n34+p[x].w;if(u<=
+S){u=!1;break a}}u=!0}u=!u}if(!u){c=e[d]=e[d]||new THREE.RenderableObject;s.copy(J.position);j.multiplyVector3(s);c.object=J;c.z=s.z;v.push(c);d++}}I&&v.sort(a);return v};this.projectScene=function(z,v,I){var E=[],K=v.near,J=v.far,u,D,S,x,N,F,A,O,Q,B,w,M,P,r,G,R;i=n=o=0;v.matrixAutoUpdate&&v.update();j.multiply(v.projectionMatrix,v.globalMatrix);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
+j.n23,j.n44+j.n24);p[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);p[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);p[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(u=0;u<6;u++){F=p[u];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}z.update(undefined,!1,v);F=this.projectObjects(z,v,!0);z=0;for(u=F.length;z<u;z++){A=F[z].object;if(A.visible){A.matrixAutoUpdate&&A.updateMatrix();O=A.globalMatrix;w=A.matrixRotation;Q=A.materials;B=A.overdraw;if(A instanceof THREE.Mesh){M=
+A.geometry;P=M.vertices;D=0;for(S=P.length;D<S;D++){r=P[D];r.positionWorld.copy(r.position);O.multiplyVector3(r.positionWorld);x=r.positionScreen;x.copy(r.positionWorld);j.multiplyVector4(x);x.x/=x.w;x.y/=x.w;r.__visible=x.z>K&&x.z<J}M=M.faces;D=0;for(S=M.length;D<S;D++){r=M[D];if(r instanceof THREE.Face3){x=P[r.a];N=P[r.b];G=P[r.c];if(x.__visible&&N.__visible&&G.__visible&&(A.doubleSided||A.flipSided!=(G.positionScreen.x-x.positionScreen.x)*(N.positionScreen.y-x.positionScreen.y)-(G.positionScreen.y-
+x.positionScreen.y)*(N.positionScreen.x-x.positionScreen.x)<0)){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(N.positionWorld);f.v3.positionWorld.copy(G.positionWorld);f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(G.positionScreen);f.normalWorld.copy(r.normal);w.multiplyVector3(f.normalWorld);f.centroidWorld.copy(r.centroid);O.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
+j.multiplyVector3(f.centroidScreen);G=r.vertexNormals;L=f.vertexNormalsWorld;x=0;for(N=G.length;x<N;x++){R=L[x]=L[x]||new THREE.Vector3;R.copy(G[x]);w.multiplyVector3(R)}f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=r.materials;f.overdraw=B;if(A.geometry.uvs[D]){f.uvs[0]=A.geometry.uvs[D][0];f.uvs[1]=A.geometry.uvs[D][1];f.uvs[2]=A.geometry.uvs[D][2]}E.push(f);i++}}else if(r instanceof THREE.Face4){x=P[r.a];N=P[r.b];G=P[r.c];R=P[r.d];if(x.__visible&&N.__visible&&G.__visible&&R.__visible&&
+(A.doubleSided||A.flipSided!=((R.positionScreen.x-x.positionScreen.x)*(N.positionScreen.y-x.positionScreen.y)-(R.positionScreen.y-x.positionScreen.y)*(N.positionScreen.x-x.positionScreen.x)<0||(N.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-(N.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(N.positionWorld);f.v3.positionWorld.copy(R.positionWorld);
+f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(r.normal);w.multiplyVector3(f.normalWorld);f.centroidWorld.copy(r.centroid);O.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=r.materials;f.overdraw=B;if(A.geometry.uvs[D]){f.uvs[0]=A.geometry.uvs[D][0];f.uvs[1]=A.geometry.uvs[D][1];f.uvs[2]=
+A.geometry.uvs[D][3]}E.push(f);i++;g=h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(G.positionWorld);g.v3.positionWorld.copy(R.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(G.positionScreen);g.v3.positionScreen.copy(R.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=r.materials;
+g.overdraw=B;if(A.geometry.uvs[D]){g.uvs[0]=A.geometry.uvs[D][1];g.uvs[1]=A.geometry.uvs[D][2];g.uvs[2]=A.geometry.uvs[D][3]}E.push(g);i++}}}}else if(A instanceof THREE.Line){H.multiply(j,O);P=A.geometry.vertices;r=P[0];r.positionScreen.copy(r.position);H.multiplyVector4(r.positionScreen);D=1;for(S=P.length;D<S;D++){x=P[D];x.positionScreen.copy(x.position);H.multiplyVector4(x.positionScreen);N=P[D-1];y.copy(x.positionScreen);C.copy(N.positionScreen);if(b(y,C)){y.multiplyScalar(1/y.w);C.multiplyScalar(1/
+C.w);k=m[n]=m[n]||new THREE.RenderableLine;k.v1.positionScreen.copy(y);k.v2.positionScreen.copy(C);k.z=Math.max(y.z,C.z);k.materials=A.materials;E.push(k);n++}}}else if(A instanceof THREE.Particle){t.set(A.position.x,A.position.y,A.position.z,1);j.multiplyVector4(t);t.z/=t.w;if(t.z>0&&t.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=t.x/t.w;l.y=t.y/t.w;l.z=t.z;l.rotation=A.rotation.z;l.scale.x=A.scale.x*Math.abs(l.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));l.scale.y=A.scale.y*
+Math.abs(l.y-(t.y+v.projectionMatrix.n22)/(t.w+v.projectionMatrix.n24));l.materials=A.materials;E.push(l);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=THREE.Matrix4.makeInvert(v.globalMatrix);I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}};
+THREE.SVGRenderer=function(){function a(F,A,O){var Q,B,w,M;Q=0;for(B=F.lights.length;Q<B;Q++){w=F.lights[Q];if(w instanceof THREE.DirectionalLight){M=A.normalWorld.dot(w.position)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}else if(w instanceof THREE.PointLight){I.sub(w.position,A.centroidWorld);I.normalize();M=A.normalWorld.dot(I)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}}}function b(F,A,O,Q,B,w){u=d(D++);u.setAttribute("d","M "+F.positionScreen.x+
+" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(w,Q,y);p.r=B.color.r*y.r;p.g=B.color.g*y.g;p.b=B.color.b*y.b;p.updateStyleString()}else p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){v=1-B.__2near/(B.__farPlusNear-Q.z*B.__farMinusNear);
+p.setRGB(v,v,v)}else B instanceof THREE.MeshNormalMaterial&&p.setRGB(e(Q.normalWorld.x),e(Q.normalWorld.y),e(Q.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+B.opacity);i.appendChild(u)}function c(F,A,O,Q,B,w,M){u=d(D++);u.setAttribute("d",
+"M "+F.positionScreen.x+" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(M,B,y);p.r=w.color.r*y.r;p.g=w.color.g*y.g;p.b=w.color.b*y.b;p.updateStyleString()}else p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){v=
+1-w.__2near/(w.__farPlusNear-B.z*w.__farMinusNear);p.setRGB(v,v,v)}else w instanceof THREE.MeshNormalMaterial&&p.setRGB(e(B.normalWorld.x),e(B.normalWorld.y),e(B.normalWorld.z));w.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+w.wireframe_linewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframe_linecap+"; stroke-linejoin: "+w.wireframe_linejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+w.opacity);i.appendChild(u)}
+function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,k,n,m,l,o,q,s,t=new THREE.Rectangle,j=new THREE.Rectangle,H=!1,p=new THREE.Color(16777215),y=new THREE.Color(16777215),C=new THREE.Color(0),L=new THREE.Color(0),z=new THREE.Color(0),
+v,I=new THREE.Vector3,E=[],K=[],J=[],u,D,S,x,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":N=1;break;case "low":N=0}};this.setSize=function(F,A){h=F;k=A;n=h/2;m=k/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+k);i.setAttribute("width",h);i.setAttribute("height",k);t.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,A){var O,Q,B,w,M,P,r,G;this.autoClear&&
+this.clear();f=g.projectScene(F,A,this.sortElements);x=S=D=0;if(H=F.lights.length>0){r=F.lights;C.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);O=0;for(Q=r.length;O<Q;O++){B=r[O];w=B.color;if(B instanceof THREE.AmbientLight){C.r+=w.r;C.g+=w.g;C.b+=w.b}else if(B instanceof THREE.DirectionalLight){L.r+=w.r;L.g+=w.g;L.b+=w.b}else if(B instanceof THREE.PointLight){z.r+=w.r;z.g+=w.g;z.b+=w.b}}}O=0;for(Q=f.length;O<Q;O++){r=f[O];j.empty();if(r instanceof THREE.RenderableParticle){l=r;l.x*=n;l.y*=-m;B=0;
+for(w=r.materials.length;B<w;B++)if(G=r.materials[B]){M=l;P=r;var R=S++;if(K[R]==null){K[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");N==0&&K[R].setAttribute("shape-rendering","crispEdges")}u=K[R];u.setAttribute("cx",M.x);u.setAttribute("cy",M.y);u.setAttribute("r",P.scale.x*n);if(G instanceof THREE.ParticleCircleMaterial){if(H){y.r=C.r+L.r+z.r;y.g=C.g+L.g+z.g;y.b=C.b+L.b+z.b;p.r=G.color.r*y.r;p.g=G.color.g*y.g;p.b=G.color.b*y.b;p.updateStyleString()}else p=G.color;u.setAttribute("style",
+"fill: "+p.__styleString)}i.appendChild(u)}}else if(r instanceof THREE.RenderableLine){l=r.v1;o=r.v2;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.materials.length;B<w;)if(G=r.materials[B++]){M=l;P=o;R=x++;if(J[R]==null){J[R]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&J[R].setAttribute("shape-rendering",
+"crispEdges")}u=J[R];u.setAttribute("x1",M.positionScreen.x);u.setAttribute("y1",M.positionScreen.y);u.setAttribute("x2",P.positionScreen.x);u.setAttribute("y2",P.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){p.__styleString=G.color.__styleString;u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);i.appendChild(u)}}}}else if(r instanceof THREE.RenderableFace3){l=
+r.v1;o=r.v2;q=r.v3;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&b(l,o,q,r,
+G,F)}else G&&b(l,o,q,r,G,F)}}}else if(r instanceof THREE.RenderableFace4){l=r.v1;o=r.v2;q=r.v3;s=r.v4;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;s.positionScreen.x*=n;s.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);j.addPoint(s.positionScreen.x,s.positionScreen.y);if(t.instersects(j)){B=
+0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&c(l,o,q,s,r,G,F)}else G&&c(l,o,q,s,r,G,F)}}}}}};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};
 THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null};

+ 85 - 88
build/custom/ThreeWebGL.js

@@ -4,47 +4,44 @@ THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,d){this.r=a;this.g=c;th
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA: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)},toString:function(){return"THREE.Color ( r: "+
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
 this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0};
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
 THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x*
-this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.x=a||0;this.y=c||0;this.z=d||0};
-THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},
-cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/=
-a.z;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+
-this.y+this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+
-this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
+this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,c,d){this.set(a||0,c||0,d||0)};
+THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a,
+c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.set(d*a.z-f*a.y,f*a.x-c*a.z,c*a.y-d*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/
+a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a=
+this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}};THREE.Vector4=function(a,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1};
 THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){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)},toString:function(){return"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=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(a){function c(K,J,R,L){L=L.clone().subSelf(J);R=R.clone().subSelf(J);var P=K.clone().subSelf(J);K=L.dot(L);J=L.dot(R);L=L.dot(P);var b=R.dot(R);R=R.dot(P);P=1/(K*b-J*J);b=(b*L-J*R)*P;K=(K*R-J*L)*P;return b>0&&K>0&&b+K<1}var d,f,g,j,k,o,i,s,w,x,
-z,A=a.geometry,E=A.vertices,H=[];d=0;for(f=A.faces.length;d<f;d++){g=A.faces[d];x=this.origin.clone();z=this.direction.clone();i=a.globalMatrix;i.extractRotationMatrix(a.matrixRotation);j=i.multiplyVector3(E[g.a].position.clone());k=i.multiplyVector3(E[g.b].position.clone());o=i.multiplyVector3(E[g.c].position.clone());i=g instanceof THREE.Face4?i.multiplyVector3(E[g.d].position.clone()):null;s=a.matrixRotation.multiplyVector3(g.normal.clone());w=z.dot(s);if(w<0){s=s.dot((new THREE.Vector3).sub(j,
-x))/w;x=x.addSelf(z.multiplyScalar(s));if(g instanceof THREE.Face3){if(c(x,j,k,o)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(c(x,j,k,i)||c(x,k,o,i))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}}return H}};
-THREE.Rectangle=function(){function a(){j=f-c;k=g-d}var c,d,f,g,j,k,o=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(i,s,w,x){o=!1;c=i;d=s;f=w;g=x;a()};this.addPoint=function(i,s){if(o){o=!1;c=i;d=s;f=i;g=s}else{c=c<i?c:i;d=d<s?d:s;f=f>i?f:i;g=g>s?g:s}a()};
-this.add3Points=function(i,s,w,x,z,A){if(o){o=!1;c=i<w?i<z?i:z:w<z?w:z;d=s<x?s<A?s:A:x<A?x:A;f=i>w?i>z?i:z:w>z?w:z;g=s>x?s>A?s:A:x>A?x:A}else{c=i<w?i<z?i<c?i:c:z<c?z:c:w<z?w<c?w:c:z<c?z:c;d=s<x?s<A?s<d?s:d:A<d?A:d:x<A?x<d?x:d:A<d?A:d;f=i>w?i>z?i>f?i:f:z>f?z:f:w>z?w>f?w:f:z>f?z:f;g=s>x?s>A?s>g?s:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(i){if(o){o=!1;c=i.getLeft();d=i.getTop();f=i.getRight();g=i.getBottom()}else{c=c<i.getLeft()?c:i.getLeft();d=d<i.getTop()?d:i.getTop();f=f>i.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,g=[];a=0;for(c=f.length;a<c;a++){d=f[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(a){function c(K,J,R,L){L=L.clone().subSelf(J);R=R.clone().subSelf(J);var P=K.clone().subSelf(J);K=L.dot(L);J=L.dot(R);L=L.dot(P);var b=R.dot(R);R=R.dot(P);P=1/(K*b-J*J);b=(b*L-J*R)*P;K=(K*R-J*L)*P;return b>0&&K>0&&b+K<1}var d,f,g,j,k,o,i,t,w,x,
+z,A=a.geometry,E=A.vertices,H=[];d=0;for(f=A.faces.length;d<f;d++){g=A.faces[d];x=this.origin.clone();z=this.direction.clone();i=a.globalMatrix;j=i.multiplyVector3(E[g.a].position.clone());k=i.multiplyVector3(E[g.b].position.clone());o=i.multiplyVector3(E[g.c].position.clone());i=g instanceof THREE.Face4?i.multiplyVector3(E[g.d].position.clone()):null;t=a.matrixRotation.multiplyVector3(g.normal.clone());w=z.dot(t);if(w<0){t=t.dot((new THREE.Vector3).sub(j,x))/w;x=x.addSelf(z.multiplyScalar(t));if(g instanceof
+THREE.Face3){if(c(x,j,k,o)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(c(x,j,k,i)||c(x,k,o,i))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:a};H.push(g)}}}return H}};
+THREE.Rectangle=function(){function a(){j=f-c;k=g-d}var c,d,f,g,j,k,o=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(i,t,w,x){o=!1;c=i;d=t;f=w;g=x;a()};this.addPoint=function(i,t){if(o){o=!1;c=i;d=t;f=i;g=t}else{c=c<i?c:i;d=d<t?d:t;f=f>i?f:i;g=g>t?g:t}a()};
+this.add3Points=function(i,t,w,x,z,A){if(o){o=!1;c=i<w?i<z?i:z:w<z?w:z;d=t<x?t<A?t:A:x<A?x:A;f=i>w?i>z?i:z:w>z?w:z;g=t>x?t>A?t:A:x>A?x:A}else{c=i<w?i<z?i<c?i:c:z<c?z:c:w<z?w<c?w:c:z<c?z:c;d=t<x?t<A?t<d?t:d:A<d?A:d:x<A?x<d?x:d:A<d?A:d;f=i>w?i>z?i>f?i:f:z>f?z:f:w>z?w>f?w:f:z>f?z:f;g=t>x?t>A?t>g?t:g:A>g?A:g:x>A?x>g?x:g:A>g?A:g}a()};this.addRectangle=function(i){if(o){o=!1;c=i.getLeft();d=i.getTop();f=i.getRight();g=i.getBottom()}else{c=c<i.getLeft()?c:i.getLeft();d=d<i.getTop()?d:i.getTop();f=f>i.getRight()?
 f:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){c-=i;d-=i;f+=i;g+=i;a()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();f=f<i.getRight()?f:i.getRight();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(f,i.getRight())-Math.max(c,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){o=!0;g=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=function(){return"THREE.Rectangle ( left: "+
 f:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){c-=i;d-=i;f+=i;g+=i;a()};this.minSelf=function(i){c=c>i.getLeft()?c:i.getLeft();d=d>i.getTop()?d:i.getTop();f=f<i.getRight()?f:i.getRight();g=g<i.getBottom()?g:i.getBottom();a()};this.instersects=function(i){return Math.min(f,i.getRight())-Math.max(c,i.getLeft())>=0&&Math.min(g,i.getBottom())-Math.max(d,i.getTop())>=0};this.empty=function(){o=!0;g=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString=function(){return"THREE.Rectangle ( left: "+
 c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+j+", height: "+k+" )"}};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}};
 c+", right: "+f+", top: "+d+", bottom: "+g+", width: "+j+", height: "+k+" )"}};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,d,f,g,j,k,o,i,s,w,x,z,A,E,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=g||0;this.n22=j||1;this.n23=k||0;this.n24=o||0;this.n31=i||0;this.n32=s||0;this.n33=w||1;this.n34=x||0;this.n41=z||0;this.n42=A||0;this.n43=E||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,f,g,j,k,o,i,s,w,x,z,A,E,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=j;this.n23=k;this.n24=o;this.n31=i;this.n32=s;this.n33=w;this.n34=x;this.n41=z;this.n42=A;this.n43=E;this.n44=H;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
-a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,j=THREE.Matrix4.__tmpVec3;j.sub(a,c).normalize();f.cross(d,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);
-this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var c=a.x,d=a.y;a=a.z;return(this.n31*c+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*d+this.n43*
-a+this.n44))},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*g;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 d=a.n11,f=a.n12,g=a.n13,j=a.n14,k=a.n21,o=a.n22,i=a.n23,s=a.n24,w=a.n31,x=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44,R=c.n11,L=c.n12,P=c.n13,b=c.n14,ba=c.n21,ca=c.n22,da=c.n23,ha=c.n24,ea=c.n31,ma=c.n32,ka=c.n33,U=c.n34,aa=c.n41,la=c.n42,qa=c.n43,za=c.n44;this.n11=d*R+f*ba+g*ea+j*aa;this.n12=d*L+f*ca+g*ma+j*la;this.n13=d*P+f*da+g*ka+j*qa;this.n14=d*b+f*ha+g*U+j*za;this.n21=k*R+o*ba+i*ea+s*aa;this.n22=k*L+
-o*ca+i*ma+s*la;this.n23=k*P+o*da+i*ka+s*qa;this.n24=k*b+o*ha+i*U+s*za;this.n31=w*R+x*ba+z*ea+A*aa;this.n32=w*L+x*ca+z*ma+A*la;this.n33=w*P+x*da+z*ka+A*qa;this.n34=w*b+x*ha+z*U+A*za;this.n41=E*R+H*ba+K*ea+J*aa;this.n42=E*L+H*ca+K*ma+J*la;this.n43=E*P+H*da+K*ka+J*qa;this.n44=E*b+H*ha+K*U+J*za;return this},multiplyToArray:function(a,c,d){var f=a.n11,g=a.n12,j=a.n13,k=a.n14,o=a.n21,i=a.n22,s=a.n23,w=a.n24,x=a.n31,z=a.n32,A=a.n33,E=a.n34,H=a.n41,K=a.n42,J=a.n43;a=a.n44;var R=c.n11,L=c.n12,P=c.n13,b=c.n14,
-ba=c.n21,ca=c.n22,da=c.n23,ha=c.n24,ea=c.n31,ma=c.n32,ka=c.n33,U=c.n34,aa=c.n41,la=c.n42,qa=c.n43;c=c.n44;this.n11=f*R+g*ba+j*ea+k*aa;this.n12=f*L+g*ca+j*ma+k*la;this.n13=f*P+g*da+j*ka+k*qa;this.n14=f*b+g*ha+j*U+k*c;this.n21=o*R+i*ba+s*ea+w*aa;this.n22=o*L+i*ca+s*ma+w*la;this.n23=o*P+i*da+s*ka+w*qa;this.n24=o*b+i*ha+s*U+w*c;this.n31=x*R+z*ba+A*ea+E*aa;this.n32=x*L+z*ca+A*ma+E*la;this.n33=x*P+z*da+A*ka+E*qa;this.n34=x*b+z*ha+A*U+E*c;this.n41=H*R+K*ba+J*ea+a*aa;this.n42=H*L+K*ca+J*ma+a*la;this.n43=
-H*P+K*da+J*ka+a*qa;this.n44=H*b+K*ha+J*U+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,j=this.n21,k=this.n22,o=this.n23,i=this.n24,s=this.n31,w=this.n32,x=this.n33,z=this.n34,A=this.n41,E=this.n42,H=this.n43,K=this.n44,J=a.n11,
-R=a.n21,L=a.n31,P=a.n41,b=a.n12,ba=a.n22,ca=a.n32,da=a.n42,ha=a.n13,ea=a.n23,ma=a.n33,ka=a.n43,U=a.n14,aa=a.n24,la=a.n34;a=a.n44;this.n11=c*J+d*R+f*L+g*P;this.n12=c*b+d*ba+f*ca+g*da;this.n13=c*ha+d*ea+f*ma+g*ka;this.n14=c*U+d*aa+f*la+g*a;this.n21=j*J+k*R+o*L+i*P;this.n22=j*b+k*ba+o*ca+i*da;this.n23=j*ha+k*ea+o*ma+i*ka;this.n24=j*U+k*aa+o*la+i*a;this.n31=s*J+w*R+x*L+z*P;this.n32=s*b+w*ba+x*ca+z*da;this.n33=s*ha+w*ea+x*ma+z*ka;this.n34=s*U+w*aa+x*la+z*a;this.n41=A*J+E*R+H*L+K*P;this.n42=A*b+E*ba+H*
-ca+K*da;this.n43=A*ha+E*ea+H*ma+K*ka;this.n44=A*U+E*aa+H*la+K*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,d=this.n13,f=this.n14,g=this.n21,j=this.n22,k=this.n23,o=this.n24,i=this.n31,s=this.n32,w=this.n33,x=this.n34,z=this.n41,A=this.n42,E=this.n43,
-H=this.n44;return f*k*s*z-d*o*s*z-f*j*w*z+c*o*w*z+d*j*x*z-c*k*x*z-f*k*i*A+d*o*i*A+f*g*w*A-a*o*w*A-d*g*x*A+a*k*x*A+f*j*i*E-c*o*i*E-f*g*s*E+a*o*s*E+c*g*x*E-a*j*x*E-d*j*i*H+c*k*i*H+d*g*s*H-a*k*s*H-c*g*w*H+a*j*w*H},transpose:function(){function a(c,d,f){var g=c[d];c[d]=c[f];c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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(){var a=this.flat;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},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,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),g=1-d,j=a.x,k=a.y,o=a.z,i=g*j,s=g*k;this.set(i*j+d,i*k-f*o,i*o+f*k,0,i*k+f*o,s*k+d,s*o-f*j,0,i*o-f*k,s*o+f*j,g*o*o+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,d=a.y,f=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var j=Math.cos(f);f=Math.sin(f);var k=a*d,o=c*d;this.n11=g*j;this.n12=-g*f;this.n13=d;this.n21=
-o*j+a*f;this.n22=-o*f+a*j;this.n23=-c*g;this.n31=-k*j+c*f;this.n32=k*f+c*j;this.n33=a*g},setRotationFromQuaternion:function(a){var c=a.x,d=a.y,f=a.z,g=a.w,j=c+c,k=d+d,o=f+f;a=c*j;var i=c*k;c*=o;var s=d*k;d*=o;f*=o;j*=g;k*=g;g*=o;this.n11=1-(s+f);this.n12=i-g;this.n13=c+k;this.n21=i+g;this.n22=1-(a+f);this.n23=d-j;this.n31=c-k;this.n32=d+j;this.n33=1-(a+s)},scale:function(a){var c=a.x,d=a.y;a=a.z;this.n11*=c;this.n12*=d;this.n13*=a;this.n21*=c;this.n22*=d;this.n23*=a;this.n31*=c;this.n32*=d;this.n33*=
-a;this.n41*=c;this.n42*=d;this.n43*=a;return this},extractRotationMatrix:function(a){a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=0;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=0;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=0;a.n41=0;a.n42=0;a.n43=0;a.n44=1},extractPositionVector:function(a){a.x=this.n14;a.y=this.n24;a.z=this.n34},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+
-" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};
+THREE.Matrix4=function(a,c,d,f,g,j,k,o,i,t,w,x,z,A,E,H){this.set(a||1,c||0,d||0,f||0,g||0,j||1,k||0,o||0,i||0,t||0,w||1,x||0,z||0,A||0,E||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,c,d,f,g,j,k,o,i,t,w,x,z,A,E,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=g;this.n22=j;this.n23=k;this.n24=o;this.n31=i;this.n32=t;this.n33=w;this.n34=x;this.n41=z;this.n42=A;this.n43=E;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,
+g=THREE.Matrix4.__tmpVec2,j=THREE.Matrix4.__tmpVec3;j.sub(a,c).normalize();f.cross(d,j).normalize();g.cross(j,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,g=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*g;a.y=
+(this.n21*c+this.n22*d+this.n23*f+this.n24)*g;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var c=a.x,d=a.y;a=a.z;return(this.n31*c+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,g=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*g;a.y=this.n21*c+this.n22*d+this.n23*f+this.n24*g;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*g;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*
+g;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 d=a.n11,f=a.n12,g=a.n13,j=a.n14,k=a.n21,o=a.n22,i=a.n23,t=a.n24,w=a.n31,x=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44,R=c.n11,L=c.n12,P=c.n13,b=c.n14,aa=c.n21,ba=c.n22,
+ca=c.n23,ga=c.n24,da=c.n31,ja=c.n32,na=c.n33,$=c.n34;this.n11=d*R+f*aa+g*da;this.n12=d*L+f*ba+g*ja;this.n13=d*P+f*ca+g*na;this.n14=d*b+f*ga+g*$+j;this.n21=k*R+o*aa+i*da;this.n22=k*L+o*ba+i*ja;this.n23=k*P+o*ca+i*na;this.n24=k*b+o*ga+i*$+t;this.n31=w*R+x*aa+z*da;this.n32=w*L+x*ba+z*ja;this.n33=w*P+x*ca+z*na;this.n34=w*b+x*ga+z*$+A;this.n41=E*R+H*aa+K*da;this.n42=E*L+H*ba+K*ja;this.n43=E*P+H*ca+K*na;this.n44=E*b+H*ga+K*$+J;return this},multiplyToArray:function(a,c,d){var f=a.n11,g=a.n12,j=a.n13,k=a.n14,
+o=a.n21,i=a.n22,t=a.n23,w=a.n24,x=a.n31,z=a.n32,A=a.n33,E=a.n34,H=a.n41,K=a.n42,J=a.n43;a=a.n44;var R=c.n11,L=c.n12,P=c.n13,b=c.n14,aa=c.n21,ba=c.n22,ca=c.n23,ga=c.n24,da=c.n31,ja=c.n32,na=c.n33,$=c.n34,qa=c.n41,va=c.n42,wa=c.n43;c=c.n44;this.n11=f*R+g*aa+j*da+k*qa;this.n12=f*L+g*ba+j*ja+k*va;this.n13=f*P+g*ca+j*na+k*wa;this.n14=f*b+g*ga+j*$+k*c;this.n21=o*R+i*aa+t*da+w*qa;this.n22=o*L+i*ba+t*ja+w*va;this.n23=o*P+i*ca+t*na+w*wa;this.n24=o*b+i*ga+t*$+w*c;this.n31=x*R+z*aa+A*da+E*qa;this.n32=x*L+z*
+ba+A*ja+E*va;this.n33=x*P+z*ca+A*na+E*wa;this.n34=x*b+z*ga+A*$+E*c;this.n41=H*R+K*aa+J*da+a*qa;this.n42=H*L+K*ba+J*ja+a*va;this.n43=H*P+K*ca+J*na+a*wa;this.n44=H*b+K*ga+J*$+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,g=this.n14,j=this.n21,
+k=this.n22,o=this.n23,i=this.n24,t=this.n31,w=this.n32,x=this.n33,z=this.n34,A=this.n41,E=this.n42,H=this.n43,K=this.n44,J=a.n11,R=a.n21,L=a.n31,P=a.n12,b=a.n22,aa=a.n32,ba=a.n13,ca=a.n23,ga=a.n33,da=a.n14,ja=a.n24;a=a.n34;this.n11=c*J+d*R+f*L;this.n12=c*P+d*b+f*aa;this.n13=c*ba+d*ca+f*ga;this.n14=c*da+d*ja+f*a+g;this.n21=j*J+k*R+o*L;this.n22=j*P+k*b+o*aa;this.n23=j*ba+k*ca+o*ga;this.n24=j*da+k*ja+o*a+i;this.n31=t*J+w*R+x*L;this.n32=t*P+w*b+x*aa;this.n33=t*ba+w*ca+x*ga;this.n34=t*da+w*ja+x*a+z;this.n41=
+A*J+E*R+H*L;this.n42=A*P+E*b+H*aa;this.n43=A*ba+E*ca+H*ga;this.n44=A*da+E*ja+H*a+K;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,d=this.n13,f=this.n14,g=this.n21,j=this.n22,k=this.n23,o=this.n24,i=this.n31,t=this.n32,w=this.n33,x=this.n34,z=this.n41,A=this.n42,
+E=this.n43,H=this.n44;return f*k*t*z-d*o*t*z-f*j*w*z+c*o*w*z+d*j*x*z-c*k*x*z-f*k*i*A+d*o*i*A+f*g*w*A-a*o*w*A-d*g*x*A+a*k*x*A+f*j*i*E-c*o*i*E-f*g*t*E+a*o*t*E+c*g*x*E-a*j*x*E-d*j*i*H+c*k*i*H+d*g*t*H-a*k*t*H-c*g*w*H+a*j*w*H},transpose:function(){function a(c,d,f){var g=c[d];c[d]=c[f];c[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");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.flattenToArray(this.flat);return 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,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},
+setRotX: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},setRotY: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},setRotZ: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},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),g=1-d,j=a.x,k=a.y,o=a.z,i=g*j,t=g*k;this.set(i*j+d,i*k-f*o,i*o+f*k,0,i*k+f*o,t*k+d,t*o-f*j,0,i*o-f*k,t*o+f*j,g*o*o+d,0,0,
+0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,d=a.y,f=a.z;a=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var j=Math.cos(f);f=Math.sin(f);var k=a*d,o=c*d;this.n11=g*j;this.n12=-g*f;this.n13=d;this.n21=o*j+a*f;this.n22=-o*f+a*j;this.n23=-c*g;this.n31=-k*j+c*f;this.n32=k*f+c*j;this.n33=a*g},setRotationFromQuaternion:function(a){var c=a.x,d=a.y,f=a.z,g=a.w,j=c+c,k=d+d,o=f+f;a=c*j;var i=c*k;c*=o;var t=
+d*k;d*=o;f*=o;j*=g;k*=g;g*=o;this.n11=1-(t+f);this.n12=i-g;this.n13=c+k;this.n21=i+g;this.n22=1-(a+f);this.n23=d-j;this.n31=c-k;this.n32=d+j;this.n33=1-(a+t)},scale:function(a){var c=a.x,d=a.y;a=a.z;this.n11*=c;this.n12*=d;this.n13*=a;this.n21*=c;this.n22*=d;this.n23*=a;this.n31*=c;this.n32*=d;this.n33*=a;this.n41*=c;this.n42*=d;this.n43*=a;return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+
+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f};THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};
 THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
 THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a,c){var d=a.n11,f=a.n12,g=a.n13,j=a.n14,k=a.n21,o=a.n22,i=a.n23,s=a.n24,w=a.n31,x=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=i*A*H-s*z*H+s*x*K-o*A*K-i*x*J+o*z*J;c.n12=j*z*H-g*A*H-j*x*K+f*A*K+g*x*J-f*z*J;c.n13=g*s*H-j*i*H+j*o*K-f*s*K-g*o*J+f*i*J;c.n14=j*i*x-g*s*x-j*o*z+f*s*z+g*o*A-f*i*A;c.n21=s*z*E-i*A*E-s*w*K+k*A*K+i*w*J-k*z*J;c.n22=g*A*E-j*z*E+j*w*K-d*A*K-g*w*J+d*z*J;c.n23=j*i*E-g*s*E-j*k*K+d*s*K+g*k*J-d*i*J;
-c.n24=g*s*w-j*i*w+j*k*z-d*s*z-g*k*A+d*i*A;c.n31=o*A*E-s*x*E+s*w*H-k*A*H-o*w*J+k*x*J;c.n32=j*x*E-f*A*E-j*w*H+d*A*H+f*w*J-d*x*J;c.n33=g*s*E-j*o*E+j*k*H-d*s*H-f*k*J+d*o*J;c.n34=j*o*w-f*s*w-j*k*x+d*s*x+f*k*A-d*o*A;c.n41=i*x*E-o*z*E-i*w*H+k*z*H+o*w*K-k*x*K;c.n42=f*z*E-g*x*E+g*w*H-d*z*H-f*w*K+d*x*K;c.n43=g*o*E-f*i*E-g*k*H+d*i*H+f*k*K-d*o*K;c.n44=f*i*w-g*o*w+g*k*x-d*i*x-f*k*z+d*o*z;c.multiplyScalar(1/a.determinant());return c};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,j=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,s=a.n23*a.n12-a.n22*a.n13,w=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*k+a.n31*s;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*g;d[2]=a*j;d[3]=a*k;d[4]=a*o;d[5]=a*i;d[6]=a*s;d[7]=a*w;d[8]=a*x;return c};
+THREE.Matrix4.makeInvert=function(a,c){var d=a.n11,f=a.n12,g=a.n13,j=a.n14,k=a.n21,o=a.n22,i=a.n23,t=a.n24,w=a.n31,x=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=i*A*H-t*z*H+t*x*K-o*A*K-i*x*J+o*z*J;c.n12=j*z*H-g*A*H-j*x*K+f*A*K+g*x*J-f*z*J;c.n13=g*t*H-j*i*H+j*o*K-f*t*K-g*o*J+f*i*J;c.n14=j*i*x-g*t*x-j*o*z+f*t*z+g*o*A-f*i*A;c.n21=t*z*E-i*A*E-t*w*K+k*A*K+i*w*J-k*z*J;c.n22=g*A*E-j*z*E+j*w*K-d*A*K-g*w*J+d*z*J;c.n23=j*i*E-g*t*E-j*k*K+d*t*K+g*k*J-d*i*J;
+c.n24=g*t*w-j*i*w+j*k*z-d*t*z-g*k*A+d*i*A;c.n31=o*A*E-t*x*E+t*w*H-k*A*H-o*w*J+k*x*J;c.n32=j*x*E-f*A*E-j*w*H+d*A*H+f*w*J-d*x*J;c.n33=g*t*E-j*o*E+j*k*H-d*t*H-f*k*J+d*o*J;c.n34=j*o*w-f*t*w-j*k*x+d*t*x+f*k*A-d*o*A;c.n41=i*x*E-o*z*E-i*w*H+k*z*H+o*w*K-k*x*K;c.n42=f*z*E-g*x*E+g*w*H-d*z*H-f*w*K+d*x*K;c.n43=g*o*E-f*i*E-g*k*H+d*i*H+f*k*K-d*o*K;c.n44=f*i*w-g*o*w+g*k*x-d*i*x-f*k*z+d*o*z;c.multiplyScalar(1/a.determinant());return c};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,j=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,w=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*k+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*g;d[2]=a*j;d[3]=a*k;d[4]=a*o;d[5]=a*i;d[6]=a*t;d[7]=a*w;d[8]=a*x;return c};
 THREE.Matrix4.makeFrustum=function(a,c,d,f,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(c-a);k.n12=0;k.n13=(c+a)/(c-a);k.n14=0;k.n21=0;k.n22=2*g/(f-d);k.n23=(f+d)/(f-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)};
 THREE.Matrix4.makeFrustum=function(a,c,d,f,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(c-a);k.n12=0;k.n13=(c+a)/(c-a);k.n14=0;k.n21=0;k.n22=2*g/(f-d);k.n23=(f+d)/(f-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,c,d,f){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*c,a*c,g,a,d,f)};
-THREE.Matrix4.makeOrtho=function(a,c,d,f,g,j){var k,o,i,s;k=new THREE.Matrix4;o=c-a;i=d-f;s=j-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((c+a)/o);k.n21=0;k.n22=2/i;k.n23=0;k.n24=-((d+f)/i);k.n31=0;k.n32=0;k.n33=-2/s;k.n34=-((j+g)/s);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(a,c,d,f,g,j){var k,o,i,t;k=new THREE.Matrix4;o=c-a;i=d-f;t=j-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((c+a)/o);k.n21=0;k.n22=2/i;k.n23=0;k.n24=-((d+f)/i);k.n31=0;k.n32=0;k.n33=-2/t;k.n34=-((j+g)/t);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrixRotation=new THREE.Matrix4;this.localMatrix=new THREE.Matrix4;this.globalMatrix=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.screenPosition=new THREE.Vector4;this.boundRadius=0;this.boundRadiusScale=
 1;this.visible=!0};
 1;this.visible=!0};
 THREE.Object3D.prototype={update:function(a,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;c=!0}var f=this.children.length;for(a=0;a<f;a++)this.children[a].update(this.globalMatrix,c,d)}},updateMatrix:function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.matrixRotation.setRotationFromQuaternion(this.quaternion):this.matrixRotation.setRotationFromEuler(this.rotation);
 THREE.Object3D.prototype={update:function(a,c,d){if(this.visible){this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;c=!0}var f=this.children.length;for(a=0;a<f;a++)this.children[a].update(this.globalMatrix,c,d)}},updateMatrix:function(){this.localMatrix.setPosition(this.position);this.useQuaternion?this.matrixRotation.setRotationFromQuaternion(this.quaternion):this.matrixRotation.setRotationFromEuler(this.rotation);
@@ -58,20 +55,20 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,j,k,o=new THREE.Vector3,i=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){j=this.vertices[f];j.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];if(a&&j.vertexNormals.length){o.set(0,0,0);c=0;for(d=j.normal.length;c<d;c++)o.addSelf(j.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];o.sub(k.position,
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,f,g,j,k,o=new THREE.Vector3,i=new THREE.Vector3;f=0;for(g=this.vertices.length;f<g;f++){j=this.vertices[f];j.normal.set(0,0,0)}f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];if(a&&j.vertexNormals.length){o.set(0,0,0);c=0;for(d=j.normal.length;c<d;c++)o.addSelf(j.vertexNormals[c]);o.divideScalar(3)}else{c=this.vertices[j.a];d=this.vertices[j.b];k=this.vertices[j.c];o.sub(k.position,
 d.position);i.sub(c.position,d.position);o.crossSelf(i)}o.isZero()||o.normalize();j.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 d.position);i.sub(c.position,d.position);o.crossSelf(i)}o.isZero()||o.normalize();j.normal.copy(o)}},computeVertexNormals:function(){var a,c,d,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)f[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)f[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){f[d.a].addSelf(d.normal);f[d.b].addSelf(d.normal);f[d.c].addSelf(d.normal);f[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)f[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a(U,aa,la,qa,za,Ba,Ia){j=U.vertices[aa].position;k=U.vertices[la].position;o=U.vertices[qa].position;i=g[za];s=g[Ba];w=g[Ia];x=k.x-j.x;z=o.x-j.x;A=k.y-j.y;
-E=o.y-j.y;H=k.z-j.z;K=o.z-j.z;J=s.u-i.u;R=w.u-i.u;L=s.v-i.v;P=w.v-i.v;b=1/(J*P-R*L);da.set((P*x-L*z)*b,(P*A-L*E)*b,(P*H-L*K)*b);ha.set((J*z-R*x)*b,(J*E-R*A)*b,(J*K-R*H)*b);ba[aa].addSelf(da);ba[la].addSelf(da);ba[qa].addSelf(da);ca[aa].addSelf(ha);ca[la].addSelf(ha);ca[qa].addSelf(ha)}var c,d,f,g,j,k,o,i,s,w,x,z,A,E,H,K,J,R,L,P,b,ba=[],ca=[],da=new THREE.Vector3,ha=new THREE.Vector3,ea=new THREE.Vector3,ma=new THREE.Vector3,ka=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){ba[c]=new THREE.Vector3;
-ca[c]=new THREE.Vector3}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
-this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){ka.copy(this.vertices[c].normal);f=ba[c];ea.copy(f);ea.subSelf(ka.multiplyScalar(ka.dot(f))).normalize();ma.cross(this.vertices[c].normal,f);f=ma.dot(ca[c]);f=f<0?-1:1;this.vertices[c].tangent.set(ea.x,ea.y,ea.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(f[d.a]);d.vertexNormals[1].copy(f[d.b]);d.vertexNormals[2].copy(f[d.c]);d.vertexNormals[3].copy(f[d.d])}}},computeTangents:function(){function a($,qa,va,wa,Ha,Aa,Ia){j=$.vertices[qa].position;k=$.vertices[va].position;o=$.vertices[wa].position;i=g[Ha];t=g[Aa];w=g[Ia];x=k.x-j.x;z=o.x-j.x;A=k.y-j.y;
+E=o.y-j.y;H=k.z-j.z;K=o.z-j.z;J=t.u-i.u;R=w.u-i.u;L=t.v-i.v;P=w.v-i.v;b=1/(J*P-R*L);ca.set((P*x-L*z)*b,(P*A-L*E)*b,(P*H-L*K)*b);ga.set((J*z-R*x)*b,(J*E-R*A)*b,(J*K-R*H)*b);aa[qa].addSelf(ca);aa[va].addSelf(ca);aa[wa].addSelf(ca);ba[qa].addSelf(ga);ba[va].addSelf(ga);ba[wa].addSelf(ga)}var c,d,f,g,j,k,o,i,t,w,x,z,A,E,H,K,J,R,L,P,b,aa=[],ba=[],ca=new THREE.Vector3,ga=new THREE.Vector3,da=new THREE.Vector3,ja=new THREE.Vector3,na=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){aa[c]=new THREE.Vector3;
+ba[c]=new THREE.Vector3}c=0;for(d=this.faces.length;c<d;c++){f=this.faces[c];g=this.uvs[c];if(f instanceof THREE.Face3){a(this,f.a,f.b,f.c,0,1,2);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2])}else if(f instanceof THREE.Face4){a(this,f.a,f.b,f.c,0,1,2);a(this,f.a,f.b,f.d,0,1,3);this.vertices[f.a].normal.copy(f.vertexNormals[0]);this.vertices[f.b].normal.copy(f.vertexNormals[1]);this.vertices[f.c].normal.copy(f.vertexNormals[2]);
+this.vertices[f.d].normal.copy(f.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){na.copy(this.vertices[c].normal);f=aa[c];da.copy(f);da.subSelf(na.multiplyScalar(na.dot(f))).normalize();ja.cross(this.vertices[c].normal,f);f=ja.dot(ba[c]);f=f<0?-1:1;this.vertices[c].tangent.set(da.x,da.y,da.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(w){var x=[];c=0;for(d=w.length;c<d;c++)w[c]==undefined?x.push("undefined"):x.push(w[c].id);return x.join("_")}var c,d,f,g,j,k,o,i,s={};f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];
-k=j.materials;o=a(k);s[o]==undefined&&(s[o]={hash:o,counter:0});i=s[o].hash+"_"+s[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0});j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+j>65535){s[o].counter+=1;i=s[o].hash+"_"+s[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0})}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+
+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,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(w){var x=[];c=0;for(d=w.length;c<d;c++)w[c]==undefined?x.push("undefined"):x.push(w[c].id);return x.join("_")}var c,d,f,g,j,k,o,i,t={};f=0;for(g=this.faces.length;f<g;f++){j=this.faces[f];
+k=j.materials;o=a(k);t[o]==undefined&&(t[o]={hash:o,counter:0});i=t[o].hash+"_"+t[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0});j=j instanceof THREE.Face3?3:4;if(this.geometryChunks[i].vertices+j>65535){t[o].counter+=1;i=t[o].hash+"_"+t[o].counter;this.geometryChunks[i]==undefined&&(this.geometryChunks[i]={faces:[],materials:k,vertices:0})}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0;
 THREE.Camera=function(a,c,d,f,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=d||0.1;this.far=f||2E3;this.screenCenterY=this.screenCenterX=0;this.target=g||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);if(k)this.tmpVec.y=
 THREE.Camera=function(a,c,d,f,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=d||0.1;this.far=f||2E3;this.screenCenterY=this.screenCenterX=0;this.target=g||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.inverseMatrix=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);if(k)this.tmpVec.y=
 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);if(k)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 0;this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};this.translateZ=function(j,k){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);if(k)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,c,d){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;c=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 THREE.Camera.prototype.update=function(a,c,d){if(this.useTarget){this.localMatrix.lookAt(this.position,this.target.position,this.up);a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);THREE.Matrix4.makeInvert(this.globalMatrix,this.inverseMatrix);c=!0}else{this.matrixAutoUpdate&&(c|=this.updateMatrix());if(c||this.matrixNeedsUpdate){a?this.globalMatrix.multiply(a,this.localMatrix):this.globalMatrix.copy(this.localMatrix);this.matrixNeedsUpdate=!1;c=!0;THREE.Matrix4.makeInvert(this.globalMatrix,
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,c,d)};
 this.inverseMatrix)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.globalMatrix,c,d)};
-THREE.Camera.prototype.frustumContains=function(a){var c=a.globalMatrix.n14,d=a.globalMatrix.n24,f=a.globalMatrix.n34,g=this.inverseMatrix,j=a.boundRadius*a.boundRadiusScale,k=g.n31*c+g.n32*d+g.n33*f+g.n34;if(k-j>-this.near)return!1;if(k+j<-this.far)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),s=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*s;j=o.n11*j*s;if(w+j<-this.screenCenterX)return!1;if(w-j>this.screenCenterX)return!1;c=(g.n21*c+g.n22*d+g.n23*f+g.n24)*o.n22*i*this.screenCenterY;
+THREE.Camera.prototype.frustumContains=function(a){var c=a.globalMatrix.n14,d=a.globalMatrix.n24,f=a.globalMatrix.n34,g=this.inverseMatrix,j=a.boundRadius*a.boundRadiusScale,k=g.n31*c+g.n32*d+g.n33*f+g.n34;if(k-j>-this.near)return!1;if(k+j<-this.far)return!1;k-=j;var o=this.projectionMatrix,i=1/(o.n43*k),t=i*this.screenCenterX,w=(g.n11*c+g.n12*d+g.n13*f+g.n14)*o.n11*t;j=o.n11*j*t;if(w+j<-this.screenCenterX)return!1;if(w-j>this.screenCenterX)return!1;c=(g.n21*c+g.n22*d+g.n23*f+g.n24)*o.n22*i*this.screenCenterY;
 if(c+j<-this.screenCenterY)return!1;if(c-j>this.screenCenterY)return!1;a.screenPosition.set(w,c,k,j);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 if(c+j<-this.screenCenterY)return!1;if(c-j>this.screenCenterY)return!1;a.screenPosition.set(w,c,k,j);return!0};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
 THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};
@@ -118,70 +115,70 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.objects=[];this.lights=[];
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var c=0;c<a.children.length;c++)this.addChildRecurse(a.children[c])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound3D)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var c=0;c<a.children.length;c++)this.addChildRecurse(a.children[c])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound3D){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);c!==-1&&this.objects.splice(c,1)}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var c=this.lights.indexOf(a);c!==-1&&this.lights.splice(c,1)}else if(a instanceof THREE.Sound3D){c=this.sounds.indexOf(a);c!==-1&&this.sounds.splice(c,1)}else if(!(a instanceof THREE.Camera)){c=this.objects.indexOf(a);c!==-1&&this.objects.splice(c,1)}for(c=0;c<a.children.length;c++)this.removeChildRecurse(a.children[c])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.WebGLRenderer=function(a){function c(e,n,m){var h,l,v,r=e.vertices,q=r.length,t=e.colors,G=t.length,F=e.__vertexArray,I=e.__colorArray,S=e.__sortArray,y=e.__dirtyVertices,M=e.__dirtyColors;if(m.sortParticles){aa.multiplySelf(m.globalMatrix);for(h=0;h<q;h++){l=r[h].position;Ba.copy(l);aa.multiplyVector3(Ba);S[h]=[Ba.z,h]}S.sort(function(fa,$){return $[0]-fa[0]});for(h=0;h<q;h++){l=r[S[h][1]].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}for(h=0;h<G;h++){v=h*3;color=t[S[h][1]];I[v]=color.r;I[v+
-1]=color.g;I[v+2]=color.b}}else{if(y)for(h=0;h<q;h++){l=r[h].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}if(M)for(h=0;h<G;h++){color=t[h];v=h*3;I[v]=color.r;I[v+1]=color.g;I[v+2]=color.b}}if(y||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,n)}if(M||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,I,n)}}function d(e,n){e.fragment_shader=n.fragment_shader;e.vertex_shader=n.vertex_shader;e.uniforms=Uniforms.clone(n.uniforms)}
-function f(e,n,m,h,l){h.program||da.initMaterial(h,n,m);var v=h.program,r=v.uniforms,q=h.uniforms;if(v!=ba){b.useProgram(v);ba=v;b.uniformMatrix4fv(r.projectionMatrix,!1,la)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){q.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){q.fogNear.value=m.near;q.fogFar.value=m.far}else if(m instanceof
-THREE.FogExp2)q.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var t,G,F=0,I=0,S=0,y,M,fa,$=da.lights,Q=$.directional.colors,O=$.directional.positions,N=$.point.colors,ta=$.point.positions,u=0,pa=0;m=G=G=0;for(t=n.length;m<t;m++){G=n[m];y=G.color;M=G.position;fa=G.intensity;if(G instanceof THREE.AmbientLight){F+=y.r;I+=y.g;S+=y.b}else if(G instanceof THREE.DirectionalLight){G=u*3;Q[G]=y.r*fa;Q[G+1]=y.g*fa;Q[G+2]=y.b*fa;O[G]=M.x;O[G+1]=M.y;
-O[G+2]=M.z;u+=1}else if(G instanceof THREE.PointLight){G=pa*3;N[G]=y.r*fa;N[G+1]=y.g*fa;N[G+2]=y.b*fa;ta[G]=M.x;ta[G+1]=M.y;ta[G+2]=M.z;pa+=1}}for(m=u*3;m<Q.length;m++)Q[m]=0;for(m=pa*3;m<N.length;m++)N[m]=0;$.point.length=pa;$.directional.length=u;$.ambient[0]=F;$.ambient[1]=I;$.ambient[2]=S;n=da.lights;q.enableLighting.value=n.directional.length+n.point.length;q.ambientLightColor.value=n.ambient;q.directionalLightColor.value=n.directional.colors;q.directionalLightDirection.value=n.directional.positions;
+THREE.WebGLRenderer=function(a){function c(e,n,m){var h,l,v,r=e.vertices,q=r.length,s=e.colors,G=s.length,F=e.__vertexArray,I=e.__colorArray,S=e.__sortArray,y=e.__dirtyVertices,M=e.__dirtyColors;if(m.sortParticles){qa.multiplySelf(m.globalMatrix);for(h=0;h<q;h++){l=r[h].position;Aa.copy(l);qa.multiplyVector3(Aa);S[h]=[Aa.z,h]}S.sort(function(ea,Z){return Z[0]-ea[0]});for(h=0;h<q;h++){l=r[S[h][1]].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}for(h=0;h<G;h++){v=h*3;color=s[S[h][1]];I[v]=color.r;I[v+
+1]=color.g;I[v+2]=color.b}}else{if(y)for(h=0;h<q;h++){l=r[h].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}if(M)for(h=0;h<G;h++){color=s[h];v=h*3;I[v]=color.r;I[v+1]=color.g;I[v+2]=color.b}}if(y||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,n)}if(M||m.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,I,n)}}function d(e,n){e.fragment_shader=n.fragment_shader;e.vertex_shader=n.vertex_shader;e.uniforms=Uniforms.clone(n.uniforms)}
+function f(e,n,m,h,l){h.program||ca.initMaterial(h,n,m);var v=h.program,r=v.uniforms,q=h.uniforms;if(v!=aa){b.useProgram(v);aa=v;b.uniformMatrix4fv(r.projectionMatrix,!1,va)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){q.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){q.fogNear.value=m.near;q.fogFar.value=m.far}else if(m instanceof
+THREE.FogExp2)q.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var s,G,F=0,I=0,S=0,y,M,ea,Z=ca.lights,Q=Z.directional.colors,O=Z.directional.positions,N=Z.point.colors,ra=Z.point.positions,u=0,ma=0;m=G=G=0;for(s=n.length;m<s;m++){G=n[m];y=G.color;M=G.position;ea=G.intensity;if(G instanceof THREE.AmbientLight){F+=y.r;I+=y.g;S+=y.b}else if(G instanceof THREE.DirectionalLight){G=u*3;Q[G]=y.r*ea;Q[G+1]=y.g*ea;Q[G+2]=y.b*ea;O[G]=M.x;O[G+1]=M.y;
+O[G+2]=M.z;u+=1}else if(G instanceof THREE.PointLight){G=ma*3;N[G]=y.r*ea;N[G+1]=y.g*ea;N[G+2]=y.b*ea;ra[G]=M.x;ra[G+1]=M.y;ra[G+2]=M.z;ma+=1}}for(m=u*3;m<Q.length;m++)Q[m]=0;for(m=ma*3;m<N.length;m++)N[m]=0;Z.point.length=ma;Z.directional.length=u;Z.ambient[0]=F;Z.ambient[1]=I;Z.ambient[2]=S;n=ca.lights;q.enableLighting.value=n.directional.length+n.point.length;q.ambientLightColor.value=n.ambient;q.directionalLightColor.value=n.directional.colors;q.directionalLightDirection.value=n.directional.positions;
 q.pointLightColor.value=n.point.colors;q.pointLightPosition.value=n.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.map.texture=h.map;q.light_map.texture=h.light_map;q.env_map.texture=h.env_map;q.reflectivity.value=h.reflectivity;q.refraction_ratio.value=h.refraction_ratio;q.combine.value=h.combine;q.useRefract.value=
 q.pointLightColor.value=n.point.colors;q.pointLightPosition.value=n.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.map.texture=h.map;q.light_map.texture=h.light_map;q.env_map.texture=h.env_map;q.reflectivity.value=h.reflectivity;q.refraction_ratio.value=h.refraction_ratio;q.combine.value=h.combine;q.useRefract.value=
 h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){q.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.size.value=h.size;q.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){q.ambient.value.setRGB(h.ambient.r,h.ambient.g,
 h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){q.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.size.value=h.size;q.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){q.ambient.value.setRGB(h.ambient.r,h.ambient.g,
-h.ambient.b);q.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);q.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){q.mNear.value=e.near;q.mFar.value=e.far;q.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)q.opacity.value=h.opacity;for(var na in q)if(F=v.uniforms[na]){m=q[na];t=m.type;n=m.value;if(t=="i")b.uniform1i(F,n);else if(t=="f")b.uniform1f(F,n);else if(t=="fv1")b.uniform1fv(F,n);else if(t=="fv")b.uniform3fv(F,n);else if(t=="v2")b.uniform2f(F,
-n.x,n.y);else if(t=="v3")b.uniform3f(F,n.x,n.y,n.z);else if(t=="c")b.uniform3f(F,n.r,n.g,n.b);else if(t=="t"){b.uniform1i(F,n);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(!m.image.__webGLTextureCube)m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);
-b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(t=0;t<6;++t)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[t]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{if(m.needsUpdate){if(m.__wasSetOnce){b.bindTexture(b.TEXTURE_2D,
+h.ambient.b);q.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);q.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){q.mNear.value=e.near;q.mFar.value=e.far;q.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)q.opacity.value=h.opacity;for(var ka in q)if(F=v.uniforms[ka]){m=q[ka];s=m.type;n=m.value;if(s=="i")b.uniform1i(F,n);else if(s=="f")b.uniform1f(F,n);else if(s=="fv1")b.uniform1fv(F,n);else if(s=="fv")b.uniform3fv(F,n);else if(s=="v2")b.uniform2f(F,
+n.x,n.y);else if(s=="v3")b.uniform3f(F,n.x,n.y,n.z);else if(s=="c")b.uniform3f(F,n.r,n.g,n.b);else if(s=="t"){b.uniform1i(F,n);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(!m.image.__webGLTextureCube)m.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);
+b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image[s]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{if(m.needsUpdate){if(m.__wasSetOnce){b.bindTexture(b.TEXTURE_2D,
 m.__webGLTexture);b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}else{m.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
 m.__webGLTexture);b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}else{m.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);b.texImage2D(b.TEXTURE_2D,
 0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null);m.__wasSetOnce=!0}m.needsUpdate=!1}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_2D,m.__webGLTexture)}}}b.uniformMatrix4fv(r.modelViewMatrix,
 0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,m.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(m.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(m.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(m.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(m.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null);m.__wasSetOnce=!0}m.needsUpdate=!1}b.activeTexture(b.TEXTURE0+n);b.bindTexture(b.TEXTURE_2D,m.__webGLTexture)}}}b.uniformMatrix4fv(r.modelViewMatrix,
 !1,l._modelViewMatrixArray);b.uniformMatrix3fv(r.normalMatrix,!1,l._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)&&b.uniform3f(r.cameraPosition,e.position.x,e.position.y,e.position.z);(h instanceof THREE.MeshShaderMaterial||h.env_map||h.skinning)&&b.uniformMatrix4fv(r.objectMatrix,!1,l._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&b.uniformMatrix4fv(r.viewMatrix,
 !1,l._modelViewMatrixArray);b.uniformMatrix3fv(r.normalMatrix,!1,l._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.env_map)&&b.uniform3f(r.cameraPosition,e.position.x,e.position.y,e.position.z);(h instanceof THREE.MeshShaderMaterial||h.env_map||h.skinning)&&b.uniformMatrix4fv(r.objectMatrix,!1,l._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&b.uniformMatrix4fv(r.viewMatrix,
-!1,za);if(h.skinning){b.uniformMatrix4fv(r.cameraInverseMatrix,!1,qa);b.uniformMatrix4fv(r.boneGlobalMatrices,!1,l.boneMatrices)}return v}function g(e,n,m,h,l,v){e=f(e,n,m,h,v).attributes;b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,!1,0,0);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,!1,0,0)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,
+!1,Ha);if(h.skinning){b.uniformMatrix4fv(r.cameraInverseMatrix,!1,wa);b.uniformMatrix4fv(r.boneGlobalMatrices,!1,l.boneMatrices)}return v}function g(e,n,m,h,l,v){e=f(e,n,m,h,v).attributes;b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.vertexAttribPointer(e.position,3,b.FLOAT,!1,0,0);if(e.color>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,!1,0,0)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,
 3,b.FLOAT,!1,0,0)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,!1,0,0)}if(e.uv>=0)if(l.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(l.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);
 3,b.FLOAT,!1,0,0)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,!1,0,0)}if(e.uv>=0)if(l.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(l.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);
 if(h.skinning&&e.skinVertexA>=0&&e.skinVertexB>=0&&e.skinIndex>=0&&e.skinWeight>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinVertexABuffer);b.vertexAttribPointer(e.skinVertexA,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinVertexBBuffer);b.vertexAttribPointer(e.skinVertexB,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinIndicesBuffer);b.vertexAttribPointer(e.skinIndex,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinWeightsBuffer);b.vertexAttribPointer(e.skinWeight,
 if(h.skinning&&e.skinVertexA>=0&&e.skinVertexB>=0&&e.skinIndex>=0&&e.skinWeight>=0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinVertexABuffer);b.vertexAttribPointer(e.skinVertexA,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinVertexBBuffer);b.vertexAttribPointer(e.skinVertexB,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinIndicesBuffer);b.vertexAttribPointer(e.skinIndex,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,l.__webGLSkinWeightsBuffer);b.vertexAttribPointer(e.skinWeight,
 4,b.FLOAT,!1,0,0)}if(v instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.drawElements(b.LINES,l.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,l.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(v,0,l.__webGLLineCount)}else if(v instanceof
 4,b.FLOAT,!1,0,0)}if(v instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.drawElements(b.LINES,l.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,l.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(v,0,l.__webGLLineCount)}else if(v instanceof
 THREE.ParticleSystem)b.drawArrays(b.POINTS,0,l.__webGLParticleCount);else v instanceof THREE.Ribbon&&b.drawArrays(b.TRIANGLE_STRIP,0,l.__webGLVertexCount)}function j(e,n){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.position);b.vertexAttribPointer(n.attributes.position,
 THREE.ParticleSystem)b.drawArrays(b.POINTS,0,l.__webGLParticleCount);else v instanceof THREE.Ribbon&&b.drawArrays(b.TRIANGLE_STRIP,0,l.__webGLVertexCount)}function j(e,n){if(!e.__webGLVertexBuffer)e.__webGLVertexBuffer=b.createBuffer();if(!e.__webGLNormalBuffer)e.__webGLNormalBuffer=b.createBuffer();if(e.hasPos){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,e.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.position);b.vertexAttribPointer(n.attributes.position,
-3,b.FLOAT,!1,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.normal);b.vertexAttribPointer(n.attributes.normal,3,b.FLOAT,!1,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function k(e){if(ha!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);ha=e.doubleSided}if(ea!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);ea=e.flipSided}}function o(e){if(ka!=
-e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST);ka=e}}function i(e){U[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);U[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+e.n14);U[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);U[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);U[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);U[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var n;for(e=0;e<6;e++){n=U[e];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}}
-function s(e){for(var n=e.globalMatrix,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=U[h].x*n.n14+U[h].y*n.n24+U[h].z*n.n34+U[h].w;if(e<=m)return!1}return!0}function w(e,n){e.list[e.count]=n;e.count+=1}function x(e){var n,m,h=e.object,l=e.opaque,v=e.transparent;v.count=0;e=l.count=0;for(n=h.materials.length;e<n;e++){m=h.materials[e];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?w(v,m):w(l,m)}}function z(e){var n,m,h,l,v=e.object,r=
-e.buffer,q=e.opaque,t=e.transparent;t.count=0;e=q.count=0;for(h=v.materials.length;e<h;e++){n=v.materials[e];if(n instanceof THREE.MeshFaceMaterial){n=0;for(m=r.materials.length;n<m;n++)(l=r.materials[n])&&(l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?w(t,l):w(q,l))}else{l=n;l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?w(t,l):w(q,l)}}}function A(e,n){return n.z-e.z}function E(e,n,m,h,l){if(n[m]==undefined){e.push({buffer:h,object:l,opaque:{list:[],count:0},transparent:{list:[],
-count:0}});n[m]=1}}function H(e,n){e._modelViewMatrix.multiplyToArray(n.globalMatrix,e.globalMatrix,e._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function K(e){if(e!=ma){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
-break;case THREE.ReverseSubtractiveBlending:b.blendEquation(b.FUNC_REVERSE_SUBTRACT);b.blendFunc(b.ONE,b.ONE);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}ma=e}}function J(e,n){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,
+3,b.FLOAT,!1,0,0)}if(e.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,e.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,e.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(n.attributes.normal);b.vertexAttribPointer(n.attributes.normal,3,b.FLOAT,!1,0,0)}b.drawArrays(b.TRIANGLES,0,e.count);e.count=0}function k(e){if(ga!=e.doubleSided){e.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);ga=e.doubleSided}if(da!=e.flipSided){e.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);da=e.flipSided}}function o(e){if(na!=
+e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST);na=e}}function i(e){$[0].set(e.n41-e.n11,e.n42-e.n12,e.n43-e.n13,e.n44-e.n14);$[1].set(e.n41+e.n11,e.n42+e.n12,e.n43+e.n13,e.n44+e.n14);$[2].set(e.n41+e.n21,e.n42+e.n22,e.n43+e.n23,e.n44+e.n24);$[3].set(e.n41-e.n21,e.n42-e.n22,e.n43-e.n23,e.n44-e.n24);$[4].set(e.n41-e.n31,e.n42-e.n32,e.n43-e.n33,e.n44-e.n34);$[5].set(e.n41+e.n31,e.n42+e.n32,e.n43+e.n33,e.n44+e.n34);var n;for(e=0;e<6;e++){n=$[e];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*n.z))}}
+function t(e){for(var n=e.globalMatrix,m=-e.geometry.boundingSphere.radius*Math.max(e.scale.x,Math.max(e.scale.y,e.scale.z)),h=0;h<6;h++){e=$[h].x*n.n14+$[h].y*n.n24+$[h].z*n.n34+$[h].w;if(e<=m)return!1}return!0}function w(e,n){e.list[e.count]=n;e.count+=1}function x(e){var n,m,h=e.object,l=e.opaque,v=e.transparent;v.count=0;e=l.count=0;for(n=h.materials.length;e<n;e++){m=h.materials[e];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?w(v,m):w(l,m)}}function z(e){var n,m,h,l,v=e.object,r=
+e.buffer,q=e.opaque,s=e.transparent;s.count=0;e=q.count=0;for(h=v.materials.length;e<h;e++){n=v.materials[e];if(n instanceof THREE.MeshFaceMaterial){n=0;for(m=r.materials.length;n<m;n++)(l=r.materials[n])&&(l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?w(s,l):w(q,l))}else{l=n;l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?w(s,l):w(q,l)}}}function A(e,n){return n.z-e.z}function E(e,n,m,h,l){if(n[m]==undefined){e.push({buffer:h,object:l,opaque:{list:[],count:0},transparent:{list:[],
+count:0}});n[m]=1}}function H(e,n){e._modelViewMatrix.multiplyToArray(n.globalMatrix,e.globalMatrix,e._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(e._modelViewMatrix).transposeIntoArray(e._normalMatrixArray)}function K(e){if(e!=ja){switch(e){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);
+break;case THREE.ReverseSubtractiveBlending:b.blendEquation(b.FUNC_REVERSE_SUBTRACT);b.blendFunc(b.ONE,b.ONE);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}ja=e}}function J(e,n){if(e&&!e.__webGLFramebuffer){e.__webGLFramebuffer=b.createFramebuffer();e.__webGLRenderbuffer=b.createRenderbuffer();e.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,e.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,e.width,e.height);b.bindTexture(b.TEXTURE_2D,
 e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(e.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,L(e.format),e.width,e.height,0,L(e.format),L(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);
 e.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,L(e.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,L(e.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,L(e.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,L(e.min_filter));b.texImage2D(b.TEXTURE_2D,0,L(e.format),e.width,e.height,0,L(e.format),L(e.type),null);b.bindFramebuffer(b.FRAMEBUFFER,e.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,e.__webGLTexture,0);
-b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var m,h,l;if(e){m=e.__webGLFramebuffer;h=e.width;l=e.height}else{m=null;h=P.width;l=P.height}if(m!=ca){b.bindFramebuffer(b.FRAMEBUFFER,m);b.viewport(0,0,h,l);n&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);ca=m}}function R(e,n){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else e==
+b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,e.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var m,h,l;if(e){m=e.__webGLFramebuffer;h=e.width;l=e.height}else{m=null;h=P.width;l=P.height}if(m!=ba){b.bindFramebuffer(b.FRAMEBUFFER,m);b.viewport(0,0,h,l);n&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);ba=m}}function R(e,n){var m;if(e=="fragment")m=b.createShader(b.FRAGMENT_SHADER);else e==
 "vertex"&&(m=b.createShader(b.VERTEX_SHADER));b.shaderSource(m,n);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));return null}return m}function L(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;
 "vertex"&&(m=b.createShader(b.VERTEX_SHADER));b.shaderSource(m,n);b.compileShader(m);if(!b.getShaderParameter(m,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(m));return null}return m}function L(e){switch(e){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;
 case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;
 case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;
-case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var P=document.createElement("canvas"),b,ba=null,ca=null,da=this,ha=null,ea=null,ma=null,ka=null,U=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],aa=new THREE.Matrix4,la=new Float32Array(16),qa=new Float32Array(16),za=new Float32Array(16),Ba=new THREE.Vector4,
+case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var P=document.createElement("canvas"),b,aa=null,ba=null,ca=this,ga=null,da=null,ja=null,na=null,$=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],qa=new THREE.Matrix4,va=new Float32Array(16),wa=new Float32Array(16),Ha=new Float32Array(16),Aa=new THREE.Vector4,
 Ia=!0,Oa=new THREE.Color(0),Pa=0;if(a){if(a.antialias!==undefined)Ia=a.antialias;a.clearColor!==undefined&&Oa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Pa=a.clearAlpha}this.domElement=P;this.autoClear=!0;this.sortObjects=!1;(function(e,n,m){try{b=P.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}if(!b)throw"cannot create webgl context";b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);
 Ia=!0,Oa=new THREE.Color(0),Pa=0;if(a){if(a.antialias!==undefined)Ia=a.antialias;a.clearColor!==undefined&&Oa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Pa=a.clearAlpha}this.domElement=P;this.autoClear=!0;this.sortObjects=!1;(function(e,n,m){try{b=P.getContext("experimental-webgl",{antialias:e})}catch(h){console.log(h)}if(!b)throw"cannot create webgl context";b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);
 b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(n.r,n.g,n.b,m);_cullEnabled=!0})(Ia,Oa,Pa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,n){P.width=e;P.height=n;b.viewport(0,0,P.width,P.height)};this.setClearColorHex=function(e,n){var m=new THREE.Color(e);b.clearColor(m.r,m.g,m.b,n)};this.setClearColor=function(e,n){b.clearColor(e.r,e.g,e.b,n)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|
 b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(n.r,n.g,n.b,m);_cullEnabled=!0})(Ia,Oa,Pa);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(e,n){P.width=e;P.height=n;b.viewport(0,0,P.width,P.height)};this.setClearColorHex=function(e,n){var m=new THREE.Color(e);b.clearColor(m.r,m.g,m.b,n)};this.setClearColor=function(e,n){b.clearColor(e.r,e.g,e.b,n)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|
 b.DEPTH_BUFFER_BIT)};this.initMaterial=function(e,n,m){var h,l;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);else e instanceof
 b.DEPTH_BUFFER_BIT)};this.initMaterial=function(e,n,m){var h,l;if(e instanceof THREE.MeshDepthMaterial)d(e,THREE.ShaderLib.depth);else if(e instanceof THREE.MeshNormalMaterial)d(e,THREE.ShaderLib.normal);else if(e instanceof THREE.MeshBasicMaterial)d(e,THREE.ShaderLib.basic);else if(e instanceof THREE.MeshLambertMaterial)d(e,THREE.ShaderLib.lambert);else if(e instanceof THREE.MeshPhongMaterial)d(e,THREE.ShaderLib.phong);else if(e instanceof THREE.LineBasicMaterial)d(e,THREE.ShaderLib.basic);else e instanceof
-THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var v,r,q,t;l=q=t=0;for(v=n.length;l<v;l++){r=n[l];r instanceof THREE.DirectionalLight&&q++;r instanceof THREE.PointLight&&t++}if(t+q<=4)n=q;else{n=Math.ceil(4*q/(t+q));t=4-n}l={directional:n,point:t};t=e.fragment_shader;n=e.vertex_shader;v={fog:m,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,skinning:e.skinning,maxDirLights:l.directional,maxPointLights:l.point};m=b.createProgram();l=["#ifdef GL_ES\nprecision highp float;\n#endif",
+THREE.ParticleBasicMaterial&&d(e,THREE.ShaderLib.particle_basic);var v,r,q,s;l=q=s=0;for(v=n.length;l<v;l++){r=n[l];r instanceof THREE.DirectionalLight&&q++;r instanceof THREE.PointLight&&s++}if(s+q<=4)n=q;else{n=Math.ceil(4*q/(s+q));s=4-n}l={directional:n,point:s};s=e.fragment_shader;n=e.vertex_shader;v={fog:m,map:e.map,env_map:e.env_map,light_map:e.light_map,vertex_colors:e.vertex_colors,skinning:e.skinning,maxDirLights:l.directional,maxPointLights:l.point};m=b.createProgram();l=["#ifdef GL_ES\nprecision highp float;\n#endif",
 "#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+
 "#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+
 v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"",v.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
 v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"",v.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-b.attachShader(m,R("fragment",l+t));b.attachShader(m,R("vertex",v+n));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(h in e.uniforms)m.push(h);h=e.program;t=0;for(n=m.length;t<
-n;t++){l=m[t];h.uniforms[l]=b.getUniformLocation(h,l)}h=e.program;m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];t=0;for(n=m.length;t<n;t++){l=m[t];h.attributes[l]=b.getAttribLocation(h,l)}h=e.program.attributes;b.enableVertexAttribArray(h.position);h.color>=0&&b.enableVertexAttribArray(h.color);h.normal>=0&&b.enableVertexAttribArray(h.normal);h.tangent>=0&&b.enableVertexAttribArray(h.tangent);if(e.skinning&&h.skinVertexA>=0&&h.skinVertexB>=
-0&&h.skinIndex>=0&&h.skinWeight>=0){b.enableVertexAttribArray(h.skinVertexA);b.enableVertexAttribArray(h.skinVertexB);b.enableVertexAttribArray(h.skinIndex);b.enableVertexAttribArray(h.skinWeight)}};this.render=function(e,n,m,h){var l,v,r,q,t,G,F,I,S=e.lights,y=e.fog;n.matrixAutoUpdate&&n.update();n.globalMatrix.flattenToArray(za);n.projectionMatrix.flattenToArray(la);n.inverseMatrix.flattenToArray(qa);aa.multiply(n.projectionMatrix,n.globalMatrix);i(aa);THREE.AnimationHandler&&THREE.AnimationHandler.update();
-e.update(undefined,!1,n);this.initWebGLObjects(e,n);J(m,h!==undefined?h:!0);this.autoClear&&this.clear();t=e.__webGLObjects.length;for(h=0;h<t;h++){l=e.__webGLObjects[h];F=l.object;if(F.visible)if(!(F instanceof THREE.Mesh)||s(F)){F.globalMatrix.flattenToArray(F._objectMatrixArray);H(F,n);z(l);l.render=!0;if(this.sortObjects){Ba.copy(F.position);aa.multiplyVector3(Ba);l.z=Ba.z}}else l.render=!1;else l.render=!1}this.sortObjects&&e.__webGLObjects.sort(A);G=e.__webGLObjectsImmediate.length;for(h=0;h<
-G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){F.matrixAutoUpdate&&F.globalMatrix.flattenToArray(F._objectMatrixArray);H(F,n);x(l)}}K(THREE.NormalBlending);for(h=0;h<t;h++){l=e.__webGLObjects[h];if(l.render){F=l.object;I=l.buffer;r=l.opaque;k(F);for(l=0;l<r.count;l++){q=r.list[l];o(q.depth_test);g(n,S,y,q,I,F)}}}for(h=0;h<G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.opaque;k(F);for(l=0;l<r.count;l++){q=r.list[l];o(q.depth_test);v=f(n,S,y,q,F);F.render(function(M){j(M,
-v)})}}}for(h=0;h<t;h++){l=e.__webGLObjects[h];if(l.render){F=l.object;I=l.buffer;r=l.transparent;k(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);o(q.depth_test);g(n,S,y,q,I,F)}}}for(h=0;h<G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.transparent;k(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);o(q.depth_test);v=f(n,S,y,q,F);F.render(function(M){j(M,v)})}}}if(m&&m.min_filter!==THREE.NearestFilter&&m.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);
-b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e,n){var m,h,l;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}m=0;for(h=e.objects.length;m<h;m++){l=e.objects[m];var v=e,r=n,q=void 0,t=void 0,G=void 0,F=void 0;t=l.geometry;if(v.__webGLObjectsMap[l.id]==undefined){v.__webGLObjectsMap[l.id]={};l._modelViewMatrix=new THREE.Matrix4;l._normalMatrixArray=new Float32Array(9);l._modelViewMatrixArray=new Float32Array(16);
-l._objectMatrixArray=new Float32Array(16);l.globalMatrix.flattenToArray(l._objectMatrixArray)}F=v.__webGLObjectsMap[l.id];objlist=v.__webGLObjects;if(l instanceof THREE.Mesh){for(q in t.geometryChunks){G=t.geometryChunks[q];if(!G.__webGLVertexBuffer){r=G;r.__webGLVertexBuffer=b.createBuffer();r.__webGLNormalBuffer=b.createBuffer();r.__webGLTangentBuffer=b.createBuffer();r.__webGLColorBuffer=b.createBuffer();r.__webGLUVBuffer=b.createBuffer();r.__webGLUV2Buffer=b.createBuffer();r.__webGLSkinVertexABuffer=
-b.createBuffer();r.__webGLSkinVertexBBuffer=b.createBuffer();r.__webGLSkinIndicesBuffer=b.createBuffer();r.__webGLSkinWeightsBuffer=b.createBuffer();r.__webGLFaceBuffer=b.createBuffer();r.__webGLLineBuffer=b.createBuffer();r=G;var I=l,S=void 0,y=void 0,M=0,fa=v=0,$=I.geometry.faces,Q=r.faces;S=0;for(y=Q.length;S<y;S++){fi=Q[S];face=$[fi];if(face instanceof THREE.Face3){M+=3;v+=1;fa+=3}else if(face instanceof THREE.Face4){M+=4;v+=2;fa+=4}}r.__vertexArray=new Float32Array(M*3);r.__normalArray=new Float32Array(M*
-3);r.__tangentArray=new Float32Array(M*4);r.__colorArray=new Float32Array(M*3);r.__uvArray=new Float32Array(M*2);r.__uv2Array=new Float32Array(M*2);r.__skinVertexAArray=new Float32Array(M*4);r.__skinVertexBArray=new Float32Array(M*4);r.__skinIndexArray=new Float32Array(M*4);r.__skinWeightArray=new Float32Array(M*4);r.__faceArray=new Uint16Array(v*3);r.__lineArray=new Uint16Array(fa*2);y=S=r;M=void 0;$=void 0;var O=void 0,N=void 0;O=void 0;Q=!1;M=0;for($=I.materials.length;M<$;M++){O=I.materials[M];
-if(O instanceof THREE.MeshFaceMaterial){O=0;for(N=y.materials.length;O<N;O++)if(y.materials[O]&&y.materials[O].shading!=undefined&&y.materials[O].shading==THREE.SmoothShading){Q=!0;break}}else if(O&&O.shading!=undefined&&O.shading==THREE.SmoothShading){Q=!0;break}if(Q)break}S.__needsSmoothNormals=Q;r.__webGLFaceCount=v*3;r.__webGLLineCount=fa*2;t.__dirtyVertices=!0;t.__dirtyElements=!0;t.__dirtyUvs=!0;t.__dirtyNormals=!0;t.__dirtyTangents=!0;t.__dirtyColors=!0}if(t.__dirtyVertices||t.__dirtyElements||
-t.__dirtyUvs||t.__dirtyNormals||t.__dirtyColors||t.__dirtyTangents){r=G;v=b.DYNAMIC_DRAW;fa=void 0;S=void 0;var ta=void 0,u=void 0,pa=void 0,na=void 0,wa=void 0;ta=void 0;var B=void 0,C=void 0,D=void 0,T=void 0;B=void 0;C=void 0;D=void 0;u=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;u=void 0;na=void 0;pa=void 0;wa=void 0;var ra=N=O=Q=$=M=I=y=0,ga=0,p=0,ia=
-r.__vertexArray,Ga=r.__uvArray,Ha=r.__uv2Array,va=r.__normalArray,V=r.__tangentArray,ja=r.__colorArray,W=r.__skinVertexAArray,X=r.__skinVertexBArray,Y=r.__skinIndexArray,Z=r.__skinWeightArray,xa=r.__faceArray,sa=r.__lineArray,Qa=r.__needsSmoothNormals,oa=l.geometry,Ja=oa.__dirtyVertices,Ka=oa.__dirtyElements,Fa=oa.__dirtyUvs,La=oa.__dirtyNormals,Ma=oa.__dirtyTangents,Na=oa.__dirtyColors,ua=oa.vertices,Ra=r.faces,Sa=oa.faces,Ta=oa.uvs,Ua=oa.uvs2,ya=oa.colors,Ca=oa.skinVerticesA,Da=oa.skinVerticesB,
-Ea=oa.skinIndices,Aa=oa.skinWeights;fa=0;for(S=Ra.length;fa<S;fa++){ta=Ra[fa];u=Sa[ta];wa=Ta[ta];ta=Ua[ta];pa=u.vertexNormals;na=u.normal;if(u instanceof THREE.Face3){if(Ja){B=ua[u.a].position;C=ua[u.b].position;D=ua[u.c].position;ia[I]=B.x;ia[I+1]=B.y;ia[I+2]=B.z;ia[I+3]=C.x;ia[I+4]=C.y;ia[I+5]=C.z;ia[I+6]=D.x;ia[I+7]=D.y;ia[I+8]=D.z;I+=9}if(Aa.length){B=Aa[u.a];C=Aa[u.b];D=Aa[u.c];Z[p]=B.x;Z[p+1]=B.y;Z[p+2]=B.z;Z[p+3]=B.w;Z[p+4]=C.x;Z[p+5]=C.y;Z[p+6]=C.z;Z[p+7]=C.w;Z[p+8]=D.x;Z[p+9]=D.y;Z[p+10]=
-D.z;Z[p+11]=D.w;B=Ea[u.a];C=Ea[u.b];D=Ea[u.c];Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=D.z;Y[p+11]=D.w;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;B=Da[u.a];C=Da[u.b];D=Da[u.c];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=1;X[p+4]=C.x;X[p+5]=C.y;X[p+6]=C.z;X[p+7]=1;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=1;p+=12}if(Na&&
-ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];ja[ga]=B.r;ja[ga+1]=B.g;ja[ga+2]=B.b;ja[ga+3]=C.r;ja[ga+4]=C.g;ja[ga+5]=C.b;ja[ga+6]=D.r;ja[ga+7]=D.g;ja[ga+8]=D.b;ga+=9}if(Ma&&oa.hasTangents){B=ua[u.a].tangent;C=ua[u.b].tangent;D=ua[u.c].tangent;V[N]=B.x;V[N+1]=B.y;V[N+2]=B.z;V[N+3]=B.w;V[N+4]=C.x;V[N+5]=C.y;V[N+6]=C.z;V[N+7]=C.w;V[N+8]=D.x;V[N+9]=D.y;V[N+10]=D.z;V[N+11]=D.w;N+=12}if(La)if(pa.length==3&&Qa)for(u=0;u<3;u++){na=pa[u];va[O]=na.x;va[O+1]=na.y;va[O+2]=na.z;O+=3}else for(u=0;u<3;u++){va[O]=na.x;
-va[O+1]=na.y;va[O+2]=na.z;O+=3}if(Fa&&wa)for(u=0;u<3;u++){pa=wa[u];Ga[M]=pa.u;Ga[M+1]=pa.v;M+=2}if(Fa&&ta)for(u=0;u<3;u++){wa=ta[u];Ha[$]=wa.u;Ha[$+1]=wa.v;$+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;Q+=3;sa[ra]=y;sa[ra+1]=y+1;sa[ra+2]=y;sa[ra+3]=y+2;sa[ra+4]=y+1;sa[ra+5]=y+2;ra+=6;y+=3}}else if(u instanceof THREE.Face4){if(Ja){B=ua[u.a].position;C=ua[u.b].position;D=ua[u.c].position;T=ua[u.d].position;ia[I]=B.x;ia[I+1]=B.y;ia[I+2]=B.z;ia[I+3]=C.x;ia[I+4]=C.y;ia[I+5]=C.z;ia[I+6]=D.x;ia[I+7]=D.y;ia[I+
-8]=D.z;ia[I+9]=T.x;ia[I+10]=T.y;ia[I+11]=T.z;I+=12}if(Aa.length){B=Aa[u.a];C=Aa[u.b];D=Aa[u.c];T=Aa[u.d];Z[p]=B.x;Z[p+1]=B.y;Z[p+2]=B.z;Z[p+3]=B.w;Z[p+4]=C.x;Z[p+5]=C.y;Z[p+6]=C.z;Z[p+7]=C.w;Z[p+8]=D.x;Z[p+9]=D.y;Z[p+10]=D.z;Z[p+11]=D.w;Z[p+12]=T.x;Z[p+13]=T.y;Z[p+14]=T.z;Z[p+15]=T.w;B=Ea[u.a];C=Ea[u.b];D=Ea[u.c];T=Ea[u.d];Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=D.z;Y[p+11]=D.w;Y[p+12]=T.x;Y[p+13]=T.y;Y[p+14]=T.z;Y[p+15]=
-T.w;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];T=Ca[u.d];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;W[p+12]=T.x;W[p+13]=T.y;W[p+14]=T.z;W[p+15]=1;B=Da[u.a];C=Da[u.b];D=Da[u.c];T=Da[u.d];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=1;X[p+4]=C.x;X[p+5]=C.y;X[p+6]=C.z;X[p+7]=1;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=1;X[p+12]=T.x;X[p+13]=T.y;X[p+14]=T.z;X[p+15]=1;p+=16}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];T=ya[u.d];ja[ga]=B.r;
-ja[ga+1]=B.g;ja[ga+2]=B.b;ja[ga+3]=C.r;ja[ga+4]=C.g;ja[ga+5]=C.b;ja[ga+6]=D.r;ja[ga+7]=D.g;ja[ga+8]=D.b;ja[ga+9]=T.r;ja[ga+10]=T.g;ja[ga+11]=T.b;ga+=12}if(Ma&&oa.hasTangents){B=ua[u.a].tangent;C=ua[u.b].tangent;D=ua[u.c].tangent;u=ua[u.d].tangent;V[N]=B.x;V[N+1]=B.y;V[N+2]=B.z;V[N+3]=B.w;V[N+4]=C.x;V[N+5]=C.y;V[N+6]=C.z;V[N+7]=C.w;V[N+8]=D.x;V[N+9]=D.y;V[N+10]=D.z;V[N+11]=D.w;V[N+12]=u.x;V[N+13]=u.y;V[N+14]=u.z;V[N+15]=u.w;N+=16}if(La)if(pa.length==4&&Qa)for(u=0;u<4;u++){na=pa[u];va[O]=na.x;va[O+
-1]=na.y;va[O+2]=na.z;O+=3}else for(u=0;u<4;u++){va[O]=na.x;va[O+1]=na.y;va[O+2]=na.z;O+=3}if(Fa&&wa)for(u=0;u<4;u++){pa=wa[u];Ga[M]=pa.u;Ga[M+1]=pa.v;M+=2}if(Fa&&ta)for(u=0;u<4;u++){wa=ta[u];Ha[$]=wa.u;Ha[$+1]=wa.v;$+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;xa[Q+3]=y;xa[Q+4]=y+2;xa[Q+5]=y+3;Q+=6;sa[ra]=y;sa[ra+1]=y+1;sa[ra+2]=y;sa[ra+3]=y+3;sa[ra+4]=y+1;sa[ra+5]=y+2;sa[ra+6]=y+2;sa[ra+7]=y+3;ra+=8;y+=4}}}if(Ja){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,ia,v)}if(Na&&
-ya.length){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ja,v)}if(La){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,va,v)}if(Ma&&oa.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,V,v)}if(Fa&&M>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ga,v)}if(Fa&&$>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Ha,v)}if(Ka){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
-r.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,xa,v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,sa,v)}if(p>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinVertexABuffer);b.bufferData(b.ARRAY_BUFFER,W,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinVertexBBuffer);b.bufferData(b.ARRAY_BUFFER,X,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinIndicesBuffer);b.bufferData(b.ARRAY_BUFFER,Y,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinWeightsBuffer);b.bufferData(b.ARRAY_BUFFER,
-Z,v)}}E(objlist,F,q,G,l)}t.__dirtyVertices=!1;t.__dirtyElements=!1;t.__dirtyUvs=!1;t.__dirtyNormals=!1;t.__dirtyTangents=!1;t.__dirtyColors=!1}else if(l instanceof THREE.Ribbon){if(!t.__webGLVertexBuffer){q=t;q.__webGLVertexBuffer=b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=t;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLVertexCount=G;t.__dirtyVertices=!0;t.__dirtyColors=!0}if(t.__dirtyVertices||t.__dirtyColors){q=t;G=b.DYNAMIC_DRAW;
-y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;$=M.length;fa=v.length;Q=q.__vertexArray;S=q.__colorArray;O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<$;y++){I=M[y].position;r=y*3;Q[r]=I.x;Q[r+1]=I.y;Q[r+2]=I.z}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<fa;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,S,G)}}E(objlist,F,0,t,l);t.__dirtyVertices=
-!1;t.__dirtyColors=!1}else if(l instanceof THREE.Line){if(!t.__webGLVertexBuffer){q=t;q.__webGLVertexBuffer=b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=t;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLLineCount=G;t.__dirtyVertices=!0;t.__dirtyColors=!0}if(t.__dirtyVertices||t.__dirtyColors){q=t;G=b.DYNAMIC_DRAW;y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;$=M.length;fa=v.length;Q=q.__vertexArray;S=q.__colorArray;
-O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<$;y++){I=M[y].position;r=y*3;Q[r]=I.x;Q[r+1]=I.y;Q[r+2]=I.z}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<fa;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,S,G)}}E(objlist,F,0,t,l);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(l instanceof THREE.ParticleSystem){if(!t.__webGLVertexBuffer){q=t;q.__webGLVertexBuffer=
-b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=t;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__sortArray=[];q.__webGLParticleCount=G;t.__dirtyVertices=!0;t.__dirtyColors=!0}(t.__dirtyVertices||t.__dirtyColors||l.sortParticles)&&c(t,b.DYNAMIC_DRAW,l,r);E(objlist,F,0,t,l);t.__dirtyVertices=!1;t.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&l instanceof THREE.MarchingCubes){t=F;if(t[0]==undefined){v.__webGLObjectsImmediate.push({object:l,
-opaque:{list:[],count:0},transparent:{list:[],count:0}});t[0]=1}}}};this.removeObject=function(e,n){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;n==h&&e.__webGLObjects.splice(m,1)}};this.setFaceCulling=function(e,n){if(e){!n||n=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+b.attachShader(m,R("fragment",l+s));b.attachShader(m,R("vertex",v+n));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(h in e.uniforms)m.push(h);h=e.program;s=0;for(n=m.length;s<
+n;s++){l=m[s];h.uniforms[l]=b.getUniformLocation(h,l)}h=e.program;m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];s=0;for(n=m.length;s<n;s++){l=m[s];h.attributes[l]=b.getAttribLocation(h,l)}h=e.program.attributes;b.enableVertexAttribArray(h.position);h.color>=0&&b.enableVertexAttribArray(h.color);h.normal>=0&&b.enableVertexAttribArray(h.normal);h.tangent>=0&&b.enableVertexAttribArray(h.tangent);if(e.skinning&&h.skinVertexA>=0&&h.skinVertexB>=
+0&&h.skinIndex>=0&&h.skinWeight>=0){b.enableVertexAttribArray(h.skinVertexA);b.enableVertexAttribArray(h.skinVertexB);b.enableVertexAttribArray(h.skinIndex);b.enableVertexAttribArray(h.skinWeight)}};this.render=function(e,n,m,h){var l,v,r,q,s,G,F,I,S=e.lights,y=e.fog;n.matrixAutoUpdate&&n.update();n.globalMatrix.flattenToArray(Ha);n.projectionMatrix.flattenToArray(va);n.inverseMatrix.flattenToArray(wa);qa.multiply(n.projectionMatrix,n.globalMatrix);i(qa);THREE.AnimationHandler&&THREE.AnimationHandler.update();
+e.update(undefined,!1,n);this.initWebGLObjects(e,n);J(m,h!==undefined?h:!0);this.autoClear&&this.clear();s=e.__webGLObjects.length;for(h=0;h<s;h++){l=e.__webGLObjects[h];F=l.object;if(F.visible)if(!(F instanceof THREE.Mesh)||t(F)){F.globalMatrix.flattenToArray(F._objectMatrixArray);H(F,n);z(l);l.render=!0;if(this.sortObjects){Aa.copy(F.position);qa.multiplyVector3(Aa);l.z=Aa.z}}else l.render=!1;else l.render=!1}this.sortObjects&&e.__webGLObjects.sort(A);G=e.__webGLObjectsImmediate.length;for(h=0;h<
+G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){F.matrixAutoUpdate&&F.globalMatrix.flattenToArray(F._objectMatrixArray);H(F,n);x(l)}}K(THREE.NormalBlending);for(h=0;h<s;h++){l=e.__webGLObjects[h];if(l.render){F=l.object;I=l.buffer;r=l.opaque;k(F);for(l=0;l<r.count;l++){q=r.list[l];o(q.depth_test);g(n,S,y,q,I,F)}}}for(h=0;h<G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.opaque;k(F);for(l=0;l<r.count;l++){q=r.list[l];o(q.depth_test);v=f(n,S,y,q,F);F.render(function(M){j(M,
+v)})}}}for(h=0;h<s;h++){l=e.__webGLObjects[h];if(l.render){F=l.object;I=l.buffer;r=l.transparent;k(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);o(q.depth_test);g(n,S,y,q,I,F)}}}for(h=0;h<G;h++){l=e.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.transparent;k(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);o(q.depth_test);v=f(n,S,y,q,F);F.render(function(M){j(M,v)})}}}if(m&&m.min_filter!==THREE.NearestFilter&&m.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,m.__webGLTexture);
+b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(e,n){var m,h,l;if(!e.__webGLObjects){e.__webGLObjects=[];e.__webGLObjectsMap={};e.__webGLObjectsImmediate=[]}m=0;for(h=e.objects.length;m<h;m++){l=e.objects[m];var v=e,r=n,q=void 0,s=void 0,G=void 0,F=void 0;s=l.geometry;if(v.__webGLObjectsMap[l.id]==undefined){v.__webGLObjectsMap[l.id]={};l._modelViewMatrix=new THREE.Matrix4;l._normalMatrixArray=new Float32Array(9);l._modelViewMatrixArray=new Float32Array(16);
+l._objectMatrixArray=new Float32Array(16);l.globalMatrix.flattenToArray(l._objectMatrixArray)}F=v.__webGLObjectsMap[l.id];objlist=v.__webGLObjects;if(l instanceof THREE.Mesh){for(q in s.geometryChunks){G=s.geometryChunks[q];if(!G.__webGLVertexBuffer){r=G;r.__webGLVertexBuffer=b.createBuffer();r.__webGLNormalBuffer=b.createBuffer();r.__webGLTangentBuffer=b.createBuffer();r.__webGLColorBuffer=b.createBuffer();r.__webGLUVBuffer=b.createBuffer();r.__webGLUV2Buffer=b.createBuffer();r.__webGLSkinVertexABuffer=
+b.createBuffer();r.__webGLSkinVertexBBuffer=b.createBuffer();r.__webGLSkinIndicesBuffer=b.createBuffer();r.__webGLSkinWeightsBuffer=b.createBuffer();r.__webGLFaceBuffer=b.createBuffer();r.__webGLLineBuffer=b.createBuffer();r=G;var I=l,S=void 0,y=void 0,M=0,ea=v=0,Z=I.geometry.faces,Q=r.faces;S=0;for(y=Q.length;S<y;S++){fi=Q[S];face=Z[fi];if(face instanceof THREE.Face3){M+=3;v+=1;ea+=3}else if(face instanceof THREE.Face4){M+=4;v+=2;ea+=4}}r.__vertexArray=new Float32Array(M*3);r.__normalArray=new Float32Array(M*
+3);r.__tangentArray=new Float32Array(M*4);r.__colorArray=new Float32Array(M*3);r.__uvArray=new Float32Array(M*2);r.__uv2Array=new Float32Array(M*2);r.__skinVertexAArray=new Float32Array(M*4);r.__skinVertexBArray=new Float32Array(M*4);r.__skinIndexArray=new Float32Array(M*4);r.__skinWeightArray=new Float32Array(M*4);r.__faceArray=new Uint16Array(v*3);r.__lineArray=new Uint16Array(ea*2);y=S=r;M=void 0;Z=void 0;var O=void 0,N=void 0;O=void 0;Q=!1;M=0;for(Z=I.materials.length;M<Z;M++){O=I.materials[M];
+if(O instanceof THREE.MeshFaceMaterial){O=0;for(N=y.materials.length;O<N;O++)if(y.materials[O]&&y.materials[O].shading!=undefined&&y.materials[O].shading==THREE.SmoothShading){Q=!0;break}}else if(O&&O.shading!=undefined&&O.shading==THREE.SmoothShading){Q=!0;break}if(Q)break}S.__needsSmoothNormals=Q;r.__webGLFaceCount=v*3;r.__webGLLineCount=ea*2;s.__dirtyVertices=!0;s.__dirtyElements=!0;s.__dirtyUvs=!0;s.__dirtyNormals=!0;s.__dirtyTangents=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyElements||
+s.__dirtyUvs||s.__dirtyNormals||s.__dirtyColors||s.__dirtyTangents){r=G;v=b.DYNAMIC_DRAW;ea=void 0;S=void 0;var ra=void 0,u=void 0,ma=void 0,ka=void 0,ua=void 0;ra=void 0;var B=void 0,C=void 0,D=void 0,T=void 0;B=void 0;C=void 0;D=void 0;u=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;u=void 0;ka=void 0;ma=void 0;ua=void 0;var oa=N=O=Q=Z=M=I=y=0,fa=0,p=0,ha=
+r.__vertexArray,Fa=r.__uvArray,Ga=r.__uv2Array,ta=r.__normalArray,U=r.__tangentArray,ia=r.__colorArray,V=r.__skinVertexAArray,W=r.__skinVertexBArray,X=r.__skinIndexArray,Y=r.__skinWeightArray,xa=r.__faceArray,pa=r.__lineArray,Qa=r.__needsSmoothNormals,la=l.geometry,Ja=la.__dirtyVertices,Ka=la.__dirtyElements,Ea=la.__dirtyUvs,La=la.__dirtyNormals,Ma=la.__dirtyTangents,Na=la.__dirtyColors,sa=la.vertices,Ra=r.faces,Sa=la.faces,Ta=la.uvs,Ua=la.uvs2,ya=la.colors,Ba=la.skinVerticesA,Ca=la.skinVerticesB,
+Da=la.skinIndices,za=la.skinWeights;ea=0;for(S=Ra.length;ea<S;ea++){ra=Ra[ea];u=Sa[ra];ua=Ta[ra];ra=Ua[ra];ma=u.vertexNormals;ka=u.normal;if(u instanceof THREE.Face3){if(Ja){B=sa[u.a].position;C=sa[u.b].position;D=sa[u.c].position;ha[I]=B.x;ha[I+1]=B.y;ha[I+2]=B.z;ha[I+3]=C.x;ha[I+4]=C.y;ha[I+5]=C.z;ha[I+6]=D.x;ha[I+7]=D.y;ha[I+8]=D.z;I+=9}if(za.length){B=za[u.a];C=za[u.b];D=za[u.c];Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=
+D.z;Y[p+11]=D.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=B.w;X[p+4]=C.x;X[p+5]=C.y;X[p+6]=C.z;X[p+7]=C.w;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=D.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];V[p]=B.x;V[p+1]=B.y;V[p+2]=B.z;V[p+3]=1;V[p+4]=C.x;V[p+5]=C.y;V[p+6]=C.z;V[p+7]=1;V[p+8]=D.x;V[p+9]=D.y;V[p+10]=D.z;V[p+11]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;p+=12}if(Na&&
+ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];ia[fa]=B.r;ia[fa+1]=B.g;ia[fa+2]=B.b;ia[fa+3]=C.r;ia[fa+4]=C.g;ia[fa+5]=C.b;ia[fa+6]=D.r;ia[fa+7]=D.g;ia[fa+8]=D.b;fa+=9}if(Ma&&la.hasTangents){B=sa[u.a].tangent;C=sa[u.b].tangent;D=sa[u.c].tangent;U[N]=B.x;U[N+1]=B.y;U[N+2]=B.z;U[N+3]=B.w;U[N+4]=C.x;U[N+5]=C.y;U[N+6]=C.z;U[N+7]=C.w;U[N+8]=D.x;U[N+9]=D.y;U[N+10]=D.z;U[N+11]=D.w;N+=12}if(La)if(ma.length==3&&Qa)for(u=0;u<3;u++){ka=ma[u];ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}else for(u=0;u<3;u++){ta[O]=ka.x;
+ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}if(Ea&&ua)for(u=0;u<3;u++){ma=ua[u];Fa[M]=ma.u;Fa[M+1]=ma.v;M+=2}if(Ea&&ra)for(u=0;u<3;u++){ua=ra[u];Ga[Z]=ua.u;Ga[Z+1]=ua.v;Z+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;Q+=3;pa[oa]=y;pa[oa+1]=y+1;pa[oa+2]=y;pa[oa+3]=y+2;pa[oa+4]=y+1;pa[oa+5]=y+2;oa+=6;y+=3}}else if(u instanceof THREE.Face4){if(Ja){B=sa[u.a].position;C=sa[u.b].position;D=sa[u.c].position;T=sa[u.d].position;ha[I]=B.x;ha[I+1]=B.y;ha[I+2]=B.z;ha[I+3]=C.x;ha[I+4]=C.y;ha[I+5]=C.z;ha[I+6]=D.x;ha[I+7]=D.y;ha[I+
+8]=D.z;ha[I+9]=T.x;ha[I+10]=T.y;ha[I+11]=T.z;I+=12}if(za.length){B=za[u.a];C=za[u.b];D=za[u.c];T=za[u.d];Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=D.z;Y[p+11]=D.w;Y[p+12]=T.x;Y[p+13]=T.y;Y[p+14]=T.z;Y[p+15]=T.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];T=Da[u.d];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=B.w;X[p+4]=C.x;X[p+5]=C.y;X[p+6]=C.z;X[p+7]=C.w;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=D.w;X[p+12]=T.x;X[p+13]=T.y;X[p+14]=T.z;X[p+15]=
+T.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];T=Ba[u.d];V[p]=B.x;V[p+1]=B.y;V[p+2]=B.z;V[p+3]=1;V[p+4]=C.x;V[p+5]=C.y;V[p+6]=C.z;V[p+7]=1;V[p+8]=D.x;V[p+9]=D.y;V[p+10]=D.z;V[p+11]=1;V[p+12]=T.x;V[p+13]=T.y;V[p+14]=T.z;V[p+15]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];T=Ca[u.d];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;W[p+12]=T.x;W[p+13]=T.y;W[p+14]=T.z;W[p+15]=1;p+=16}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];T=ya[u.d];ia[fa]=B.r;
+ia[fa+1]=B.g;ia[fa+2]=B.b;ia[fa+3]=C.r;ia[fa+4]=C.g;ia[fa+5]=C.b;ia[fa+6]=D.r;ia[fa+7]=D.g;ia[fa+8]=D.b;ia[fa+9]=T.r;ia[fa+10]=T.g;ia[fa+11]=T.b;fa+=12}if(Ma&&la.hasTangents){B=sa[u.a].tangent;C=sa[u.b].tangent;D=sa[u.c].tangent;u=sa[u.d].tangent;U[N]=B.x;U[N+1]=B.y;U[N+2]=B.z;U[N+3]=B.w;U[N+4]=C.x;U[N+5]=C.y;U[N+6]=C.z;U[N+7]=C.w;U[N+8]=D.x;U[N+9]=D.y;U[N+10]=D.z;U[N+11]=D.w;U[N+12]=u.x;U[N+13]=u.y;U[N+14]=u.z;U[N+15]=u.w;N+=16}if(La)if(ma.length==4&&Qa)for(u=0;u<4;u++){ka=ma[u];ta[O]=ka.x;ta[O+
+1]=ka.y;ta[O+2]=ka.z;O+=3}else for(u=0;u<4;u++){ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}if(Ea&&ua)for(u=0;u<4;u++){ma=ua[u];Fa[M]=ma.u;Fa[M+1]=ma.v;M+=2}if(Ea&&ra)for(u=0;u<4;u++){ua=ra[u];Ga[Z]=ua.u;Ga[Z+1]=ua.v;Z+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;xa[Q+3]=y;xa[Q+4]=y+2;xa[Q+5]=y+3;Q+=6;pa[oa]=y;pa[oa+1]=y+1;pa[oa+2]=y;pa[oa+3]=y+3;pa[oa+4]=y+1;pa[oa+5]=y+2;pa[oa+6]=y+2;pa[oa+7]=y+3;oa+=8;y+=4}}}if(Ja){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,ha,v)}if(Na&&
+ya.length){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,ia,v)}if(La){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,ta,v)}if(Ma&&la.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,U,v)}if(Ea&&M>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Fa,v)}if(Ea&&Z>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Ga,v)}if(Ka){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
+r.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,xa,v);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,pa,v)}if(p>0){b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinVertexABuffer);b.bufferData(b.ARRAY_BUFFER,V,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinVertexBBuffer);b.bufferData(b.ARRAY_BUFFER,W,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinIndicesBuffer);b.bufferData(b.ARRAY_BUFFER,X,v);b.bindBuffer(b.ARRAY_BUFFER,r.__webGLSkinWeightsBuffer);b.bufferData(b.ARRAY_BUFFER,
+Y,v)}}E(objlist,F,q,G,l)}s.__dirtyVertices=!1;s.__dirtyElements=!1;s.__dirtyUvs=!1;s.__dirtyNormals=!1;s.__dirtyTangents=!1;s.__dirtyColors=!1}else if(l instanceof THREE.Ribbon){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=s;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLVertexCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;G=b.DYNAMIC_DRAW;
+y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;Z=M.length;ea=v.length;Q=q.__vertexArray;S=q.__colorArray;O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<Z;y++){I=M[y].position;r=y*3;Q[r]=I.x;Q[r+1]=I.y;Q[r+2]=I.z}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<ea;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,S,G)}}E(objlist,F,0,s,l);s.__dirtyVertices=
+!1;s.__dirtyColors=!1}else if(l instanceof THREE.Line){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=s;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLLineCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;G=b.DYNAMIC_DRAW;y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;Z=M.length;ea=v.length;Q=q.__vertexArray;S=q.__colorArray;
+O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<Z;y++){I=M[y].position;r=y*3;Q[r]=I.x;Q[r+1]=I.y;Q[r+2]=I.z}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<ea;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,S,G)}}E(objlist,F,0,s,l);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(l instanceof THREE.ParticleSystem){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=
+b.createBuffer();q.__webGLColorBuffer=b.createBuffer();q=s;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__sortArray=[];q.__webGLParticleCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}(s.__dirtyVertices||s.__dirtyColors||l.sortParticles)&&c(s,b.DYNAMIC_DRAW,l,r);E(objlist,F,0,s,l);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&l instanceof THREE.MarchingCubes){s=F;if(s[0]==undefined){v.__webGLObjectsImmediate.push({object:l,
+opaque:{list:[],count:0},transparent:{list:[],count:0}});s[0]=1}}}};this.removeObject=function(e,n){var m,h;for(m=e.__webGLObjects.length-1;m>=0;m--){h=e.__webGLObjects[m].object;n==h&&e.__webGLObjects.splice(m,1)}};this.setFaceCulling=function(e,n){if(e){!n||n=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
 0}};
 0}};
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",

+ 29 - 36
examples/misc_sound.html

@@ -29,38 +29,37 @@
 		</style>
 		</style>
 	</head>
 	</head>
 	<body>
 	<body>
-	
+
 		<div id="info">
 		<div id="info">
-			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl 3d sounds example - 
-			music by <a href="http://www.newgrounds.com/audio/listen/358232" target="_blank">larrylarrybb</a> and 
+			<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - webgl 3d sounds example -
+			music by <a href="http://www.newgrounds.com/audio/listen/358232" target="_blank">larrylarrybb</a> and
 			<a href="http://www.newgrounds.com/audio/listen/376737" target="_blank">skullbeatz</a> <br/><br/>
 			<a href="http://www.newgrounds.com/audio/listen/376737" target="_blank">skullbeatz</a> <br/><br/>
-			
+
 			navigate with WASD / arrows / mouse
 			navigate with WASD / arrows / mouse
 		</div>
 		</div>
 
 
 
 
-		<div id="container"></div> 
-		
+		<div id="container"></div>
+
 		<script type="text/javascript" src="../build/Three.js"></script>
 		<script type="text/javascript" src="../build/Three.js"></script>
 
 
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/Detector.js"></script>
-		<script type="text/javascript" src="js/Stats.js"></script>
 
 
 		<script type="text/javascript">
 		<script type="text/javascript">
 
 
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
 
 
-			var container, stats;
+			var container;
 			var camera, scene, renderer, soundRenderer;
 			var camera, scene, renderer, soundRenderer;
 			var light, pointLight;
 			var light, pointLight;
 			var cameraControl;
 			var cameraControl;
 
 
 			var mesh;
 			var mesh;
 			var material_sphere1, material_sphere2;
 			var material_sphere1, material_sphere2;
-			
+
 			var postprocessing = { enabled: true };
 			var postprocessing = { enabled: true };
-			
+
 			init();
 			init();
 			animate();
 			animate();
 
 
@@ -73,7 +72,7 @@
 
 
 				camera = new THREE.QuakeCamera( { fov: 50, aspect: window.innerWidth / window.innerHeight, near: 1, far: 10000,
 				camera = new THREE.QuakeCamera( { fov: 50, aspect: window.innerWidth / window.innerHeight, near: 1, far: 10000,
 												  movement_speed: 1, look_speed: 0.002, nofly: true, look_vertical: false } );
 												  movement_speed: 1, look_speed: 0.002, nofly: true, look_vertical: false } );
-												  
+
 				camera.position.set( 0, 25, 0 );
 				camera.position.set( 0, 25, 0 );
 
 
 				light = new THREE.DirectionalLight( 0xffffff );
 				light = new THREE.DirectionalLight( 0xffffff );
@@ -82,22 +81,22 @@
 				scene.addLight( light );
 				scene.addLight( light );
 
 
 				var sphere = new Sphere( 20, 32, 16 );
 				var sphere = new Sphere( 20, 32, 16 );
-				
+
 				material_sphere1 = new THREE.MeshLambertMaterial( { color: 0xffaa00, shading: THREE.FlatShading } );
 				material_sphere1 = new THREE.MeshLambertMaterial( { color: 0xffaa00, shading: THREE.FlatShading } );
 				material_sphere2 = new THREE.MeshLambertMaterial( { color: 0xff2200, shading: THREE.FlatShading } );
 				material_sphere2 = new THREE.MeshLambertMaterial( { color: 0xff2200, shading: THREE.FlatShading } );
-				
+
 				var cube = new Cube( 5, 40, 5 );
 				var cube = new Cube( 5, 40, 5 );
 				var material_cube = new THREE.MeshLambertMaterial( { color: 0xffff00, shading: THREE.FlatShading } );
 				var material_cube = new THREE.MeshLambertMaterial( { color: 0xffff00, shading: THREE.FlatShading } );
 				material_cube.color.setHSV( 0.1, 0.7, 1 );
 				material_cube.color.setHSV( 0.1, 0.7, 1 );
 
 
 				// sound spheres
 				// sound spheres
-				
+
 				var s = 1;
 				var s = 1;
-				
+
 				var mesh1 = new THREE.Mesh( sphere, material_sphere1 );
 				var mesh1 = new THREE.Mesh( sphere, material_sphere1 );
 				mesh1.position.set( -250, 30, 0 );
 				mesh1.position.set( -250, 30, 0 );
 				mesh1.scale.set( s, s, s );
 				mesh1.scale.set( s, s, s );
-			
+
 				var sound1 = new THREE.Sound3D( [ "sounds/358232_j_s_song.mp3", "sounds/358232_j_s_song.ogg" ] , 275, 20, true );
 				var sound1 = new THREE.Sound3D( [ "sounds/358232_j_s_song.mp3", "sounds/358232_j_s_song.ogg" ] , 275, 20, true );
 				//var sound1 = new THREE.Sound3D( "sounds/358232_j_s_song.ogg", 275, 20, true );
 				//var sound1 = new THREE.Sound3D( "sounds/358232_j_s_song.ogg", 275, 20, true );
 				sound1.play();
 				sound1.play();
@@ -105,17 +104,17 @@
 				var dbg = new THREE.Mesh( cube, material_cube );
 				var dbg = new THREE.Mesh( cube, material_cube );
 				dbg.position.set( 0, -10 ,0 );
 				dbg.position.set( 0, -10 ,0 );
 				mesh1.addChild( dbg );
 				mesh1.addChild( dbg );
-				
+
 				mesh1.addChild( sound1 );
 				mesh1.addChild( sound1 );
 				scene.addObject( mesh1 );
 				scene.addObject( mesh1 );
-				
+
 
 
 				var mesh2 = new THREE.Mesh( sphere, material_sphere2 );
 				var mesh2 = new THREE.Mesh( sphere, material_sphere2 );
 				mesh2.position.set( 250, 30, 0 );
 				mesh2.position.set( 250, 30, 0 );
 				mesh2.scale.set( s, s, s );
 				mesh2.scale.set( s, s, s );
-				
-				var sound2 = new THREE.Sound3D( [ "sounds/376737_Skullbeatz___Bad_Cat_Maste.mp3", "sounds/376737_Skullbeatz___Bad_Cat_Maste.ogg" ], 275, 20, true );				
-				//var sound2 = new THREE.Sound3D( "sounds/376737_Skullbeatz___Bad_Cat_Maste.ogg", 275, 20, true );				
+
+				var sound2 = new THREE.Sound3D( [ "sounds/376737_Skullbeatz___Bad_Cat_Maste.mp3", "sounds/376737_Skullbeatz___Bad_Cat_Maste.ogg" ], 275, 20, true );
+				//var sound2 = new THREE.Sound3D( "sounds/376737_Skullbeatz___Bad_Cat_Maste.ogg", 275, 20, true );
 				sound2.play();
 				sound2.play();
 
 
 				var dbg = new THREE.Mesh( cube, material_cube );
 				var dbg = new THREE.Mesh( cube, material_cube );
@@ -126,11 +125,11 @@
 				scene.addObject( mesh2 );
 				scene.addObject( mesh2 );
 
 
 				// ground
 				// ground
-				
+
 				var material_wireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, wireframe_linewidth: 1 } );
 				var material_wireframe = new THREE.MeshLambertMaterial( { color: 0xffaa00, wireframe: true, wireframe_linewidth: 1 } );
 				material_wireframe.color.setHSV( 0.1, 0.2, 0.25 );
 				material_wireframe.color.setHSV( 0.1, 0.2, 0.25 );
-				
-				
+
+
 				var plane = new Plane( 1000, 1000, 100, 100 );
 				var plane = new Plane( 1000, 1000, 100, 100 );
 				mesh = new THREE.Mesh( plane, material_wireframe );
 				mesh = new THREE.Mesh( plane, material_wireframe );
 				mesh.position.y = 0.1;
 				mesh.position.y = 0.1;
@@ -142,19 +141,14 @@
 				renderer.setSize( window.innerWidth, window.innerHeight );
 				renderer.setSize( window.innerWidth, window.innerHeight );
 
 
 				soundRenderer = new THREE.SoundRenderer();
 				soundRenderer = new THREE.SoundRenderer();
-				
+
 				container.innerHTML = "";
 				container.innerHTML = "";
 				container.appendChild( renderer.domElement );
 				container.appendChild( renderer.domElement );
 				container.appendChild( soundRenderer.domElement );
 				container.appendChild( soundRenderer.domElement );
 
 
-				stats = new Stats();
-				stats.domElement.style.position = 'absolute';
-				stats.domElement.style.top = '0px';
-				//container.appendChild( stats.domElement );				
-				
 				initPostprocessing();
 				initPostprocessing();
 				renderer.autoClear = false;
 				renderer.autoClear = false;
-				
+
 			}
 			}
 
 
 
 
@@ -215,18 +209,17 @@
 				requestAnimationFrame( animate );
 				requestAnimationFrame( animate );
 
 
 				render();
 				render();
-				stats.update();
 
 
 			}
 			}
 
 
-			
+
 			function render() {
 			function render() {
 
 
 				var time = new Date().getTime() * 0.005;
 				var time = new Date().getTime() * 0.005;
-				
+
 				material_sphere1.color.setHSV( 0.0, 0.3 + 0.7 * ( 1 + Math.cos(time) ) / 2, 1 );
 				material_sphere1.color.setHSV( 0.0, 0.3 + 0.7 * ( 1 + Math.cos(time) ) / 2, 1 );
-				material_sphere2.color.setHSV( 0.1, 0.3 + 0.7 * ( 1 + Math.sin(time) ) / 2, 1 );	
-				
+				material_sphere2.color.setHSV( 0.1, 0.3 + 0.7 * ( 1 + Math.sin(time) ) / 2, 1 );
+
 				if ( postprocessing.enabled ) {
 				if ( postprocessing.enabled ) {
 
 
 					renderer.clear();
 					renderer.clear();

+ 10 - 11
src/core/Geometry.js

@@ -8,13 +8,13 @@
 THREE.Geometry = function () {
 THREE.Geometry = function () {
 
 
 	this.id = "Geometry" + THREE.GeometryIdCounter++;
 	this.id = "Geometry" + THREE.GeometryIdCounter++;
-	
+
 	this.vertices = [];
 	this.vertices = [];
 	this.faces = [];
 	this.faces = [];
 	this.uvs = [];
 	this.uvs = [];
 	this.uvs2 = [];
 	this.uvs2 = [];
 	this.colors = [];
 	this.colors = [];
-	
+
 	this.skinWeights = [];
 	this.skinWeights = [];
 	this.skinIndices = [];
 	this.skinIndices = [];
 	//this.skinVerticesA = [];
 	//this.skinVerticesA = [];
@@ -127,18 +127,18 @@ THREE.Geometry.prototype = {
 
 
 		// create internal buffers for reuse when calling this method repeatedly
 		// create internal buffers for reuse when calling this method repeatedly
 		// (otherwise memory allocation / deallocation every frame is big resource hog)
 		// (otherwise memory allocation / deallocation every frame is big resource hog)
-		
+
 		if ( this.__tmpVertices == undefined ) {
 		if ( this.__tmpVertices == undefined ) {
-			
+
 			this.__tmpVertices = new Array( this.vertices.length );
 			this.__tmpVertices = new Array( this.vertices.length );
 			vertices = this.__tmpVertices;
 			vertices = this.__tmpVertices;
-			
+
 			for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 			for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 
 
 				vertices[ v ] = new THREE.Vector3();
 				vertices[ v ] = new THREE.Vector3();
 
 
 			}
 			}
-			
+
 			for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 			for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 
 				face = this.faces[ f ];
 				face = this.faces[ f ];
@@ -154,19 +154,18 @@ THREE.Geometry.prototype = {
 				}
 				}
 
 
 			}
 			}
-			
+
 		} else {
 		} else {
-			
+
 			vertices = this.__tmpVertices;
 			vertices = this.__tmpVertices;
-			
+
 			for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 			for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) {
 
 
 				vertices[ v ].set( 0, 0, 0 );
 				vertices[ v ].set( 0, 0, 0 );
 
 
 			}
 			}
-			
+
 		}
 		}
-		
 
 
 		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 

+ 153 - 152
src/core/Matrix4.js

@@ -10,10 +10,14 @@
 
 
 THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 
 
-	this.n11 = n11 || 1; this.n12 = n12 || 0; this.n13 = n13 || 0; this.n14 = n14 || 0;
-	this.n21 = n21 || 0; this.n22 = n22 || 1; this.n23 = n23 || 0; this.n24 = n24 || 0;
-	this.n31 = n31 || 0; this.n32 = n32 || 0; this.n33 = n33 || 1; this.n34 = n34 || 0;
-	this.n41 = n41 || 0; this.n42 = n42 || 0; this.n43 = n43 || 0; this.n44 = n44 || 1;
+	this.set(
+
+		n11 || 1, n12 || 0, n13 || 0, n14 || 0,
+		n21 || 0, n22 || 1, n23 || 0, n24 || 0,
+		n31 || 0, n32 || 0, n33 || 1, n34 || 0,
+		n41 || 0, n42 || 0, n43 || 0, n44 || 1
+
+	);
 
 
 	this.flat = new Array( 16 );
 	this.flat = new Array( 16 );
 	this.m33 = new THREE.Matrix3();
 	this.m33 = new THREE.Matrix3();
@@ -22,23 +26,27 @@ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33
 
 
 THREE.Matrix4.prototype = {
 THREE.Matrix4.prototype = {
 
 
-	identity: function () {
+	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
 
 
-		this.n11 = 1; this.n12 = 0; this.n13 = 0; this.n14 = 0;
-		this.n21 = 0; this.n22 = 1; this.n23 = 0; this.n24 = 0;
-		this.n31 = 0; this.n32 = 0; this.n33 = 1; this.n34 = 0;
-		this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1;
+		this.n11 = n11; this.n12 = n12; this.n13 = n13; this.n14 = n14;
+		this.n21 = n21; this.n22 = n22; this.n23 = n23; this.n24 = n24;
+		this.n31 = n31; this.n32 = n32; this.n33 = n33; this.n34 = n34;
+		this.n41 = n41; this.n42 = n42; this.n43 = n43; this.n44 = n44;
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {
+	identity: function () {
 
 
-		this.n11 = n11; this.n12 = n12; this.n13 = n13; this.n14 = n14;
-		this.n21 = n21; this.n22 = n22; this.n23 = n23; this.n24 = n24;
-		this.n31 = n31; this.n32 = n32; this.n33 = n33; this.n34 = n34;
-		this.n41 = n41; this.n42 = n42; this.n43 = n43; this.n44 = n44;
+		this.set(
+
+			1, 0, 0, 0,
+			0, 1, 0, 0,
+			0, 0, 1, 0,
+			0, 0, 0, 1
+
+		);
 
 
 		return this;
 		return this;
 
 
@@ -46,10 +54,14 @@ THREE.Matrix4.prototype = {
 
 
 	copy: function ( m ) {
 	copy: function ( m ) {
 
 
-		this.n11 = m.n11; this.n12 = m.n12; this.n13 = m.n13; this.n14 = m.n14;
-		this.n21 = m.n21; this.n22 = m.n22; this.n23 = m.n23; this.n24 = m.n24;
-		this.n31 = m.n31; this.n32 = m.n32; this.n33 = m.n33; this.n34 = m.n34;
-		this.n41 = m.n41; this.n42 = m.n42; this.n43 = m.n43; this.n44 = m.n44;
+		this.set(
+
+			m.n11, m.n12, m.n13, m.n14,
+			m.n21, m.n22, m.n23, m.n24,
+			m.n31, m.n32, m.n33, m.n34,
+			m.n41, m.n42, m.n43, m.n44
+
+		);
 
 
 		return this;
 		return this;
 
 
@@ -133,6 +145,7 @@ THREE.Matrix4.prototype = {
 		b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34,
 		b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34,
 		b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44;
 		b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44;
 
 
+		/*
 		this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
 		this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
 		this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
 		this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
 		this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
 		this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
@@ -152,6 +165,27 @@ THREE.Matrix4.prototype = {
 		this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
 		this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
+		*/
+
+		this.n11 = a11 * b11 + a12 * b21 + a13 * b31;
+		this.n12 = a11 * b12 + a12 * b22 + a13 * b32;
+		this.n13 = a11 * b13 + a12 * b23 + a13 * b33;
+		this.n14 = a11 * b14 + a12 * b24 + a13 * b34 + a14;
+
+		this.n21 = a21 * b11 + a22 * b21 + a23 * b31;
+		this.n22 = a21 * b12 + a22 * b22 + a23 * b32;
+		this.n23 = a21 * b13 + a22 * b23 + a23 * b33;
+		this.n24 = a21 * b14 + a22 * b24 + a23 * b34 + a24;
+
+		this.n31 = a31 * b11 + a32 * b21 + a33 * b31;
+		this.n32 = a31 * b12 + a32 * b22 + a33 * b32;
+		this.n33 = a31 * b13 + a32 * b23 + a33 * b33;
+		this.n34 = a31 * b14 + a32 * b24 + a33 * b34 + a34;
+
+		this.n41 = a41 * b11 + a42 * b21 + a43 * b31;
+		this.n42 = a41 * b12 + a42 * b22 + a43 * b32;
+		this.n43 = a41 * b13 + a42 * b23 + a43 * b33;
+		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44;
 
 
 		return this;
 		return this;
 
 
@@ -189,25 +223,10 @@ THREE.Matrix4.prototype = {
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
 		this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
 
 
-		r[ 0 ] = this.n11;
-		r[ 1 ] = this.n21;
-		r[ 2 ] = this.n31;
-		r[ 3 ] = this.n41;
-
-		r[ 4 ] = this.n12;
-		r[ 5 ] = this.n22;
-		r[ 6 ] = this.n32;
-		r[ 7 ] = this.n42;
-
-		r[ 8 ]  = this.n13;
-		r[ 9 ]  = this.n23;
-		r[ 10 ] = this.n33;
-		r[ 11 ] = this.n43;
-
-		r[ 12 ] = this.n14;
-		r[ 13 ] = this.n24;
-		r[ 14 ] = this.n34;
-		r[ 15 ] = this.n44;
+		r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41;
+		r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42;
+		r[ 8 ]  = this.n13; r[ 9 ]  = this.n23; r[ 10 ] = this.n33; r[ 11 ] = this.n43;
+		r[ 12 ] = this.n14; r[ 13 ] = this.n24; r[ 14 ] = this.n34; r[ 15 ] = this.n44;
 
 
 		return this;
 		return this;
 
 
@@ -224,6 +243,7 @@ THREE.Matrix4.prototype = {
 		mn13 = m.n13, mn23 = m.n23, mn33 = m.n33, mn43 = m.n43,
 		mn13 = m.n13, mn23 = m.n23, mn33 = m.n33, mn43 = m.n43,
 		mn14 = m.n14, mn24 = m.n24, mn34 = m.n34, mn44 = m.n44;
 		mn14 = m.n14, mn24 = m.n24, mn34 = m.n34, mn44 = m.n44;
 
 
+		/*
 		this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31 + n14 * mn41;
 		this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31 + n14 * mn41;
 		this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32 + n14 * mn42;
 		this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32 + n14 * mn42;
 		this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33 + n14 * mn43;
 		this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33 + n14 * mn43;
@@ -243,6 +263,27 @@ THREE.Matrix4.prototype = {
 		this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32 + n44 * mn42;
 		this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32 + n44 * mn42;
 		this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33 + n44 * mn43;
 		this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33 + n44 * mn43;
 		this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44 * mn44;
 		this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44 * mn44;
+		*/
+
+		this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31;
+		this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32;
+		this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33;
+		this.n14 = n11 * mn14 + n12 * mn24 + n13 * mn34 + n14;
+
+		this.n21 = n21 * mn11 + n22 * mn21 + n23 * mn31;
+		this.n22 = n21 * mn12 + n22 * mn22 + n23 * mn32;
+		this.n23 = n21 * mn13 + n22 * mn23 + n23 * mn33;
+		this.n24 = n21 * mn14 + n22 * mn24 + n23 * mn34 + n24;
+
+		this.n31 = n31 * mn11 + n32 * mn21 + n33 * mn31;
+		this.n32 = n31 * mn12 + n32 * mn22 + n33 * mn32;
+		this.n33 = n31 * mn13 + n32 * mn23 + n33 * mn33;
+		this.n34 = n31 * mn14 + n32 * mn24 + n33 * mn34 + n34;
+
+		this.n41 = n41 * mn11 + n42 * mn21 + n43 * mn31;
+		this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32;
+		this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33;
+		this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44;
 
 
 		return this;
 		return this;
 
 
@@ -297,7 +338,8 @@ THREE.Matrix4.prototype = {
 			n13 * n21 * n32 * n44-
 			n13 * n21 * n32 * n44-
 			n11 * n23 * n32 * n44-
 			n11 * n23 * n32 * n44-
 			n12 * n21 * n33 * n44+
 			n12 * n21 * n33 * n44+
-			n11 * n22 * n33 * n44 );
+			n11 * n22 * n33 * n44
+		);
 
 
 	},
 	},
 
 
@@ -335,55 +377,19 @@ THREE.Matrix4.prototype = {
 
 
 	},
 	},
 
 
-	flatten: function() {
-
-		var flat = this.flat;
-
-		flat[ 0 ] = this.n11;
-		flat[ 1 ] = this.n21;
-		flat[ 2 ] = this.n31;
-		flat[ 3 ] = this.n41;
-
-		flat[ 4 ] = this.n12;
-		flat[ 5 ] = this.n22;
-		flat[ 6 ] = this.n32;
-		flat[ 7 ] = this.n42;
-
-		flat[ 8 ]  = this.n13;
-		flat[ 9 ]  = this.n23;
-		flat[ 10 ] = this.n33;
-		flat[ 11 ] = this.n43;
-
-		flat[ 12 ] = this.n14;
-		flat[ 13 ] = this.n24;
-		flat[ 14 ] = this.n34;
-		flat[ 15 ] = this.n44;
+	flatten: function () {
 
 
+		this.flattenToArray( this.flat );
 		return flat;
 		return flat;
 
 
 	},
 	},
 
 
-	flattenToArray: function( flat ) {
-
-		flat[ 0 ] = this.n11;
-		flat[ 1 ] = this.n21;
-		flat[ 2 ] = this.n31;
-		flat[ 3 ] = this.n41;
-
-		flat[ 4 ] = this.n12;
-		flat[ 5 ] = this.n22;
-		flat[ 6 ] = this.n32;
-		flat[ 7 ] = this.n42;
-
-		flat[ 8 ]  = this.n13;
-		flat[ 9 ]  = this.n23;
-		flat[ 10 ] = this.n33;
-		flat[ 11 ] = this.n43;
+	flattenToArray: function ( flat ) {
 
 
-		flat[ 12 ] = this.n14;
-		flat[ 13 ] = this.n24;
-		flat[ 14 ] = this.n34;
-		flat[ 15 ] = this.n44;
+		flat[ 0 ] = this.n11; flat[ 1 ] = this.n21; flat[ 2 ] = this.n31; flat[ 3 ] = this.n41;
+		flat[ 4 ] = this.n12; flat[ 5 ] = this.n22; flat[ 6 ] = this.n32; flat[ 7 ] = this.n42;
+		flat[ 8 ]  = this.n13; flat[ 9 ]  = this.n23; flat[ 10 ] = this.n33; flat[ 11 ] = this.n43;
+		flat[ 12 ] = this.n14; flat[ 13 ] = this.n24; flat[ 14 ] = this.n34; flat[ 15 ] = this.n44;
 
 
 		return flat;
 		return flat;
 
 
@@ -391,7 +397,7 @@ THREE.Matrix4.prototype = {
 
 
 	flattenToArrayOffset: function( flat, offset ) {
 	flattenToArrayOffset: function( flat, offset ) {
 
 
-		flat[ offset ] 	   = this.n11;
+		flat[ offset ] = this.n11;
 		flat[ offset + 1 ] = this.n21;
 		flat[ offset + 1 ] = this.n21;
 		flat[ offset + 2 ] = this.n31;
 		flat[ offset + 2 ] = this.n31;
 		flat[ offset + 3 ] = this.n41;
 		flat[ offset + 3 ] = this.n41;
@@ -417,34 +423,46 @@ THREE.Matrix4.prototype = {
 
 
 	setTranslation: function( x, y, z ) {
 	setTranslation: function( x, y, z ) {
 
 
-		this.set( 1, 0, 0, x,
-				  0, 1, 0, y,
-				  0, 0, 1, z,
-				  0, 0, 0, 1 );
+		this.set(
+
+			1, 0, 0, x,
+			0, 1, 0, y,
+			0, 0, 1, z,
+			0, 0, 0, 1
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	setScale: function( x, y, z ) {
+	setScale: function ( x, y, z ) {
+
+		this.set(
+
+			x, 0, 0, 0,
+			0, y, 0, 0,
+			0, 0, z, 0,
+			0, 0, 0, 1
 
 
-		this.set( x, 0, 0, 0,
-				  0, y, 0, 0,
-				  0, 0, z, 0,
-				  0, 0, 0, 1 );
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	setRotX: function( theta ) {
+	setRotX: function ( theta ) {
 
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
 
-		this.set( 1, 0,  0, 0,
-				  0, c, -s, 0,
-				  0, s,  c, 0,
-				  0, 0,  0, 1 );
+		this.set(
+
+			1, 0,  0, 0,
+			0, c, -s, 0,
+			0, s,  c, 0,
+			0, 0,  0, 1
+
+		);
 
 
 		return this;
 		return this;
 
 
@@ -454,10 +472,14 @@ THREE.Matrix4.prototype = {
 
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
 
-		this.set( c, 0, s, 0,
-				  0, 1, 0, 0,
-				 -s, 0, c, 0,
-				  0, 0, 0, 1 );
+		this.set(
+
+			 c, 0, s, 0,
+			 0, 1, 0, 0,
+			-s, 0, c, 0,
+			 0, 0, 0, 1
+
+		);
 
 
 		return this;
 		return this;
 
 
@@ -467,10 +489,14 @@ THREE.Matrix4.prototype = {
 
 
 		var c = Math.cos( theta ), s = Math.sin( theta );
 		var c = Math.cos( theta ), s = Math.sin( theta );
 
 
-		this.set( c, -s, 0, 0,
-				  s,  c, 0, 0,
-				  0,  0, 1, 0,
-				  0,  0, 0, 1 );
+		this.set(
+
+			c, -s, 0, 0,
+			s,  c, 0, 0,
+			0,  0, 1, 0,
+			0,  0, 0, 1
+
+		);
 
 
 		return this;
 		return this;
 
 
@@ -478,18 +504,22 @@ THREE.Matrix4.prototype = {
 
 
 	setRotAxis: function( axis, angle ) {
 	setRotAxis: function( axis, angle ) {
 
 
-		//Based on http://www.gamedev.net/reference/articles/article1199.asp
+		// Based on http://www.gamedev.net/reference/articles/article1199.asp
 
 
 		var c = Math.cos( angle ),
 		var c = Math.cos( angle ),
-			s = Math.sin( angle ),
-			t = 1 - c,
-			x = axis.x, y = axis.y, z = axis.z,
-			tx = t * x, ty = t * y;
+		s = Math.sin( angle ),
+		t = 1 - c,
+		x = axis.x, y = axis.y, z = axis.z,
+		tx = t * x, ty = t * y;
+
+		this.set(
+
+		 	tx * x + c, tx * y - s * z, tx * z + s * y, 0,
+			tx * y + s * z, ty * y + c, ty * z - s * x, 0,
+			tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
+			0, 0, 0, 1
 
 
-		 this.set( tx * x + c, tx * y - s * z, tx * z + s * y, 0,
-				  tx * y + s * z, ty * y + c, ty * z - s * x, 0,
-				  tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
-				  0, 0, 0, 1 );
+		);
 
 
 		 return this;
 		 return this;
 
 
@@ -530,22 +560,10 @@ THREE.Matrix4.prototype = {
 	setRotationFromQuaternion: function( quat ) {
 	setRotationFromQuaternion: function( quat ) {
 
 
 		var x = quat.x, y = quat.y, z = quat.z, w = quat.w,
 		var x = quat.x, y = quat.y, z = quat.z, w = quat.w,
-
-			x2 = x + x,
-			y2 = y + y,
-			z2 = z + z,
-
-			xx = x * x2,
-			xy = x * y2,
-			xz = x * z2,
-
-			yy = y * y2,
-			yz = y * z2,
-			zz = z * z2,
-
-			wx = w * x2,
-			wy = w * y2,
-			wz = w * z2;
+		x2 = x + x, y2 = y + y, z2 = z + z,
+		xx = x * x2, xy = x * y2, xz = x * z2,
+		yy = y * y2, yz = y * z2, zz = z * z2,
+		wx = w * x2, wy = w * y2, wz = w * z2;
 
 
 		this.n11 = 1 - ( yy + zz );
 		this.n11 = 1 - ( yy + zz );
 		this.n12 = xy - wz;
 		this.n12 = xy - wz;
@@ -561,7 +579,7 @@ THREE.Matrix4.prototype = {
 
 
 	},
 	},
 
 
-	scale: function( vec3 ) {
+	scale : function ( vec3 ) {
 
 
 		var x = vec3.x, y = vec3.y, z = vec3.z;
 		var x = vec3.x, y = vec3.y, z = vec3.z;
 
 
@@ -574,24 +592,7 @@ THREE.Matrix4.prototype = {
 
 
 	},
 	},
 
 
-	extractRotationMatrix: function( m ) {
-
-		m.n11 = this.n11; m.n12 = this.n12; m.n13 = this.n13; m.n14 = 0;
-		m.n21 = this.n21; m.n22 = this.n22; m.n23 = this.n23; m.n24 = 0;
-		m.n31 = this.n31; m.n32 = this.n32; m.n33 = this.n33; m.n34 = 0;
-		m.n41 = 0; m.n42 = 0; m.n43 = 0; m.n44 = 1;
-
-	},
-
-	extractPositionVector: function( v ) {
-
-		v.x = this.n14;
-		v.y = this.n24;
-		v.z = this.n34;
-
-	},
-
-	toString: function() {
+	toString : function() {
 
 
 		return  "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" +
 		return  "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" +
 			"| " + this.n21 + " " + this.n22 + " " + this.n23 + " " + this.n24 + " |\n" +
 			"| " + this.n21 + " " + this.n22 + " " + this.n23 + " " + this.n24 + " |\n" +
@@ -667,9 +668,9 @@ THREE.Matrix4.makeInvert = function ( m1, m2 ) {
 	// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
 	// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
 
 
 	var n11 = m1.n11, n12 = m1.n12, n13 = m1.n13, n14 = m1.n14,
 	var n11 = m1.n11, n12 = m1.n12, n13 = m1.n13, n14 = m1.n14,
-		n21 = m1.n21, n22 = m1.n22, n23 = m1.n23, n24 = m1.n24,
-		n31 = m1.n31, n32 = m1.n32, n33 = m1.n33, n34 = m1.n34,
-		n41 = m1.n41, n42 = m1.n42, n43 = m1.n43, n44 = m1.n44;
+	n21 = m1.n21, n22 = m1.n22, n23 = m1.n23, n24 = m1.n24,
+	n31 = m1.n31, n32 = m1.n32, n33 = m1.n33, n34 = m1.n34,
+	n41 = m1.n41, n42 = m1.n42, n43 = m1.n43, n44 = m1.n44;
 
 
 	if( m2 === undefined ) m2 = new THREE.Matrix4();
 	if( m2 === undefined ) m2 = new THREE.Matrix4();
 
 
@@ -699,7 +700,7 @@ THREE.Matrix4.makeInvert = function ( m1, m2 ) {
 THREE.Matrix4.makeInvert = function ( m1 ) {
 THREE.Matrix4.makeInvert = function ( m1 ) {
 
 
 	var m2 = new THREE.Matrix4();
 	var m2 = new THREE.Matrix4();
-	
+
 	return THREE.Matrix4.makeInvertTo( m1, m2 );
 	return THREE.Matrix4.makeInvertTo( m1, m2 );
 
 
 };
 };

+ 0 - 1
src/core/Ray.js

@@ -54,7 +54,6 @@ THREE.Ray.prototype = {
 			direction = this.direction.clone();
 			direction = this.direction.clone();
 
 
 			objMatrix = object.globalMatrix;
 			objMatrix = object.globalMatrix;
-			objMatrix.extractRotationMatrix( object.matrixRotation );
 
 
 			a = objMatrix.multiplyVector3( vertices[ face.a ].position.clone() );
 			a = objMatrix.multiplyVector3( vertices[ face.a ].position.clone() );
 			b = objMatrix.multiplyVector3( vertices[ face.b ].position.clone() );
 			b = objMatrix.multiplyVector3( vertices[ face.b ].position.clone() );

+ 142 - 86
src/core/Vector3.js

@@ -7,10 +7,14 @@
 
 
 THREE.Vector3 = function ( x, y, z ) {
 THREE.Vector3 = function ( x, y, z ) {
 
 
-	this.x = x || 0;
-	this.y = y || 0;
-	this.z = z || 0;
-	
+	this.set(
+
+		x || 0,
+		y || 0,
+		z || 0
+
+	);
+
 };
 };
 
 
 
 
@@ -26,224 +30,276 @@ THREE.Vector3.prototype = {
 
 
 	},
 	},
 
 
-	copy: function ( v ) {
+	copy : function ( v ) {
+
+		this.set(
+
+			v.x,
+			v.y,
+			v.z
+
+		);
 
 
-		this.x = v.x;
-		this.y = v.y;
-		this.z = v.z;
-		
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 
 
-	add: function ( a, b ) {
+	add : function ( a, b ) {
 
 
-		this.x = a.x + b.x;
-		this.y = a.y + b.y;
-		this.z = a.z + b.z;
+		this.set(
+
+			a.x + b.x,
+			a.y + b.y,
+			a.z + b.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 
 
-	addSelf: function ( v ) {
+	addSelf : function ( v ) {
+
+		this.set(
 
 
-		this.x += v.x;
-		this.y += v.y;
-		this.z += v.z;
+			this.x + v.x,
+			this.y + v.y,
+			this.z + v.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 
 
-	addScalar: function ( s ) {
+	addScalar : function ( s ) {
+
+		this.set(
+
+			this.x + s,
+			this.y + s,
+			this.z + s
 
 
-		this.x += s;
-		this.y += s;
-		this.z += s;
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 
 
-	sub: function( a, b ) {
+	sub : function ( a, b ) {
 
 
-		this.x = a.x - b.x;
-		this.y = a.y - b.y;
-		this.z = a.z - b.z;
+		this.set(
+
+			a.x - b.x,
+			a.y - b.y,
+			a.z - b.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
-	
 
 
-	subSelf: function ( v ) {
+	subSelf : function ( v ) {
+
+		this.set(
 
 
-		this.x -= v.x;
-		this.y -= v.y;
-		this.z -= v.z;
+			this.x - v.x,
+			this.y - v.y,
+			this.z - v.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
 
 
-	cross: function ( a, b ) {
+	cross : function ( a, b ) {
+
+		this.set(
+
+			a.y * b.z - a.z * b.y,
+			a.z * b.x - a.x * b.z,
+			a.x * b.y - a.y * b.x
 
 
-		this.x = a.y * b.z - a.z * b.y;
-		this.y = a.z * b.x - a.x * b.z;
-		this.z = a.x * b.y - a.y * b.x;
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	crossSelf: function ( v ) {
+	crossSelf : function ( v ) {
 
 
 		var tx = this.x, ty = this.y, tz = this.z;
 		var tx = this.x, ty = this.y, tz = this.z;
 
 
-		this.x = ty * v.z - tz * v.y;
-		this.y = tz * v.x - tx * v.z;
-		this.z = tx * v.y - ty * v.x;
+		this.set(
+
+			ty * v.z - tz * v.y,
+			tz * v.x - tx * v.z,
+			tx * v.y - ty * v.x
+
+		);
+
+		return this;
+
+	},
+
+	multiply : function ( a, b ) {
+
+		this.set(
+
+			a.x * b.x,
+			a.y * b.y,
+			a.z * b.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	multiply: function ( a, b ) {
+	multiplySelf : function ( v ) {
+
+		this.set(
 
 
-		this.x = a.x * b.x;
-		this.y = a.y * b.y;
-		this.z = a.z * b.z;
+			this.x * v.x,
+			this.y * v.y,
+			this.z * v.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	multiplySelf: function ( v ) {
+	multiplyScalar : function ( s ) {
+
+		this.set(
+
+			this.x * s,
+			this.y * s,
+			this.z * s
 
 
-		this.x *= v.x;
-		this.y *= v.y;
-		this.z *= v.z;
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	multiplyScalar: function ( s ) {
+	divideSelf : function ( v ) {
 
 
-		this.x *= s;
-		this.y *= s;
-		this.z *= s;
+		this.set(
+
+			this.x / v.x,
+			this.y / v.y,
+			this.z / v.z
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	divideSelf: function ( v ) {
+	divideScalar : function ( s ) {
+
+		this.set(
 
 
-		this.x /= v.x;
-		this.y /= v.y;
-		this.z /= v.z;
+			this.x / s,
+			this.y / s,
+			this.z / s
+
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	divideScalar: function ( s ) {
+	negate : function () {
+
+		this.set(
+
+			- this.x,
+			- this.y,
+			- this.z
 
 
-		this.x /= s;
-		this.y /= s;
-		this.z /= s;
+		);
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	dot: function ( v ) {
+	dot : function ( v ) {
 
 
 		return this.x * v.x + this.y * v.y + this.z * v.z;
 		return this.x * v.x + this.y * v.y + this.z * v.z;
 
 
 	},
 	},
 
 
-	distanceTo: function ( v ) {
+	distanceTo : function ( v ) {
 
 
-		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
-		return Math.sqrt( dx * dx + dy * dy + dz * dz );
+		return Math.sqrt( this.distanceToSquared( v ) );
 
 
 	},
 	},
 
 
-	distanceToSquared: function ( v ) {
+	distanceToSquared : function ( v ) {
 
 
 		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
 		var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;
 		return dx * dx + dy * dy + dz * dz;
 		return dx * dx + dy * dy + dz * dz;
 
 
 	},
 	},
 
 
-	length: function () {
+	length : function () {
 
 
-		return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+		return Math.sqrt( this.lengthSq() );
 
 
 	},
 	},
 
 
-	lengthSq: function () {
+	lengthSq : function () {
 
 
 		return this.x * this.x + this.y * this.y + this.z * this.z;
 		return this.x * this.x + this.y * this.y + this.z * this.z;
 
 
 	},
 	},
 
 
-	lengthManhattan: function () {
+	lengthManhattan : function () {
 
 
 		return this.x + this.y + this.z;
 		return this.x + this.y + this.z;
 
 
 	},
 	},
 
 
+	normalize : function () {
 
 
-	negate: function () {
-
-		this.x = - this.x;
-		this.y = - this.y;
-		this.z = - this.z;
-
-		return this;
-
-	},
-
-	normalize: function () {
-
-		var length = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );
+		var l = this.length();
 
 
-		length > 0 ? this.multiplyScalar( 1 / length ) : this.set( 0, 0, 0 );
+		l > 0 ? this.multiplyScalar( 1 / l ) : this.set( 0, 0, 0 );
 
 
 		return this;
 		return this;
 
 
 	},
 	},
 
 
-	setLength: function( len ) {
+	setLength : function( len ) {
 
 
 		return this.normalize().multiplyScalar( len );
 		return this.normalize().multiplyScalar( len );
 
 
 	},
 	},
 
 
-	isZero: function () {
+	isZero : function () {
 
 
 		var almostZero = 0.0001;
 		var almostZero = 0.0001;
-		
 		return ( Math.abs( this.x ) < almostZero ) && ( Math.abs( this.y ) < almostZero ) && ( Math.abs( this.z ) < almostZero );
 		return ( Math.abs( this.x ) < almostZero ) && ( Math.abs( this.y ) < almostZero ) && ( Math.abs( this.z ) < almostZero );
 
 
 	},
 	},
 
 
-	clone: function () {
+	clone : function () {
 
 
 		return new THREE.Vector3( this.x, this.y, this.z );
 		return new THREE.Vector3( this.x, this.y, this.z );
 
 
 	},
 	},
 
 
-	toString: function () {
+	toString : function () {
 
 
 		return 'THREE.Vector3 ( ' + this.x + ', ' + this.y + ', ' + this.z + ' )';
 		return 'THREE.Vector3 ( ' + this.x + ', ' + this.y + ', ' + this.z + ' )';
 
 

+ 15 - 15
src/objects/Mesh.js

@@ -7,31 +7,31 @@
 THREE.Mesh = function( geometry, materials ) {
 THREE.Mesh = function( geometry, materials ) {
 
 
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
-	
-	this.geometry     = geometry;
-	this.materials    = materials && materials.length ? materials : [ materials ];
-	
+
+	this.geometry = geometry;
+	this.materials = materials && materials.length ? materials : [ materials ];
+
 	this.flipSided = false;
 	this.flipSided = false;
 	this.doubleSided = false;
 	this.doubleSided = false;
 
 
 	this.overdraw = false; // TODO: Move to material?
 	this.overdraw = false; // TODO: Move to material?
-	
+
 	// calc bound radius
 	// calc bound radius
-	
-	if( this.geometry ) {
-		
-		if( !this.geometry.boundingSphere )
+
+	if ( this.geometry ) {
+
+		if( !this.geometry.boundingSphere ) {
+
 			 this.geometry.computeBoundingSphere();
 			 this.geometry.computeBoundingSphere();
-	
+
+		}
+
 		this.boundRadius = geometry.boundingSphere.radius;
 		this.boundRadius = geometry.boundingSphere.radius;
 
 
 	}
 	}
 
 
 }
 }
 
 
-THREE.Mesh.prototype             = new THREE.Object3D();
+THREE.Mesh.prototype = new THREE.Object3D();
 THREE.Mesh.prototype.constructor = THREE.Mesh;
 THREE.Mesh.prototype.constructor = THREE.Mesh;
-THREE.Mesh.prototype.supr        = THREE.Object3D.prototype;
-
-
-
+THREE.Mesh.prototype.supr = THREE.Object3D.prototype;

+ 90 - 100
src/objects/Sound3D.js

@@ -2,49 +2,52 @@
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-THREE.Sound3D = function( sources, radius, volume, loop ) {
-	
+THREE.Sound3D = function ( sources, radius, volume, loop ) {
+
 	THREE.Object3D.call( this );
 	THREE.Object3D.call( this );
-	
-	// flags
-	
-	this.isLoaded     = false;
-	this.isAddedToDOM = false;
-	this.isPlaying    = false;
-	this.duration     = -1;
-	this.radius       = radius !== undefined ? Math.abs( radius ) : 100;
-	this.volume       = Math.min( 1, Math.max( 0, volume !== undefined ? volume : 1 ) );
 
 
-	
-	// dom
+	this.isLoaded = false;
+	this.isAddedToDOM = false;
+	this.isPlaying = false;
+	this.duration = -1;
+	this.radius = radius !== undefined ? Math.abs( radius ) : 100;
+	this.volume = Math.min( 1, Math.max( 0, volume !== undefined ? volume : 1 ) );
 
 
-	this.domElement        = document.createElement( "audio" );
+	this.domElement = document.createElement( 'audio' );
 	this.domElement.volume = 0;
 	this.domElement.volume = 0;
-	this.domElement.pan    = 0;
-	this.domElement.loop   = loop !== undefined ? loop : true;
-		
-	
+	this.domElement.pan = 0;
+	this.domElement.loop = loop !== undefined ? loop : true;
+
 	// init sources
 	// init sources
-		
+
 	this.sources = sources instanceof Array ? sources : [ sources ];
 	this.sources = sources instanceof Array ? sources : [ sources ];
-	
-	var element, source, type,
-		s, sl = this.sources.length;
-	
-	for( s = 0; s < sl; s++ ) {
-		
+
+	var element, source, type, s, sl = this.sources.length;
+
+	for ( s = 0; s < sl; s++ ) {
+
 		source = this.sources[ s ];
 		source = this.sources[ s ];
 		source.toLowerCase();
 		source.toLowerCase();
-		
-			 if( source.indexOf( ".mp3" ) !== -1 ) type = "audio/mpeg";	
-		else if( source.indexOf( ".ogg" ) !== -1 ) type = "audio/ogg";
-		else if( source.indexOf( ".wav" ) !== -1 ) type = "audio/wav";
-
-		if( this.domElement.canPlayType( type ) ) {
-			
-			element     = document.createElement( "source" );
+
+		if ( source.indexOf( ".mp3" ) !== -1 ) {
+
+			type = "audio/mpeg";
+
+		} else if( source.indexOf( ".ogg" ) !== -1 ) {
+
+			type = "audio/ogg";
+
+		} else if( source.indexOf( ".wav" ) !== -1 ) {
+
+			type = "audio/wav";
+
+		}
+
+		if ( this.domElement.canPlayType( type ) ) {
+
+			element = document.createElement( "source" );
 			element.src = this.sources[ s ];
 			element.src = this.sources[ s ];
-			
+
 			this.domElement.THREESound3D = this;
 			this.domElement.THREESound3D = this;
 			this.domElement.appendChild( element );
 			this.domElement.appendChild( element );
 			this.domElement.addEventListener( "canplay", this.onLoad, true );
 			this.domElement.addEventListener( "canplay", this.onLoad, true );
@@ -59,81 +62,67 @@ THREE.Sound3D = function( sources, radius, volume, loop ) {
 };
 };
 
 
 
 
-THREE.Sound3D.prototype             = new THREE.Object3D();
+THREE.Sound3D.prototype = new THREE.Object3D();
 THREE.Sound3D.prototype.constructor = THREE.Sound3D;
 THREE.Sound3D.prototype.constructor = THREE.Sound3D;
-THREE.Sound3D.prototype.supr        = THREE.Object3D.prototype;
+THREE.Sound3D.prototype.supr = THREE.Object3D.prototype;
 
 
 
 
-/*
- * OnLoad
- */
+THREE.Sound3D.prototype.onLoad = function () {
 
 
-THREE.Sound3D.prototype.onLoad = function( ) {
-	
 	var sound3D = this.THREESound3D;
 	var sound3D = this.THREESound3D;
-	
-	if( sound3D.isLoaded )
+
+	if ( sound3D.isLoaded ) {
+
 		return;
 		return;
-	
+
+	}
+
 	this.removeEventListener( "canplay", this.onLoad, true );
 	this.removeEventListener( "canplay", this.onLoad, true );
-	
+
 	sound3D.isLoaded = true;
 	sound3D.isLoaded = true;
 	sound3D.duration = this.duration;
 	sound3D.duration = this.duration;
-	
-	if( sound3D.isPlaying )
+
+	if ( sound3D.isPlaying ) {
+
 		sound3D.play();
 		sound3D.play();
 
 
+	}
+
 };
 };
 
 
-/*
- * Add To DOM
- */
+THREE.Sound3D.prototype.addToDOM = function ( parent ) {
 
 
-THREE.Sound3D.prototype.addToDOM = function( parent ) {
-	
 	this.isAddedToDOM = true;
 	this.isAddedToDOM = true;
 	parent.appendChild( this.domElement );
 	parent.appendChild( this.domElement );
 
 
 };
 };
 
 
+THREE.Sound3D.prototype.play = function ( startTime ) {
 
 
-/*
- * Play
- */
-
-THREE.Sound3D.prototype.play = function( startTime ) {
-	
 	this.isPlaying = true;
 	this.isPlaying = true;
-	
-	if( this.isLoaded ) {
-		
+
+	if ( this.isLoaded ) {
+
 		this.domElement.play();
 		this.domElement.play();
-		
-		if( startTime )
+
+		if ( startTime ) {
+
 			this.domElement.currentTime = startTime % this.duration;
 			this.domElement.currentTime = startTime % this.duration;
 
 
+		}
+
 	}
 	}
 
 
 };
 };
 
 
+THREE.Sound3D.prototype.pause = function () {
 
 
-/*
- * Pause
- */
-
-THREE.Sound3D.prototype.pause = function() {
-	
 	this.isPlaying = false;
 	this.isPlaying = false;
 	this.domElement.pause();
 	this.domElement.pause();
 
 
 };
 };
 
 
-
-/*
- * Stop
- */
-
-THREE.Sound3D.prototype.stop = function(){
+THREE.Sound3D.prototype.stop = function (){
 
 
 	this.isPlaying = false;
 	this.isPlaying = false;
 	this.domElement.pause();
 	this.domElement.pause();
@@ -141,32 +130,28 @@ THREE.Sound3D.prototype.stop = function(){
 
 
 };
 };
 
 
-/*
- * Calculate Volume and Pan
- */
+THREE.Sound3D.prototype.calculateVolumeAndPan = function ( cameraRelativePosition ) {
+
+	var distance = cameraRelativePosition.length();
+
+	if( distance <= this.radius ) {
 
 
-THREE.Sound3D.prototype.calculateVolumeAndPan = function( cameraRelativePosition ) {
-	
-	var distance = cameraRelativePosition.length();	
-	
-	if( distance <= this.radius )
 		this.domElement.volume = this.volume * ( 1 - distance / this.radius );
 		this.domElement.volume = this.volume * ( 1 - distance / this.radius );
-	else 
-		this.domElement.volume = 0;
 
 
-};
+	} else {
+
+		this.domElement.volume = 0;
 
 
+	}
 
 
-/*
- * Update
- */
+};
 
 
-THREE.Sound3D.prototype.update = function( parentGlobalMatrix, forceUpdate, camera ) {
+THREE.Sound3D.prototype.update = function ( parentGlobalMatrix, forceUpdate, camera ) {
 
 
 	// update local (rotation/scale is not used)
 	// update local (rotation/scale is not used)
 
 
-	if( this.matrixAutoUpdate ) {
-		
+	if ( this.matrixAutoUpdate ) {
+
 		this.localMatrix.setPosition( this.position );
 		this.localMatrix.setPosition( this.position );
 		forceUpdate = true;
 		forceUpdate = true;
 
 
@@ -175,15 +160,20 @@ THREE.Sound3D.prototype.update = function( parentGlobalMatrix, forceUpdate, came
 
 
 	// update global
 	// update global
 
 
-	if( forceUpdate || this.matrixNeedsUpdate ) {
+	if ( forceUpdate || this.matrixNeedsUpdate ) {
+
+		if ( parentGlobalMatrix ) {
 
 
-		if( parentGlobalMatrix )
 			this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
 			this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix );
-		else
+
+		} else {
+
 			this.globalMatrix.copy( this.localMatrix );
 			this.globalMatrix.copy( this.localMatrix );
 
 
+		}
+
 		this.matrixNeedsUpdate = false;
 		this.matrixNeedsUpdate = false;
-		forceUpdate            = true;
+		forceUpdate = true;
 
 
 	}
 	}
 
 
@@ -192,10 +182,10 @@ THREE.Sound3D.prototype.update = function( parentGlobalMatrix, forceUpdate, came
 
 
 	var i, l = this.children.length;
 	var i, l = this.children.length;
 
 
-	for( i = 0; i < l; i++ )
-		this.children[ i ].update( this.globalMatrix, forceUpdate, camera );
-
-};
+	for ( i = 0; i < l; i++ ) {
 
 
+		this.children[ i ].update( this.globalMatrix, forceUpdate, camera );
 
 
+	}
 
 
+};

+ 33 - 28
src/renderers/SoundRenderer.js

@@ -2,46 +2,51 @@
  * @author mikael emtinger / http://gomo.se/
  * @author mikael emtinger / http://gomo.se/
  */
  */
 
 
-
 THREE.SoundRenderer = function() {
 THREE.SoundRenderer = function() {
-	
-	this.volume        = 1;
-	this.domElement    = document.createElement( "div" );
+
+	this.volume = 1;
+	this.domElement = document.createElement( "div" );
 	this.domElement.id = "THREESound";
 	this.domElement.id = "THREESound";
-	
+
 	this.cameraPosition = new THREE.Vector3();
 	this.cameraPosition = new THREE.Vector3();
-	this.soundPosition  = new THREE.Vector3();
-	
-	/*
-	 * Render
-	 */
-	
-	this.render = function( scene, camera, callSceneUpdate ) {
-		
-		if( callSceneUpdate )
+	this.soundPosition = new THREE.Vector3();
+
+	this.render = function ( scene, camera, callSceneUpdate ) {
+
+		if ( callSceneUpdate ) {
+
 			scene.update( undefined, false, camera );
 			scene.update( undefined, false, camera );
-		
-		
-		// loop through all sounds
-		
+
+		}
+
 		var sound;
 		var sound;
 		var sounds = scene.sounds;
 		var sounds = scene.sounds;
 		var s, l = sounds.length;
 		var s, l = sounds.length;
-		
+
 		//camera.globalMatrix.extractPositionVector( this.cameraPosition );
 		//camera.globalMatrix.extractPositionVector( this.cameraPosition );
-		
-		for( s = 0; s < l; s++ ) {
-			
+
+		for ( s = 0; s < l; s++ ) {
+
 			sound = sounds[ s ];
 			sound = sounds[ s ];
-			
-			sound.globalMatrix.extractPositionVector( this.soundPosition );
+
+			this.soundPosition.set(
+
+				sound.globalMatrix.n14,
+				sound.globalMatrix.n24,
+				sound.globalMatrix.n34
+
+			);
+
 			this.soundPosition.subSelf( camera.position );
 			this.soundPosition.subSelf( camera.position );
-			
+
 			if( sound.isPlaying && sound.isLoaded ) {
 			if( sound.isPlaying && sound.isLoaded ) {
-				
-				if( !sound.isAddedToDOM )
+
+				if ( !sound.isAddedToDOM ) {
+
 					sound.addToDOM( this.domElement );
 					sound.addToDOM( this.domElement );
-				
+
+				}
+
 				sound.calculateVolumeAndPan( this.soundPosition );
 				sound.calculateVolumeAndPan( this.soundPosition );
 
 
 			}
 			}

+ 59 - 53
src/scenes/Scene.js

@@ -4,27 +4,20 @@
  */
  */
 
 
 THREE.Scene = function() {
 THREE.Scene = function() {
-	
-	// call super
-	
-	THREE.Object3D.call( this );
 
 
-	// vars
+	THREE.Object3D.call( this );
 
 
 	this.objects = [];
 	this.objects = [];
-	this.lights  = [];
-	this.sounds  = [];
-	this.fog     = null;
+	this.lights = [];
+	this.sounds = [];
+
+	this.fog = null;
 
 
 };
 };
 
 
-THREE.Scene.prototype             = new THREE.Object3D();
+THREE.Scene.prototype = new THREE.Object3D();
 THREE.Scene.prototype.constructor = THREE.Scene;
 THREE.Scene.prototype.constructor = THREE.Scene;
-THREE.Scene.prototype.supr        = THREE.Object3D.prototype;
-
-/*
- * Add Child
- */
+THREE.Scene.prototype.supr = THREE.Object3D.prototype;
 
 
 THREE.Scene.prototype.addChild = function( child ) {
 THREE.Scene.prototype.addChild = function( child ) {
 
 
@@ -34,34 +27,42 @@ THREE.Scene.prototype.addChild = function( child ) {
 }
 }
 
 
 THREE.Scene.prototype.addChildRecurse = function( child ) {
 THREE.Scene.prototype.addChildRecurse = function( child ) {
-	
-	if( child instanceof THREE.Light ) {
-			
-		if( this.lights.indexOf( child ) === -1 )
-			this.lights.push( child );	
-
-	} else if( child instanceof THREE.Sound3D ) {
-		
-		if( this.sounds.indexOf( child ) === -1 )
+
+	if ( child instanceof THREE.Light ) {
+
+		if ( this.lights.indexOf( child ) === -1 ) {
+
+			this.lights.push( child );
+
+		}
+
+	} else if ( child instanceof THREE.Sound3D ) {
+
+		if ( this.sounds.indexOf( child ) === -1 ) {
+
 			this.sounds.push( child );
 			this.sounds.push( child );
 
 
-	} else if( !( child instanceof THREE.Camera || child instanceof THREE.Bone ) ) {
-		
-		if( this.objects.indexOf( child ) === -1 )
+		}
+
+	} else if ( !( child instanceof THREE.Camera || child instanceof THREE.Bone ) ) {
+
+		if ( this.objects.indexOf( child ) === -1 ) {
+
 			this.objects.push( child );
 			this.objects.push( child );
 
 
+		}
+
 	}
 	}
-	
-	for( var c = 0; c < child.children.length; c++ )
+
+	for ( var c = 0; c < child.children.length; c++ ) {
+
 		this.addChildRecurse( child.children[ c ] );
 		this.addChildRecurse( child.children[ c ] );
 
 
+	}
+
 }
 }
 
 
 
 
-/*
- * Remove Child
- */
-
 THREE.Scene.prototype.removeChild = function( child ) {
 THREE.Scene.prototype.removeChild = function( child ) {
 
 
 	this.supr.removeChild.call( this, child );
 	this.supr.removeChild.call( this, child );
@@ -70,43 +71,48 @@ THREE.Scene.prototype.removeChild = function( child ) {
 }
 }
 
 
 THREE.Scene.prototype.removeChildRecurse = function( child ) {
 THREE.Scene.prototype.removeChildRecurse = function( child ) {
-	
-	if( child instanceof THREE.Light ) {
-		
+
+	if ( child instanceof THREE.Light ) {
+
 		var i = this.lights.indexOf( child );
 		var i = this.lights.indexOf( child );
-		
-		if( i !== -1 )
+
+		if ( i !== -1 ) {
+
 			this.lights.splice( i, 1 );
 			this.lights.splice( i, 1 );
 
 
-	} else if( child instanceof THREE.Sound3D ) {
-		
+		}
+
+	} else if ( child instanceof THREE.Sound3D ) {
+
 		var i = this.sounds.indexOf( child );
 		var i = this.sounds.indexOf( child );
-		
-		if( i !== -1 )
+
+		if( i !== -1 ) {
+
 			this.sounds.splice( i, 1 );
 			this.sounds.splice( i, 1 );
 
 
-	} else if( !( child instanceof THREE.Camera ) ) {
-		
+		}
+
+	} else if ( !( child instanceof THREE.Camera ) ) {
+
 		var i = this.objects.indexOf( child );
 		var i = this.objects.indexOf( child );
-		
-		if( i !== -1 )
+
+		if( i !== -1 ) {
+
 			this.objects.splice( i, 1 );
 			this.objects.splice( i, 1 );
 
 
+		}
+
 	}
 	}
-	
-	for( var c = 0; c < child.children.length; c++ )
-		this.removeChildRecurse( child.children[ c ] );
 
 
-}
+	for ( var c = 0; c < child.children.length; c++ ) {
 
 
+		this.removeChildRecurse( child.children[ c ] );
 
 
+	}
 
 
-/*
- * Backward Compatibility
- */
+}
 
 
 THREE.Scene.prototype.addObject    = THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.addObject    = THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject = THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeObject = THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.addLight     = THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.addLight     = THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeLight  = THREE.Scene.prototype.removeChild;
 THREE.Scene.prototype.removeLight  = THREE.Scene.prototype.removeChild;
-