From 1286e5171b6c1a2edff2b70c5df1eb823941a503 Mon Sep 17 00:00:00 2001 From: zz85 Date: Fri, 27 May 2011 05:09:20 -0700 Subject: [PATCH] inital import for THREE.Text and example --- build/Three.js | 841 +++++++++++++++-------------- build/custom/ThreeCanvas.js | 4 +- build/custom/ThreeDOM.js | 4 +- build/custom/ThreeExtras.js | 262 ++++----- build/custom/ThreeSVG.js | 4 +- build/custom/ThreeWebGL.js | 6 +- examples/canvas_geometry_text.html | 208 +++++++ src/core/Vector2.js | 19 + src/extras/geometries/Text.js | 690 +++++++++++++++++++++++ utils/build.py | 1 + 10 files changed, 1493 insertions(+), 546 deletions(-) create mode 100644 examples/canvas_geometry_text.html create mode 100644 src/extras/geometries/Text.js diff --git a/build/Three.js b/build/Three.js index 3cad5e9e..13fc2137 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,80 +1,80 @@ // Three.js r41/ROME - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}THREE.Color=function(b){this.setHex(b)}; -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,c){this.r=b;this.g=d;this.b=c;this.updateHex()},setHSV:function(b,d,c){var f,g,h,j,k,m;if(c==0)f=g=h=0;else{j=Math.floor(b*6);k=b*6-j;b=c*(1-d);m=c*(1-d*k);d=c*(1-d*(1-k));switch(j){case 1:f=m;g=c;h=b;break;case 2:f=b;g=c;h=d;break;case 3:f=b;g=m;h=c;break;case 4:f=d;g=b;h=c;break;case 5:f=c;g=b;h=m;break;case 6:case 0:f=c;g=d;h=b}}this.setRGB(f, -g,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(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,c){this.set(b||0,d||0,c||0)}; -THREE.Vector3.prototype={set:function(b,d,c){this.x=b;this.y=d;this.z=c;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,c=this.y,f=this.z;this.set(c*b.z-f*b.y,f*b.x-d*b.z,d*b.y-c*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,c=this.y-b.y;b=this.z-b.z;return d*d+c*c+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= -this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var d=Math.cos(this.y);this.y=Math.asin(b.n13);if(Math.abs(d)>1.0E-5){this.x=Math.atan2(-b.n23/d,b.n33/d);this.z=Math.atan2(-b.n12/d,b.n11/d)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< -1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,d,c,f){this.set(b||0,d||0,c||0,f||1)}; -THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* -b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var d,c,f,g=[];d=0;for(c=b.length;d0&&H>0&&O+H<1}var c,f,g,h,j,k,m,o,p,x,y,t=b.geometry,u=t.vertices,I=[];c=0;for(f=t.faces.length;c0:p<0)){o=o.dot((new THREE.Vector3).sub(h,x))/p;x=x.addSelf(y.multiplyScalar(o));if(g instanceof THREE.Face3){if(d(x,h,j,k)){g={distance:this.origin.distanceTo(x),point:x,face:g,object:b};I.push(g)}}else if(g instanceof THREE.Face4&&(d(x,h,j,m)||d(x,j,k,m))){g={distance:this.origin.distanceTo(x),point:x,face:g,object:b};I.push(g)}}}return I}}; -THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(m,o,p,x){k=!1;d=m;c=o;f=p;g=x;b()};this.addPoint=function(m,o){if(k){k=!1;d=m;c=o;f=m;g=o}else{d=dm?f:m;g=g>o?g:o}b()}; -this.add3Points=function(m,o,p,x,y,t){if(k){k=!1;d=mp?m>y?m:y:p>y?p:y;g=o>x?o>t?o:t:x>t?x:t}else{d=mp?m>y?m>f?m:f:y>f?y:f:p>y?p>f?p:f:y>f?y:f;g=o>x?o>t?o>g?o:g:t>g?t:g:x>t?x>g?x:g:t>g?t:g}b()};this.addRectangle=function(m){if(k){k=!1;d=m.getLeft();c=m.getTop();f=m.getRight();g=m.getBottom()}else{d=dm.getRight()? -f:m.getRight();g=g>m.getBottom()?g:m.getBottom()}b()};this.inflate=function(m){d-=m;c-=m;f+=m;g+=m;b()};this.minSelf=function(m){d=d>m.getLeft()?d:m.getLeft();c=c>m.getTop()?c:m.getTop();f=f=0&&Math.min(g,m.getBottom())-Math.max(c,m.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}}; -THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}}; -THREE.Matrix4=function(b,d,c,f,g,h,j,k,m,o,p,x,y,t,u,I){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,m||0,o||0,p||1,x||0,y||0,t||0,u||0,I||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,m,o,p,x,y,t,u,I){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=p;this.n34=x;this.n41=y;this.n42=t;this.n43=u;this.n44=I;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1, -g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23* -f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize(); -return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,x=b.n32,y=b.n33,t=b.n34,u=b.n41,I=b.n42,H=b.n43,C=b.n44,S=d.n11,E=d.n12,T=d.n13,O=d.n14,Q=d.n21,ya=d.n22, -aa=d.n23,ga=d.n24,X=d.n31,ha=d.n32,e=d.n33,Ja=d.n34;this.n11=c*S+f*Q+g*X;this.n12=c*E+f*ya+g*ha;this.n13=c*T+f*aa+g*e;this.n14=c*O+f*ga+g*Ja+h;this.n21=j*S+k*Q+m*X;this.n22=j*E+k*ya+m*ha;this.n23=j*T+k*aa+m*e;this.n24=j*O+k*ga+m*Ja+o;this.n31=p*S+x*Q+y*X;this.n32=p*E+x*ya+y*ha;this.n33=p*T+x*aa+y*e;this.n34=p*O+x*ga+y*Ja+t;this.n41=u*S+I*Q+H*X;this.n42=u*E+I*ya+H*ha;this.n43=u*T+I*aa+H*e;this.n44=u*O+I*ga+H*Ja+C;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=this.n21; +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,e,c){this.r=b;this.g=e;this.b=c;this.updateHex()},setHSV:function(b,e,c){var g,h,j,k,m,n;if(c==0)g=h=j=0;else{k=Math.floor(b*6);m=b*6-k;b=c*(1-e);n=c*(1-e*m);e=c*(1-e*(1-m));switch(k){case 1:g=n;h=c;j=b;break;case 2:g=b;h=c;j=e;break;case 3:g=b;h=n;j=c;break;case 4:g=e;h=b;j=c;break;case 5:g=c;h=b;j=n;break;case 6:case 0:g=c;h=e;j=b}}this.setRGB(g, +h,j)},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,e){this.set(b||0,e||0)}; +THREE.Vector2.prototype={set:function(b,e){this.x=b;this.y=e;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,e){this.set(b.x+e.x,b.y+e.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.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},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var e=this.x-b.x;b=this.y-b.y;return e*e+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,e,c){this.set(b||0,e||0,c||0)}; +THREE.Vector3.prototype={set:function(b,e,c){this.x=b;this.y=e;this.z=c;return this},copy:function(b){this.set(b.x,b.y,b.z);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y,b.z+e.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,e){this.set(b.x-e.x,b.y-e.y,b.z-e.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, +e){this.set(b.y*e.z-b.z*e.y,b.z*e.x-b.x*e.z,b.x*e.y-b.y*e.x);return this},crossSelf:function(b){var e=this.x,c=this.y,g=this.z;this.set(c*b.z-g*b.y,g*b.x-e*b.z,e*b.y-c*b.x);return this},multiply:function(b,e){this.set(b.x*e.x,b.y*e.y,b.z*e.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 e=this.x-b.x,c=this.y-b.y;b=this.z-b.z;return e*e+c*c+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= +this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var e=Math.cos(this.y);this.y=Math.asin(b.n13);if(Math.abs(e)>1.0E-5){this.x=Math.atan2(-b.n23/e,b.n33/e);this.z=Math.atan2(-b.n12/e,b.n11/e)}else{this.x=0;this.z=Math.atan2(b.n21,b.n22)}},setLength:function(b){return this.normalize().multiplyScalar(b)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)< +1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(b,e,c,g){this.set(b||0,e||0,c||0,g||1)}; +THREE.Vector4.prototype={set:function(b,e,c,g){this.x=b;this.y=e;this.z=c;this.w=g;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,e){this.set(b.x+e.x,b.y+e.y,b.z+e.z,b.w+e.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,e){this.set(b.x-e.x,b.y-e.y,b.z-e.z,b.w-e.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x* +b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,e){this.set(this.x+(b.x-this.x)*e,this.y+(b.y-this.y)*e,this.z+(b.z-this.z)*e,this.w+(b.w-this.w)*e)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,e){this.origin=b||new THREE.Vector3;this.direction=e||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var e,c,g,h=[];e=0;for(c=b.length;e0&&L>0&&P+L<1}var c,g,h,j,k,m,n,p,t,w,A,u=b.geometry,v=u.vertices,K=[];c=0;for(g=u.faces.length;c0:t<0)){p=p.dot((new THREE.Vector3).sub(j,w))/t;w=w.addSelf(A.multiplyScalar(p));if(h instanceof THREE.Face3){if(e(w,j,k,m)){h={distance:this.origin.distanceTo(w),point:w,face:h,object:b};K.push(h)}}else if(h instanceof THREE.Face4&&(e(w,j,k,n)||e(w,k,m,n))){h={distance:this.origin.distanceTo(w),point:w,face:h,object:b};K.push(h)}}}return K}}; +THREE.Rectangle=function(){function b(){j=g-e;k=h-c}var e,c,g,h,j,k,m=!0;this.getX=function(){return e};this.getY=function(){return c};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return e};this.getTop=function(){return c};this.getRight=function(){return g};this.getBottom=function(){return h};this.set=function(n,p,t,w){m=!1;e=n;c=p;g=t;h=w;b()};this.addPoint=function(n,p){if(m){m=!1;e=n;c=p;g=n;h=p}else{e=en?g:n;h=h>p?h:p}b()}; +this.add3Points=function(n,p,t,w,A,u){if(m){m=!1;e=nt?n>A?n:A:t>A?t:A;h=p>w?p>u?p:u:w>u?w:u}else{e=nt?n>A?n>g?n:g:A>g?A:g:t>A?t>g?t:g:A>g?A:g;h=p>w?p>u?p>h?p:h:u>h?u:h:w>u?w>h?w:h:u>h?u:h}b()};this.addRectangle=function(n){if(m){m=!1;e=n.getLeft();c=n.getTop();g=n.getRight();h=n.getBottom()}else{e=en.getRight()? +g:n.getRight();h=h>n.getBottom()?h:n.getBottom()}b()};this.inflate=function(n){e-=n;c-=n;g+=n;h+=n;b()};this.minSelf=function(n){e=e>n.getLeft()?e:n.getLeft();c=c>n.getTop()?c:n.getTop();g=g=0&&Math.min(h,n.getBottom())-Math.max(c,n.getTop())>=0};this.empty=function(){m=!0;h=g=c=e=0;b()};this.isEmpty=function(){return m}}; +THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,e=this.m;b=e[1];e[1]=e[3];e[3]=b;b=e[2];e[2]=e[6];e[6]=b;b=e[5];e[5]=e[7];e[7]=b;return this},transposeIntoArray:function(b){var e=this.m;b[0]=e[0];b[1]=e[3];b[2]=e[6];b[3]=e[1];b[4]=e[4];b[5]=e[7];b[6]=e[2];b[7]=e[5];b[8]=e[8];return this}}; +THREE.Matrix4=function(b,e,c,g,h,j,k,m,n,p,t,w,A,u,v,K){this.set(b||1,e||0,c||0,g||0,h||0,j||1,k||0,m||0,n||0,p||0,t||1,w||0,A||0,u||0,v||0,K||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,e,c,g,h,j,k,m,n,p,t,w,A,u,v,K){this.n11=b;this.n12=e;this.n13=c;this.n14=g;this.n21=h;this.n22=j;this.n23=k;this.n24=m;this.n31=n;this.n32=p;this.n33=t;this.n34=w;this.n41=A;this.n42=u;this.n43=v;this.n44=K;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,e,c){var g=THREE.Matrix4.__v1, +h=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,e).normalize();if(j.length()===0)j.z=1;g.cross(c,j).normalize();if(g.length()===0){j.x+=1.0E-4;g.cross(c,j).normalize()}h.cross(j,g).normalize();this.n11=g.x;this.n12=h.x;this.n13=j.x;this.n21=g.y;this.n22=h.y;this.n23=j.y;this.n31=g.z;this.n32=h.z;this.n33=j.z;return this},multiplyVector3:function(b){var e=b.x,c=b.y,g=b.z,h=1/(this.n41*e+this.n42*c+this.n43*g+this.n44);b.x=(this.n11*e+this.n12*c+this.n13*g+this.n14)*h;b.y=(this.n21*e+this.n22*c+this.n23* +g+this.n24)*h;b.z=(this.n31*e+this.n32*c+this.n33*g+this.n34)*h;return b},multiplyVector4:function(b){var e=b.x,c=b.y,g=b.z,h=b.w;b.x=this.n11*e+this.n12*c+this.n13*g+this.n14*h;b.y=this.n21*e+this.n22*c+this.n23*g+this.n24*h;b.z=this.n31*e+this.n32*c+this.n33*g+this.n34*h;b.w=this.n41*e+this.n42*c+this.n43*g+this.n44*h;return b},rotateAxis:function(b){var e=b.x,c=b.y,g=b.z;b.x=e*this.n11+c*this.n12+g*this.n13;b.y=e*this.n21+c*this.n22+g*this.n23;b.z=e*this.n31+c*this.n32+g*this.n33;b.normalize(); +return b},crossVector:function(b){var e=new THREE.Vector4;e.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;e.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;e.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;e.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return e},multiply:function(b,e){var c=b.n11,g=b.n12,h=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,t=b.n31,w=b.n32,A=b.n33,u=b.n34,v=b.n41,K=b.n42,L=b.n43,F=b.n44,T=e.n11,G=e.n12,V=e.n13,P=e.n14,R=e.n21,ya=e.n22, +da=e.n23,ja=e.n24,$=e.n31,ka=e.n32,f=e.n33,Ja=e.n34;this.n11=c*T+g*R+h*$;this.n12=c*G+g*ya+h*ka;this.n13=c*V+g*da+h*f;this.n14=c*P+g*ja+h*Ja+j;this.n21=k*T+m*R+n*$;this.n22=k*G+m*ya+n*ka;this.n23=k*V+m*da+n*f;this.n24=k*P+m*ja+n*Ja+p;this.n31=t*T+w*R+A*$;this.n32=t*G+w*ya+A*ka;this.n33=t*V+w*da+A*f;this.n34=t*P+w*ja+A*Ja+u;this.n41=v*T+K*R+L*$;this.n42=v*G+K*ya+L*ka;this.n43=v*V+K*da+L*f;this.n44=v*P+K*ja+L*Ja+F;return this},multiplyToArray:function(b,e,c){this.multiply(b,e);c[0]=this.n11;c[1]=this.n21; c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this}, -determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,p=this.n33,x=this.n34,y=this.n41,t=this.n42,u=this.n43,I=this.n44;return f*j*o*y-c*k*o*y-f*h*p*y+d*k*p*y+c*h*x*y-d*j*x*y-f*j*m*t+c*k*m*t+f*g*p*t-b*k*p*t-c*g*x*t+b*j*x*t+f*h*m*u-d*k*m*u-f*g*o*u+b*k*o*u+d*g*x*u-b*h*x*u-c*h*m*I+d*j*m*I+c*g*o*I-b*j*o*I-d*g*p*I+b*h*p*I},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13= +determinant:function(){var b=this.n11,e=this.n12,c=this.n13,g=this.n14,h=this.n21,j=this.n22,k=this.n23,m=this.n24,n=this.n31,p=this.n32,t=this.n33,w=this.n34,A=this.n41,u=this.n42,v=this.n43,K=this.n44;return g*k*p*A-c*m*p*A-g*j*t*A+e*m*t*A+c*j*w*A-e*k*w*A-g*k*n*u+c*m*n*u+g*h*t*u-b*m*t*u-c*h*w*u+b*k*w*u+g*j*n*v-e*m*n*v-g*h*p*v+b*m*p*v+e*h*w*v-b*j*w*v-c*j*n*K+e*k*n*K+c*h*p*K-b*k*p*K-e*h*t*K+b*j*t*K},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13= b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11; this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13; -b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,0,1);return this}, -setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=1-c,h=b.x,j=b.y,k= -b.z,m=g*h,o=g*j;this.set(m*h+c,m*j-f*k,m*k+f*j,0,m*j+f*k,o*j+c,o*k-f*h,0,m*k-f*j,o*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY= -new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+ -d*h;this.n33=b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var m=d*j;d*=k;var o=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(o+f);this.n12=m-g;this.n13=d+j;this.n21=m+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+o);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this}, -extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,x=b.n32,y=b.n33,t=b.n34,u=b.n41,I=b.n42,H=b.n43,C=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=m*t*I-o*y*I+o*x*H-k*t*H-m*x*C+k*y*C;d.n12=h*y*I-g*t*I-h*x*H+f*t*H+g*x*C-f*y*C;d.n13=g*o*I-h*m*I+h*k*H-f*o*H-g*k*C+f*m*C;d.n14=h*m*x-g*o*x-h*k*y+f*o*y+g*k*t-f*m*t;d.n21=o*y*u-m*t*u-o*p*H+j*t*H+m*p*C-j*y*C;d.n22=g*t*u-h*y*u+h*p*H-c*t*H-g*p*C+c*y*C;d.n23=h*m*u-g*o*u-h*j*H+c*o*H+g*j*C-c*m*C; -d.n24=g*o*p-h*m*p+h*j*y-c*o*y-g*j*t+c*m*t;d.n31=k*t*u-o*x*u+o*p*I-j*t*I-k*p*C+j*x*C;d.n32=h*x*u-f*t*u-h*p*I+c*t*I+f*p*C-c*x*C;d.n33=g*o*u-h*k*u+h*j*I-c*o*I-f*j*C+c*k*C;d.n34=h*k*p-f*o*p-h*j*x+c*o*x+f*j*t-c*k*t;d.n41=m*x*u-k*y*u-m*p*I+j*y*I+k*p*H-j*x*H;d.n42=f*y*u-g*x*u+g*p*I-c*y*I-f*p*H+c*x*H;d.n43=g*k*u-f*m*u-g*j*I+c*m*I+f*j*H-c*k*H;d.n44=f*m*p-g*k*p+g*j*x-c*m*x-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d}; -THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,x=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*o;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*m;c[6]=b*o;c[7]=b*p;c[8]=b*x;return d}; -THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)}; -THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,m,o;j=new THREE.Matrix4;k=d-b;m=c-f;o=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((c+f)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((h+g)/o);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; +b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,e){b[e]=this.n11;b[e+1]=this.n21;b[e+2]=this.n31;b[e+3]=this.n41;b[e+4]=this.n12;b[e+5]=this.n22;b[e+6]=this.n32;b[e+7]=this.n42;b[e+8]=this.n13;b[e+9]=this.n23;b[e+10]=this.n33;b[e+11]=this.n43;b[e+12]=this.n14;b[e+13]=this.n24;b[e+14]=this.n34;b[e+15]=this.n44;return b},setTranslation:function(b,e,c){this.set(1,0,0,b,0,1,0,e,0,0,1,c,0,0,0,1);return this}, +setScale:function(b,e,c){this.set(b,0,0,0,0,e,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,e,-b,0,0,b,e,0,0,0,0,1);return this},setRotationY:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(e,0,b,0,0,1,0,0,-b,0,e,0,0,0,0,1);return this},setRotationZ:function(b){var e=Math.cos(b);b=Math.sin(b);this.set(e,-b,0,0,b,e,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,e){var c=Math.cos(e),g=Math.sin(e),h=1-c,j=b.x,k=b.y,m= +b.z,n=h*j,p=h*k;this.set(n*j+c,n*k-g*m,n*m+g*k,0,n*k+g*m,p*k+c,p*m-g*j,0,n*m-g*k,p*m+g*j,h*m*m+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY= +new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b){var e=b.x,c=b.y,g=b.z;b=Math.cos(e);e=Math.sin(e);var h=Math.cos(c);c=Math.sin(c);var j=Math.cos(g);g=Math.sin(g);var k=b*c,m=e*c;this.n11=h*j;this.n12=-h*g;this.n13=c;this.n21=m*j+b*g;this.n22=-m*g+b*j;this.n23=-e*h;this.n31=-k*j+e*g;this.n32=k*g+ +e*j;this.n33=b*h;return this},setRotationFromQuaternion:function(b){var e=b.x,c=b.y,g=b.z,h=b.w,j=e+e,k=c+c,m=g+g;b=e*j;var n=e*k;e*=m;var p=c*k;c*=m;g*=m;j*=h;k*=h;h*=m;this.n11=1-(p+g);this.n12=n-h;this.n13=e+k;this.n21=n+h;this.n22=1-(b+g);this.n23=c-j;this.n31=e-k;this.n32=c+j;this.n33=1-(b+p);return this},scale:function(b){var e=b.x,c=b.y;b=b.z;this.n11*=e;this.n12*=c;this.n13*=b;this.n21*=e;this.n22*=c;this.n23*=b;this.n31*=e;this.n32*=c;this.n33*=b;this.n41*=e;this.n42*=c;this.n43*=b;return this}, +extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,e){var c=1/e.x,g=1/e.y,h=1/e.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*g;this.n22=b.n22*g;this.n32=b.n32*g;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}}; +THREE.Matrix4.makeInvert=function(b,e){var c=b.n11,g=b.n12,h=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,p=b.n24,t=b.n31,w=b.n32,A=b.n33,u=b.n34,v=b.n41,K=b.n42,L=b.n43,F=b.n44;e===undefined&&(e=new THREE.Matrix4);e.n11=n*u*K-p*A*K+p*w*L-m*u*L-n*w*F+m*A*F;e.n12=j*A*K-h*u*K-j*w*L+g*u*L+h*w*F-g*A*F;e.n13=h*p*K-j*n*K+j*m*L-g*p*L-h*m*F+g*n*F;e.n14=j*n*w-h*p*w-j*m*A+g*p*A+h*m*u-g*n*u;e.n21=p*A*v-n*u*v-p*t*L+k*u*L+n*t*F-k*A*F;e.n22=h*u*v-j*A*v+j*t*L-c*u*L-h*t*F+c*A*F;e.n23=j*n*v-h*p*v-j*k*L+c*p*L+h*k*F-c*n*F; +e.n24=h*p*t-j*n*t+j*k*A-c*p*A-h*k*u+c*n*u;e.n31=m*u*v-p*w*v+p*t*K-k*u*K-m*t*F+k*w*F;e.n32=j*w*v-g*u*v-j*t*K+c*u*K+g*t*F-c*w*F;e.n33=h*p*v-j*m*v+j*k*K-c*p*K-g*k*F+c*m*F;e.n34=j*m*t-g*p*t-j*k*w+c*p*w+g*k*u-c*m*u;e.n41=n*w*v-m*A*v-n*t*K+k*A*K+m*t*L-k*w*L;e.n42=g*A*v-h*w*v+h*t*K-c*A*K-g*t*L+c*w*L;e.n43=h*m*v-g*n*v-h*k*K+c*n*K+g*k*L-c*m*L;e.n44=g*n*t-h*m*t+h*k*w-c*n*w-g*k*A+c*m*A;e.multiplyScalar(1/b.determinant());return e}; +THREE.Matrix4.makeInvert3x3=function(b){var e=b.m33,c=e.m,g=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,t=-b.n23*b.n11+b.n21*b.n13,w=b.n22*b.n11-b.n21*b.n12;b=b.n11*g+b.n21*k+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*g;c[1]=b*h;c[2]=b*j;c[3]=b*k;c[4]=b*m;c[5]=b*n;c[6]=b*p;c[7]=b*t;c[8]=b*w;return e}; +THREE.Matrix4.makeFrustum=function(b,e,c,g,h,j){var k;k=new THREE.Matrix4;k.n11=2*h/(e-b);k.n12=0;k.n13=(e+b)/(e-b);k.n14=0;k.n21=0;k.n22=2*h/(g-c);k.n23=(g+c)/(g-c);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+h)/(j-h);k.n34=-2*j*h/(j-h);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,e,c,g){var h;b=c*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*e,b*e,h,b,c,g)}; +THREE.Matrix4.makeOrtho=function(b,e,c,g,h,j){var k,m,n,p;k=new THREE.Matrix4;m=e-b;n=c-g;p=j-h;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((e+b)/m);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((c+g)/n);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((j+h)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.dynamic=!1;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale= 1;this.visible=!0;this._vector=new THREE.Vector3;this.name=""}; -THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)=== --1){b.parent!==undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d.parent!==undefined;)d=d.parent;d!==undefined&&d instanceof THREE.Scene&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,1)}},getChildByName:function(b,d){var c,f,g;c=0;for(f=this.children.length;c=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.001){c.w=0.5*(b.w+d.w);c.x=0.5*(b.x+d.x);c.y=0.5*(b.y+d.y);c.z=0.5*(b.z+d.z);return c}g=Math.sin((1-f)*h)/j;f=Math.sin(f*h)/j;c.w=b.w*g+d.w*f;c.x=b.x*g+d.x*f;c.y=b.y*g+d.y*f;c.z=b.z*g+d.z*f;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; -THREE.Face3=function(b,d,c,f,g,h){this.a=b;this.b=d;this.c=c;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; -THREE.Face4=function(b,d,c,f,g,h,j){this.a=b;this.b=d;this.c=c;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)}; -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}; -THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;dthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; -if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;dthis.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;o=this.points[c[0]];p=this.points[c[1]]; -x=this.points[c[2]];y=this.points[c[3]];k=j*j;m=j*k;f.x=d(o.x,p.x,x.x,y.x,j,k,m);f.y=d(o.y,p.y,x.y,y.y,j,k,m);f.z=d(o.z,p.z,x.z,y.z,j,k,m);return f};this.getControlPointsArray=function(){var t,u,I=this.points.length,H=[];for(t=0;t=1){c.w=b.w;c.x=b.x;c.y=b.y;c.z=b.z;return c}var j=Math.acos(h),k=Math.sqrt(1-h*h);if(Math.abs(k)<0.0010){c.w=0.5*(b.w+e.w);c.x=0.5*(b.x+e.x);c.y=0.5*(b.y+e.y);c.z=0.5*(b.z+e.z);return c}h=Math.sin((1-g)*j)/k;g=Math.sin(g*j)/k;c.w=b.w*h+e.w*g;c.x=b.x*h+e.x*g;c.y=b.y*h+e.y*g;c.z=b.z*h+e.z*g;return c};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,e,c,g,h,j){this.a=b;this.b=e;this.c=c;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,e,c,g,h,j,k){this.a=b;this.b=e;this.c=c;this.d=g;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,e){this.set(b||0,e||0)}; +THREE.UV.prototype={set:function(b,e){this.u=b;this.v=e;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}; +THREE.Geometry.prototype={computeCentroids:function(){var b,e,c;b=0;for(e=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var e=1,c=this.vertices.length;ethis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x; +if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,e=0,c=this.vertices.length;ethis.points.length-2?j:j+1;c[3]=j>this.points.length-3?j:j+2;p=this.points[c[0]];t=this.points[c[1]]; +w=this.points[c[2]];A=this.points[c[3]];m=k*k;n=k*m;g.x=e(p.x,t.x,w.x,A.x,k,m,n);g.y=e(p.y,t.y,w.y,A.y,k,m,n);g.z=e(p.z,t.z,w.z,A.z,k,m,n);return g};this.getControlPointsArray=function(){var u,v,K=this.points.length,L=[];for(u=0;u1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance){this.LODs[f-1].object3D.visible= -!1;this.LODs[f].object3D.visible=!0}else break;for(;f1){b=c.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var g=1;g=this.LODs[g].visibleAtDistance){this.LODs[g-1].object3D.visible= +!1;this.LODs[g].object3D.visible=!0}else break;for(;gx){c=p;p=x;x=c}}else if(pt){c=y;y=t;t=c}}else if(yw){c=t;t=w;w=c}}else if(tu){c=A;A=u;u=c}}else if(A=0&&ca>=0&&ua>=0&&da>=0)return!0;else if(Da<0&&ca<0||ua<0&&da<0)return!1;else{if(Da<0)Ja=Math.max(Ja,Da/(Da-ca));else ca<0&&(ta=Math.min(ta,Da/(Da-ca)));if(ua<0)Ja=Math.max(Ja,ua/(ua-da));else da<0&&(ta=Math.min(ta,ua/(ua-da)));if(taDa&&j.positionScreen.z0&&O.z<1){xa=E[S]=E[S]||new THREE.RenderableParticle;S++;C=xa;C.x=O.x/O.w;C.y=O.y/O.w;C.z=O.z;C.rotation=fa.rotation.z;C.scale.x=fa.scale.x*Math.abs(C.x-(O.x+e.projectionMatrix.n11)/(O.w+e.projectionMatrix.n14));C.scale.y=fa.scale.y*Math.abs(C.y-(O.y+e.projectionMatrix.n22)/(O.w+e.projectionMatrix.n24));C.materials=fa.materials;ta.push(C)}}}}Ja&&ta.sort(d);return ta}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var m,o,p,x,y,t,u,I;b=d.projectScene(j,k);m=0;for(o=b.length;m>1;za=ma.height>>1;va=pa.scale.x*y;wa=pa.scale.y*t;qa=va*N;Ia=wa*za;D.set(R.x-qa,R.y-Ia,R.x+qa,R.y+Ia);if(lb.instersects(D)){u.save();u.translate(R.x,R.y);u.rotate(-pa.rotation);u.scale(va,-wa);u.translate(-N,-za);u.drawImage(ma,0,0);u.restore()}}}else if(va instanceof THREE.ParticleCanvasMaterial){qa=pa.scale.x*y;Ia=pa.scale.y*t;D.set(R.x-qa,R.y-Ia,R.x+qa,R.y+Ia);if(lb.instersects(D)){f(va.color);g(va.color);u.save(); -u.translate(R.x,R.y);u.rotate(-pa.rotation);u.scale(qa,Ia);va.program(u);u.restore()}}}function kb(R,pa,va,qa){d(qa.opacity);c(qa.blending);u.beginPath();u.moveTo(R.positionScreen.x,R.positionScreen.y);u.lineTo(pa.positionScreen.x,pa.positionScreen.y);u.closePath();if(qa instanceof THREE.LineBasicMaterial){R=qa.linewidth;if(O!=R)u.lineWidth=O=R;R=qa.linecap;if(Q!=R)u.lineCap=Q=R;R=qa.linejoin;if(ya!=R)u.lineJoin=ya=R;f(qa.color);u.stroke();D.inflate(qa.linewidth*2)}}function Ca(R,pa,va,qa,Ia,wa,ma, -N,za){j.data.vertices+=3;j.data.faces++;d(N.opacity);c(N.blending);ta=R.positionScreen.x;Da=R.positionScreen.y;ca=pa.positionScreen.x;ua=pa.positionScreen.y;da=va.positionScreen.x;sa=va.positionScreen.y;Ea(ta,Da,ca,ua,da,sa);if(N instanceof THREE.MeshBasicMaterial)if(N.map){if(N.map.mapping instanceof THREE.UVMapping){la=ma.uvs[0];w(ta,Da,ca,ua,da,sa,N.map.image,la[qa].u,la[qa].v,la[Ia].u,la[Ia].v,la[wa].u,la[wa].v)}}else if(N.envMap){if(N.envMap.mapping instanceof THREE.SphericalReflectionMapping){R= -Ka.matrixWorldInverse;G.copy(ma.vertexNormalsWorld[0]);Na=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;fb=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;G.copy(ma.vertexNormalsWorld[1]);hb=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;Ga=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;G.copy(ma.vertexNormalsWorld[2]);ka=(G.x*R.n11+G.y*R.n12+G.z*R.n13)*0.5+0.5;ub=-(G.x*R.n21+G.y*R.n22+G.z*R.n23)*0.5+0.5;w(ta,Da,ca,ua,da,sa,N.envMap.image,Na,fb,hb,Ga,ka,ub)}}else N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap, -N.wireframeLinejoin):$(N.color);else if(N instanceof THREE.MeshLambertMaterial){if(N.map&&!N.wireframe){if(N.map.mapping instanceof THREE.UVMapping){la=ma.uvs[0];w(ta,Da,ca,ua,da,sa,N.map.image,la[qa].u,la[qa].v,la[Ia].u,la[Ia].v,la[wa].u,la[wa].v)}c(THREE.SubtractiveBlending)}if(z)if(!N.wireframe&&N.shading==THREE.SmoothShading&&ma.vertexNormalsWorld.length==3){xa.r=Ma.r=Qa.r=A.r;xa.g=Ma.g=Qa.g=A.g;xa.b=Ma.b=Qa.b=A.b;La(za,ma.v1.positionWorld,ma.vertexNormalsWorld[0],xa);La(za,ma.v2.positionWorld, -ma.vertexNormalsWorld[1],Ma);La(za,ma.v3.positionWorld,ma.vertexNormalsWorld[2],Qa);Ua.r=(Ma.r+Qa.r)*0.5;Ua.g=(Ma.g+Qa.g)*0.5;Ua.b=(Ma.b+Qa.b)*0.5;ja=cb(xa,Ma,Qa,Ua);w(ta,Da,ca,ua,da,sa,ja,0,0,1,0,0,1)}else{v.r=A.r;v.g=A.g;v.b=A.b;La(za,ma.centroidWorld,ma.normalWorld,v);fa.r=Math.max(0,Math.min(N.color.r*v.r,1));fa.g=Math.max(0,Math.min(N.color.g*v.g,1));fa.b=Math.max(0,Math.min(N.color.b*v.b,1));fa.updateHex();N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else N.wireframe? -F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshDepthMaterial){L=Ka.near;Z=Ka.far;xa.r=xa.g=xa.b=1-gb(R.positionScreen.z,L,Z);Ma.r=Ma.g=Ma.b=1-gb(pa.positionScreen.z,L,Z);Qa.r=Qa.g=Qa.b=1-gb(va.positionScreen.z,L,Z);Ua.r=(Ma.r+Qa.r)*0.5;Ua.g=(Ma.g+Qa.g)*0.5;Ua.b=(Ma.b+Qa.b)*0.5;ja=cb(xa,Ma,Qa,Ua);w(ta,Da,ca,ua,da,sa,ja,0,0,1,0,0,1)}else if(N instanceof THREE.MeshNormalMaterial){fa.r=Va(ma.normalWorld.x);fa.g=Va(ma.normalWorld.y);fa.b= -Va(ma.normalWorld.z);fa.updateHex();N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}}function Ha(R,pa,va,qa,Ia,wa,ma,N,za){j.data.vertices+=4;j.data.faces++;d(N.opacity);c(N.blending);if(N.map||N.envMap){Ca(R,pa,qa,0,1,3,ma,N,za);Ca(Ia,va,wa,1,2,3,ma,N,za)}else{ta=R.positionScreen.x;Da=R.positionScreen.y;ca=pa.positionScreen.x;ua=pa.positionScreen.y;da=va.positionScreen.x;sa=va.positionScreen.y;na=qa.positionScreen.x;ra=qa.positionScreen.y;oa=Ia.positionScreen.x; -ea=Ia.positionScreen.y;Aa=wa.positionScreen.x;Oa=wa.positionScreen.y;if(N instanceof THREE.MeshBasicMaterial){Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshLambertMaterial)if(z)if(!N.wireframe&&N.shading==THREE.SmoothShading&&ma.vertexNormalsWorld.length==4){xa.r=Ma.r=Qa.r=Ua.r=A.r;xa.g=Ma.g=Qa.g=Ua.g=A.g;xa.b=Ma.b=Qa.b=Ua.b=A.b;La(za,ma.v1.positionWorld,ma.vertexNormalsWorld[0],xa);La(za,ma.v2.positionWorld, -ma.vertexNormalsWorld[1],Ma);La(za,ma.v4.positionWorld,ma.vertexNormalsWorld[3],Qa);La(za,ma.v3.positionWorld,ma.vertexNormalsWorld[2],Ua);ja=cb(xa,Ma,Qa,Ua);Ea(ta,Da,ca,ua,na,ra);w(ta,Da,ca,ua,na,ra,ja,0,0,1,0,0,1);Ea(oa,ea,da,sa,Aa,Oa);w(oa,ea,da,sa,Aa,Oa,ja,1,0,1,1,0,1)}else{v.r=A.r;v.g=A.g;v.b=A.b;La(za,ma.centroidWorld,ma.normalWorld,v);fa.r=Math.max(0,Math.min(N.color.r*v.r,1));fa.g=Math.max(0,Math.min(N.color.g*v.g,1));fa.b=Math.max(0,Math.min(N.color.b*v.b,1));fa.updateHex();Ta(ta,Da,ca,ua, -da,sa,na,ra);N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else{Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(N.color,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(N.color)}else if(N instanceof THREE.MeshNormalMaterial){fa.r=Va(ma.normalWorld.x);fa.g=Va(ma.normalWorld.y);fa.b=Va(ma.normalWorld.z);fa.updateHex();Ta(ta,Da,ca,ua,da,sa,na,ra);N.wireframe?F(fa,N.wireframeLinewidth,N.wireframeLinecap,N.wireframeLinejoin):$(fa)}else if(N instanceof THREE.MeshDepthMaterial){L= -Ka.near;Z=Ka.far;xa.r=xa.g=xa.b=1-gb(R.positionScreen.z,L,Z);Ma.r=Ma.g=Ma.b=1-gb(pa.positionScreen.z,L,Z);Qa.r=Qa.g=Qa.b=1-gb(qa.positionScreen.z,L,Z);Ua.r=Ua.g=Ua.b=1-gb(va.positionScreen.z,L,Z);ja=cb(xa,Ma,Qa,Ua);Ea(ta,Da,ca,ua,na,ra);w(ta,Da,ca,ua,na,ra,ja,0,0,1,0,0,1);Ea(oa,ea,da,sa,Aa,Oa);w(oa,ea,da,sa,Aa,Oa,ja,1,0,1,1,0,1)}}}function Ea(R,pa,va,qa,Ia,wa){u.beginPath();u.moveTo(R,pa);u.lineTo(va,qa);u.lineTo(Ia,wa);u.lineTo(R,pa);u.closePath()}function Ta(R,pa,va,qa,Ia,wa,ma,N){u.beginPath(); -u.moveTo(R,pa);u.lineTo(va,qa);u.lineTo(Ia,wa);u.lineTo(ma,N);u.lineTo(R,pa);u.closePath()}function F(R,pa,va,qa){if(O!=pa)u.lineWidth=O=pa;if(Q!=va)u.lineCap=Q=va;if(ya!=qa)u.lineJoin=ya=qa;f(R);u.stroke();D.inflate(pa*2)}function $(R){g(R);u.fill()}function w(R,pa,va,qa,Ia,wa,ma,N,za,Ra,Pa,ib,eb){var Za,$a;Za=ma.width-1;$a=ma.height-1;N*=Za;za*=$a;Ra*=Za;Pa*=$a;ib*=Za;eb*=$a;va-=R;qa-=pa;Ia-=R;wa-=pa;Ra-=N;Pa-=za;ib-=N;eb-=za;Za=Ra*eb-ib*Pa;if(Za!=0){$a=1/Za;Za=(eb*va-Pa*Ia)*$a;Pa=(eb*qa-Pa*wa)* -$a;va=(Ra*Ia-ib*va)*$a;qa=(Ra*wa-ib*qa)*$a;R=R-Za*N-va*za;pa=pa-Pa*N-qa*za;u.save();u.transform(Za,Pa,va,qa,R,pa);u.clip();u.drawImage(ma,0,0);u.restore()}}function cb(R,pa,va,qa){var Ia=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);var ma=~~(pa.r*255),N=~~(pa.g*255);pa=~~(pa.b*255);var za=~~(va.r*255),Ra=~~(va.g*255);va=~~(va.b*255);var Pa=~~(qa.r*255),ib=~~(qa.g*255);qa=~~(qa.b*255);K[0]=Ia<0?0:Ia>255?255:Ia;K[1]=wa<0?0:wa>255?255:wa;K[2]=R<0?0:R>255?255:R;K[4]=ma<0?0:ma>255?255:ma;K[5]=N<0?0:N>255? -255:N;K[6]=pa<0?0:pa>255?255:pa;K[8]=za<0?0:za>255?255:za;K[9]=Ra<0?0:Ra>255?255:Ra;K[10]=va<0?0:va>255?255:va;K[12]=Pa<0?0:Pa>255?255:Pa;K[13]=ib<0?0:ib>255?255:ib;K[14]=qa<0?0:qa>255?255:qa;Y.putImageData(B,0,0);ia.drawImage(U,0,0);return W}function gb(R,pa,va){R=(R-pa)/(va-pa);return R*R*(3-2*R)}function Va(R){R=(R+1)*0.5;return R<0?0:R>1?1:R}function Wa(R,pa){var va=pa.x-R.x,qa=pa.y-R.y,Ia=1/Math.sqrt(va*va+qa*qa);va*=Ia;qa*=Ia;pa.x+=va;pa.y+=qa;R.x-=va;R.y-=qa}var jb,mb,Fa,Xa,Sa,ab,Ya,P;this.autoClear? -this.clear():u.setTransform(1,0,0,-1,y,t);j.data.vertices=0;j.data.faces=0;k=m.projectScene(V,Ka,this.sortElements);(z=V.lights.length>0)&&Ba(V);jb=0;for(mb=k.length;jb=0&&ea>=0&&xa>=0&&ga>=0)return!0;else if(Da<0&&ea<0||xa<0&&ga<0)return!1;else{if(Da<0)Ja=Math.max(Ja,Da/(Da-ea));else ea<0&&(qa=Math.min(qa,Da/(Da-ea)));if(xa<0)Ja=Math.max(Ja,xa/(xa-ga));else ga<0&&(qa=Math.min(qa,xa/(xa-ga)));if(qaDa&&k.positionScreen.z0&&P.z<1){Ba=G[T]=G[T]||new THREE.RenderableParticle;T++;F=Ba;F.x=P.x/P.w;F.y=P.y/P.w;F.z=P.z;F.rotation=ia.rotation.z;F.scale.x=ia.scale.x*Math.abs(F.x-(P.x+f.projectionMatrix.n11)/(P.w+f.projectionMatrix.n14));F.scale.y=ia.scale.y*Math.abs(F.y-(P.y+f.projectionMatrix.n22)/(P.w+f.projectionMatrix.n24));F.materials=ia.materials;qa.push(F)}}}}Ja&&qa.sort(e);return qa}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,e=new THREE.Projector,c,g,h,j;this.domElement=document.createElement("div");this.setSize=function(k,m){c=k;g=m;h=c/2;j=g/2};this.render=function(k,m){var n,p,t,w,A,u,v,K;b=e.projectScene(k,m);n=0;for(p=b.length;n>1;Ca=sa.height>>1;za=ta.scale.x*A;Aa=ta.scale.y*u;va=za*S;Ma=Aa*Ca;H.set(W.x-va,W.y-Ma,W.x+va,W.y+Ma);if(ob.instersects(H)){v.save();v.translate(W.x,W.y);v.rotate(-ta.rotation);v.scale(za,-Aa);v.translate(-S,-Ca);v.drawImage(sa,0,0);v.restore()}}}else if(za instanceof THREE.ParticleCanvasMaterial){va=ta.scale.x*A;Ma=ta.scale.y*u;H.set(W.x-va,W.y-Ma,W.x+va,W.y+Ma);if(ob.instersects(H)){g(za.color); +h(za.color);v.save();v.translate(W.x,W.y);v.rotate(-ta.rotation);v.scale(va,Ma);za.program(v);v.restore()}}}function nb(W,ta,za,va){e(va.opacity);c(va.blending);v.beginPath();v.moveTo(W.positionScreen.x,W.positionScreen.y);v.lineTo(ta.positionScreen.x,ta.positionScreen.y);v.closePath();if(va instanceof THREE.LineBasicMaterial){W=va.linewidth;if(P!=W)v.lineWidth=P=W;W=va.linecap;if(R!=W)v.lineCap=R=W;W=va.linejoin;if(ya!=W)v.lineJoin=ya=W;g(va.color);v.stroke();H.inflate(va.linewidth*2)}}function Ga(W, +ta,za,va,Ma,Aa,sa,S,Ca){k.data.vertices+=3;k.data.faces++;e(S.opacity);c(S.blending);qa=W.positionScreen.x;Da=W.positionScreen.y;ea=ta.positionScreen.x;xa=ta.positionScreen.y;ga=za.positionScreen.x;wa=za.positionScreen.y;Ha(qa,Da,ea,xa,ga,wa);if(S instanceof THREE.MeshBasicMaterial)if(S.map){if(S.map.mapping instanceof THREE.UVMapping){ra=sa.uvs[0];B(qa,Da,ea,xa,ga,wa,S.map.image,ra[va].u,ra[va].v,ra[Ma].u,ra[Ma].v,ra[Aa].u,ra[Aa].v)}}else if(S.envMap){if(S.envMap.mapping instanceof THREE.SphericalReflectionMapping){W= +Na.matrixWorldInverse;J.copy(sa.vertexNormalsWorld[0]);Qa=(J.x*W.n11+J.y*W.n12+J.z*W.n13)*0.5+0.5;ib=-(J.x*W.n21+J.y*W.n22+J.z*W.n23)*0.5+0.5;J.copy(sa.vertexNormalsWorld[1]);kb=(J.x*W.n11+J.y*W.n12+J.z*W.n13)*0.5+0.5;Ka=-(J.x*W.n21+J.y*W.n22+J.z*W.n23)*0.5+0.5;J.copy(sa.vertexNormalsWorld[2]);pa=(J.x*W.n11+J.y*W.n12+J.z*W.n13)*0.5+0.5;xb=-(J.x*W.n21+J.y*W.n22+J.z*W.n23)*0.5+0.5;B(qa,Da,ea,xa,ga,wa,S.envMap.image,Qa,ib,kb,Ka,pa,xb)}}else S.wireframe?I(S.color,S.wireframeLinewidth,S.wireframeLinecap, +S.wireframeLinejoin):fa(S.color);else if(S instanceof THREE.MeshLambertMaterial){if(S.map&&!S.wireframe){if(S.map.mapping instanceof THREE.UVMapping){ra=sa.uvs[0];B(qa,Da,ea,xa,ga,wa,S.map.image,ra[va].u,ra[va].v,ra[Ma].u,ra[Ma].v,ra[Aa].u,ra[Aa].v)}c(THREE.SubtractiveBlending)}if(C)if(!S.wireframe&&S.shading==THREE.SmoothShading&&sa.vertexNormalsWorld.length==3){Ba.r=Pa.r=Ta.r=D.r;Ba.g=Pa.g=Ta.g=D.g;Ba.b=Pa.b=Ta.b=D.b;Oa(Ca,sa.v1.positionWorld,sa.vertexNormalsWorld[0],Ba);Oa(Ca,sa.v2.positionWorld, +sa.vertexNormalsWorld[1],Pa);Oa(Ca,sa.v3.positionWorld,sa.vertexNormalsWorld[2],Ta);Xa.r=(Pa.r+Ta.r)*0.5;Xa.g=(Pa.g+Ta.g)*0.5;Xa.b=(Pa.b+Ta.b)*0.5;ma=fb(Ba,Pa,Ta,Xa);B(qa,Da,ea,xa,ga,wa,ma,0,0,1,0,0,1)}else{z.r=D.r;z.g=D.g;z.b=D.b;Oa(Ca,sa.centroidWorld,sa.normalWorld,z);ia.r=Math.max(0,Math.min(S.color.r*z.r,1));ia.g=Math.max(0,Math.min(S.color.g*z.g,1));ia.b=Math.max(0,Math.min(S.color.b*z.b,1));ia.updateHex();S.wireframe?I(ia,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(ia)}else S.wireframe? +I(S.color,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(S.color)}else if(S instanceof THREE.MeshDepthMaterial){O=Na.near;ca=Na.far;Ba.r=Ba.g=Ba.b=1-jb(W.positionScreen.z,O,ca);Pa.r=Pa.g=Pa.b=1-jb(ta.positionScreen.z,O,ca);Ta.r=Ta.g=Ta.b=1-jb(za.positionScreen.z,O,ca);Xa.r=(Pa.r+Ta.r)*0.5;Xa.g=(Pa.g+Ta.g)*0.5;Xa.b=(Pa.b+Ta.b)*0.5;ma=fb(Ba,Pa,Ta,Xa);B(qa,Da,ea,xa,ga,wa,ma,0,0,1,0,0,1)}else if(S instanceof THREE.MeshNormalMaterial){ia.r=Ya(sa.normalWorld.x);ia.g=Ya(sa.normalWorld.y); +ia.b=Ya(sa.normalWorld.z);ia.updateHex();S.wireframe?I(ia,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(ia)}}function La(W,ta,za,va,Ma,Aa,sa,S,Ca){k.data.vertices+=4;k.data.faces++;e(S.opacity);c(S.blending);if(S.map||S.envMap){Ga(W,ta,va,0,1,3,sa,S,Ca);Ga(Ma,za,Aa,1,2,3,sa,S,Ca)}else{qa=W.positionScreen.x;Da=W.positionScreen.y;ea=ta.positionScreen.x;xa=ta.positionScreen.y;ga=za.positionScreen.x;wa=za.positionScreen.y;na=va.positionScreen.x;ua=va.positionScreen.y;oa=Ma.positionScreen.x; +ha=Ma.positionScreen.y;Ea=Aa.positionScreen.x;Ra=Aa.positionScreen.y;if(S instanceof THREE.MeshBasicMaterial){Wa(qa,Da,ea,xa,ga,wa,na,ua);S.wireframe?I(S.color,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(S.color)}else if(S instanceof THREE.MeshLambertMaterial)if(C)if(!S.wireframe&&S.shading==THREE.SmoothShading&&sa.vertexNormalsWorld.length==4){Ba.r=Pa.r=Ta.r=Xa.r=D.r;Ba.g=Pa.g=Ta.g=Xa.g=D.g;Ba.b=Pa.b=Ta.b=Xa.b=D.b;Oa(Ca,sa.v1.positionWorld,sa.vertexNormalsWorld[0],Ba);Oa(Ca,sa.v2.positionWorld, +sa.vertexNormalsWorld[1],Pa);Oa(Ca,sa.v4.positionWorld,sa.vertexNormalsWorld[3],Ta);Oa(Ca,sa.v3.positionWorld,sa.vertexNormalsWorld[2],Xa);ma=fb(Ba,Pa,Ta,Xa);Ha(qa,Da,ea,xa,na,ua);B(qa,Da,ea,xa,na,ua,ma,0,0,1,0,0,1);Ha(oa,ha,ga,wa,Ea,Ra);B(oa,ha,ga,wa,Ea,Ra,ma,1,0,1,1,0,1)}else{z.r=D.r;z.g=D.g;z.b=D.b;Oa(Ca,sa.centroidWorld,sa.normalWorld,z);ia.r=Math.max(0,Math.min(S.color.r*z.r,1));ia.g=Math.max(0,Math.min(S.color.g*z.g,1));ia.b=Math.max(0,Math.min(S.color.b*z.b,1));ia.updateHex();Wa(qa,Da,ea,xa, +ga,wa,na,ua);S.wireframe?I(ia,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(ia)}else{Wa(qa,Da,ea,xa,ga,wa,na,ua);S.wireframe?I(S.color,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(S.color)}else if(S instanceof THREE.MeshNormalMaterial){ia.r=Ya(sa.normalWorld.x);ia.g=Ya(sa.normalWorld.y);ia.b=Ya(sa.normalWorld.z);ia.updateHex();Wa(qa,Da,ea,xa,ga,wa,na,ua);S.wireframe?I(ia,S.wireframeLinewidth,S.wireframeLinecap,S.wireframeLinejoin):fa(ia)}else if(S instanceof THREE.MeshDepthMaterial){O= +Na.near;ca=Na.far;Ba.r=Ba.g=Ba.b=1-jb(W.positionScreen.z,O,ca);Pa.r=Pa.g=Pa.b=1-jb(ta.positionScreen.z,O,ca);Ta.r=Ta.g=Ta.b=1-jb(va.positionScreen.z,O,ca);Xa.r=Xa.g=Xa.b=1-jb(za.positionScreen.z,O,ca);ma=fb(Ba,Pa,Ta,Xa);Ha(qa,Da,ea,xa,na,ua);B(qa,Da,ea,xa,na,ua,ma,0,0,1,0,0,1);Ha(oa,ha,ga,wa,Ea,Ra);B(oa,ha,ga,wa,Ea,Ra,ma,1,0,1,1,0,1)}}}function Ha(W,ta,za,va,Ma,Aa){v.beginPath();v.moveTo(W,ta);v.lineTo(za,va);v.lineTo(Ma,Aa);v.lineTo(W,ta);v.closePath()}function Wa(W,ta,za,va,Ma,Aa,sa,S){v.beginPath(); +v.moveTo(W,ta);v.lineTo(za,va);v.lineTo(Ma,Aa);v.lineTo(sa,S);v.lineTo(W,ta);v.closePath()}function I(W,ta,za,va){if(P!=ta)v.lineWidth=P=ta;if(R!=za)v.lineCap=R=za;if(ya!=va)v.lineJoin=ya=va;g(W);v.stroke();H.inflate(ta*2)}function fa(W){h(W);v.fill()}function B(W,ta,za,va,Ma,Aa,sa,S,Ca,Ua,Sa,lb,hb){var bb,cb;bb=sa.width-1;cb=sa.height-1;S*=bb;Ca*=cb;Ua*=bb;Sa*=cb;lb*=bb;hb*=cb;za-=W;va-=ta;Ma-=W;Aa-=ta;Ua-=S;Sa-=Ca;lb-=S;hb-=Ca;bb=Ua*hb-lb*Sa;if(bb!=0){cb=1/bb;bb=(hb*za-Sa*Ma)*cb;Sa=(hb*va-Sa*Aa)* +cb;za=(Ua*Ma-lb*za)*cb;va=(Ua*Aa-lb*va)*cb;W=W-bb*S-za*Ca;ta=ta-Sa*S-va*Ca;v.save();v.transform(bb,Sa,za,va,W,ta);v.clip();v.drawImage(sa,0,0);v.restore()}}function fb(W,ta,za,va){var Ma=~~(W.r*255),Aa=~~(W.g*255);W=~~(W.b*255);var sa=~~(ta.r*255),S=~~(ta.g*255);ta=~~(ta.b*255);var Ca=~~(za.r*255),Ua=~~(za.g*255);za=~~(za.b*255);var Sa=~~(va.r*255),lb=~~(va.g*255);va=~~(va.b*255);N[0]=Ma<0?0:Ma>255?255:Ma;N[1]=Aa<0?0:Aa>255?255:Aa;N[2]=W<0?0:W>255?255:W;N[4]=sa<0?0:sa>255?255:sa;N[5]=S<0?0:S>255? +255:S;N[6]=ta<0?0:ta>255?255:ta;N[8]=Ca<0?0:Ca>255?255:Ca;N[9]=Ua<0?0:Ua>255?255:Ua;N[10]=za<0?0:za>255?255:za;N[12]=Sa<0?0:Sa>255?255:Sa;N[13]=lb<0?0:lb>255?255:lb;N[14]=va<0?0:va>255?255:va;aa.putImageData(E,0,0);la.drawImage(X,0,0);return Z}function jb(W,ta,za){W=(W-ta)/(za-ta);return W*W*(3-2*W)}function Ya(W){W=(W+1)*0.5;return W<0?0:W>1?1:W}function Za(W,ta){var za=ta.x-W.x,va=ta.y-W.y,Ma=1/Math.sqrt(za*za+va*va);za*=Ma;va*=Ma;ta.x+=za;ta.y+=va;W.x-=za;W.y-=va}var mb,pb,Ia,$a,Va,db,ab,U;this.autoClear? +this.clear():v.setTransform(1,0,0,-1,A,u);k.data.vertices=0;k.data.faces=0;m=n.projectScene(Y,Na,this.sortElements);(C=Y.lights.length>0)&&Fa(Y);mb=0;for(pb=m.length;mb0){na.r+=ea.color.r*Aa;na.g+=ea.color.g*Aa;na.b+=ea.color.b*Aa}}else if(ea instanceof THREE.PointLight){ha.sub(ea.position,sa.centroidWorld);ha.normalize();Aa=sa.normalWorld.dot(ha)*ea.intensity;if(Aa>0){na.r+=ea.color.r*Aa;na.g+=ea.color.g*Aa;na.b+=ea.color.b*Aa}}}}function d(da,sa, -na,ra,oa,ea){j.data.vertices+=3;j.data.faces++;ta=f(Da++);ta.setAttribute("d","M "+da.positionScreen.x+" "+da.positionScreen.y+" L "+sa.positionScreen.x+" "+sa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");if(oa instanceof THREE.MeshBasicMaterial)O.hex=oa.color.hex;else if(oa instanceof THREE.MeshLambertMaterial)if(T){Q.r=ya.r;Q.g=ya.g;Q.b=ya.b;b(ea,ra,Q);O.r=Math.max(0,Math.min(oa.color.r*Q.r,1));O.g=Math.max(0,Math.min(oa.color.g*Q.g,1));O.b=Math.max(0,Math.min(oa.color.b* -Q.b,1));O.updateHex()}else O.hex=oa.color.hex;else if(oa instanceof THREE.MeshDepthMaterial){X=1-oa.__2near/(oa.__farPlusNear-ra.z*oa.__farMinusNear);O.setRGB(X,X,X)}else oa instanceof THREE.MeshNormalMaterial&&O.setRGB(g(ra.normalWorld.x),g(ra.normalWorld.y),g(ra.normalWorld.z));oa.wireframe?ta.setAttribute("style","fill: none; stroke: #"+h(O.hex.toString(16))+"; stroke-width: "+oa.wireframeLinewidth+"; stroke-opacity: "+oa.opacity+"; stroke-linecap: "+oa.wireframeLinecap+"; stroke-linejoin: "+oa.wireframeLinejoin): -ta.setAttribute("style","fill: #"+h(O.hex.toString(16))+"; fill-opacity: "+oa.opacity);o.appendChild(ta)}function c(da,sa,na,ra,oa,ea,Aa){j.data.vertices+=4;j.data.faces++;ta=f(Da++);ta.setAttribute("d","M "+da.positionScreen.x+" "+da.positionScreen.y+" L "+sa.positionScreen.x+" "+sa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(ea instanceof THREE.MeshBasicMaterial)O.hex=ea.color.hex;else if(ea instanceof THREE.MeshLambertMaterial)if(T){Q.r= -ya.r;Q.g=ya.g;Q.b=ya.b;b(Aa,oa,Q);O.r=Math.max(0,Math.min(ea.color.r*Q.r,1));O.g=Math.max(0,Math.min(ea.color.g*Q.g,1));O.b=Math.max(0,Math.min(ea.color.b*Q.b,1));O.updateHex()}else O.hex=ea.color.hex;else if(ea instanceof THREE.MeshDepthMaterial){X=1-ea.__2near/(ea.__farPlusNear-oa.z*ea.__farMinusNear);O.setRGB(X,X,X)}else ea instanceof THREE.MeshNormalMaterial&&O.setRGB(g(oa.normalWorld.x),g(oa.normalWorld.y),g(oa.normalWorld.z));ea.wireframe?ta.setAttribute("style","fill: none; stroke: #"+h(O.hex.toString(16))+ -"; stroke-width: "+ea.wireframeLinewidth+"; stroke-opacity: "+ea.opacity+"; stroke-linecap: "+ea.wireframeLinecap+"; stroke-linejoin: "+ea.wireframeLinejoin):ta.setAttribute("style","fill: #"+h(O.hex.toString(16))+"; fill-opacity: "+ea.opacity);o.appendChild(ta)}function f(da){if(e[da]==null){e[da]=document.createElementNS("http://www.w3.org/2000/svg","path");ua==0&&e[da].setAttribute("shape-rendering","crispEdges")}return e[da]}function g(da){da=(da+1)*0.5;return da<0?0:da>1?1:da}function h(da){for(;da.length< -6;)da="0"+da;return da}var j=this,k=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,x,y,t,u,I,H,C,S=new THREE.Rectangle,E=new THREE.Rectangle,T=!1,O=new THREE.Color(16777215),Q=new THREE.Color(16777215),ya=new THREE.Color(0),aa=new THREE.Color(0),ga=new THREE.Color(0),X,ha=new THREE.Vector3,e=[],Ja=[],ta,Da,ca,ua=1;this.domElement=o;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(da){switch(da){case "high":ua= -1;break;case "low":ua=0}};this.setSize=function(da,sa){p=da;x=sa;y=p/2;t=x/2;o.setAttribute("viewBox",-y+" "+-t+" "+p+" "+x);o.setAttribute("width",p);o.setAttribute("height",x);S.set(-y,-t,y,t)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(da,sa){var na,ra,oa,ea,Aa,Oa,fa,xa;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(da,sa,this.sortElements);ca=Da=0;if(T=da.lights.length>0){fa=da.lights;ya.setRGB(0,0,0); -aa.setRGB(0,0,0);ga.setRGB(0,0,0);na=0;for(ra=fa.length;na0){na.r+=ha.color.r*Ea;na.g+=ha.color.g*Ea;na.b+=ha.color.b*Ea}}else if(ha instanceof THREE.PointLight){ka.sub(ha.position,wa.centroidWorld);ka.normalize();Ea=wa.normalWorld.dot(ka)*ha.intensity;if(Ea>0){na.r+=ha.color.r*Ea;na.g+=ha.color.g*Ea;na.b+=ha.color.b*Ea}}}}function e(ga,wa, +na,ua,oa,ha){k.data.vertices+=3;k.data.faces++;qa=g(Da++);qa.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+wa.positionScreen.x+" "+wa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+"z");if(oa instanceof THREE.MeshBasicMaterial)P.hex=oa.color.hex;else if(oa instanceof THREE.MeshLambertMaterial)if(V){R.r=ya.r;R.g=ya.g;R.b=ya.b;b(ha,ua,R);P.r=Math.max(0,Math.min(oa.color.r*R.r,1));P.g=Math.max(0,Math.min(oa.color.g*R.g,1));P.b=Math.max(0,Math.min(oa.color.b* +R.b,1));P.updateHex()}else P.hex=oa.color.hex;else if(oa instanceof THREE.MeshDepthMaterial){$=1-oa.__2near/(oa.__farPlusNear-ua.z*oa.__farMinusNear);P.setRGB($,$,$)}else oa instanceof THREE.MeshNormalMaterial&&P.setRGB(h(ua.normalWorld.x),h(ua.normalWorld.y),h(ua.normalWorld.z));oa.wireframe?qa.setAttribute("style","fill: none; stroke: #"+j(P.hex.toString(16))+"; stroke-width: "+oa.wireframeLinewidth+"; stroke-opacity: "+oa.opacity+"; stroke-linecap: "+oa.wireframeLinecap+"; stroke-linejoin: "+oa.wireframeLinejoin): +qa.setAttribute("style","fill: #"+j(P.hex.toString(16))+"; fill-opacity: "+oa.opacity);p.appendChild(qa)}function c(ga,wa,na,ua,oa,ha,Ea){k.data.vertices+=4;k.data.faces++;qa=g(Da++);qa.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+wa.positionScreen.x+" "+wa.positionScreen.y+" L "+na.positionScreen.x+","+na.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(ha instanceof THREE.MeshBasicMaterial)P.hex=ha.color.hex;else if(ha instanceof THREE.MeshLambertMaterial)if(V){R.r= +ya.r;R.g=ya.g;R.b=ya.b;b(Ea,oa,R);P.r=Math.max(0,Math.min(ha.color.r*R.r,1));P.g=Math.max(0,Math.min(ha.color.g*R.g,1));P.b=Math.max(0,Math.min(ha.color.b*R.b,1));P.updateHex()}else P.hex=ha.color.hex;else if(ha instanceof THREE.MeshDepthMaterial){$=1-ha.__2near/(ha.__farPlusNear-oa.z*ha.__farMinusNear);P.setRGB($,$,$)}else ha instanceof THREE.MeshNormalMaterial&&P.setRGB(h(oa.normalWorld.x),h(oa.normalWorld.y),h(oa.normalWorld.z));ha.wireframe?qa.setAttribute("style","fill: none; stroke: #"+j(P.hex.toString(16))+ +"; stroke-width: "+ha.wireframeLinewidth+"; stroke-opacity: "+ha.opacity+"; stroke-linecap: "+ha.wireframeLinecap+"; stroke-linejoin: "+ha.wireframeLinejoin):qa.setAttribute("style","fill: #"+j(P.hex.toString(16))+"; fill-opacity: "+ha.opacity);p.appendChild(qa)}function g(ga){if(f[ga]==null){f[ga]=document.createElementNS("http://www.w3.org/2000/svg","path");xa==0&&f[ga].setAttribute("shape-rendering","crispEdges")}return f[ga]}function h(ga){ga=(ga+1)*0.5;return ga<0?0:ga>1?1:ga}function j(ga){for(;ga.length< +6;)ga="0"+ga;return ga}var k=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,w,A,u,v,K,L,F,T=new THREE.Rectangle,G=new THREE.Rectangle,V=!1,P=new THREE.Color(16777215),R=new THREE.Color(16777215),ya=new THREE.Color(0),da=new THREE.Color(0),ja=new THREE.Color(0),$,ka=new THREE.Vector3,f=[],Ja=[],qa,Da,ea,xa=1;this.domElement=p;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.data={vertices:0,faces:0};this.setQuality=function(ga){switch(ga){case "high":xa= +1;break;case "low":xa=0}};this.setSize=function(ga,wa){t=ga;w=wa;A=t/2;u=w/2;p.setAttribute("viewBox",-A+" "+-u+" "+t+" "+w);p.setAttribute("width",t);p.setAttribute("height",w);T.set(-A,-u,A,u)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(ga,wa){var na,ua,oa,ha,Ea,Ra,ia,Ba;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;m=n.projectScene(ga,wa,this.sortElements);ea=Da=0;if(V=ga.lights.length>0){ia=ga.lights;ya.setRGB(0,0,0); +da.setRGB(0,0,0);ja.setRGB(0,0,0);na=0;for(ua=ia.length;na 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + vViewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", -default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif"};THREE.UniformsUtils={merge:function(b){var d,c,f,g={};for(d=0;d=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(n.position,3,e.FLOAT,!1,0,0)}else{D=v.program.attributes;if(M.morphTargetBase!==-1){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[M.morphTargetBase]); -e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0)}else if(D.position>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0)}if(M.morphTargetForcedOrder.length){z=0;for(var G=M.morphTargetForcedOrder,U=M.morphTargetInfluences;zY){B=K;Y=U[B]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[B]);e.vertexAttribPointer(D["morphTarget"+z],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[z]=Y;G[B]=1;Y=-1;z++}}v.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(v.program.uniforms.morphTargetInfluences,M.__webglMorphTargetInfluences)}if(v.attributes)for(J in v.attributes)if(n[J]!== -undefined&&n[J]>=0){D=v.attributes[J];if(D.buffer){e.bindBuffer(e.ARRAY_BUFFER,D.buffer);e.vertexAttribPointer(n[J],D.size,e.FLOAT,!1,0,0)}}if(n.color>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglColorBuffer);e.vertexAttribPointer(n.color,3,e.FLOAT,!1,0,0)}if(n.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglNormalBuffer);e.vertexAttribPointer(n.normal,3,e.FLOAT,!1,0,0)}if(n.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglTangentBuffer);e.vertexAttribPointer(n.tangent,4,e.FLOAT,!1,0,0)}if(n.uv>=0)if(A.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER, -A.__webglUVBuffer);e.vertexAttribPointer(n.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv)}else e.disableVertexAttribArray(n.uv);if(n.uv2>=0)if(A.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,A.__webglUV2Buffer);e.vertexAttribPointer(n.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(n.uv2)}else e.disableVertexAttribArray(n.uv2);if(v.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexABuffer);e.vertexAttribPointer(n.skinVertexA, -4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexBBuffer);e.vertexAttribPointer(n.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinIndicesBuffer);e.vertexAttribPointer(n.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinWeightsBuffer);e.vertexAttribPointer(n.skinWeight,4,e.FLOAT,!1,0,0)}if(M instanceof THREE.Mesh){if(v.wireframe){e.lineWidth(v.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglLineBuffer);e.drawElements(e.LINES, -A.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglFaceBuffer);e.drawElements(e.TRIANGLES,A.__webglFaceCount,e.UNSIGNED_SHORT,0)}ha.data.vertices+=A.__webglFaceCount;ha.data.faces+=A.__webglFaceCount/3;ha.data.drawCalls++}else if(M instanceof THREE.Line){M=M.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(M,0,A.__webglLineCount);ha.data.drawCalls++}else if(M instanceof THREE.ParticleSystem){e.drawArrays(e.POINTS,0,A.__webglParticleCount); -ha.data.drawCalls++}else if(M instanceof THREE.Ribbon){e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount);ha.data.drawCalls++}}}function g(n,D,z){if(!n.__webglVertexBuffer)n.__webglVertexBuffer=e.createBuffer();if(!n.__webglNormalBuffer)n.__webglNormalBuffer=e.createBuffer();if(n.hasPos){e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(D.attributes.position);e.vertexAttribPointer(D.attributes.position,3,e.FLOAT, -!1,0,0)}if(n.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer);if(z==THREE.FlatShading){var v,A,M,J,G,U,Y,B,K,W,ia=n.count*3;for(W=0;W0&&Ka[0]0&&Ka[1]< -Aa){e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGB,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ba.renderType,0);e.uniform2fv(Ba.scale,ia);e.uniform3fv(Ba.screenPosition,V);e.disable(e.BLEND);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.bindTexture(e.TEXTURE_2D,ka.occlusionTexture);e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,Ka[0]-8,Ka[1]-8,16,16,0);e.uniform1i(Ba.renderType,1);e.disable(e.DEPTH_TEST);e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.drawElements(e.TRIANGLES, -6,e.UNSIGNED_SHORT,0);z.positionScreen.x=V[0];z.positionScreen.y=V[1];z.positionScreen.z=V[2];z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();e.uniform1i(Ba.renderType,2);e.enable(e.BLEND);M=0;for(J=z.lensFlares.length;M0.001&&G.scale>0.001){V[0]=G.x;V[1]=G.y;V[2]=G.z;W=G.size*G.scale/Aa;ia[0]=W*Y;ia[1]=W;e.uniform3fv(Ba.screenPosition,V);e.uniform2fv(Ba.scale,ia);e.uniform1f(Ba.rotation,G.rotation);e.uniform1f(Ba.opacity,G.opacity);T(G.blending); -Q(G.texture,1);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ca)}function H(n,D){n._modelViewMatrix.multiplyToArray(D.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(n._modelViewMatrix).transposeIntoArray(n._normalMatrixArray)}function C(n){var D,z,v,A,M;if(n instanceof THREE.Mesh){z=n.geometry;for(D in z.geometryGroups){v=z.geometryGroups[D];M=!1;for(A in v.__webglCustomAttributes)if(v.__webglCustomAttributes[A].needsUpdate){M= -!0;break}if(z.__dirtyVertices||z.__dirtyMorphTargets||z.__dirtyElements||z.__dirtyUvs||z.__dirtyNormals||z.__dirtyColors||z.__dirtyTangents||M){M=n;var J=e.DYNAMIC_DRAW;if(v.__inittedArrays){var G=void 0,U=void 0,Y=void 0,B=void 0;Y=void 0;var K=void 0,W=void 0,ia=void 0,V=void 0,Ka=void 0,Ba=void 0,La=void 0,bb=void 0,kb=void 0,Ca=void 0,Ha=void 0,Ea=void 0,Ta=void 0;W=void 0;ia=void 0;B=void 0;V=void 0;B=void 0;var F=void 0,$=void 0;W=void 0;F=void 0;$=void 0;var w=void 0,cb=void 0;F=void 0;$=void 0; -w=void 0;cb=void 0;F=void 0;$=void 0;w=void 0;cb=void 0;F=void 0;$=void 0;w=void 0;B=void 0;V=void 0;K=void 0;Y=void 0;Y=void 0;F=void 0;$=void 0;w=void 0;var gb=void 0,Va=0,Wa=0,jb=0,mb=0,Fa=0,Xa=0,Sa=0,ab=0,Ya=0,P=0,R=0;$=F=0;var pa=v.__vertexArray,va=v.__uvArray,qa=v.__uv2Array,Ia=v.__normalArray,wa=v.__tangentArray,ma=v.__colorArray,N=v.__skinVertexAArray,za=v.__skinVertexBArray,Ra=v.__skinIndexArray,Pa=v.__skinWeightArray,ib=v.__morphTargetsArrays,eb=v.__webglCustomAttributes;w=void 0;var Za= -v.__faceArray,$a=v.__lineArray,Bb=v.__needsSmoothNormals;Ba=v.__vertexColorType;Ka=v.__uvType;La=v.__normalType;var db=M.geometry,vb=db.__dirtyVertices,wb=db.__dirtyElements,tb=db.__dirtyUvs,xb=db.__dirtyNormals,yb=db.__dirtyTangents,zb=db.__dirtyColors,Ab=db.__dirtyMorphTargets,pb=db.vertices,Cb=v.faces,Fb=db.faces,Db=db.faceVertexUvs[0],Eb=db.faceVertexUvs[1],qb=db.skinVerticesA,rb=db.skinVerticesB,sb=db.skinIndices,nb=db.skinWeights,ob=M instanceof THREE.ShadowVolume?db.edgeFaces:undefined;morphTargets= -db.morphTargets;if(eb)for(gb in eb){eb[gb].offset=0;eb[gb].offsetSrc=0}G=0;for(U=Cb.length;G0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ma,J)}if(xb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ia,J)}if(yb&&db.hasTangents){e.bindBuffer(e.ARRAY_BUFFER, -v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,wa,J)}if(tb&&jb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,va,J)}if(tb&&mb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,qa,J)}if(wb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Za,J);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,$a,J)}if(P>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer); -e.bufferData(e.ARRAY_BUFFER,N,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,za,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,J);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,J)}if(!M.dynamic){delete v.__inittedArrays;delete v.__colorArray;delete v.__normalArray;delete v.__tangentArray;delete v.__uvArray;delete v.__uv2Array;delete v.__faceArray;delete v.__vertexArray;delete v.__lineArray; -delete v.__skinVertexAArray;delete v.__skinVertexBArray;delete v.__skinIndexArray;delete v.__skinWeightArray}}}}z.__dirtyVertices=!1;z.__dirtyMorphTargets=!1;z.__dirtyElements=!1;z.__dirtyUvs=!1;z.__dirtyNormals=!1;z.__dirtyTangents=!1;z.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){z=n.geometry;if(z.__dirtyVertices||z.__dirtyColors){n=z;D=e.DYNAMIC_DRAW;Ka=n.vertices;v=n.colors;Ba=Ka.length;M=v.length;La=n.__vertexArray;J=n.__colorArray;bb=n.__dirtyColors;if(n.__dirtyVertices){for(G=0;G65535){B[U].counter+=1;Y=B[U].hash+"_"+B[U].counter;n.geometryGroups[Y]==undefined&&(n.geometryGroups[Y]={faces:[],materials:G,vertices:0,numMorphTargets:K})}n.geometryGroups[Y].faces.push(A);n.geometryGroups[Y].vertices+=J}}function E(n,D,z){n.push({buffer:D,object:z,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function T(n){if(n!=sa){switch(n){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD); -e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}sa=n}}function O(n,D,z){if((z.width&z.width-1)==0&&(z.height&z.height-1)==0){e.texParameteri(n,e.TEXTURE_WRAP_S,X(D.wrapS));e.texParameteri(n, -e.TEXTURE_WRAP_T,X(D.wrapT));e.texParameteri(n,e.TEXTURE_MAG_FILTER,X(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,X(D.minFilter));e.generateMipmap(n)}else{e.texParameteri(n,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(n,e.TEXTURE_MAG_FILTER,ga(D.magFilter));e.texParameteri(n,e.TEXTURE_MIN_FILTER,ga(D.minFilter))}}function Q(n,D){if(n.needsUpdate){if(n.__webglTexture)n.__webglTexture=e.deleteTexture(n.__webglTexture);n.__webglTexture= -e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.image);O(e.TEXTURE_2D,n,n.image);e.bindTexture(e.TEXTURE_2D,null);n.needsUpdate=!1}e.activeTexture(e.TEXTURE0+D);e.bindTexture(e.TEXTURE_2D,n.__webglTexture)}function ya(n){if(n&&!n.__webglFramebuffer){if(n.depthBuffer===undefined)n.depthBuffer=!0;if(n.stencilBuffer===undefined)n.stencilBuffer=!0;n.__webglFramebuffer=e.createFramebuffer();n.__webglRenderbuffer=e.createRenderbuffer(); -n.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,n.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,X(n.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,X(n.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,X(n.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,X(n.minFilter));e.texImage2D(e.TEXTURE_2D,0,X(n.format),n.width,n.height,0,X(n.format),X(n.type),null);e.bindRenderbuffer(e.RENDERBUFFER,n.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER, -n.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n.__webglTexture,0);if(n.depthBuffer&&!n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,n.__webglRenderbuffer)}else if(n.depthBuffer&&n.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,n.width,n.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER, -n.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,n.width,n.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var D,z;if(n){D=n.__webglFramebuffer;z=n.width;n=n.height}else{D=null;z=ea;n=Aa}if(D!=Da){e.bindFramebuffer(e.FRAMEBUFFER,D);e.viewport(ra,oa,z,n);Da=D}}function aa(n,D){var z;if(n=="fragment")z=e.createShader(e.FRAGMENT_SHADER);else n=="vertex"&&(z=e.createShader(e.VERTEX_SHADER));e.shaderSource(z, -D);e.compileShader(z);if(!e.getShaderParameter(z,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(z));console.error(D);return null}return z}function ga(n){switch(n){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function X(n){switch(n){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST; -case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT; -case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var ha=this,e,Ja=[],ta=null,Da=null,ca=!0,ua=null,da=null,sa=null,na=null,ra=0,oa=0,ea=0,Aa=0,Oa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4], -fa=new THREE.Matrix4,xa=new Float32Array(16),Ma=new Float32Array(16),Qa=new THREE.Vector4,Ua={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};var L=b.canvas!==undefined?b.canvas:document.createElement("canvas"),Z=b.stencil!==undefined?b.stencil:!0,ja=b.antialias!==undefined?b.antialias:!1,la=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0),Na=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0, -faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=L;this.autoClear=!0;this.sortObjects=!0;try{if(!(e=L.getContext("experimental-webgl",{antialias:ja,stencil:Z})))throw"Error creating WebGL context.";}catch(fb){console.error(fb)}console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION));e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW); -e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(la.r,la.g,la.b,Na);this.context=e;var hb=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(Z){var Ga={};Ga.vertices=new Float32Array(12);Ga.faces=new Uint16Array(6);Ga.darkness=0.5;Ga.vertices[0]=-20;Ga.vertices[1]=-20;Ga.vertices[2]=-1;Ga.vertices[3]=20;Ga.vertices[4]=-20;Ga.vertices[5]=-1;Ga.vertices[6]=20;Ga.vertices[7]=20;Ga.vertices[8]=-1;Ga.vertices[9]= --20;Ga.vertices[10]=20;Ga.vertices[11]=-1;Ga.faces[0]=0;Ga.faces[1]=1;Ga.faces[2]=2;Ga.faces[3]=0;Ga.faces[4]=2;Ga.faces[5]=3;Ga.vertexBuffer=e.createBuffer();Ga.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,Ga.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ga.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,Ga.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ga.faces,e.STATIC_DRAW);Ga.program=e.createProgram();e.attachShader(Ga.program,aa("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); -e.attachShader(Ga.program,aa("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(Ga.program);Ga.vertexLocation=e.getAttribLocation(Ga.program,"position");Ga.projectionLocation=e.getUniformLocation(Ga.program,"projectionMatrix");Ga.darknessLocation=e.getUniformLocation(Ga.program,"darkness")}var ka={};ka.vertices=new Float32Array(16);ka.faces=new Uint16Array(6);b=0;ka.vertices[b++]=-1;ka.vertices[b++]=-1;ka.vertices[b++]=0;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]= -1;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]=1;ka.vertices[b++]=0;ka.vertices[b++]=1;b=0;ka.faces[b++]=0;ka.faces[b++]=1;ka.faces[b++]=2;ka.faces[b++]=0;ka.faces[b++]=2;ka.faces[b++]=3;ka.vertexBuffer=e.createBuffer();ka.elementBuffer=e.createBuffer();ka.tempTexture=e.createTexture();ka.occlusionTexture=e.createTexture();e.bindBuffer(e.ARRAY_BUFFER,ka.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka.vertices,e.STATIC_DRAW); -e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ka.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ka.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);e.bindTexture(e.TEXTURE_2D, -ka.occlusionTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,16,16,0,e.RGBA,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);if(e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){ka.hasVertexTexture=!1;ka.program=e.createProgram();e.attachShader(ka.program,aa("fragment",THREE.ShaderLib.lensFlare.fragmentShader)); -e.attachShader(ka.program,aa("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{ka.hasVertexTexture=!0;ka.program=e.createProgram();e.attachShader(ka.program,aa("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));e.attachShader(ka.program,aa("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}e.linkProgram(ka.program);ka.attributes={};ka.uniforms={};ka.attributes.vertex=e.getAttribLocation(ka.program,"position");ka.attributes.uv=e.getAttribLocation(ka.program,"UV");ka.uniforms.renderType= -e.getUniformLocation(ka.program,"renderType");ka.uniforms.map=e.getUniformLocation(ka.program,"map");ka.uniforms.occlusionMap=e.getUniformLocation(ka.program,"occlusionMap");ka.uniforms.opacity=e.getUniformLocation(ka.program,"opacity");ka.uniforms.scale=e.getUniformLocation(ka.program,"scale");ka.uniforms.rotation=e.getUniformLocation(ka.program,"rotation");ka.uniforms.screenPosition=e.getUniformLocation(ka.program,"screenPosition");var ub=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces= -new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]= -2;_sprite.faces[b++]=3;_sprite.vertexBuffer=e.createBuffer();_sprite.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,_sprite.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,_sprite.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,_sprite.faces,e.STATIC_DRAW);_sprite.program=e.createProgram();e.attachShader(_sprite.program,aa("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(_sprite.program,aa("vertex",THREE.ShaderLib.sprite.vertexShader)); -e.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=e.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=e.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=e.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=e.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=e.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=e.getUniformLocation(_sprite.program,"scale"); -_sprite.uniforms.alignment=e.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=e.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=e.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=e.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=e.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=e.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix= -e.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=e.getUniformLocation(_sprite.program,"projectionMatrix");var lb=!1;this.setSize=function(n,D){L.width=n;L.height=D;this.setViewport(0,0,L.width,L.height)};this.setViewport=function(n,D,z,v){ra=n;oa=D;ea=z;Aa=v;e.viewport(ra,oa,ea,Aa)};this.setScissor=function(n,D,z,v){e.scissor(n,D,z,v)};this.enableScissorTest=function(n){n?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(n){ca= -n;e.depthMask(n)};this.setClearColorHex=function(n,D){la.setHex(n);Na=D;e.clearColor(la.r,la.g,la.b,Na)};this.setClearColor=function(n,D){la.copy(n);Na=D;e.clearColor(la.r,la.g,la.b,Na)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(n){Ga.darkness=n};this.getContext=function(){return e};this.initMaterial=function(n,D,z,v){var A,M,J;if(n instanceof THREE.MeshDepthMaterial)J="depth";else if(n instanceof THREE.ShadowVolumeDynamicMaterial)J= -"shadowVolumeDynamic";else if(n instanceof THREE.MeshNormalMaterial)J="normal";else if(n instanceof THREE.MeshBasicMaterial)J="basic";else if(n instanceof THREE.MeshLambertMaterial)J="lambert";else if(n instanceof THREE.MeshPhongMaterial)J="phong";else if(n instanceof THREE.LineBasicMaterial)J="basic";else n instanceof THREE.ParticleBasicMaterial&&(J="particle_basic");if(J){var G=THREE.ShaderLib[J];n.uniforms=THREE.UniformsUtils.clone(G.uniforms);n.vertexShader=G.vertexShader;n.fragmentShader=G.fragmentShader}var U, -Y,B;U=B=G=0;for(Y=D.length;U=0&&e.enableVertexAttribArray(K.position);K.color>=0&&e.enableVertexAttribArray(K.color); -K.normal>=0&&e.enableVertexAttribArray(K.normal);K.tangent>=0&&e.enableVertexAttribArray(K.tangent);if(n.skinning&&K.skinVertexA>=0&&K.skinVertexB>=0&&K.skinIndex>=0&&K.skinWeight>=0){e.enableVertexAttribArray(K.skinVertexA);e.enableVertexAttribArray(K.skinVertexB);e.enableVertexAttribArray(K.skinIndex);e.enableVertexAttribArray(K.skinWeight)}if(n.attributes)for(A in n.attributes)K[A]!==undefined&&K[A]>=0&&e.enableVertexAttribArray(K[A]);if(n.morphTargets){n.numSupportedMorphTargets=0;if(K.morphTarget0>= -0){e.enableVertexAttribArray(K.morphTarget0);n.numSupportedMorphTargets++}if(K.morphTarget1>=0){e.enableVertexAttribArray(K.morphTarget1);n.numSupportedMorphTargets++}if(K.morphTarget2>=0){e.enableVertexAttribArray(K.morphTarget2);n.numSupportedMorphTargets++}if(K.morphTarget3>=0){e.enableVertexAttribArray(K.morphTarget3);n.numSupportedMorphTargets++}if(K.morphTarget4>=0){e.enableVertexAttribArray(K.morphTarget4);n.numSupportedMorphTargets++}if(K.morphTarget5>=0){e.enableVertexAttribArray(K.morphTarget5); -n.numSupportedMorphTargets++}if(K.morphTarget6>=0){e.enableVertexAttribArray(K.morphTarget6);n.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);n.numSupportedMorphTargets++}v.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);n=0;for(A=this.maxMorphTargets;n0||W.faceVertexUvs.length>0)J.__uvArray=new Float32Array(U*2);if(W.faceUvs.length>1||W.faceVertexUvs.length> -1)J.__uv2Array=new Float32Array(U*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){J.__skinVertexAArray=new Float32Array(U*4);J.__skinVertexBArray=new Float32Array(U*4);J.__skinIndexArray=new Float32Array(U*4);J.__skinWeightArray=new Float32Array(U*4)}J.__faceArray=new Uint16Array(V*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*6:0));J.__lineArray=new Uint16Array(Ka*2);if(J.numMorphTargets){J.__morphTargetsArrays=[];W=0;for(ia=J.numMorphTargets;W=0;A--){v=z.__webglObjects[A].object;if(D==v){z.__webglObjects.splice(A,1);break}}else if(D instanceof THREE.Sprite)for(A=z.__webglSprites.length- -1;A>=0;A--){v=z.__webglSprites[A];if(D==v){z.__webglSprites.splice(A,1);break}}n.__objectsRemoved.splice(0,1)}D=0;for(z=n.__webglObjects.length;D=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglVertexBuffer);f.vertexAttribPointer(o.position,3,f.FLOAT,!1,0,0)}else{H=z.program.attributes;if(Q.morphTargetBase!==-1){f.bindBuffer(f.ARRAY_BUFFER,D.__webglMorphTargetsBuffers[Q.morphTargetBase]); +f.vertexAttribPointer(H.position,3,f.FLOAT,!1,0,0)}else if(H.position>=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglVertexBuffer);f.vertexAttribPointer(H.position,3,f.FLOAT,!1,0,0)}if(Q.morphTargetForcedOrder.length){C=0;for(var J=Q.morphTargetForcedOrder,X=Q.morphTargetInfluences;Caa){E=N;aa=X[E]}f.bindBuffer(f.ARRAY_BUFFER,D.__webglMorphTargetsBuffers[E]);f.vertexAttribPointer(H["morphTarget"+C],3,f.FLOAT,!1,0,0);Q.__webglMorphTargetInfluences[C]=aa;J[E]=1;aa=-1;C++}}z.program.uniforms.morphTargetInfluences!==null&&f.uniform1fv(z.program.uniforms.morphTargetInfluences,Q.__webglMorphTargetInfluences)}if(z.attributes)for(M in z.attributes)if(o[M]!== +undefined&&o[M]>=0){H=z.attributes[M];if(H.buffer){f.bindBuffer(f.ARRAY_BUFFER,H.buffer);f.vertexAttribPointer(o[M],H.size,f.FLOAT,!1,0,0)}}if(o.color>=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglColorBuffer);f.vertexAttribPointer(o.color,3,f.FLOAT,!1,0,0)}if(o.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglNormalBuffer);f.vertexAttribPointer(o.normal,3,f.FLOAT,!1,0,0)}if(o.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglTangentBuffer);f.vertexAttribPointer(o.tangent,4,f.FLOAT,!1,0,0)}if(o.uv>=0)if(D.__webglUVBuffer){f.bindBuffer(f.ARRAY_BUFFER, +D.__webglUVBuffer);f.vertexAttribPointer(o.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(o.uv)}else f.disableVertexAttribArray(o.uv);if(o.uv2>=0)if(D.__webglUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,D.__webglUV2Buffer);f.vertexAttribPointer(o.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(o.uv2)}else f.disableVertexAttribArray(o.uv2);if(z.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,D.__webglSkinVertexABuffer);f.vertexAttribPointer(o.skinVertexA, +4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,D.__webglSkinVertexBBuffer);f.vertexAttribPointer(o.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,D.__webglSkinIndicesBuffer);f.vertexAttribPointer(o.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,D.__webglSkinWeightsBuffer);f.vertexAttribPointer(o.skinWeight,4,f.FLOAT,!1,0,0)}if(Q instanceof THREE.Mesh){if(z.wireframe){f.lineWidth(z.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webglLineBuffer);f.drawElements(f.LINES, +D.__webglLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webglFaceBuffer);f.drawElements(f.TRIANGLES,D.__webglFaceCount,f.UNSIGNED_SHORT,0)}ka.data.vertices+=D.__webglFaceCount;ka.data.faces+=D.__webglFaceCount/3;ka.data.drawCalls++}else if(Q instanceof THREE.Line){Q=Q.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(z.linewidth);f.drawArrays(Q,0,D.__webglLineCount);ka.data.drawCalls++}else if(Q instanceof THREE.ParticleSystem){f.drawArrays(f.POINTS,0,D.__webglParticleCount); +ka.data.drawCalls++}else if(Q instanceof THREE.Ribbon){f.drawArrays(f.TRIANGLE_STRIP,0,D.__webglVertexCount);ka.data.drawCalls++}}}function h(o,H,C){if(!o.__webglVertexBuffer)o.__webglVertexBuffer=f.createBuffer();if(!o.__webglNormalBuffer)o.__webglNormalBuffer=f.createBuffer();if(o.hasPos){f.bindBuffer(f.ARRAY_BUFFER,o.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,o.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(H.attributes.position);f.vertexAttribPointer(H.attributes.position,3,f.FLOAT, +!1,0,0)}if(o.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,o.__webglNormalBuffer);if(C==THREE.FlatShading){var z,D,Q,M,J,X,aa,E,N,Z,la=o.count*3;for(Z=0;Z0&&Na[0]0&&Na[1]0.0010&&J.scale>0.0010){Y[0]=J.x;Y[1]=J.y;Y[2]=J.z;Z=J.size*J.scale/Ea;la[0]=Z*aa;la[1]=Z;f.uniform3fv(Fa.screenPosition,Y);f.uniform2fv(Fa.scale,la);f.uniform1f(Fa.rotation,J.rotation);f.uniform1f(Fa.opacity, +J.opacity);V(J.blending);R(J.texture,1);f.drawElements(f.TRIANGLES,6,f.UNSIGNED_SHORT,0)}}}}f.enable(f.CULL_FACE);f.enable(f.DEPTH_TEST);f.depthMask(ea)}function L(o,H){o._modelViewMatrix.multiplyToArray(H.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(o._modelViewMatrix).transposeIntoArray(o._normalMatrixArray)}function F(o){var H,C,z,D,Q;if(o instanceof THREE.Mesh){C=o.geometry;for(H in C.geometryGroups){z=C.geometryGroups[H];Q=!1;for(D in z.__webglCustomAttributes)if(z.__webglCustomAttributes[D].needsUpdate){Q= +!0;break}if(C.__dirtyVertices||C.__dirtyMorphTargets||C.__dirtyElements||C.__dirtyUvs||C.__dirtyNormals||C.__dirtyColors||C.__dirtyTangents||Q){Q=o;var M=f.DYNAMIC_DRAW;if(z.__inittedArrays){var J=void 0,X=void 0,aa=void 0,E=void 0;aa=void 0;var N=void 0,Z=void 0,la=void 0,Y=void 0,Na=void 0,Fa=void 0,Oa=void 0,eb=void 0,nb=void 0,Ga=void 0,La=void 0,Ha=void 0,Wa=void 0;Z=void 0;la=void 0;E=void 0;Y=void 0;E=void 0;var I=void 0,fa=void 0;Z=void 0;I=void 0;fa=void 0;var B=void 0,fb=void 0;I=void 0; +fa=void 0;B=void 0;fb=void 0;I=void 0;fa=void 0;B=void 0;fb=void 0;I=void 0;fa=void 0;B=void 0;E=void 0;Y=void 0;N=void 0;aa=void 0;aa=void 0;I=void 0;fa=void 0;B=void 0;var jb=void 0,Ya=0,Za=0,mb=0,pb=0,Ia=0,$a=0,Va=0,db=0,ab=0,U=0,W=0;fa=I=0;var ta=z.__vertexArray,za=z.__uvArray,va=z.__uv2Array,Ma=z.__normalArray,Aa=z.__tangentArray,sa=z.__colorArray,S=z.__skinVertexAArray,Ca=z.__skinVertexBArray,Ua=z.__skinIndexArray,Sa=z.__skinWeightArray,lb=z.__morphTargetsArrays,hb=z.__webglCustomAttributes; +B=void 0;var bb=z.__faceArray,cb=z.__lineArray,Eb=z.__needsSmoothNormals;Fa=z.__vertexColorType;Na=z.__uvType;Oa=z.__normalType;var gb=Q.geometry,yb=gb.__dirtyVertices,zb=gb.__dirtyElements,wb=gb.__dirtyUvs,Ab=gb.__dirtyNormals,Bb=gb.__dirtyTangents,Cb=gb.__dirtyColors,Db=gb.__dirtyMorphTargets,sb=gb.vertices,Fb=z.faces,Ib=gb.faces,Gb=gb.faceVertexUvs[0],Hb=gb.faceVertexUvs[1],tb=gb.skinVerticesA,ub=gb.skinVerticesB,vb=gb.skinIndices,qb=gb.skinWeights,rb=Q instanceof THREE.ShadowVolume?gb.edgeFaces: +undefined;morphTargets=gb.morphTargets;if(hb)for(jb in hb){hb[jb].offset=0;hb[jb].offsetSrc=0}J=0;for(X=Fb.length;J0){f.bindBuffer(f.ARRAY_BUFFER,z.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER, +sa,M)}if(Ab){f.bindBuffer(f.ARRAY_BUFFER,z.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ma,M)}if(Bb&&gb.hasTangents){f.bindBuffer(f.ARRAY_BUFFER,z.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,Aa,M)}if(wb&&mb>0){f.bindBuffer(f.ARRAY_BUFFER,z.__webglUVBuffer);f.bufferData(f.ARRAY_BUFFER,za,M)}if(wb&&pb>0){f.bindBuffer(f.ARRAY_BUFFER,z.__webglUV2Buffer);f.bufferData(f.ARRAY_BUFFER,va,M)}if(zb){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,z.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,bb,M); +f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,z.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,cb,M)}if(U>0){f.bindBuffer(f.ARRAY_BUFFER,z.__webglSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,S,M);f.bindBuffer(f.ARRAY_BUFFER,z.__webglSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,Ca,M);f.bindBuffer(f.ARRAY_BUFFER,z.__webglSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,Ua,M);f.bindBuffer(f.ARRAY_BUFFER,z.__webglSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,Sa,M)}if(!Q.dynamic){delete z.__inittedArrays; +delete z.__colorArray;delete z.__normalArray;delete z.__tangentArray;delete z.__uvArray;delete z.__uv2Array;delete z.__faceArray;delete z.__vertexArray;delete z.__lineArray;delete z.__skinVertexAArray;delete z.__skinVertexBArray;delete z.__skinIndexArray;delete z.__skinWeightArray}}}}C.__dirtyVertices=!1;C.__dirtyMorphTargets=!1;C.__dirtyElements=!1;C.__dirtyUvs=!1;C.__dirtyNormals=!1;C.__dirtyTangents=!1;C.__dirtyColors=!1}else if(o instanceof THREE.Ribbon){C=o.geometry;if(C.__dirtyVertices||C.__dirtyColors){o= +C;H=f.DYNAMIC_DRAW;Na=o.vertices;z=o.colors;Fa=Na.length;Q=z.length;Oa=o.__vertexArray;M=o.__colorArray;eb=o.__dirtyColors;if(o.__dirtyVertices){for(J=0;J65535){E[X].counter+=1;aa=E[X].hash+"_"+E[X].counter;o.geometryGroups[aa]==undefined&&(o.geometryGroups[aa]={faces:[],materials:J,vertices:0,numMorphTargets:N})}o.geometryGroups[aa].faces.push(D); +o.geometryGroups[aa].vertices+=M}}function G(o,H,C){o.push({buffer:H,object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function V(o){if(o!=wa){switch(o){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD, +f.FUNC_ADD);f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}wa=o}}function P(o,H,C){if((C.width&C.width-1)==0&&(C.height&C.height-1)==0){f.texParameteri(o,f.TEXTURE_WRAP_S,$(H.wrapS));f.texParameteri(o,f.TEXTURE_WRAP_T,$(H.wrapT));f.texParameteri(o,f.TEXTURE_MAG_FILTER,$(H.magFilter));f.texParameteri(o,f.TEXTURE_MIN_FILTER,$(H.minFilter));f.generateMipmap(o)}else{f.texParameteri(o,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(o,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE); +f.texParameteri(o,f.TEXTURE_MAG_FILTER,ja(H.magFilter));f.texParameteri(o,f.TEXTURE_MIN_FILTER,ja(H.minFilter))}}function R(o,H){if(o.needsUpdate){if(o.__webglTexture)o.__webglTexture=f.deleteTexture(o.__webglTexture);o.__webglTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,o.__webglTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,f.RGBA,f.UNSIGNED_BYTE,o.image);P(f.TEXTURE_2D,o,o.image);f.bindTexture(f.TEXTURE_2D,null);o.needsUpdate=!1}f.activeTexture(f.TEXTURE0+H);f.bindTexture(f.TEXTURE_2D,o.__webglTexture)} +function ya(o){if(o&&!o.__webglFramebuffer){if(o.depthBuffer===undefined)o.depthBuffer=!0;if(o.stencilBuffer===undefined)o.stencilBuffer=!0;o.__webglFramebuffer=f.createFramebuffer();o.__webglRenderbuffer=f.createRenderbuffer();o.__webglTexture=f.createTexture();f.bindTexture(f.TEXTURE_2D,o.__webglTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,$(o.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,$(o.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,$(o.magFilter));f.texParameteri(f.TEXTURE_2D, +f.TEXTURE_MIN_FILTER,$(o.minFilter));f.texImage2D(f.TEXTURE_2D,0,$(o.format),o.width,o.height,0,$(o.format),$(o.type),null);f.bindRenderbuffer(f.RENDERBUFFER,o.__webglRenderbuffer);f.bindFramebuffer(f.FRAMEBUFFER,o.__webglFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,f.TEXTURE_2D,o.__webglTexture,0);if(o.depthBuffer&&!o.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,o.width,o.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER, +o.__webglRenderbuffer)}else if(o.depthBuffer&&o.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,o.width,o.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,o.__webglRenderbuffer)}else f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,o.width,o.height);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var H,C;if(o){H=o.__webglFramebuffer;C=o.width;o=o.height}else{H=null;C=ha;o=Ea}if(H!= +Da){f.bindFramebuffer(f.FRAMEBUFFER,H);f.viewport(ua,oa,C,o);Da=H}}function da(o,H){var C;if(o=="fragment")C=f.createShader(f.FRAGMENT_SHADER);else o=="vertex"&&(C=f.createShader(f.VERTEX_SHADER));f.shaderSource(C,H);f.compileShader(C);if(!f.getShaderParameter(C,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(C));console.error(H);return null}return C}function ja(o){switch(o){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}} +function $(o){switch(o){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0} +var ka=this,f,Ja=[],qa=null,Da=null,ea=!0,xa=null,ga=null,wa=null,na=null,ua=0,oa=0,ha=0,Ea=0,Ra=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ia=new THREE.Matrix4,Ba=new Float32Array(16),Pa=new Float32Array(16),Ta=new THREE.Vector4,Xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};b=b||{};var O=b.canvas!==undefined?b.canvas:document.createElement("canvas"),ca=b.stencil!== +undefined?b.stencil:!0,ma=b.antialias!==undefined?b.antialias:!1,ra=b.clearColor!==undefined?new THREE.Color(b.clearColor):new THREE.Color(0),Qa=b.clearAlpha!==undefined?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=O;this.autoClear=!0;this.sortObjects=!0;try{if(!(f=O.getContext("experimental-webgl",{antialias:ma,stencil:ca})))throw"Error creating WebGL context.";}catch(ib){console.error(ib)}console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+ +" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION));f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(ra.r,ra.g,ra.b,Qa);this.context=f;var kb=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ca){var Ka={};Ka.vertices=new Float32Array(12); +Ka.faces=new Uint16Array(6);Ka.darkness=0.5;Ka.vertices[0]=-20;Ka.vertices[1]=-20;Ka.vertices[2]=-1;Ka.vertices[3]=20;Ka.vertices[4]=-20;Ka.vertices[5]=-1;Ka.vertices[6]=20;Ka.vertices[7]=20;Ka.vertices[8]=-1;Ka.vertices[9]=-20;Ka.vertices[10]=20;Ka.vertices[11]=-1;Ka.faces[0]=0;Ka.faces[1]=1;Ka.faces[2]=2;Ka.faces[3]=0;Ka.faces[4]=2;Ka.faces[5]=3;Ka.vertexBuffer=f.createBuffer();Ka.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,Ka.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,Ka.vertices, +f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,Ka.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ka.faces,f.STATIC_DRAW);Ka.program=f.createProgram();f.attachShader(Ka.program,da("fragment",THREE.ShaderLib.shadowPost.fragmentShader));f.attachShader(Ka.program,da("vertex",THREE.ShaderLib.shadowPost.vertexShader));f.linkProgram(Ka.program);Ka.vertexLocation=f.getAttribLocation(Ka.program,"position");Ka.projectionLocation=f.getUniformLocation(Ka.program,"projectionMatrix");Ka.darknessLocation= +f.getUniformLocation(Ka.program,"darkness")}var pa={};pa.vertices=new Float32Array(16);pa.faces=new Uint16Array(6);b=0;pa.vertices[b++]=-1;pa.vertices[b++]=-1;pa.vertices[b++]=0;pa.vertices[b++]=0;pa.vertices[b++]=1;pa.vertices[b++]=-1;pa.vertices[b++]=1;pa.vertices[b++]=0;pa.vertices[b++]=1;pa.vertices[b++]=1;pa.vertices[b++]=1;pa.vertices[b++]=1;pa.vertices[b++]=-1;pa.vertices[b++]=1;pa.vertices[b++]=0;pa.vertices[b++]=1;b=0;pa.faces[b++]=0;pa.faces[b++]=1;pa.faces[b++]=2;pa.faces[b++]=0;pa.faces[b++]= +2;pa.faces[b++]=3;pa.vertexBuffer=f.createBuffer();pa.elementBuffer=f.createBuffer();pa.tempTexture=f.createTexture();pa.occlusionTexture=f.createTexture();f.bindBuffer(f.ARRAY_BUFFER,pa.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,pa.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,pa.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,pa.faces,f.STATIC_DRAW);f.bindTexture(f.TEXTURE_2D,pa.tempTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGB,16,16,0,f.RGB,f.UNSIGNED_BYTE,null);f.texParameteri(f.TEXTURE_2D, +f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST);f.bindTexture(f.TEXTURE_2D,pa.occlusionTexture);f.texImage2D(f.TEXTURE_2D,0,f.RGBA,16,16,0,f.RGBA,f.UNSIGNED_BYTE,null);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER, +f.NEAREST);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST);if(f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0){pa.hasVertexTexture=!1;pa.program=f.createProgram();f.attachShader(pa.program,da("fragment",THREE.ShaderLib.lensFlare.fragmentShader));f.attachShader(pa.program,da("vertex",THREE.ShaderLib.lensFlare.vertexShader))}else{pa.hasVertexTexture=!0;pa.program=f.createProgram();f.attachShader(pa.program,da("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader));f.attachShader(pa.program, +da("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader))}f.linkProgram(pa.program);pa.attributes={};pa.uniforms={};pa.attributes.vertex=f.getAttribLocation(pa.program,"position");pa.attributes.uv=f.getAttribLocation(pa.program,"UV");pa.uniforms.renderType=f.getUniformLocation(pa.program,"renderType");pa.uniforms.map=f.getUniformLocation(pa.program,"map");pa.uniforms.occlusionMap=f.getUniformLocation(pa.program,"occlusionMap");pa.uniforms.opacity=f.getUniformLocation(pa.program,"opacity"); +pa.uniforms.scale=f.getUniformLocation(pa.program,"scale");pa.uniforms.rotation=f.getUniformLocation(pa.program,"rotation");pa.uniforms.screenPosition=f.getUniformLocation(pa.program,"screenPosition");var xb=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]= +1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=f.createBuffer();_sprite.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,_sprite.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,_sprite.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER, +_sprite.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,_sprite.faces,f.STATIC_DRAW);_sprite.program=f.createProgram();f.attachShader(_sprite.program,da("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(_sprite.program,da("vertex",THREE.ShaderLib.sprite.vertexShader));f.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=f.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=f.getAttribLocation(_sprite.program,"uv"); +_sprite.uniforms.uvOffset=f.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=f.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=f.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=f.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=f.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=f.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=f.getUniformLocation(_sprite.program,"opacity"); +_sprite.uniforms.useScreenCoordinates=f.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=f.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=f.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=f.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=f.getUniformLocation(_sprite.program,"projectionMatrix");var ob=!1;this.setSize=function(o,H){O.width= +o;O.height=H;this.setViewport(0,0,O.width,O.height)};this.setViewport=function(o,H,C,z){ua=o;oa=H;ha=C;Ea=z;f.viewport(ua,oa,ha,Ea)};this.setScissor=function(o,H,C,z){f.scissor(o,H,C,z)};this.enableScissorTest=function(o){o?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.enableDepthBufferWrite=function(o){ea=o;f.depthMask(o)};this.setClearColorHex=function(o,H){ra.setHex(o);Qa=H;f.clearColor(ra.r,ra.g,ra.b,Qa)};this.setClearColor=function(o,H){ra.copy(o);Qa=H;f.clearColor(ra.r,ra.g,ra.b, +Qa)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(o){Ka.darkness=o};this.getContext=function(){return f};this.initMaterial=function(o,H,C,z){var D,Q,M;if(o instanceof THREE.MeshDepthMaterial)M="depth";else if(o instanceof THREE.ShadowVolumeDynamicMaterial)M="shadowVolumeDynamic";else if(o instanceof THREE.MeshNormalMaterial)M="normal";else if(o instanceof THREE.MeshBasicMaterial)M="basic";else if(o instanceof THREE.MeshLambertMaterial)M= +"lambert";else if(o instanceof THREE.MeshPhongMaterial)M="phong";else if(o instanceof THREE.LineBasicMaterial)M="basic";else o instanceof THREE.ParticleBasicMaterial&&(M="particle_basic");if(M){var J=THREE.ShaderLib[M];o.uniforms=THREE.UniformsUtils.clone(J.uniforms);o.vertexShader=J.vertexShader;o.fragmentShader=J.fragmentShader}var X,aa,E;X=E=J=0;for(aa=H.length;X=0&&f.enableVertexAttribArray(N.position);N.color>=0&&f.enableVertexAttribArray(N.color); +N.normal>=0&&f.enableVertexAttribArray(N.normal);N.tangent>=0&&f.enableVertexAttribArray(N.tangent);if(o.skinning&&N.skinVertexA>=0&&N.skinVertexB>=0&&N.skinIndex>=0&&N.skinWeight>=0){f.enableVertexAttribArray(N.skinVertexA);f.enableVertexAttribArray(N.skinVertexB);f.enableVertexAttribArray(N.skinIndex);f.enableVertexAttribArray(N.skinWeight)}if(o.attributes)for(D in o.attributes)N[D]!==undefined&&N[D]>=0&&f.enableVertexAttribArray(N[D]);if(o.morphTargets){o.numSupportedMorphTargets=0;if(N.morphTarget0>= +0){f.enableVertexAttribArray(N.morphTarget0);o.numSupportedMorphTargets++}if(N.morphTarget1>=0){f.enableVertexAttribArray(N.morphTarget1);o.numSupportedMorphTargets++}if(N.morphTarget2>=0){f.enableVertexAttribArray(N.morphTarget2);o.numSupportedMorphTargets++}if(N.morphTarget3>=0){f.enableVertexAttribArray(N.morphTarget3);o.numSupportedMorphTargets++}if(N.morphTarget4>=0){f.enableVertexAttribArray(N.morphTarget4);o.numSupportedMorphTargets++}if(N.morphTarget5>=0){f.enableVertexAttribArray(N.morphTarget5); +o.numSupportedMorphTargets++}if(N.morphTarget6>=0){f.enableVertexAttribArray(N.morphTarget6);o.numSupportedMorphTargets++}if(N.morphTarget7>=0){f.enableVertexAttribArray(N.morphTarget7);o.numSupportedMorphTargets++}z.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);o=0;for(D=this.maxMorphTargets;o0||Z.faceVertexUvs.length>0)M.__uvArray=new Float32Array(X* +2);if(Z.faceUvs.length>1||Z.faceVertexUvs.length>1)M.__uv2Array=new Float32Array(X*2)}if(J.geometry.skinWeights.length&&J.geometry.skinIndices.length){M.__skinVertexAArray=new Float32Array(X*4);M.__skinVertexBArray=new Float32Array(X*4);M.__skinIndexArray=new Float32Array(X*4);M.__skinWeightArray=new Float32Array(X*4)}M.__faceArray=new Uint16Array(Y*3+(J.geometry.edgeFaces?J.geometry.edgeFaces.length*6:0));M.__lineArray=new Uint16Array(Na*2);if(M.numMorphTargets){M.__morphTargetsArrays=[];Z=0;for(la= +M.numMorphTargets;Z=0;D--){z=C.__webglObjects[D].object;if(H==z){C.__webglObjects.splice(D, +1);break}}else if(H instanceof THREE.Sprite)for(D=C.__webglSprites.length-1;D>=0;D--){z=C.__webglSprites[D];if(H==z){C.__webglSprites.splice(D,1);break}}o.__objectsRemoved.splice(0,1)}H=0;for(C=o.__webglObjects.length;H1&&(c-=1)}d===undefined&&(d={h:0,s:0,v:0});d.h=c;d.s=j;d.v=h;return d}, -clamp:function(b,d,c){return bc?c:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,m=g.faces,o=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var p=0,x=j.length;p1&&(c-=1)}e===undefined&&(e={h:0,s:0,v:0});e.h=c;e.s=k;e.v=j;return e}, +clamp:function(b,e,c){return bc?c:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; +var GeometryUtils={merge:function(b,e){var c=e instanceof THREE.Mesh,g=b.vertices.length,h=c?e.geometry:e,j=b.vertices,k=h.vertices,m=b.faces,n=h.faces,p=b.faceVertexUvs[0];h=h.faceVertexUvs[0];c&&e.matrixAutoUpdate&&e.updateMatrix();for(var t=0,w=k.length;t25&&(h=25);g=(h-1)*0.5;c=Array(h);for(d=f=0;d25&&(j=25);h=(j-1)*0.5;c=Array(j);for(e=g=0;e1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= -this.getPrevKeyWith("pos",t,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c=== -"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&p[0][o]===undefined){this.hierarchy[0].update(undefined,!0);for(t=0;tb.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];m=b[c[2]];o=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],m[0],o[0],g,c,j);f[1]=this.interpolate(h[1],k[1],m[1],o[1],g,c,j);f[2]=this.interpolate(h[2],k[2],m[2],o[2],g,c,j);return f}; -THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]}; -THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.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(b){if(b.movementSpeed!==undefined)this.movementSpeed= +THREE.Animation.prototype.update=function(b){if(this.isPlaying){var e=["pos","rot","scl"],c,g,h,j,k,m,n,p,t=this.data.JIT.hierarchy,w,A;this.currentTime+=b*this.timeScale;A=this.currentTime;w=this.currentTime%=this.data.length;p=parseInt(Math.min(w*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,v=this.hierarchy.length;u1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+u);g=g<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=h[0]+(j[0]-h[0])*g;c.y=h[1]+(j[1]-h[1])*g;c.z=h[2]+(j[2]-h[2])*g}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]= +this.getPrevKeyWith("pos",u,k.index-1).pos;this.points[1]=h;this.points[2]=j;this.points[3]=this.getNextKeyWith("pos",u,m.index+1).pos;g=g*0.33+0.33;h=this.interpolateCatmullRom(this.points,g);c.x=h[0];c.y=h[1];c.z=h[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){g=this.interpolateCatmullRom(this.points,g*1.01);this.target.set(g[0],g[1],g[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();g=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,g,0)}}}else if(c=== +"rot")THREE.Quaternion.slerp(h,j,b.quaternion,g);else if(c==="scl"){c=b.scale;c.x=h[0]+(j[0]-h[0])*g;c.y=h[1]+(j[1]-h[1])*g;c.z=h[2]+(j[2]-h[2])*g}}}}if(this.JITCompile&&t[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;ub.length-2?j:j+1;c[3]=j>b.length-3?j:j+2;j=b[c[0]];m=b[c[1]];n=b[c[2]];p=b[c[3]];c=h*h;k=h*c;g[0]=this.interpolate(j[0],m[0],n[0],p[0],h,c,k);g[1]=this.interpolate(j[1],m[1],n[1],p[1],h,c,k);g[2]=this.interpolate(j[2],m[2],n[2],p[2],h,c,k);return g}; +THREE.Animation.prototype.interpolate=function(b,e,c,g,h,j,k){b=(c-b)*0.5;g=(g-e)*0.5;return(2*(e-c)+b+g)*k+(-3*(e-c)-2*b-g)*j+b*h+e};THREE.Animation.prototype.getNextKeyWith=function(b,e,c){var g=this.data.hierarchy[e].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c0?c:0:c>=0?c:c+g.length;c>=0;c--)if(g[c][b]!==undefined)return g[c];return this.data.hierarchy[e].keys[g.length-1]}; +THREE.QuakeCamera=function(b){function e(c,g){return function(){g.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.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(b){if(b.movementSpeed!==undefined)this.movementSpeed= b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.noFly!==undefined)this.noFly=b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax= b.heightMax;if(b.constrainVertical!==undefined)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==undefined)this.verticalMin=b.verticalMin;if(b.verticalMax!==undefined)this.verticalMax=b.verticalMax;if(b.domElement!==undefined)this.domElement=b.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(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown= function(c){switch(c.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(c){switch(c.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 c=(new Date).getTime();this.tdiff=(c-this.lastUpdate)/ -1E3;this.lastUpdate=c;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var f=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(f+this.autoSpeedFactor));this.moveBackward&&this.translateZ(f);this.moveLeft&&this.translateX(-f);this.moveRight&&this.translateX(f);f=this.tdiff*this.lookSpeed; -this.activeLook||(f=0);this.lon+=this.mouseX*f;this.lookVertical&&(this.lat-=this.mouseY*f);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;c=this.target.position;var g=this.position;c.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=g.y+100*Math.cos(this.phi);c.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*f;this.lookVertical&&(this.lat-=this.mouseY*f);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;c=this.target.position;g=this.position;c.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=g.y+100*Math.cos(this.phi);c.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this, -this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; -THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))}; -THREE.PathCamera=function(b){function d(o,p,x,y){var t={name:x,fps:0.6,length:y,hierarchy:[]},u,I=p.getControlPointsArray(),H=p.getLength(),C=I.length,S=0;u=C-1;p={parent:-1,keys:[]};p.keys[0]={time:0,pos:I[0],rot:[0,0,0,1],scl:[1,1,1]};p.keys[u]={time:y,pos:I[u],rot:[0,0,0,1],scl:[1,1,1]};for(u=1;uthis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var g=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(g+this.autoSpeedFactor));this.moveBackward&&this.translateZ(g);this.moveLeft&&this.translateX(-g);this.moveRight&&this.translateX(g);g=this.tdiff*this.lookSpeed; +this.activeLook||(g=0);this.lon+=this.mouseX*g;this.lookVertical&&(this.lat-=this.mouseY*g);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;c=this.target.position;var h=this.position;c.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=h.y+100*Math.cos(this.phi);c.z=h.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*g;this.lookVertical&&(this.lat-=this.mouseY*g);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;c=this.target.position;h=this.position;c.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=h.y+100*Math.cos(this.phi);c.z=h.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",e(this, +this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; +THREE.QuakeCamera.prototype.translate=function(b,e){this.matrix.rotateAxis(e);if(this.noFly)e.y=0;this.position.addSelf(e.multiplyScalar(b));this.target.position.addSelf(e.multiplyScalar(b))}; +THREE.PathCamera=function(b){function e(p,t,w,A){var u={name:w,fps:0.6,length:A,hierarchy:[]},v,K=t.getControlPointsArray(),L=t.getLength(),F=K.length,T=0;v=F-1;t={parent:-1,keys:[]};t.keys[0]={time:0,pos:K[0],rot:[0,0,0,1],scl:[1,1,1]};t.keys[v]={time:A,pos:K[v],rot:[0,0,0,1],scl:[1,1,1]};for(v=1;v=0?y:y+g;y=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange; -var u=t[1]-t[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0]-t[0])/u)*u+t[0];y=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;u=t[1]-t[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-y[0])*(t[1]-t[0])/(y[1]-y[0])+t[0]-t[0])/u)*u+t[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,o,p,x)};this.onMouseMove= -function(o){this.mouseX=o.clientX-this.windowHalfX;this.mouseY=o.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10, -0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(o,p){return function(){p.apply(o,arguments)}}(this, +this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var h=Math.PI*2,j=Math.PI/180;this.update=function(p,t,w){var A,u;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)*j;this.theta=this.lon*j;A=this.phi%h;this.phi=A>=0?A:A+h;A=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange; +var v=u[1]-u[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-A[0])*(u[1]-u[0])/(A[1]-A[0])+u[0]-u[0])/v)*v+u[0];A=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;v=u[1]-u[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-A[0])*(u[1]-u[0])/(A[1]-A[0])+u[0]-u[0])/v)*v+u[0];A=this.target.position;A.x=100*Math.sin(this.phi)*Math.cos(this.theta);A.y=100*Math.cos(this.phi);A.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,t,w)};this.onMouseMove= +function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var k=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.Cube(10,10,20),n=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,k);b.position.set(0,10, +0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&g(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,t){return function(){t.apply(p,arguments)}}(this, this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; -THREE.FlyCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.005;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==undefined)this.autoForward= +THREE.FlyCamera=function(b){function e(c,g){return function(){g.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.dragToLook=!1;this.autoForward=!1;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==undefined)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==undefined)this.dragToLook=b.dragToLook;if(b.autoForward!==undefined)this.autoForward= b.autoForward;if(b.domElement!==undefined)this.domElement=b.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(c){if(typeof this[c.type]=="function")this[c.type](c)};this.keydown=function(c){if(!c.altKey){switch(c.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(c){switch(c.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(c){c.preventDefault();c.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(c){if(!this.dragToLook||this.mouseStatus>0){var f=this.getContainerDimensions(),g=f.size[0]/2,h=f.size[1]/2;this.moveState.yawLeft=-(c.clientX-f.offset[0]-g)/g;this.moveState.pitchDown=(c.clientY- -f.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(c){c.preventDefault();c.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var c=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=c;this.tdiff=(c-this.lastUpdate)/1E3;this.lastUpdate=c;c=this.tdiff*this.movementSpeed;var f=this.tdiff* -this.rollSpeed;this.translateX(this.moveVector.x*c);this.translateY(this.moveVector.y*c);this.translateZ(this.moveVector.z*c);this.tmpQuaternion.set(this.rotationVector.x*f,this.rotationVector.y*f,this.rotationVector.z*f,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 c=this.moveState.forward|| +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(c){c.preventDefault();c.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(c){if(!this.dragToLook||this.mouseStatus>0){var g=this.getContainerDimensions(),h=g.size[0]/2,j=g.size[1]/2;this.moveState.yawLeft=-(c.clientX-g.offset[0]-h)/h;this.moveState.pitchDown=(c.clientY- +g.offset[1]-j)/j;this.updateRotationVector()}};this.mouseup=function(c){c.preventDefault();c.stopPropagation();if(this.dragToLook){this.mouseStatus--;this.moveState.yawLeft=this.moveState.pitchDown=0}else switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var c=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=c;this.tdiff=(c-this.lastUpdate)/1E3;this.lastUpdate=c;c=this.tdiff*this.movementSpeed;var g=this.tdiff* +this.rollSpeed;this.translateX(this.moveVector.x*c);this.translateY(this.moveVector.y*c);this.translateZ(this.moveVector.z*c);this.tmpQuaternion.set(this.rotationVector.x*g,this.rotationVector.y*g,this.rotationVector.z*g,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 c=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=-c+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",d(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",d(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",d(this,this.mouseup),!1);window.addEventListener("keydown",d(this,this.keydown),!1);window.addEventListener("keyup",d(this, +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",e(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",e(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",e(this,this.mouseup),!1);window.addEventListener("keydown",e(this,this.keydown),!1);window.addEventListener("keyup",e(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(b,d,c,f){THREE.Camera.call(this,b,d,c,f);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,h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,o=1,p=0,x=0,y=0,t=0,u=0,I=window.innerWidth/2,H=window.innerHeight/2;this.update= -function(){var C=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=C;this.delta=(C-this.lastUpdate)/1E3;this.lastUpdate=C;if(this.mouseLook){C=this.delta*this.lookSpeed;this.rotateHorizontally(C*t);this.rotateVertically(C*u)}C=this.delta*this.movementSpeed;this.translateZ(C*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(C*x);this.translateY(C*y);m&&(this.roll+=this.rollSpeed*this.delta*o);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()}j.copy(this.forward);h.set(0,1,0);g.cross(h,j).normalize();h.cross(j,g).normalize();this.matrix.n11=g.x;this.matrix.n12=h.x;this.matrix.n13=j.x;this.matrix.n21=g.y;this.matrix.n22=h.y;this.matrix.n23=j.y;this.matrix.n31=g.z;this.matrix.n32=h.z;this.matrix.n33=j.z;k.identity();k.n11=Math.cos(this.roll);k.n12=-Math.sin(this.roll);k.n21=Math.sin(this.roll);k.n22=Math.cos(this.roll);this.matrix.multiplySelf(k); -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(C){this.position.x+=this.matrix.n11*C;this.position.y+=this.matrix.n21*C;this.position.z+=this.matrix.n31*C};this.translateY=function(C){this.position.x+=this.matrix.n12*C;this.position.y+=this.matrix.n22*C;this.position.z+=this.matrix.n32*C};this.translateZ=function(C){this.position.x-=this.matrix.n13*C;this.position.y-= -this.matrix.n23*C;this.position.z-=this.matrix.n33*C};this.rotateHorizontally=function(C){g.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);g.multiplyScalar(C);this.forward.subSelf(g);this.forward.normalize()};this.rotateVertically=function(C){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(C);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(C){C.preventDefault()},!1);this.domElement.addEventListener("mousemove", -function(C){t=(C.clientX-I)/window.innerWidth;u=(C.clientY-H)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(C){C.preventDefault();C.stopPropagation();switch(C.button){case 0:p=1;break;case 2:p=-1}},!1);this.domElement.addEventListener("mouseup",function(C){C.preventDefault();C.stopPropagation();switch(C.button){case 0:p=0;break;case 2:p=0}},!1);this.domElement.addEventListener("keydown",function(C){switch(C.keyCode){case 38:case 87:p=1;break;case 37:case 65:x=-1;break; -case 40:case 83:p=-1;break;case 39:case 68:x=1;break;case 81:m=!0;o=1;break;case 69:m=!0;o=-1;break;case 82:y=1;break;case 70:y=-1}},!1);this.domElement.addEventListener("keyup",function(C){switch(C.keyCode){case 38:case 87:p=0;break;case 37:case 65:x=0;break;case 40:case 83:p=0;break;case 39:case 68:x=0;break;case 81:m=!1;break;case 69:m=!1;break;case 82:y=0;break;case 70:y=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; +THREE.RollCamera=function(b,e,c,g){THREE.Camera.call(this,b,e,c,g);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 h=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,t=0,w=0,A=0,u=0,v=0,K=window.innerWidth/2,L=window.innerHeight/2;this.update= +function(){var F=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=F;this.delta=(F-this.lastUpdate)/1E3;this.lastUpdate=F;if(this.mouseLook){F=this.delta*this.lookSpeed;this.rotateHorizontally(F*u);this.rotateVertically(F*v)}F=this.delta*this.movementSpeed;this.translateZ(F*(t>0||this.autoForward&&!(t<0)?1:t));this.translateX(F*w);this.translateY(F*A);n&&(this.roll+=this.rollSpeed*this.delta*p);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()}k.copy(this.forward);j.set(0,1,0);h.cross(j,k).normalize();j.cross(k,h).normalize();this.matrix.n11=h.x;this.matrix.n12=j.x;this.matrix.n13=k.x;this.matrix.n21=h.y;this.matrix.n22=j.y;this.matrix.n23=k.y;this.matrix.n31=h.z;this.matrix.n32=j.z;this.matrix.n33=k.z;m.identity();m.n11=Math.cos(this.roll);m.n12=-Math.sin(this.roll);m.n21=Math.sin(this.roll);m.n22=Math.cos(this.roll);this.matrix.multiplySelf(m); +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(F){this.position.x+=this.matrix.n11*F;this.position.y+=this.matrix.n21*F;this.position.z+=this.matrix.n31*F};this.translateY=function(F){this.position.x+=this.matrix.n12*F;this.position.y+=this.matrix.n22*F;this.position.z+=this.matrix.n32*F};this.translateZ=function(F){this.position.x-=this.matrix.n13*F;this.position.y-= +this.matrix.n23*F;this.position.z-=this.matrix.n33*F};this.rotateHorizontally=function(F){h.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);h.multiplyScalar(F);this.forward.subSelf(h);this.forward.normalize()};this.rotateVertically=function(F){j.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);j.multiplyScalar(F);this.forward.addSelf(j);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(F){F.preventDefault()},!1);this.domElement.addEventListener("mousemove", +function(F){u=(F.clientX-K)/window.innerWidth;v=(F.clientY-L)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(F){F.preventDefault();F.stopPropagation();switch(F.button){case 0:t=1;break;case 2:t=-1}},!1);this.domElement.addEventListener("mouseup",function(F){F.preventDefault();F.stopPropagation();switch(F.button){case 0:t=0;break;case 2:t=0}},!1);this.domElement.addEventListener("keydown",function(F){switch(F.keyCode){case 38:case 87:t=1;break;case 37:case 65:w=-1;break; +case 40:case 83:t=-1;break;case 39:case 68:w=1;break;case 81:n=!0;p=1;break;case 69:n=!0;p=-1;break;case 82:A=1;break;case 70:A=-1}},!1);this.domElement.addEventListener("keyup",function(F){switch(F.keyCode){case 38:case 87:t=0;break;case 37:case 65:w=0;break;case 40:case 83:t=0;break;case 39:case 68:w=0;break;case 81:n=!1;break;case 69:n=!1;break;case 82:A=0;break;case 70:A=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera; THREE.RollCamera.prototype.supr=THREE.Camera.prototype; -THREE.Cube=function(b,d,c,f,g,h,j,k,m){function o(H,C,S,E,T,O,Q,ya){var aa,ga,X=f||1,ha=g||1,e=T/2,Ja=O/2,ta=p.vertices.length;if(H=="x"&&C=="y"||H=="y"&&C=="x")aa="z";else if(H=="x"&&C=="z"||H=="z"&&C=="x"){aa="y";ha=h||1}else if(H=="z"&&C=="y"||H=="y"&&C=="z"){aa="x";X=h||1}var Da=X+1,ca=ha+1;T/=X;var ua=O/ha;for(ga=0;ga0){j(0,0,-p-(h||0));for(m=b;m0){j(0,0,p+(g||0)); -for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0){k(0,0,-t-(j||0));for(n=b;n0){k(0,0,t+(h||0)); +for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,y)))-1);o.push(p)}d.push(o)}var t,u,I;g=d.length;for(c=0;c0)for(f=0;f1){t=this.vertices[j].position.clone(); -u=this.vertices[m].position.clone();I=this.vertices[o].position.clone();t.normalize();u.normalize();I.normalize();this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(I.x,I.y,I.z)]));this.faceVertexUvs[0].push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; -THREE.Torus=function(b,d,c,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c= -1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; -THREE.TorusKnot=function(b,d,c,f,g,h,j){function k(x,y,t,u,I,H){y=t/u*x;t=Math.cos(y);return new THREE.Vector3(I*(2+t)*0.5*Math.cos(x),I*(2+t)*Math.sin(x)*0.5,H*I*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b>7)-127;ja|=(Na&127)<<16|la<<8;if(ja==0&&hb==-127)return 0;return(1-2*(fb>>7))*(1+ja*Math.pow(2,-23))*Math.pow(2,hb)}function k(L,Z){var ja=p(L,Z),la=p(L,Z+1),Na=p(L,Z+2);return(p(L,Z+3)<<24)+(Na<<16)+(la<<8)+ja}function m(L,Z){var ja=p(L,Z);return(p(L,Z+1)<<8)+ja}function o(L,Z){var ja=p(L,Z);return ja> -127?ja-256:ja}function p(L,Z){return L.charCodeAt(Z)&255}function x(L){var Z,ja,la;Z=k(b,L);ja=k(b,L+Q);la=k(b,L+ya);L=m(b,L+aa);THREE.BinaryLoader.prototype.f3(C,Z,ja,la,L)}function y(L){var Z,ja,la,Na,fb,hb;Z=k(b,L);ja=k(b,L+Q);la=k(b,L+ya);Na=m(b,L+aa);fb=k(b,L+ga);hb=k(b,L+X);L=k(b,L+ha);THREE.BinaryLoader.prototype.f3n(C,T,Z,ja,la,Na,fb,hb,L)}function t(L){var Z,ja,la,Na;Z=k(b,L);ja=k(b,L+e);la=k(b,L+Ja);Na=k(b,L+ta);L=m(b,L+Da);THREE.BinaryLoader.prototype.f4(C,Z,ja,la,Na,L)}function u(L){var Z, -ja,la,Na,fb,hb,Ga,ka;Z=k(b,L);ja=k(b,L+e);la=k(b,L+Ja);Na=k(b,L+ta);fb=m(b,L+Da);hb=k(b,L+ca);Ga=k(b,L+ua);ka=k(b,L+da);L=k(b,L+sa);THREE.BinaryLoader.prototype.f4n(C,T,Z,ja,la,Na,fb,hb,Ga,ka,L)}function I(L){var Z,ja;Z=k(b,L);ja=k(b,L+na);L=k(b,L+ra);THREE.BinaryLoader.prototype.uv3(C.faceVertexUvs[0],O[Z*2],O[Z*2+1],O[ja*2],O[ja*2+1],O[L*2],O[L*2+1])}function H(L){var Z,ja,la;Z=k(b,L);ja=k(b,L+oa);la=k(b,L+ea);L=k(b,L+Aa);THREE.BinaryLoader.prototype.uv4(C.faceVertexUvs[0],O[Z*2],O[Z*2+1],O[ja* -2],O[ja*2+1],O[la*2],O[la*2+1],O[L*2],O[L*2+1])}var C=this,S=0,E,T=[],O=[],Q,ya,aa,ga,X,ha,e,Ja,ta,Da,ca,ua,da,sa,na,ra,oa,ea,Aa,Oa,fa,xa,Ma,Qa,Ua;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,f,h);E={signature:b.substr(S,8),header_bytes:p(b,S+8),vertex_coordinate_bytes:p(b,S+9),normal_coordinate_bytes:p(b,S+10),uv_coordinate_bytes:p(b,S+11),vertex_index_bytes:p(b,S+12),normal_index_bytes:p(b,S+13),uv_index_bytes:p(b,S+14),material_index_bytes:p(b,S+15),nvertices:k(b,S+16),nnormals:k(b, -S+16+4),nuvs:k(b,S+16+8),ntri_flat:k(b,S+16+12),ntri_smooth:k(b,S+16+16),ntri_flat_uv:k(b,S+16+20),ntri_smooth_uv:k(b,S+16+24),nquad_flat:k(b,S+16+28),nquad_smooth:k(b,S+16+32),nquad_flat_uv:k(b,S+16+36),nquad_smooth_uv:k(b,S+16+40)};S+=E.header_bytes;Q=E.vertex_index_bytes;ya=E.vertex_index_bytes*2;aa=E.vertex_index_bytes*3;ga=E.vertex_index_bytes*3+E.material_index_bytes;X=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes;ha=E.vertex_index_bytes*3+E.material_index_bytes+E.normal_index_bytes* -2;e=E.vertex_index_bytes;Ja=E.vertex_index_bytes*2;ta=E.vertex_index_bytes*3;Da=E.vertex_index_bytes*4;ca=E.vertex_index_bytes*4+E.material_index_bytes;ua=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes;da=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*2;sa=E.vertex_index_bytes*4+E.material_index_bytes+E.normal_index_bytes*3;na=E.uv_index_bytes;ra=E.uv_index_bytes*2;oa=E.uv_index_bytes;ea=E.uv_index_bytes*2;Aa=E.uv_index_bytes*3;h=E.vertex_index_bytes*3+E.material_index_bytes; -Ua=E.vertex_index_bytes*4+E.material_index_bytes;Oa=E.ntri_flat*h;fa=E.ntri_smooth*(h+E.normal_index_bytes*3);xa=E.ntri_flat_uv*(h+E.uv_index_bytes*3);Ma=E.ntri_smooth_uv*(h+E.normal_index_bytes*3+E.uv_index_bytes*3);Qa=E.nquad_flat*Ua;h=E.nquad_smooth*(Ua+E.normal_index_bytes*4);Ua=E.nquad_flat_uv*(Ua+E.uv_index_bytes*4);S+=function(L){for(var Z,ja,la,Na=E.vertex_coordinate_bytes*3,fb=L+E.nvertices*Na;L1&&(ga=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(Q,ga);object.name=t;object.position.set(E[0],E[1],E[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=S.visible;ca.scene.addObject(object);ca.objects[t]=object;if(S.meshCollider){var na=THREE.CollisionUtils.MeshColliderWBox(object);ca.scene.collisions.colliders.push(na)}if(S.castsShadow){na= -new THREE.ShadowVolume(Q);ca.scene.addChild(na);na.position=object.position;na.rotation=object.rotation;na.scale=object.scale}if(S.trigger&&S.trigger.toLowerCase()!="none"){na={type:S.trigger,object:S};ca.triggers[object.name]=na}}}else{E=S.position;r=S.rotation;q=S.quaternion;s=S.scale;q=0;object=new THREE.Object3D;object.name=t;object.position.set(E[0],E[1],E[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=S.visible!==undefined?S.visible:!1;ca.scene.addObject(object);ca.objects[t]=object;ca.empties[t]=object;if(S.trigger&&S.trigger.toLowerCase()!="none"){na={type:S.trigger,object:S};ca.triggers[object.name]=na}}}}function m(na){return function(ra){ca.geometries[na]=ra;k();e-=1;c.onLoadComplete();p()}}function o(na){return function(ra){ca.geometries[na]=ra}}function p(){c.callbackProgress({totalModels:ta,totalTextures:Da,loadedModels:ta-e,loadedTextures:Da-Ja},ca);c.onLoadProgress(); -e==0&&Ja==0&&d(ca)}var x,y,t,u,I,H,C,S,E,T,O,Q,ya,aa,ga,X,ha,e,Ja,ta,Da,ca;X=h.data;h=new THREE.BinaryLoader;ha=new THREE.JSONLoader;Ja=e=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var ua=!1;for(t in X.objects){S=X.objects[t];if(S.meshCollider){ua=!0;break}}if(ua)ca.scene.collisions=new THREE.CollisionSystem;if(X.transform){ua=X.transform.position;T=X.transform.rotation;var da=X.transform.scale;ua&&ca.scene.position.set(ua[0], -ua[1],ua[2]);T&&ca.scene.rotation.set(T[0],T[1],T[2]);da&&ca.scene.scale.set(da[0],da[1],da[2]);(ua||T||da)&&ca.scene.updateMatrix()}ua=function(){Ja-=1;p();c.onLoadComplete()};for(I in X.cameras){T=X.cameras[I];if(T.type=="perspective")ya=new THREE.Camera(T.fov,T.aspect,T.near,T.far);else if(T.type=="ortho"){ya=new THREE.Camera;ya.projectionMatrix=THREE.Matrix4.makeOrtho(T.left,T.right,T.top,T.bottom,T.near,T.far)}E=T.position;T=T.target;ya.position.set(E[0],E[1],E[2]);ya.target.position.set(T[0], -T[1],T[2]);ca.cameras[I]=ya}for(u in X.lights){I=X.lights[u];ya=I.color!==undefined?I.color:16777215;T=I.intensity!==undefined?I.intensity:1;if(I.type=="directional"){E=I.direction;light=new THREE.DirectionalLight(ya,T);light.position.set(E[0],E[1],E[2]);light.position.normalize()}else if(I.type=="point"){E=I.position;light=new THREE.PointLight(ya,T);light.position.set(E[0],E[1],E[2])}ca.scene.addLight(light);ca.lights[u]=light}for(H in X.fogs){u=X.fogs[H];if(u.type=="linear")aa=new THREE.Fog(0,u.near, -u.far);else u.type=="exp2"&&(aa=new THREE.FogExp2(0,u.density));T=u.color;aa.color.setRGB(T[0],T[1],T[2]);ca.fogs[H]=aa}if(ca.cameras&&X.defaults.camera)ca.currentCamera=ca.cameras[X.defaults.camera];if(ca.fogs&&X.defaults.fog)ca.scene.fog=ca.fogs[X.defaults.fog];T=X.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(T[0],T[1],T[2]);ca.bgColorAlpha=X.defaults.bgalpha;for(x in X.geometries){H=X.geometries[x];if(H.type=="bin_mesh"||H.type=="ascii_mesh"){e+=1;c.onLoadStart()}}ta=e;for(x in X.geometries){H= -X.geometries[x];if(H.type=="cube"){Q=new THREE.Cube(H.width,H.height,H.depth,H.segmentsWidth,H.segmentsHeight,H.segmentsDepth,null,H.flipped,H.sides);ca.geometries[x]=Q}else if(H.type=="plane"){Q=new THREE.Plane(H.width,H.height,H.segmentsWidth,H.segmentsHeight);ca.geometries[x]=Q}else if(H.type=="sphere"){Q=new THREE.Sphere(H.radius,H.segmentsWidth,H.segmentsHeight);ca.geometries[x]=Q}else if(H.type=="cylinder"){Q=new THREE.Cylinder(H.numSegs,H.topRad,H.botRad,H.height,H.topOffset,H.botOffset);ca.geometries[x]= -Q}else if(H.type=="torus"){Q=new THREE.Torus(H.radius,H.tube,H.segmentsR,H.segmentsT);ca.geometries[x]=Q}else if(H.type=="icosahedron"){Q=new THREE.Icosahedron(H.subdivisions);ca.geometries[x]=Q}else if(H.type=="bin_mesh")h.load({model:j(H.url,X.urlBaseType),callback:m(x)});else if(H.type=="ascii_mesh")ha.load({model:j(H.url,X.urlBaseType),callback:m(x)});else if(H.type=="embedded_mesh")(H=X.embeds[H.id])&&ha.createModel(H,o(x),"")}for(C in X.textures){x=X.textures[C];if(x.url instanceof Array){Ja+= -x.url.length;for(h=0;h=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;fthis.size-1&&(m=this.size-1);var y=Math.floor(o-k);y<1&&(y=1);o=Math.floor(o+k);o>this.size-1&&(o= -this.size-1);var t=Math.floor(p-k);t<1&&(t=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size-1);for(var u,I,H,C,S,E;x0&&(this.field[H+u]+=C)}}}};this.addPlaneX=function(c,f){var g,h,j,k,m,o=this.size,p=this.yd,x=this.zd,y=this.field,t=o*Math.sqrt(c/f);t>o&&(t=o);for(g=0;g0)for(h=0;hp&&(u=p);for(h=0;h0){m=h*x;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(h=0;h0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,m,A)))-1);p.push(t)}e.push(p)}var u,v,K;h=e.length;for(c=0;c0)for(g=0;g1){u=this.vertices[k].position.clone(); +v=this.vertices[n].position.clone();K=this.vertices[p].position.clone();u.normalize();v.normalize();K.normalize();this.faces.push(new THREE.Face3(k,n,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(K.x,K.y,K.z)]));this.faceVertexUvs[0].push([t,w,L])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; +THREE.Torus=function(b,e,c,g){THREE.Geometry.call(this);this.radius=b||100;this.tube=e||40;this.segmentsR=c||8;this.segmentsT=g||6;b=[];for(e=0;e<=this.segmentsR;++e)for(c=0;c<=this.segmentsT;++c){g=c/this.segmentsT*2*Math.PI;var h=e/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(h))*Math.cos(g),(this.radius+this.tube*Math.cos(h))*Math.sin(g),this.tube*Math.sin(h))));b.push([c/this.segmentsT,1-e/this.segmentsR])}for(e=1;e<=this.segmentsR;++e)for(c= +1;c<=this.segmentsT;++c){g=(this.segmentsT+1)*e+c;h=(this.segmentsT+1)*e+c-1;var j=(this.segmentsT+1)*(e-1)+c-1,k=(this.segmentsT+1)*(e-1)+c;this.faces.push(new THREE.Face4(g,h,j,k));this.faceVertexUvs[0].push([new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[k][0],b[k][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; +THREE.TorusKnot=function(b,e,c,g,h,j,k){function m(w,A,u,v,K,L){A=u/v*w;u=Math.cos(A);return new THREE.Vector3(K*(2+u)*0.5*Math.cos(w),K*(2+u)*Math.sin(w)*0.5,L*K*Math.sin(A)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=e||40;this.segmentsR=c||64;this.segmentsT=g||8;this.p=h||2;this.q=j||3;this.heightScale=k||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;g=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b0;){if(j){if(j.equals(contour[h])){j=null;continue}}else j=contour[h];for(c=0;c=0?t-1:g.length-1;nextShapeVert=t+1=0?p-1:b.length-1;nextHoleVert=p+12;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");return null}var w=n;j<=w&&(w=0);n=w+1;j<=n&&(n=0);var A=n+1;j<=A&&(A=0);var u;a:{u=c;var v=w,K=n,L=A,F=j,T=k,G=void 0,V=void 0,P=void 0, +R=void 0,ya=void 0,da=void 0,ja=void 0,$=void 0,ka=void 0;V=u[T[v]].x;P=u[T[v]].y;R=u[T[K]].x;ya=u[T[K]].y;da=u[T[L]].x;ja=u[T[L]].y;if(1.0E-10>(R-V)*(ja-P)-(ya-P)*(da-V))u=!1;else{for(G=0;G=0&&qa>=0&&ea>=0){u=!1;break a}}u=!0}}if(u){p=k[w];u=k[n];v=k[A];h.push(c[p]);h.push(c[u]);h.push(c[v]);m.push([k[w],k[n],k[A]]);t++;w=n;for(A=n+1;A>7)-127;ma|=(Qa&127)<<16|ra<<8;if(ma==0&&kb==-127)return 0;return(1-2*(ib>>7))*(1+ma*Math.pow(2,-23))*Math.pow(2,kb)}function m(O,ca){var ma=t(O,ca),ra=t(O,ca+1),Qa=t(O,ca+2);return(t(O,ca+3)<<24)+(Qa<<16)+(ra<<8)+ma}function n(O,ca){var ma=t(O,ca);return(t(O,ca+1)<<8)+ma}function p(O,ca){var ma=t(O, +ca);return ma>127?ma-256:ma}function t(O,ca){return O.charCodeAt(ca)&255}function w(O){var ca,ma,ra;ca=m(b,O);ma=m(b,O+R);ra=m(b,O+ya);O=n(b,O+da);THREE.BinaryLoader.prototype.f3(F,ca,ma,ra,O)}function A(O){var ca,ma,ra,Qa,ib,kb;ca=m(b,O);ma=m(b,O+R);ra=m(b,O+ya);Qa=n(b,O+da);ib=m(b,O+ja);kb=m(b,O+$);O=m(b,O+ka);THREE.BinaryLoader.prototype.f3n(F,V,ca,ma,ra,Qa,ib,kb,O)}function u(O){var ca,ma,ra,Qa;ca=m(b,O);ma=m(b,O+f);ra=m(b,O+Ja);Qa=m(b,O+qa);O=n(b,O+Da);THREE.BinaryLoader.prototype.f4(F,ca,ma, +ra,Qa,O)}function v(O){var ca,ma,ra,Qa,ib,kb,Ka,pa;ca=m(b,O);ma=m(b,O+f);ra=m(b,O+Ja);Qa=m(b,O+qa);ib=n(b,O+Da);kb=m(b,O+ea);Ka=m(b,O+xa);pa=m(b,O+ga);O=m(b,O+wa);THREE.BinaryLoader.prototype.f4n(F,V,ca,ma,ra,Qa,ib,kb,Ka,pa,O)}function K(O){var ca,ma;ca=m(b,O);ma=m(b,O+na);O=m(b,O+ua);THREE.BinaryLoader.prototype.uv3(F.faceVertexUvs[0],P[ca*2],P[ca*2+1],P[ma*2],P[ma*2+1],P[O*2],P[O*2+1])}function L(O){var ca,ma,ra;ca=m(b,O);ma=m(b,O+oa);ra=m(b,O+ha);O=m(b,O+Ea);THREE.BinaryLoader.prototype.uv4(F.faceVertexUvs[0], +P[ca*2],P[ca*2+1],P[ma*2],P[ma*2+1],P[ra*2],P[ra*2+1],P[O*2],P[O*2+1])}var F=this,T=0,G,V=[],P=[],R,ya,da,ja,$,ka,f,Ja,qa,Da,ea,xa,ga,wa,na,ua,oa,ha,Ea,Ra,ia,Ba,Pa,Ta,Xa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,g,j);G={signature:b.substr(T,8),header_bytes:t(b,T+8),vertex_coordinate_bytes:t(b,T+9),normal_coordinate_bytes:t(b,T+10),uv_coordinate_bytes:t(b,T+11),vertex_index_bytes:t(b,T+12),normal_index_bytes:t(b,T+13),uv_index_bytes:t(b,T+14),material_index_bytes:t(b,T+15), +nvertices:m(b,T+16),nnormals:m(b,T+16+4),nuvs:m(b,T+16+8),ntri_flat:m(b,T+16+12),ntri_smooth:m(b,T+16+16),ntri_flat_uv:m(b,T+16+20),ntri_smooth_uv:m(b,T+16+24),nquad_flat:m(b,T+16+28),nquad_smooth:m(b,T+16+32),nquad_flat_uv:m(b,T+16+36),nquad_smooth_uv:m(b,T+16+40)};T+=G.header_bytes;R=G.vertex_index_bytes;ya=G.vertex_index_bytes*2;da=G.vertex_index_bytes*3;ja=G.vertex_index_bytes*3+G.material_index_bytes;$=G.vertex_index_bytes*3+G.material_index_bytes+G.normal_index_bytes;ka=G.vertex_index_bytes* +3+G.material_index_bytes+G.normal_index_bytes*2;f=G.vertex_index_bytes;Ja=G.vertex_index_bytes*2;qa=G.vertex_index_bytes*3;Da=G.vertex_index_bytes*4;ea=G.vertex_index_bytes*4+G.material_index_bytes;xa=G.vertex_index_bytes*4+G.material_index_bytes+G.normal_index_bytes;ga=G.vertex_index_bytes*4+G.material_index_bytes+G.normal_index_bytes*2;wa=G.vertex_index_bytes*4+G.material_index_bytes+G.normal_index_bytes*3;na=G.uv_index_bytes;ua=G.uv_index_bytes*2;oa=G.uv_index_bytes;ha=G.uv_index_bytes*2;Ea=G.uv_index_bytes* +3;j=G.vertex_index_bytes*3+G.material_index_bytes;Xa=G.vertex_index_bytes*4+G.material_index_bytes;Ra=G.ntri_flat*j;ia=G.ntri_smooth*(j+G.normal_index_bytes*3);Ba=G.ntri_flat_uv*(j+G.uv_index_bytes*3);Pa=G.ntri_smooth_uv*(j+G.normal_index_bytes*3+G.uv_index_bytes*3);Ta=G.nquad_flat*Xa;j=G.nquad_smooth*(Xa+G.normal_index_bytes*4);Xa=G.nquad_flat_uv*(Xa+G.uv_index_bytes*4);T+=function(O){for(var ca,ma,ra,Qa=G.vertex_coordinate_bytes*3,ib=O+G.nvertices*Qa;O1&&(ja=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(R,ja);object.name=u;object.position.set(G[0],G[1],G[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=T.visible;ea.scene.addObject(object);ea.objects[u]=object;if(T.meshCollider){var na=THREE.CollisionUtils.MeshColliderWBox(object);ea.scene.collisions.colliders.push(na)}if(T.castsShadow){na= +new THREE.ShadowVolume(R);ea.scene.addChild(na);na.position=object.position;na.rotation=object.rotation;na.scale=object.scale}if(T.trigger&&T.trigger.toLowerCase()!="none"){na={type:T.trigger,object:T};ea.triggers[object.name]=na}}}else{G=T.position;r=T.rotation;q=T.quaternion;s=T.scale;q=0;object=new THREE.Object3D;object.name=u;object.position.set(G[0],G[1],G[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=T.visible!==undefined?T.visible:!1;ea.scene.addObject(object);ea.objects[u]=object;ea.empties[u]=object;if(T.trigger&&T.trigger.toLowerCase()!="none"){na={type:T.trigger,object:T};ea.triggers[object.name]=na}}}}function n(na){return function(ua){ea.geometries[na]=ua;m();f-=1;c.onLoadComplete();t()}}function p(na){return function(ua){ea.geometries[na]=ua}}function t(){c.callbackProgress({totalModels:qa,totalTextures:Da,loadedModels:qa-f,loadedTextures:Da-Ja},ea);c.onLoadProgress(); +f==0&&Ja==0&&e(ea)}var w,A,u,v,K,L,F,T,G,V,P,R,ya,da,ja,$,ka,f,Ja,qa,Da,ea;$=j.data;j=new THREE.BinaryLoader;ka=new THREE.JSONLoader;Ja=f=0;ea={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var xa=!1;for(u in $.objects){T=$.objects[u];if(T.meshCollider){xa=!0;break}}if(xa)ea.scene.collisions=new THREE.CollisionSystem;if($.transform){xa=$.transform.position;V=$.transform.rotation;var ga=$.transform.scale;xa&&ea.scene.position.set(xa[0], +xa[1],xa[2]);V&&ea.scene.rotation.set(V[0],V[1],V[2]);ga&&ea.scene.scale.set(ga[0],ga[1],ga[2]);(xa||V||ga)&&ea.scene.updateMatrix()}xa=function(){Ja-=1;t();c.onLoadComplete()};for(K in $.cameras){V=$.cameras[K];if(V.type=="perspective")ya=new THREE.Camera(V.fov,V.aspect,V.near,V.far);else if(V.type=="ortho"){ya=new THREE.Camera;ya.projectionMatrix=THREE.Matrix4.makeOrtho(V.left,V.right,V.top,V.bottom,V.near,V.far)}G=V.position;V=V.target;ya.position.set(G[0],G[1],G[2]);ya.target.position.set(V[0], +V[1],V[2]);ea.cameras[K]=ya}for(v in $.lights){K=$.lights[v];ya=K.color!==undefined?K.color:16777215;V=K.intensity!==undefined?K.intensity:1;if(K.type=="directional"){G=K.direction;light=new THREE.DirectionalLight(ya,V);light.position.set(G[0],G[1],G[2]);light.position.normalize()}else if(K.type=="point"){G=K.position;light=new THREE.PointLight(ya,V);light.position.set(G[0],G[1],G[2])}ea.scene.addLight(light);ea.lights[v]=light}for(L in $.fogs){v=$.fogs[L];if(v.type=="linear")da=new THREE.Fog(0,v.near, +v.far);else v.type=="exp2"&&(da=new THREE.FogExp2(0,v.density));V=v.color;da.color.setRGB(V[0],V[1],V[2]);ea.fogs[L]=da}if(ea.cameras&&$.defaults.camera)ea.currentCamera=ea.cameras[$.defaults.camera];if(ea.fogs&&$.defaults.fog)ea.scene.fog=ea.fogs[$.defaults.fog];V=$.defaults.bgcolor;ea.bgColor=new THREE.Color;ea.bgColor.setRGB(V[0],V[1],V[2]);ea.bgColorAlpha=$.defaults.bgalpha;for(w in $.geometries){L=$.geometries[w];if(L.type=="bin_mesh"||L.type=="ascii_mesh"){f+=1;c.onLoadStart()}}qa=f;for(w in $.geometries){L= +$.geometries[w];if(L.type=="cube"){R=new THREE.Cube(L.width,L.height,L.depth,L.segmentsWidth,L.segmentsHeight,L.segmentsDepth,null,L.flipped,L.sides);ea.geometries[w]=R}else if(L.type=="plane"){R=new THREE.Plane(L.width,L.height,L.segmentsWidth,L.segmentsHeight);ea.geometries[w]=R}else if(L.type=="sphere"){R=new THREE.Sphere(L.radius,L.segmentsWidth,L.segmentsHeight);ea.geometries[w]=R}else if(L.type=="cylinder"){R=new THREE.Cylinder(L.numSegs,L.topRad,L.botRad,L.height,L.topOffset,L.botOffset);ea.geometries[w]= +R}else if(L.type=="torus"){R=new THREE.Torus(L.radius,L.tube,L.segmentsR,L.segmentsT);ea.geometries[w]=R}else if(L.type=="icosahedron"){R=new THREE.Icosahedron(L.subdivisions);ea.geometries[w]=R}else if(L.type=="bin_mesh")j.load({model:k(L.url,$.urlBaseType),callback:n(w)});else if(L.type=="ascii_mesh")ka.load({model:k(L.url,$.urlBaseType),callback:n(w)});else if(L.type=="embedded_mesh")(L=$.embeds[L.id])&&ka.createModel(L,p(w),"")}for(F in $.textures){w=$.textures[F];if(w.url instanceof Array){Ja+= +w.url.length;for(j=0;j=this.maxCount-3&&m(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var g=this.count*3;gthis.size-1&&(n=this.size-1);var A=Math.floor(p-m);A<1&&(A=1);p=Math.floor(p+m);p>this.size-1&&(p= +this.size-1);var u=Math.floor(t-m);u<1&&(u=1);m=Math.floor(t+m);m>this.size-1&&(m=this.size-1);for(var v,K,L,F,T,G;w0&&(this.field[L+v]+=F)}}}};this.addPlaneX=function(c,g){var h,j,k,m,n,p=this.size,t=this.yd,w=this.zd,A=this.field,u=p*Math.sqrt(c/g);u>p&&(u=p);for(h=0;h0)for(j=0;jt&&(v=t);for(j=0;j0){n=j*w;for(h=0;hsize&&(dist=size);for(k=0;k0){n=zd*k;for(j=0;jh?this.hits.push(g):this.hits.unshift(g);h=f}}return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(b){var d=this.rayCastAll(b);if(d.length==0)return null;for(var c=0;d[c]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,d[c]);if(f.distd.length)return null;return d[c]}; -THREE.CollisionSystem.prototype.rayCast=function(b,d){if(d instanceof THREE.PlaneCollider)return this.rayPlane(b,d);else if(d instanceof THREE.SphereCollider)return this.raySphere(b,d);else if(d instanceof THREE.BoxCollider)return this.rayBox(b,d);else if(d instanceof THREE.MeshCollider&&d.box)return this.rayBox(b,d.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,d){for(var c=this.makeRayLocal(b,d.mesh),f=Number.MAX_VALUE,g,h=0;h=k*g))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);if(Math.abs(h.x)>Math.abs(h.y))if(Math.abs(h.x)>Math.abs(h.z)){b=k.y-d.y;h=c.y- -d.y;g=f.y-d.y;k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}else if(Math.abs(h.y)>Math.abs(h.z)){b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.z-d.z;c=c.z-d.z;f=f.z-d.z}else{b=k.x-d.x;h=c.x-d.x;g=f.x-d.x;k=k.y-d.y;c=c.y-d.y;f=f.y-d.y}d=h*f-c*g;if(d==0)return Number.MAX_VALUE;d=1/d;f=(b*f-k*g)*d;if(!(f>=0))return Number.MAX_VALUE;d*=h*k-c*b;if(!(d>=0))return Number.MAX_VALUE;if(!(1-f-d>=0))return Number.MAX_VALUE;return j}; -THREE.CollisionSystem.prototype.makeRayLocal=function(b,d){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(d.matrixWorld,c);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);c.multiplyVector3(f.origin);c.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,d){var c;if(d.dynamic&&d.mesh&&d.mesh.matrixWorld)c=this.makeRayLocal(b,d.mesh);else{c=THREE.CollisionSystem.__r;c.origin.copy(b.origin);c.direction.copy(b.direction)}var f=0,g=0,h=0,j=0,k=0,m=0,o=!0;if(c.origin.xd.max.x){f=d.max.x-c.origin.x;f/=c.direction.x;o=!1;j=1}if(c.origin.yd.max.y){g=d.max.y- -c.origin.y;g/=c.direction.y;o=!1;k=1}if(c.origin.zd.max.z){h=d.max.z-c.origin.z;h/=c.direction.z;o=!1;m=1}if(o)return-1;o=0;if(g>f){o=1;f=g}if(h>f){o=2;f=h}switch(o){case 0:k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal.set(j,0,0);break;case 1:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE; -c=c.origin.z+c.direction.z*f;if(cd.max.z)return Number.MAX_VALUE;d.normal.set(0,k,0);break;case 2:j=c.origin.x+c.direction.x*f;if(jd.max.x)return Number.MAX_VALUE;k=c.origin.y+c.direction.y*f;if(kd.max.y)return Number.MAX_VALUE;d.normal.set(0,0,m)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,d){var c=b.direction.dot(d.normal),f=d.point.dot(d.normal);if(c<0)c=(f-b.origin.dot(d.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(b,d){var c=d.center.clone().subSelf(b.origin);if(c.lengthSq=0)return Math.abs(f)-Math.sqrt(c);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(b){b.geometry.computeBoundingBox();var d=b.geometry.boundingBox,c=new THREE.Vector3(d.x[0],d.y[0],d.z[0]);d=new THREE.Vector3(d.x[1],d.y[1],d.z[1]);c=new THREE.BoxCollider(c,d);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var d=THREE.CollisionUtils.MeshOBB(b);d.min.addSelf(b.position);d.max.addSelf(b.position);d.dynamic=!1;return d}; +THREE.Trident=function(b){function e(j){return new THREE.Mesh(new THREE.Cylinder(30,0.1,b.length/20,b.length/5),new THREE.MeshBasicMaterial({color:j}))}function c(j,k){var m=new THREE.Geometry;m.vertices=[new THREE.Vertex,new THREE.Vertex(j)];return new THREE.Line(m,new THREE.LineBasicMaterial({color:k}))}THREE.Object3D.call(this);var g=Math.PI/2,h;b=b||THREE.Trident.defaultParams;if(b!==THREE.Trident.defaultParams)for(h in THREE.Trident.defaultParams)b.hasOwnProperty(h)||(b[h]=THREE.Trident.defaultParams[h]); +this.scale=new THREE.Vector3(b.scale,b.scale,b.scale);this.addChild(c(new THREE.Vector3(b.length,0,0),b.xAxisColor));this.addChild(c(new THREE.Vector3(0,b.length,0),b.yAxisColor));this.addChild(c(new THREE.Vector3(0,0,b.length),b.zAxisColor));if(b.showArrows){h=e(b.xAxisColor);h.rotation.y=-g;h.position.x=b.length;this.addChild(h);h=e(b.yAxisColor);h.rotation.x=g;h.position.y=b.length;this.addChild(h);h=e(b.zAxisColor);h.rotation.y=Math.PI;h.position.z=b.length;this.addChild(h)}}; +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(b,e){this.point=b;this.normal=e};THREE.SphereCollider=function(b,e){this.center=b;this.radius=e;this.radiusSq=e*e};THREE.BoxCollider=function(b,e){this.min=b;this.max=e;this.dynamic=!0;this.normal=new THREE.Vector3}; +THREE.MeshCollider=function(b,e){this.mesh=b;this.box=e;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(b){this.colliders=this.colliders.concat(b.colliders);this.hits=this.hits.concat(b.hits)}; +THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var e,c,g,h,j=0;e=0;for(c=this.colliders.length;ej?this.hits.push(h):this.hits.unshift(h);j=g}}return this.hits}; +THREE.CollisionSystem.prototype.rayCastNearest=function(b){var e=this.rayCastAll(b);if(e.length==0)return null;for(var c=0;e[c]instanceof THREE.MeshCollider;){var g=this.rayMesh(b,e[c]);if(g.diste.length)return null;return e[c]}; +THREE.CollisionSystem.prototype.rayCast=function(b,e){if(e instanceof THREE.PlaneCollider)return this.rayPlane(b,e);else if(e instanceof THREE.SphereCollider)return this.raySphere(b,e);else if(e instanceof THREE.BoxCollider)return this.rayBox(b,e);else if(e instanceof THREE.MeshCollider&&e.box)return this.rayBox(b,e.box)}; +THREE.CollisionSystem.prototype.rayMesh=function(b,e){for(var c=this.makeRayLocal(b,e.mesh),g=Number.MAX_VALUE,h,j=0;j=m*h))return Number.MAX_VALUE;k/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(k);m.addSelf(b.origin);if(Math.abs(j.x)>Math.abs(j.y))if(Math.abs(j.x)>Math.abs(j.z)){b=m.y-e.y;j=c.y- +e.y;h=g.y-e.y;m=m.z-e.z;c=c.z-e.z;g=g.z-e.z}else{b=m.x-e.x;j=c.x-e.x;h=g.x-e.x;m=m.y-e.y;c=c.y-e.y;g=g.y-e.y}else if(Math.abs(j.y)>Math.abs(j.z)){b=m.x-e.x;j=c.x-e.x;h=g.x-e.x;m=m.z-e.z;c=c.z-e.z;g=g.z-e.z}else{b=m.x-e.x;j=c.x-e.x;h=g.x-e.x;m=m.y-e.y;c=c.y-e.y;g=g.y-e.y}e=j*g-c*h;if(e==0)return Number.MAX_VALUE;e=1/e;g=(b*g-m*h)*e;if(!(g>=0))return Number.MAX_VALUE;e*=j*m-c*b;if(!(e>=0))return Number.MAX_VALUE;if(!(1-g-e>=0))return Number.MAX_VALUE;return k}; +THREE.CollisionSystem.prototype.makeRayLocal=function(b,e){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(e.matrixWorld,c);var g=THREE.CollisionSystem.__r;g.origin.copy(b.origin);g.direction.copy(b.direction);c.multiplyVector3(g.origin);c.rotateAxis(g.direction);g.direction.normalize();return g}; +THREE.CollisionSystem.prototype.rayBox=function(b,e){var c;if(e.dynamic&&e.mesh&&e.mesh.matrixWorld)c=this.makeRayLocal(b,e.mesh);else{c=THREE.CollisionSystem.__r;c.origin.copy(b.origin);c.direction.copy(b.direction)}var g=0,h=0,j=0,k=0,m=0,n=0,p=!0;if(c.origin.xe.max.x){g=e.max.x-c.origin.x;g/=c.direction.x;p=!1;k=1}if(c.origin.ye.max.y){h=e.max.y- +c.origin.y;h/=c.direction.y;p=!1;m=1}if(c.origin.ze.max.z){j=e.max.z-c.origin.z;j/=c.direction.z;p=!1;n=1}if(p)return-1;p=0;if(h>g){p=1;g=h}if(j>g){p=2;g=j}switch(p){case 0:m=c.origin.y+c.direction.y*g;if(me.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*g;if(ce.max.z)return Number.MAX_VALUE;e.normal.set(k,0,0);break;case 1:k=c.origin.x+c.direction.x*g;if(ke.max.x)return Number.MAX_VALUE; +c=c.origin.z+c.direction.z*g;if(ce.max.z)return Number.MAX_VALUE;e.normal.set(0,m,0);break;case 2:k=c.origin.x+c.direction.x*g;if(ke.max.x)return Number.MAX_VALUE;m=c.origin.y+c.direction.y*g;if(me.max.y)return Number.MAX_VALUE;e.normal.set(0,0,n)}return g};THREE.CollisionSystem.prototype.rayPlane=function(b,e){var c=b.direction.dot(e.normal),g=e.point.dot(e.normal);if(c<0)c=(g-b.origin.dot(e.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.raySphere=function(b,e){var c=e.center.clone().subSelf(b.origin);if(c.lengthSq=0)return Math.abs(g)-Math.sqrt(c);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(b){b.geometry.computeBoundingBox();var e=b.geometry.boundingBox,c=new THREE.Vector3(e.x[0],e.y[0],e.z[0]);e=new THREE.Vector3(e.x[1],e.y[1],e.z[1]);c=new THREE.BoxCollider(c,e);c.mesh=b;return c};THREE.CollisionUtils.MeshAABB=function(b){var e=THREE.CollisionUtils.MeshOBB(b);e.min.addSelf(b.position);e.max.addSelf(b.position);e.dynamic=!1;return e}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; diff --git a/build/custom/ThreeCanvas.js b/build/custom/ThreeCanvas.js index f89d19b6..d86d617f 100644 --- a/build/custom/ThreeCanvas.js +++ b/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}; diff --git a/build/custom/ThreeDOM.js b/build/custom/ThreeDOM.js index 0c1e50ab..067aacd1 100644 --- a/build/custom/ThreeDOM.js +++ b/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; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index 15e6bf41..58442cdf 100644 --- a/build/custom/ThreeExtras.js +++ b/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 ab?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;k25&&(d=25);f=(d-1)*0.5;b=Array(d);for(c=e=0;c25&&(f=25);g=(f-1)*0.5;b=Array(f);for(c=e=0;c1){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;na.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=b1){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;oa.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=b0?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.ythis.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=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;G0){g(0,0,-k-(d||0));for(j=a;j0){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;j0){h(0,0,-l-(f||0));for(k=a;k0){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;k0||(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;b0)for(e=0;e1){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;a0||(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;b0)for(e=0;e1){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;a0;){if(f){if(f.equals(contour[g])){f=null;continue}}else f=contour[g];for(b=0;b=0?l-1:e.length-1;nextShapeVert=l+1=0?m-1:a.length-1;nextHoleVert=m+12;){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=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>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;t1&&(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>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;u1&&(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=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;ethis.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;m0&&(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;f0)for(d=0;dk&&(v=k);for(d=0;d0){j=d*m;for(f=0;fsize&&(dist=size);for(g=0;g0){j=zd*g;for(d=0;d=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;ethis.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;n0&&(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;g0)for(f=0;fl&&(w=l);for(f=0;f0){k=f*n;for(g=0;gsize&&(dist=size);for(h=0;h0){k=zd*h;for(f=0;fd?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;cf?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.distc.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=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=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.xc.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;l=!1;g=1}if(b.origin.yc.max.y){f=c.max.y- -b.origin.y;f/=b.direction.y;l=!1;h=1}if(b.origin.zc.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(hc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(g,0,0);break;case 1:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE; -b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case 2:g=b.origin.x+b.direction.x*e;if(gc.max.x)return Number.MAX_VALUE;h=b.origin.y+b.direction.y*e;if(hc.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.xc.max.x){e=c.max.x-b.origin.x;e/=b.direction.x;m=!1;h=1}if(b.origin.yc.max.y){g=c.max.y- +b.origin.y;g/=b.direction.y;m=!1;j=1}if(b.origin.zc.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(jc.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(h,0,0);break;case 1:h=b.origin.x+b.direction.x*e;if(hc.max.x)return Number.MAX_VALUE; +b=b.origin.z+b.direction.z*e;if(bc.max.z)return Number.MAX_VALUE;c.normal.set(0,j,0);break;case 2:h=b.origin.x+b.direction.x*e;if(hc.max.x)return Number.MAX_VALUE;j=b.origin.y+b.direction.y*e;if(jc.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=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))}; diff --git a/build/custom/ThreeSVG.js b/build/custom/ThreeSVG.js index 81296619..e84bfb96 100644 --- a/build/custom/ThreeSVG.js +++ b/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}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index 1af856ce..cfaeb64e 100644 --- a/build/custom/ThreeWebGL.js +++ b/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;i0&&Z[0]0&&Z[1]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;x0.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, diff --git a/examples/canvas_geometry_text.html b/examples/canvas_geometry_text.html new file mode 100644 index 00000000..6eaead11 --- /dev/null +++ b/examples/canvas_geometry_text.html @@ -0,0 +1,208 @@ + + + + three.js canvas/webgl - geometry - text + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/core/Vector2.js b/src/core/Vector2.js index fcf2342f..ce2e2e08 100644 --- a/src/core/Vector2.js +++ b/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) ); } }; diff --git a/src/extras/geometries/Text.js b/src/extras/geometries/Text.js new file mode 100644 index 00000000..bf824ab9 --- /dev/null +++ b/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 ", 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=0 ? shapeIndex-1:shape.length-1 ; + nextShapeVert = (shapeIndex+1)=0 ? holeIndex-1:hole.length-1; + nextHoleVert = (holeIndex+1)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, */ + 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= 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