浏览代码

inital import for THREE.Text and example

zz85 14 年之前
父节点
当前提交
1286e5171b

文件差异内容过多而无法显示
+ 151 - 151
build/Three.js


+ 2 - 2
build/custom/ThreeCanvas.js

@@ -3,7 +3,7 @@ var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float3
 THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,i,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);i=a*6-f;a=c*(1-b);h=c*(1-b*i);b=c*(1-b*(1-i));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d,
 e,g)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
-this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},clone:function(){return new THREE.Vector2(this.x,this.y)},equals:function(a){return a.x==this.x&&a.y==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=
@@ -49,7 +49,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+e*g+c*i-d*f;this.y=c*a+e*f+d*g-b*i;this.z=d*a+e*i+b*f-c*g;this.w=e*a-b*g-c*f-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*e-i*d,o=
 h*d+i*c-g*e,q=h*e+g*d-f*c;c=-g*c-f*d-i*e;b.x=j*h+c*-g+o*-i-q*-f;b.y=o*h+c*-f+q*-g-j*-i;b.z=q*h+c*-i+j*-f-o*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 2 - 2
build/custom/ThreeDOM.js

@@ -3,7 +3,7 @@ var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float3
 THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,h,f,j,g;if(c==0)d=e=h=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=g;e=c;h=a;break;case 2:d=a;e=c;h=b;break;case 3:d=a;e=g;h=c;break;case 4:d=b;e=a;h=c;break;case 5:d=c;e=a;h=g;break;case 6:case 0:d=c;e=b;h=a}}this.setRGB(d,
 e,h)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
-this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},clone:function(){return new THREE.Vector2(this.x,this.y)},equals:function(a){return a.x==this.x&&a.y==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=
@@ -49,7 +49,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,h=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*h+c*j-d*f;this.y=c*a+e*f+d*h-b*j;this.z=d*a+e*j+b*f-c*h;this.w=e*a-b*h-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,h=this.x,f=this.y,j=this.z,g=this.w,i=g*c+f*e-j*d,l=
 g*d+j*c-h*e,k=g*e+h*d-f*c;c=-h*c-f*d-j*e;b.x=i*g+c*-h+l*-j-k*-f;b.y=l*g+c*-f+k*-h-i*-j;b.z=k*g+c*-j+i*-f-l*-h;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var h=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*h)/f;d=Math.sin(d*h)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,h){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,h,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;

+ 138 - 124
build/custom/ThreeExtras.js

@@ -1,13 +1,13 @@
 // ThreeExtras.js r41/ROME - http://github.com/mrdoob/three.js
-THREE.ColorUtils={adjustHSV:function(a,c,b,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+c,0,1);f.s=THREE.ColorUtils.clamp(f.s+b,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,c){var b=a.r,e=a.g,f=a.b,d=Math.max(Math.max(b,e),f),g=Math.min(Math.min(b,e),f);if(g==d)g=b=0;else{var h=d-g;g=h/d;b=b==d?(e-f)/h:e==d?2+(f-b)/h:4+(b-e)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===undefined&&(c={h:0,s:0,v:0});c.h=b;c.s=g;c.v=d;return c},
+THREE.ColorUtils={adjustHSV:function(a,c,b,e){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.ColorUtils.clamp(g.h+c,0,1);g.s=THREE.ColorUtils.clamp(g.s+b,0,1);g.v=THREE.ColorUtils.clamp(g.v+e,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,e=a.g,g=a.b,f=Math.max(Math.max(b,e),g),h=Math.min(Math.min(b,e),g);if(h==f)h=b=0;else{var j=f-h;h=j/f;b=b==f?(e-g)/j:e==f?2+(g-b)/j:4+(b-e)/j;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===undefined&&(c={h:0,s:0,v:0});c.h=b;c.s=h;c.v=f;return c},
 clamp:function(a,c,b){return a<c?c:a>b?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,f=b?c.geometry:c,d=a.vertices,g=f.vertices,h=a.faces,j=f.faces,l=a.faceVertexUvs[0];f=f.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var k=0,m=g.length;k<m;k++){var p=new THREE.Vertex(g[k].position.clone());b&&c.matrix.multiplyVector3(p.position);d.push(p)}k=0;for(m=j.length;k<m;k++){g=j[k];var n,v,A=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)n=new THREE.Face3(g.a+e,g.b+e,g.c+
-e);else g instanceof THREE.Face4&&(n=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));n.normal.copy(g.normal);b=0;for(d=A.length;b<d;b++){v=A[b];n.vertexNormals.push(v.clone())}n.color.copy(g.color);b=0;for(d=p.length;b<d;b++){v=p[b];n.vertexColors.push(v.clone())}n.materials=g.materials.slice();n.centroid.copy(g.centroid);h.push(n)}k=0;for(m=f.length;k<m;k++){e=f[k];h=[];b=0;for(d=e.length;b<d;b++)h.push(new THREE.UV(e[b].u,e[b].v));l.push(h)}}};
-THREE.ImageUtils={loadTexture:function(a,c,b){var e=new Image,f=new THREE.Texture(e,c);e.onload=function(){f.needsUpdate=!0;b&&b(this)};e.src=a;return f},loadTextureCube:function(a,c,b){var e,f=[],d=new THREE.Texture(f,c);c=f.loadCount=0;for(e=a.length;c<e;++c){f[c]=new Image;f[c].onload=function(){f.loadCount+=1;if(f.loadCount==6)d.needsUpdate=!0;b&&b(this)};f[c].src=a[c]}return d}};
-THREE.SceneUtils={addMesh:function(a,c,b,e,f,d,g,h,j,l){c=new THREE.Mesh(c,l);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=e;c.position.y=f;c.position.z=d;c.rotation.x=g;c.rotation.y=h;c.rotation.z=j;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
+var GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,e=a.vertices.length,g=b?c.geometry:c,f=a.vertices,h=g.vertices,j=a.faces,k=g.faces,m=a.faceVertexUvs[0];g=g.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var l=0,n=h.length;l<n;l++){var p=new THREE.Vertex(h[l].position.clone());b&&c.matrix.multiplyVector3(p.position);f.push(p)}l=0;for(n=k.length;l<n;l++){h=k[l];var o,w,D=h.vertexNormals;p=h.vertexColors;if(h instanceof THREE.Face3)o=new THREE.Face3(h.a+e,h.b+e,h.c+
+e);else h instanceof THREE.Face4&&(o=new THREE.Face4(h.a+e,h.b+e,h.c+e,h.d+e));o.normal.copy(h.normal);b=0;for(f=D.length;b<f;b++){w=D[b];o.vertexNormals.push(w.clone())}o.color.copy(h.color);b=0;for(f=p.length;b<f;b++){w=p[b];o.vertexColors.push(w.clone())}o.materials=h.materials.slice();o.centroid.copy(h.centroid);j.push(o)}l=0;for(n=g.length;l<n;l++){e=g[l];j=[];b=0;for(f=e.length;b<f;b++)j.push(new THREE.UV(e[b].u,e[b].v));m.push(j)}}};
+THREE.ImageUtils={loadTexture:function(a,c,b){var e=new Image,g=new THREE.Texture(e,c);e.onload=function(){g.needsUpdate=!0;b&&b(this)};e.src=a;return g},loadTextureCube:function(a,c,b){var e,g=[],f=new THREE.Texture(g,c);c=g.loadCount=0;for(e=a.length;c<e;++c){g[c]=new Image;g[c].onload=function(){g.loadCount+=1;if(g.loadCount==6)f.needsUpdate=!0;b&&b(this)};g[c].src=a[c]}return f}};
+THREE.SceneUtils={addMesh:function(a,c,b,e,g,f,h,j,k,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=b;c.position.x=e;c.position.y=g;c.position.z=f;c.rotation.x=h;c.rotation.y=j;c.rotation.z=k;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,b){var e=THREE.ShaderUtils.lib.cube;e.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:e.uniforms});c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,1,null,!0),b);a.addObject(c);
 return c},addPanoramaCube:function(a,c,b){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));c=new THREE.Mesh(new THREE.Cube(c,c,c,1,1,e,!0),
-new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var e=c/2;c=new THREE.Plane(c,c);var f=Math.PI,d=Math.PI/2;THREE.SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));THREE.SceneUtils.addMesh(a,c,1,-e,0,0,0,d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));THREE.SceneUtils.addMesh(a,c,1,e,0,0,0,-d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));THREE.SceneUtils.addMesh(a,c,1,0,e,0,d,
-0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));THREE.SceneUtils.addMesh(a,c,1,0,-e,0,-d,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,e,f=a.children.length;for(e=0;e<f;e++){b=a.children[e];c(b);THREE.SceneUtils.traverseHierarchy(b,c)}}};
+new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,b){var e=c/2;c=new THREE.Plane(c,c);var g=Math.PI,f=Math.PI/2;THREE.SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));THREE.SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));THREE.SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));THREE.SceneUtils.addMesh(a,c,1,0,e,0,f,
+0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));THREE.SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(b){b.visible=c})},traverseHierarchy:function(a,c){var b,e,g=a.children.length;for(e=0;e<g;e++){b=a.children[e];c(b);THREE.SceneUtils.traverseHierarchy(b,c)}}};
 THREE.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}},fragmentShader:"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}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
 normal:{uniforms:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",
@@ -17,138 +17,152 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"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}",fragmentShader:"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}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"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}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,e,f,d=2*Math.ceil(a*3)+1;d>25&&(d=25);f=(d-1)*0.5;b=Array(d);for(c=e=0;c<d;++c){b[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=b[c]}for(c=0;c<d;++c)b[c]/=e;return b}};
-THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(f){for(var d=0;d<a.length;d++)a[d].update(f)};b.addToUpdate=function(f){a.indexOf(f)===-1&&a.push(f)};b.removeFromUpdate=function(f){f=a.indexOf(f);f!==-1&&a.splice(f,1)};b.add=function(f){c[f.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+f.name+" already exists in library. Overwriting.");c[f.name]=f;if(f.initialized!==!0){for(var d=0;d<f.hierarchy.length;d++){for(var g=0;g<f.hierarchy[d].keys.length;g++){if(f.hierarchy[d].keys[g].time<
-0)f.hierarchy[d].keys[g].time=0;if(f.hierarchy[d].keys[g].rot!==undefined&&!(f.hierarchy[d].keys[g].rot instanceof THREE.Quaternion)){var h=f.hierarchy[d].keys[g].rot;f.hierarchy[d].keys[g].rot=new THREE.Quaternion(h[0],h[1],h[2],h[3])}}if(f.hierarchy[d].keys[0].morphTargets!==undefined){h={};for(g=0;g<f.hierarchy[d].keys.length;g++)for(var j=0;j<f.hierarchy[d].keys[g].morphTargets.length;j++){var l=f.hierarchy[d].keys[g].morphTargets[j];h[l]=-1}f.hierarchy[d].usedMorphTargets=h;for(g=0;g<f.hierarchy[d].keys.length;g++){var k=
-{};for(l in h){for(j=0;j<f.hierarchy[d].keys[g].morphTargets.length;j++)if(f.hierarchy[d].keys[g].morphTargets[j]===l){k[l]=f.hierarchy[d].keys[g].morphTargetsInfluences[j];break}j===f.hierarchy[d].keys[g].morphTargets.length&&(k[l]=0)}f.hierarchy[d].keys[g].morphTargetsInfluences=k}}for(g=1;g<f.hierarchy[d].keys.length;g++)if(f.hierarchy[d].keys[g].time===f.hierarchy[d].keys[g-1].time){f.hierarchy[d].keys.splice(g,1);g--}for(g=1;g<f.hierarchy[d].keys.length;g++)f.hierarchy[d].keys[g].index=g}g=parseInt(f.length*
-f.fps,10);f.JIT={};f.JIT.hierarchy=[];for(d=0;d<f.hierarchy.length;d++)f.JIT.hierarchy.push(Array(g));f.initialized=!0}};b.get=function(f){if(typeof f==="string")if(c[f])return c[f];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+f);return null}};b.parse=function(f){var d=[];if(f instanceof THREE.SkinnedMesh)for(var g=0;g<f.bones.length;g++)d.push(f.bones[g]);else e(f,d);return d};var e=function(f,d){d.push(f);for(var g=0;g<f.children.length;g++)e(f.children[g],d)};b.LINEAR=
+fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,e,g,f=2*Math.ceil(a*3)+1;f>25&&(f=25);g=(f-1)*0.5;b=Array(f);for(c=e=0;c<f;++c){b[c]=Math.exp(-((c-g)*(c-g))/(2*a*a));e+=b[c]}for(c=0;c<f;++c)b[c]/=e;return b}};
+THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(g){for(var f=0;f<a.length;f++)a[f].update(g)};b.addToUpdate=function(g){a.indexOf(g)===-1&&a.push(g)};b.removeFromUpdate=function(g){g=a.indexOf(g);g!==-1&&a.splice(g,1)};b.add=function(g){c[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");c[g.name]=g;if(g.initialized!==!0){for(var f=0;f<g.hierarchy.length;f++){for(var h=0;h<g.hierarchy[f].keys.length;h++){if(g.hierarchy[f].keys[h].time<
+0)g.hierarchy[f].keys[h].time=0;if(g.hierarchy[f].keys[h].rot!==undefined&&!(g.hierarchy[f].keys[h].rot instanceof THREE.Quaternion)){var j=g.hierarchy[f].keys[h].rot;g.hierarchy[f].keys[h].rot=new THREE.Quaternion(j[0],j[1],j[2],j[3])}}if(g.hierarchy[f].keys[0].morphTargets!==undefined){j={};for(h=0;h<g.hierarchy[f].keys.length;h++)for(var k=0;k<g.hierarchy[f].keys[h].morphTargets.length;k++){var m=g.hierarchy[f].keys[h].morphTargets[k];j[m]=-1}g.hierarchy[f].usedMorphTargets=j;for(h=0;h<g.hierarchy[f].keys.length;h++){var l=
+{};for(m in j){for(k=0;k<g.hierarchy[f].keys[h].morphTargets.length;k++)if(g.hierarchy[f].keys[h].morphTargets[k]===m){l[m]=g.hierarchy[f].keys[h].morphTargetsInfluences[k];break}k===g.hierarchy[f].keys[h].morphTargets.length&&(l[m]=0)}g.hierarchy[f].keys[h].morphTargetsInfluences=l}}for(h=1;h<g.hierarchy[f].keys.length;h++)if(g.hierarchy[f].keys[h].time===g.hierarchy[f].keys[h-1].time){g.hierarchy[f].keys.splice(h,1);h--}for(h=1;h<g.hierarchy[f].keys.length;h++)g.hierarchy[f].keys[h].index=h}h=parseInt(g.length*
+g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(f=0;f<g.hierarchy.length;f++)g.JIT.hierarchy.push(Array(h));g.initialized=!0}};b.get=function(g){if(typeof g==="string")if(c[g])return c[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};b.parse=function(g){var f=[];if(g instanceof THREE.SkinnedMesh)for(var h=0;h<g.bones.length;h++)f.push(g.bones[h]);else e(g,f);return f};var e=function(g,f){f.push(g);for(var h=0;h<g.children.length;h++)e(g.children[h],f)};b.LINEAR=
 0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=2;return b}();THREE.Animation=function(a,c,b,e){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=b!==undefined?b:THREE.AnimationHandler.LINEAR;this.JITCompile=e!==undefined?e:!0;this.points=[];this.target=new THREE.Vector3};
-THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,e=this.hierarchy.length,f;for(b=0;b<e;b++){f=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===undefined){f.animationCache={};f.animationCache.prevKey={pos:0,rot:0,scl:0};f.animationCache.nextKey={pos:0,rot:0,scl:0};f.animationCache.originalMatrix=
-f instanceof THREE.Bone?f.skinMatrix:f.matrix}var d=f.animationCache.prevKey;f=f.animationCache.nextKey;d.pos=this.data.hierarchy[b].keys[0];d.rot=this.data.hierarchy[b].keys[0];d.scl=this.data.hierarchy[b].keys[0];f.pos=this.getNextKeyWith("pos",b,1);f.rot=this.getNextKeyWith("rot",b,1);f.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
+THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==undefined?a:!0;this.currentTime=c!==undefined?c:0;var b,e=this.hierarchy.length,g;for(b=0;b<e;b++){g=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===undefined){g.animationCache={};g.animationCache.prevKey={pos:0,rot:0,scl:0};g.animationCache.nextKey={pos:0,rot:0,scl:0};g.animationCache.originalMatrix=
+g instanceof THREE.Bone?g.skinMatrix:g.matrix}var f=g.animationCache.prevKey;g=g.animationCache.nextKey;f.pos=this.data.hierarchy[b].keys[0];f.rot=this.data.hierarchy[b].keys[0];f.scl=this.data.hierarchy[b].keys[0];g.pos=this.getNextKeyWith("pos",b,1);g.rot=this.getNextKeyWith("rot",b,1);g.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==undefined){if(this.hierarchy[a]instanceof THREE.Bone)this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix;else this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix;delete this.hierarchy[a].animationCache}};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,f,d,g,h,j,l,k=this.data.JIT.hierarchy,m,p;this.currentTime+=a*this.timeScale;p=this.currentTime;m=this.currentTime%=this.data.length;l=parseInt(Math.min(m*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,v=this.hierarchy.length;n<v;n++){a=this.hierarchy[n];j=a.animationCache;if(this.JITCompile&&k[n][l]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=k[n][l];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
-!1}else{a.matrix=k[n][l];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var A=0;A<3;A++){b=c[A];g=j.prevKey[b];h=j.nextKey[b];if(h.time<=p){if(m<p)if(this.loop){g=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(b,n,1);h.time<m;){g=h;h=this.getNextKeyWith(b,n,h.index+1)}}else{this.stop();return}else{do{g=h;h=this.getNextKeyWith(b,n,h.index+1)}while(h.time<
-m)}j.prevKey[b]=g;j.nextKey[b]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(m-g.time)/(h.time-g.time);f=g[b];d=h[b];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+n);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=f[0]+(d[0]-f[0])*e;b.y=f[1]+(d[1]-f[1])*e;b.z=f[2]+(d[2]-f[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",n,g.index-1).pos;this.points[1]=f;this.points[2]=d;this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos;e=e*0.33+0.33;f=this.interpolateCatmullRom(this.points,e);b.x=f[0];b.y=f[1];b.z=f[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(b===
-"rot")THREE.Quaternion.slerp(f,d,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=f[0]+(d[0]-f[0])*e;b.y=f[1]+(d[1]-f[1])*e;b.z=f[2]+(d[2]-f[2])*e}}}}if(this.JITCompile&&k[0][l]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][l]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],f,d,g,h,j,l;f=(a.length-1)*c;d=Math.floor(f);f-=d;b[0]=d==0?d:d-1;b[1]=d;b[2]=d>a.length-2?d:d+1;b[3]=d>a.length-3?d:d+2;d=a[b[0]];h=a[b[1]];j=a[b[2]];l=a[b[3]];b=f*f;g=f*b;e[0]=this.interpolate(d[0],h[0],j[0],l[0],f,b,g);e[1]=this.interpolate(d[1],h[1],j[1],l[1],f,b,g);e[2]=this.interpolate(d[2],h[2],j[2],l[2],f,b,g);return e};
-THREE.Animation.prototype.interpolate=function(a,c,b,e,f,d,g){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*g+(-3*(c-b)-2*a-e)*d+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<e.length-1?b:e.length-1;else b%=e.length;for(;b<e.length;b++)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[0]};
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,e,g,f,h,j,k,m,l=this.data.JIT.hierarchy,n,p;this.currentTime+=a*this.timeScale;p=this.currentTime;n=this.currentTime%=this.data.length;m=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,w=this.hierarchy.length;o<w;o++){a=this.hierarchy[o];k=a.animationCache;if(this.JITCompile&&l[o][m]!==undefined)if(a instanceof THREE.Bone){a.skinMatrix=l[o][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=
+!1}else{a.matrix=l[o][m];a.matrixAutoUpdate=!1;a.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(a instanceof THREE.Bone)a.skinMatrix=a.animationCache.originalMatrix;else a.matrix=a.animationCache.originalMatrix;for(var D=0;D<3;D++){b=c[D];h=k.prevKey[b];j=k.nextKey[b];if(j.time<=p){if(n<p)if(this.loop){h=this.data.hierarchy[o].keys[0];for(j=this.getNextKeyWith(b,o,1);j.time<n;){h=j;j=this.getNextKeyWith(b,o,j.index+1)}}else{this.stop();return}else{do{h=j;j=this.getNextKeyWith(b,o,j.index+1)}while(j.time<
+n)}k.prevKey[b]=h;k.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;e=(n-h.time)/(j.time-h.time);g=h[b];f=j[b];if(e<0||e>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o);e=e<0?0:1}if(b==="pos"){b=a.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){b.x=g[0]+(f[0]-g[0])*e;b.y=g[1]+(f[1]-g[1])*e;b.z=g[2]+(f[2]-g[2])*e}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",o,h.index-1).pos;this.points[1]=g;this.points[2]=f;this.points[3]=this.getNextKeyWith("pos",o,j.index+1).pos;e=e*0.33+0.33;g=this.interpolateCatmullRom(this.points,e);b.x=g[0];b.y=g[1];b.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){e=this.interpolateCatmullRom(this.points,e*1.01);this.target.set(e[0],e[1],e[2]);this.target.subSelf(b);this.target.y=0;this.target.normalize();e=Math.atan2(this.target.x,this.target.z);a.rotation.set(0,e,0)}}}else if(b===
+"rot")THREE.Quaternion.slerp(g,f,a.quaternion,e);else if(b==="scl"){b=a.scale;b.x=g[0]+(f[0]-g[0])*e;b.y=g[1]+(f[1]-g[1])*e;b.z=g[2]+(f[2]-g[2])*e}}}}if(this.JITCompile&&l[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(o=0;o<this.hierarchy.length;o++)l[o][m]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],e=[],g,f,h,j,k,m;g=(a.length-1)*c;f=Math.floor(g);g-=f;b[0]=f==0?f:f-1;b[1]=f;b[2]=f>a.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=g*g;h=g*b;e[0]=this.interpolate(f[0],j[0],k[0],m[0],g,b,h);e[1]=this.interpolate(f[1],j[1],k[1],m[1],g,b,h);e[2]=this.interpolate(f[2],j[2],k[2],m[2],g,b,h);return e};
+THREE.Animation.prototype.interpolate=function(a,c,b,e,g,f,h){a=(b-a)*0.5;e=(e-c)*0.5;return(2*(c-b)+a+e)*h+(-3*(c-b)-2*a-e)*f+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)b=b<e.length-1?b:e.length-1;else b%=e.length;for(;b<e.length;b++)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){var e=this.data.hierarchy[c].keys;for(b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+e.length;b>=0;b--)if(e[b][a]!==undefined)return e[b];return this.data.hierarchy[c].keys[e.length-1]};
-THREE.QuakeCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=
+THREE.QuakeCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=
 a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=
 a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=
 window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!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;break;case 81:this.freeze=!this.freeze}};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(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/
 1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.translateZ(e);this.moveLeft&&this.translateX(-e);this.moveRight&&this.translateX(e);e=this.tdiff*this.lookSpeed;
-this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);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;b=this.target.position;var f=this.position;b.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=f.y+100*Math.cos(this.phi);b.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=
-(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;f=this.position;b.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=f.y+100*Math.cos(this.phi);b.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,
+this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);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;b=this.target.position;var g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=
+(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,
 this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
 THREE.QuakeCamera.prototype.translate=function(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
-THREE.PathCamera=function(a){function c(l,k,m,p){var n={name:m,fps:0.6,length:p,hierarchy:[]},v,A=k.getControlPointsArray(),w=k.getLength(),u=A.length,y=0;v=u-1;k={parent:-1,keys:[]};k.keys[0]={time:0,pos:A[0],rot:[0,0,0,1],scl:[1,1,1]};k.keys[v]={time:p,pos:A[v],rot:[0,0,0,1],scl:[1,1,1]};for(v=1;v<u-1;v++){y=p*w.chunks[v]/w.total;k.keys[v]={time:y,pos:A[v]}}n.hierarchy[0]=k;THREE.AnimationHandler.add(n);return new THREE.Animation(l,m,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(l,k){var m,
-p,n=new THREE.Geometry;for(m=0;m<l.points.length*k;m++){p=m/(l.points.length*k);p=l.getPoint(p);n.vertices[m]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return n}function e(l,k){var m=b(k,10),p=b(k,10),n=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(m,n);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);l.addChild(lineObj);particleObj.scale.set(1,1,1);l.addChild(particleObj);p=new THREE.Sphere(1,
-16,8);n=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<k.points.length;i++){m=new THREE.Mesh(p,n);m.position.copy(k.points[i]);m.updateMatrix();l.addChild(m)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
+THREE.PathCamera=function(a){function c(m,l,n,p){var o={name:n,fps:0.6,length:p,hierarchy:[]},w,D=l.getControlPointsArray(),z=l.getLength(),v=D.length,A=0;w=v-1;l={parent:-1,keys:[]};l.keys[0]={time:0,pos:D[0],rot:[0,0,0,1],scl:[1,1,1]};l.keys[w]={time:p,pos:D[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<v-1;w++){A=p*z.chunks[w]/z.total;l.keys[w]={time:A,pos:D[w]}}o.hierarchy[0]=l;THREE.AnimationHandler.add(o);return new THREE.Animation(m,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(m,l){var n,
+p,o=new THREE.Geometry;for(n=0;n<m.points.length*l;n++){p=n/(m.points.length*l);p=m.getPoint(p);o.vertices[n]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return o}function e(m,l){var n=b(l,10),p=b(l,10),o=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,o);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);m.addChild(lineObj);particleObj.scale.set(1,1,1);m.addChild(particleObj);p=new THREE.Sphere(1,
+16,8);o=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<l.points.length;i++){n=new THREE.Mesh(p,o);n.position.copy(l.points[i]);n.updateMatrix();m.addChild(n)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
-this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,d=Math.PI/180;this.update=function(l,k,m){var p,n;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*d;this.theta=this.lon*d;p=this.phi%f;this.phi=p>=0?p:p+f;p=this.verticalAngleMap.srcRange;n=this.verticalAngleMap.dstRange;
-var v=n[1]-n[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0]-n[0])/v)*v+n[0];p=this.horizontalAngleMap.srcRange;n=this.horizontalAngleMap.dstRange;v=n[1]-n[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-p[0])*(n[1]-n[0])/(p[1]-p[0])+n[0]-n[0])/v)*v+n[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,l,k,m)};this.onMouseMove=
-function(l){this.mouseX=l.clientX-this.windowHalfX;this.mouseY=l.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new THREE.Cube(10,10,20),j=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(j,g);a.position.set(0,10,
-0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(l,k){return function(){k.apply(l,arguments)}}(this,
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,f=Math.PI/180;this.update=function(m,l,n){var p,o;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*f;this.theta=this.lon*f;p=this.phi%g;this.phi=p>=0?p:p+g;p=this.verticalAngleMap.srcRange;o=this.verticalAngleMap.dstRange;
+var w=o[1]-o[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0]-o[0])/w)*w+o[0];p=this.horizontalAngleMap.srcRange;o=this.horizontalAngleMap.dstRange;w=o[1]-o[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-p[0])*(o[1]-o[0])/(p[1]-p[0])+o[0]-o[0])/w)*w+o[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,m,l,n)};this.onMouseMove=
+function(m){this.mouseX=m.clientX-this.windowHalfX;this.mouseY=m.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var h=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.Cube(10,10,20),k=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,h);a.position.set(0,10,
+0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&e(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(m,l){return function(){l.apply(m,arguments)}}(this,
 this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward=
+THREE.FlyCamera=function(a){function c(b,e){return function(){e.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==undefined)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==undefined)this.dragToLook=a.dragToLook;if(a.autoForward!==undefined)this.autoForward=
 a.autoForward;if(a.domElement!==undefined)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=
 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
 this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
-case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),f=e.size[0]/2,d=e.size[1]/2;this.moveState.yawLeft=-(b.clientX-e.offset[0]-f)/f;this.moveState.pitchDown=(b.clientY-
-e.offset[1]-d)/d;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;b=this.tdiff*this.movementSpeed;var e=this.tdiff*
+case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var e=this.getContainerDimensions(),g=e.size[0]/2,f=e.size[1]/2;this.moveState.yawLeft=-(b.clientX-e.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY-
+e.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;b=this.tdiff*this.movementSpeed;var e=this.tdiff*
 this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*e,this.rotationVector.y*e,this.rotationVector.z*e,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||
 this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
 document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this,
 this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
-THREE.RollCamera=function(a,c,b,e){THREE.Camera.call(this,a,c,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,d=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Matrix4,j=!1,l=1,k=0,m=0,p=0,n=0,v=0,A=window.innerWidth/2,w=window.innerHeight/2;this.update=
-function(){var u=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=u;this.delta=(u-this.lastUpdate)/1E3;this.lastUpdate=u;if(this.mouseLook){u=this.delta*this.lookSpeed;this.rotateHorizontally(u*n);this.rotateVertically(u*v)}u=this.delta*this.movementSpeed;this.translateZ(u*(k>0||this.autoForward&&!(k<0)?1:k));this.translateX(u*m);this.translateY(u*p);j&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y<
-this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}g.copy(this.forward);d.set(0,1,0);f.cross(d,g).normalize();d.cross(g,f).normalize();this.matrix.n11=f.x;this.matrix.n12=d.x;this.matrix.n13=g.x;this.matrix.n21=f.y;this.matrix.n22=d.y;this.matrix.n23=g.y;this.matrix.n31=f.z;this.matrix.n32=d.z;this.matrix.n33=g.z;h.identity();h.n11=Math.cos(this.roll);h.n12=-Math.sin(this.roll);h.n21=Math.sin(this.roll);h.n22=Math.cos(this.roll);this.matrix.multiplySelf(h);
-this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(u){this.position.x+=this.matrix.n11*u;this.position.y+=this.matrix.n21*u;this.position.z+=this.matrix.n31*u};this.translateY=function(u){this.position.x+=this.matrix.n12*u;this.position.y+=this.matrix.n22*u;this.position.z+=this.matrix.n32*u};this.translateZ=function(u){this.position.x-=this.matrix.n13*u;this.position.y-=
-this.matrix.n23*u;this.position.z-=this.matrix.n33*u};this.rotateHorizontally=function(u){f.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);f.multiplyScalar(u);this.forward.subSelf(f);this.forward.normalize()};this.rotateVertically=function(u){d.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);d.multiplyScalar(u);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(u){u.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-function(u){n=(u.clientX-A)/window.innerWidth;v=(u.clientY-w)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(u){u.preventDefault();u.stopPropagation();switch(u.button){case 0:k=1;break;case 2:k=-1}},!1);this.domElement.addEventListener("mouseup",function(u){u.preventDefault();u.stopPropagation();switch(u.button){case 0:k=0;break;case 2:k=0}},!1);this.domElement.addEventListener("keydown",function(u){switch(u.keyCode){case 38:case 87:k=1;break;case 37:case 65:m=-1;break;
-case 40:case 83:k=-1;break;case 39:case 68:m=1;break;case 81:j=!0;l=1;break;case 69:j=!0;l=-1;break;case 82:p=1;break;case 70:p=-1}},!1);this.domElement.addEventListener("keyup",function(u){switch(u.keyCode){case 38:case 87:k=0;break;case 37:case 65:m=0;break;case 40:case 83:k=0;break;case 39:case 68:m=0;break;case 81:j=!1;break;case 69:j=!1;break;case 82:p=0;break;case 70:p=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
+THREE.RollCamera=function(a,c,b,e){THREE.Camera.call(this,a,c,b,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.useTarget=!1;this.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,j=new THREE.Matrix4,k=!1,m=1,l=0,n=0,p=0,o=0,w=0,D=window.innerWidth/2,z=window.innerHeight/2;this.update=
+function(){var v=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=v;this.delta=(v-this.lastUpdate)/1E3;this.lastUpdate=v;if(this.mouseLook){v=this.delta*this.lookSpeed;this.rotateHorizontally(v*o);this.rotateVertically(v*w)}v=this.delta*this.movementSpeed;this.translateZ(v*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(v*n);this.translateY(v*p);k&&(this.roll+=this.rollSpeed*this.delta*m);if(this.forward.y>this.constrainVertical[1]){this.forward.y=this.constrainVertical[1];this.forward.normalize()}else if(this.forward.y<
+this.constrainVertical[0]){this.forward.y=this.constrainVertical[0];this.forward.normalize()}h.copy(this.forward);f.set(0,1,0);g.cross(f,h).normalize();f.cross(h,g).normalize();this.matrix.n11=g.x;this.matrix.n12=f.x;this.matrix.n13=h.x;this.matrix.n21=g.y;this.matrix.n22=f.y;this.matrix.n23=h.y;this.matrix.n31=g.z;this.matrix.n32=f.z;this.matrix.n33=h.z;j.identity();j.n11=Math.cos(this.roll);j.n12=-Math.sin(this.roll);j.n21=Math.sin(this.roll);j.n22=Math.cos(this.roll);this.matrix.multiplySelf(j);
+this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(v){this.position.x+=this.matrix.n11*v;this.position.y+=this.matrix.n21*v;this.position.z+=this.matrix.n31*v};this.translateY=function(v){this.position.x+=this.matrix.n12*v;this.position.y+=this.matrix.n22*v;this.position.z+=this.matrix.n32*v};this.translateZ=function(v){this.position.x-=this.matrix.n13*v;this.position.y-=
+this.matrix.n23*v;this.position.z-=this.matrix.n33*v};this.rotateHorizontally=function(v){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(v);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(v){f.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);f.multiplyScalar(v);this.forward.addSelf(f);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(v){v.preventDefault()},!1);this.domElement.addEventListener("mousemove",
+function(v){o=(v.clientX-D)/window.innerWidth;w=(v.clientY-z)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:l=1;break;case 2:l=-1}},!1);this.domElement.addEventListener("mouseup",function(v){v.preventDefault();v.stopPropagation();switch(v.button){case 0:l=0;break;case 2:l=0}},!1);this.domElement.addEventListener("keydown",function(v){switch(v.keyCode){case 38:case 87:l=1;break;case 37:case 65:n=-1;break;
+case 40:case 83:l=-1;break;case 39:case 68:n=1;break;case 81:k=!0;m=1;break;case 69:k=!0;m=-1;break;case 82:p=1;break;case 70:p=-1}},!1);this.domElement.addEventListener("keyup",function(v){switch(v.keyCode){case 38:case 87:l=0;break;case 37:case 65:n=0;break;case 40:case 83:l=0;break;case 39:case 68:n=0;break;case 81:k=!1;break;case 69:k=!1;break;case 82:p=0;break;case 70:p=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
 THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
-THREE.Cube=function(a,c,b,e,f,d,g,h,j){function l(w,u,y,o,z,B,I,K){var J,G,D=e||1,L=f||1,R=z/2,O=B/2,S=k.vertices.length;if(w=="x"&&u=="y"||w=="y"&&u=="x")J="z";else if(w=="x"&&u=="z"||w=="z"&&u=="x"){J="y";L=d||1}else if(w=="z"&&u=="y"||w=="y"&&u=="z"){J="x";D=d||1}var P=D+1,F=L+1;z/=D;var N=B/L;for(G=0;G<F;G++)for(B=0;B<P;B++){var Q=new THREE.Vector3;Q[w]=(B*z-R)*y;Q[u]=(G*N-O)*o;Q[J]=I;k.vertices.push(new THREE.Vertex(Q))}for(G=0;G<L;G++)for(B=0;B<D;B++){k.faces.push(new THREE.Face4(B+P*G+S,B+
-P*(G+1)+S,B+1+P*(G+1)+S,B+1+P*G+S,null,null,K));k.faceVertexUvs[0].push([new THREE.UV(B/D,G/L),new THREE.UV(B/D,(G+1)/L),new THREE.UV((B+1)/D,(G+1)/L),new THREE.UV((B+1)/D,G/L)])}}THREE.Geometry.call(this);var k=this,m=a/2,p=c/2,n=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(j!=undefined)for(var A in j)this.sides[A]!=undefined&&(this.sides[A]=
-j[A]);this.sides.px&&l("z","y",1*h,-1,b,c,-m,this.materials[0]);this.sides.nx&&l("z","y",-1*h,-1,b,c,m,this.materials[1]);this.sides.py&&l("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&l("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&l("x","y",1*h,-1,a,c,n,this.materials[4]);this.sides.nz&&l("x","y",-1*h,-1,a,c,-n,this.materials[5]);(function(){for(var w=[],u=[],y=0,o=k.vertices.length;y<o;y++){for(var z=k.vertices[y],B=!1,I=0,K=w.length;I<K;I++){var J=w[I];if(z.position.x==J.position.x&&
-z.position.y==J.position.y&&z.position.z==J.position.z){u[y]=I;B=!0;break}}if(!B){u[y]=w.length;w.push(new THREE.Vertex(z.position.clone()))}}y=0;for(o=k.faces.length;y<o;y++){z=k.faces[y];z.a=u[z.a];z.b=u[z.b];z.c=u[z.c];z.d=u[z.d]}k.vertices=w})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
-THREE.Cylinder=function(a,c,b,e,f,d){function g(p,n,v){h.vertices.push(new THREE.Vertex(new THREE.Vector3(p,n,v)))}THREE.Geometry.call(this);var h=this,j,l=Math.PI*2,k=e/2;for(j=0;j<a;j++)g(Math.sin(l*j/a)*c,Math.cos(l*j/a)*c,-k);for(j=0;j<a;j++)g(Math.sin(l*j/a)*b,Math.cos(l*j/a)*b,k);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(b>0){g(0,0,-k-(d||0));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(c>0){g(0,0,k+(f||0));
-for(j=a+a/2;j<2*a;j++)h.faces.push(new THREE.Face4(2*a+1,(2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a))}j=0;for(a=this.faces.length;j<a;j++){c=[];b=this.faces[j];f=this.vertices[b.a];d=this.vertices[b.b];k=this.vertices[b.c];var m=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/l,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(d.position.x,d.position.y)/l,0.5+d.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(k.position.x,k.position.y)/l,0.5+k.position.z/
-e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(m.position.x,m.position.y)/l,0.5+m.position.z/e));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
-THREE.Icosahedron=function(a){function c(m,p,n){var v=Math.sqrt(m*m+p*p+n*n);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(m/v,p/v,n/v)))-1}function b(m,p,n,v){v.faces.push(new THREE.Face3(m,p,n))}function e(m,p){var n=f.vertices[m].position,v=f.vertices[p].position;return c((n.x+v.x)/2,(n.y+v.y)/2,(n.z+v.z)/2)}var f=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
-1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in d.faces){var j=e(d.faces[h].a,d.faces[h].b),l=e(d.faces[h].b,d.faces[h].c),k=e(d.faces[h].c,d.faces[h].a);b(d.faces[h].a,j,k,g);b(d.faces[h].b,l,j,g);b(d.faces[h].c,
-k,l,g);b(j,l,k,g)}d.faces=g.faces}f.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
-THREE.Lathe=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;b=[];for(var e=[],f=[],d=[],g=(new THREE.Matrix4).setRotationZ(c),h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));b[h]=a[h].clone();e[h]=this.vertices.length-1}for(var j=0;j<=this.angle+0.001;j+=c){for(h=0;h<b.length;h++)if(j<this.angle){b[h]=g.multiplyVector3(b[h].clone());this.vertices.push(new THREE.Vertex(b[h]));f[h]=this.vertices.length-1}else f=d;j==0&&(d=e);
-for(h=0;h<e.length-1;h++){this.faces.push(new THREE.Face4(f[h],f[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(1-j/this.angle,h/a.length),new THREE.UV(1-j/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,(h+1)/a.length),new THREE.UV(1-(j-c)/this.angle,h/a.length)])}e=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
-THREE.Plane=function(a,c,b,e){THREE.Geometry.call(this);var f,d=a/2,g=c/2;b=b||1;e=e||1;var h=b+1,j=e+1;a/=b;var l=c/e;for(f=0;f<j;f++)for(c=0;c<h;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-d,-(f*l-g),0)));for(f=0;f<e;f++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+h*f,c+h*(f+1),c+1+h*(f+1),c+1+h*f));this.faceVertexUvs[0].push([new THREE.UV(c/b,f/e),new THREE.UV(c/b,(f+1)/e),new THREE.UV((c+1)/b,(f+1)/e),new THREE.UV((c+1)/b,f/e)])}this.computeCentroids();this.computeFaceNormals()};
+THREE.Cube=function(a,c,b,e,g,f,h,j,k){function m(z,v,A,t,C,E,K,N){var L,J,G=e||1,O=g||1,R=C/2,T=E/2,S=l.vertices.length;if(z=="x"&&v=="y"||z=="y"&&v=="x")L="z";else if(z=="x"&&v=="z"||z=="z"&&v=="x"){L="y";O=f||1}else if(z=="z"&&v=="y"||z=="y"&&v=="z"){L="x";G=f||1}var U=G+1,H=O+1;C/=G;var Q=E/O;for(J=0;J<H;J++)for(E=0;E<U;E++){var V=new THREE.Vector3;V[z]=(E*C-R)*A;V[v]=(J*Q-T)*t;V[L]=K;l.vertices.push(new THREE.Vertex(V))}for(J=0;J<O;J++)for(E=0;E<G;E++){l.faces.push(new THREE.Face4(E+U*J+S,E+
+U*(J+1)+S,E+1+U*(J+1)+S,E+1+U*J+S,null,null,N));l.faceVertexUvs[0].push([new THREE.UV(E/G,J/O),new THREE.UV(E/G,(J+1)/O),new THREE.UV((E+1)/G,(J+1)/O),new THREE.UV((E+1)/G,J/O)])}}THREE.Geometry.call(this);var l=this,n=a/2,p=c/2,o=b/2;j=j?-1:1;if(h!==undefined)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var D in k)this.sides[D]!=undefined&&(this.sides[D]=
+k[D]);this.sides.px&&m("z","y",1*j,-1,b,c,-n,this.materials[0]);this.sides.nx&&m("z","y",-1*j,-1,b,c,n,this.materials[1]);this.sides.py&&m("x","z",1*j,1,a,b,p,this.materials[2]);this.sides.ny&&m("x","z",1*j,-1,a,b,-p,this.materials[3]);this.sides.pz&&m("x","y",1*j,-1,a,c,o,this.materials[4]);this.sides.nz&&m("x","y",-1*j,-1,a,c,-o,this.materials[5]);(function(){for(var z=[],v=[],A=0,t=l.vertices.length;A<t;A++){for(var C=l.vertices[A],E=!1,K=0,N=z.length;K<N;K++){var L=z[K];if(C.position.x==L.position.x&&
+C.position.y==L.position.y&&C.position.z==L.position.z){v[A]=K;E=!0;break}}if(!E){v[A]=z.length;z.push(new THREE.Vertex(C.position.clone()))}}A=0;for(t=l.faces.length;A<t;A++){C=l.faces[A];C.a=v[C.a];C.b=v[C.b];C.c=v[C.c];C.d=v[C.d]}l.vertices=z})();this.computeCentroids();this.computeFaceNormals()};THREE.Cube.prototype=new THREE.Geometry;THREE.Cube.prototype.constructor=THREE.Cube;
+THREE.Cylinder=function(a,c,b,e,g,f){function h(p,o,w){j.vertices.push(new THREE.Vertex(new THREE.Vector3(p,o,w)))}THREE.Geometry.call(this);var j=this,k,m=Math.PI*2,l=e/2;for(k=0;k<a;k++)h(Math.sin(m*k/a)*c,Math.cos(m*k/a)*c,-l);for(k=0;k<a;k++)h(Math.sin(m*k/a)*b,Math.cos(m*k/a)*b,l);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b>0){h(0,0,-l-(f||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c>0){h(0,0,l+(g||0));
+for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a))}k=0;for(a=this.faces.length;k<a;k++){c=[];b=this.faces[k];g=this.vertices[b.a];f=this.vertices[b.b];l=this.vertices[b.c];var n=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(g.position.x,g.position.y)/m,0.5+g.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/m,0.5+f.position.z/e));c.push(new THREE.UV(0.5+Math.atan2(l.position.x,l.position.y)/m,0.5+l.position.z/
+e));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/m,0.5+n.position.z/e));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.Cylinder.prototype=new THREE.Geometry;THREE.Cylinder.prototype.constructor=THREE.Cylinder;
+THREE.Icosahedron=function(a){function c(n,p,o){var w=Math.sqrt(n*n+p*p+o*o);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(n/w,p/w,o/w)))-1}function b(n,p,o,w){w.faces.push(new THREE.Face3(n,p,o))}function e(n,p){var o=g.vertices[n].position,w=g.vertices[p].position;return c((o.x+w.x)/2,(o.y+w.y)/2,(o.z+w.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
+1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,f);b(0,5,1,f);b(0,1,7,f);b(0,7,10,f);b(0,10,11,f);b(1,5,9,f);b(5,11,4,f);b(11,10,2,f);b(10,7,6,f);b(7,1,8,f);b(3,9,4,f);b(3,4,2,f);b(3,2,6,f);b(3,6,8,f);b(3,8,9,f);b(4,9,5,f);b(2,4,11,f);b(6,2,10,f);b(8,6,7,f);b(9,8,1,f);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var j in f.faces){var k=e(f.faces[j].a,f.faces[j].b),m=e(f.faces[j].b,f.faces[j].c),l=e(f.faces[j].c,f.faces[j].a);b(f.faces[j].a,k,l,h);b(f.faces[j].b,m,k,h);b(f.faces[j].c,
+l,m,h);b(k,m,l,h)}f.faces=h.faces}g.faces=f.faces;delete f;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Icosahedron.prototype=new THREE.Geometry;THREE.Icosahedron.prototype.constructor=THREE.Icosahedron;
+THREE.Lathe=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;c=this.angle/this.steps;b=[];for(var e=[],g=[],f=[],h=(new THREE.Matrix4).setRotationZ(c),j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));b[j]=a[j].clone();e[j]=this.vertices.length-1}for(var k=0;k<=this.angle+0.0010;k+=c){for(j=0;j<b.length;j++)if(k<this.angle){b[j]=h.multiplyVector3(b[j].clone());this.vertices.push(new THREE.Vertex(b[j]));g[j]=this.vertices.length-1}else g=f;k==0&&(f=e);
+for(j=0;j<e.length-1;j++){this.faces.push(new THREE.Face4(g[j],g[j+1],e[j+1],e[j]));this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,j/a.length)])}e=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Lathe.prototype=new THREE.Geometry;THREE.Lathe.prototype.constructor=THREE.Lathe;
+THREE.Plane=function(a,c,b,e){THREE.Geometry.call(this);var g,f=a/2,h=c/2;b=b||1;e=e||1;var j=b+1,k=e+1;a/=b;var m=c/e;for(g=0;g<k;g++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-f,-(g*m-h),0)));for(g=0;g<e;g++)for(c=0;c<b;c++){this.faces.push(new THREE.Face4(c+j*g,c+j*(g+1),c+1+j*(g+1),c+1+j*g));this.faceVertexUvs[0].push([new THREE.UV(c/b,g/e),new THREE.UV(c/b,(g+1)/e),new THREE.UV((c+1)/b,(g+1)/e),new THREE.UV((c+1)/b,g/e)])}this.computeCentroids();this.computeFaceNormals()};
 THREE.Plane.prototype=new THREE.Geometry;THREE.Plane.prototype.constructor=THREE.Plane;
-THREE.Sphere=function(a,c,b){THREE.Geometry.call(this);var e,f=Math.PI,d=Math.max(3,c||8),g=Math.max(2,b||6);c=[];for(b=0;b<g+1;b++){e=b/g;var h=a*Math.cos(e*f),j=a*Math.sin(e*f),l=[],k=0;for(e=0;e<d;e++){var m=2*e/d,p=j*Math.sin(m*f);m=j*Math.cos(m*f);(b==0||b==g)&&e>0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,h,p)))-1);l.push(k)}c.push(l)}var n,v,A;f=c.length;for(b=0;b<f;b++){d=c[b].length;if(b>0)for(e=0;e<d;e++){l=e==d-1;g=c[b][l?0:e+1];h=c[b][l?d-1:e];j=c[b-1][l?d-1:e];l=c[b-
-1][l?0:e+1];p=b/(f-1);n=(b-1)/(f-1);v=(e+1)/d;m=e/d;k=new THREE.UV(1-v,p);p=new THREE.UV(1-m,p);m=new THREE.UV(1-m,n);var w=new THREE.UV(1-v,n);if(b<c.length-1){n=this.vertices[g].position.clone();v=this.vertices[h].position.clone();A=this.vertices[j].position.clone();n.normalize();v.normalize();A.normalize();this.faces.push(new THREE.Face3(g,h,j,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([k,p,m])}if(b>1){n=this.vertices[g].position.clone();
-v=this.vertices[j].position.clone();A=this.vertices[l].position.clone();n.normalize();v.normalize();A.normalize();this.faces.push(new THREE.Face3(g,j,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(A.x,A.y,A.z)]));this.faceVertexUvs[0].push([k,m,w])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
-THREE.Torus=function(a,c,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
-1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*c+b;f=(this.segmentsT+1)*c+b-1;var d=(this.segmentsT+1)*(c-1)+b-1,g=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,f,d,g));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
-THREE.TorusKnot=function(a,c,b,e,f,d,g){function h(m,p,n,v,A,w){p=n/v*m;n=Math.cos(p);return new THREE.Vector3(A*(2+n)*0.5*Math.cos(m),A*(2+n)*Math.sin(m)*0.5,w*A*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=f||2;this.q=d||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;d=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var j=
-a/this.segmentsR*2*this.p*Math.PI;g=c/this.segmentsT*2*Math.PI;f=h(j,g,this.q,this.p,this.radius,this.heightScale);j=h(j+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=j.x-f.x;b.y=j.y-f.y;b.z=j.z-f.z;e.x=j.x+f.x;e.y=j.y+f.y;e.z=j.z+f.z;d.cross(b,e);e.cross(d,b);d.normalize();e.normalize();j=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=j*e.x+g*d.x;f.y+=j*e.y+g*d.y;f.z+=j*e.z+g*d.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
-0;c<this.segmentsT;++c){e=(a+1)%this.segmentsR;d=(c+1)%this.segmentsT;f=this.grid[a][c];b=this.grid[e][c];e=this.grid[e][d];d=this.grid[a][d];g=new THREE.UV(a/this.segmentsR,c/this.segmentsT);j=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var l=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(f,b,e,d));this.faceVertexUvs[0].push([g,j,l,k])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
-THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
+THREE.Sphere=function(a,c,b){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b<h+1;b++){e=b/h;var j=a*Math.cos(e*g),k=a*Math.sin(e*g),m=[],l=0;for(e=0;e<f;e++){var n=2*e/f,p=k*Math.sin(n*g);n=k*Math.cos(n*g);(b==0||b==h)&&e>0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,p)))-1);m.push(l)}c.push(m)}var o,w,D;g=c.length;for(b=0;b<g;b++){f=c[b].length;if(b>0)for(e=0;e<f;e++){m=e==f-1;h=c[b][m?0:e+1];j=c[b][m?f-1:e];k=c[b-1][m?f-1:e];m=c[b-
+1][m?0:e+1];p=b/(g-1);o=(b-1)/(g-1);w=(e+1)/f;n=e/f;l=new THREE.UV(1-w,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,o);var z=new THREE.UV(1-w,o);if(b<c.length-1){o=this.vertices[h].position.clone();w=this.vertices[j].position.clone();D=this.vertices[k].position.clone();o.normalize();w.normalize();D.normalize();this.faces.push(new THREE.Face3(h,j,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(D.x,D.y,D.z)]));this.faceVertexUvs[0].push([l,p,n])}if(b>1){o=this.vertices[h].position.clone();
+w=this.vertices[k].position.clone();D=this.vertices[m].position.clone();o.normalize();w.normalize();D.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(D.x,D.y,D.z)]));this.faceVertexUvs[0].push([l,n,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere;
+THREE.Torus=function(a,c,b,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=e||6;a=[];for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){e=b/this.segmentsT*2*Math.PI;var g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
+1;b<=this.segmentsT;++b){e=(this.segmentsT+1)*c+b;g=(this.segmentsT+1)*c+b-1;var f=(this.segmentsT+1)*(c-1)+b-1,h=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(e,g,f,h));this.faceVertexUvs[0].push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus;
+THREE.TorusKnot=function(a,c,b,e,g,f,h){function j(n,p,o,w,D,z){p=o/w*n;o=Math.cos(p);return new THREE.Vector3(D*(2+o)*0.5*Math.cos(n),D*(2+o)*Math.sin(n)*0.5,z*D*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=e||8;this.p=g||2;this.q=f||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<this.segmentsT;++c){var k=
+a/this.segmentsR*2*this.p*Math.PI;h=c/this.segmentsT*2*Math.PI;g=j(k,h,this.q,this.p,this.radius,this.heightScale);k=j(k+0.01,h,this.q,this.p,this.radius,this.heightScale);b.x=k.x-g.x;b.y=k.y-g.y;b.z=k.z-g.z;e.x=k.x+g.x;e.y=k.y+g.y;e.z=k.z+g.z;f.cross(b,e);e.cross(f,b);f.normalize();e.normalize();k=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);g.x+=k*e.x+h*f.x;g.y+=k*e.y+h*f.y;g.z+=k*e.z+h*f.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=
+0;c<this.segmentsT;++c){e=(a+1)%this.segmentsR;f=(c+1)%this.segmentsT;g=this.grid[a][c];b=this.grid[e][c];e=this.grid[e][f];f=this.grid[a][f];h=new THREE.UV(a/this.segmentsR,c/this.segmentsT);k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT);var m=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),l=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(g,b,e,f));this.faceVertexUvs[0].push([h,k,m,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};
+THREE.TorusKnot.prototype=new THREE.Geometry;THREE.TorusKnot.prototype.constructor=THREE.TorusKnot;
+THREE.Text=function(a,c,b,e){c||(c=100);b||(b=50);e||(e=4);THREE.Geometry.call(this);ThreeFont.size=c;ThreeFont.divisions=e;a=ThreeFont.drawText(a);vertices=a.points;faces=a.faces;contour=a.contour;a=0;for(var g in vertices){c=vertices[g];this.vertices.push(new THREE.Vertex(new THREE.Vector3(c.x,c.y,0)));a++}for(g in vertices){c=vertices[g];this.vertices.push(new THREE.Vertex(new THREE.Vector3(c.x,c.y,b)))}for(g in faces){b=faces[g];this.faces.push(new THREE.Face3(b[2],b[1],b[0]))}for(g in faces){b=
+faces[g];this.faces.push(new THREE.Face3(b[0]+a,b[1]+a,b[2]+a))}g=contour.length;for(var f;--g>0;){if(f){if(f.equals(contour[g])){f=null;continue}}else f=contour[g];for(b=0;b<vertices.length;b++)if(vertices[b].equals(contour[g]))break;for(c=0;c<vertices.length;c++)if(vertices[c].equals(contour[g-1]))break;this.faces.push(new THREE.Face4(b,c,c+a,b+a))}this.computeCentroids();this.computeFaceNormals()};THREE.Text.prototype=new THREE.Geometry;THREE.Text.prototype.constructor=THREE.Text;
+var ThreeFont={};ThreeFont.faces={};ThreeFont.face="helvetiker";ThreeFont.weight="normal";ThreeFont.style="normal";ThreeFont.size=150;ThreeFont.divisions=10;ThreeFont.getFace=function(){return this.faces[this.face][this.weight][this.style]};
+ThreeFont.loadFace=function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};if(a.strokeFont){this.faces[c].normal=this.faces[c].normal||{};this.faces[c].normal.normal=a;this.faces[c].normal.italic=a;this.faces[c].bold=this.faces[c].normal||{};this.faces[c].bold.normal=a;this.faces[c].bold.italic=a}else{this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a}return a};
+ThreeFont.extractPoints=function(a){if(a.length<3)console.log("not valid polygon");else{var c=[],b,e,g=[],f;for(f in a){b=a[f];c.push(b.x+","+b.y)}b=c[0];b=c.slice(1).indexOf(b);if(b<c.length){b++;e=a.slice(0,b)}for(holes=[];b<c.length;){firstIndex=b+1;b=c[firstIndex];b=c.slice(firstIndex+1).indexOf(b)+firstIndex;if(b<=firstIndex)break;var h=a.slice(firstIndex,b+1);if(THREE.Triangulate.area(h)<0){g.push({shape:e,holes:holes});e=h;holes=[]}else holes.push(h);b++}g.push({shape:e,holes:holes});c=[];
+for(var j in g){b=g[j];e=b.shape;holes=b.holes;for(var k in holes){a=holes[k];h=Number.POSITIVE_INFINITY;var m,l,n;for(n in a){var p=a[n];for(f in e){d=p.distanceTo(e[f]);if(d<h){h=d;m=n;l=f}}}prevShapeVert=l-1>=0?l-1:e.length-1;nextShapeVert=l+1<e.length?l+1:0;prevHoleVert=m-1>=0?m-1:a.length-1;nextHoleVert=m+1<a.length?m+1:0;h=e.slice(0,l);p=e.slice(l);var o=a.slice(m),w=a.slice(0,m);c.push(a[m]);c.push(e[l]);c.push(e[prevShapeVert]);c.push(a[m]);c.push(a[prevHoleVert]);c.push(e[l]);b.shape=h.concat(o).concat(w).concat(p)}}a=
+[];f=[];m=0;for(j in g){b=g[j];e=b.shape;a=a.concat(e);l=THREE.Triangulate(e,!0);for(var D in l){k=l[D];k[0]+=m;k[1]+=m;k[2]+=m}f=f.concat(l);m+=e.length}for(D=0;D<c.length/3;D++){k=[];for(g=0;g<3;g++)for(e=0;e<a.length;e++)if(a[e].equals(c[D*3+g])){k.push(e);break}f.push(k)}return{points:a,faces:f}}};
+ThreeFont.drawText=function(a){pts=[];var c=this.getFace(),b=this.size/c.resolution,e=0,g=String(a).split(""),f=g.length;for(a=0;a<f;a++)e+=this.extractGlyphPoints(g[a],c,b,e);width=e/2;for(var h in pts)pts[h].x-=width;c=this.extractPoints(pts);c.contour=pts;return c};function b2p0(a,c){return(1-a)*(1-a)*c}function b2p1(a,c){return 2*(1-a)*a*c}function b2p2(a,c){return a*a*c}function b2(a,c,b,e){return b2p0(a,c)+b2p1(a,b)+b2p2(a,e)}function b3p0(a,c){var b=1-a;return b*b*b*c}
+function b3p1(a,c){var b=1-a;return 3*b*b*a*c}function b3p2(a,c){return 3*(1-a)*a*a*c}function b3p3(a,c){return a*a*a*c}function b3(a,c,b,e,g){return b3p0(a,c)+b3p1(a,b)+b3p2(a,e)+b3p3(a,g)}
+ThreeFont.extractGlyphPoints=function(a,c,b,e){var g,f,h,j=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(j){if(j.o){c=j._cachedOutline||(j._cachedOutline=j.o.split(" "));h=c.length;for(a=0;a<h;){g=c[a++];switch(g){case "m":x=c[a++]*b+e;y=c[a++]*b;pts.push(new THREE.Vector2(x,y));break;case "l":x=c[a++]*b+e;y=c[a++]*b;pts.push(new THREE.Vector2(x,y));break;case "q":g=c[a++]*b+e;f=c[a++]*b;cpx1=c[a++]*b+e;cpy1=c[a++]*b;var k=pts[pts.length-1];if(k){cpx0=k.x;cpy0=k.y;k=1;for(var m=this.divisions;k<=
+m;k++){var l=k/m,n=b2(l,cpx0,cpx1,g);l=b2(l,cpy0,cpy1,f);pts.push(new THREE.Vector2(n,l))}}break;case "b":g=c[a++]*b+e;f=c[a++]*b;cpx1=c[a++]*b+e;cpy1=c[a++]*-b;cpx2=c[a++]*b+e;cpy2=c[a++]*-b;if(k=pts[pts.length-1]){cpx0=k.x;cpy0=k.y;k=1;for(m=this.divisions;k<=m;k++){l=k/m;n=b3(l,cpx0,cpx1,cpx2,g);l=b3(l,cpy0,cpy1,cpy2,f);pts.push(new THREE.Vector2(n,l))}}}}}return j.ha*b}};
+(function(a){var c=function(b){for(var e=b.length,g=0,f=e-1,h=0;h<e;f=h++)g+=b[f].x*b[h].y-b[h].x*b[f].y;return g*0.5};a.Triangulate=function(b,e){var g=[],f=b.length;if(f<3)return null;var h=[],j=[],k;if(0<c(b))for(k=0;k<f;k++)h[k]=k;else for(k=0;k<f;k++)h[k]=f-1-k;var m=2*f,l;l=0;for(k=f-1;f>2;){if(0>=m--){console.log("Warning, unable to triangulate polygon!");return null}var n=k;f<=n&&(n=0);k=n+1;f<=k&&(k=0);var p=k+1;f<=p&&(p=0);var o;a:{o=b;var w=n,D=k,z=p,v=f,A=h,t=void 0,C=void 0,E=void 0,
+K=void 0,N=void 0,L=void 0,J=void 0,G=void 0,O=void 0;C=o[A[w]].x;E=o[A[w]].y;K=o[A[D]].x;N=o[A[D]].y;L=o[A[z]].x;J=o[A[z]].y;if(1.0E-10>(K-C)*(J-E)-(N-E)*(L-C))o=!1;else{for(t=0;t<v;t++)if(!(t==w||t==D||t==z)){G=o[A[t]].x;O=o[A[t]].y;var R=void 0,T=void 0,S=void 0,U=void 0,H=void 0,Q=void 0,V=void 0,W=void 0,P=void 0,Y=void 0,aa=void 0,ba=void 0;H=void 0;S=void 0;R=void 0;R=L-K;T=J-N;S=C-L;U=E-J;H=K-C;Q=N-E;V=G-C;W=O-E;P=G-K;Y=O-N;aa=G-L;ba=O-J;R=R*Y-T*P;H=H*W-Q*V;S=S*ba-U*aa;if(R>=0&&S>=0&&H>=0){o=
+!1;break a}}o=!0}}if(o){m=h[n];o=h[k];w=h[p];g.push(b[m]);g.push(b[o]);g.push(b[w]);j.push([h[n],h[k],h[p]]);l++;n=k;for(p=k+1;p<f;n++,p++)h[n]=h[p];f--;m=2*f}}if(e)return j;return g};a.Triangulate.area=c;return a})(THREE);window._typeface_js={faces:ThreeFont.faces,loadFace:ThreeFont.loadFace};THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
-this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],b)]},createMaterial:function(a,c){function b(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function e(h,j){var l=new Image;l.onload=function(){if(!b(this.width)||!b(this.height)){var k=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),m=Math.pow(2,Math.round(Math.log(this.height)/
-Math.LN2));h.image.width=k;h.image.height=m;h.image.getContext("2d").drawImage(this,0,0,k,m)}else h.image=this;h.needsUpdate=!0};l.src=j}var f,d,g;f="MeshLambertMaterial";d={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")f="MeshPhongMaterial";else a.shading=="Basic"&&(f="MeshBasicMaterial");if(a.blending)if(a.blending=="Additive")d.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")d.blending=THREE.SubtractiveBlending;else if(a.blending==
-"Multiply")d.blending=THREE.MultiplyBlending;if(a.transparent!==undefined||a.opacity<1)d.transparent=a.transparent;if(a.depthTest!==undefined)d.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")d.vertexColors=THREE.FaceColors;else if(a.vertexColors)d.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&c){g=document.createElement("canvas");d.map=new THREE.Texture(g);d.map.sourceFile=a.mapDiffuse;e(d.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<
-16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;d.color=g;d.opacity=a.transparency}else if(a.DbgColor)d.color=a.DbgColor;if(a.mapLightmap&&c){g=document.createElement("canvas");d.lightMap=new THREE.Texture(g);d.lightMap.sourceFile=a.mapLightmap;e(d.lightMap,c+"/"+a.mapLightmap)}return new THREE[f](d)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
-THREE.JSONLoader.prototype.load=function(a){var c=this,b=a.model,e=a.callback,f=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(d){c.createModel(d.data,e,f);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry,f=a.scale!==undefined?1/a.scale:1;this.init_materials(e,a.materials,b);(function(d){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var g,h,j,l,k,m,p,n,v,A,w,u,y,o,z=a.faces;m=a.vertices;var B=a.normals,I=a.colors,K=0;for(g=0;g<a.uvs.length;g++)a.uvs[g].length&&K++;for(g=0;g<K;g++){e.faceUvs[g]=[];e.faceVertexUvs[g]=[]}l=0;for(k=m.length;l<k;){p=new THREE.Vertex;p.position.x=m[l++]*
-d;p.position.y=m[l++]*d;p.position.z=m[l++]*d;e.vertices.push(p)}l=0;for(k=z.length;l<k;){d=z[l++];m=d&1;j=d&2;g=d&4;h=d&8;n=d&16;p=d&32;A=d&64;d&=128;if(m){w=new THREE.Face4;w.a=z[l++];w.b=z[l++];w.c=z[l++];w.d=z[l++];m=4}else{w=new THREE.Face3;w.a=z[l++];w.b=z[l++];w.c=z[l++];m=3}if(j){j=z[l++];w.materials=e.materials[j]}j=e.faces.length;if(g)for(g=0;g<K;g++){u=a.uvs[g];v=z[l++];o=u[v*2];v=u[v*2+1];e.faceUvs[g][j]=new THREE.UV(o,v)}if(h)for(g=0;g<K;g++){u=a.uvs[g];y=[];for(h=0;h<m;h++){v=z[l++];
-o=u[v*2];v=u[v*2+1];y[h]=new THREE.UV(o,v)}e.faceVertexUvs[g][j]=y}if(n){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.normal=h}if(p)for(g=0;g<m;g++){n=z[l++]*3;h=new THREE.Vector3;h.x=B[n++];h.y=B[n++];h.z=B[n];w.vertexNormals.push(h)}if(A){p=z[l++];p=new THREE.Color(I[p]);w.color=p}if(d)for(g=0;g<m;g++){p=z[l++];p=new THREE.Color(I[p]);w.vertexColors.push(p)}e.faces.push(w)}}})(f);(function(){var d,g,h,j;if(a.skinWeights){d=0;for(g=a.skinWeights.length;d<g;d+=2){h=a.skinWeights[d];
-j=a.skinWeights[d+1];e.skinWeights.push(new THREE.Vector4(h,j,0,0))}}if(a.skinIndices){d=0;for(g=a.skinIndices.length;d<g;d+=2){h=a.skinIndices[d];j=a.skinIndices[d+1];e.skinIndices.push(new THREE.Vector4(h,j,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(d){if(a.morphTargets!==undefined){var g,h,j,l,k,m,p,n,v;g=0;for(h=a.morphTargets.length;g<h;g++){e.morphTargets[g]={};e.morphTargets[g].name=a.morphTargets[g].name;e.morphTargets[g].vertices=[];n=e.morphTargets[g].vertices;v=a.morphTargets[g].vertices;
-j=0;for(l=v.length;j<l;j+=3){k=v[j]*d;m=v[j+1]*d;p=v[j+2]*d;n.push(new THREE.Vertex(new THREE.Vector3(k,m,p)))}}}if(a.morphColors!==undefined){g=0;for(h=a.morphColors.length;g<h;g++){e.morphColors[g]={};e.morphColors[g].name=a.morphColors[g].name;e.morphColors[g].colors=[];l=e.morphColors[g].colors;k=a.morphColors[g].colors;d=0;for(j=k.length;d<j;d+=3){m=new THREE.Color(16755200);m.setRGB(k[d],k[d+1],k[d+2]);l.push(m)}}}})(f);(function(){if(a.edges!==undefined){var d,g,h;for(d=0;d<a.edges.length;d+=
-2){g=a.edges[d];h=a.edges[d+1];e.edges.push(new THREE.Edge(e.vertices[g],e.vertices[h],g,h))}}})();e.computeFaceNormals();c(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
-THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var d=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,f,e,d)};c.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
-c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,f,d){var g=new XMLHttpRequest,h=e+"/"+a,j=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,f,c):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(d){j==0&&(j=g.getResponseHeader("Content-Length"));d({total:j,loaded:g.responseText.length})}}else g.readyState==2&&(j=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
-g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,c,b,e){var f=function(d){function g(t,x){var C=k(t,x),E=k(t,x+1),H=k(t,x+2),T=k(t,x+3),V=(T<<1&255|H>>7)-127;C|=(H&127)<<16|E<<8;if(C==0&&V==-127)return 0;return(1-2*(T>>7))*(1+C*Math.pow(2,-23))*Math.pow(2,V)}function h(t,x){var C=k(t,x),E=k(t,x+1),H=k(t,x+2);return(k(t,x+3)<<24)+(H<<16)+(E<<8)+C}function j(t,x){var C=k(t,x);return(k(t,x+1)<<8)+C}function l(t,x){var C=k(t,x);return C>127?C-256:C}function k(t,
-x){return t.charCodeAt(x)&255}function m(t){var x,C,E;x=h(a,t);C=h(a,t+I);E=h(a,t+K);t=j(a,t+J);THREE.BinaryLoader.prototype.f3(u,x,C,E,t)}function p(t){var x,C,E,H,T,V;x=h(a,t);C=h(a,t+I);E=h(a,t+K);H=j(a,t+J);T=h(a,t+G);V=h(a,t+D);t=h(a,t+L);THREE.BinaryLoader.prototype.f3n(u,z,x,C,E,H,T,V,t)}function n(t){var x,C,E,H;x=h(a,t);C=h(a,t+R);E=h(a,t+O);H=h(a,t+S);t=j(a,t+P);THREE.BinaryLoader.prototype.f4(u,x,C,E,H,t)}function v(t){var x,C,E,H,T,V,ca,da;x=h(a,t);C=h(a,t+R);E=h(a,t+O);H=h(a,t+S);T=j(a,
-t+P);V=h(a,t+F);ca=h(a,t+N);da=h(a,t+Q);t=h(a,t+U);THREE.BinaryLoader.prototype.f4n(u,z,x,C,E,H,T,V,ca,da,t)}function A(t){var x,C;x=h(a,t);C=h(a,t+M);t=h(a,t+W);THREE.BinaryLoader.prototype.uv3(u.faceVertexUvs[0],B[x*2],B[x*2+1],B[C*2],B[C*2+1],B[t*2],B[t*2+1])}function w(t){var x,C,E;x=h(a,t);C=h(a,t+ea);E=h(a,t+fa);t=h(a,t+ga);THREE.BinaryLoader.prototype.uv4(u.faceVertexUvs[0],B[x*2],B[x*2+1],B[C*2],B[C*2+1],B[E*2],B[E*2+1],B[t*2],B[t*2+1])}var u=this,y=0,o,z=[],B=[],I,K,J,G,D,L,R,O,S,P,F,N,Q,
-U,M,W,ea,fa,ga,Y,Z,$,aa,ba,X;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,d);o={signature:a.substr(y,8),header_bytes:k(a,y+8),vertex_coordinate_bytes:k(a,y+9),normal_coordinate_bytes:k(a,y+10),uv_coordinate_bytes:k(a,y+11),vertex_index_bytes:k(a,y+12),normal_index_bytes:k(a,y+13),uv_index_bytes:k(a,y+14),material_index_bytes:k(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
-y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=o.header_bytes;I=o.vertex_index_bytes;K=o.vertex_index_bytes*2;J=o.vertex_index_bytes*3;G=o.vertex_index_bytes*3+o.material_index_bytes;D=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;L=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;R=o.vertex_index_bytes;O=o.vertex_index_bytes*2;S=o.vertex_index_bytes*3;P=o.vertex_index_bytes*4;F=o.vertex_index_bytes*
-4+o.material_index_bytes;N=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;Q=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;U=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;M=o.uv_index_bytes;W=o.uv_index_bytes*2;ea=o.uv_index_bytes;fa=o.uv_index_bytes*2;ga=o.uv_index_bytes*3;d=o.vertex_index_bytes*3+o.material_index_bytes;X=o.vertex_index_bytes*4+o.material_index_bytes;Y=o.ntri_flat*d;Z=o.ntri_smooth*(d+o.normal_index_bytes*3);$=o.ntri_flat_uv*
-(d+o.uv_index_bytes*3);aa=o.ntri_smooth_uv*(d+o.normal_index_bytes*3+o.uv_index_bytes*3);ba=o.nquad_flat*X;d=o.nquad_smooth*(X+o.normal_index_bytes*4);X=o.nquad_flat_uv*(X+o.uv_index_bytes*4);y+=function(t){for(var x,C,E,H=o.vertex_coordinate_bytes*3,T=t+o.nvertices*H;t<T;t+=H){x=g(a,t);C=g(a,t+o.vertex_coordinate_bytes);E=g(a,t+o.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(u,x,C,E)}return o.nvertices*H}(y);y+=function(t){for(var x,C,E,H=o.normal_coordinate_bytes*3,T=t+o.nnormals*H;t<
-T;t+=H){x=l(a,t);C=l(a,t+o.normal_coordinate_bytes);E=l(a,t+o.normal_coordinate_bytes*2);z.push(x/127,C/127,E/127)}return o.nnormals*H}(y);y+=function(t){for(var x,C,E=o.uv_coordinate_bytes*2,H=t+o.nuvs*E;t<H;t+=E){x=g(a,t);C=g(a,t+o.uv_coordinate_bytes);B.push(x,C)}return o.nuvs*E}(y);Y=y+Y;Z=Y+Z;$=Z+$;aa=$+aa;ba=aa+ba;d=ba+d;X=d+X;(function(t){var x,C=o.vertex_index_bytes*3+o.material_index_bytes,E=C+o.uv_index_bytes*3,H=t+o.ntri_flat_uv*E;for(x=t;x<H;x+=E){m(x);A(x+C)}return H-t})(Z);(function(t){var x,
-C=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,E=C+o.uv_index_bytes*3,H=t+o.ntri_smooth_uv*E;for(x=t;x<H;x+=E){p(x);A(x+C)}return H-t})($);(function(t){var x,C=o.vertex_index_bytes*4+o.material_index_bytes,E=C+o.uv_index_bytes*4,H=t+o.nquad_flat_uv*E;for(x=t;x<H;x+=E){n(x);w(x+C)}return H-t})(d);(function(t){var x,C=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,E=C+o.uv_index_bytes*4,H=t+o.nquad_smooth_uv*E;for(x=t;x<H;x+=E){v(x);w(x+C)}return H-t})(X);
-(function(t){var x,C=o.vertex_index_bytes*3+o.material_index_bytes,E=t+o.ntri_flat*C;for(x=t;x<E;x+=C)m(x);return E-t})(y);(function(t){var x,C=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,E=t+o.ntri_smooth*C;for(x=t;x<E;x+=C)p(x);return E-t})(Y);(function(t){var x,C=o.vertex_index_bytes*4+o.material_index_bytes,E=t+o.nquad_flat*C;for(x=t;x<E;x+=C)n(x);return E-t})(aa);(function(t){var x,C=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,E=t+o.nquad_smooth*
-C;for(x=t;x<E;x+=C)v(x);return E-t})(ba);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(b))},v:function(a,c,b,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,e)))},f3:function(a,c,b,e,f){a.faces.push(new THREE.Face3(c,b,e,null,null,a.materials[f]))},f4:function(a,c,b,e,f,d){a.faces.push(new THREE.Face4(c,b,e,f,null,null,a.materials[d]))},f3n:function(a,c,b,e,f,d,g,h,j){d=a.materials[d];var l=c[h*3],k=c[h*3+1];h=c[h*3+2];
-var m=c[j*3],p=c[j*3+1];j=c[j*3+2];a.faces.push(new THREE.Face3(b,e,f,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(l,k,h),new THREE.Vector3(m,p,j)],null,d))},f4n:function(a,c,b,e,f,d,g,h,j,l,k){g=a.materials[g];var m=c[j*3],p=c[j*3+1];j=c[j*3+2];var n=c[l*3],v=c[l*3+1];l=c[l*3+2];var A=c[k*3],w=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face4(b,e,f,d,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,p,j),new THREE.Vector3(n,v,l),new THREE.Vector3(A,w,k)],null,g))},
-uv3:function(a,c,b,e,f,d,g){var h=[];h.push(new THREE.UV(c,b));h.push(new THREE.UV(e,f));h.push(new THREE.UV(d,g));a.push(h)},uv4:function(a,c,b,e,f,d,g,h,j){var l=[];l.push(new THREE.UV(c,b));l.push(new THREE.UV(e,f));l.push(new THREE.UV(d,g));l.push(new THREE.UV(h,j));a.push(l)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
-THREE.SceneLoader.prototype={load:function(a,c){var b=this,e=new Worker(a);e.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(d){function g(M,W){return W=="relativeToHTML"?M:f+"/"+M}function h(){for(n in D.objects)if(!F.objects[n]){y=D.objects[n];if(y.geometry!==undefined){if(I=F.geometries[y.geometry]){G=[];for(U=0;U<y.materials.length;U++)G[U]=F.materials[y.materials[U]];o=y.position;r=y.rotation;q=y.quaternion;s=y.scale;q=0;G.length==0&&(G[0]=new THREE.MeshFaceMaterial);
-G.length>1&&(G=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(I,G);object.name=n;object.position.set(o[0],o[1],o[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible;F.scene.addObject(object);F.objects[n]=object;if(y.meshCollider){var M=THREE.CollisionUtils.MeshColliderWBox(object);F.scene.collisions.colliders.push(M)}if(y.castsShadow){M=new THREE.ShadowVolume(I);F.scene.addChild(M);
-M.position=object.position;M.rotation=object.rotation;M.scale=object.scale}if(y.trigger&&y.trigger.toLowerCase()!="none"){M={type:y.trigger,object:y};F.triggers[object.name]=M}}}else{o=y.position;r=y.rotation;q=y.quaternion;s=y.scale;q=0;object=new THREE.Object3D;object.name=n;object.position.set(o[0],o[1],o[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=y.visible!==undefined?y.visible:
-!1;F.scene.addObject(object);F.objects[n]=object;F.empties[n]=object;if(y.trigger&&y.trigger.toLowerCase()!="none"){M={type:y.trigger,object:y};F.triggers[object.name]=M}}}}function j(M){return function(W){F.geometries[M]=W;h();R-=1;b.onLoadComplete();k()}}function l(M){return function(W){F.geometries[M]=W}}function k(){b.callbackProgress({totalModels:S,totalTextures:P,loadedModels:S-R,loadedTextures:P-O},F);b.onLoadProgress();R==0&&O==0&&c(F)}var m,p,n,v,A,w,u,y,o,z,B,I,K,J,G,D,L,R,O,S,P,F;D=d.data;
-d=new THREE.BinaryLoader;L=new THREE.JSONLoader;O=R=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var N=!1;for(n in D.objects){y=D.objects[n];if(y.meshCollider){N=!0;break}}if(N)F.scene.collisions=new THREE.CollisionSystem;if(D.transform){N=D.transform.position;z=D.transform.rotation;var Q=D.transform.scale;N&&F.scene.position.set(N[0],N[1],N[2]);z&&F.scene.rotation.set(z[0],z[1],z[2]);Q&&F.scene.scale.set(Q[0],Q[1],
-Q[2]);(N||z||Q)&&F.scene.updateMatrix()}N=function(){O-=1;k();b.onLoadComplete()};for(A in D.cameras){z=D.cameras[A];if(z.type=="perspective")K=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}o=z.position;z=z.target;K.position.set(o[0],o[1],o[2]);K.target.position.set(z[0],z[1],z[2]);F.cameras[A]=K}for(v in D.lights){A=D.lights[v];K=A.color!==undefined?A.color:16777215;
-z=A.intensity!==undefined?A.intensity:1;if(A.type=="directional"){o=A.direction;light=new THREE.DirectionalLight(K,z);light.position.set(o[0],o[1],o[2]);light.position.normalize()}else if(A.type=="point"){o=A.position;light=new THREE.PointLight(K,z);light.position.set(o[0],o[1],o[2])}F.scene.addLight(light);F.lights[v]=light}for(w in D.fogs){v=D.fogs[w];if(v.type=="linear")J=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(J=new THREE.FogExp2(0,v.density));z=v.color;J.color.setRGB(z[0],z[1],z[2]);
-F.fogs[w]=J}if(F.cameras&&D.defaults.camera)F.currentCamera=F.cameras[D.defaults.camera];if(F.fogs&&D.defaults.fog)F.scene.fog=F.fogs[D.defaults.fog];z=D.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(z[0],z[1],z[2]);F.bgColorAlpha=D.defaults.bgalpha;for(m in D.geometries){w=D.geometries[m];if(w.type=="bin_mesh"||w.type=="ascii_mesh"){R+=1;b.onLoadStart()}}S=R;for(m in D.geometries){w=D.geometries[m];if(w.type=="cube"){I=new THREE.Cube(w.width,w.height,w.depth,w.segmentsWidth,w.segmentsHeight,
-w.segmentsDepth,null,w.flipped,w.sides);F.geometries[m]=I}else if(w.type=="plane"){I=new THREE.Plane(w.width,w.height,w.segmentsWidth,w.segmentsHeight);F.geometries[m]=I}else if(w.type=="sphere"){I=new THREE.Sphere(w.radius,w.segmentsWidth,w.segmentsHeight);F.geometries[m]=I}else if(w.type=="cylinder"){I=new THREE.Cylinder(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset);F.geometries[m]=I}else if(w.type=="torus"){I=new THREE.Torus(w.radius,w.tube,w.segmentsR,w.segmentsT);F.geometries[m]=
-I}else if(w.type=="icosahedron"){I=new THREE.Icosahedron(w.subdivisions);F.geometries[m]=I}else if(w.type=="bin_mesh")d.load({model:g(w.url,D.urlBaseType),callback:j(m)});else if(w.type=="ascii_mesh")L.load({model:g(w.url,D.urlBaseType),callback:j(m)});else if(w.type=="embedded_mesh")(w=D.embeds[w.id])&&L.createModel(w,l(m),"")}for(u in D.textures){m=D.textures[u];if(m.url instanceof Array){O+=m.url.length;for(d=0;d<m.url.length;d++)b.onLoadStart()}else{O+=1;b.onLoadStart()}}P=O;for(u in D.textures){m=
-D.textures[u];if(m.mapping!=undefined&&THREE[m.mapping]!=undefined)m.mapping=new THREE[m.mapping];if(m.url instanceof Array){d=[];for(var U=0;U<m.url.length;U++)d[U]=g(m.url[U],D.urlBaseType);d=THREE.ImageUtils.loadTextureCube(d,m.mapping,N)}else{d=THREE.ImageUtils.loadTexture(g(m.url,D.urlBaseType),m.mapping,N);if(THREE[m.minFilter]!=undefined)d.minFilter=THREE[m.minFilter];if(THREE[m.magFilter]!=undefined)d.magFilter=THREE[m.magFilter]}F.textures[u]=d}for(p in D.materials){u=D.materials[p];for(B in u.parameters)if(B==
-"envMap"||B=="map"||B=="lightMap")u.parameters[B]=F.textures[u.parameters[B]];else if(B=="shading")u.parameters[B]=u.parameters[B]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(B=="blending")u.parameters[B]=THREE[u.parameters[B]]?THREE[u.parameters[B]]:THREE.NormalBlending;else if(B=="combine")u.parameters[B]=u.parameters[B]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(B=="vertexColors")if(u.parameters[B]=="face")u.parameters[B]=THREE.FaceColors;else if(u.parameters[B])u.parameters[B]=
-THREE.VertexColors;if(u.parameters.opacity!==undefined&&u.parameters.opacity<1)u.parameters.transparent=!0;u=new THREE[u.type](u.parameters);F.materials[p]=u}h();b.callbackSync(F)}}};
+this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],b)]},createMaterial:function(a,c){function b(j){j=Math.log(j)/Math.LN2;return Math.floor(j)==j}function e(j,k){var m=new Image;m.onload=function(){if(!b(this.width)||!b(this.height)){var l=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/
+Math.LN2));j.image.width=l;j.image.height=n;j.image.getContext("2d").drawImage(this,0,0,l,n)}else j.image=this;j.needsUpdate=!0};m.src=k}var g,f,h;g="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")g="MeshPhongMaterial";else a.shading=="Basic"&&(g="MeshBasicMaterial");if(a.blending)if(a.blending=="Additive")f.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")f.blending=THREE.SubtractiveBlending;else if(a.blending==
+"Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==undefined||a.opacity<1)f.transparent=a.transparent;if(a.depthTest!==undefined)f.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&c){h=document.createElement("canvas");f.map=new THREE.Texture(h);f.map.sourceFile=a.mapDiffuse;e(f.map,c+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<
+16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;f.color=h;f.opacity=a.transparency}else if(a.DbgColor)f.color=a.DbgColor;if(a.mapLightmap&&c){h=document.createElement("canvas");f.lightMap=new THREE.Texture(h);f.lightMap.sourceFile=a.mapLightmap;e(f.lightMap,c+"/"+a.mapLightmap)}return new THREE[g](f)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
+THREE.JSONLoader.prototype.load=function(a){var c=this,b=a.model,e=a.callback,g=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(f){c.createModel(f.data,e,g);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
+THREE.JSONLoader.prototype.createModel=function(a,c,b){var e=new THREE.Geometry,g=a.scale!==undefined?1/a.scale:1;this.init_materials(e,a.materials,b);(function(f){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var h,j,k,m,l,n,p,o,w,D,z,v,A,t,C=a.faces;n=a.vertices;var E=a.normals,K=a.colors,N=0;for(h=0;h<a.uvs.length;h++)a.uvs[h].length&&N++;for(h=0;h<N;h++){e.faceUvs[h]=[];e.faceVertexUvs[h]=[]}m=0;for(l=n.length;m<l;){p=new THREE.Vertex;p.position.x=n[m++]*
+f;p.position.y=n[m++]*f;p.position.z=n[m++]*f;e.vertices.push(p)}m=0;for(l=C.length;m<l;){f=C[m++];n=f&1;k=f&2;h=f&4;j=f&8;o=f&16;p=f&32;D=f&64;f&=128;if(n){z=new THREE.Face4;z.a=C[m++];z.b=C[m++];z.c=C[m++];z.d=C[m++];n=4}else{z=new THREE.Face3;z.a=C[m++];z.b=C[m++];z.c=C[m++];n=3}if(k){k=C[m++];z.materials=e.materials[k]}k=e.faces.length;if(h)for(h=0;h<N;h++){v=a.uvs[h];w=C[m++];t=v[w*2];w=v[w*2+1];e.faceUvs[h][k]=new THREE.UV(t,w)}if(j)for(h=0;h<N;h++){v=a.uvs[h];A=[];for(j=0;j<n;j++){w=C[m++];
+t=v[w*2];w=v[w*2+1];A[j]=new THREE.UV(t,w)}e.faceVertexUvs[h][k]=A}if(o){o=C[m++]*3;j=new THREE.Vector3;j.x=E[o++];j.y=E[o++];j.z=E[o];z.normal=j}if(p)for(h=0;h<n;h++){o=C[m++]*3;j=new THREE.Vector3;j.x=E[o++];j.y=E[o++];j.z=E[o];z.vertexNormals.push(j)}if(D){p=C[m++];p=new THREE.Color(K[p]);z.color=p}if(f)for(h=0;h<n;h++){p=C[m++];p=new THREE.Color(K[p]);z.vertexColors.push(p)}e.faces.push(z)}}})(g);(function(){var f,h,j,k;if(a.skinWeights){f=0;for(h=a.skinWeights.length;f<h;f+=2){j=a.skinWeights[f];
+k=a.skinWeights[f+1];e.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(a.skinIndices){f=0;for(h=a.skinIndices.length;f<h;f+=2){j=a.skinIndices[f];k=a.skinIndices[f+1];e.skinIndices.push(new THREE.Vector4(j,k,0,0))}}e.bones=a.bones;e.animation=a.animation})();(function(f){if(a.morphTargets!==undefined){var h,j,k,m,l,n,p,o,w;h=0;for(j=a.morphTargets.length;h<j;h++){e.morphTargets[h]={};e.morphTargets[h].name=a.morphTargets[h].name;e.morphTargets[h].vertices=[];o=e.morphTargets[h].vertices;w=a.morphTargets[h].vertices;
+k=0;for(m=w.length;k<m;k+=3){l=w[k]*f;n=w[k+1]*f;p=w[k+2]*f;o.push(new THREE.Vertex(new THREE.Vector3(l,n,p)))}}}if(a.morphColors!==undefined){h=0;for(j=a.morphColors.length;h<j;h++){e.morphColors[h]={};e.morphColors[h].name=a.morphColors[h].name;e.morphColors[h].colors=[];m=e.morphColors[h].colors;l=a.morphColors[h].colors;f=0;for(k=l.length;f<k;f+=3){n=new THREE.Color(16755200);n.setRGB(l[f],l[f+1],l[f+2]);m.push(n)}}}})(g);(function(){if(a.edges!==undefined){var f,h,j;for(f=0;f<a.edges.length;f+=
+2){h=a.edges[f];j=a.edges[f+1];e.edges.push(new THREE.Edge(e.vertices[h],e.vertices[j],h,j))}}})();e.computeFaceNormals();c(e)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
+THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(h){THREE.BinaryLoader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,b,g,e,f)};c.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};
+c.postMessage(a)},loadAjaxBuffers:function(a,c,b,e,g,f){var h=new XMLHttpRequest,j=e+"/"+a,k=0;h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,b,g,c):alert("Couldn't load ["+j+"] ["+h.status+"]");else if(h.readyState==3){if(f){k==0&&(k=h.getResponseHeader("Content-Length"));f({total:k,loaded:h.responseText.length})}}else h.readyState==2&&(k=h.getResponseHeader("Content-Length"))};h.open("GET",j,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
+h.setRequestHeader("Content-Type","text/plain");h.send(null)},createBinModel:function(a,c,b,e){var g=function(f){function h(u,B){var F=l(u,B),I=l(u,B+1),M=l(u,B+2),X=l(u,B+3),Z=(X<<1&255|M>>7)-127;F|=(M&127)<<16|I<<8;if(F==0&&Z==-127)return 0;return(1-2*(X>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,Z)}function j(u,B){var F=l(u,B),I=l(u,B+1),M=l(u,B+2);return(l(u,B+3)<<24)+(M<<16)+(I<<8)+F}function k(u,B){var F=l(u,B);return(l(u,B+1)<<8)+F}function m(u,B){var F=l(u,B);return F>127?F-256:F}function l(u,
+B){return u.charCodeAt(B)&255}function n(u){var B,F,I;B=j(a,u);F=j(a,u+K);I=j(a,u+N);u=k(a,u+L);THREE.BinaryLoader.prototype.f3(v,B,F,I,u)}function p(u){var B,F,I,M,X,Z;B=j(a,u);F=j(a,u+K);I=j(a,u+N);M=k(a,u+L);X=j(a,u+J);Z=j(a,u+G);u=j(a,u+O);THREE.BinaryLoader.prototype.f3n(v,C,B,F,I,M,X,Z,u)}function o(u){var B,F,I,M;B=j(a,u);F=j(a,u+R);I=j(a,u+T);M=j(a,u+S);u=k(a,u+U);THREE.BinaryLoader.prototype.f4(v,B,F,I,M,u)}function w(u){var B,F,I,M,X,Z,ha,ia;B=j(a,u);F=j(a,u+R);I=j(a,u+T);M=j(a,u+S);X=k(a,
+u+U);Z=j(a,u+H);ha=j(a,u+Q);ia=j(a,u+V);u=j(a,u+W);THREE.BinaryLoader.prototype.f4n(v,C,B,F,I,M,X,Z,ha,ia,u)}function D(u){var B,F;B=j(a,u);F=j(a,u+P);u=j(a,u+Y);THREE.BinaryLoader.prototype.uv3(v.faceVertexUvs[0],E[B*2],E[B*2+1],E[F*2],E[F*2+1],E[u*2],E[u*2+1])}function z(u){var B,F,I;B=j(a,u);F=j(a,u+aa);I=j(a,u+ba);u=j(a,u+ja);THREE.BinaryLoader.prototype.uv4(v.faceVertexUvs[0],E[B*2],E[B*2+1],E[F*2],E[F*2+1],E[I*2],E[I*2+1],E[u*2],E[u*2+1])}var v=this,A=0,t,C=[],E=[],K,N,L,J,G,O,R,T,S,U,H,Q,V,
+W,P,Y,aa,ba,ja,ca,da,ea,fa,ga,$;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);t={signature:a.substr(A,8),header_bytes:l(a,A+8),vertex_coordinate_bytes:l(a,A+9),normal_coordinate_bytes:l(a,A+10),uv_coordinate_bytes:l(a,A+11),vertex_index_bytes:l(a,A+12),normal_index_bytes:l(a,A+13),uv_index_bytes:l(a,A+14),material_index_bytes:l(a,A+15),nvertices:j(a,A+16),nnormals:j(a,A+16+4),nuvs:j(a,A+16+8),ntri_flat:j(a,A+16+12),ntri_smooth:j(a,A+16+16),ntri_flat_uv:j(a,A+16+20),ntri_smooth_uv:j(a,
+A+16+24),nquad_flat:j(a,A+16+28),nquad_smooth:j(a,A+16+32),nquad_flat_uv:j(a,A+16+36),nquad_smooth_uv:j(a,A+16+40)};A+=t.header_bytes;K=t.vertex_index_bytes;N=t.vertex_index_bytes*2;L=t.vertex_index_bytes*3;J=t.vertex_index_bytes*3+t.material_index_bytes;G=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;O=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;R=t.vertex_index_bytes;T=t.vertex_index_bytes*2;S=t.vertex_index_bytes*3;U=t.vertex_index_bytes*4;H=t.vertex_index_bytes*
+4+t.material_index_bytes;Q=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;V=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;W=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;P=t.uv_index_bytes;Y=t.uv_index_bytes*2;aa=t.uv_index_bytes;ba=t.uv_index_bytes*2;ja=t.uv_index_bytes*3;f=t.vertex_index_bytes*3+t.material_index_bytes;$=t.vertex_index_bytes*4+t.material_index_bytes;ca=t.ntri_flat*f;da=t.ntri_smooth*(f+t.normal_index_bytes*3);ea=t.ntri_flat_uv*
+(f+t.uv_index_bytes*3);fa=t.ntri_smooth_uv*(f+t.normal_index_bytes*3+t.uv_index_bytes*3);ga=t.nquad_flat*$;f=t.nquad_smooth*($+t.normal_index_bytes*4);$=t.nquad_flat_uv*($+t.uv_index_bytes*4);A+=function(u){for(var B,F,I,M=t.vertex_coordinate_bytes*3,X=u+t.nvertices*M;u<X;u+=M){B=h(a,u);F=h(a,u+t.vertex_coordinate_bytes);I=h(a,u+t.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(v,B,F,I)}return t.nvertices*M}(A);A+=function(u){for(var B,F,I,M=t.normal_coordinate_bytes*3,X=u+t.nnormals*M;u<
+X;u+=M){B=m(a,u);F=m(a,u+t.normal_coordinate_bytes);I=m(a,u+t.normal_coordinate_bytes*2);C.push(B/127,F/127,I/127)}return t.nnormals*M}(A);A+=function(u){for(var B,F,I=t.uv_coordinate_bytes*2,M=u+t.nuvs*I;u<M;u+=I){B=h(a,u);F=h(a,u+t.uv_coordinate_bytes);E.push(B,F)}return t.nuvs*I}(A);ca=A+ca;da=ca+da;ea=da+ea;fa=ea+fa;ga=fa+ga;f=ga+f;$=f+$;(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes,I=F+t.uv_index_bytes*3,M=u+t.ntri_flat_uv*I;for(B=u;B<M;B+=I){n(B);D(B+F)}return M-u})(da);
+(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,I=F+t.uv_index_bytes*3,M=u+t.ntri_smooth_uv*I;for(B=u;B<M;B+=I){p(B);D(B+F)}return M-u})(ea);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes,I=F+t.uv_index_bytes*4,M=u+t.nquad_flat_uv*I;for(B=u;B<M;B+=I){o(B);z(B+F)}return M-u})(f);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,I=F+t.uv_index_bytes*4,M=u+t.nquad_smooth_uv*I;for(B=u;B<M;B+=I){w(B);
+z(B+F)}return M-u})($);(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes,I=u+t.ntri_flat*F;for(B=u;B<I;B+=F)n(B);return I-u})(A);(function(u){var B,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,I=u+t.ntri_smooth*F;for(B=u;B<I;B+=F)p(B);return I-u})(ca);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes,I=u+t.nquad_flat*F;for(B=u;B<I;B+=F)o(B);return I-u})(fa);(function(u){var B,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*
+4,I=u+t.nquad_smooth*F;for(B=u;B<I;B+=F)w(B);return I-u})(ga);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;c(new g(b))},v:function(a,c,b,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,e)))},f3:function(a,c,b,e,g){a.faces.push(new THREE.Face3(c,b,e,null,null,a.materials[g]))},f4:function(a,c,b,e,g,f){a.faces.push(new THREE.Face4(c,b,e,g,null,null,a.materials[f]))},f3n:function(a,c,b,e,g,f,h,j,k){f=a.materials[f];var m=c[j*3],
+l=c[j*3+1];j=c[j*3+2];var n=c[k*3],p=c[k*3+1];k=c[k*3+2];a.faces.push(new THREE.Face3(b,e,g,[new THREE.Vector3(c[h*3],c[h*3+1],c[h*3+2]),new THREE.Vector3(m,l,j),new THREE.Vector3(n,p,k)],null,f))},f4n:function(a,c,b,e,g,f,h,j,k,m,l){h=a.materials[h];var n=c[k*3],p=c[k*3+1];k=c[k*3+2];var o=c[m*3],w=c[m*3+1];m=c[m*3+2];var D=c[l*3],z=c[l*3+1];l=c[l*3+2];a.faces.push(new THREE.Face4(b,e,g,f,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(n,p,k),new THREE.Vector3(o,w,m),new THREE.Vector3(D,
+z,l)],null,h))},uv3:function(a,c,b,e,g,f,h){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(e,g));j.push(new THREE.UV(f,h));a.push(j)},uv4:function(a,c,b,e,g,f,h,j,k){var m=[];m.push(new THREE.UV(c,b));m.push(new THREE.UV(e,g));m.push(new THREE.UV(f,h));m.push(new THREE.UV(j,k));a.push(m)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
+THREE.SceneLoader.prototype={load:function(a,c){var b=this,e=new Worker(a);e.postMessage(0);var g=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(f){function h(P,Y){return Y=="relativeToHTML"?P:g+"/"+P}function j(){for(o in G.objects)if(!H.objects[o]){A=G.objects[o];if(A.geometry!==undefined){if(K=H.geometries[A.geometry]){J=[];for(W=0;W<A.materials.length;W++)J[W]=H.materials[A.materials[W]];t=A.position;r=A.rotation;q=A.quaternion;s=A.scale;q=0;J.length==0&&(J[0]=new THREE.MeshFaceMaterial);
+J.length>1&&(J=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(K,J);object.name=o;object.position.set(t[0],t[1],t[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else 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[o]=object;if(A.meshCollider){var P=THREE.CollisionUtils.MeshColliderWBox(object);H.scene.collisions.colliders.push(P)}if(A.castsShadow){P=new THREE.ShadowVolume(K);H.scene.addChild(P);
+P.position=object.position;P.rotation=object.rotation;P.scale=object.scale}if(A.trigger&&A.trigger.toLowerCase()!="none"){P={type:A.trigger,object:A};H.triggers[object.name]=P}}}else{t=A.position;r=A.rotation;q=A.quaternion;s=A.scale;q=0;object=new THREE.Object3D;object.name=o;object.position.set(t[0],t[1],t[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible!==undefined?A.visible:
+!1;H.scene.addObject(object);H.objects[o]=object;H.empties[o]=object;if(A.trigger&&A.trigger.toLowerCase()!="none"){P={type:A.trigger,object:A};H.triggers[object.name]=P}}}}function k(P){return function(Y){H.geometries[P]=Y;j();R-=1;b.onLoadComplete();l()}}function m(P){return function(Y){H.geometries[P]=Y}}function l(){b.callbackProgress({totalModels:S,totalTextures:U,loadedModels:S-R,loadedTextures:U-T},H);b.onLoadProgress();R==0&&T==0&&c(H)}var n,p,o,w,D,z,v,A,t,C,E,K,N,L,J,G,O,R,T,S,U,H;G=f.data;
+f=new THREE.BinaryLoader;O=new THREE.JSONLoader;T=R=0;H={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var Q=!1;for(o in G.objects){A=G.objects[o];if(A.meshCollider){Q=!0;break}}if(Q)H.scene.collisions=new THREE.CollisionSystem;if(G.transform){Q=G.transform.position;C=G.transform.rotation;var V=G.transform.scale;Q&&H.scene.position.set(Q[0],Q[1],Q[2]);C&&H.scene.rotation.set(C[0],C[1],C[2]);V&&H.scene.scale.set(V[0],V[1],
+V[2]);(Q||C||V)&&H.scene.updateMatrix()}Q=function(){T-=1;l();b.onLoadComplete()};for(D in G.cameras){C=G.cameras[D];if(C.type=="perspective")N=new THREE.Camera(C.fov,C.aspect,C.near,C.far);else if(C.type=="ortho"){N=new THREE.Camera;N.projectionMatrix=THREE.Matrix4.makeOrtho(C.left,C.right,C.top,C.bottom,C.near,C.far)}t=C.position;C=C.target;N.position.set(t[0],t[1],t[2]);N.target.position.set(C[0],C[1],C[2]);H.cameras[D]=N}for(w in G.lights){D=G.lights[w];N=D.color!==undefined?D.color:16777215;
+C=D.intensity!==undefined?D.intensity:1;if(D.type=="directional"){t=D.direction;light=new THREE.DirectionalLight(N,C);light.position.set(t[0],t[1],t[2]);light.position.normalize()}else if(D.type=="point"){t=D.position;light=new THREE.PointLight(N,C);light.position.set(t[0],t[1],t[2])}H.scene.addLight(light);H.lights[w]=light}for(z in G.fogs){w=G.fogs[z];if(w.type=="linear")L=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(L=new THREE.FogExp2(0,w.density));C=w.color;L.color.setRGB(C[0],C[1],C[2]);
+H.fogs[z]=L}if(H.cameras&&G.defaults.camera)H.currentCamera=H.cameras[G.defaults.camera];if(H.fogs&&G.defaults.fog)H.scene.fog=H.fogs[G.defaults.fog];C=G.defaults.bgcolor;H.bgColor=new THREE.Color;H.bgColor.setRGB(C[0],C[1],C[2]);H.bgColorAlpha=G.defaults.bgalpha;for(n in G.geometries){z=G.geometries[n];if(z.type=="bin_mesh"||z.type=="ascii_mesh"){R+=1;b.onLoadStart()}}S=R;for(n in G.geometries){z=G.geometries[n];if(z.type=="cube"){K=new THREE.Cube(z.width,z.height,z.depth,z.segmentsWidth,z.segmentsHeight,
+z.segmentsDepth,null,z.flipped,z.sides);H.geometries[n]=K}else if(z.type=="plane"){K=new THREE.Plane(z.width,z.height,z.segmentsWidth,z.segmentsHeight);H.geometries[n]=K}else if(z.type=="sphere"){K=new THREE.Sphere(z.radius,z.segmentsWidth,z.segmentsHeight);H.geometries[n]=K}else if(z.type=="cylinder"){K=new THREE.Cylinder(z.numSegs,z.topRad,z.botRad,z.height,z.topOffset,z.botOffset);H.geometries[n]=K}else if(z.type=="torus"){K=new THREE.Torus(z.radius,z.tube,z.segmentsR,z.segmentsT);H.geometries[n]=
+K}else if(z.type=="icosahedron"){K=new THREE.Icosahedron(z.subdivisions);H.geometries[n]=K}else if(z.type=="bin_mesh")f.load({model:h(z.url,G.urlBaseType),callback:k(n)});else if(z.type=="ascii_mesh")O.load({model:h(z.url,G.urlBaseType),callback:k(n)});else if(z.type=="embedded_mesh")(z=G.embeds[z.id])&&O.createModel(z,m(n),"")}for(v in G.textures){n=G.textures[v];if(n.url instanceof Array){T+=n.url.length;for(f=0;f<n.url.length;f++)b.onLoadStart()}else{T+=1;b.onLoadStart()}}U=T;for(v in G.textures){n=
+G.textures[v];if(n.mapping!=undefined&&THREE[n.mapping]!=undefined)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){f=[];for(var W=0;W<n.url.length;W++)f[W]=h(n.url[W],G.urlBaseType);f=THREE.ImageUtils.loadTextureCube(f,n.mapping,Q)}else{f=THREE.ImageUtils.loadTexture(h(n.url,G.urlBaseType),n.mapping,Q);if(THREE[n.minFilter]!=undefined)f.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=undefined)f.magFilter=THREE[n.magFilter]}H.textures[v]=f}for(p in G.materials){v=G.materials[p];for(E in v.parameters)if(E==
+"envMap"||E=="map"||E=="lightMap")v.parameters[E]=H.textures[v.parameters[E]];else if(E=="shading")v.parameters[E]=v.parameters[E]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(E=="blending")v.parameters[E]=THREE[v.parameters[E]]?THREE[v.parameters[E]]:THREE.NormalBlending;else if(E=="combine")v.parameters[E]=v.parameters[E]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(E=="vertexColors")if(v.parameters[E]=="face")v.parameters[E]=THREE.FaceColors;else if(v.parameters[E])v.parameters[E]=
+THREE.VertexColors;if(v.parameters.opacity!==undefined&&v.parameters.opacity<1)v.parameters.transparent=!0;v=new THREE[v.type](v.parameters);H.materials[p]=v}j();b.callbackSync(H)}}};
 THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;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(b,e,f){return b+(e-b)*f};this.VIntX=function(b,e,f,d,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[d]=h+g*this.delta;e[d+1]=j;e[d+2]=l;f[d]=this.lerp(k[b],k[b+3],g);f[d+1]=this.lerp(k[b+1],k[b+4],g);f[d+2]=this.lerp(k[b+2],k[b+5],g)};this.VIntY=function(b,e,f,d,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[d]=h;e[d+1]=j+g*this.delta;e[d+
-2]=l;e=b+this.yd*3;f[d]=this.lerp(k[b],k[e],g);f[d+1]=this.lerp(k[b+1],k[e+1],g);f[d+2]=this.lerp(k[b+2],k[e+2],g)};this.VIntZ=function(b,e,f,d,g,h,j,l,k,m){g=(g-k)/(m-k);k=this.normal_cache;e[d]=h;e[d+1]=j;e[d+2]=l+g*this.delta;e=b+this.zd*3;f[d]=this.lerp(k[b],k[e],g);f[d+1]=this.lerp(k[b+1],k[e+1],g);f[d+2]=this.lerp(k[b+2],k[e+2],g)};this.compNorm=function(b){var e=b*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[b-1]-this.field[b+1];this.normal_cache[e+1]=this.field[b-this.yd]-
-this.field[b+this.yd];this.normal_cache[e+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,e,f,d,g,h){var j=d+1,l=d+this.yd,k=d+this.zd,m=j+this.yd,p=j+this.zd,n=d+this.yd+this.zd,v=j+this.yd+this.zd,A=0,w=this.field[d],u=this.field[j],y=this.field[l],o=this.field[m],z=this.field[k],B=this.field[p],I=this.field[n],K=this.field[v];w<g&&(A|=1);u<g&&(A|=2);y<g&&(A|=8);o<g&&(A|=4);z<g&&(A|=16);B<g&&(A|=32);I<g&&(A|=128);K<g&&(A|=64);var J=THREE.edgeTable[A];if(J==0)return 0;
-var G=this.delta,D=b+G,L=e+G;G=f+G;if(J&1){this.compNorm(d);this.compNorm(j);this.VIntX(d*3,this.vlist,this.nlist,0,g,b,e,f,w,u)}if(J&2){this.compNorm(j);this.compNorm(m);this.VIntY(j*3,this.vlist,this.nlist,3,g,D,e,f,u,o)}if(J&4){this.compNorm(l);this.compNorm(m);this.VIntX(l*3,this.vlist,this.nlist,6,g,b,L,f,y,o)}if(J&8){this.compNorm(d);this.compNorm(l);this.VIntY(d*3,this.vlist,this.nlist,9,g,b,e,f,w,y)}if(J&16){this.compNorm(k);this.compNorm(p);this.VIntX(k*3,this.vlist,this.nlist,12,g,b,e,G,
-z,B)}if(J&32){this.compNorm(p);this.compNorm(v);this.VIntY(p*3,this.vlist,this.nlist,15,g,D,e,G,B,K)}if(J&64){this.compNorm(n);this.compNorm(v);this.VIntX(n*3,this.vlist,this.nlist,18,g,b,L,G,I,K)}if(J&128){this.compNorm(k);this.compNorm(n);this.VIntY(k*3,this.vlist,this.nlist,21,g,b,e,G,z,I)}if(J&256){this.compNorm(d);this.compNorm(k);this.VIntZ(d*3,this.vlist,this.nlist,24,g,b,e,f,w,z)}if(J&512){this.compNorm(j);this.compNorm(p);this.VIntZ(j*3,this.vlist,this.nlist,27,g,D,e,f,u,B)}if(J&1024){this.compNorm(m);
-this.compNorm(v);this.VIntZ(m*3,this.vlist,this.nlist,30,g,D,L,f,o,K)}if(J&2048){this.compNorm(l);this.compNorm(n);this.VIntZ(l*3,this.vlist,this.nlist,33,g,b,L,f,y,I)}A<<=4;for(g=d=0;THREE.triTable[A+g]!=-1;){b=A+g;e=b+1;f=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[f],h);g+=3;d++}return d};this.posnormtriv=function(b,e,f,d,g,h){var j=this.count*3;this.positionArray[j]=b[f];this.positionArray[j+1]=b[f+1];this.positionArray[j+2]=b[f+2];this.positionArray[j+
-3]=b[d];this.positionArray[j+4]=b[d+1];this.positionArray[j+5]=b[d+2];this.positionArray[j+6]=b[g];this.positionArray[j+7]=b[g+1];this.positionArray[j+8]=b[g+2];this.normalArray[j]=e[f];this.normalArray[j+1]=e[f+1];this.normalArray[j+2]=e[f+2];this.normalArray[j+3]=e[d];this.normalArray[j+4]=e[d+1];this.normalArray[j+5]=e[d+2];this.normalArray[j+6]=e[g];this.normalArray[j+7]=e[g+1];this.normalArray[j+8]=e[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,f,d,g){var h=this.size*Math.sqrt(d/g),j=f*this.size,l=e*this.size,k=b*this.size,m=Math.floor(j-h);m<1&&(m=1);j=Math.floor(j+h);j>this.size-1&&(j=this.size-1);var p=Math.floor(l-h);p<1&&(p=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(k-h);n<1&&(n=1);h=Math.floor(k+h);
-h>this.size-1&&(h=this.size-1);for(var v,A,w,u,y,o;m<j;m++){k=this.size2*m;A=m/this.size-f;y=A*A;for(A=p;A<l;A++){w=k+this.size*A;v=A/this.size-e;o=v*v;for(v=n;v<h;v++){u=v/this.size-b;u=d/(1.0E-6+u*u+o+y)-g;u>0&&(this.field[w+v]+=u)}}}};this.addPlaneX=function(b,e){var f,d,g,h,j,l=this.size,k=this.yd,m=this.zd,p=this.field,n=l*Math.sqrt(b/e);n>l&&(n=l);for(f=0;f<n;f++){d=f/l;d*=d;h=b/(1.0E-4+d)-e;if(h>0)for(d=0;d<l;d++){j=f+d*k;for(g=0;g<l;g++)p[m*g+j]+=h}}};this.addPlaneY=function(b,e){var f,d,
-g,h,j,l,k=this.size,m=this.yd,p=this.zd,n=this.field,v=k*Math.sqrt(b/e);v>k&&(v=k);for(d=0;d<v;d++){f=d/k;f*=f;h=b/(1.0E-4+f)-e;if(h>0){j=d*m;for(f=0;f<k;f++){l=j+f;for(g=0;g<k;g++)n[p*g+l]+=h}}}};this.addPlaneZ=function(b,e){var f,d,g,h,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(g=0;g<dist;g++){f=g/size;f*=f;h=b/(1.0E-4+f)-e;if(h>0){j=zd*g;for(d=0;d<size;d++){l=j+d*yd;for(f=0;f<size;f++)field[l+f]+=h}}}};this.reset=function(){var b;
-for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var e,f,d,g,h,j,l,k,m,p=this.size-2;for(g=1;g<p;g++){m=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(d=1;d<p;d++){k=m+this.size*d;j=(d-this.halfsize)/this.halfsize;for(f=1;f<p;f++){h=(f-this.halfsize)/this.halfsize;e=k+f;this.polygonize(h,j,l,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,f=[];this.render(function(d){var g,h,j,l,k,m,p,n;for(g=
-0;g<d.count;g++){p=g*3;k=p+1;n=p+2;h=d.positionArray[p];j=d.positionArray[k];l=d.positionArray[n];m=new THREE.Vector3(h,j,l);h=d.normalArray[p];j=d.normalArray[k];l=d.normalArray[n];p=new THREE.Vector3(h,j,l);p.normalize();k=new THREE.Vertex(m);e.vertices.push(k);f.push(p)}nfaces=d.count/3;for(g=0;g<nfaces;g++){p=(b+g)*3;k=p+1;n=p+2;m=f[p];h=f[k];j=f[n];p=new THREE.Face3(p,k,n,[m,h,j]);e.faces.push(p)}b+=nfaces;d.count=0});return e};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;
+0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,e,g){return b+(e-b)*g};this.VIntX=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j+h*this.delta;e[f+1]=k;e[f+2]=m;g[f]=this.lerp(l[b],l[b+3],h);g[f+1]=this.lerp(l[b+1],l[b+4],h);g[f+2]=this.lerp(l[b+2],l[b+5],h)};this.VIntY=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j;e[f+1]=k+h*this.delta;e[f+
+2]=m;e=b+this.yd*3;g[f]=this.lerp(l[b],l[e],h);g[f+1]=this.lerp(l[b+1],l[e+1],h);g[f+2]=this.lerp(l[b+2],l[e+2],h)};this.VIntZ=function(b,e,g,f,h,j,k,m,l,n){h=(h-l)/(n-l);l=this.normal_cache;e[f]=j;e[f+1]=k;e[f+2]=m+h*this.delta;e=b+this.zd*3;g[f]=this.lerp(l[b],l[e],h);g[f+1]=this.lerp(l[b+1],l[e+1],h);g[f+2]=this.lerp(l[b+2],l[e+2],h)};this.compNorm=function(b){var e=b*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[b-1]-this.field[b+1];this.normal_cache[e+1]=this.field[b-this.yd]-
+this.field[b+this.yd];this.normal_cache[e+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,e,g,f,h,j){var k=f+1,m=f+this.yd,l=f+this.zd,n=k+this.yd,p=k+this.zd,o=f+this.yd+this.zd,w=k+this.yd+this.zd,D=0,z=this.field[f],v=this.field[k],A=this.field[m],t=this.field[n],C=this.field[l],E=this.field[p],K=this.field[o],N=this.field[w];z<h&&(D|=1);v<h&&(D|=2);A<h&&(D|=8);t<h&&(D|=4);C<h&&(D|=16);E<h&&(D|=32);K<h&&(D|=128);N<h&&(D|=64);var L=THREE.edgeTable[D];if(L==0)return 0;
+var J=this.delta,G=b+J,O=e+J;J=g+J;if(L&1){this.compNorm(f);this.compNorm(k);this.VIntX(f*3,this.vlist,this.nlist,0,h,b,e,g,z,v)}if(L&2){this.compNorm(k);this.compNorm(n);this.VIntY(k*3,this.vlist,this.nlist,3,h,G,e,g,v,t)}if(L&4){this.compNorm(m);this.compNorm(n);this.VIntX(m*3,this.vlist,this.nlist,6,h,b,O,g,A,t)}if(L&8){this.compNorm(f);this.compNorm(m);this.VIntY(f*3,this.vlist,this.nlist,9,h,b,e,g,z,A)}if(L&16){this.compNorm(l);this.compNorm(p);this.VIntX(l*3,this.vlist,this.nlist,12,h,b,e,J,
+C,E)}if(L&32){this.compNorm(p);this.compNorm(w);this.VIntY(p*3,this.vlist,this.nlist,15,h,G,e,J,E,N)}if(L&64){this.compNorm(o);this.compNorm(w);this.VIntX(o*3,this.vlist,this.nlist,18,h,b,O,J,K,N)}if(L&128){this.compNorm(l);this.compNorm(o);this.VIntY(l*3,this.vlist,this.nlist,21,h,b,e,J,C,K)}if(L&256){this.compNorm(f);this.compNorm(l);this.VIntZ(f*3,this.vlist,this.nlist,24,h,b,e,g,z,C)}if(L&512){this.compNorm(k);this.compNorm(p);this.VIntZ(k*3,this.vlist,this.nlist,27,h,G,e,g,v,E)}if(L&1024){this.compNorm(n);
+this.compNorm(w);this.VIntZ(n*3,this.vlist,this.nlist,30,h,G,O,g,t,N)}if(L&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,h,b,O,g,A,K)}D<<=4;for(h=f=0;THREE.triTable[D+h]!=-1;){b=D+h;e=b+1;g=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[e],3*THREE.triTable[g],j);h+=3;f++}return f};this.posnormtriv=function(b,e,g,f,h,j){var k=this.count*3;this.positionArray[k]=b[g];this.positionArray[k+1]=b[g+1];this.positionArray[k+2]=b[g+2];this.positionArray[k+
+3]=b[f];this.positionArray[k+4]=b[f+1];this.positionArray[k+5]=b[f+2];this.positionArray[k+6]=b[h];this.positionArray[k+7]=b[h+1];this.positionArray[k+8]=b[h+2];this.normalArray[k]=e[g];this.normalArray[k+1]=e[g+1];this.normalArray[k+2]=e[g+2];this.normalArray[k+3]=e[f];this.normalArray[k+4]=e[f+1];this.normalArray[k+5]=e[f+2];this.normalArray[k+6]=e[h];this.normalArray[k+7]=e[h+1];this.normalArray[k+8]=e[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;b(this)}};this.addBall=function(b,e,g,f,h){var j=this.size*Math.sqrt(f/h),k=g*this.size,m=e*this.size,l=b*this.size,n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);j=Math.floor(l+j);
+j>this.size-1&&(j=this.size-1);for(var w,D,z,v,A,t;n<k;n++){l=this.size2*n;D=n/this.size-g;A=D*D;for(D=p;D<m;D++){z=l+this.size*D;w=D/this.size-e;t=w*w;for(w=o;w<j;w++){v=w/this.size-b;v=f/(1.0E-6+v*v+t+A)-h;v>0&&(this.field[z+w]+=v)}}}};this.addPlaneX=function(b,e){var g,f,h,j,k,m=this.size,l=this.yd,n=this.zd,p=this.field,o=m*Math.sqrt(b/e);o>m&&(o=m);for(g=0;g<o;g++){f=g/m;f*=f;j=b/(1.0E-4+f)-e;if(j>0)for(f=0;f<m;f++){k=g+f*l;for(h=0;h<m;h++)p[n*h+k]+=j}}};this.addPlaneY=function(b,e){var g,f,
+h,j,k,m,l=this.size,n=this.yd,p=this.zd,o=this.field,w=l*Math.sqrt(b/e);w>l&&(w=l);for(f=0;f<w;f++){g=f/l;g*=g;j=b/(1.0E-4+g)-e;if(j>0){k=f*n;for(g=0;g<l;g++){m=k+g;for(h=0;h<l;h++)o[p*h+m]+=j}}}};this.addPlaneZ=function(b,e){var g,f,h,j,k,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/e);dist>size&&(dist=size);for(h=0;h<dist;h++){g=h/size;g*=g;j=b/(1.0E-4+g)-e;if(j>0){k=zd*h;for(f=0;f<size;f++){m=k+f*yd;for(g=0;g<size;g++)field[m+g]+=j}}}};this.reset=function(){var b;
+for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var e,g,f,h,j,k,m,l,n,p=this.size-2;for(h=1;h<p;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(f=1;f<p;f++){l=n+this.size*f;k=(f-this.halfsize)/this.halfsize;for(g=1;g<p;g++){j=(g-this.halfsize)/this.halfsize;e=l+g;this.polygonize(j,k,m,e,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,e=new THREE.Geometry,g=[];this.render(function(f){var h,j,k,m,l,n,p,o;for(h=
+0;h<f.count;h++){p=h*3;l=p+1;o=p+2;j=f.positionArray[p];k=f.positionArray[l];m=f.positionArray[o];n=new THREE.Vector3(j,k,m);j=f.normalArray[p];k=f.normalArray[l];m=f.normalArray[o];p=new THREE.Vector3(j,k,m);p.normalize();l=new THREE.Vertex(n);e.vertices.push(l);g.push(p)}nfaces=f.count/3;for(h=0;h<nfaces;h++){p=(b+h)*3;l=p+1;o=p+2;n=g[p];j=g[l];k=g[o];p=new THREE.Face3(p,l,o,[n,j,k]);e.faces.push(p)}b+=nfaces;f.count=0});return e};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,
 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,
@@ -174,21 +188,21 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
-THREE.Trident=function(a){function c(d){return new THREE.Mesh(new THREE.Cylinder(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:d}))}function b(d,g){var h=new THREE.Geometry;h.vertices=[new THREE.Vertex,new THREE.Vertex(d)];return new THREE.Line(h,new THREE.LineBasicMaterial({color:g}))}THREE.Object3D.call(this);var e=Math.PI/2,f;a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(f in THREE.Trident.defaultParams)a.hasOwnProperty(f)||(a[f]=THREE.Trident.defaultParams[f]);
-this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(b(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(b(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(b(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows){f=c(a.xAxisColor);f.rotation.y=-e;f.position.x=a.length;this.addChild(f);f=c(a.yAxisColor);f.rotation.x=e;f.position.y=a.length;this.addChild(f);f=c(a.zAxisColor);f.rotation.y=Math.PI;f.position.z=a.length;this.addChild(f)}};
+THREE.Trident=function(a){function c(f){return new THREE.Mesh(new THREE.Cylinder(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:f}))}function b(f,h){var j=new THREE.Geometry;j.vertices=[new THREE.Vertex,new THREE.Vertex(f)];return new THREE.Line(j,new THREE.LineBasicMaterial({color:h}))}THREE.Object3D.call(this);var e=Math.PI/2,g;a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(g in THREE.Trident.defaultParams)a.hasOwnProperty(g)||(a[g]=THREE.Trident.defaultParams[g]);
+this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(b(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(b(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(b(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows){g=c(a.xAxisColor);g.rotation.y=-e;g.position.x=a.length;this.addChild(g);g=c(a.yAxisColor);g.rotation.x=e;g.position.y=a.length;this.addChild(g);g=c(a.zAxisColor);g.rotation.y=Math.PI;g.position.z=a.length;this.addChild(g)}};
 THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
 THREE.MeshCollider=function(a,c){this.mesh=a;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){this.colliders=this.colliders.concat(a.colliders);this.hits=this.hits.concat(a.hits)};
-THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,e,f,d=0;c=0;for(b=this.colliders.length;c<b;c++){f=this.colliders[c];e=this.rayCast(a,f);if(e<Number.MAX_VALUE){f.distance=e;e>d?this.hits.push(f):this.hits.unshift(f);d=e}}return this.hits};
+THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,e,g,f=0;c=0;for(b=this.colliders.length;c<b;c++){g=this.colliders[c];e=this.rayCast(a,g);if(e<Number.MAX_VALUE){g.distance=e;e>f?this.hits.push(g):this.hits.unshift(g);f=e}}return this.hits};
 THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,c[b]);if(e.dist<Number.MAX_VALUE){c[b].distance=e.dist;c[b].faceIndex=e.faceIndex;break}b++}if(b>c.length)return null;return c[b]};
 THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)};
-THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,f,d=0;d<c.numFaces;d++){var g=c.mesh.geometry.faces[d],h=c.mesh.geometry.vertices[g.a].position,j=c.mesh.geometry.vertices[g.b].position,l=c.mesh.geometry.vertices[g.c].position,k=g instanceof THREE.Face4?c.mesh.geometry.vertices[g.d].position:null;if(g instanceof THREE.Face3){g=this.rayTriangle(b,h,j,l,e,this.collisionNormal);if(g<e){e=g;f=d;c.normal.copy(this.collisionNormal);c.normal.normalize()}}else if(g instanceof
-THREE.Face4){g=this.rayTriangle(b,h,j,k,e,this.collisionNormal);if(g<e){e=g;f=d;c.normal.copy(this.collisionNormal);c.normal.normalize()}g=this.rayTriangle(b,j,l,k,e,this.collisionNormal);if(g<e){e=g;f=d;c.normal.copy(this.collisionNormal);c.normal.normalize()}}}return{dist:e,faceIndex:f}};
-THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,e,f,d){var g=THREE.CollisionSystem.__v1,h=THREE.CollisionSystem.__v2;d.set(0,0,0);g.sub(b,c);h.sub(e,b);d.cross(g,h);h=d.dot(a.direction);if(!(h<0))return Number.MAX_VALUE;g=d.dot(c)-d.dot(a.origin);if(!(g<=0))return Number.MAX_VALUE;if(!(g>=h*f))return Number.MAX_VALUE;g/=h;h=THREE.CollisionSystem.__v3;h.copy(a.direction);h.multiplyScalar(g);h.addSelf(a.origin);if(Math.abs(d.x)>Math.abs(d.y))if(Math.abs(d.x)>Math.abs(d.z)){a=h.y-c.y;d=b.y-
-c.y;f=e.y-c.y;h=h.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=h.x-c.x;d=b.x-c.x;f=e.x-c.x;h=h.y-c.y;b=b.y-c.y;e=e.y-c.y}else if(Math.abs(d.y)>Math.abs(d.z)){a=h.x-c.x;d=b.x-c.x;f=e.x-c.x;h=h.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=h.x-c.x;d=b.x-c.x;f=e.x-c.x;h=h.y-c.y;b=b.y-c.y;e=e.y-c.y}c=d*e-b*f;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-h*f)*c;if(!(e>=0))return Number.MAX_VALUE;c*=d*h-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return g};
+THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),e=Number.MAX_VALUE,g,f=0;f<c.numFaces;f++){var h=c.mesh.geometry.faces[f],j=c.mesh.geometry.vertices[h.a].position,k=c.mesh.geometry.vertices[h.b].position,m=c.mesh.geometry.vertices[h.c].position,l=h instanceof THREE.Face4?c.mesh.geometry.vertices[h.d].position:null;if(h instanceof THREE.Face3){h=this.rayTriangle(b,j,k,m,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}}else if(h instanceof
+THREE.Face4){h=this.rayTriangle(b,j,k,l,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}h=this.rayTriangle(b,k,m,l,e,this.collisionNormal);if(h<e){e=h;g=f;c.normal.copy(this.collisionNormal);c.normal.normalize()}}}return{dist:e,faceIndex:g}};
+THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,e,g,f){var h=THREE.CollisionSystem.__v1,j=THREE.CollisionSystem.__v2;f.set(0,0,0);h.sub(b,c);j.sub(e,b);f.cross(h,j);j=f.dot(a.direction);if(!(j<0))return Number.MAX_VALUE;h=f.dot(c)-f.dot(a.origin);if(!(h<=0))return Number.MAX_VALUE;if(!(h>=j*g))return Number.MAX_VALUE;h/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(h);j.addSelf(a.origin);if(Math.abs(f.x)>Math.abs(f.y))if(Math.abs(f.x)>Math.abs(f.z)){a=j.y-c.y;f=b.y-
+c.y;g=e.y-c.y;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}else if(Math.abs(f.y)>Math.abs(f.z)){a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.z-c.z;b=b.z-c.z;e=e.z-c.z}else{a=j.x-c.x;f=b.x-c.x;g=e.x-c.x;j=j.y-c.y;b=b.y-c.y;e=e.y-c.y}c=f*e-b*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(a*e-j*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=f*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return h};
 THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);b.multiplyVector3(e.origin);b.rotateAxis(e.direction);e.direction.normalize();return e};
-THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;if(c.dynamic&&c.mesh&&c.mesh.matrixWorld)b=this.makeRayLocal(a,c.mesh);else{b=THREE.CollisionSystem.__r;b.origin.copy(a.origin);b.direction.copy(a.direction)}var e=0,f=0,d=0,g=0,h=0,j=0,l=!0;if(b.origin.x<c.min.x){e=c.min.x-b.origin.x;e/=b.direction.x;l=!1;g=-1}else if(b.origin.x>c.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.y<c.min.y){f=c.min.y-b.origin.y;f/=b.direction.y;l=!1;h=-1}else if(b.origin.y>c.max.y){f=c.max.y-
-b.origin.y;f/=b.direction.y;l=!1;h=1}if(b.origin.z<c.min.z){d=c.min.z-b.origin.z;d/=b.direction.z;l=!1;j=-1}else if(b.origin.z>c.max.z){d=c.max.z-b.origin.z;d/=b.direction.z;l=!1;j=1}if(l)return-1;l=0;if(f>e){l=1;e=f}if(d>e){l=2;e=d}switch(l){case 0:h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>c.max.x)return Number.MAX_VALUE;
-b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(g<c.min.x||g>c.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(h<c.min.y||h>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,j)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
+THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;if(c.dynamic&&c.mesh&&c.mesh.matrixWorld)b=this.makeRayLocal(a,c.mesh);else{b=THREE.CollisionSystem.__r;b.origin.copy(a.origin);b.direction.copy(a.direction)}var e=0,g=0,f=0,h=0,j=0,k=0,m=!0;if(b.origin.x<c.min.x){e=c.min.x-b.origin.x;e/=b.direction.x;m=!1;h=-1}else if(b.origin.x>c.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;m=!1;h=1}if(b.origin.y<c.min.y){g=c.min.y-b.origin.y;g/=b.direction.y;m=!1;j=-1}else if(b.origin.y>c.max.y){g=c.max.y-
+b.origin.y;g/=b.direction.y;m=!1;j=1}if(b.origin.z<c.min.z){f=c.min.z-b.origin.z;f/=b.direction.z;m=!1;k=-1}else if(b.origin.z>c.max.z){f=c.max.z-b.origin.z;f/=b.direction.z;m=!1;k=1}if(m)return-1;m=0;if(g>e){m=1;e=g}if(f>e){m=2;e=f}switch(m){case 0:j=b.origin.y+b.direction.y*e;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=b.origin.x+b.direction.x*e;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;
+b=b.origin.z+b.direction.z*e;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,j,0);break;case 2:h=b.origin.x+b.direction.x*e;if(h<c.min.x||h>c.max.x)return Number.MAX_VALUE;j=b.origin.y+b.direction.y*e;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,k)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),e=c.point.dot(c.normal);if(b<0)b=(e-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
 THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var e=b.dot(a.direction.clone());if(e<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-e*e);if(b>=0)return Math.abs(e)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
 THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]);c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]);b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
 THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};

+ 2 - 2
build/custom/ThreeSVG.js

@@ -3,7 +3,7 @@ var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float3
 THREE.Color.prototype={copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.hex=a.hex},setHex:function(a){this.hex=~~a&16777215;this.updateRGB()},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;this.updateHex()},setHSV:function(a,b,c){var d,e,g,f,j,h;if(c==0)d=e=g=0;else{f=Math.floor(a*6);j=a*6-f;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(f){case 1:d=h;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=h;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=h;break;case 6:case 0:d=c;e=b;g=a}}this.setRGB(d,
 e,g)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
-this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)};
+this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},clone:function(){return new THREE.Vector2(this.x,this.y)},equals:function(a){return a.x==this.x&&a.y==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=
@@ -49,7 +49,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,j=a.z;a=a.w;this.x=b*a+e*g+c*j-d*f;this.y=c*a+e*f+d*g-b*j;this.z=d*a+e*j+b*f-c*g;this.w=e*a-b*g-c*f-d*j;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,j=this.z,h=this.w,i=h*c+f*e-j*d,k=
 h*d+j*c-g*e,n=h*e+g*d-f*c;c=-g*c-f*d-j*e;b.x=i*h+c*-g+k*-j-n*-f;b.y=k*h+c*-f+n*-g-i*-j;b.z=n*h+c*-j+i*-f-k*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<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}e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 3 - 3
build/custom/ThreeWebGL.js

@@ -3,7 +3,7 @@ var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float3
 THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;this.updateHex()},setHSV:function(b,d,e){var g,h,p,o,q,r;if(e==0)g=h=p=0;else{o=Math.floor(b*6);q=b*6-o;b=e*(1-d);r=e*(1-d*q);d=e*(1-d*(1-q));switch(o){case 1:g=r;h=e;p=b;break;case 2:g=b;h=e;p=d;break;case 3:g=b;h=r;p=e;break;case 4:g=d;h=b;p=e;break;case 5:g=e;h=b;p=r;break;case 6:case 0:g=e;h=d;p=b}}this.setRGB(g,
 h,p)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,d){this.set(b||0,d||0)};
 THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
-this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
+this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x;b=this.y-b.y;return d*d+b*b},clone:function(){return new THREE.Vector2(this.x,this.y)},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
 THREE.Vector3.prototype={set:function(b,d,e){this.x=b;this.y=d;this.z=e;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z);return this},addScalar:function(b){this.set(this.x+b,this.y+b,this.z+b);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z);return this},cross:function(b,
 d){this.set(b.y*d.z-b.z*d.y,b.z*d.x-b.x*d.z,b.x*d.y-b.y*d.x);return this},crossSelf:function(b){var d=this.x,e=this.y,g=this.z;this.set(e*b.z-g*b.y,g*b.x-d*b.z,d*b.y-e*b.x);return this},multiply:function(b,d){this.set(b.x*d.x,b.y*d.y,b.z*d.z);return this},multiplySelf:function(b){this.set(this.x*b.x,this.y*b.y,this.z*b.z);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b,this.z*b);return this},divideSelf:function(b){this.set(this.x/b.x,this.y/b.y,this.z/b.z);return this},divideScalar:function(b){this.set(this.x/
 b,this.y/b,this.z/b);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var d=this.x-b.x,e=this.y-b.y;b=this.z-b.z;return d*d+e*e+b*b},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 b=
@@ -49,7 +49,7 @@ THREE.Quaternion.prototype={set:function(b,d,e,g){this.x=b;this.y=d;this.z=e;thi
 b.y*g;this.z=b.z*g;this.w=Math.cos(e);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},
 multiplySelf:function(b){var d=this.x,e=this.y,g=this.z,h=this.w,p=b.x,o=b.y,q=b.z;b=b.w;this.x=d*b+h*p+e*q-g*o;this.y=e*b+h*o+g*p-d*q;this.z=g*b+h*q+d*o-e*p;this.w=h*b-d*p-e*o-g*q;return this},multiply:function(b,d){this.x=b.x*d.w+b.y*d.z-b.z*d.y+b.w*d.x;this.y=-b.x*d.z+b.y*d.w+b.z*d.x+b.w*d.y;this.z=b.x*d.y-b.y*d.x+b.z*d.w+b.w*d.z;this.w=-b.x*d.x-b.y*d.y-b.z*d.z+b.w*d.w;return this},multiplyVector3:function(b,d){d||(d=b);var e=b.x,g=b.y,h=b.z,p=this.x,o=this.y,q=this.z,r=this.w,v=r*e+o*h-q*g,E=
 r*g+q*e-p*h,G=r*h+p*g-o*e;e=-p*e-o*g-q*h;d.x=v*r+e*-p+E*-q-G*-o;d.y=E*r+e*-o+G*-p-v*-q;d.z=G*r+e*-q+v*-o-E*-p;return d}};
-THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var p=Math.acos(h),o=Math.sqrt(1-h*h);if(Math.abs(o)<0.001){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*p)/o;g=Math.sin(g*p)/o;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.slerp=function(b,d,e,g){var h=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(h)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var p=Math.acos(h),o=Math.sqrt(1-h*h);if(Math.abs(o)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}h=Math.sin((1-g)*p)/o;g=Math.sin(g*p)/o;e.w=b.w*h+d.w*g;e.x=b.x*h+d.x*g;e.y=b.y*h+d.y*g;e.z=b.z*h+d.z*g;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,g,h,p){this.a=b;this.b=d;this.c=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=p instanceof Array?p:[p];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,g,h,p,o){this.a=b;this.b=d;this.c=e;this.d=g;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=p instanceof THREE.Color?p:new THREE.Color;this.vertexColors=p instanceof Array?p:[];this.vertexTangents=[];this.materials=o instanceof Array?o:[o];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -212,7 +212,7 @@ c.uniform1f(x.opacity,m.opacity);c.uniform1f(x.rotation,m.rotation);c.uniform2fv
 c.useProgram(N.program);ta=N.program;ga=-1;if(!ub){c.enableVertexAttribArray(N.attributes.vertex);c.enableVertexAttribArray(N.attributes.uv);ub=!0}c.uniform1i(Q.occlusionMap,0);c.uniform1i(Q.map,1);c.bindBuffer(c.ARRAY_BUFFER,N.vertexBuffer);c.vertexAttribPointer(k.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(k.uv,2,c.FLOAT,!1,16,8);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);c.activeTexture(c.TEXTURE0);c.bindTexture(c.TEXTURE_2D,N.occlusionTexture);
 c.activeTexture(c.TEXTURE1);for(i=0;i<m;i++){k=f.__webglLensFlares[i].object;z.set(k.matrixWorld.n14,k.matrixWorld.n24,k.matrixWorld.n34);t.matrixWorldInverse.multiplyVector3(z);t.projectionMatrix.multiplyVector3(z);J[0]=z.x;J[1]=z.y;J[2]=z.z;Z[0]=J[0]*n+n;Z[1]=J[1]*y+y;if(N.hasVertexTexture||Z[0]>0&&Z[0]<fa&&Z[1]>0&&Z[1]<ua){c.bindTexture(c.TEXTURE_2D,N.tempTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGB,Z[0]-8,Z[1]-8,16,16,0);c.uniform1i(Q.renderType,0);c.uniform2fv(Q.scale,K);c.uniform3fv(Q.screenPosition,
 J);c.disable(c.BLEND);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.bindTexture(c.TEXTURE_2D,N.occlusionTexture);c.copyTexImage2D(c.TEXTURE_2D,0,c.RGBA,Z[0]-8,Z[1]-8,16,16,0);c.uniform1i(Q.renderType,1);c.disable(c.DEPTH_TEST);c.bindTexture(c.TEXTURE_2D,N.tempTexture);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);k.positionScreen.x=J[0];k.positionScreen.y=J[1];k.positionScreen.z=J[2];k.customUpdateCallback?k.customUpdateCallback(k):k.updateLensFlares();c.uniform1i(Q.renderType,
-2);c.enable(c.BLEND);x=0;for(w=k.lensFlares.length;x<w;x++){u=k.lensFlares[x];if(u.opacity>0.001&&u.scale>0.001){J[0]=u.x;J[1]=u.y;J[2]=u.z;B=u.size*u.scale/ua;K[0]=B*D;K[1]=B;c.uniform3fv(Q.screenPosition,J);c.uniform2fv(Q.scale,K);c.uniform1f(Q.rotation,u.rotation);c.uniform1f(Q.opacity,u.opacity);$(u.blending);M(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(va)}function P(f,t){f._modelViewMatrix.multiplyToArray(t.matrixWorldInverse,
+2);c.enable(c.BLEND);x=0;for(w=k.lensFlares.length;x<w;x++){u=k.lensFlares[x];if(u.opacity>0.0010&&u.scale>0.0010){J[0]=u.x;J[1]=u.y;J[2]=u.z;B=u.size*u.scale/ua;K[0]=B*D;K[1]=B;c.uniform3fv(Q.screenPosition,J);c.uniform2fv(Q.scale,K);c.uniform1f(Q.rotation,u.rotation);c.uniform1f(Q.opacity,u.opacity);$(u.blending);M(u.texture,1);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(va)}function P(f,t){f._modelViewMatrix.multiplyToArray(t.matrixWorldInverse,
 f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function L(f){var t,k,i,m,x;if(f instanceof THREE.Mesh){k=f.geometry;for(t in k.geometryGroups){i=k.geometryGroups[t];x=!1;for(m in i.__webglCustomAttributes)if(i.__webglCustomAttributes[m].needsUpdate){x=!0;break}if(k.__dirtyVertices||k.__dirtyMorphTargets||k.__dirtyElements||k.__dirtyUvs||k.__dirtyNormals||k.__dirtyColors||k.__dirtyTangents||x){x=f;var w=c.DYNAMIC_DRAW;
 if(i.__inittedArrays){var u=void 0,z=void 0,D=void 0,n=void 0;D=void 0;var y=void 0,B=void 0,K=void 0,J=void 0,Z=void 0,Q=void 0,aa=void 0,Ga=void 0,Wa=void 0,R=void 0,T=void 0,U=void 0,pa=void 0;B=void 0;K=void 0;n=void 0;J=void 0;n=void 0;var s=void 0,I=void 0;B=void 0;s=void 0;I=void 0;var j=void 0,Ka=void 0;s=void 0;I=void 0;j=void 0;Ka=void 0;s=void 0;I=void 0;j=void 0;Ka=void 0;s=void 0;I=void 0;j=void 0;n=void 0;J=void 0;y=void 0;D=void 0;D=void 0;s=void 0;I=void 0;j=void 0;var Xa=void 0,wa=
 0,Aa=0,bb=0,cb=0,Ja=0,La=0,ha=0,Ma=0,ya=0,A=0,Ba=0;I=s=0;var Ca=i.__vertexArray,jb=i.__uvArray,kb=i.__uv2Array,Ra=i.__normalArray,ka=i.__tangentArray,Da=i.__colorArray,la=i.__skinVertexAArray,ma=i.__skinVertexBArray,na=i.__skinIndexArray,oa=i.__skinWeightArray,mb=i.__morphTargetsArrays,Sa=i.__webglCustomAttributes;j=void 0;var Na=i.__faceArray,Pa=i.__lineArray,vb=i.__needsSmoothNormals;Q=i.__vertexColorType;Z=i.__uvType;aa=i.__normalType;var Ha=x.geometry,nb=Ha.__dirtyVertices,ob=Ha.__dirtyElements,

+ 208 - 0
examples/canvas_geometry_text.html

@@ -0,0 +1,208 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js canvas/webgl - geometry - text</title>
+		<meta charset="utf-8">
+		<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
+		<style type="text/css">
+			body {
+				font-family: Monospace;
+				background-color: #f0f0f0;
+				margin: 0px;
+				overflow: hidden;
+			}
+		</style>
+	</head>
+	<body>
+
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+       
+       
+       <!-- 
+        <script type="text/javascript" src="../src/extras/geometries/Text.js"></script>
+         <script type="text/javascript" src="helvetiker-normal-normal.js"></script>
+        -->
+       <script type="text/javascript" src="http://canvas-text.googlecode.com/svn-history/r41/trunk/faces/helvetiker-normal-normal.js"></script>
+        
+
+		<script type="text/javascript">
+
+			var container, stats;
+
+			var camera, scene, renderer;
+
+			var text, plane;
+
+			var targetRotation = 0;
+			var targetRotationOnMouseDown = 0;
+
+			var mouseX = 0;
+			var mouseXOnMouseDown = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			init();
+			animate();
+
+			function init() {
+
+				container = document.createElement( 'div' );
+				document.body.appendChild( container );
+
+				var info = document.createElement( 'div' );
+				info.style.position = 'absolute';
+				info.style.top = '10px';
+				info.style.width = '100%';
+				info.style.textAlign = 'center';
+				info.innerHTML = 'Drag to spin the text';
+				container.appendChild( info );
+
+				camera = new THREE.Camera( 70, window.innerWidth / window.innerHeight, 1, 1000 );
+				camera.position.y = 150;
+				camera.position.z = 500;
+				camera.target.position.y = 150;
+
+				scene = new THREE.Scene();
+
+				// Get text from hash
+				var theText = "Hello three.js! :)";
+                 var hash = document.location.hash.substr(1);
+                  if (hash.length === 0) {
+                    
+                  } else {
+                   theText = hash;
+                  }
+                
+                var text3d = new THREE.Text(theText, 80, 40, 4, "");
+             
+                //try MeshPhongMaterial MeshLambertMaterial MeshPhongMaterial MeshNormalMaterial
+                var textMaterial = new THREE.MeshBasicMaterial( { color: 0.5 * 0xffffff, wireframe:false });
+                text = new THREE.Mesh( text3d, textMaterial);
+                
+                text.doubleSided = false;
+                text.position.y = 0;
+                text.position.y = 0;
+                text.position.z = 0;
+                text.rotation.x = 0*Math.PI;
+                text.rotation.y = Math.PI*2;
+				text.overdraw = true;
+				
+                scene.addObject( text );
+             
+				// Plane
+				plane = new THREE.Mesh( new THREE.Plane( 800, 800 ), new THREE.MeshBasicMaterial( { color: 0xe0e0e0, wireframe:true}) );
+				plane.rotation.x = - 90 * ( Math.PI / 180 );
+                plane.position.x = 0;
+				plane.overdraw = true;
+                
+                
+                
+				scene.addObject( plane );
+
+				renderer = new THREE.CanvasRenderer();
+                renderer.setSize( window.innerWidth, window.innerHeight );
+
+				container.appendChild( renderer.domElement );
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				container.appendChild( stats.domElement );
+
+				document.addEventListener( 'mousedown', onDocumentMouseDown, false );
+				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
+				document.addEventListener( 'touchmove', onDocumentTouchMove, false );
+			}
+
+			//
+
+			function onDocumentMouseDown( event ) {
+
+				event.preventDefault();
+
+				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
+				document.addEventListener( 'mouseup', onDocumentMouseUp, false );
+				document.addEventListener( 'mouseout', onDocumentMouseOut, false );
+
+				mouseXOnMouseDown = event.clientX - windowHalfX;
+				targetRotationOnMouseDown = targetRotation;
+			}
+
+			function onDocumentMouseMove( event ) {
+
+				mouseX = event.clientX - windowHalfX;
+
+				targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.02;
+			}
+
+			function onDocumentMouseUp( event ) {
+
+				document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
+				document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
+				document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
+			}
+
+			function onDocumentMouseOut( event ) {
+
+				document.removeEventListener( 'mousemove', onDocumentMouseMove, false );
+				document.removeEventListener( 'mouseup', onDocumentMouseUp, false );
+				document.removeEventListener( 'mouseout', onDocumentMouseOut, false );
+			}
+
+			function onDocumentTouchStart( event ) {
+
+				if ( event.touches.length == 1 ) {
+
+					event.preventDefault();
+
+					mouseXOnMouseDown = event.touches[ 0 ].pageX - windowHalfX;
+					targetRotationOnMouseDown = targetRotation;
+
+				}
+			}
+
+			function onDocumentTouchMove( event ) {
+
+				if ( event.touches.length == 1 ) {
+
+					event.preventDefault();
+
+					mouseX = event.touches[ 0 ].pageX - windowHalfX;
+					targetRotation = targetRotationOnMouseDown + ( mouseX - mouseXOnMouseDown ) * 0.05;
+
+				}
+			}
+
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				plane.rotation.z = text.rotation.y += ( targetRotation - text.rotation.y ) * 0.05;
+				renderer.render( scene, camera );
+
+			}
+
+		</script>
+        <script>
+        var _gaq=[["_setAccount","UA-7549263-1"],["_trackPageview"]]; 
+        (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
+        g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
+        s.parentNode.insertBefore(g,s)}(document,"script"));
+        </script>
+
+	</body>
+</html>

+ 19 - 0
src/core/Vector2.js

@@ -1,6 +1,7 @@
 /**
  * @author mr.doob / http://mrdoob.com/
  * @author philogb / http://blog.thejit.org/
+ * @author zz85 / http://www.lab4games.net/zz85/blog
  */
 
 THREE.Vector2 = function ( x, y ) {
@@ -135,11 +136,29 @@ THREE.Vector2.prototype = {
 		return this.x * this.x + this.y * this.y;
 
 	},
+	
+	distanceTo : function ( v ) {
+
+		return Math.sqrt( this.distanceToSquared( v ) );
+
+	},
+
+	distanceToSquared : function ( v ) {
+
+		var dx = this.x - v.x, dy = this.y - v.y;
+		return dx * dx + dy * dy;
+
+	},
+
 
 	clone : function () {
 
 		return new THREE.Vector2( this.x, this.y );
 
+	},
+	
+	equals : function(v) {
+		return ( (v.x == this.x) && (v.y == this.y) );
 	}
 
 };

+ 690 - 0
src/extras/geometries/Text.js

@@ -0,0 +1,690 @@
+/**
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ * THREE.FontText.js
+ * Techniques obtained from projects like 
+ * typeface.js, canvastext,
+ * 
+ * Triangulation ** 
+ * with holes http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/
+ *
+ * In an experiment for creating 2d and 3d text in three.js
+ * 
+ */
+ 
+ /* TODO: 
+    Cleanup
+    JSON Param
+    FontLoader?
+    Refactor to FontUtils?
+*/
+    
+
+
+
+THREE.Text = function (text, size, height, curveSegments, font) {
+    if (!size) size = 100;
+    if (!height) height = 50;
+    if (!curveSegments) curveSegments = 4;
+    if (!font) font = "";
+    
+    
+    
+	THREE.Geometry.call( this );
+    
+    ThreeFont.size = size;
+    ThreeFont.divisions = curveSegments;
+    
+    // Get a Font data object
+    var data = ThreeFont.drawText(text);
+    //console.log("data", data);
+    
+    
+    vertices = data.points;
+    faces = data.faces;
+    contour = data.contour;
+    
+    
+    
+    
+    var scope = this;
+    
+    var vlen = 0;
+    for (var i in vertices) {
+        var vert = vertices[i];
+        v(vert.x, vert.y, 0);
+        vlen++;
+    }
+    
+    for (var i in vertices) {
+        var vert = vertices[i];
+        v(vert.x, vert.y, height);
+    }
+
+    // Bottom faces
+    for (var i in faces) {
+        var face = faces[i];
+        f3(face[2], face[1], face[0]);
+        //f3(face[0], face[1], face[2]);
+    }
+
+    // Top Faces
+    for (var i in faces) {
+        var face = faces[i];
+        f3(face[0]+vlen, face[1]+vlen, face[2]+vlen);
+        // f3(face[2]+vlen, face[1]+vlen, face[0]+vlen);
+        //  f3(face.a, face.b, face.c);
+
+    }
+    
+   
+    
+    var i = contour.length;
+    
+    var lastV;
+    var j;
+    while (--i > 0) {
+        if (!lastV) {
+            lastV = contour[i];
+        } else if (lastV.equals(contour[i])) {
+            lastV  = null;
+            continue;
+        }
+        
+        var j,k;
+        
+        for (j=0; j<vertices.length; j++) {
+            if (vertices[j].equals(contour[i])) {
+                break;
+            }
+        }
+        
+        for (k=0; k<vertices.length; k++) {
+            if (vertices[k].equals(contour[i-1])) break;
+        }
+        
+        //f4(j+vlen, k+vlen,k,j);
+        f4(j, k, k+vlen,j+vlen);
+        
+        
+    }
+
+
+	
+    
+    // UVs to be added
+
+	this.computeCentroids();
+	this.computeFaceNormals();
+	// this.computeVertexNormals();
+
+	function v( x, y, z ) {
+
+		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
+
+	}
+
+	function f3( a, b, c) {
+
+		scope.faces.push( new THREE.Face3( a, b, c) );
+
+	}
+    
+    function f4( a, b, c, d) {
+
+		scope.faces.push( new THREE.Face4( a, b, c, d) );
+
+	}
+
+    //console.log(this);
+
+
+};
+
+THREE.Text.prototype = new THREE.Geometry();
+THREE.Text.prototype.constructor = THREE.Text;
+
+
+
+var ThreeFont = {};
+
+ThreeFont.faces = {};
+
+// Just for now. face[weight][style]
+ThreeFont.face = "helvetiker";
+ThreeFont.weight = "normal";
+ThreeFont.style = "normal";
+ThreeFont.size = 150;
+ThreeFont.divisions = 10;
+
+ThreeFont.getFace = function() {
+    return this.faces[this.face][this.weight][this.style];
+}
+
+ThreeFont.loadFace = function(data) {
+    var family = data.familyName.toLowerCase();
+
+    this.faces[family] = this.faces[family] || {};
+    
+    if (data.strokeFont) {
+      this.faces[family].normal = this.faces[family].normal || {};
+      this.faces[family].normal.normal = data;
+      this.faces[family].normal.italic = data;
+      
+      this.faces[family].bold = this.faces[family].normal || {};
+      this.faces[family].bold.normal = data;
+      this.faces[family].bold.italic = data;
+    }
+    else {
+      this.faces[family][data.cssFontWeight] = this.faces[family][data.cssFontWeight] || {};
+      this.faces[family][data.cssFontWeight][data.cssFontStyle] = data;
+    }
+    
+    return data;
+};
+
+
+ThreeFont.extractPoints = function(points) {
+    // Quick Exit
+    if (points.length <3) {
+		console.log("not valid polygon");
+		return;
+	}
+    
+	// Try to split shapes and holes.
+	var all = [], point, shape;
+    
+    var isolatedShapes = [];
+	
+    // Use a quick hashmap for locating duplicates
+	for (var p in points) {
+		point = points[p];
+		all.push(point.x +","+ point.y);
+	}
+	
+	
+	
+	var firstPt = all[0];
+	var endPt = all.slice(1).indexOf(firstPt);
+	
+	if (endPt < all.length) {
+		endPt ++;
+		shape = points.slice(0, endPt);
+	}
+	
+	holes = [];
+    
+	while (endPt < all.length) {
+		firstIndex = endPt+1;
+		firstPt = all[firstIndex];
+		endPt = all.slice(firstIndex+1).indexOf(firstPt) + firstIndex;
+		if (endPt <= firstIndex ) break; 
+		
+		var contours = points.slice(firstIndex, endPt+1);
+		
+		if (THREE.Triangulate.area(contours)<0) {
+            isolatedShapes.push({shape: shape, holes: holes});
+			// Save the old shapes, then work on new additional seperated shape
+            
+            shape = contours;
+            holes = [];
+            
+		} else {
+            holes.push(contours);
+		}
+        
+		endPt++;
+		//console.log("holes--> ", contours.length);
+		//console.log("CCW", THREE.Triangulate.area(contours));
+		
+		
+	}
+    
+    isolatedShapes.push({shape: shape, holes: holes});
+	
+	//console.log("isolatedShapes", isolatedShapes);
+	
+    
+    
+    /* For each isolated shape, find the closest points and break to the hole to allow triangulation*/
+    
+	// Find closest points between holes    
+	
+    // we could optimize here
+    // http://en.wikipedia.org/wiki/Proximity_problems
+	// http://en.wikipedia.org/wiki/Closest_pair_of_points
+	// http://stackoverflow.com/questions/1602164/shortest-distance-between-points-algorithm
+	
+	var verts = [];
+    
+    
+    
+    for (var shapeId in isolatedShapes) {
+        var shapeGroup = isolatedShapes[shapeId];
+        shape = shapeGroup.shape;
+        holes = shapeGroup.holes;
+        
+        for (var h in holes) {
+            // we slice to each hole when neccessary
+            var hole = holes[h];
+            var shortest = Number.POSITIVE_INFINITY;
+            var holeIndex, shapeIndex;
+            for (var h2 in hole) {
+                var pts1 = hole[h2];
+                
+                for (var p in shape) {
+                    var pts2 = shape[p];
+                    d = pts1.distanceTo(pts2);
+                    
+                    if (d<shortest) {
+                        shortest = d;
+                        holeIndex = h2;
+                        shapeIndex = p;
+                    }
+                }
+                
+            }
+                    
+            //console.log("point ind, hole ind", shapeIndex, holeIndex);
+            //console.log("shape.length, tmpShape",shape.length, hole.length);
+            
+            prevShapeVert = (shapeIndex-1)>=0 ? shapeIndex-1:shape.length-1 ;
+            nextShapeVert = (shapeIndex+1)<shape.length ? shapeIndex + 1 : 0;
+            
+            prevHoleVert = (holeIndex-1)>=0 ? holeIndex-1:hole.length-1;
+            nextHoleVert = (holeIndex+1)<hole.length ? holeIndex + 1 : 0 ;
+            
+            var tmpShape1 = shape.slice(0, shapeIndex);
+            var tmpShape2 = shape.slice(shapeIndex);
+            var tmpHole1 = hole.slice(holeIndex);
+            var tmpHole2 = hole.slice(0,holeIndex);
+        
+            verts.push(hole[holeIndex]);
+            verts.push(shape[shapeIndex]);
+            verts.push(shape[prevShapeVert]);
+            
+            verts.push(hole[holeIndex]);
+            verts.push(hole[prevHoleVert]);
+            verts.push(shape[shapeIndex]);
+                            
+            shapeGroup.shape = tmpShape1.concat(tmpHole1).concat(tmpHole2).concat(tmpShape2);
+
+        }
+    }
+	
+    points = [];
+    var triangulatedVertices = [];
+    var lastTriangles = 0;
+    for (var shapeId in isolatedShapes) {
+        var shapeGroup = isolatedShapes[shapeId];
+        shape = shapeGroup.shape;
+        points = points.concat(shape);
+        var triangles = THREE.Triangulate(shape,true);
+        // We need to offset vertics indexs for faces
+        for (var v in triangles) {
+            var face = triangles[v];
+            face[0] += lastTriangles;
+            face[1] += lastTriangles;
+            face[2] += lastTriangles;
+        }
+        triangulatedVertices = triangulatedVertices.concat(triangles);
+        lastTriangles += shape.length;
+    }
+   
+   
+   // Now we push the "cutted" vertics back to the triangulated indics.
+   //console.log("we have verts.length",verts.length);
+   var j;
+   for (var v=0; v<verts.length/3; v++) {        
+        
+        var face = [];
+        
+        for (var k=0;k<3;k++) {            
+            for (j=0; j<points.length; j++) {
+                
+                var l =v*3+k;
+                if (points[j].equals(verts[l])) {
+                    face.push(j);
+                    break;
+                }
+                
+            }
+        }
+        
+        triangulatedVertices.push(face);
+   }
+   
+   
+    //console.log("triangles", triangulatedVertices.length, "points", points);
+
+    return {
+        points: points,
+        faces: triangulatedVertices
+    };
+
+}
+
+ThreeFont.drawText = function(text) {
+    pts = [];
+    // RenderText // (text);
+    var face = this.getFace(),
+        scale = (this.size / face.resolution),
+        offset = 0, i, 
+        chars = String(text).split(''), 
+        length = chars.length;
+    for (i = 0; i < length; i++) {
+      offset += this.extractGlyphPoints(chars[i], face, scale, offset); 
+    }
+    
+    // get the width 
+    width = offset/2;
+    for (var p in pts) {
+        pts[p].x -= width;
+    }
+    
+    //console.log("Length pts", pts.length);
+    
+    var extract = this.extractPoints(pts);
+    
+    extract.contour = pts;
+    return extract;
+    
+};
+
+
+// Bezier Curves formuals obtained from
+// http://en.wikipedia.org/wiki/B%C3%A9zier_curve
+
+// Quad Bezier Functions
+function b2p0(t, p) {
+    return (1-t)*(1-t) * p;
+}
+
+function b2p1(t, p) {
+    return 2*(1-t) * t * p;
+}
+
+function b2p2(t, p) {
+    return t * t * p;
+}
+
+function b2(t, p0, p1, p2) {
+    return b2p0(t, p0) + b2p1(t, p1) + b2p2(t, p2);
+}
+
+// Cubic Bezier Funcitions
+function b3p0(t, p) {
+    var k = (1-t);
+    return k*k*k * p;
+}
+
+function b3p1(t, p) {
+    var k = (1-t);
+    return 3* k*k * t * p;
+}
+
+function b3p2(t, p) {
+    var k = 1-t;
+    return 3 * k * t * t * p;
+}
+
+function b3p3(t, p) {
+    return t * t * t * p;
+}
+
+function b3(t, p0, p1, p2, p3) {
+    return b3p0(t, p0) + b3p1(t, p1) + b3p2(t, p2) +  b3p3(t, p3);
+}
+
+
+ThreeFont.extractGlyphPoints = function(c, face, scale, offset){
+      var i, cpx, cpy, outline, action, length,
+          glyph = face.glyphs[c] || face.glyphs[ctxt.options.fallbackCharacter];
+    
+      if (!glyph) return;
+  
+      if (glyph.o) {
+      
+        outline = glyph._cachedOutline || (glyph._cachedOutline = glyph.o.split(' '));
+        length = outline.length;
+        
+        var scaleX = scale;
+        var scaleY = scale;
+		 
+        for (i = 0; i < length; ) {
+          action = outline[i++];
+  
+          switch(action) {
+            case 'm':
+                // Move To
+                x = outline[i++]*scaleX+offset, y = outline[i++]*scaleY;
+                pts.push(new THREE.Vector2(x,y));
+              break;
+            case 'l':
+                // Line To
+                x = outline[i++]*scaleX+offset, y = outline[i++]*scaleY;
+                pts.push(new THREE.Vector2(x,y));
+              break;
+            case 'q':
+                //quadraticCurveTo
+              cpx = outline[i++]*scaleX+offset;
+              cpy = outline[i++]*scaleY;
+              cpx1 = outline[i++]*scaleX+offset;
+              cpy1 = outline[i++]*scaleY;
+              
+              var laste = pts[pts.length-1];
+              
+              if (laste) {
+                cpx0 = laste.x;
+                cpy0 = laste.y;
+                
+                for (var i2 = 1, divisions = this.divisions;i2<=divisions;i2++) {
+                    var t = i2/divisions;
+                    var tx = b2(t, cpx0, cpx1, cpx);
+                    var ty = b2(t, cpy0, cpy1, cpy);
+                    pts.push(new THREE.Vector2(tx, ty));
+                  }
+              }
+              
+              
+              break;
+            case 'b':
+                // Cubic Bezier Curve
+              cpx = outline[i++]*scaleX+offset;
+              cpy = outline[i++]*scaleY;
+              
+              cpx1 = outline[i++]*scale+offset;
+              cpy1 = outline[i++]*-scale;
+              cpx2 = outline[i++]*scale+offset;
+              cpy2 = outline[i++]*-scale;
+              
+              var laste = pts[pts.length-1];
+              
+              if (laste) {
+                cpx0 = laste.x;
+                cpy0 = laste.y;
+                
+                for (var i2 = 1, divisions = this.divisions;i2<=divisions;i2++) {
+                    var t = i2/divisions;
+                    var tx = b3(t, cpx0, cpx1, cpx2, cpx);
+                    var ty = b3(t, cpy0, cpy1, cpy2, cpy);
+                    pts.push(new THREE.Vector2(tx, ty));
+                  }
+              }
+
+              
+              //this.ctx.bezierCurveTo(outline[i++]*scale+offset, outline[i++]*-scale, outline[i++]*scale+offset, outline[i++]*-scale, cpx, cpy);
+              break;
+          }
+        }
+      }
+      return glyph.ha*scale;
+    };
+
+
+
+
+
+
+/**
+This code is a quick port of code written in C++ which was submitted to 
+flipcode.com by John W. Ratcliff  // July 22, 2000 
+See original code and more information here:
+http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml
+
+ported to actionscript by Zevan Rosser
+www.actionsnippet.com
+
+ported to javascript by Joshua Koo
+http://www.lab4games.net/zz85/blog
+
+*/
+
+
+(function(namespace) {
+		
+    var EPSILON =0.0000000001;
+    
+    // takes in an contour array and returns 
+    var process = function(contour, indics) {
+       
+        var result = [];
+        var n = contour.length;
+        if ( n < 3 ) return null
+        
+        var verts = [], vertIndics = [];
+        
+          /* we want a counter-clockwise polygon in verts */
+        var v;
+        
+        
+        if ( 0.0 < area(contour)) {
+            for (v=0; v<n; v++) verts[v] = v;
+        } else {
+            for (v=0; v<n; v++) verts[v] = (n-1)-v;
+        }
+        
+        var nv = n;
+        
+        /*  remove nv-2 vertsertices, creating 1 triangle every time */
+        var count = 2*nv;   /* error detection */
+            var m;
+            for(m=0, v=nv-1; nv>2; )
+            {
+            
+            
+                /* if we loop, it is probably a non-simple polygon */
+                if (0 >= (count--)){
+                    //** Triangulate: ERROR - probable bad polygon!
+                    console.log("Warning, unable to triangulate polygon!");
+                    return null;
+                }
+            
+                /* three consecutive vertices in current polygon, <u,v,w> */
+                var u = v; if (nv <= u) u = 0;     /* previous */
+                v = u+1; if (nv <= v) v = 0;     /* new v    */
+                var w = v+1; if (nv <= w) w = 0;     /* next     */
+            
+                if ( snip(contour,u,v,w,nv,verts)){
+                  var a,b,c,s,t;
+            
+                  /* true names of the vertices */
+                  a = verts[u]; b = verts[v]; c = verts[w];
+            
+                  /* output Triangle */
+                  result.push( contour[a] );
+                  result.push( contour[b] );
+                  result.push( contour[c] );
+                  vertIndics.push([verts[u], verts[v],verts[w]]);
+                  //vertIndics.push(THREE.Face3(verts[u], verts[v],verts[w]));
+            
+            
+                  m++;
+            
+                  /* remove v from remaining polygon */
+                  for(s=v,t=v+1;t<nv;s++,t++) {
+                   verts[s] = verts[t]; 
+                   
+                   }
+                   nv--;
+                  
+            
+                  /* resest error detection counter */
+                  count = 2 * nv;
+            }
+          }
+        
+        if (indics) return vertIndics;
+          return result;
+    };
+    
+    // calculate area of the contour polygon
+    var area = function (contour){
+        var n = contour.length;
+        var a  = 0.0;
+        
+        for(var p=n-1, q=0; q<n; p=q++){
+            a += contour[p].x * contour[q].y - contour[q].x * contour[p].y;
+        }
+        return a * 0.5;
+    };
+    
+    // see if p is inside triangle abc
+    var insideTriangle = function(ax, ay,
+                      bx, by,
+                      cx, cy,
+                      px, py){
+          var aX, aY, bX, bY;
+          var cX, cY, apx, apy;
+          var bpx, bpy, cpx, cpy;
+          var cCROSSap, bCROSScp, aCROSSbp;
+        
+          aX = cx - bx;  aY = cy - by;
+          bX = ax - cx;  bY = ay - cy;
+          cX = bx - ax;  cY = by - ay;
+          apx= px  -ax;  apy= py - ay;
+          bpx= px - bx;  bpy= py - by;
+          cpx= px - cx;  cpy= py - cy;
+        
+          aCROSSbp = aX*bpy - aY*bpx;
+          cCROSSap = cX*apy - cY*apx;
+          bCROSScp = bX*cpy - bY*cpx;
+        
+          return ((aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0));
+    };
+    
+    
+   var snip =  function (contour, u, v, w, n, verts) {
+          var p;
+          var ax, ay, bx, by;
+          var cx, cy, px, py;
+        
+              ax = contour[verts[u]].x;
+              ay = contour[verts[u]].y;
+            
+              bx = contour[verts[v]].x;
+              by = contour[verts[v]].y;
+            
+              cx = contour[verts[w]].x;
+              cy = contour[verts[w]].y;
+        
+          if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false;
+        
+          for (p=0;p<n;p++){
+                if( (p == u) || (p == v) || (p == w) ) continue;
+                px = contour[verts[p]].x
+                py = contour[verts[p]].y
+                if (insideTriangle(ax,ay,bx,by,cx,cy,px,py)) return false;
+          }
+          return true;
+    };
+    
+    
+    namespace.Triangulate = process;
+	namespace.Triangulate.area = area;
+    
+    return namespace;
+})(THREE);
+
+// To use the typeface.js face files, hook their API
+window._typeface_js = {faces: ThreeFont.faces, loadFace: ThreeFont.loadFace};
+

+ 1 - 0
utils/build.py

@@ -101,6 +101,7 @@ EXTRAS_FILES = [
 'extras/geometries/Sphere.js',
 'extras/geometries/Torus.js',
 'extras/geometries/TorusKnot.js',
+'extras/geometries/Text.js',
 'extras/io/Loader.js',
 'extras/io/JSONLoader.js',
 'extras/io/BinaryLoader.js',

部分文件因为文件数量过多而无法显示