diff --git a/README.md b/README.md index 5caba530..c02c2b14 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ This code creates a camera, then creates a scene, adds a cube on it, creates a & scene = new THREE.Scene(); - geometry = new THREE.Cube( 200, 200, 200 ); + geometry = new THREE.CubeGeometry( 200, 200, 200 ); material = new THREE.MeshBasicMaterial( { color: 0xff0000, wireframe: true } ); mesh = new THREE.Mesh( geometry, material ); diff --git a/build/Three.js b/build/Three.js index ae70c99a..15ae605c 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,7 +1,7 @@ // 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,c,d){this.r=b;this.g=c;this.b=d;this.updateHex()},setHSV:function(b,c,d){var e,g,f,j,k,m;if(d==0)e=g=f=0;else switch(j=Math.floor(b*6),k=b*6-j,b=d*(1-c),m=d*(1-c*k),c=d*(1-c*(1-k)),j){case 1:e=m;g=d;f=b;break;case 2:e=b;g=d;f=c;break;case 3:e=b;g=m;f=d;break;case 4:e=c;g=b;f=d;break;case 5:e=d;g=b;f=m;break;case 6:case 0:e=d,g=c,f=b}this.setRGB(e, -g,f)},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,c){this.set(b||0,c||0)}; +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,c,d){this.r=b;this.g=c;this.b=d;this.updateHex()},setHSV:function(b,c,d){var e,f,g,j,k,m;if(d==0)e=f=g=0;else switch(j=Math.floor(b*6),k=b*6-j,b=d*(1-c),m=d*(1-c*k),c=d*(1-c*(1-k)),j){case 1:e=m;f=d;g=b;break;case 2:e=b;f=d;g=c;break;case 3:e=b;f=m;g=d;break;case 4:e=c;f=b;g=d;break;case 5:e=d;f=b;g=m;break;case 6:case 0:e=d,f=c,g=b}this.setRGB(e, +f,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(b,c){this.set(b||0,c||0)}; THREE.Vector2.prototype={set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this},divideScalar:function(b){b? (this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,d){this.set(b||0,c||0,d||0)}; @@ -14,71 +14,71 @@ THREE.Vector4.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())}, setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,d,e=[];c=0;for(d=b.length;c0&&b>0&&f+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b);if(!e||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b);if(!e||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,f,j,k,m,n,o,p,t,u,v=b.geometry, -z=v.vertices,B=[],e=0;for(g=v.faces.length;e0:p<0))if(o=o.dot((new THREE.Vector3).sub(j,t))/p,t=t.addSelf(u.multiplyScalar(o)), -f instanceof THREE.Face3)d(t,j,k,m)&&(f={distance:this.origin.distanceTo(t),point:t,face:f,object:b},B.push(f));else if(f instanceof THREE.Face4&&(d(t,j,k,n)||d(t,k,m,n)))f={distance:this.origin.distanceTo(t),point:t,face:f,object:b},B.push(f);return B}else return[]}}; -THREE.Rectangle=function(){function b(){f=e-c;j=g-d}var c,d,e,g,f,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(f,j,o,p){k=!1;c=f;d=j;e=o;g=p;b()};this.addPoint=function(f,j){k?(k=!1,c=f,d=j,e=f,g=j):(c=cf?e:f,g=g>j?g:j);b()};this.add3Points= -function(f,j,o,p,t,u){k?(k=!1,c=fo?f>t?f:t:o>t?o:t,g=j>p?j>u?j:u:p>u?p:u):(c=fo?f>t?f>e?f:e:t>e?t:e:o>t?o>e?o:e:t>e?t:e,g=j>p?j>u?j>g?j:g:u>g?u:g:p>u?p>g?p:g:u>g?u:g);b()};this.addRectangle=function(f){k?(k=!1,c=f.getLeft(),d=f.getTop(),e=f.getRight(),g=f.getBottom()):(c=cf.getRight()?e:f.getRight(),g=g> -f.getBottom()?g:f.getBottom());b()};this.inflate=function(f){c-=f;d-=f;e+=f;g+=f;b()};this.minSelf=function(f){c=c>f.getLeft()?c:f.getLeft();d=d>f.getTop()?d:f.getTop();e=e=0&&Math.min(g,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;g=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,g,f,j,k,m,n,o,p,t,u,v,z){this.set(b||1,c||0,d||0,e||0,g||0,f||1,j||0,k||0,m||0,n||0,o||1,p||0,t||0,u||0,v||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,c,d,e,g,f,j,k,m,n,o,p,t,u,v,z){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=j;this.n24=k;this.n31=m;this.n32=n;this.n33=o;this.n34=p;this.n41=t;this.n42=u;this.n43=v;this.n44=z;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,c,d){var e=THREE.Matrix4.__v1, -g=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(b,c).normalize();if(f.length()===0)f.z=1;e.cross(d,f).normalize();e.length()===0&&(f.x+=1.0E-4,e.cross(d,f).normalize());g.cross(f,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=f.x;this.n21=e.y;this.n22=g.y;this.n23=f.y;this.n31=e.z;this.n32=g.z;this.n33=f.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;b.y=(this.n21*c+this.n22*d+this.n23* -e+this.n24)*g;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,g=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*g;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*this.n33;b.normalize(); -return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,g=b.n13,f=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,B=b.n43,y=b.n44,D=c.n11,x=c.n12,H=c.n13,F=c.n14,A=c.n21,O=c.n22, -C=c.n23,L=c.n24,G=c.n31,S=c.n32,h=c.n33,U=c.n34;this.n11=d*D+e*A+g*G;this.n12=d*x+e*O+g*S;this.n13=d*H+e*C+g*h;this.n14=d*F+e*L+g*U+f;this.n21=j*D+k*A+m*G;this.n22=j*x+k*O+m*S;this.n23=j*H+k*C+m*h;this.n24=j*F+k*L+m*U+n;this.n31=o*D+p*A+t*G;this.n32=o*x+p*O+t*S;this.n33=o*H+p*C+t*h;this.n34=o*F+p*L+t*U+u;this.n41=v*D+z*A+B*G;this.n42=v*x+z*O+B*S;this.n43=v*H+z*C+B*h;this.n44=v*F+z*L+B*U+y;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]= +f=b.clone().subSelf(d),b=e.dot(e),d=e.dot(c),e=e.dot(f),g=c.dot(c),c=c.dot(f),f=1/(b*g-d*d),g=(g*e-d*c)*f,b=(b*c-d*e)*f;return g>0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b);if(!e||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b);if(!e||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var f,g,j,k,m,o,n,p,t,u,v=b.geometry, +z=v.vertices,A=[],e=0;for(f=v.faces.length;e0:p<0))if(n=n.dot((new THREE.Vector3).sub(j,t))/p,t=t.addSelf(u.multiplyScalar(n)), +g instanceof THREE.Face3)d(t,j,k,m)&&(g={distance:this.origin.distanceTo(t),point:t,face:g,object:b},A.push(g));else if(g instanceof THREE.Face4&&(d(t,j,k,o)||d(t,k,m,o)))g={distance:this.origin.distanceTo(t),point:t,face:g,object:b},A.push(g);return A}else return[]}}; +THREE.Rectangle=function(){function b(){g=e-c;j=f-d}var c,d,e,f,g,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return g};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(g,j,n,p){k=!1;c=g;d=j;e=n;f=p;b()};this.addPoint=function(g,j){k?(k=!1,c=g,d=j,e=g,f=j):(c=cg?e:g,f=f>j?f:j);b()};this.add3Points= +function(g,j,n,p,t,u){k?(k=!1,c=gn?g>t?g:t:n>t?n:t,f=j>p?j>u?j:u:p>u?p:u):(c=gn?g>t?g>e?g:e:t>e?t:e:n>t?n>e?n:e:t>e?t:e,f=j>p?j>u?j>f?j:f:u>f?u:f:p>u?p>f?p:f:u>f?u:f);b()};this.addRectangle=function(g){k?(k=!1,c=g.getLeft(),d=g.getTop(),e=g.getRight(),f=g.getBottom()):(c=cg.getRight()?e:g.getRight(),f=f> +g.getBottom()?f:g.getBottom());b()};this.inflate=function(g){c-=g;d-=g;e+=g;f+=g;b()};this.minSelf=function(g){c=c>g.getLeft()?c:g.getLeft();d=d>g.getTop()?d:g.getTop();e=e=0&&Math.min(f,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;f=e=d=c=0;b()};this.isEmpty=function(){return k}};THREE.Matrix3=function(){this.m=[]}; +THREE.Matrix3.prototype={transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,e,f,g,j,k,m,o,n,p,t,u,v,z){this.set(b||1,c||0,d||0,e||0,f||0,g||1,j||0,k||0,m||0,o||0,n||1,p||0,t||0,u||0,v||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,c,d,e,f,g,j,k,m,o,n,p,t,u,v,z){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=g;this.n23=j;this.n24=k;this.n31=m;this.n32=o;this.n33=n;this.n34=p;this.n41=t;this.n42=u;this.n43=v;this.n44=z;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,c,d){var e=THREE.Matrix4.__v1, +f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(b,c).normalize();if(g.length()===0)g.z=1;e.cross(d,g).normalize();e.length()===0&&(g.x+=1.0E-4,e.cross(d,g).normalize());f.cross(g,e).normalize();this.n11=e.x;this.n12=f.x;this.n13=g.x;this.n21=e.y;this.n22=f.y;this.n23=g.y;this.n31=e.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;b.y=(this.n21*c+this.n22*d+this.n23* +e+this.n24)*f;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,f=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*f;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*this.n33;b.normalize(); +return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,e=b.n12,f=b.n13,g=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,n=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,A=b.n43,x=b.n44,G=c.n11,y=c.n12,D=c.n13,F=c.n14,B=c.n21,P=c.n22, +K=c.n23,L=c.n24,E=c.n31,M=c.n32,T=c.n33,h=c.n34;this.n11=d*G+e*B+f*E;this.n12=d*y+e*P+f*M;this.n13=d*D+e*K+f*T;this.n14=d*F+e*L+f*h+g;this.n21=j*G+k*B+m*E;this.n22=j*y+k*P+m*M;this.n23=j*D+k*K+m*T;this.n24=j*F+k*L+m*h+o;this.n31=n*G+p*B+t*E;this.n32=n*y+p*P+t*M;this.n33=n*D+p*K+t*T;this.n34=n*F+p*L+t*h+u;this.n41=v*G+z*B+A*E;this.n42=v*y+z*P+A*M;this.n43=v*D+z*K+A*T;this.n44=v*F+z*L+A*h+x;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]= this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(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,c=this.n12,d=this.n13,e=this.n14,g=this.n21,f=this.n22,j=this.n23,k=this.n24,m=this.n31,n=this.n32,o=this.n33,p=this.n34,t=this.n41,u=this.n42,v=this.n43,z=this.n44;return e*j*n*t-d*k*n*t-e*f*o*t+c*k*o*t+d*f*p*t-c*j*p*t-e*j*m*u+d*k*m*u+e*g*o*u-b*k*o*u-d*g*p*u+b*j*p*u+e*f*m*v-c*k*m*v-e*g*n*v+b*k*n*v+c*g*p*v-b*f*p*v-d*f*m*z+c*j*m*z+d*g*n*z-b*j*n*z-c*g*o*z+b*f*o*z},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.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,j=this.n23,k=this.n24,m=this.n31,o=this.n32,n=this.n33,p=this.n34,t=this.n41,u=this.n42,v=this.n43,z=this.n44;return e*j*o*t-d*k*o*t-e*g*n*t+c*k*n*t+d*g*p*t-c*j*p*t-e*j*m*u+d*k*m*u+e*f*n*u-b*k*n*u-d*f*p*u+b*j*p*u+e*g*m*v-c*k*m*v-e*f*o*v+b*k*o*v+c*f*p*v-b*g*p*v-d*g*m*z+c*j*m*z+d*f*o*z-b*j*o*z-c*f*n*z+b*g*n*z},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,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b, -c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),g=1-d,f=b.x,j=b.y,k=b.z,m=g*f,n=g*j;this.set(m* -f+d,m*j-e*k,m*k+e*j,0,m*j+e*k,n*j+d,n*k-e*f,0,m*k-e*j,n*k+e*f,g*k*k+d,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 c=b.x,d=b.y,e=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),f=Math.cos(e),e=Math.sin(e),j=b*d,k=c*d;this.n11=g*f;this.n12=-g*e;this.n13=d;this.n21=k*f+b*e;this.n22=-k*e+b*f;this.n23=-c*g;this.n31=-j*f+c*e;this.n32=j*e+c*f;this.n33=b*g;return this}, -setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,g=b.w,f=c+c,j=d+d,k=e+e,b=c*f,m=c*j;c*=k;var n=d*j;d*=k;e*=k;f*=g;j*=g;g*=k;this.n11=1-(n+e);this.n12=m-g;this.n13=c+j;this.n21=m+g;this.n22=1-(b+e);this.n23=d-f;this.n31=c-j;this.n32=d+f;this.n33=1-(b+n);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14= -b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,e=1/c.y,g=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; -THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,g=b.n13,f=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,B=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*u*z-n*t*z+n*p*B-k*u*B-m*p*y+k*t*y;c.n12=f*t*z-g*u*z-f*p*B+e*u*B+g*p*y-e*t*y;c.n13=g*n*z-f*m*z+f*k*B-e*n*B-g*k*y+e*m*y;c.n14=f*m*p-g*n*p-f*k*t+e*n*t+g*k*u-e*m*u;c.n21=n*t*v-m*u*v-n*o*B+j*u*B+m*o*y-j*t*y;c.n22=g*u*v-f*t*v+f*o*B-d*u*B-g*o*y+d*t*y;c.n23=f*m*v-g*n*v-f*j*B+d*n*B+g*j*y-d*m*y;c.n24= -g*n*o-f*m*o+f*j*t-d*n*t-g*j*u+d*m*u;c.n31=k*u*v-n*p*v+n*o*z-j*u*z-k*o*y+j*p*y;c.n32=f*p*v-e*u*v-f*o*z+d*u*z+e*o*y-d*p*y;c.n33=g*n*v-f*k*v+f*j*z-d*n*z-e*j*y+d*k*y;c.n34=f*k*o-e*n*o-f*j*p+d*n*p+e*j*u-d*k*u;c.n41=m*p*v-k*t*v-m*o*z+j*t*z+k*o*B-j*p*B;c.n42=e*t*v-g*p*v+g*o*z-d*t*z-e*o*B+d*p*B;c.n43=g*k*v-e*m*v-g*j*z+d*m*z+e*j*B-d*k*B;c.n44=e*m*o-g*k*o+g*j*p-d*m*p-e*j*t+d*k*t;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,f=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,n=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,p=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*n;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*f;d[3]=b*j;d[4]=b*k;d[5]=b*m;d[6]=b*n;d[7]=b*o;d[8]=b*p;return c}; -THREE.Matrix4.makeFrustum=function(b,c,d,e,g,f){var j;j=new THREE.Matrix4;j.n11=2*g/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*g/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(f+g)/(f-g);j.n34=-2*f*g/(f-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var g,b=d*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,d,e)}; -THREE.Matrix4.makeOrtho=function(b,c,d,e,g,f){var j,k,m,n;j=new THREE.Matrix4;k=c-b;m=d-e;n=f-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((d+e)/m);j.n31=0;j.n32=0;j.n33=-2/n;j.n34=-((f+g)/n);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; +c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,g=b.x,j=b.y,k=b.z,m=f*g,o=f*j;this.set(m* +g+d,m*j-e*k,m*k+e*j,0,m*j+e*k,o*j+d,o*k-e*g,0,m*k-e*j,o*k+e*g,f*k*k+d,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 c=b.x,d=b.y,e=b.z,b=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),g=Math.cos(e),e=Math.sin(e),j=b*d,k=c*d;this.n11=f*g;this.n12=-f*e;this.n13=d;this.n21=k*g+b*e;this.n22=-k*e+b*g;this.n23=-c*f;this.n31=-j*g+c*e;this.n32=j*e+c*g;this.n33=b*f;return this}, +setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,f=b.w,g=c+c,j=d+d,k=e+e,b=c*g,m=c*j;c*=k;var o=d*j;d*=k;e*=k;g*=f;j*=f;f*=k;this.n11=1-(o+e);this.n12=m-f;this.n13=c+j;this.n21=m+f;this.n22=1-(b+e);this.n23=d-g;this.n31=c-j;this.n32=d+g;this.n33=1-(b+o);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},extractPosition:function(b){this.n14= +b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,e=1/c.y,f=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*f;this.n23=b.n23*f;this.n33=b.n33*f}}; +THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,f=b.n13,g=b.n14,j=b.n21,k=b.n22,m=b.n23,o=b.n24,n=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,A=b.n43,x=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*u*z-o*t*z+o*p*A-k*u*A-m*p*x+k*t*x;c.n12=g*t*z-f*u*z-g*p*A+e*u*A+f*p*x-e*t*x;c.n13=f*o*z-g*m*z+g*k*A-e*o*A-f*k*x+e*m*x;c.n14=g*m*p-f*o*p-g*k*t+e*o*t+f*k*u-e*m*u;c.n21=o*t*v-m*u*v-o*n*A+j*u*A+m*n*x-j*t*x;c.n22=f*u*v-g*t*v+g*n*A-d*u*A-f*n*x+d*t*x;c.n23=g*m*v-f*o*v-g*j*A+d*o*A+f*j*x-d*m*x;c.n24= +f*o*n-g*m*n+g*j*t-d*o*t-f*j*u+d*m*u;c.n31=k*u*v-o*p*v+o*n*z-j*u*z-k*n*x+j*p*x;c.n32=g*p*v-e*u*v-g*n*z+d*u*z+e*n*x-d*p*x;c.n33=f*o*v-g*k*v+g*j*z-d*o*z-e*j*x+d*k*x;c.n34=g*k*n-e*o*n-g*j*p+d*o*p+e*j*u-d*k*u;c.n41=m*p*v-k*t*v-m*n*z+j*t*z+k*n*A-j*p*A;c.n42=e*t*v-f*p*v+f*n*z-d*t*z-e*n*A+d*p*A;c.n43=f*k*v-e*m*v-f*j*z+d*m*z+e*j*A-d*k*A;c.n44=e*m*n-f*k*n+f*j*p-d*m*p-e*j*t+d*k*t;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,f=-b.n33*b.n21+b.n31*b.n23,g=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,n=-b.n23*b.n11+b.n21*b.n13,p=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*f;d[2]=b*g;d[3]=b*j;d[4]=b*k;d[5]=b*m;d[6]=b*o;d[7]=b*n;d[8]=b*p;return c}; +THREE.Matrix4.makeFrustum=function(b,c,d,e,f,g){var j;j=new THREE.Matrix4;j.n11=2*f/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*f/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(g+f)/(g-f);j.n34=-2*g*f/(g-f);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var f,b=d*Math.tan(b*Math.PI/360);f=-b;return THREE.Matrix4.makeFrustum(f*c,b*c,f,b,d,e)}; +THREE.Matrix4.makeOrtho=function(b,c,d,e,f,g){var j,k,m,o;j=new THREE.Matrix4;k=c-b;m=d-e;o=g-f;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((d+e)/m);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((g+f)/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; THREE.Object3D=function(){this.parent=void 0;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.flipSided=this.doubleSided=this.dynamic=!1;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=!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,c){this.matrix.rotateAxis(c);this.position.addSelf(c.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!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,e,g;d=0;for(e=this.children.length;d=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var f=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;g=Math.sin((1-e)*f)/j;e=Math.sin(e*f)/j;d.w=b.w*g+c.w*e;d.x=b.x*g+c.x*e;d.y=b.y*g+c.y*e;d.z=b.z*g+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; -THREE.Face3=function(b,c,d,e,g,f){this.a=b;this.b=c;this.c=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.Face4=function(b,c,d,e,g,f,j){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; +multiplySelf:function(b){var c=this.x,d=this.y,e=this.z,f=this.w,g=b.x,j=b.y,k=b.z,b=b.w;this.x=c*b+f*g+d*k-e*j;this.y=d*b+f*j+e*g-c*k;this.z=e*b+f*k+c*j-d*g;this.w=f*b-c*g-d*j-e*k;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,e=b.y,f=b.z,g=this.x,j=this.y,k=this.z,m=this.w,o=m*d+j*f-k*e,n= +m*e+k*d-g*f,p=m*f+g*e-j*d,d=-g*d-j*e-k*f;c.x=o*m+d*-g+n*-k-p*-j;c.y=n*m+d*-j+p*-g-o*-k;c.z=p*m+d*-k+o*-j-n*-g;return c}}; +THREE.Quaternion.slerp=function(b,c,d,e){var f=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(f)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var g=Math.acos(f),j=Math.sqrt(1-f*f);if(Math.abs(j)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;f=Math.sin((1-e)*g)/j;e=Math.sin(e*g)/j;d.w=b.w*f+c.w*e;d.x=b.x*f+c.x*e;d.y=b.y*f+c.y*e;d.z=b.z*f+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; +THREE.Face3=function(b,c,d,e,f,g){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,c,d,e,f,g,j){this.a=b;this.b=c;this.c=d;this.d=e;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=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;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,c,d;b=0;for(c=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 c=1,d=this.vertices.length;cthis.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=0,c=0,d=this.vertices.length;cthis.points.length-2?f:f+1;d[3]=f>this.points.length-3?f:f+2;n=this.points[d[0]];o=this.points[d[1]]; -p=this.points[d[2]];t=this.points[d[3]];k=j*j;m=j*k;e.x=c(n.x,o.x,p.x,t.x,j,k,m);e.y=c(n.y,o.y,p.y,t.y,j,k,m);e.z=c(n.z,o.z,p.z,t.z,j,k,m);return e};this.getControlPointsArray=function(){var b,d,c=this.points.length,e=[];for(b=0;bthis.points.length-2?g:g+1;d[3]=g>this.points.length-3?g:g+2;o=this.points[d[0]];n=this.points[d[1]]; +p=this.points[d[2]];t=this.points[d[3]];k=j*j;m=j*k;e.x=c(o.x,n.x,p.x,t.x,j,k,m);e.y=c(o.y,n.y,p.y,t.y,j,k,m);e.z=c(o.z,n.z,p.z,t.z,j,k,m);return e};this.getControlPointsArray=function(){var b,d,c=this.points.length,e=[];for(b=0;b1){b=d.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 e=1;e=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1, this.LODs[e].object3D.visible=!0;else break;for(;ep&&(d=o,o=p,p=d):ou&&(d=t,t=u,u=d):tp&&(d=n,n=p,p=d):nu&&(d=t,t=u,u=d):t=0&&f>=0&&j>=0&&k>=0?!0:g<0&&f<0||j<0&&k<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(e=Math.min(e,g/(g-f))),j<0?c=Math.max(c,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),eH&&j.positionScreen.z0&&F.z<1))K=x[D]=x[D]||new THREE.RenderableParticle,D++,y=K,y.x=F.x/F.w,y.y=F.y/F.w,y.z=F.z,y.rotation=N.rotation.z,y.scale.x=N.scale.x*Math.abs(y.x-(F.x+h.projectionMatrix.n11)/(F.w+ -h.projectionMatrix.n14)),y.scale.y=N.scale.y*Math.abs(y.y-(F.y+h.projectionMatrix.n22)/(F.w+h.projectionMatrix.n24)),y.materials=N.materials,f.push(y);g&&f.sort(c);return f}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(b,c){d=b;e=c;g=d/2;f=e/2};this.render=function(d,e){var m,n,o,p,t,u,v,z;b=c.projectScene(d,e);m=0;for(n=b.length;m>1,p=n.height>>1,f=h.scale.x*t, -m=h.scale.y*u,j=f*T,k=m*p,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(f,-m),v.translate(-T,-p),v.drawImage(n,0,0),v.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=h.scale.x*t,k=h.scale.y*u,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(e(f.color),g(f.color),v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(j,k),f.program(v),v.restore()))}function y(b,h,f,g){c(g.opacity);d(g.blending);v.beginPath(); -v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(h.positionScreen.x,h.positionScreen.y);v.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(F!=b)v.lineWidth=F=b;b=g.linecap;if(A!=b)v.lineCap=A=b;b=g.linejoin;if(O!=b)v.lineJoin=O=b;e(g.color);v.stroke();pa.inflate(g.linewidth*2)}}function x(b,e,h,g,k,m,n,T,o){j.data.vertices+=3;j.data.faces++;c(T.opacity);d(T.blending);Q=b.positionScreen.x;W=b.positionScreen.y;J=e.positionScreen.x;$=e.positionScreen.y;R=h.positionScreen.x; -P=h.positionScreen.y;B(Q,W,J,$,R,P);if(T instanceof THREE.MeshBasicMaterial)if(T.map)T.map.mapping instanceof THREE.UVMapping&&(ma=n.uvs[0],w(Q,W,J,$,R,P,T.map.image,ma[g].u,ma[g].v,ma[k].u,ma[k].v,ma[m].u,ma[m].v));else if(T.envMap){if(T.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=f.matrixWorldInverse,na.copy(n.vertexNormalsWorld[0]),ia=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,za=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(n.vertexNormalsWorld[1]),wa=(na.x*b.n11+na.y*b.n12+ -na.z*b.n13)*0.5+0.5,aa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(n.vertexNormalsWorld[2]),M=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,xa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,w(Q,W,J,$,R,P,T.envMap.image,ia,za,wa,aa,M,xa)}else T.wireframe?E(T.color,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(T.color);else if(T instanceof THREE.MeshLambertMaterial)T.map&&!T.wireframe&&(T.map.mapping instanceof THREE.UVMapping&&(ma=n.uvs[0],w(Q,W,J,$,R,P,T.map.image,ma[g].u,ma[g].v, -ma[k].u,ma[k].v,ma[m].u,ma[m].v)),d(THREE.SubtractiveBlending)),Ta?!T.wireframe&&T.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(K.r=X.r=Y.r=ra.r,K.g=X.g=Y.g=ra.g,K.b=X.b=Y.b=ra.b,p(o,n.v1.positionWorld,n.vertexNormalsWorld[0],K),p(o,n.v2.positionWorld,n.vertexNormalsWorld[1],X),p(o,n.v3.positionWorld,n.vertexNormalsWorld[2],Y),ka.r=(X.r+Y.r)*0.5,ka.g=(X.g+Y.g)*0.5,ka.b=(X.b+Y.b)*0.5,fa=Qa(K,X,Y,ka),w(Q,W,J,$,R,P,fa,0,0,1,0,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(o,n.centroidWorld, -n.normalWorld,sa),N.r=Math.max(0,Math.min(T.color.r*sa.r,1)),N.g=Math.max(0,Math.min(T.color.g*sa.g,1)),N.b=Math.max(0,Math.min(T.color.b*sa.b,1)),N.updateHex(),T.wireframe?E(N,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(N)):T.wireframe?E(T.color,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(T.color);else if(T instanceof THREE.MeshDepthMaterial)Z=f.near,ja=f.far,K.r=K.g=K.b=1-Da(b.positionScreen.z,Z,ja),X.r=X.g=X.b=1-Da(e.positionScreen.z,Z,ja),Y.r=Y.g=Y.b=1-Da(h.positionScreen.z, -Z,ja),ka.r=(X.r+Y.r)*0.5,ka.g=(X.g+Y.g)*0.5,ka.b=(X.b+Y.b)*0.5,fa=Qa(K,X,Y,ka),w(Q,W,J,$,R,P,fa,0,0,1,0,0,1);else if(T instanceof THREE.MeshNormalMaterial)N.r=Ia(n.normalWorld.x),N.g=Ia(n.normalWorld.y),N.b=Ia(n.normalWorld.z),N.updateHex(),T.wireframe?E(N,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(N)}function z(b,e,h,g,k,T,n,m,o){j.data.vertices+=4;j.data.faces++;c(m.opacity);d(m.blending);if(m.map||m.envMap)x(b,e,g,0,1,3,n,m,o),x(k,h,T,1,2,3,n,m,o);else if(Q=b.positionScreen.x, -W=b.positionScreen.y,J=e.positionScreen.x,$=e.positionScreen.y,R=h.positionScreen.x,P=h.positionScreen.y,ga=g.positionScreen.x,V=g.positionScreen.y,da=k.positionScreen.x,ha=k.positionScreen.y,ea=T.positionScreen.x,ca=T.positionScreen.y,m instanceof THREE.MeshBasicMaterial)D(Q,W,J,$,R,P,ga,V),m.wireframe?E(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color);else if(m instanceof THREE.MeshLambertMaterial)Ta?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length== -4?(K.r=X.r=Y.r=ka.r=ra.r,K.g=X.g=Y.g=ka.g=ra.g,K.b=X.b=Y.b=ka.b=ra.b,p(o,n.v1.positionWorld,n.vertexNormalsWorld[0],K),p(o,n.v2.positionWorld,n.vertexNormalsWorld[1],X),p(o,n.v4.positionWorld,n.vertexNormalsWorld[3],Y),p(o,n.v3.positionWorld,n.vertexNormalsWorld[2],ka),fa=Qa(K,X,Y,ka),B(Q,W,J,$,ga,V),w(Q,W,J,$,ga,V,fa,0,0,1,0,0,1),B(da,ha,R,P,ea,ca),w(da,ha,R,P,ea,ca,fa,1,0,1,1,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(o,n.centroidWorld,n.normalWorld,sa),N.r=Math.max(0,Math.min(m.color.r*sa.r,1)),N.g= -Math.max(0,Math.min(m.color.g*sa.g,1)),N.b=Math.max(0,Math.min(m.color.b*sa.b,1)),N.updateHex(),D(Q,W,J,$,R,P,ga,V),m.wireframe?E(N,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(N)):(D(Q,W,J,$,R,P,ga,V),m.wireframe?E(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color));else if(m instanceof THREE.MeshNormalMaterial)N.r=Ia(n.normalWorld.x),N.g=Ia(n.normalWorld.y),N.b=Ia(n.normalWorld.z),N.updateHex(),D(Q,W,J,$,R,P,ga,V),m.wireframe?E(N,m.wireframeLinewidth, -m.wireframeLinecap,m.wireframeLinejoin):H(N);else if(m instanceof THREE.MeshDepthMaterial)Z=f.near,ja=f.far,K.r=K.g=K.b=1-Da(b.positionScreen.z,Z,ja),X.r=X.g=X.b=1-Da(e.positionScreen.z,Z,ja),Y.r=Y.g=Y.b=1-Da(g.positionScreen.z,Z,ja),ka.r=ka.g=ka.b=1-Da(h.positionScreen.z,Z,ja),fa=Qa(K,X,Y,ka),B(Q,W,J,$,ga,V),w(Q,W,J,$,ga,V,fa,0,0,1,0,0,1),B(da,ha,R,P,ea,ca),w(da,ha,R,P,ea,ca,fa,1,0,1,1,0,1)}function B(b,d,c,e,h,f){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(b,d);v.closePath()} -function D(b,d,c,e,h,f,g,j){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(g,j);v.lineTo(b,d);v.closePath()}function E(b,d,c,h){if(F!=d)v.lineWidth=F=d;if(A!=c)v.lineCap=A=c;if(O!=h)v.lineJoin=O=h;e(b);v.stroke();pa.inflate(d*2)}function H(b){g(b);v.fill()}function w(b,d,c,e,h,f,g,j,k,m,T,n,p){var o,t;o=g.width-1;t=g.height-1;j*=o;k*=t;m*=o;T*=t;n*=o;p*=t;c-=b;e-=d;h-=b;f-=d;m-=j;T-=k;n-=j;p-=k;o=m*p-n*T;o!=0&&(t=1/o,o=(p*c-T*h)*t,T=(p*e-T*f)*t,c=(m*h-n*c)*t,e=(m*f-n*e)*t,b=b-o* -j-c*k,d=d-T*j-e*k,v.save(),v.transform(o,T,c,e,b,d),v.clip(),v.drawImage(g,0,0),v.restore())}function Qa(b,d,c,e){var h=~~(b.r*255),f=~~(b.g*255),b=~~(b.b*255),g=~~(d.r*255),j=~~(d.g*255),d=~~(d.b*255),k=~~(c.r*255),T=~~(c.g*255),c=~~(c.b*255),m=~~(e.r*255),n=~~(e.g*255),e=~~(e.b*255);ta[0]=h<0?0:h>255?255:h;ta[1]=f<0?0:f>255?255:f;ta[2]=b<0?0:b>255?255:b;ta[4]=g<0?0:g>255?255:g;ta[5]=j<0?0:j>255?255:j;ta[6]=d<0?0:d>255?255:d;ta[8]=k<0?0:k>255?255:k;ta[9]=T<0?0:T>255?255:T;ta[10]=c<0?0:c>255?255: -c;ta[12]=m<0?0:m>255?255:m;ta[13]=n<0?0:n>255?255:n;ta[14]=e<0?0:e>255?255:e;La.putImageData(Ua,0,0);Pa.drawImage(Ka,0,0);return Ma}function Da(b,d,c){b=(b-d)/(c-d);return b*b*(3-2*b)}function Ia(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Aa(b,d){var c=d.x-b.x,e=d.y-b.y,h=1/Math.sqrt(c*c+e*e);c*=h;e*=h;d.x+=c;d.y+=e;b.x-=c;b.y-=e}var Ra,Ya,la,ua,Ba,Ja,Sa,I;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,u);j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,f,this.sortElements);(Ta=b.lights.length> -0)&&n(b);Ra=0;for(Ya=k.length;Ra0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(S.sub(f.position,d.centroidWorld),S.normalize(),g=d.normalWorld.dot(S)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function c(d,c,h,k,m,p){j.data.vertices+=3;j.data.faces++;Q=e(W++);Q.setAttribute("d", -"M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?F.hex=m.color.hex:m instanceof THREE.MeshLambertMaterial?H?(A.r=O.r,A.g=O.g,A.b=O.b,b(p,k,A),F.r=Math.max(0,Math.min(m.color.r*A.r,1)),F.g=Math.max(0,Math.min(m.color.g*A.g,1)),F.b=Math.max(0,Math.min(m.color.b*A.b,1)),F.updateHex()):F.hex=m.color.hex:m instanceof THREE.MeshDepthMaterial?(G=1-m.__2near/(m.__farPlusNear- -k.z*m.__farMinusNear),F.setRGB(G,G,G)):m instanceof THREE.MeshNormalMaterial&&F.setRGB(g(k.normalWorld.x),g(k.normalWorld.y),g(k.normalWorld.z));m.wireframe?Q.setAttribute("style","fill: none; stroke: #"+f(F.hex.toString(16))+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):Q.setAttribute("style","fill: #"+f(F.hex.toString(16))+"; fill-opacity: "+m.opacity);n.appendChild(Q)}function d(d,c,h,k, -m,p,o){j.data.vertices+=4;j.data.faces++;Q=e(W++);Q.setAttribute("d","M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?F.hex=p.color.hex:p instanceof THREE.MeshLambertMaterial?H?(A.r=O.r,A.g=O.g,A.b=O.b,b(o,m,A),F.r=Math.max(0,Math.min(p.color.r*A.r,1)),F.g=Math.max(0,Math.min(p.color.g*A.g,1)),F.b=Math.max(0,Math.min(p.color.b* -A.b,1)),F.updateHex()):F.hex=p.color.hex:p instanceof THREE.MeshDepthMaterial?(G=1-p.__2near/(p.__farPlusNear-m.z*p.__farMinusNear),F.setRGB(G,G,G)):p instanceof THREE.MeshNormalMaterial&&F.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));p.wireframe?Q.setAttribute("style","fill: none; stroke: #"+f(F.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):Q.setAttribute("style", -"fill: #"+f(F.hex.toString(16))+"; fill-opacity: "+p.opacity);n.appendChild(Q)}function e(b){h[b]==null&&(h[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),$==0&&h[b].setAttribute("shape-rendering","crispEdges"));return h[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function f(b){for(;b.length<6;)b="0"+b;return b}var j=this,k=null,m=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,p,t,u,v,z,B,y,D=new THREE.Rectangle,x=new THREE.Rectangle,H= -!1,F=new THREE.Color(16777215),A=new THREE.Color(16777215),O=new THREE.Color(0),C=new THREE.Color(0),L=new THREE.Color(0),G,S=new THREE.Vector3,h=[],U=[],Q,W,J,$=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":$=1;break;case "low":$=0}};this.setSize=function(b,d){o=b;p=d;t=o/2;u=p/2;n.setAttribute("viewBox",-t+" "+-u+" "+o+" "+p);n.setAttribute("width",o);n.setAttribute("height",p);D.set(-t,-u, -t,u)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(b,e){var h,g,p,o,A,F,G,K;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,e,this.sortElements);J=W=0;if(H=b.lights.length>0){G=b.lights;O.setRGB(0,0,0);C.setRGB(0,0,0);L.setRGB(0,0,0);h=0;for(g=G.length;h=0&&g>=0&&j>=0&&k>=0?!0:f<0&&g<0||j<0&&k<0?!1:(f<0?c=Math.max(c,f/(f-g)):g<0&&(e=Math.min(e,f/(f-g))),j<0?c=Math.max(c,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),eD&&j.positionScreen.z0&&F.z<1))S=y[G]=y[G]||new THREE.RenderableParticle,G++,x=S,x.x=F.x/F.w,x.y=F.y/F.w,x.z=F.z,x.rotation=I.rotation.z,x.scale.x=I.scale.x*Math.abs(x.x-(F.x+f.projectionMatrix.n11)/(F.w+ +f.projectionMatrix.n14)),x.scale.y=I.scale.y*Math.abs(x.y-(F.y+f.projectionMatrix.n22)/(F.w+f.projectionMatrix.n24)),x.materials=I.materials,g.push(x);h&&g.sort(c);return g}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,d,e,f,g;this.domElement=document.createElement("div");this.setSize=function(b,c){d=b;e=c;f=d/2;g=e/2};this.render=function(d,e){var m,o,n,p,t,u,v,z;b=c.projectScene(d,e);m=0;for(o=b.length;m>1,qa=o.height>> +1,g=h.scale.x*t,m=h.scale.y*u,j=g*p,k=m*qa,X.set(b.x-j,b.y-k,b.x+j,b.y+k),sa.instersects(X)&&(v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(g,-m),v.translate(-p,-qa),v.drawImage(o,0,0),v.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(j=h.scale.x*t,k=h.scale.y*u,X.set(b.x-j,b.y-k,b.x+j,b.y+k),sa.instersects(X)&&(e(g.color),f(g.color),v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(j,k),g.program(v),v.restore()))}function x(b,h,f,g){c(g.opacity);d(g.blending); +v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(h.positionScreen.x,h.positionScreen.y);v.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(F!=b)v.lineWidth=F=b;b=g.linecap;if(B!=b)v.lineCap=B=b;b=g.linejoin;if(P!=b)v.lineJoin=P=b;e(g.color);v.stroke();X.inflate(g.linewidth*2)}}function z(b,e,h,f,k,m,o,X,n){j.data.vertices+=3;j.data.faces++;c(X.opacity);d(X.blending);Q=b.positionScreen.x;R=b.positionScreen.y;N=e.positionScreen.x;aa=e.positionScreen.y;U=h.positionScreen.x; +V=h.positionScreen.y;A(Q,R,N,aa,U,V);if(X instanceof THREE.MeshBasicMaterial)if(X.map)X.map.mapping instanceof THREE.UVMapping&&(ma=o.uvs[0],va(Q,R,N,aa,U,V,X.map.image,ma[f].u,ma[f].v,ma[k].u,ma[k].v,ma[m].u,ma[m].v));else if(X.envMap){if(X.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=g.matrixWorldInverse,oa.copy(o.vertexNormalsWorld[0]),ja=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,na=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(o.vertexNormalsWorld[1]),Aa=(oa.x*b.n11+oa.y* +b.n12+oa.z*b.n13)*0.5+0.5,ya=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(o.vertexNormalsWorld[2]),ca=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,O=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,va(Q,R,N,aa,U,V,X.envMap.image,ja,na,Aa,ya,ca,O)}else X.wireframe?D(X.color,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):C(X.color);else if(X instanceof THREE.MeshLambertMaterial)X.map&&!X.wireframe&&(X.map.mapping instanceof THREE.UVMapping&&(ma=o.uvs[0],va(Q,R,N,aa,U,V,X.map.image,ma[f].u, +ma[f].v,ma[k].u,ma[k].v,ma[m].u,ma[m].v)),d(THREE.SubtractiveBlending)),Ta?!X.wireframe&&X.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(S.r=Z.r=$.r=qa.r,S.g=Z.g=$.g=qa.g,S.b=Z.b=$.b=qa.b,p(n,o.v1.positionWorld,o.vertexNormalsWorld[0],S),p(n,o.v2.positionWorld,o.vertexNormalsWorld[1],Z),p(n,o.v3.positionWorld,o.vertexNormalsWorld[2],$),ia.r=(Z.r+$.r)*0.5,ia.g=(Z.g+$.g)*0.5,ia.b=(Z.b+$.b)*0.5,ha=w(S,Z,$,ia),va(Q,R,N,aa,U,V,ha,0,0,1,0,0,1)):(ta.r=qa.r,ta.g=qa.g,ta.b=qa.b,p(n,o.centroidWorld, +o.normalWorld,ta),I.r=Math.max(0,Math.min(X.color.r*ta.r,1)),I.g=Math.max(0,Math.min(X.color.g*ta.g,1)),I.b=Math.max(0,Math.min(X.color.b*ta.b,1)),I.updateHex(),X.wireframe?D(I,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):C(I)):X.wireframe?D(X.color,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):C(X.color);else if(X instanceof THREE.MeshDepthMaterial)Y=g.near,H=g.far,S.r=S.g=S.b=1-Ea(b.positionScreen.z,Y,H),Z.r=Z.g=Z.b=1-Ea(e.positionScreen.z,Y,H),$.r=$.g=$.b=1-Ea(h.positionScreen.z, +Y,H),ia.r=(Z.r+$.r)*0.5,ia.g=(Z.g+$.g)*0.5,ia.b=(Z.b+$.b)*0.5,ha=w(S,Z,$,ia),va(Q,R,N,aa,U,V,ha,0,0,1,0,0,1);else if(X instanceof THREE.MeshNormalMaterial)I.r=Ja(o.normalWorld.x),I.g=Ja(o.normalWorld.y),I.b=Ja(o.normalWorld.z),I.updateHex(),X.wireframe?D(I,X.wireframeLinewidth,X.wireframeLinecap,X.wireframeLinejoin):C(I)}function y(b,e,h,f,k,X,o,m,n){j.data.vertices+=4;j.data.faces++;c(m.opacity);d(m.blending);if(m.map||m.envMap)z(b,e,f,0,1,3,o,m,n),z(k,h,X,1,2,3,o,m,n);else if(Q=b.positionScreen.x, +R=b.positionScreen.y,N=e.positionScreen.x,aa=e.positionScreen.y,U=h.positionScreen.x,V=h.positionScreen.y,ga=f.positionScreen.x,W=f.positionScreen.y,da=k.positionScreen.x,ea=k.positionScreen.y,ka=X.positionScreen.x,fa=X.positionScreen.y,m instanceof THREE.MeshBasicMaterial)G(Q,R,N,aa,U,V,ga,W),m.wireframe?D(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):C(m.color);else if(m instanceof THREE.MeshLambertMaterial)Ta?!m.wireframe&&m.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length== +4?(S.r=Z.r=$.r=ia.r=qa.r,S.g=Z.g=$.g=ia.g=qa.g,S.b=Z.b=$.b=ia.b=qa.b,p(n,o.v1.positionWorld,o.vertexNormalsWorld[0],S),p(n,o.v2.positionWorld,o.vertexNormalsWorld[1],Z),p(n,o.v4.positionWorld,o.vertexNormalsWorld[3],$),p(n,o.v3.positionWorld,o.vertexNormalsWorld[2],ia),ha=w(S,Z,$,ia),A(Q,R,N,aa,ga,W),va(Q,R,N,aa,ga,W,ha,0,0,1,0,0,1),A(da,ea,U,V,ka,fa),va(da,ea,U,V,ka,fa,ha,1,0,1,1,0,1)):(ta.r=qa.r,ta.g=qa.g,ta.b=qa.b,p(n,o.centroidWorld,o.normalWorld,ta),I.r=Math.max(0,Math.min(m.color.r*ta.r,1)), +I.g=Math.max(0,Math.min(m.color.g*ta.g,1)),I.b=Math.max(0,Math.min(m.color.b*ta.b,1)),I.updateHex(),G(Q,R,N,aa,U,V,ga,W),m.wireframe?D(I,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):C(I)):(G(Q,R,N,aa,U,V,ga,W),m.wireframe?D(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):C(m.color));else if(m instanceof THREE.MeshNormalMaterial)I.r=Ja(o.normalWorld.x),I.g=Ja(o.normalWorld.y),I.b=Ja(o.normalWorld.z),I.updateHex(),G(Q,R,N,aa,U,V,ga,W),m.wireframe?D(I,m.wireframeLinewidth, +m.wireframeLinecap,m.wireframeLinejoin):C(I);else if(m instanceof THREE.MeshDepthMaterial)Y=g.near,H=g.far,S.r=S.g=S.b=1-Ea(b.positionScreen.z,Y,H),Z.r=Z.g=Z.b=1-Ea(e.positionScreen.z,Y,H),$.r=$.g=$.b=1-Ea(f.positionScreen.z,Y,H),ia.r=ia.g=ia.b=1-Ea(h.positionScreen.z,Y,H),ha=w(S,Z,$,ia),A(Q,R,N,aa,ga,W),va(Q,R,N,aa,ga,W,ha,0,0,1,0,0,1),A(da,ea,U,V,ka,fa),va(da,ea,U,V,ka,fa,ha,1,0,1,1,0,1)}function A(b,d,c,e,h,f){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(b,d);v.closePath()} +function G(b,d,c,e,h,f,g,j){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(g,j);v.lineTo(b,d);v.closePath()}function D(b,d,c,h){if(F!=d)v.lineWidth=F=d;if(B!=c)v.lineCap=B=c;if(P!=h)v.lineJoin=P=h;e(b);v.stroke();X.inflate(d*2)}function C(b){f(b);v.fill()}function va(b,d,c,e,h,f,g,j,k,m,o,X,p){var n,t;n=g.width-1;t=g.height-1;j*=n;k*=t;m*=n;o*=t;X*=n;p*=t;c-=b;e-=d;h-=b;f-=d;m-=j;o-=k;X-=j;p-=k;n=m*p-X*o;n!=0&&(t=1/n,n=(p*c-o*h)*t,o=(p*e-o*f)*t,c=(m*h-X*c)*t,e=(m*f-X*e)*t,b=b-n* +j-c*k,d=d-o*j-e*k,v.save(),v.transform(n,o,c,e,b,d),v.clip(),v.drawImage(g,0,0),v.restore())}function w(b,d,c,e){var h=~~(b.r*255),f=~~(b.g*255),b=~~(b.b*255),g=~~(d.r*255),j=~~(d.g*255),d=~~(d.b*255),k=~~(c.r*255),m=~~(c.g*255),c=~~(c.b*255),o=~~(e.r*255),X=~~(e.g*255),e=~~(e.b*255);ua[0]=h<0?0:h>255?255:h;ua[1]=f<0?0:f>255?255:f;ua[2]=b<0?0:b>255?255:b;ua[4]=g<0?0:g>255?255:g;ua[5]=j<0?0:j>255?255:j;ua[6]=d<0?0:d>255?255:d;ua[8]=k<0?0:k>255?255:k;ua[9]=m<0?0:m>255?255:m;ua[10]=c<0?0:c>255?255:c; +ua[12]=o<0?0:o>255?255:o;ua[13]=X<0?0:X>255?255:X;ua[14]=e<0?0:e>255?255:e;Ma.putImageData(Ua,0,0);Qa.drawImage(La,0,0);return Na}function Ea(b,d,c){b=(b-d)/(c-d);return b*b*(3-2*b)}function Ja(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ba(b,d){var c=d.x-b.x,e=d.y-b.y,h=1/Math.sqrt(c*c+e*e);c*=h;e*=h;d.x+=c;d.y+=e;b.x-=c;b.y-=e}var Ra,Ya,la,wa,Ca,Ka,Sa,ra;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,u);j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,g,this.sortElements);(Ta=b.lights.length> +0)&&o(b);Ra=0;for(Ya=k.length;Ra0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(M.sub(f.position,d.centroidWorld),M.normalize(),g=d.normalWorld.dot(M)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function c(d,c,h,k,m,p){j.data.vertices+=3;j.data.faces++;Q=e(R++);Q.setAttribute("d", +"M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?F.hex=m.color.hex:m instanceof THREE.MeshLambertMaterial?D?(B.r=P.r,B.g=P.g,B.b=P.b,b(p,k,B),F.r=Math.max(0,Math.min(m.color.r*B.r,1)),F.g=Math.max(0,Math.min(m.color.g*B.g,1)),F.b=Math.max(0,Math.min(m.color.b*B.b,1)),F.updateHex()):F.hex=m.color.hex:m instanceof THREE.MeshDepthMaterial?(E=1-m.__2near/(m.__farPlusNear- +k.z*m.__farMinusNear),F.setRGB(E,E,E)):m instanceof THREE.MeshNormalMaterial&&F.setRGB(f(k.normalWorld.x),f(k.normalWorld.y),f(k.normalWorld.z));m.wireframe?Q.setAttribute("style","fill: none; stroke: #"+g(F.hex.toString(16))+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):Q.setAttribute("style","fill: #"+g(F.hex.toString(16))+"; fill-opacity: "+m.opacity);o.appendChild(Q)}function d(d,c,h,k, +m,p,n){j.data.vertices+=4;j.data.faces++;Q=e(R++);Q.setAttribute("d","M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?F.hex=p.color.hex:p instanceof THREE.MeshLambertMaterial?D?(B.r=P.r,B.g=P.g,B.b=P.b,b(n,m,B),F.r=Math.max(0,Math.min(p.color.r*B.r,1)),F.g=Math.max(0,Math.min(p.color.g*B.g,1)),F.b=Math.max(0,Math.min(p.color.b* +B.b,1)),F.updateHex()):F.hex=p.color.hex:p instanceof THREE.MeshDepthMaterial?(E=1-p.__2near/(p.__farPlusNear-m.z*p.__farMinusNear),F.setRGB(E,E,E)):p instanceof THREE.MeshNormalMaterial&&F.setRGB(f(m.normalWorld.x),f(m.normalWorld.y),f(m.normalWorld.z));p.wireframe?Q.setAttribute("style","fill: none; stroke: #"+g(F.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):Q.setAttribute("style", +"fill: #"+g(F.hex.toString(16))+"; fill-opacity: "+p.opacity);o.appendChild(Q)}function e(b){T[b]==null&&(T[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),aa==0&&T[b].setAttribute("shape-rendering","crispEdges"));return T[b]}function f(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function g(b){for(;b.length<6;)b="0"+b;return b}var j=this,k=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,t,u,v,z,A,x,G=new THREE.Rectangle,y=new THREE.Rectangle, +D=!1,F=new THREE.Color(16777215),B=new THREE.Color(16777215),P=new THREE.Color(0),K=new THREE.Color(0),L=new THREE.Color(0),E,M=new THREE.Vector3,T=[],h=[],Q,R,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(b,d){n=b;p=d;t=n/2;u=p/2;o.setAttribute("viewBox",-t+" "+-u+" "+n+" "+p);o.setAttribute("width",n);o.setAttribute("height",p);G.set(-t, +-u,t,u)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(b,e){var f,p,n,F,B,E,I,S;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,e,this.sortElements);N=R=0;if(D=b.lights.length>0){I=b.lights;P.setRGB(0,0,0);K.setRGB(0,0,0);L.setRGB(0,0,0);f=0;for(p=I.length;f 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 c,d,e,g={};for(c=0;c=0)h.bindBuffer(h.ARRAY_BUFFER,f.__webglVertexBuffer),h.vertexAttribPointer(b.position,3,h.FLOAT,!1,0,0);else{c=g.program.attributes;j.morphTargetBase!==-1?(h.bindBuffer(h.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j.morphTargetBase]), -h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0)):c.position>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglVertexBuffer),h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,m=j.morphTargetForcedOrder,n=j.morphTargetInfluences;ep&&(o=t,p=n[o]);h.bindBuffer(h.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[o]);h.vertexAttribPointer(c["morphTarget"+e],3,h.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=p;m[o]=1;p=-1;e++}}g.program.uniforms.morphTargetInfluences!==null&&h.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(f.__webglCustomAttributes)for(k in f.__webglCustomAttributes)b[k]>= -0&&(c=f.__webglCustomAttributes[k],h.bindBuffer(h.ARRAY_BUFFER,c.buffer),h.vertexAttribPointer(b[k],c.size,h.FLOAT,!1,0,0));b.color>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglColorBuffer),h.vertexAttribPointer(b.color,3,h.FLOAT,!1,0,0));b.normal>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglNormalBuffer),h.vertexAttribPointer(b.normal,3,h.FLOAT,!1,0,0));b.tangent>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglTangentBuffer),h.vertexAttribPointer(b.tangent,4,h.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(h.bindBuffer(h.ARRAY_BUFFER, -f.__webglUVBuffer),h.vertexAttribPointer(b.uv,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv)):h.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUV2Buffer),h.vertexAttribPointer(b.uv2,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv2)):h.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexABuffer),h.vertexAttribPointer(b.skinVertexA,4, -h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),h.vertexAttribPointer(b.skinVertexB,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),h.vertexAttribPointer(b.skinIndex,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),h.vertexAttribPointer(b.skinWeight,4,h.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(h.lineWidth(g.wireframeLinewidth),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),h.drawElements(h.LINES,f.__webglLineCount, -h.UNSIGNED_SHORT,0)):(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),h.drawElements(h.TRIANGLES,f.__webglFaceCount,h.UNSIGNED_SHORT,0)),S.data.vertices+=f.__webglFaceCount,S.data.faces+=f.__webglFaceCount/3,S.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?h.LINE_STRIP:h.LINES,h.lineWidth(g.linewidth),h.drawArrays(j,0,f.__webglLineCount),S.data.drawCalls++):j instanceof THREE.ParticleSystem?(h.drawArrays(h.POINTS,0,f.__webglParticleCount),S.data.drawCalls++):j instanceof -THREE.Ribbon&&(h.drawArrays(h.TRIANGLE_STRIP,0,f.__webglVertexCount),S.data.drawCalls++)}}function g(b,d,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=h.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=h.createBuffer();b.hasPos&&(h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,b.positionArray,h.DYNAMIC_DRAW),h.enableVertexAttribArray(d.attributes.position),h.vertexAttribPointer(d.attributes.position,3,h.FLOAT,!1,0,0));if(b.hasNormal){h.bindBuffer(h.ARRAY_BUFFER, -b.__webglNormalBuffer);if(c==THREE.FlatShading){var e,f,g,j,k,m,n,p,o,t,u=b.count*3;for(t=0;t0&&y[0]0&&y[1]0.0010&&k.scale>0.0010)v[0]=k.x,v[1]=k.y,v[2]=k.z,t=k.size*k.scale/ea,u[0]=t*n,u[1]=t,h.uniform3fv(x.screenPosition,v),h.uniform2fv(x.scale,u),h.uniform1f(x.rotation,k.rotation),h.uniform1f(x.opacity,k.opacity),H(k.blending),A(k.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)}h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(J)}function B(b,d){b._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} -function y(b){var d,e,f,g,j;if(b instanceof THREE.Mesh){e=b.geometry;for(d in e.geometryGroups){f=e.geometryGroups[d];j=!1;for(g in f.__webglCustomAttributes)if(f.__webglCustomAttributes[g].needsUpdate){j=!0;break}if(e.__dirtyVertices||e.__dirtyMorphTargets||e.__dirtyElements||e.__dirtyUvs||e.__dirtyNormals||e.__dirtyColors||e.__dirtyTangents||j){j=b;var k=h.DYNAMIC_DRAW;if(f.__inittedArrays){var m=void 0,n=void 0,p=void 0,o=void 0,t=p=void 0,u=void 0,v=void 0,y=void 0,x=void 0,z=void 0,B=void 0, -G=void 0,Z=void 0,A=void 0,D=void 0,F=void 0,H=void 0,E=o=y=o=v=u=void 0,C=void 0,w=C=E=u=void 0,ja=void 0,L=w=C=E=p=p=t=y=o=w=C=E=ja=w=C=E=ja=w=C=E=void 0,fa=0,J=0,M=0,ma=0,O=0,S=0,K=0,Q=0,N=0,I=0,P=0,C=E=0,V=f.__vertexArray,aa=f.__uvArray,$=f.__uv2Array,ga=f.__normalArray,R=f.__tangentArray,W=f.__colorArray,U=f.__skinVertexAArray,ia=f.__skinVertexBArray,X=f.__skinIndexArray,Y=f.__skinWeightArray,ha=f.__morphTargetsArrays,ea=f.__webglCustomAttributes,w=void 0,ca=f.__faceArray,da=f.__lineArray,ka= -f.__needsSmoothNormals,z=f.__vertexColorType,x=f.__uvType,B=f.__normalType,oa=j.geometry,za=oa.__dirtyVertices,wa=oa.__dirtyElements,qa=oa.__dirtyUvs,xa=oa.__dirtyNormals,Va=oa.__dirtyTangents,Wa=oa.__dirtyColors,Xa=oa.__dirtyMorphTargets,Ea=oa.vertices,Za=f.faces,bb=oa.faces,$a=oa.faceVertexUvs[0],ab=oa.faceVertexUvs[1],Fa=oa.skinVerticesA,Ga=oa.skinVerticesB,Ha=oa.skinIndices,ya=oa.skinWeights,Ca=j instanceof THREE.ShadowVolume?oa.edgeFaces:void 0,va=oa.morphTargets;if(ea)for(L in ea)ea[L].offset= -0,ea[L].offsetSrc=0;m=0;for(n=Za.length;m0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,W,k));xa&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglNormalBuffer),h.bufferData(h.ARRAY_BUFFER,ga,k));Va&&oa.hasTangents&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglTangentBuffer),h.bufferData(h.ARRAY_BUFFER,R,k));qa&&M>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUVBuffer),h.bufferData(h.ARRAY_BUFFER,aa,k));qa&&ma>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUV2Buffer),h.bufferData(h.ARRAY_BUFFER,$,k));wa&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, -f.__webglFaceBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,ca,k),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,da,k));I>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexABuffer),h.bufferData(h.ARRAY_BUFFER,U,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),h.bufferData(h.ARRAY_BUFFER,ia,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),h.bufferData(h.ARRAY_BUFFER,X,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),h.bufferData(h.ARRAY_BUFFER, -Y,k));j.dynamic||(delete f.__inittedArrays,delete f.__colorArray,delete f.__normalArray,delete f.__tangentArray,delete f.__uvArray,delete f.__uv2Array,delete f.__faceArray,delete f.__vertexArray,delete f.__lineArray,delete f.__skinVertexAArray,delete f.__skinVertexBArray,delete f.__skinIndexArray,delete f.__skinWeightArray)}}}e.__dirtyVertices=!1;e.__dirtyMorphTargets=!1;e.__dirtyElements=!1;e.__dirtyUvs=!1;e.__dirtyNormals=!1;e.__dirtyTangents=!1;e.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){e= -b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=h.DYNAMIC_DRAW;x=b.vertices;f=b.colors;z=x.length;j=f.length;B=b.__vertexArray;k=b.__colorArray;G=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m65535&&(o[k].counter+=1,m=o[k].hash+"_"+o[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:n})),b.geometryGroups[m].faces.push(f), -b.geometryGroups[m].vertices+=h}function x(b,d,c){b.push({buffer:d,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=P){switch(b){case THREE.AdditiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE);break;case THREE.SubtractiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.SRC_COLOR);break;default:h.blendEquationSeparate(h.FUNC_ADD, -h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)}P=b}}function F(b,d,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(h.texParameteri(b,h.TEXTURE_WRAP_S,G(d.wrapS)),h.texParameteri(b,h.TEXTURE_WRAP_T,G(d.wrapT)),h.texParameteri(b,h.TEXTURE_MAG_FILTER,G(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,G(d.minFilter)),h.generateMipmap(b)):(h.texParameteri(b,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(b,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(b, -h.TEXTURE_MAG_FILTER,L(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,L(d.minFilter)))}function A(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=h.deleteTexture(b.__webglTexture);b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,b.image);F(h.TEXTURE_2D,b,b.image);h.bindTexture(h.TEXTURE_2D,null);b.needsUpdate=!1}h.activeTexture(h.TEXTURE0+d);h.bindTexture(h.TEXTURE_2D,b.__webglTexture)}function O(b){if(b&& -!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=h.createFramebuffer();b.__webglRenderbuffer=h.createRenderbuffer();b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,G(b.wrapS));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,G(b.wrapT));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,G(b.magFilter));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER, -G(b.minFilter));h.texImage2D(h.TEXTURE_2D,0,G(b.format),b.width,b.height,0,G(b.format),G(b.type),null);h.bindRenderbuffer(h.RENDERBUFFER,b.__webglRenderbuffer);h.bindFramebuffer(h.FRAMEBUFFER,b.__webglFramebuffer);h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_COMPONENT16,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)): -b.depthBuffer&&b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_STENCIL,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_STENCIL_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):h.renderbufferStorage(h.RENDERBUFFER,h.RGBA4,b.width,b.height);h.bindTexture(h.TEXTURE_2D,null);h.bindRenderbuffer(h.RENDERBUFFER,null);h.bindFramebuffer(h.FRAMEBUFFER,null)}var d,c;b?(d=b.__webglFramebuffer,c=b.width,b=b.height):(d=null,c=ha,b=ea);d!=W&&(h.bindFramebuffer(h.FRAMEBUFFER,d),h.viewport(V, -da,c,b),W=d)}function C(b,d){var c;b=="fragment"?c=h.createShader(h.FRAGMENT_SHADER):b=="vertex"&&(c=h.createShader(h.VERTEX_SHADER));h.shaderSource(c,d);h.compileShader(c);if(!h.getShaderParameter(c,h.COMPILE_STATUS))return console.error(h.getShaderInfoLog(c)),console.error(d),null;return c}function L(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return h.NEAREST;default:return h.LINEAR}}function G(b){switch(b){case THREE.RepeatWrapping:return h.REPEAT; -case THREE.ClampToEdgeWrapping:return h.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return h.MIRRORED_REPEAT;case THREE.NearestFilter:return h.NEAREST;case THREE.NearestMipMapNearestFilter:return h.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return h.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return h.LINEAR;case THREE.LinearMipMapNearestFilter:return h.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return h.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return h.BYTE; -case THREE.UnsignedByteType:return h.UNSIGNED_BYTE;case THREE.ShortType:return h.SHORT;case THREE.UnsignedShortType:return h.UNSIGNED_SHORT;case THREE.IntType:return h.INT;case THREE.UnsignedShortType:return h.UNSIGNED_INT;case THREE.FloatType:return h.FLOAT;case THREE.AlphaFormat:return h.ALPHA;case THREE.RGBFormat:return h.RGB;case THREE.RGBAFormat:return h.RGBA;case THREE.LuminanceFormat:return h.LUMINANCE;case THREE.LuminanceAlphaFormat:return h.LUMINANCE_ALPHA}return 0}var S=this,h,U=[],Q=null, -W=null,J=!0,$=null,R=null,P=null,ga=null,V=0,da=0,ha=0,ea=0,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Matrix4,K=new Float32Array(16),X=new Float32Array(16),Y=new THREE.Vector4,ka={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Z=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ja=b.stencil!==void 0?b.stencil:!0,fa=b.antialias!== -void 0?b.antialias:!1,ma=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ia=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Z;this.sortObjects=this.autoClear=!0;try{if(!(h=Z.getContext("experimental-webgl",{antialias:fa,stencil:ja})))throw"Error creating WebGL context.";}catch(za){console.error(za)}console.log(navigator.userAgent+" | "+h.getParameter(h.VERSION)+" | "+h.getParameter(h.VENDOR)+" | "+h.getParameter(h.RENDERER)+ -" | "+h.getParameter(h.SHADING_LANGUAGE_VERSION));h.clearColor(0,0,0,1);h.clearDepth(1);h.enable(h.DEPTH_TEST);h.depthFunc(h.LEQUAL);h.frontFace(h.CCW);h.cullFace(h.BACK);h.enable(h.CULL_FACE);h.enable(h.BLEND);h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA);h.clearColor(ma.r,ma.g,ma.b,ia);this.context=h;var wa=h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ja){var aa={};aa.vertices=new Float32Array(12);aa.faces=new Uint16Array(6);aa.darkness=0.5;aa.vertices[0]=-20; -aa.vertices[1]=-20;aa.vertices[2]=-1;aa.vertices[3]=20;aa.vertices[4]=-20;aa.vertices[5]=-1;aa.vertices[6]=20;aa.vertices[7]=20;aa.vertices[8]=-1;aa.vertices[9]=-20;aa.vertices[10]=20;aa.vertices[11]=-1;aa.faces[0]=0;aa.faces[1]=1;aa.faces[2]=2;aa.faces[3]=0;aa.faces[4]=2;aa.faces[5]=3;aa.vertexBuffer=h.createBuffer();aa.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,aa.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,aa.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,aa.elementBuffer); -h.bufferData(h.ELEMENT_ARRAY_BUFFER,aa.faces,h.STATIC_DRAW);aa.program=h.createProgram();h.attachShader(aa.program,C("fragment",THREE.ShaderLib.shadowPost.fragmentShader));h.attachShader(aa.program,C("vertex",THREE.ShaderLib.shadowPost.vertexShader));h.linkProgram(aa.program);aa.vertexLocation=h.getAttribLocation(aa.program,"position");aa.projectionLocation=h.getUniformLocation(aa.program,"projectionMatrix");aa.darknessLocation=h.getUniformLocation(aa.program,"darkness")}var M={};M.vertices=new Float32Array(16); -M.faces=new Uint16Array(6);b=0;M.vertices[b++]=-1;M.vertices[b++]=-1;M.vertices[b++]=0;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;b=0;M.faces[b++]=0;M.faces[b++]=1;M.faces[b++]=2;M.faces[b++]=0;M.faces[b++]=2;M.faces[b++]=3;M.vertexBuffer=h.createBuffer();M.elementBuffer=h.createBuffer();M.tempTexture=h.createTexture(); -M.occlusionTexture=h.createTexture();h.bindBuffer(h.ARRAY_BUFFER,M.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,M.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,M.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,M.faces,h.STATIC_DRAW);h.bindTexture(h.TEXTURE_2D,M.tempTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGB,16,16,0,h.RGB,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D, -h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.bindTexture(h.TEXTURE_2D,M.occlusionTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,16,16,0,h.RGBA,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<= -0?(M.hasVertexTexture=!1,M.program=h.createProgram(),h.attachShader(M.program,C("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),h.attachShader(M.program,C("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(M.hasVertexTexture=!0,M.program=h.createProgram(),h.attachShader(M.program,C("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),h.attachShader(M.program,C("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));h.linkProgram(M.program);M.attributes={};M.uniforms={}; -M.attributes.vertex=h.getAttribLocation(M.program,"position");M.attributes.uv=h.getAttribLocation(M.program,"UV");M.uniforms.renderType=h.getUniformLocation(M.program,"renderType");M.uniforms.map=h.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=h.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=h.getUniformLocation(M.program,"opacity");M.uniforms.scale=h.getUniformLocation(M.program,"scale");M.uniforms.rotation=h.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition= -h.getUniformLocation(M.program,"screenPosition");var xa=!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++]= +if(e instanceof THREE.LineBasicMaterial)k.diffuse.value=e.color,k.opacity.value=e.opacity;else if(e instanceof THREE.ParticleBasicMaterial)k.psColor.value=e.color,k.opacity.value=e.opacity,k.size.value=e.size,k.scale.value=H.height/2,k.map.texture=e.map;else if(e instanceof THREE.MeshPhongMaterial)k.ambient.value=e.ambient,k.specular.value=e.specular,k.shininess.value=e.shininess;else if(e instanceof THREE.MeshDepthMaterial)k.mNear.value=b.near,k.mFar.value=b.far,k.opacity.value=e.opacity;else if(e instanceof +THREE.MeshNormalMaterial)k.opacity.value=e.opacity;for(var va in k)if(n=g.uniforms[va])if(m=k[va],p=m.type,c=m.value,p=="i")h.uniform1i(n,c);else if(p=="f")h.uniform1f(n,c);else if(p=="fv1")h.uniform1fv(n,c);else if(p=="fv")h.uniform3fv(n,c);else if(p=="v2")h.uniform2f(n,c.x,c.y);else if(p=="v3")h.uniform3f(n,c.x,c.y,c.z);else if(p=="v4")h.uniform4f(n,c.x,c.y,c.z,c.w);else if(p=="c")h.uniform3f(n,c.r,c.g,c.b);else if(p=="t"&&(h.uniform1i(n,c),m=m.texture))if(m.image instanceof Array&&m.image.length== +6){if(m.image.length==6){if(m.needsUpdate){if(m.__webglInit){h.bindTexture(h.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)h.texSubImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,0,0,h.RGBA,h.UNSIGNED_BYTE,m.image[p])}else{m.image.__webglTextureCube=h.createTexture();h.bindTexture(h.TEXTURE_CUBE_MAP,m.image.__webglTextureCube);for(p=0;p<6;++p)h.texImage2D(h.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,m.image[p]);m.__webglInit=!0}B(h.TEXTURE_CUBE_MAP,m,m.image[0]);h.bindTexture(h.TEXTURE_CUBE_MAP, +null);m.needsUpdate=!1}h.activeTexture(h.TEXTURE0+c);h.bindTexture(h.TEXTURE_CUBE_MAP,m.image.__webglTextureCube)}}else P(m,c);h.uniformMatrix4fv(j.modelViewMatrix,!1,f._modelViewMatrixArray);h.uniformMatrix3fv(j.normalMatrix,!1,f._normalMatrixArray);(e instanceof THREE.MeshShaderMaterial||e instanceof THREE.MeshPhongMaterial||e.envMap)&&j.cameraPosition!==null&&h.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(e instanceof THREE.MeshShaderMaterial||e.envMap||e.skinning)&&j.objectMatrix!== +null&&h.uniformMatrix4fv(j.objectMatrix,!1,f._objectMatrixArray);(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshShaderMaterial||e.skinning)&&j.viewMatrix!==null&&h.uniformMatrix4fv(j.viewMatrix,!1,$);if(e instanceof THREE.ShadowVolumeDynamicMaterial)b=k.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,h.uniform3fv(j.directionalLightDirection,b),h.uniformMatrix4fv(j.objectMatrix,!1,f._objectMatrixArray), +h.uniformMatrix4fv(j.viewMatrix,!1,$);e.skinning&&(h.uniformMatrix4fv(j.cameraInverseMatrix,!1,$),h.uniformMatrix4fv(j.boneGlobalMatrices,!1,f.boneMatrices));return g}function e(b,c,e,f,g,j){if(f.opacity!=0){var k,b=d(b,c,e,f,j).attributes;if(!f.morphTargets&&b.position>=0)h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(b.position,3,h.FLOAT,!1,0,0);else{c=f.program.attributes;j.morphTargetBase!==-1?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[j.morphTargetBase]), +h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0)):c.position>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,m=j.morphTargetForcedOrder,o=j.morphTargetInfluences;ep&&(n=t,p=o[n]);h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[n]);h.vertexAttribPointer(c["morphTarget"+e],3,h.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=p;m[n]=1;p=-1;e++}}f.program.uniforms.morphTargetInfluences!==null&&h.uniform1fv(f.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(k in g.__webglCustomAttributes)b[k]>= +0&&(c=g.__webglCustomAttributes[k],h.bindBuffer(h.ARRAY_BUFFER,c.buffer),h.vertexAttribPointer(b[k],c.size,h.FLOAT,!1,0,0));b.color>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglColorBuffer),h.vertexAttribPointer(b.color,3,h.FLOAT,!1,0,0));b.normal>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglNormalBuffer),h.vertexAttribPointer(b.normal,3,h.FLOAT,!1,0,0));b.tangent>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglTangentBuffer),h.vertexAttribPointer(b.tangent,4,h.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(h.bindBuffer(h.ARRAY_BUFFER, +g.__webglUVBuffer),h.vertexAttribPointer(b.uv,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv)):h.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUV2Buffer),h.vertexAttribPointer(b.uv2,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv2)):h.disableVertexAttribArray(b.uv2));f.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexABuffer),h.vertexAttribPointer(b.skinVertexA,4, +h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),h.vertexAttribPointer(b.skinVertexB,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),h.vertexAttribPointer(b.skinIndex,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),h.vertexAttribPointer(b.skinWeight,4,h.FLOAT,!1,0,0));j instanceof THREE.Mesh?(f.wireframe?(h.lineWidth(f.wireframeLinewidth),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),h.drawElements(h.LINES,g.__webglLineCount, +h.UNSIGNED_SHORT,0)):(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),h.drawElements(h.TRIANGLES,g.__webglFaceCount,h.UNSIGNED_SHORT,0)),T.data.vertices+=g.__webglFaceCount,T.data.faces+=g.__webglFaceCount/3,T.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?h.LINE_STRIP:h.LINES,h.lineWidth(f.linewidth),h.drawArrays(j,0,g.__webglLineCount),T.data.drawCalls++):j instanceof THREE.ParticleSystem?(h.drawArrays(h.POINTS,0,g.__webglParticleCount),T.data.drawCalls++):j instanceof +THREE.Ribbon&&(h.drawArrays(h.TRIANGLE_STRIP,0,g.__webglVertexCount),T.data.drawCalls++)}}function f(b,d,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=h.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=h.createBuffer();b.hasPos&&(h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,b.positionArray,h.DYNAMIC_DRAW),h.enableVertexAttribArray(d.attributes.position),h.vertexAttribPointer(d.attributes.position,3,h.FLOAT,!1,0,0));if(b.hasNormal){h.bindBuffer(h.ARRAY_BUFFER, +b.__webglNormalBuffer);if(c==THREE.FlatShading){var e,f,g,j,k,m,o,p,n,t,u=b.count*3;for(t=0;t0&&x[0]0&&x[1]0.0010&&k.scale>0.0010)v[0]=k.x,v[1]=k.y,v[2]=k.z,t=k.size*k.scale/fa,u[0]=t*o,u[1]=t,h.uniform3fv(z.screenPosition,v),h.uniform2fv(z.scale,u),h.uniform1f(z.rotation,k.rotation),h.uniform1f(z.opacity,k.opacity),F(k.blending),P(k.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)}h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(aa)}function A(b,d){b._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} +function x(b){var d,e,f,g,j;if(b instanceof THREE.Mesh){e=b.geometry;for(d in e.geometryGroups){f=e.geometryGroups[d];j=!1;for(g in f.__webglCustomAttributes)if(f.__webglCustomAttributes[g].needsUpdate){j=!0;break}if(e.__dirtyVertices||e.__dirtyMorphTargets||e.__dirtyElements||e.__dirtyUvs||e.__dirtyNormals||e.__dirtyColors||e.__dirtyTangents||j){j=b;var k=h.DYNAMIC_DRAW;if(f.__inittedArrays){var m=void 0,o=void 0,p=void 0,n=void 0,t=p=void 0,u=void 0,v=void 0,x=void 0,z=void 0,y=void 0,A=void 0, +F=void 0,G=void 0,B=void 0,D=void 0,Y=void 0,E=void 0,C=n=x=n=v=u=void 0,H=void 0,w=H=C=u=void 0,L=void 0,I=w=H=C=p=p=t=x=n=w=H=C=L=w=H=C=L=w=H=C=void 0,K=0,ha=0,N=0,O=0,P=0,ma=0,M=0,S=0,Q=0,J=0,W=0,H=C=0,V=f.__vertexArray,aa=f.__uvArray,ca=f.__uv2Array,ga=f.__normalArray,R=f.__tangentArray,ja=f.__colorArray,T=f.__skinVertexAArray,U=f.__skinVertexBArray,Z=f.__skinIndexArray,$=f.__skinWeightArray,ia=f.__morphTargetsArrays,fa=f.__webglCustomAttributes,w=void 0,da=f.__faceArray,ea=f.__lineArray,ka=f.__needsSmoothNormals, +y=f.__vertexColorType,z=f.__uvType,A=f.__normalType,na=j.geometry,pa=na.__dirtyVertices,Aa=na.__dirtyElements,sa=na.__dirtyUvs,ya=na.__dirtyNormals,Va=na.__dirtyTangents,Wa=na.__dirtyColors,Xa=na.__dirtyMorphTargets,Fa=na.vertices,Za=f.faces,bb=na.faces,$a=na.faceVertexUvs[0],ab=na.faceVertexUvs[1],Ga=na.skinVerticesA,Ha=na.skinVerticesB,Ia=na.skinIndices,za=na.skinWeights,Da=j instanceof THREE.ShadowVolume?na.edgeFaces:void 0,xa=na.morphTargets;if(fa)for(I in fa)fa[I].offset=0,fa[I].offsetSrc=0; +m=0;for(o=Za.length;m0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,ja,k));ya&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglNormalBuffer),h.bufferData(h.ARRAY_BUFFER,ga,k));Va&&na.hasTangents&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglTangentBuffer),h.bufferData(h.ARRAY_BUFFER,R,k));sa&&N>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUVBuffer),h.bufferData(h.ARRAY_BUFFER,aa,k));sa&&O>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUV2Buffer),h.bufferData(h.ARRAY_BUFFER,ca,k));Aa&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, +f.__webglFaceBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,da,k),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,ea,k));J>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexABuffer),h.bufferData(h.ARRAY_BUFFER,T,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),h.bufferData(h.ARRAY_BUFFER,U,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),h.bufferData(h.ARRAY_BUFFER,Z,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),h.bufferData(h.ARRAY_BUFFER, +$,k));j.dynamic||(delete f.__inittedArrays,delete f.__colorArray,delete f.__normalArray,delete f.__tangentArray,delete f.__uvArray,delete f.__uv2Array,delete f.__faceArray,delete f.__vertexArray,delete f.__lineArray,delete f.__skinVertexAArray,delete f.__skinVertexBArray,delete f.__skinIndexArray,delete f.__skinWeightArray)}}}e.__dirtyVertices=!1;e.__dirtyMorphTargets=!1;e.__dirtyElements=!1;e.__dirtyUvs=!1;e.__dirtyNormals=!1;e.__dirtyTangents=!1;e.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){e= +b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=h.DYNAMIC_DRAW;z=b.vertices;f=b.colors;y=z.length;j=f.length;A=b.__vertexArray;k=b.__colorArray;F=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m=0;c--)b[c].object==d&&b.splice(c,1)}function y(b){function d(b){var f=[];c=0;for(e=b.length;c65535&&(n[k].counter+=1,m=n[k].hash+"_"+n[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[], +materials:j,vertices:0,numMorphTargets:o})),b.geometryGroups[m].faces.push(f),b.geometryGroups[m].vertices+=h}function D(b,d,c){b.push({buffer:d,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(b){if(b!=ga){switch(b){case THREE.AdditiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE);break;case THREE.SubtractiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:h.blendEquation(h.FUNC_ADD); +h.blendFunc(h.ZERO,h.SRC_COLOR);break;default:h.blendEquationSeparate(h.FUNC_ADD,h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)}ga=b}}function B(b,d,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(h.texParameteri(b,h.TEXTURE_WRAP_S,M(d.wrapS)),h.texParameteri(b,h.TEXTURE_WRAP_T,M(d.wrapT)),h.texParameteri(b,h.TEXTURE_MAG_FILTER,M(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,M(d.minFilter)),h.generateMipmap(b)):(h.texParameteri(b,h.TEXTURE_WRAP_S, +h.CLAMP_TO_EDGE),h.texParameteri(b,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(b,h.TEXTURE_MAG_FILTER,E(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,E(d.minFilter)))}function P(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=h.deleteTexture(b.__webglTexture);b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,b.image);B(h.TEXTURE_2D,b,b.image);h.bindTexture(h.TEXTURE_2D,null);b.needsUpdate= +!1}h.activeTexture(h.TEXTURE0+d);h.bindTexture(h.TEXTURE_2D,b.__webglTexture)}function K(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=h.createFramebuffer();b.__webglRenderbuffer=h.createRenderbuffer();b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,M(b.wrapS));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,M(b.wrapT));h.texParameteri(h.TEXTURE_2D, +h.TEXTURE_MAG_FILTER,M(b.magFilter));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,M(b.minFilter));h.texImage2D(h.TEXTURE_2D,0,M(b.format),b.width,b.height,0,M(b.format),M(b.type),null);h.bindRenderbuffer(h.RENDERBUFFER,b.__webglRenderbuffer);h.bindFramebuffer(h.FRAMEBUFFER,b.__webglFramebuffer);h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_COMPONENT16,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER, +h.DEPTH_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_STENCIL,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_STENCIL_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):h.renderbufferStorage(h.RENDERBUFFER,h.RGBA4,b.width,b.height);h.bindTexture(h.TEXTURE_2D,null);h.bindRenderbuffer(h.RENDERBUFFER,null);h.bindFramebuffer(h.FRAMEBUFFER,null)}var d,c;b?(d=b.__webglFramebuffer,c=b.width,b=b.height):(d=null, +c=ka,b=fa);d!=N&&(h.bindFramebuffer(h.FRAMEBUFFER,d),h.viewport(da,ea,c,b),N=d)}function L(b,d){var c;b=="fragment"?c=h.createShader(h.FRAGMENT_SHADER):b=="vertex"&&(c=h.createShader(h.VERTEX_SHADER));h.shaderSource(c,d);h.compileShader(c);if(!h.getShaderParameter(c,h.COMPILE_STATUS))return console.error(h.getShaderInfoLog(c)),console.error(d),null;return c}function E(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return h.NEAREST; +default:return h.LINEAR}}function M(b){switch(b){case THREE.RepeatWrapping:return h.REPEAT;case THREE.ClampToEdgeWrapping:return h.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return h.MIRRORED_REPEAT;case THREE.NearestFilter:return h.NEAREST;case THREE.NearestMipMapNearestFilter:return h.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return h.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return h.LINEAR;case THREE.LinearMipMapNearestFilter:return h.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return h.LINEAR_MIPMAP_LINEAR; +case THREE.ByteType:return h.BYTE;case THREE.UnsignedByteType:return h.UNSIGNED_BYTE;case THREE.ShortType:return h.SHORT;case THREE.UnsignedShortType:return h.UNSIGNED_SHORT;case THREE.IntType:return h.INT;case THREE.UnsignedShortType:return h.UNSIGNED_INT;case THREE.FloatType:return h.FLOAT;case THREE.AlphaFormat:return h.ALPHA;case THREE.RGBFormat:return h.RGB;case THREE.RGBAFormat:return h.RGBA;case THREE.LuminanceFormat:return h.LUMINANCE;case THREE.LuminanceAlphaFormat:return h.LUMINANCE_ALPHA}return 0} +var T=this,h,Q=[],R=null,N=null,aa=!0,U=null,V=null,ga=null,W=null,da=0,ea=0,ka=0,fa=0,I=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],S=new THREE.Matrix4,Z=new Float32Array(16),$=new Float32Array(16),ia=new THREE.Vector4,Y={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},H=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ha=b.stencil!==void 0?b.stencil: +!0,ma=b.antialias!==void 0?b.antialias:!1,ja=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),na=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=H;this.sortObjects=this.autoClear=!0;try{if(!(h=H.getContext("experimental-webgl",{antialias:ma,stencil:ha})))throw"Error creating WebGL context.";}catch(Aa){console.error(Aa)}console.log(navigator.userAgent+" | "+h.getParameter(h.VERSION)+" | "+h.getParameter(h.VENDOR)+ +" | "+h.getParameter(h.RENDERER)+" | "+h.getParameter(h.SHADING_LANGUAGE_VERSION));h.clearColor(0,0,0,1);h.clearDepth(1);h.enable(h.DEPTH_TEST);h.depthFunc(h.LEQUAL);h.frontFace(h.CCW);h.cullFace(h.BACK);h.enable(h.CULL_FACE);h.enable(h.BLEND);h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA);h.clearColor(ja.r,ja.g,ja.b,na);this.context=h;var ya=h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ha){var ca={};ca.vertices=new Float32Array(12);ca.faces=new Uint16Array(6); +ca.darkness=0.5;ca.vertices[0]=-20;ca.vertices[1]=-20;ca.vertices[2]=-1;ca.vertices[3]=20;ca.vertices[4]=-20;ca.vertices[5]=-1;ca.vertices[6]=20;ca.vertices[7]=20;ca.vertices[8]=-1;ca.vertices[9]=-20;ca.vertices[10]=20;ca.vertices[11]=-1;ca.faces[0]=0;ca.faces[1]=1;ca.faces[2]=2;ca.faces[3]=0;ca.faces[4]=2;ca.faces[5]=3;ca.vertexBuffer=h.createBuffer();ca.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,ca.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,ca.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, +ca.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,ca.faces,h.STATIC_DRAW);ca.program=h.createProgram();h.attachShader(ca.program,L("fragment",THREE.ShaderLib.shadowPost.fragmentShader));h.attachShader(ca.program,L("vertex",THREE.ShaderLib.shadowPost.vertexShader));h.linkProgram(ca.program);ca.vertexLocation=h.getAttribLocation(ca.program,"position");ca.projectionLocation=h.getUniformLocation(ca.program,"projectionMatrix");ca.darknessLocation=h.getUniformLocation(ca.program,"darkness")}var O={}; +O.vertices=new Float32Array(16);O.faces=new Uint16Array(6);b=0;O.vertices[b++]=-1;O.vertices[b++]=-1;O.vertices[b++]=0;O.vertices[b++]=0;O.vertices[b++]=1;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]=0;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=1;O.vertices[b++]=-1;O.vertices[b++]=1;O.vertices[b++]=0;O.vertices[b++]=1;b=0;O.faces[b++]=0;O.faces[b++]=1;O.faces[b++]=2;O.faces[b++]=0;O.faces[b++]=2;O.faces[b++]=3;O.vertexBuffer=h.createBuffer();O.elementBuffer=h.createBuffer(); +O.tempTexture=h.createTexture();O.occlusionTexture=h.createTexture();h.bindBuffer(h.ARRAY_BUFFER,O.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,O.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,O.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,O.faces,h.STATIC_DRAW);h.bindTexture(h.TEXTURE_2D,O.tempTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGB,16,16,0,h.RGB,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE); +h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.bindTexture(h.TEXTURE_2D,O.occlusionTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,16,16,0,h.RGBA,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<= +0?(O.hasVertexTexture=!1,O.program=h.createProgram(),h.attachShader(O.program,L("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),h.attachShader(O.program,L("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(O.hasVertexTexture=!0,O.program=h.createProgram(),h.attachShader(O.program,L("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),h.attachShader(O.program,L("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));h.linkProgram(O.program);O.attributes={};O.uniforms={}; +O.attributes.vertex=h.getAttribLocation(O.program,"position");O.attributes.uv=h.getAttribLocation(O.program,"UV");O.uniforms.renderType=h.getUniformLocation(O.program,"renderType");O.uniforms.map=h.getUniformLocation(O.program,"map");O.uniforms.occlusionMap=h.getUniformLocation(O.program,"occlusionMap");O.uniforms.opacity=h.getUniformLocation(O.program,"opacity");O.uniforms.scale=h.getUniformLocation(O.program,"scale");O.uniforms.rotation=h.getUniformLocation(O.program,"rotation");O.uniforms.screenPosition= +h.getUniformLocation(O.program,"screenPosition");var sa=!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=h.createBuffer();_sprite.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,_sprite.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,_sprite.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,_sprite.faces,h.STATIC_DRAW);_sprite.program=h.createProgram(); -h.attachShader(_sprite.program,C("fragment",THREE.ShaderLib.sprite.fragmentShader));h.attachShader(_sprite.program,C("vertex",THREE.ShaderLib.sprite.vertexShader));h.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=h.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=h.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=h.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=h.getUniformLocation(_sprite.program, +h.attachShader(_sprite.program,L("fragment",THREE.ShaderLib.sprite.fragmentShader));h.attachShader(_sprite.program,L("vertex",THREE.ShaderLib.sprite.vertexShader));h.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=h.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=h.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=h.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=h.getUniformLocation(_sprite.program, "uvScale");_sprite.uniforms.rotation=h.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=h.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=h.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=h.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=h.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=h.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance= -h.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=h.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=h.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=h.getUniformLocation(_sprite.program,"projectionMatrix");var qa=!1;this.setSize=function(b,d){Z.width=b;Z.height=d;this.setViewport(0,0,Z.width,Z.height)};this.setViewport=function(b,d,c,e){V=b;da=d;ha=c;ea=e;h.viewport(V,da,ha,ea)}; -this.setScissor=function(b,d,c,e){h.scissor(b,d,c,e)};this.enableScissorTest=function(b){b?h.enable(h.SCISSOR_TEST):h.disable(h.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){J=b;h.depthMask(b)};this.setClearColorHex=function(b,d){ma.setHex(b);ia=d;h.clearColor(ma.r,ma.g,ma.b,ia)};this.setClearColor=function(b,d){ma.copy(b);ia=d;h.clearColor(ma.r,ma.g,ma.b,ia)};this.clear=function(){h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){aa.darkness= +h.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=h.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=h.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=h.getUniformLocation(_sprite.program,"projectionMatrix");var pa=!1;this.setSize=function(b,d){H.width=b;H.height=d;this.setViewport(0,0,H.width,H.height)};this.setViewport=function(b,d,c,e){da=b;ea=d;ka=c;fa=e;h.viewport(da,ea,ka,fa)}; +this.setScissor=function(b,d,c,e){h.scissor(b,d,c,e)};this.enableScissorTest=function(b){b?h.enable(h.SCISSOR_TEST):h.disable(h.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){aa=b;h.depthMask(b)};this.setClearColorHex=function(b,d){ja.setHex(b);na=d;h.clearColor(ja.r,ja.g,ja.b,na)};this.setClearColor=function(b,d){ja.copy(b);na=d;h.clearColor(ja.r,ja.g,ja.b,na)};this.clear=function(){h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){ca.darkness= b};this.getContext=function(){return h};this.initMaterial=function(b,d,c,e){var f,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic"); -if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,o,n;m=n=k=0;for(o=d.length;m=0&&h.enableVertexAttribArray(p.position);p.color>=0&&h.enableVertexAttribArray(p.color);p.normal>= +h.attachShader(t,L("fragment",g+m));h.attachShader(t,L("vertex",o+n));h.linkProgram(t);h.getProgramParameter(t,h.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+h.getProgramParameter(t,h.VALIDATE_STATUS)+", gl error ["+h.getError()+"]");t.uniforms={};t.attributes={};var u;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(u in k)m.push(u);u=m;k=0;for(m= +u.length;k=0&&h.enableVertexAttribArray(p.position);p.color>=0&&h.enableVertexAttribArray(p.color);p.normal>= 0&&h.enableVertexAttribArray(p.normal);p.tangent>=0&&h.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(h.enableVertexAttribArray(p.skinVertexA),h.enableVertexAttribArray(p.skinVertexB),h.enableVertexAttribArray(p.skinIndex),h.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(f in b.attributes)p[f]!==void 0&&p[f]>=0&&h.enableVertexAttribArray(p[f]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=0&&(h.enableVertexAttribArray(p.morphTarget0), b.numSupportedMorphTargets++);p.morphTarget1>=0&&(h.enableVertexAttribArray(p.morphTarget1),b.numSupportedMorphTargets++);p.morphTarget2>=0&&(h.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(h.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(h.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(h.enableVertexAttribArray(p.morphTarget5),b.numSupportedMorphTargets++);p.morphTarget6>= -0&&(h.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>=0&&(h.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);e.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(f=this.maxMorphTargets;b=0&&(h.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);e.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(f=this.maxMorphTargets;b0||t.faceVertexUvs.length>0)j.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(m*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(m*4),j.__skinVertexBArray=new Float32Array(m*4),j.__skinIndexArray=new Float32Array(m*4),j.__skinWeightArray= -new Float32Array(m*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(z*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];t=0;for(u=j.numMorphTargets;t=0;f--){if(e=d.__webglObjects[f].object,c==e){d.__webglObjects.splice(f,1);break}}else if(c instanceof THREE.Sprite)for(f=d.__webglSprites.length-1;f>=0;f--)if(e=d.__webglSprites[f],c==e){d.__webglSprites.splice(f,1);break}b.__objectsRemoved.splice(0,1)}c=0;for(d=b.__webglObjects.length;c0||t.faceVertexUvs.length>0)j.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(m*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(m*4),j.__skinVertexBArray=new Float32Array(m*4),j.__skinIndexArray=new Float32Array(m*4),j.__skinWeightArray= +new Float32Array(m*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(z*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];t=0;for(u=j.numMorphTargets;t1&&(d-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=d;c.s=j;c.v=f;return c}, +THREE.ColorUtils={adjustHSV:function(b,c,d,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,f);f.h=THREE.ColorUtils.clamp(f.h+c,0,1);f.s=THREE.ColorUtils.clamp(f.s+d,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);b.setHSV(f.h,f.s,f.v)},rgbToHsv:function(b,c){var d=b.r,e=b.g,f=b.b,g=Math.max(Math.max(d,e),f),j=Math.min(Math.min(d,e),f);if(j==g)j=d=0;else{var k=g-j,j=k/g,d=d==g?(e-f)/k:e==g?2+(f-d)/k:4+(d-e)/k;d/=6;d<0&&(d+=1);d>1&&(d-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=d;c.s=j;c.v=g;return c}, clamp:function(b,c,d){return bd?d:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(b,c){var d=c instanceof THREE.Mesh,e=b.vertices.length,g=d?c.geometry:c,f=b.vertices,j=g.vertices,k=b.faces,m=g.faces,n=b.faceVertexUvs[0],g=g.faceVertexUvs[0];d&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,p=j.length;o25&&(f=25);g=(f-1)*0.5;d=Array(f);for(c=e=0;c25&&(g=25);f=(g-1)*0.5;d=Array(g);for(c=e=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(d==="pos")if(d=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)d.x=g[0]+(f[0]-g[0])*e,d.y=g[1]+(f[1]-g[1])*e,d.z=g[2]+(f[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",u,j.index-1).pos,this.points[1]=g,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),d.x=g[0],d.y=g[1],d.z=g[2],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(d),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,e,0)}else if(d=== -"rot")THREE.Quaternion.slerp(g,f,b.quaternion,e);else if(d==="scl")d=b.scale,d.x=g[0]+(f[0]-g[0])*e,d.y=g[1]+(f[1]-g[1])*e,d.z=g[2]+(f[2]-g[2])*e}}if(this.JITCompile&&o[0][n]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?f:f+1;d[3]=f>b.length-3?f:f+2;f=b[d[0]];k=b[d[1]];m=b[d[2]];n=b[d[3]];d=g*g;j=g*d;e[0]=this.interpolate(f[0],k[0],m[0],n[0],g,d,j);e[1]=this.interpolate(f[1],k[1],m[1],n[1],g,d,j);e[2]=this.interpolate(f[2],k[2],m[2],n[2],g,d,j);return e}; -THREE.Animation.prototype.interpolate=function(b,c,d,e,g,f,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*f+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,d){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d=d1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(d==="pos")if(d=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)d.x=f[0]+(g[0]-f[0])*e,d.y=f[1]+(g[1]-f[1])*e,d.z=f[2]+(g[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",u,j.index-1).pos,this.points[1]=f,this.points[2]=g,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),d.x=f[0],d.y=f[1],d.z=f[2],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(d),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,e,0)}else if(d=== +"rot")THREE.Quaternion.slerp(f,g,b.quaternion,e);else if(d==="scl")d=b.scale,d.x=f[0]+(g[0]-f[0])*e,d.y=f[1]+(g[1]-f[1])*e,d.z=f[2]+(g[2]-f[2])*e}}if(this.JITCompile&&n[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?g:g+1;d[3]=g>b.length-3?g:g+2;g=b[d[0]];k=b[d[1]];m=b[d[2]];o=b[d[3]];d=f*f;j=f*d;e[0]=this.interpolate(g[0],k[0],m[0],o[0],f,d,j);e[1]=this.interpolate(g[1],k[1],m[1],o[1],f,d,j);e[2]=this.interpolate(g[2],k[2],m[2],o[2],f,d,j);return e}; +THREE.Animation.prototype.interpolate=function(b,c,d,e,f,g,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*g+b*f+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,d){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d=d0?d:0:d>=0?d:d+e.length;d>=0;d--)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[e.length-1]}; THREE.QuakeCamera=function(b){function c(b,c){return function(){c.apply(b,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!==void 0)this.movementSpeed= b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!== @@ -383,139 +383,142 @@ void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this 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 c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&& -(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,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*c;this.lookVertical&&(this.lat-=this.mouseY*c);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), +(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,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*c;this.lookVertical&&(this.lat-=this.mouseY*c);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.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(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; -THREE.PathCamera=function(b){function c(b,c,d,e){var f={name:d,fps:0.6,length:e,hierarchy:[]},g,j=c.getControlPointsArray(),k=c.getLength(),m=j.length,D=0;g=m-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[g]={time:e,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g=0?e:e+g;e=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var k=j[1]-j[0];this.phi= +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,g=Math.PI/180;this.update=function(b,c,d){var e,j;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)*g;this.theta=this.lon*g;e=this.phi%f;this.phi=e>=0?e:e+f;e=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var k=j[1]-j[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;k=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,d)};this.onMouseMove=function(b){this.mouseX= -b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),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=c(this.animationParent, -this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}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(b,c){return function(){c.apply(b,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; +b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.CubeGeometry(10,10,20),m=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.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(b)}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(b,c){return function(){c.apply(b,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 c(b,c){return function(){c.apply(b,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.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward= b.autoForward;if(b.domElement!==void 0)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(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 c=this.getContainerDimensions(),g=c.size[0]/2,f=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- -c.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;var b=this.tdiff*this.movementSpeed,c=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 c=this.getContainerDimensions(),f=c.size[0]/2,g=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-f)/f;this.moveState.pitchDown=(b.clientY- +c.offset[1]-g)/g;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;var b=this.tdiff*this.movementSpeed,c=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*c,this.rotationVector.y*c,this.rotationVector.z*c,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(b,c,d,e){THREE.Camera.call(this,b,c,d,e);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!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,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,n=1,o=0,p=0,t=0,u=0,v=0,z=window.innerWidth/2,B=window.innerHeight/2;this.update= -function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*u),this.rotateVertically(b*v));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*p);this.translateY(b*t);m&&(this.roll+=this.rollSpeed*this.delta*n);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(n<0)?1:n));this.translateX(b*p);this.translateY(b*t);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.y1?d.normalize():d.z=Math.sqrt(1-e*e);g=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(d.y);e.addSelf(this.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e}; -this.rotateCamera=function(){var b=Math.acos(f.dot(j)/f.length()/j.length());if(b){var c=(new THREE.Vector3).cross(f,j).normalize(),d=new THREE.Quaternion;b*=this.rotateSpeed;d.setFromAxisAngle(c,-b);d.multiplyVector3(g);d.multiplyVector3(this.up);d.multiplyVector3(j);this.staticMoving?f=j:(d.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),d.multiplyVector3(f))}};this.zoomCamera=function(){var b=1+(m.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?k=m:k.y+=(m.y-k.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var b=o.clone().subSelf(n);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var c=g.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?n=o:n.addSelf(b.sub(o,n).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), -g.lengthSq()1?d.normalize():d.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(d.y);e.addSelf(this.up.clone().crossSelf(f).setLength(d.x));e.addSelf(f.setLength(d.z));return e}; +this.rotateCamera=function(){var b=Math.acos(g.dot(j)/g.length()/j.length());if(b){var c=(new THREE.Vector3).cross(g,j).normalize(),d=new THREE.Quaternion;b*=this.rotateSpeed;d.setFromAxisAngle(c,-b);d.multiplyVector3(f);d.multiplyVector3(this.up);d.multiplyVector3(j);this.staticMoving?g=j:(d.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),d.multiplyVector3(g))}};this.zoomCamera=function(){var b=1+(m.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(f.multiplyScalar(b),this.staticMoving?k=m:k.y+=(m.y-k.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var b=n.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(f.length()*this.panSpeed);var c=f.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?o=n:o.addSelf(b.sub(n,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +f.lengthSq()0){j(0,0,-o-(f||0));for(m=b;m0){j(0,0,o+(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||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,k,t)))-1);n.push(o)}c.push(n)}for(var u,v,z,g=c.length,d=0;d0)for(e=0;e1&&(u=this.vertices[j].position.clone(), -v=this.vertices[m].position.clone(),z=this.vertices[n].position.clone(),u.normalize(),v.normalize(),z.normalize(),this.faces.push(new THREE.Face3(j,m,n,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([o,p,B]))}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,c,d,e){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;b=[];for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){var e=d/this.segmentsT*2*Math.PI,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))));b.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d= -1;d<=this.segmentsT;++d){var e=(this.segmentsT+1)*c+d,g=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,j));this.faceVertexUvs[0].push([new THREE.UV(b[e][0],b[e][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[f][0],b[f][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,c,d,e,g,f,j){function k(b,c,d,e,f,g){c=d/e*b;d=Math.cos(c);return new THREE.Vector3(f*(2+d)*0.5*Math.cos(b),f*(2+d)*Math.sin(b)*0.5,g*f*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=d||64;this.segmentsT=e||8;this.p=g||2;this.q=f||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);d=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(b=0;b0;){if(o){if(o.equals(g[f])){o=null;continue}}else o=g[f];for(d=0;d0){j(0,0,-n-(g||0));for(m=b;m0){j(0,0,n+ +(f||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||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,k,t)))-1);o.push(n)}c.push(o)}for(var u,v,z,f=c.length,d=0;d0)for(e=0;e1&&(u= +this.vertices[j].position.clone(),v=this.vertices[m].position.clone(),z=this.vertices[o].position.clone(),u.normalize(),v.normalize(),z.normalize(),this.faces.push(new THREE.Face3(j,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([n,p,A]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(b,c){THREE.Geometry.call(this);this.parameters=c||{};this.set(b)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; +THREE.TextGeometry.prototype.set=function(b,c){function d(b,c,d){v.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))}function e(b,c,d,e){v.faces.push(new THREE.Face4(b,c,d,e))}this.text=b;var c=c||this.parameters,f=c.height!==void 0?c.height:50,g=c.curveSegments!==void 0?c.curveSegments:4,j=c.font!==void 0?c.font:"helvetiker",k=c.weight!==void 0?c.weight:"normal",m=c.style!==void 0?c.style:"normal",o=c.bezelThickness!==void 0?c.bezelThickness:10,n=c.bezelSize!==void 0?c.bezelSize:8,p=c.bezelEnabled!== +void 0?c.bezelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=g;THREE.FontUtils.face=j;THREE.FontUtils.weight=k;THREE.FontUtils.style=m;THREE.FontUtils.bezelSize=n;var k=THREE.FontUtils.drawText(b),g=k.points,t=k.faces,j=k.contour,u=k.bezel,v=this;v.vertices=[];v.faces=[];for(var z,m=g.length,A=t.length,n=u.length,k=0;k0;){if(x){if(x.equals(j[k])){x=null;continue}}else x=j[k];o=m*2+k;t=o-1;e(o,t,t+n,o+n);for(p=0;p0;){if(x){if(x.equals(j[k])){x=null;continue}}else x=j[k];for(p=0;p0&&j.push({shape:g,holes:e}),g=p,e=[]):e.push(p):this.Triangulate.area(p)<0?(j.push({shape:p,holes:e}),e=[]):e.push(p);n++}o&&j.push({shape:g,holes:e})}var t,u,v,z,B,y;f=[];for(k=0;k=0?u-1:g.length-1;var p=t-1>=0?t-1:n.length-1,D=[];D.push(n[t]);D.push(g[u]);D.push(g[d]);v=this.Triangulate.area(D);var x=[];x.push(n[t]);x.push(n[p]);x.push(g[u]);B=this.Triangulate.area(x);z=u;y=t;u+=1;t+=-1;u<0&&(u+=g.length);u%=g.length;t<0&&(t+=n.length);t%=g.length;d=u-1>=0?u-1:g.length-1;p=t-1>=0?t-1:n.length- -1;D=[];D.push(n[t]);D.push(g[u]);D.push(g[d]);D=this.Triangulate.area(D);x=[];x.push(n[t]);x.push(n[p]);x.push(g[u]);x=this.Triangulate.area(x);v+B>D+x&&(u=z,t=y,u<0&&(u+=g.length),u%=g.length,t<0&&(t+=n.length),t%=g.length,d=u-1>=0?u-1:g.length-1,p=t-1>=0?t-1:n.length-1);v=g.slice(0,u);B=g.slice(u);z=n.slice(t);y=n.slice(0,t);f.push(n[t]);f.push(g[u]);f.push(g[d]);f.push(n[t]);f.push(n[p]);f.push(g[u]);g=v.concat(z).concat(y).concat(B)}m.shape=g}b=[];t=[];for(k=o=0;k0)for(n=0;n2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return f}m=n;g<=m&&(m=0);n=m+1;g<=n&&(n=0);o=n+1;g<=o&&(o=0);var t;a:{t=b;var u=m,v=n,z=o,B=g,y=j,D=void 0,x=void 0,H=void 0, -F=void 0,A=void 0,O=void 0,C=void 0,L=void 0,G=void 0,x=t[y[u]].x,H=t[y[u]].y,F=t[y[v]].x,A=t[y[v]].y,O=t[y[z]].x,C=t[y[z]].y;if(1.0E-10>(F-x)*(C-H)-(A-H)*(O-x))t=!1;else{for(D=0;D=0&&U>=0&&W>=0){t=!1;break a}}t= -!0}}if(t){p=j[m];t=j[n];u=j[o];f.push(b[p]);f.push(b[t]);f.push(b[u]);k.push([j[m],j[n],j[o]]);m=n;for(o=n+1;o0&&j.push({shape:f,holes:e}),f=p,e=[]):e.push(p):this.Triangulate.area(p)<0?(j.push({shape:p,holes:e}),e=[]):e.push(p);o++}n&&j.push({shape:f,holes:e})}var t,u,v,z,A,x;g=[];for(k=0;k=0?u-1:f.length-1;var p=t-1>=0?t-1:o.length-1,G=[];G.push(o[t]);G.push(f[u]);G.push(f[d]);v=this.Triangulate.area(G);var y=[];y.push(o[t]);y.push(o[p]);y.push(f[u]);A=this.Triangulate.area(y);z=u;x=t;u+=1;t+=-1;u<0&&(u+=f.length);u%=f.length;t<0&&(t+=o.length);t%=f.length;d=u-1>=0?u-1:f.length-1;p=t-1>=0?t-1:o.length- +1;G=[];G.push(o[t]);G.push(f[u]);G.push(f[d]);G=this.Triangulate.area(G);y=[];y.push(o[t]);y.push(o[p]);y.push(f[u]);y=this.Triangulate.area(y);v+A>G+y&&(u=z,t=x,u<0&&(u+=f.length),u%=f.length,t<0&&(t+=o.length),t%=f.length,d=u-1>=0?u-1:f.length-1,p=t-1>=0?t-1:o.length-1);v=f.slice(0,u);A=f.slice(u);z=o.slice(t);x=o.slice(0,t);g.push(o[t]);g.push(f[u]);g.push(f[d]);g.push(o[t]);g.push(o[p]);g.push(f[u]);f=v.concat(z).concat(x).concat(A)}m.shape=f}b=[];t=[];for(k=n=0;k=0;){if(o){if(o.equals(d[b])){o=null;m=this.Triangulate.area(e)>0;j.push(m);g.push(k.divideScalar(e.length));e=[];k=new THREE.Vector2;continue}}else o=d[b];k.addSelf(d[b]);e.push(d[b])}b=d.length;e=0;for(var n;--b>=0;)m=d[b],k=g[e],m=m.clone().subSelf(k),n=this.bezelSize/m.length(), +j[e]?n+=1:n=1-n,n=m.multiplyScalar(n).addSelf(k),f.unshift(n),o?o.equals(d[b])&&(o=null,e++):o=d[b];c.bezel=f;return c},b2p0:function(b,c){var d=1-b;return d*d*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,d,e){return this.b2p0(b,c)+this.b2p1(b,d)+this.b2p2(b,e)},b3p0:function(b,c){var d=1-b;return d*d*d*c},b3p1:function(b,c){var d=1-b;return 3*d*d*b*c},b3p2:function(b,c){return 3*(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,d,e,f){return this.b3p0(b, +c)+this.b3p1(b,d)+this.b3p2(b,e)+this.b3p3(b,f)},extractGlyphPoints:function(b,c,d,e){var f=[],g,j,k,m,o,n,p,t,u,v,z=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(z){if(z.o){c=z._cachedOutline||(z._cachedOutline=z.o.split(" "));k=c.length;for(b=0;b0)for(o=0;o2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return g}m=o;f<=m&&(m=0);o=m+1;f<=o&&(o=0);n=o+1;f<=n&&(n=0);var t;a:{t=b;var u=m,v=o,z=n,A=f,x=j,G=void 0,y=void 0,D=void 0, +F=void 0,B=void 0,P=void 0,K=void 0,L=void 0,E=void 0,y=t[x[u]].x,D=t[x[u]].y,F=t[x[v]].x,B=t[x[v]].y,P=t[x[z]].x,K=t[x[z]].y;if(1.0E-10>(F-y)*(K-D)-(B-D)*(P-y))t=!1;else{for(G=0;G=0&&h>=0&&R>=0){t=!1;break a}}t= +!0}}if(t){p=j[m];t=j[o];u=j[n];g.push(b[p]);g.push(b[t]);g.push(b[u]);k.push([j[m],j[o],j[n]]);m=o;for(n=o+1;n>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function g(b,c){var d=o(b,c),e=o(b,c+1),f=o(b,c+2);return(o(b,c+3)<<24)+(f<<16)+(e<<8)+d}function m(b,c){var d=o(b,c);return(o(b,c+1)<<8)+d}function n(b,c){var d=o(b,c);return d>127?d-256:d}function o(b, -c){return b.charCodeAt(c)&255}function p(c){var d,e,f;d=g(b,c);e=g(b,c+A);f=g(b,c+O);c=m(b,c+C);THREE.BinaryLoader.prototype.f3(y,d,e,f,c)}function t(c){var d,e,f,h,j,n;d=g(b,c);e=g(b,c+A);f=g(b,c+O);h=m(b,c+C);j=g(b,c+L);n=g(b,c+G);c=g(b,c+S);THREE.BinaryLoader.prototype.f3n(y,H,d,e,f,h,j,n,c)}function u(c){var d,e,f,j;d=g(b,c);e=g(b,c+h);f=g(b,c+U);j=g(b,c+Q);c=m(b,c+W);THREE.BinaryLoader.prototype.f4(y,d,e,f,j,c)}function v(c){var d,e,f,j,n,o,p,t;d=g(b,c);e=g(b,c+h);f=g(b,c+U);j=g(b,c+Q);n=m(b, -c+W);o=g(b,c+J);p=g(b,c+$);t=g(b,c+R);c=g(b,c+P);THREE.BinaryLoader.prototype.f4n(y,H,d,e,f,j,n,o,p,t,c)}function z(c){var d,e;d=g(b,c);e=g(b,c+ga);c=g(b,c+V);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[c*2],F[c*2+1])}function B(c){var d,e,f;d=g(b,c);e=g(b,c+da);f=g(b,c+ha);c=g(b,c+ea);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[f*2],F[f*2+1],F[c*2],F[c*2+1])}var y=this,D=0,x,H=[],F=[],A,O,C,L,G,S,h,U,Q,W,J,$,R,P, -ga,V,da,ha,ea,ca,N,K,X,Y,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,c);x={signature:b.substr(D,8),header_bytes:o(b,D+8),vertex_coordinate_bytes:o(b,D+9),normal_coordinate_bytes:o(b,D+10),uv_coordinate_bytes:o(b,D+11),vertex_index_bytes:o(b,D+12),normal_index_bytes:o(b,D+13),uv_index_bytes:o(b,D+14),material_index_bytes:o(b,D+15),nvertices:g(b,D+16),nnormals:g(b,D+16+4),nuvs:g(b,D+16+8),ntri_flat:g(b,D+16+12),ntri_smooth:g(b,D+16+16),ntri_flat_uv:g(b,D+16+20),ntri_smooth_uv:g(b, -D+16+24),nquad_flat:g(b,D+16+28),nquad_smooth:g(b,D+16+32),nquad_flat_uv:g(b,D+16+36),nquad_smooth_uv:g(b,D+16+40)};D+=x.header_bytes;A=x.vertex_index_bytes;O=x.vertex_index_bytes*2;C=x.vertex_index_bytes*3;L=x.vertex_index_bytes*3+x.material_index_bytes;G=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;S=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;h=x.vertex_index_bytes;U=x.vertex_index_bytes*2;Q=x.vertex_index_bytes*3;W=x.vertex_index_bytes*4;J=x.vertex_index_bytes* -4+x.material_index_bytes;$=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;R=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;P=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;ga=x.uv_index_bytes;V=x.uv_index_bytes*2;da=x.uv_index_bytes;ha=x.uv_index_bytes*2;ea=x.uv_index_bytes*3;c=x.vertex_index_bytes*3+x.material_index_bytes;ka=x.vertex_index_bytes*4+x.material_index_bytes;ca=x.ntri_flat*c;N=x.ntri_smooth*(c+x.normal_index_bytes*3);K=x.ntri_flat_uv* -(c+x.uv_index_bytes*3);X=x.ntri_smooth_uv*(c+x.normal_index_bytes*3+x.uv_index_bytes*3);Y=x.nquad_flat*ka;c=x.nquad_smooth*(ka+x.normal_index_bytes*4);ka=x.nquad_flat_uv*(ka+x.uv_index_bytes*4);D+=function(c){for(var e,f,g,h=x.vertex_coordinate_bytes*3,k=c+x.nvertices*h;c1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,L);object.name=u;object.position.set(x[0],x[1],x[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;J.scene.addObject(object);J.objects[u]=object;if(D.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);J.scene.collisions.colliders.push(b)}if(D.castsShadow)b=new THREE.ShadowVolume(A),J.scene.addChild(b), -b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},J.triggers[object.name]=b)}}else x=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(x[0],x[1],x[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=D.visible!==void 0?D.visible:!1,J.scene.addObject(object), -J.objects[u]=object,J.empties[u]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},J.triggers[object.name]=b)}function m(b){return function(c){J.geometries[b]=c;k();h-=1;d.onLoadComplete();o()}}function n(b){return function(c){J.geometries[b]=c}}function o(){d.callbackProgress({totalModels:Q,totalTextures:W,loadedModels:Q-h,loadedTextures:W-U},J);d.onLoadProgress();h==0&&U==0&&c(J)}var p,t,u,v,z,B,y,D,x,H,F,A,O,C,L,G,S,h,U,Q,W,J;G=b.data;b=new THREE.BinaryLoader;S=new THREE.JSONLoader; -U=h=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var $=!1;for(u in G.objects)if(D=G.objects[u],D.meshCollider){$=!0;break}if($)J.scene.collisions=new THREE.CollisionSystem;if(G.transform){$=G.transform.position;H=G.transform.rotation;var R=G.transform.scale;$&&J.scene.position.set($[0],$[1],$[2]);H&&J.scene.rotation.set(H[0],H[1],H[2]);R&&J.scene.scale.set(R[0],R[1],R[2]);($||H||R)&&J.scene.updateMatrix()}$=function(){U-= -1;o();d.onLoadComplete()};for(z in G.cameras){H=G.cameras[z];if(H.type=="perspective")O=new THREE.Camera(H.fov,H.aspect,H.near,H.far);else if(H.type=="ortho")O=new THREE.Camera,O.projectionMatrix=THREE.Matrix4.makeOrtho(H.left,H.right,H.top,H.bottom,H.near,H.far);x=H.position;H=H.target;O.position.set(x[0],x[1],x[2]);O.target.position.set(H[0],H[1],H[2]);J.cameras[z]=O}for(v in G.lights){z=G.lights[v];O=z.color!==void 0?z.color:16777215;H=z.intensity!==void 0?z.intensity:1;if(z.type=="directional")x= -z.direction,light=new THREE.DirectionalLight(O,H),light.position.set(x[0],x[1],x[2]),light.position.normalize();else if(z.type=="point")x=z.position,light=new THREE.PointLight(O,H),light.position.set(x[0],x[1],x[2]);J.scene.addLight(light);J.lights[v]=light}for(B in G.fogs)v=G.fogs[B],v.type=="linear"?C=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(C=new THREE.FogExp2(0,v.density)),H=v.color,C.color.setRGB(H[0],H[1],H[2]),J.fogs[B]=C;if(J.cameras&&G.defaults.camera)J.currentCamera=J.cameras[G.defaults.camera]; -if(J.fogs&&G.defaults.fog)J.scene.fog=J.fogs[G.defaults.fog];H=G.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(H[0],H[1],H[2]);J.bgColorAlpha=G.defaults.bgalpha;for(p in G.geometries)if(B=G.geometries[p],B.type=="bin_mesh"||B.type=="ascii_mesh")h+=1,d.onLoadStart();Q=h;for(p in G.geometries)B=G.geometries[p],B.type=="cube"?(A=new THREE.Cube(B.width,B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),J.geometries[p]=A):B.type=="plane"?(A=new THREE.Plane(B.width, -B.height,B.segmentsWidth,B.segmentsHeight),J.geometries[p]=A):B.type=="sphere"?(A=new THREE.Sphere(B.radius,B.segmentsWidth,B.segmentsHeight),J.geometries[p]=A):B.type=="cylinder"?(A=new THREE.Cylinder(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),J.geometries[p]=A):B.type=="torus"?(A=new THREE.Torus(B.radius,B.tube,B.segmentsR,B.segmentsT),J.geometries[p]=A):B.type=="icosahedron"?(A=new THREE.Icosahedron(B.subdivisions),J.geometries[p]=A):B.type=="bin_mesh"?b.load({model:e(B.url, -G.urlBaseType),callback:m(p)}):B.type=="ascii_mesh"?S.load({model:e(B.url,G.urlBaseType),callback:m(p)}):B.type=="embedded_mesh"&&(B=G.embeds[B.id])&&S.createModel(B,n(p),"");for(y in G.textures)if(p=G.textures[y],p.url instanceof Array){U+=p.url.length;for(b=0;b>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function f(b,c){var d=n(b,c),e=n(b,c+1),g=n(b,c+2);return(n(b,c+3)<<24)+(g<<16)+(e<<8)+d}function m(b,c){var d=n(b,c);return(n(b,c+1)<<8)+d}function o(b,c){var d=n(b,c);return d>127?d-256:d}function n(b, +c){return b.charCodeAt(c)&255}function p(c){var d,e,g;d=f(b,c);e=f(b,c+B);g=f(b,c+P);c=m(b,c+K);THREE.BinaryLoader.prototype.f3(x,d,e,g,c)}function t(c){var d,e,g,h,j,n;d=f(b,c);e=f(b,c+B);g=f(b,c+P);h=m(b,c+K);j=f(b,c+L);n=f(b,c+E);c=f(b,c+M);THREE.BinaryLoader.prototype.f3n(x,D,d,e,g,h,j,n,c)}function u(c){var d,e,g,j;d=f(b,c);e=f(b,c+T);g=f(b,c+h);j=f(b,c+Q);c=m(b,c+R);THREE.BinaryLoader.prototype.f4(x,d,e,g,j,c)}function v(c){var d,e,g,j,n,o,p,t;d=f(b,c);e=f(b,c+T);g=f(b,c+h);j=f(b,c+Q);n=m(b, +c+R);o=f(b,c+N);p=f(b,c+aa);t=f(b,c+U);c=f(b,c+V);THREE.BinaryLoader.prototype.f4n(x,D,d,e,g,j,n,o,p,t,c)}function z(c){var d,e;d=f(b,c);e=f(b,c+ga);c=f(b,c+W);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[c*2],F[c*2+1])}function A(c){var d,e,g;d=f(b,c);e=f(b,c+da);g=f(b,c+ea);c=f(b,c+ka);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[g*2],F[g*2+1],F[c*2],F[c*2+1])}var x=this,G=0,y,D=[],F=[],B,P,K,L,E,M,T,h,Q,R,N,aa,U, +V,ga,W,da,ea,ka,fa,I,S,Z,$,ia;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,c);y={signature:b.substr(G,8),header_bytes:n(b,G+8),vertex_coordinate_bytes:n(b,G+9),normal_coordinate_bytes:n(b,G+10),uv_coordinate_bytes:n(b,G+11),vertex_index_bytes:n(b,G+12),normal_index_bytes:n(b,G+13),uv_index_bytes:n(b,G+14),material_index_bytes:n(b,G+15),nvertices:f(b,G+16),nnormals:f(b,G+16+4),nuvs:f(b,G+16+8),ntri_flat:f(b,G+16+12),ntri_smooth:f(b,G+16+16),ntri_flat_uv:f(b,G+16+20),ntri_smooth_uv:f(b, +G+16+24),nquad_flat:f(b,G+16+28),nquad_smooth:f(b,G+16+32),nquad_flat_uv:f(b,G+16+36),nquad_smooth_uv:f(b,G+16+40)};G+=y.header_bytes;B=y.vertex_index_bytes;P=y.vertex_index_bytes*2;K=y.vertex_index_bytes*3;L=y.vertex_index_bytes*3+y.material_index_bytes;E=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes;M=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*2;T=y.vertex_index_bytes;h=y.vertex_index_bytes*2;Q=y.vertex_index_bytes*3;R=y.vertex_index_bytes*4;N=y.vertex_index_bytes* +4+y.material_index_bytes;aa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes;U=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*2;V=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*3;ga=y.uv_index_bytes;W=y.uv_index_bytes*2;da=y.uv_index_bytes;ea=y.uv_index_bytes*2;ka=y.uv_index_bytes*3;c=y.vertex_index_bytes*3+y.material_index_bytes;ia=y.vertex_index_bytes*4+y.material_index_bytes;fa=y.ntri_flat*c;I=y.ntri_smooth*(c+y.normal_index_bytes*3);S= +y.ntri_flat_uv*(c+y.uv_index_bytes*3);Z=y.ntri_smooth_uv*(c+y.normal_index_bytes*3+y.uv_index_bytes*3);$=y.nquad_flat*ia;c=y.nquad_smooth*(ia+y.normal_index_bytes*4);ia=y.nquad_flat_uv*(ia+y.uv_index_bytes*4);G+=function(c){for(var e,f,g,h=y.vertex_coordinate_bytes*3,k=c+y.nvertices*h;c1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(B,L);object.name=u;object.position.set(y[0],y[1],y[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=G.visible;N.scene.addObject(object);N.objects[u]=object;if(G.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);N.scene.collisions.colliders.push(b)}if(G.castsShadow)b=new THREE.ShadowVolume(B),N.scene.addChild(b), +b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},N.triggers[object.name]=b)}}else y=G.position,r=G.rotation,q=G.quaternion,s=G.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(y[0],y[1],y[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=G.visible!==void 0?G.visible:!1,N.scene.addObject(object), +N.objects[u]=object,N.empties[u]=object,G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},N.triggers[object.name]=b)}function m(b){return function(c){N.geometries[b]=c;k();T-=1;d.onLoadComplete();n()}}function o(b){return function(c){N.geometries[b]=c}}function n(){d.callbackProgress({totalModels:Q,totalTextures:R,loadedModels:Q-T,loadedTextures:R-h},N);d.onLoadProgress();T==0&&h==0&&c(N)}var p,t,u,v,z,A,x,G,y,D,F,B,P,K,L,E,M,T,h,Q,R,N;E=b.data;b=new THREE.BinaryLoader;M=new THREE.JSONLoader; +h=T=0;N={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var aa=!1;for(u in E.objects)if(G=E.objects[u],G.meshCollider){aa=!0;break}if(aa)N.scene.collisions=new THREE.CollisionSystem;if(E.transform){aa=E.transform.position;D=E.transform.rotation;var U=E.transform.scale;aa&&N.scene.position.set(aa[0],aa[1],aa[2]);D&&N.scene.rotation.set(D[0],D[1],D[2]);U&&N.scene.scale.set(U[0],U[1],U[2]);(aa||D||U)&&N.scene.updateMatrix()}aa= +function(){h-=1;n();d.onLoadComplete()};for(z in E.cameras){D=E.cameras[z];if(D.type=="perspective")P=new THREE.Camera(D.fov,D.aspect,D.near,D.far);else if(D.type=="ortho")P=new THREE.Camera,P.projectionMatrix=THREE.Matrix4.makeOrtho(D.left,D.right,D.top,D.bottom,D.near,D.far);y=D.position;D=D.target;P.position.set(y[0],y[1],y[2]);P.target.position.set(D[0],D[1],D[2]);N.cameras[z]=P}for(v in E.lights){z=E.lights[v];P=z.color!==void 0?z.color:16777215;D=z.intensity!==void 0?z.intensity:1;if(z.type== +"directional")y=z.direction,light=new THREE.DirectionalLight(P,D),light.position.set(y[0],y[1],y[2]),light.position.normalize();else if(z.type=="point")y=z.position,light=new THREE.PointLight(P,D),light.position.set(y[0],y[1],y[2]);N.scene.addLight(light);N.lights[v]=light}for(A in E.fogs)v=E.fogs[A],v.type=="linear"?K=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(K=new THREE.FogExp2(0,v.density)),D=v.color,K.color.setRGB(D[0],D[1],D[2]),N.fogs[A]=K;if(N.cameras&&E.defaults.camera)N.currentCamera= +N.cameras[E.defaults.camera];if(N.fogs&&E.defaults.fog)N.scene.fog=N.fogs[E.defaults.fog];D=E.defaults.bgcolor;N.bgColor=new THREE.Color;N.bgColor.setRGB(D[0],D[1],D[2]);N.bgColorAlpha=E.defaults.bgalpha;for(p in E.geometries)if(A=E.geometries[p],A.type=="bin_mesh"||A.type=="ascii_mesh")T+=1,d.onLoadStart();Q=T;for(p in E.geometries)A=E.geometries[p],A.type=="cube"?(B=new THREE.CubeGeometry(A.width,A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),N.geometries[p]= +B):A.type=="plane"?(B=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),N.geometries[p]=B):A.type=="sphere"?(B=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),N.geometries[p]=B):A.type=="cylinder"?(B=new THREE.CylinderGeometry(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset),N.geometries[p]=B):A.type=="torus"?(B=new THREE.TorusGeometry(A.radius,A.tube,A.segmentsR,A.segmentsT),N.geometries[p]=B):A.type=="icosahedron"?(B=new THREE.IcosahedronGeometry(A.subdivisions), +N.geometries[p]=B):A.type=="bin_mesh"?b.load({model:e(A.url,E.urlBaseType),callback:m(p)}):A.type=="ascii_mesh"?M.load({model:e(A.url,E.urlBaseType),callback:m(p)}):A.type=="embedded_mesh"&&(A=E.embeds[A.id])&&M.createModel(A,o(p),"");for(x in E.textures)if(p=E.textures[x],p.url instanceof Array){h+=p.url.length;for(b=0;b=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(m=this.size-1);var t=Math.floor(n-k);t<1&&(t=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var u=Math.floor(o-k);u<1&&(u=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size- -1);for(var v,z,B,y,D,x;p0&&(this.field[B+v]+=y)}}};this.addPlaneX=function(b,c){var g,f,j,k,m,n=this.size,o=this.yd,p=this.zd,t=this.field,u=n*Math.sqrt(b/c);u>n&&(u=n);for(g=0;g0)for(f=0;fo&&(v=o);for(f=0;f0){m=f*p;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(f=0;f=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(m=this.size-1);var t=Math.floor(o-k);t<1&&(t=1);o=Math.floor(o+k);o>this.size-1&&(o=this.size-1);var u=Math.floor(n-k);u<1&&(u=1);k=Math.floor(n+k);k>this.size-1&&(k=this.size- +1);for(var v,z,A,x,G,y;p0&&(this.field[A+v]+=x)}}};this.addPlaneX=function(b,c){var f,g,j,k,m,o=this.size,n=this.yd,p=this.zd,t=this.field,u=o*Math.sqrt(b/c);u>o&&(u=o);for(f=0;f0)for(g=0;gn&&(v=n);for(g=0;g0){m=g*p;for(f=0;fsize&&(dist=size);for(j=0;j0){m=zd*j;for(g=0;gf?this.hits.push(g):this.hits.unshift(g),f=e;return this.hits}; +THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,d,e,f,g=0;c=0;for(d=this.colliders.length;cg?this.hits.push(f):this.hits.unshift(f),g=e;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var d=0;c[d]instanceof THREE.MeshCollider;){var e=this.rayMesh(b,c[d]);if(e.distc.length)return null;return c[d]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var d=this.makeRayLocal(b,c.mesh),e=Number.MAX_VALUE,g,f=0;f=k*g))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);Math.abs(f.x)>Math.abs(f.y)?Math.abs(f.x)>Math.abs(f.z)?(b=k.y-c.y,f=d.y-c.y, -g=e.y-c.y,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y):Math.abs(f.y)>Math.abs(f.z)?(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y);c=f*e-d*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(b*e-k*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=f*k-d*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return j}; +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var d=this.makeRayLocal(b,c.mesh),e=Number.MAX_VALUE,f,g=0;g=k*f))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);Math.abs(g.x)>Math.abs(g.y)?Math.abs(g.x)>Math.abs(g.z)?(b=k.y-c.y,g=d.y-c.y, +f=e.y-c.y,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,g=d.x-c.x,f=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y):Math.abs(g.y)>Math.abs(g.z)?(b=k.x-c.x,g=d.x-c.x,f=e.x-c.x,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,g=d.x-c.x,f=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y);c=g*e-d*f;if(c==0)return Number.MAX_VALUE;c=1/c;e=(b*e-k*f)*c;if(!(e>=0))return Number.MAX_VALUE;c*=g*k-d*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return j}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var d=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,d);var e=THREE.CollisionSystem.__r;e.origin.copy(b.origin);e.direction.copy(b.direction);d.multiplyVector3(e.origin);d.rotateAxis(e.direction);e.direction.normalize();return e}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var d;c.dynamic&&c.mesh&&c.mesh.matrixWorld?d=this.makeRayLocal(b,c.mesh):(d=THREE.CollisionSystem.__r,d.origin.copy(b.origin),d.direction.copy(b.direction));var e=0,g=0,f=0,j=0,k=0,m=0,n=!0;d.origin.xc.max.x&&(e=c.max.x-d.origin.x,e/=d.direction.x,n=!1,j=1);d.origin.yc.max.y&&(g=c.max.y-d.origin.y,g/=d.direction.y, -n=!1,k=1);d.origin.zc.max.z&&(f=c.max.z-d.origin.z,f/=d.direction.z,n=!1,m=1);if(n)return-1;n=0;g>e&&(n=1,e=g);f>e&&(n=2,e=f);switch(n){case 0:k=d.origin.y+d.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*e;if(dc.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=d.origin.x+d.direction.x*e;if(jc.max.x)return Number.MAX_VALUE;d=d.origin.z+d.direction.z* +THREE.CollisionSystem.prototype.rayBox=function(b,c){var d;c.dynamic&&c.mesh&&c.mesh.matrixWorld?d=this.makeRayLocal(b,c.mesh):(d=THREE.CollisionSystem.__r,d.origin.copy(b.origin),d.direction.copy(b.direction));var e=0,f=0,g=0,j=0,k=0,m=0,o=!0;d.origin.xc.max.x&&(e=c.max.x-d.origin.x,e/=d.direction.x,o=!1,j=1);d.origin.yc.max.y&&(f=c.max.y-d.origin.y,f/=d.direction.y, +o=!1,k=1);d.origin.zc.max.z&&(g=c.max.z-d.origin.z,g/=d.direction.z,o=!1,m=1);if(o)return-1;o=0;f>e&&(o=1,e=f);g>e&&(o=2,e=g);switch(o){case 0:k=d.origin.y+d.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*e;if(dc.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=d.origin.x+d.direction.x*e;if(jc.max.x)return Number.MAX_VALUE;d=d.origin.z+d.direction.z* e;if(dc.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:j=d.origin.x+d.direction.x*e;if(jc.max.x)return Number.MAX_VALUE;k=d.origin.y+d.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,m)}return e};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var d=b.direction.dot(c.normal),e=c.point.dot(c.normal);if(d<0)d=(e-b.origin.dot(c.normal))/d;else return Number.MAX_VALUE;return d>0?d:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var d=c.center.clone().subSelf(b.origin);if(d.lengthSq=0)return Math.abs(e)-Math.sqrt(d);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 c=b.geometry.boundingBox,d=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]),d=new THREE.BoxCollider(d,c);d.mesh=b;return d};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; -THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,d=this.setSize,e=this.render,g=new THREE.Camera,f=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},j=new THREE.WebGLRenderTarget(512,512,b),k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.Camera(53,1,1,1E4);m.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:j},mapRight:{type:"t",value:1,texture:k}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var n=new THREE.Scene;n.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(b,e){d.call(c,b,e);j.width=b;j.height=e;k.width=b;k.height=e};this.render= -function(b,d){g.projectionMatrix=d.projectionMatrix;g.position.copy(d.position);g.target.position.copy(d.target.position);g.translateX(-10);f.projectionMatrix=d.projectionMatrix;f.position.copy(d.position);f.target.position.copy(d.target.position);f.translateX(10);e.call(c,b,g,j,!0);e.call(c,b,f,k,!0);e.call(c,n,m)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer; -THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,d=this.setSize,e=this.render,g,f,j=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,e){d.call(c,b,e);g=b/2;f=e};this.render=function(b,d){this.clear();j.fov=d.fov;j.aspect=0.5*d.aspect;j.near=d.near;j.far=d.far;j.updateProjectionMatrix(); -j.position.copy(d.position);j.target.position.copy(d.target.position);j.translateX(c.separation);k.projectionMatrix=j.projectionMatrix;k.position.copy(d.position);k.target.position.copy(d.target.position);k.translateX(-c.separation);this.setViewport(0,0,g,f);e.call(c,b,j);this.setViewport(g,0,g,f);e.call(c,b,k,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,d=this.setSize,e=this.render,f=new THREE.Camera,g=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},j=new THREE.WebGLRenderTarget(512,512,b),k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.Camera(53,1,1,1E4);m.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:j},mapRight:{type:"t",value:1, +texture:k}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var o= +new THREE.Scene;o.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,e){d.call(c,b,e);j.width=b;j.height=e;k.width=b;k.height=e};this.render=function(b,d){f.projectionMatrix=d.projectionMatrix;f.position.copy(d.position);f.target.position.copy(d.target.position);f.translateX(-10);g.projectionMatrix=d.projectionMatrix;g.position.copy(d.position);g.target.position.copy(d.target.position);g.translateX(10);e.call(c,b,f,j,!0);e.call(c,b,g,k,!0);e.call(c,o,m)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,d=this.setSize,e=this.render,f,g,j=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,e){d.call(c,b,e);f=b/2;g=e};this.render=function(b,d){this.clear();j.fov=d.fov;j.aspect=0.5*d.aspect;j.near=d.near;j.far=d.far; +j.updateProjectionMatrix();j.position.copy(d.position);j.target.position.copy(d.target.position);j.translateX(c.separation);k.projectionMatrix=j.projectionMatrix;k.position.copy(d.position);k.target.position.copy(d.target.position);k.translateX(-c.separation);this.setViewport(0,0,f,g);e.call(c,b,j);this.setViewport(f,0,f,g);e.call(c,b,k,!1)}}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index 600fc8d8..0eafc69d 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,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.ColorUtils.clamp(e.h+b,0,1);e.s=THREE.ColorUtils.clamp(e.s+c,0,1);e.v=THREE.ColorUtils.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g==f)g=c=0;else{var j=f-g,g=j/f,c=c==f?(d-e)/j:d==f?2+(e-c)/j:4+(c-d)/j;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}, +THREE.ColorUtils={adjustHSV:function(a,b,c,e){var d=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,d);d.h=THREE.ColorUtils.clamp(d.h+b,0,1);d.s=THREE.ColorUtils.clamp(d.s+c,0,1);d.v=THREE.ColorUtils.clamp(d.v+e,0,1);a.setHSV(d.h,d.s,d.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,d=a.b,f=Math.max(Math.max(c,e),d),g=Math.min(Math.min(c,e),d);if(g==f)g=c=0;else{var j=f-g,g=j/f,c=c==f?(e-d)/j:e==f?2+(d-c)/j:4+(c-e)/j;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}, clamp:function(a,b,c){return ac?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,e=c?b.geometry:b,f=a.vertices,g=e.vertices,j=a.faces,h=e.faces,k=a.faceVertexUvs[0],e=e.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var l=0,m=g.length;l25&&(f=25);e=(f-1)*0.5;c=Array(f);for(b=d=0;b25&&(f=25);d=(f-1)*0.5;c=Array(f);for(b=e=0;b1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+o),d=d<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",o,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",o,j.index+1).pos,d=d*0.33+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(c=== -"rot")THREE.Quaternion.slerp(e,f,a.quaternion,d);else if(c==="scl")c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].update(void 0,!0);for(o=0;oa.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];j=a[c[1]];h=a[c[2]];k=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],j[0],h[0],k[0],e,c,g);d[1]=this.interpolate(f[1],j[1],h[1],k[1],e,c,g);d[2]=this.interpolate(f[2],j[2],h[2],k[2],e,c,g);return d}; -THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+d.length;c>=0;c--)if(d[c][a]!==void 0)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,e,d,f,g,j,h,k,l=this.data.JIT.hierarchy,m,n;this.currentTime+=a*this.timeScale;n=this.currentTime;m=this.currentTime%=this.data.length;k=parseInt(Math.min(m*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,u=this.hierarchy.length;o1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+o),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=d[0]+(f[0]-d[0])*e,c.y=d[1]+(f[1]-d[1])*e,c.z=d[2]+(f[2]-d[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",o,g.index-1).pos,this.points[1]=d,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",o,j.index+1).pos,e=e*0.33+0.33,d=this.interpolateCatmullRom(this.points,e),c.x=d[0],c.y=d[1],c.z=d[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,e,0)}else if(c=== +"rot")THREE.Quaternion.slerp(d,f,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=d[0]+(f[0]-d[0])*e,c.y=d[1]+(f[1]-d[1])*e,c.z=d[2]+(f[2]-d[2])*e}}if(this.JITCompile&&l[0][k]===void 0){this.hierarchy[0].update(void 0,!0);for(o=0;oa.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];j=a[c[1]];h=a[c[2]];k=a[c[3]];c=d*d;g=d*c;e[0]=this.interpolate(f[0],j[0],h[0],k[0],d,c,g);e[1]=this.interpolate(f[1],j[1],h[1],k[1],d,c,g);e[2]=this.interpolate(f[2],j[2],h[2],k[2],d,c,g);return e}; +THREE.Animation.prototype.interpolate=function(a,b,c,e,d,f,g){a=(c-a)*0.5;e=(e-b)*0.5;return(2*(b-c)+a+e)*g+(-3*(b-c)-2*a-e)*f+a*d+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var e=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c0?c:0:c>=0?c:c+e.length;c>=0;c--)if(e[c][a]!==void 0)return e[c];return this.data.hierarchy[b].keys[e.length-1]}; THREE.QuakeCamera=function(a){function b(a,b){return function(){b.apply(a,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!==void 0)this.movementSpeed= a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!== void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault(); a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.onKeyDown=function(a){switch(a.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(a){switch(a.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 a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor= this.heightSpeed?this.tdiff*((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.translateZ(b);this.moveLeft&&this.translateX(-b);this.moveRight&&this.translateX(b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&& -(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);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;a=this.target.position;e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown), +(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,d=this.position;a.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=d.y+100*Math.cos(this.phi);a.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);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;a=this.target.position;d=this.position;a.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=d.y+100*Math.cos(this.phi);a.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown), !1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(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,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))}; -THREE.PathCamera=function(a){function b(a,c,b,d){var f={name:b,fps:0.6,length:d,hierarchy:[]},e,g=c.getControlPointsArray(),j=c.getLength(),h=g.length,w=0;e=h-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[e]={time:d,pos:g[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e=0?d:d+e;d=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=g[1]-g[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-d[0])*(g[1]-g[0])/(d[1]-d[0])+g[0]-g[0])/j)*j+g[0];d=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-d[0])*(g[1]-g[0])/(d[1]-d[0])+g[0]-g[0])/j)*j+g[0];d=this.target.position;d.x=100*Math.sin(this.phi)*Math.cos(this.theta);d.y=100*Math.cos(this.phi);d.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,c,b)};this.onMouseMove=function(a){this.mouseX= -a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),g=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.Cube(10,10,20),h=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(h,g);a.position.set(0,10,0);this.animation=b(this.animationParent, -this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&d(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.apply(a,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; +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var d=Math.PI*2,f=Math.PI/180;this.update=function(a,c,b){var e,g;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;e=this.phi%d;this.phi=e>=0?e:e+d;e=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=g[1]-g[0];this.phi= +TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/j)*j+g[0];e=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/j)*j+g[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,c,b)};this.onMouseMove=function(a){this.mouseX= +a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),g=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.CubeGeometry(10,10,20),h=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(h,g);a.position.set(0,10,0);this.animation= +b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(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(a,c){return function(){c.apply(a,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 b(a,b){return function(){b.apply(a,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.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward= a.autoForward;if(a.domElement!==void 0)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(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.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(a){switch(a.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(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),e=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-e)/e;this.moveState.pitchDown=(a.clientY- +case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),d=b.size[0]/2,f=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-d)/d;this.moveState.pitchDown=(a.clientY- b.offset[1]-f)/f;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*b,this.rotationVector.y*b,this.rotationVector.z*b,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 a=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=-a+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",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(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,b,c,d){THREE.Camera.call(this,a,b,c,d);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Matrix4,h=!1,k=1,l=0,m=0,n=0,o=0,t=0,v=window.innerWidth/2,u=window.innerHeight/2;this.update= -function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*o),this.rotateVertically(a*t));a=this.delta*this.movementSpeed;this.translateZ(a*(l>0||this.autoForward&&!(l<0)?1:l));this.translateX(a*m);this.translateY(a*n);h&&(this.roll+=this.rollSpeed*this.delta*k);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(l<0)?1:l));this.translateX(a*m);this.translateY(a*n);h&&(this.roll+=this.rollSpeed*this.delta*k);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?b.normalize():b.z=Math.sqrt(1-d*d);e=this.position.clone().subSelf(this.target.position);d=this.up.clone().setLength(b.y);d.addSelf(this.up.clone().crossSelf(e).setLength(b.x));d.addSelf(e.setLength(b.z));return d}; -this.rotateCamera=function(){var a=Math.acos(f.dot(g)/f.length()/g.length());if(a){var c=(new THREE.Vector3).cross(f,g).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(e);b.multiplyVector3(this.up);b.multiplyVector3(g);this.staticMoving?f=g:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(f))}};this.zoomCamera=function(){var a=1+(h.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),this.staticMoving?j=h:j.y+=(h.y-j.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var a=l.clone().subSelf(k);if(a.lengthSq()){a.multiplyScalar(e.length()*this.panSpeed);var c=e.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?k=l:k.addSelf(a.sub(l,k).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), -e.lengthSq()1?b.normalize():b.z=Math.sqrt(1-e*e);d=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(b.y);e.addSelf(this.up.clone().crossSelf(d).setLength(b.x));e.addSelf(d.setLength(b.z));return e}; +this.rotateCamera=function(){var a=Math.acos(f.dot(g)/f.length()/g.length());if(a){var c=(new THREE.Vector3).cross(f,g).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(d);b.multiplyVector3(this.up);b.multiplyVector3(g);this.staticMoving?f=g:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(f))}};this.zoomCamera=function(){var a=1+(h.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(d.multiplyScalar(a),this.staticMoving?j=h:j.y+=(h.y-j.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var a=l.clone().subSelf(k);if(a.lengthSq()){a.multiplyScalar(d.length()*this.panSpeed);var c=d.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?k=l:k.addSelf(a.sub(l,k).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +d.lengthSq()0){g(0,0,-l-(f||0));for(h=a;h0){g(0,0,l+(e||0)); -for(h=a+a/2;h<2*a;h++)j.faces.push(new THREE.Face4(2*a+1,(2*h-2*a+2)%a+a,(2*h-2*a+1)%a+a,(2*h-2*a)%a+a))}h=0;for(a=this.faces.length;h0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,j,n)))-1);k.push(l)}b.push(k)}for(var o,t,v,e=b.length,c=0;c0)for(d=0;d1&&(o=this.vertices[g].position.clone(), -t=this.vertices[h].position.clone(),v=this.vertices[k].position.clone(),o.normalize(),t.normalize(),v.normalize(),this.faces.push(new THREE.Face3(g,h,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(v.x,v.y,v.z)])),this.faceVertexUvs[0].push([l,m,u]))}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,b,c,d){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){var d=c/this.segmentsT*2*Math.PI,e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= -1;c<=this.segmentsT;++c){var d=(this.segmentsT+1)*b+c,e=(this.segmentsT+1)*b+c-1,f=(this.segmentsT+1)*(b-1)+c-1,g=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,e,f,g));this.faceVertexUvs[0].push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][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,b,c,d,e,f,g){function j(a,c,b,d,f,e){c=b/d*a;b=Math.cos(c);return new THREE.Vector3(f*(2+b)*0.5*Math.cos(a),f*(2+b)*Math.sin(a)*0.5,e*f*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;d=new THREE.Vector3;f=new THREE.Vector3;for(a=0;a0;){if(l){if(l.equals(e[f])){l=null;continue}}else l=e[f];for(c=0;c0){g(0,0,-l-(f||0));for(h=a;h0){g(0,0,l+ +(d||0));for(h=a+a/2;h<2*a;h++)j.faces.push(new THREE.Face4(2*a+1,(2*h-2*a+2)%a+a,(2*h-2*a+1)%a+a,(2*h-2*a)%a+a))}h=0;for(a=this.faces.length;h0||(l=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,j,n)))-1);k.push(l)}b.push(k)}for(var o,u,t,d=b.length,c=0;c0)for(e=0;e1&&(o= +this.vertices[g].position.clone(),u=this.vertices[h].position.clone(),t=this.vertices[k].position.clone(),o.normalize(),u.normalize(),t.normalize(),this.faces.push(new THREE.Face3(g,h,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([l,m,v]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,b){THREE.Geometry.call(this);this.parameters=b||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; +THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){u.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function e(a,c,b,e){u.faces.push(new THREE.Face4(a,c,b,e))}this.text=a;var b=b||this.parameters,d=b.height!==void 0?b.height:50,f=b.curveSegments!==void 0?b.curveSegments:4,g=b.font!==void 0?b.font:"helvetiker",j=b.weight!==void 0?b.weight:"normal",h=b.style!==void 0?b.style:"normal",k=b.bezelThickness!==void 0?b.bezelThickness:10,l=b.bezelSize!==void 0?b.bezelSize:8,m=b.bezelEnabled!== +void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=f;THREE.FontUtils.face=g;THREE.FontUtils.weight=j;THREE.FontUtils.style=h;THREE.FontUtils.bezelSize=l;var j=THREE.FontUtils.drawText(a),f=j.points,n=j.faces,g=j.contour,o=j.bezel,u=this;u.vertices=[];u.faces=[];for(var t,h=f.length,v=n.length,l=o.length,j=0;j0;){if(x){if(x.equals(g[j])){x=null;continue}}else x=g[j];k=h*2+j;n=k-1;e(k,n,n+l,k+l);for(m=0;m0;){if(x){if(x.equals(g[j])){x=null;continue}}else x=g[j];for(m=0;m0&&g.push({shape:e,holes:d}),e=m,d=[]):d.push(m):this.Triangulate.area(m)<0?(g.push({shape:m,holes:d}),d=[]):d.push(m);k++}l&&g.push({shape:e,holes:d})}var n,o,t,v,u,x;f=[];for(j=0;j=0?o-1:e.length-1;var m=n-1>=0?n-1:k.length-1,w=[];w.push(k[n]);w.push(e[o]);w.push(e[c]);t=this.Triangulate.area(w);var p=[];p.push(k[n]);p.push(k[m]);p.push(e[o]);u=this.Triangulate.area(p);v=o;x=n;o+=1;n+=-1;o<0&&(o+=e.length);o%=e.length;n<0&&(n+=k.length);n%=e.length;c=o-1>=0?o-1:e.length-1;m=n-1>=0?n-1:k.length- -1;w=[];w.push(k[n]);w.push(e[o]);w.push(e[c]);w=this.Triangulate.area(w);p=[];p.push(k[n]);p.push(k[m]);p.push(e[o]);p=this.Triangulate.area(p);t+u>w+p&&(o=v,n=x,o<0&&(o+=e.length),o%=e.length,n<0&&(n+=k.length),n%=e.length,c=o-1>=0?o-1:e.length-1,m=n-1>=0?n-1:k.length-1);t=e.slice(0,o);u=e.slice(o);v=k.slice(n);x=k.slice(0,n);f.push(k[n]);f.push(e[o]);f.push(e[c]);f.push(k[n]);f.push(k[m]);f.push(e[o]);e=t.concat(v).concat(x).concat(u)}h.shape=e}a=[];n=[];for(j=l=0;j0)for(k=0;k2;){if(m--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return j;return f}h=k;e<=h&&(h=0);k=h+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var n;a:{n=a;var o=h,t=k,v=l,u=e,x=g,w=void 0,p=void 0,y=void 0, -z=void 0,C=void 0,D=void 0,E=void 0,F=void 0,B=void 0,p=n[x[o]].x,y=n[x[o]].y,z=n[x[t]].x,C=n[x[t]].y,D=n[x[v]].x,E=n[x[v]].y;if(1.0E-10>(z-p)*(E-y)-(C-y)*(D-p))n=!1;else{for(w=0;w=0&&G>=0&&H>=0){n=!1;break a}}n=!0}}if(n){m= -g[h];n=g[k];o=g[l];f.push(a[m]);f.push(a[n]);f.push(a[o]);j.push([g[h],g[k],g[l]]);h=k;for(l=k+1;l0&&g.push({shape:d,holes:e}),d=m,e=[]):e.push(m):this.Triangulate.area(m)<0?(g.push({shape:m,holes:e}),e=[]):e.push(m);k++}l&&g.push({shape:d,holes:e})}var n,o,u,t,v,x;f=[];for(j=0;j=0?o-1:d.length-1;var m=n-1>=0?n-1:k.length-1,w=[];w.push(k[n]);w.push(d[o]);w.push(d[c]);u=this.Triangulate.area(w);var p=[];p.push(k[n]);p.push(k[m]);p.push(d[o]);v=this.Triangulate.area(p);t=o;x=n;o+=1;n+=-1;o<0&&(o+=d.length);o%=d.length;n<0&&(n+=k.length);n%=d.length;c=o-1>=0?o-1:d.length-1;m=n-1>=0?n-1:k.length- +1;w=[];w.push(k[n]);w.push(d[o]);w.push(d[c]);w=this.Triangulate.area(w);p=[];p.push(k[n]);p.push(k[m]);p.push(d[o]);p=this.Triangulate.area(p);u+v>w+p&&(o=t,n=x,o<0&&(o+=d.length),o%=d.length,n<0&&(n+=k.length),n%=d.length,c=o-1>=0?o-1:d.length-1,m=n-1>=0?n-1:k.length-1);u=d.slice(0,o);v=d.slice(o);t=k.slice(n);x=k.slice(0,n);f.push(k[n]);f.push(d[o]);f.push(d[c]);f.push(k[n]);f.push(k[m]);f.push(d[o]);d=u.concat(t).concat(x).concat(v)}h.shape=d}a=[];n=[];for(j=l=0;j=0;){if(k){if(k.equals(c[a])){k=null;h=this.Triangulate.area(e)>0;g.push(h);f.push(j.divideScalar(e.length));e=[];j=new THREE.Vector2;continue}}else k=c[a];j.addSelf(c[a]);e.push(c[a])}a=c.length;e=0;for(var l;--a>=0;)h=c[a],j=f[e],h=h.clone().subSelf(j),l=this.bezelSize/h.length(), +g[e]?l+=1:l=1-l,l=h.multiplyScalar(l).addSelf(j),d.unshift(l),k?k.equals(c[a])&&(k=null,e++):k=c[a];b.bezel=d;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,e){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,e)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,e,d){return this.b3p0(a, +b)+this.b3p1(a,c)+this.b3p2(a,e)+this.b3p3(a,d)},extractGlyphPoints:function(a,b,c,e){var d=[],f,g,j,h,k,l,m,n,o,u,t=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(t){if(t.o){b=t._cachedOutline||(t._cachedOutline=t.o.split(" "));j=b.length;for(a=0;a0)for(k=0;k2;){if(m--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return j;return f}h=k;d<=h&&(h=0);k=h+1;d<=k&&(k=0);l=k+1;d<=l&&(l=0);var n;a:{n=a;var o=h,u=k,t=l,v=d,x=g,w=void 0,p=void 0,y=void 0, +z=void 0,C=void 0,D=void 0,E=void 0,F=void 0,B=void 0,p=n[x[o]].x,y=n[x[o]].y,z=n[x[u]].x,C=n[x[u]].y,D=n[x[t]].x,E=n[x[t]].y;if(1.0E-10>(z-p)*(E-y)-(C-y)*(D-p))n=!1;else{for(w=0;w=0&&G>=0&&H>=0){n=!1;break a}}n=!0}}if(n){m= +g[h];n=g[k];o=g[l];f.push(a[m]);f.push(a[n]);f.push(a[o]);j.push([g[h],g[k],g[l]]);h=k;for(l=k+1;l>7)-127;d|=(f&127)<<16|e<<8;if(d==0&&h==-127)return 0;return(1-2*(g>>7))*(1+d*Math.pow(2,-23))*Math.pow(2,h)}function e(a,c){var b=l(a,c),d=l(a,c+1),f=l(a,c+2);return(l(a,c+3)<<24)+(f<<16)+(d<<8)+b}function h(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function k(a,c){var b=l(a,c);return b>127?b-256:b}function l(a, -c){return a.charCodeAt(c)&255}function m(c){var b,d,f;b=e(a,c);d=e(a,c+C);f=e(a,c+D);c=h(a,c+E);THREE.BinaryLoader.prototype.f3(x,b,d,f,c)}function n(c){var b,d,f,g,k,l;b=e(a,c);d=e(a,c+C);f=e(a,c+D);g=h(a,c+E);k=e(a,c+F);l=e(a,c+B);c=e(a,c+J);THREE.BinaryLoader.prototype.f3n(x,y,b,d,f,g,k,l,c)}function o(c){var b,d,f,g;b=e(a,c);d=e(a,c+L);f=e(a,c+G);g=e(a,c+M);c=h(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,d,f,g,c)}function t(c){var b,d,f,g,k,l,m,n;b=e(a,c);d=e(a,c+L);f=e(a,c+G);g=e(a,c+M);k=h(a, -c+H);l=e(a,c+A);m=e(a,c+I);n=e(a,c+K);c=e(a,c+N);THREE.BinaryLoader.prototype.f4n(x,y,b,d,f,g,k,l,m,n,c)}function v(c){var b,d;b=e(a,c);d=e(a,c+P);c=e(a,c+Q);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],z[b*2],z[b*2+1],z[d*2],z[d*2+1],z[c*2],z[c*2+1])}function u(c){var b,d,f;b=e(a,c);d=e(a,c+R);f=e(a,c+X);c=e(a,c+Y);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],z[b*2],z[b*2+1],z[d*2],z[d*2+1],z[f*2],z[f*2+1],z[c*2],z[c*2+1])}var x=this,w=0,p,y=[],z=[],C,D,E,F,B,J,L,G,M,H,A,I,K,N,P,Q, -R,X,Y,S,T,U,V,W,O;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,d,c);p={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:e(a,w+16),nnormals:e(a,w+16+4),nuvs:e(a,w+16+8),ntri_flat:e(a,w+16+12),ntri_smooth:e(a,w+16+16),ntri_flat_uv:e(a,w+16+20),ntri_smooth_uv:e(a,w+ -16+24),nquad_flat:e(a,w+16+28),nquad_smooth:e(a,w+16+32),nquad_flat_uv:e(a,w+16+36),nquad_smooth_uv:e(a,w+16+40)};w+=p.header_bytes;C=p.vertex_index_bytes;D=p.vertex_index_bytes*2;E=p.vertex_index_bytes*3;F=p.vertex_index_bytes*3+p.material_index_bytes;B=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;L=p.vertex_index_bytes;G=p.vertex_index_bytes*2;M=p.vertex_index_bytes*3;H=p.vertex_index_bytes*4;A=p.vertex_index_bytes* +this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,b,c){a.materials=[];for(var e=0;e>7)-127;e|=(f&127)<<16|d<<8;if(e==0&&h==-127)return 0;return(1-2*(g>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,h)}function d(a,c){var b=l(a,c),e=l(a,c+1),f=l(a,c+2);return(l(a,c+3)<<24)+(f<<16)+(e<<8)+b}function h(a,c){var b=l(a,c);return(l(a,c+1)<<8)+b}function k(a,c){var b=l(a,c);return b>127?b-256:b}function l(a, +c){return a.charCodeAt(c)&255}function m(c){var b,e,f;b=d(a,c);e=d(a,c+C);f=d(a,c+D);c=h(a,c+E);THREE.BinaryLoader.prototype.f3(x,b,e,f,c)}function n(c){var b,e,f,g,k,l;b=d(a,c);e=d(a,c+C);f=d(a,c+D);g=h(a,c+E);k=d(a,c+F);l=d(a,c+B);c=d(a,c+J);THREE.BinaryLoader.prototype.f3n(x,y,b,e,f,g,k,l,c)}function o(c){var b,e,f,g;b=d(a,c);e=d(a,c+L);f=d(a,c+G);g=d(a,c+M);c=h(a,c+H);THREE.BinaryLoader.prototype.f4(x,b,e,f,g,c)}function u(c){var b,e,f,g,k,l,m,n;b=d(a,c);e=d(a,c+L);f=d(a,c+G);g=d(a,c+M);k=h(a, +c+H);l=d(a,c+A);m=d(a,c+I);n=d(a,c+K);c=d(a,c+N);THREE.BinaryLoader.prototype.f4n(x,y,b,e,f,g,k,l,m,n,c)}function t(c){var b,e;b=d(a,c);e=d(a,c+P);c=d(a,c+Q);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],z[b*2],z[b*2+1],z[e*2],z[e*2+1],z[c*2],z[c*2+1])}function v(c){var b,e,f;b=d(a,c);e=d(a,c+R);f=d(a,c+X);c=d(a,c+Y);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],z[b*2],z[b*2+1],z[e*2],z[e*2+1],z[f*2],z[f*2+1],z[c*2],z[c*2+1])}var x=this,w=0,p,y=[],z=[],C,D,E,F,B,J,L,G,M,H,A,I,K,N,P,Q, +R,X,Y,S,T,U,V,W,O;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,e,c);p={signature:a.substr(w,8),header_bytes:l(a,w+8),vertex_coordinate_bytes:l(a,w+9),normal_coordinate_bytes:l(a,w+10),uv_coordinate_bytes:l(a,w+11),vertex_index_bytes:l(a,w+12),normal_index_bytes:l(a,w+13),uv_index_bytes:l(a,w+14),material_index_bytes:l(a,w+15),nvertices:d(a,w+16),nnormals:d(a,w+16+4),nuvs:d(a,w+16+8),ntri_flat:d(a,w+16+12),ntri_smooth:d(a,w+16+16),ntri_flat_uv:d(a,w+16+20),ntri_smooth_uv:d(a,w+ +16+24),nquad_flat:d(a,w+16+28),nquad_smooth:d(a,w+16+32),nquad_flat_uv:d(a,w+16+36),nquad_smooth_uv:d(a,w+16+40)};w+=p.header_bytes;C=p.vertex_index_bytes;D=p.vertex_index_bytes*2;E=p.vertex_index_bytes*3;F=p.vertex_index_bytes*3+p.material_index_bytes;B=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;L=p.vertex_index_bytes;G=p.vertex_index_bytes*2;M=p.vertex_index_bytes*3;H=p.vertex_index_bytes*4;A=p.vertex_index_bytes* 4+p.material_index_bytes;I=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;K=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;N=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;P=p.uv_index_bytes;Q=p.uv_index_bytes*2;R=p.uv_index_bytes;X=p.uv_index_bytes*2;Y=p.uv_index_bytes*3;c=p.vertex_index_bytes*3+p.material_index_bytes;O=p.vertex_index_bytes*4+p.material_index_bytes;S=p.ntri_flat*c;T=p.ntri_smooth*(c+p.normal_index_bytes*3);U=p.ntri_flat_uv* -(c+p.uv_index_bytes*3);V=p.ntri_smooth_uv*(c+p.normal_index_bytes*3+p.uv_index_bytes*3);W=p.nquad_flat*O;c=p.nquad_smooth*(O+p.normal_index_bytes*4);O=p.nquad_flat_uv*(O+p.uv_index_bytes*4);w+=function(c){for(var d,e,f,h=p.vertex_coordinate_bytes*3,j=c+p.nvertices*h;c1&&(F=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,F);object.name=o;object.position.set(p[0],p[1],p[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=w.visible;A.scene.addObject(object);A.objects[o]=object;if(w.meshCollider){var a=THREE.CollisionUtils.MeshColliderWBox(object);A.scene.collisions.colliders.push(a)}if(w.castsShadow)a=new THREE.ShadowVolume(C),A.scene.addChild(a), a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},A.triggers[object.name]=a)}}else p=w.position,r=w.rotation,q=w.quaternion,s=w.scale,q=0,object=new THREE.Object3D,object.name=o,object.position.set(p[0],p[1],p[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible=w.visible!==void 0?w.visible:!1,A.scene.addObject(object), -A.objects[o]=object,A.empties[o]=object,w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},A.triggers[object.name]=a)}function h(a){return function(b){A.geometries[a]=b;j();L-=1;c.onLoadComplete();l()}}function k(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:M,totalTextures:H,loadedModels:M-L,loadedTextures:H-G},A);c.onLoadProgress();L==0&&G==0&&b(A)}var m,n,o,t,v,u,x,w,p,y,z,C,D,E,F,B,J,L,G,M,H,A;B=a.data;a=new THREE.BinaryLoader;J=new THREE.JSONLoader; +A.objects[o]=object,A.empties[o]=object,w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},A.triggers[object.name]=a)}function h(a){return function(b){A.geometries[a]=b;j();L-=1;c.onLoadComplete();l()}}function k(a){return function(c){A.geometries[a]=c}}function l(){c.callbackProgress({totalModels:M,totalTextures:H,loadedModels:M-L,loadedTextures:H-G},A);c.onLoadProgress();L==0&&G==0&&b(A)}var m,n,o,u,t,v,x,w,p,y,z,C,D,E,F,B,J,L,G,M,H,A;B=a.data;a=new THREE.BinaryLoader;J=new THREE.JSONLoader; G=L=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var I=!1;for(o in B.objects)if(w=B.objects[o],w.meshCollider){I=!0;break}if(I)A.scene.collisions=new THREE.CollisionSystem;if(B.transform){I=B.transform.position;y=B.transform.rotation;var K=B.transform.scale;I&&A.scene.position.set(I[0],I[1],I[2]);y&&A.scene.rotation.set(y[0],y[1],y[2]);K&&A.scene.scale.set(K[0],K[1],K[2]);(I||y||K)&&A.scene.updateMatrix()}I=function(){G-= -1;l();c.onLoadComplete()};for(v in B.cameras){y=B.cameras[v];if(y.type=="perspective")D=new THREE.Camera(y.fov,y.aspect,y.near,y.far);else if(y.type=="ortho")D=new THREE.Camera,D.projectionMatrix=THREE.Matrix4.makeOrtho(y.left,y.right,y.top,y.bottom,y.near,y.far);p=y.position;y=y.target;D.position.set(p[0],p[1],p[2]);D.target.position.set(y[0],y[1],y[2]);A.cameras[v]=D}for(t in B.lights){v=B.lights[t];D=v.color!==void 0?v.color:16777215;y=v.intensity!==void 0?v.intensity:1;if(v.type=="directional")p= -v.direction,light=new THREE.DirectionalLight(D,y),light.position.set(p[0],p[1],p[2]),light.position.normalize();else if(v.type=="point")p=v.position,light=new THREE.PointLight(D,y),light.position.set(p[0],p[1],p[2]);A.scene.addLight(light);A.lights[t]=light}for(u in B.fogs)t=B.fogs[u],t.type=="linear"?E=new THREE.Fog(0,t.near,t.far):t.type=="exp2"&&(E=new THREE.FogExp2(0,t.density)),y=t.color,E.color.setRGB(y[0],y[1],y[2]),A.fogs[u]=E;if(A.cameras&&B.defaults.camera)A.currentCamera=A.cameras[B.defaults.camera]; -if(A.fogs&&B.defaults.fog)A.scene.fog=A.fogs[B.defaults.fog];y=B.defaults.bgcolor;A.bgColor=new THREE.Color;A.bgColor.setRGB(y[0],y[1],y[2]);A.bgColorAlpha=B.defaults.bgalpha;for(m in B.geometries)if(u=B.geometries[m],u.type=="bin_mesh"||u.type=="ascii_mesh")L+=1,c.onLoadStart();M=L;for(m in B.geometries)u=B.geometries[m],u.type=="cube"?(C=new THREE.Cube(u.width,u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides),A.geometries[m]=C):u.type=="plane"?(C=new THREE.Plane(u.width, -u.height,u.segmentsWidth,u.segmentsHeight),A.geometries[m]=C):u.type=="sphere"?(C=new THREE.Sphere(u.radius,u.segmentsWidth,u.segmentsHeight),A.geometries[m]=C):u.type=="cylinder"?(C=new THREE.Cylinder(u.numSegs,u.topRad,u.botRad,u.height,u.topOffset,u.botOffset),A.geometries[m]=C):u.type=="torus"?(C=new THREE.Torus(u.radius,u.tube,u.segmentsR,u.segmentsT),A.geometries[m]=C):u.type=="icosahedron"?(C=new THREE.Icosahedron(u.subdivisions),A.geometries[m]=C):u.type=="bin_mesh"?a.load({model:d(u.url, -B.urlBaseType),callback:h(m)}):u.type=="ascii_mesh"?J.load({model:d(u.url,B.urlBaseType),callback:h(m)}):u.type=="embedded_mesh"&&(u=B.embeds[u.id])&&J.createModel(u,k(m),"");for(x in B.textures)if(m=B.textures[x],m.url instanceof Array){G+=m.url.length;for(a=0;a=this.maxCount-3&&j(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(h=this.size-1);var n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=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 t,v,u,x,w,p;m0&&(this.field[u+t]+=x)}}};this.addPlaneX=function(a,b){var e,f,g,j,h,k=this.size,l=this.yd,m=this.zd,n=this.field,o=k*Math.sqrt(a/b);o>k&&(o=k);for(e=0;e0)for(f=0;fl&&(t=l);for(f=0;f0){h=f*m;for(e=0;esize&&(dist=size);for(g=0;g0){h=zd*g;for(f=0;f=this.maxCount-3&&j(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;bthis.size-1&&(h=this.size-1);var n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=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 u,t,v,x,w,p;m0&&(this.field[v+u]+=x)}}};this.addPlaneX=function(a,b){var d,f,g,j,h,k=this.size,l=this.yd,m=this.zd,n=this.field,o=k*Math.sqrt(a/b);o>k&&(o=k);for(d=0;d0)for(f=0;fl&&(u=l);for(f=0;f0){h=f*m;for(d=0;dsize&&(dist=size);for(g=0;g0){h=zd*g;for(f=0;ff?this.hits.push(e):this.hits.unshift(e),f=d;return this.hits}; -THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var d=this.rayMesh(a,b[c]);if(d.distb.length)return null;return b[c]}; +THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var b,c,e,d,f=0;b=0;for(c=this.colliders.length;bf?this.hits.push(d):this.hits.unshift(d),f=e;return this.hits}; +THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var e=this.rayMesh(a,b[c]);if(e.distb.length)return null;return b[c]}; THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),d=Number.MAX_VALUE,e,f=0;f=j*e))return Number.MAX_VALUE;g/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(g);j.addSelf(a.origin);Math.abs(f.x)>Math.abs(f.y)?Math.abs(f.x)>Math.abs(f.z)?(a=j.y-b.y,f=c.y-b.y, -e=d.y-b.y,j=j.z-b.z,c=c.z-b.z,d=d.z-b.z):(a=j.x-b.x,f=c.x-b.x,e=d.x-b.x,j=j.y-b.y,c=c.y-b.y,d=d.y-b.y):Math.abs(f.y)>Math.abs(f.z)?(a=j.x-b.x,f=c.x-b.x,e=d.x-b.x,j=j.z-b.z,c=c.z-b.z,d=d.z-b.z):(a=j.x-b.x,f=c.x-b.x,e=d.x-b.x,j=j.y-b.y,c=c.y-b.y,d=d.y-b.y);b=f*d-c*e;if(b==0)return Number.MAX_VALUE;b=1/b;d=(a*d-j*e)*b;if(!(d>=0))return Number.MAX_VALUE;b*=f*j-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-d-b>=0))return Number.MAX_VALUE;return g}; -THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var d=THREE.CollisionSystem.__r;d.origin.copy(a.origin);d.direction.copy(a.direction);c.multiplyVector3(d.origin);c.rotateAxis(d.direction);d.direction.normalize();return d}; -THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var d=0,e=0,f=0,g=0,j=0,h=0,k=!0;c.origin.xb.max.x&&(d=b.max.x-c.origin.x,d/=c.direction.x,k=!1,g=1);c.origin.yb.max.y&&(e=b.max.y-c.origin.y,e/=c.direction.y, -k=!1,j=1);c.origin.zb.max.z&&(f=b.max.z-c.origin.z,f/=c.direction.z,k=!1,h=1);if(k)return-1;k=0;e>d&&(k=1,d=e);f>d&&(k=2,d=f);switch(k){case 0:j=c.origin.y+c.direction.y*d;if(jb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*d;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(g,0,0);break;case 1:g=c.origin.x+c.direction.x*d;if(gb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* -d;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,j,0);break;case 2:g=c.origin.x+c.direction.x*d;if(gb.max.x)return Number.MAX_VALUE;j=c.origin.y+c.direction.y*d;if(jb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,h)}return d};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),d=b.point.dot(b.normal);if(c<0)c=(d-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; -THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(d)-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.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),e=Number.MAX_VALUE,d,f=0;f=j*d))return Number.MAX_VALUE;g/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(g);j.addSelf(a.origin);Math.abs(f.x)>Math.abs(f.y)?Math.abs(f.x)>Math.abs(f.z)?(a=j.y-b.y,f=c.y-b.y, +d=e.y-b.y,j=j.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=j.x-b.x,f=c.x-b.x,d=e.x-b.x,j=j.y-b.y,c=c.y-b.y,e=e.y-b.y):Math.abs(f.y)>Math.abs(f.z)?(a=j.x-b.x,f=c.x-b.x,d=e.x-b.x,j=j.z-b.z,c=c.z-b.z,e=e.z-b.z):(a=j.x-b.x,f=c.x-b.x,d=e.x-b.x,j=j.y-b.y,c=c.y-b.y,e=e.y-b.y);b=f*e-c*d;if(b==0)return Number.MAX_VALUE;b=1/b;e=(a*e-j*d)*b;if(!(e>=0))return Number.MAX_VALUE;b*=f*j-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-e-b>=0))return Number.MAX_VALUE;return g}; +THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var e=THREE.CollisionSystem.__r;e.origin.copy(a.origin);e.direction.copy(a.direction);c.multiplyVector3(e.origin);c.rotateAxis(e.direction);e.direction.normalize();return e}; +THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var e=0,d=0,f=0,g=0,j=0,h=0,k=!0;c.origin.xb.max.x&&(e=b.max.x-c.origin.x,e/=c.direction.x,k=!1,g=1);c.origin.yb.max.y&&(d=b.max.y-c.origin.y,d/=c.direction.y, +k=!1,j=1);c.origin.zb.max.z&&(f=b.max.z-c.origin.z,f/=c.direction.z,k=!1,h=1);if(k)return-1;k=0;d>e&&(k=1,e=d);f>e&&(k=2,e=f);switch(k){case 0:j=c.origin.y+c.direction.y*e;if(jb.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(g,0,0);break;case 1:g=c.origin.x+c.direction.x*e;if(gb.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z* +e;if(cb.max.z)return Number.MAX_VALUE;b.normal.set(0,j,0);break;case 2:g=c.origin.x+c.direction.x*e;if(gb.max.x)return Number.MAX_VALUE;j=c.origin.y+c.direction.y*e;if(jb.max.y)return Number.MAX_VALUE;b.normal.set(0,0,h)}return e};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),e=b.point.dot(b.normal);if(c<0)c=(e-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq=0)return Math.abs(e)-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(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; -THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,d=this.render,e=new THREE.Camera,f=new THREE.Camera,a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},g=new THREE.WebGLRenderTarget(512,512,a),j=new THREE.WebGLRenderTarget(512,512,a),h=new THREE.Camera(53,1,1,1E4);h.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:g},mapRight:{type:"t",value:1,texture:j}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var k=new THREE.Scene;k.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(a,d){c.call(b,a,d);g.width=a;g.height=d;j.width=a;j.height=d};this.render= -function(a,c){e.projectionMatrix=c.projectionMatrix;e.position.copy(c.position);e.target.position.copy(c.target.position);e.translateX(-10);f.projectionMatrix=c.projectionMatrix;f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(10);d.call(b,a,e,g,!0);d.call(b,a,f,j,!0);d.call(b,k,h)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer; -THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,d=this.render,e,f,g=new THREE.Camera,j=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,d){c.call(b,a,d);e=a/2;f=d};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=c.far;g.updateProjectionMatrix(); -g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(b.separation);j.projectionMatrix=g.projectionMatrix;j.position.copy(c.position);j.target.position.copy(c.target.position);j.translateX(-b.separation);this.setViewport(0,0,e,f);d.call(b,a,g);this.setViewport(e,0,e,f);d.call(b,a,j,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,e=this.render,d=new THREE.Camera,f=new THREE.Camera,a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},g=new THREE.WebGLRenderTarget(512,512,a),j=new THREE.WebGLRenderTarget(512,512,a),h=new THREE.Camera(53,1,1,1E4);h.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:g},mapRight:{type:"t",value:1, +texture:j}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});var k= +new THREE.Scene;k.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,d){c.call(b,a,d);g.width=a;g.height=d;j.width=a;j.height=d};this.render=function(a,c){d.projectionMatrix=c.projectionMatrix;d.position.copy(c.position);d.target.position.copy(c.target.position);d.translateX(-10);f.projectionMatrix=c.projectionMatrix;f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(10);e.call(b,a,d,g,!0);e.call(b,a,f,j,!0);e.call(b,k,h)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,e=this.render,d,f,g=new THREE.Camera,j=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,e){c.call(b,a,e);d=a/2;f=e};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=c.far; +g.updateProjectionMatrix();g.position.copy(c.position);g.target.position.copy(c.target.position);g.translateX(b.separation);j.projectionMatrix=g.projectionMatrix;j.position.copy(c.position);j.target.position.copy(c.target.position);j.translateX(-b.separation);this.setViewport(0,0,d,f);e.call(b,a,g);this.setViewport(d,0,d,f);e.call(b,a,j,!1)}}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index 220626f2..b54f4736 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -14,30 +14,30 @@ THREE.Vector4.prototype={set:function(b,d,e,f){this.x=b;this.y=d;this.z=e;this.w b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):this.set(0,0,0,1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())}, setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,d){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;return this}};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,e,f=[];d=0;for(e=b.length;d0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=d(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,i,g,j,p,k,n,v,r,q,z=b.geometry, -C=z.vertices,D=[],f=0;for(h=z.faces.length;f0:v<0))if(n=n.dot((new THREE.Vector3).sub(g,r))/v,r=r.addSelf(q.multiplyScalar(n)), +h=b.clone().subSelf(d),b=f.dot(f),d=f.dot(e),f=f.dot(h),g=e.dot(e),e=e.dot(h),h=1/(b*g-d*d),g=(g*f-d*e)*h,b=(b*e-d*f)*h;return g>0&&b>0&&g+b<1}if(b instanceof THREE.Particle){var f=d(this.origin,this.direction,b);if(!f||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=d(this.origin,this.direction,b);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var h,i,g,j,p,k,n,v,r,q,y=b.geometry, +B=y.vertices,D=[],f=0;for(h=y.faces.length;f0:v<0))if(n=n.dot((new THREE.Vector3).sub(g,r))/v,r=r.addSelf(q.multiplyScalar(n)), i instanceof THREE.Face3)e(r,g,j,p)&&(i={distance:this.origin.distanceTo(r),point:r,face:i,object:b},D.push(i));else if(i instanceof THREE.Face4&&(e(r,g,j,k)||e(r,j,p,k)))i={distance:this.origin.distanceTo(r),point:r,face:i,object:b},D.push(i);return D}else return[]}}; THREE.Rectangle=function(){function b(){i=f-d;g=h-e}var d,e,f,h,i,g,j=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return i};this.getHeight=function(){return g};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(g,i,n,v){j=!1;d=g;e=i;f=n;h=v;b()};this.addPoint=function(g,i){j?(j=!1,d=g,e=i,f=g,h=i):(d=dg?f:g,h=h>i?h:i);b()};this.add3Points= function(g,i,n,v,r,q){j?(j=!1,d=gn?g>r?g:r:n>r?n:r,h=i>v?i>q?i:q:v>q?v:q):(d=gn?g>r?g>f?g:f:r>f?r:f:n>r?n>f?n:f:r>f?r:f,h=i>v?i>q?i>h?i:h:q>h?q:h:v>q?v>h?v:h:q>h?q:h);b()};this.addRectangle=function(g){j?(j=!1,d=g.getLeft(),e=g.getTop(),f=g.getRight(),h=g.getBottom()):(d=dg.getRight()?f:g.getRight(),h=h> g.getBottom()?h:g.getBottom());b()};this.inflate=function(g){d-=g;e-=g;f+=g;h+=g;b()};this.minSelf=function(g){d=d>g.getLeft()?d:g.getLeft();e=e>g.getTop()?e:g.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){j=!0;h=f=e=d=0;b()};this.isEmpty=function(){return j}};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,e,f,h,i,g,j,p,k,n,v,r,q,z,C){this.set(b||1,d||0,e||0,f||0,h||0,i||1,g||0,j||0,p||0,k||0,n||1,v||0,r||0,q||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(b,d,e,f,h,i,g,j,p,k,n,v,r,q,z,C){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=g;this.n24=j;this.n31=p;this.n32=k;this.n33=n;this.n34=v;this.n41=r;this.n42=q;this.n43=z;this.n44=C;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,e){var f=THREE.Matrix4.__v1, +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,e,f,h,i,g,j,p,k,n,v,r,q,y,B){this.set(b||1,d||0,e||0,f||0,h||0,i||1,g||0,j||0,p||0,k||0,n||1,v||0,r||0,q||0,y||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(b,d,e,f,h,i,g,j,p,k,n,v,r,q,y,B){this.n11=b;this.n12=d;this.n13=e;this.n14=f;this.n21=h;this.n22=i;this.n23=g;this.n24=j;this.n31=p;this.n32=k;this.n33=n;this.n34=v;this.n41=r;this.n42=q;this.n43=y;this.n44=B;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(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,e){var f=THREE.Matrix4.__v1, h=THREE.Matrix4.__v2,i=THREE.Matrix4.__v3;i.sub(b,d).normalize();if(i.length()===0)i.z=1;f.cross(e,i).normalize();f.length()===0&&(i.x+=1.0E-4,f.cross(e,i).normalize());h.cross(i,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=i.x;this.n21=f.y;this.n22=h.y;this.n23=i.y;this.n31=f.z;this.n32=h.z;this.n33=i.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,f=b.z,h=1/(this.n41*d+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*f+this.n14)*h;b.y=(this.n21*d+this.n22*e+this.n23* f+this.n24)*h;b.z=(this.n31*d+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var d=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*d+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*d+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*d+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*d+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var d=b.x,e=b.y,f=b.z;b.x=d*this.n11+e*this.n12+f*this.n13;b.y=d*this.n21+e*this.n22+f*this.n23;b.z=d*this.n31+e*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 e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,p=b.n23,k=b.n24,n=b.n31,v=b.n32,r=b.n33,q=b.n34,z=b.n41,C=b.n42,D=b.n43,y=b.n44,S=d.n11,Q=d.n12,L=d.n13,B=d.n14,x=d.n21,R=d.n22, -J=d.n23,aa=d.n24,E=d.n31,$=d.n32,c=d.n33,ja=d.n34;this.n11=e*S+f*x+h*E;this.n12=e*Q+f*R+h*$;this.n13=e*L+f*J+h*c;this.n14=e*B+f*aa+h*ja+i;this.n21=g*S+j*x+p*E;this.n22=g*Q+j*R+p*$;this.n23=g*L+j*J+p*c;this.n24=g*B+j*aa+p*ja+k;this.n31=n*S+v*x+r*E;this.n32=n*Q+v*R+r*$;this.n33=n*L+v*J+r*c;this.n34=n*B+v*aa+r*ja+q;this.n41=z*S+C*x+D*E;this.n42=z*Q+C*R+D*$;this.n43=z*L+C*J+D*c;this.n44=z*B+C*aa+D*ja+y;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31; -e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[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,e=this.n13,f=this.n14,h=this.n21,i=this.n22,g=this.n23,j=this.n24,p=this.n31,k=this.n32,n=this.n33,v=this.n34,r=this.n41,q=this.n42,z=this.n43,C=this.n44;return f*g*k*r-e*j*k*r-f*i*n*r+d*j*n*r+e*i*v*r-d*g*v*r-f*g*p*q+e*j*p*q+f*h*n*q-b*j*n*q-e*h*v*q+b*g*v*q+f*i*p*z-d*j*p*z-f*h*k*z+b*j*k*z+d*h*v*z-b*i*v*z-e*i*p*C+d*g*p*C+e*h*k*C-b*g*k*C-d*h*n*C+b*i*n*C},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,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,0,1);return this},setScale:function(b, -d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,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 e=Math.cos(d),f=Math.sin(d),h=1-e,i=b.x,g=b.y,j=b.z,p=h*i,k=h*g;this.set(p* -i+e,p*g-f*j,p*j+f*g,0,p*g+f*j,k*g+e,k*j-f*i,0,p*j-f*g,k*j+f*i,h*j*j+e,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,e=b.y,f=b.z,b=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),i=Math.cos(f),f=Math.sin(f),g=b*e,j=d*e;this.n11=h*i;this.n12=-h*f;this.n13=e;this.n21=j*i+b*f;this.n22=-j*f+b*i;this.n23=-d*h;this.n31=-g*i+d*f;this.n32=g*f+d*i;this.n33=b*h;return this}, -setRotationFromQuaternion:function(b){var d=b.x,e=b.y,f=b.z,h=b.w,i=d+d,g=e+e,j=f+f,b=d*i,p=d*g;d*=j;var k=e*g;e*=j;f*=j;i*=h;g*=h;h*=j;this.n11=1-(k+f);this.n12=p-h;this.n13=d+g;this.n21=p+h;this.n22=1-(b+f);this.n23=e-i;this.n31=d-g;this.n32=e+i;this.n33=1-(b+k);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14= +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 e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,p=b.n23,k=b.n24,n=b.n31,v=b.n32,r=b.n33,q=b.n34,y=b.n41,B=b.n42,D=b.n43,A=b.n44,O=d.n11,ha=d.n12,T=d.n13,E=d.n14,x=d.n21,ca=d.n22, +M=d.n23,C=d.n24,Q=d.n31,$=d.n32,aa=d.n33,c=d.n34;this.n11=e*O+f*x+h*Q;this.n12=e*ha+f*ca+h*$;this.n13=e*T+f*M+h*aa;this.n14=e*E+f*C+h*c+i;this.n21=g*O+j*x+p*Q;this.n22=g*ha+j*ca+p*$;this.n23=g*T+j*M+p*aa;this.n24=g*E+j*C+p*c+k;this.n31=n*O+v*x+r*Q;this.n32=n*ha+v*ca+r*$;this.n33=n*T+v*M+r*aa;this.n34=n*E+v*C+r*c+q;this.n41=y*O+B*x+D*Q;this.n42=y*ha+B*ca+D*$;this.n43=y*T+B*M+D*aa;this.n44=y*E+B*C+D*c+A;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;e[1]=this.n21;e[2]= +this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[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,e=this.n13,f=this.n14,h=this.n21,i=this.n22,g=this.n23,j=this.n24,p=this.n31,k=this.n32,n=this.n33,v=this.n34,r=this.n41,q=this.n42,y=this.n43,B=this.n44;return f*g*k*r-e*j*k*r-f*i*n*r+d*j*n*r+e*i*v*r-d*g*v*r-f*g*p*q+e*j*p*q+f*h*n*q-b*j*n*q-e*h*v*q+b*g*v*q+f*i*p*y-d*j*p*y-f*h*k*y+b*j*k*y+d*h*v*y-b*i*v*y-e*i*p*B+d*g*p*B+e*h*k*B-b*g*k*B-d*h*n*B+b*i*n*B},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,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,0,1);return this}, +setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,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 e=Math.cos(d),f=Math.sin(d),h=1-e,i=b.x,g=b.y,j= +b.z,p=h*i,k=h*g;this.set(p*i+e,p*g-f*j,p*j+f*g,0,p*g+f*j,k*g+e,k*j-f*i,0,p*j-f*g,k*j+f*i,h*j*j+e,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,e=b.y,f=b.z,b=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),i=Math.cos(f),f=Math.sin(f),g=b*e,j=d*e;this.n11=h*i;this.n12=-h*f;this.n13=e;this.n21=j*i+b*f;this.n22=-j*f+b*i;this.n23=-d*h;this.n31=-g*i+d*f;this.n32=g*f+d*i;this.n33= +b*h;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,f=b.z,h=b.w,i=d+d,g=e+e,j=f+f,b=d*i,p=d*g;d*=j;var k=e*g;e*=j;f*=j;i*=h;g*=h;h*=j;this.n11=1-(k+f);this.n12=p-h;this.n13=d+g;this.n21=p+h;this.n22=1-(b+f);this.n23=e-i;this.n31=d-g;this.n32=e+i;this.n33=1-(b+k);return this},scale:function(b){var d=b.x,e=b.y,b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;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 e=1/d.x,f=1/d.y,h=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23=b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,p=b.n23,k=b.n24,n=b.n31,v=b.n32,r=b.n33,q=b.n34,z=b.n41,C=b.n42,D=b.n43,y=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=p*q*C-k*r*C+k*v*D-j*q*D-p*v*y+j*r*y;d.n12=i*r*C-h*q*C-i*v*D+f*q*D+h*v*y-f*r*y;d.n13=h*k*C-i*p*C+i*j*D-f*k*D-h*j*y+f*p*y;d.n14=i*p*v-h*k*v-i*j*r+f*k*r+h*j*q-f*p*q;d.n21=k*r*z-p*q*z-k*n*D+g*q*D+p*n*y-g*r*y;d.n22=h*q*z-i*r*z+i*n*D-e*q*D-h*n*y+e*r*y;d.n23=i*p*z-h*k*z-i*g*D+e*k*D+h*g*y-e*p*y;d.n24= -h*k*n-i*p*n+i*g*r-e*k*r-h*g*q+e*p*q;d.n31=j*q*z-k*v*z+k*n*C-g*q*C-j*n*y+g*v*y;d.n32=i*v*z-f*q*z-i*n*C+e*q*C+f*n*y-e*v*y;d.n33=h*k*z-i*j*z+i*g*C-e*k*C-f*g*y+e*j*y;d.n34=i*j*n-f*k*n-i*g*v+e*k*v+f*g*q-e*j*q;d.n41=p*v*z-j*r*z-p*n*C+g*r*C+j*n*D-g*v*D;d.n42=f*r*z-h*v*z+h*n*C-e*r*C-f*n*D+e*v*D;d.n43=h*j*z-f*p*z-h*g*C+e*p*C+f*g*D-e*j*D;d.n44=f*p*n-h*j*n+h*g*v-e*p*v-f*g*r+e*j*r;d.multiplyScalar(1/b.determinant());return d}; +THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,f=b.n12,h=b.n13,i=b.n14,g=b.n21,j=b.n22,p=b.n23,k=b.n24,n=b.n31,v=b.n32,r=b.n33,q=b.n34,y=b.n41,B=b.n42,D=b.n43,A=b.n44;d===void 0&&(d=new THREE.Matrix4);d.n11=p*q*B-k*r*B+k*v*D-j*q*D-p*v*A+j*r*A;d.n12=i*r*B-h*q*B-i*v*D+f*q*D+h*v*A-f*r*A;d.n13=h*k*B-i*p*B+i*j*D-f*k*D-h*j*A+f*p*A;d.n14=i*p*v-h*k*v-i*j*r+f*k*r+h*j*q-f*p*q;d.n21=k*r*y-p*q*y-k*n*D+g*q*D+p*n*A-g*r*A;d.n22=h*q*y-i*r*y+i*n*D-e*q*D-h*n*A+e*r*A;d.n23=i*p*y-h*k*y-i*g*D+e*k*D+h*g*A-e*p*A;d.n24= +h*k*n-i*p*n+i*g*r-e*k*r-h*g*q+e*p*q;d.n31=j*q*y-k*v*y+k*n*B-g*q*B-j*n*A+g*v*A;d.n32=i*v*y-f*q*y-i*n*B+e*q*B+f*n*A-e*v*A;d.n33=h*k*y-i*j*y+i*g*B-e*k*B-f*g*A+e*j*A;d.n34=i*j*n-f*k*n-i*g*v+e*k*v+f*g*q-e*j*q;d.n41=p*v*y-j*r*y-p*n*B+g*r*B+j*n*D-g*v*D;d.n42=f*r*y-h*v*y+h*n*B-e*r*B-f*n*D+e*v*D;d.n43=h*j*y-f*p*y-h*g*B+e*p*B+f*g*D-e*j*D;d.n44=f*p*n-h*j*n+h*g*v-e*p*v-f*g*r+e*j*r;d.multiplyScalar(1/b.determinant());return d}; THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,i=b.n32*b.n21-b.n31*b.n22,g=-b.n33*b.n12+b.n32*b.n13,j=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,k=b.n23*b.n12-b.n22*b.n13,n=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*g+b.n31*k;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*i;e[3]=b*g;e[4]=b*j;e[5]=b*p;e[6]=b*k;e[7]=b*n;e[8]=b*v;return d}; THREE.Matrix4.makeFrustum=function(b,d,e,f,h,i){var g;g=new THREE.Matrix4;g.n11=2*h/(d-b);g.n12=0;g.n13=(d+b)/(d-b);g.n14=0;g.n21=0;g.n22=2*h/(f-e);g.n23=(f+e)/(f-e);g.n24=0;g.n31=0;g.n32=0;g.n33=-(i+h)/(i-h);g.n34=-2*i*h/(i-h);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(b,d,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*d,b*d,h,b,e,f)}; THREE.Matrix4.makeOrtho=function(b,d,e,f,h,i){var g,j,p,k;g=new THREE.Matrix4;j=d-b;p=e-f;k=i-h;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((d+b)/j);g.n21=0;g.n22=2/p;g.n23=0;g.n24=-((e+f)/p);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((i+h)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; @@ -59,9 +59,9 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,e;b=0;for(d=this.f e.centroid.addSelf(this.vertices[e.d].position),e.centroid.divideScalar(4))},computeFaceNormals:function(b){var d,e,f,h,i,g,j=new THREE.Vector3,p=new THREE.Vector3;f=0;for(h=this.faces.length;f0){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,e=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=0,d=0,e=this.vertices.length;d1){b=e.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(;fv&&(e=n,n=v,v=e):nq&&(e=r,r=q,q=e):rv&&(e=n,n=v,v=e):nq&&(e=r,r=q,q=e):r=0&&h>=0&&g>=0&&i>=0?!0:f<0&&h<0||g<0&&i<0?!1:(f<0?d=Math.max(d,f/(f-h)):h<0&&(e=Math.min(e,f/(f-h))),g<0?d=Math.max(d,g/(g-i)):i<0&&(e=Math.min(e,g/(g-i))),eL&&g.positionScreen.z0&&B.z<1))fa=Q[S]=Q[S]||new THREE.RenderableParticle,S++,y=fa,y.x=B.x/B.w,y.y=B.y/B.w,y.z=B.z,y.rotation=P.rotation.z,y.scale.x=P.scale.x*Math.abs(y.x- -(B.x+c.projectionMatrix.n11)/(B.w+c.projectionMatrix.n14)),y.scale.y=P.scale.y*Math.abs(y.y-(B.y+c.projectionMatrix.n22)/(B.w+c.projectionMatrix.n24)),y.materials=P.materials,i.push(y);h&&i.sort(d);return i}}; +THREE.Projector=function(){function b(){var b=p[j]=p[j]||new THREE.RenderableVertex;j++;return b}function d(b,d){return d.z-b.z}function e(b,d){var c=0,e=1,f=b.z+b.w,h=d.z+d.w,g=-b.z+b.w,i=-d.z+d.w;return f>=0&&h>=0&&g>=0&&i>=0?!0:f<0&&h<0||g<0&&i<0?!1:(f<0?c=Math.max(c,f/(f-h)):h<0&&(e=Math.min(e,f/(f-h))),g<0?c=Math.max(c,g/(g-i)):i<0&&(e=Math.min(e,g/(g-i))),eT&&g.positionScreen.z0&&E.z<1))ja=ha[O]=ha[O]||new THREE.RenderableParticle,O++,A=ja,A.x=E.x/E.w,A.y=E.y/E.w,A.z=E.z,A.rotation=F.rotation.z,A.scale.x=F.scale.x*Math.abs(A.x-(E.x+h.projectionMatrix.n11)/ +(E.w+h.projectionMatrix.n14)),A.scale.y=F.scale.y*Math.abs(A.y-(E.y+h.projectionMatrix.n22)/(E.w+h.projectionMatrix.n24)),A.materials=F.materials,i.push(A);c&&i.sort(d);return i}}; THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,e){e&&b.update(void 0,!1,d);var e=b.sounds,f,h=e.length;for(f=0;f=0)c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else{d=h.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[i.morphTargetBase]), +THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)j.diffuse.value=f.color,j.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)j.psColor.value=f.color,j.opacity.value=f.opacity,j.size.value=f.size,j.scale.value=na.height/2,j.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)j.ambient.value=f.ambient,j.specular.value=f.specular,j.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)j.mNear.value=b.near,j.mFar.value=b.far,j.opacity.value= +f.opacity;else if(f instanceof THREE.MeshNormalMaterial)j.opacity.value=f.opacity;for(var z in j)if(G=g.uniforms[z])if(k=j[z],o=k.type,e=k.value,o=="i")c.uniform1i(G,e);else if(o=="f")c.uniform1f(G,e);else if(o=="fv1")c.uniform1fv(G,e);else if(o=="fv")c.uniform3fv(G,e);else if(o=="v2")c.uniform2f(G,e.x,e.y);else if(o=="v3")c.uniform3f(G,e.x,e.y,e.z);else if(o=="v4")c.uniform4f(G,e.x,e.y,e.z,e.w);else if(o=="c")c.uniform3f(G,e.r,e.g,e.b);else if(o=="t"&&(c.uniform1i(G,e),k=k.texture))if(k.image instanceof +Array&&k.image.length==6){if(k.image.length==6){if(k.needsUpdate){if(k.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(o=0;o<6;++o)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,0,0,c.RGBA,c.UNSIGNED_BYTE,k.image[o])}else{k.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube);for(o=0;o<6;++o)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,k.image[o]);k.__webglInit=!0}x(c.TEXTURE_CUBE_MAP, +k,k.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);k.needsUpdate=!1}c.activeTexture(c.TEXTURE0+e);c.bindTexture(c.TEXTURE_CUBE_MAP,k.image.__webglTextureCube)}}else ca(k,e);c.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray);c.uniformMatrix3fv(i.normalMatrix,!1,h._normalMatrixArray);(f instanceof THREE.MeshShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&i.cameraPosition!==null&&c.uniform3f(i.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.MeshShaderMaterial|| +f.envMap||f.skinning)&&i.objectMatrix!==null&&c.uniformMatrix4fv(i.objectMatrix,!1,h._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshShaderMaterial||f.skinning)&&i.viewMatrix!==null&&c.uniformMatrix4fv(i.viewMatrix,!1,ra);if(f instanceof THREE.ShadowVolumeDynamicMaterial)b=j.directionalLightDirection.value,b[0]=-d[1].position.x,b[1]=-d[1].position.y,b[2]=-d[1].position.z,c.uniform3fv(i.directionalLightDirection,b),c.uniformMatrix4fv(i.objectMatrix, +!1,h._objectMatrixArray),c.uniformMatrix4fv(i.viewMatrix,!1,ra);f.skinning&&(c.uniformMatrix4fv(i.cameraInverseMatrix,!1,ra),c.uniformMatrix4fv(i.boneGlobalMatrices,!1,h.boneMatrices));return g}function f(b,d,f,h,g,i){if(h.opacity!=0){var j,b=e(b,d,f,h,i).attributes;if(!h.morphTargets&&b.position>=0)c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(b.position,3,c.FLOAT,!1,0,0);else{d=h.program.attributes;i.morphTargetBase!==-1?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[i.morphTargetBase]), c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0)):d.position>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglVertexBuffer),c.vertexAttribPointer(d.position,3,c.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length)for(var f=0,k=i.morphTargetForcedOrder,p=i.morphTargetInfluences;fn&&(o=G,n=p[o]);c.bindBuffer(c.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[o]);c.vertexAttribPointer(d["morphTarget"+f],3,c.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[f]=n;k[o]=1;n=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&c.uniform1fv(h.program.uniforms.morphTargetInfluences,i.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(j in g.__webglCustomAttributes)b[j]>= 0&&(d=g.__webglCustomAttributes[j],c.bindBuffer(c.ARRAY_BUFFER,d.buffer),c.vertexAttribPointer(b[j],d.size,c.FLOAT,!1,0,0));b.color>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer),c.vertexAttribPointer(b.color,3,c.FLOAT,!1,0,0));b.normal>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.vertexAttribPointer(b.normal,3,c.FLOAT,!1,0,0));b.tangent>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.vertexAttribPointer(b.tangent,4,c.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(c.bindBuffer(c.ARRAY_BUFFER, g.__webglUVBuffer),c.vertexAttribPointer(b.uv,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv)):c.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.vertexAttribPointer(b.uv2,2,c.FLOAT,!1,0,0),c.enableVertexAttribArray(b.uv2)):c.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.vertexAttribPointer(b.skinVertexA,4, c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.vertexAttribPointer(b.skinVertexB,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.vertexAttribPointer(b.skinIndex,4,c.FLOAT,!1,0,0),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.vertexAttribPointer(b.skinWeight,4,c.FLOAT,!1,0,0));i instanceof THREE.Mesh?(h.wireframe?(c.lineWidth(h.wireframeLinewidth),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.drawElements(c.LINES,g.__webglLineCount, -c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.drawElements(c.TRIANGLES,g.__webglFaceCount,c.UNSIGNED_SHORT,0)),$.data.vertices+=g.__webglFaceCount,$.data.faces+=g.__webglFaceCount/3,$.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(h.linewidth),c.drawArrays(i,0,g.__webglLineCount),$.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,g.__webglParticleCount),$.data.drawCalls++):i instanceof -THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,g.__webglVertexCount),$.data.drawCalls++)}}function h(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER, +c.UNSIGNED_SHORT,0)):(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.drawElements(c.TRIANGLES,g.__webglFaceCount,c.UNSIGNED_SHORT,0)),aa.data.vertices+=g.__webglFaceCount,aa.data.faces+=g.__webglFaceCount/3,aa.data.drawCalls++):i instanceof THREE.Line?(i=i.type==THREE.LineStrip?c.LINE_STRIP:c.LINES,c.lineWidth(h.linewidth),c.drawArrays(i,0,g.__webglLineCount),aa.data.drawCalls++):i instanceof THREE.ParticleSystem?(c.drawArrays(c.POINTS,0,g.__webglParticleCount),aa.data.drawCalls++):i instanceof +THREE.Ribbon&&(c.drawArrays(c.TRIANGLE_STRIP,0,g.__webglVertexCount),aa.data.drawCalls++)}}function h(b,d,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=c.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=c.createBuffer();b.hasPos&&(c.bindBuffer(c.ARRAY_BUFFER,b.__webglVertexBuffer),c.bufferData(c.ARRAY_BUFFER,b.positionArray,c.DYNAMIC_DRAW),c.enableVertexAttribArray(d.attributes.position),c.vertexAttribPointer(d.attributes.position,3,c.FLOAT,!1,0,0));if(b.hasNormal){c.bindBuffer(c.ARRAY_BUFFER, b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,i,j,k,p,o,G,n,r=b.count*3;for(n=0;n0&&z[0]0&&z[1]0.0010&&j.scale>0.0010)q[0]=j.x,q[1]=j.y,q[2]=j.z,r=j.size*j.scale/H,v[0]=r*p,v[1]=r,c.uniform3fv(y.screenPosition,q),c.uniform2fv(y.scale,v),c.uniform1f(y.rotation,j.rotation),c.uniform1f(y.opacity,j.opacity),L(j.blending),x(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ra)}function D(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} -function y(b){var e,f,g,h,i;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){g=f.geometryGroups[e];i=!1;for(h in g.__webglCustomAttributes)if(g.__webglCustomAttributes[h].needsUpdate){i=!0;break}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||i){i=b;var j=c.DYNAMIC_DRAW;if(g.__inittedArrays){var k=void 0,p=void 0,n=void 0,o=void 0,G=n=void 0,r=void 0,v=void 0,q=void 0,t=void 0,z=void 0,y=void 0, -x=void 0,C=void 0,u=void 0,I=void 0,K=void 0,D=void 0,s=o=q=o=v=r=void 0,A=void 0,m=A=s=r=void 0,F=void 0,J=m=A=s=n=n=G=q=o=m=A=s=F=m=A=s=F=m=A=s=void 0,B=0,E=0,O=0,P=0,H=0,M=0,T=0,N=0,ca=0,w=0,da=0,A=s=0,L=g.__vertexArray,Z=g.__uvArray,$=g.__uv2Array,Q=g.__normalArray,U=g.__tangentArray,ea=g.__colorArray,V=g.__skinVertexAArray,W=g.__skinVertexBArray,X=g.__skinIndexArray,Y=g.__skinWeightArray,aa=g.__morphTargetsArrays,R=g.__webglCustomAttributes,m=void 0,ma=g.__faceArray,S=g.__lineArray,ja=g.__needsSmoothNormals, -z=g.__vertexColorType,t=g.__uvType,y=g.__normalType,ga=i.geometry,ha=ga.__dirtyVertices,ia=ga.__dirtyElements,fa=ga.__dirtyUvs,ka=ga.__dirtyNormals,na=ga.__dirtyTangents,oa=ga.__dirtyColors,pa=ga.__dirtyMorphTargets,la=ga.vertices,qa=g.faces,ra=ga.faces,sa=ga.faceVertexUvs[0],ta=ga.faceVertexUvs[1],ya=ga.skinVerticesA,za=ga.skinVerticesB,Aa=ga.skinIndices,wa=ga.skinWeights,xa=i instanceof THREE.ShadowVolume?ga.edgeFaces:void 0,ua=ga.morphTargets;if(R)for(J in R)R[J].offset=0,R[J].offsetSrc=0;k=0; -for(p=qa.length;k0&&x[0]0&&x[1]0.0010&&j.scale>0.0010)q[0]=j.x,q[1]=j.y,q[2]=j.z,r=j.size*j.scale/N,v[0]=r*p,v[1]=r,c.uniform3fv(y.screenPosition,q),c.uniform2fv(y.scale,v),c.uniform1f(y.rotation,j.rotation),c.uniform1f(y.opacity,j.opacity),E(j.blending),ca(j.texture,1),c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(ia)}function D(b,c){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} +function A(b){var e,f,g,h,i;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){g=f.geometryGroups[e];i=!1;for(h in g.__webglCustomAttributes)if(g.__webglCustomAttributes[h].needsUpdate){i=!0;break}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||i){i=b;var j=c.DYNAMIC_DRAW;if(g.__inittedArrays){var k=void 0,p=void 0,n=void 0,o=void 0,G=n=void 0,r=void 0,v=void 0,q=void 0,t=void 0,x=void 0,y=void 0, +A=void 0,B=void 0,u=void 0,I=void 0,K=void 0,D=void 0,s=o=q=o=v=r=void 0,z=void 0,m=z=s=r=void 0,F=void 0,J=m=z=s=n=n=G=q=o=m=z=s=F=m=z=s=F=m=z=s=void 0,E=0,C=0,S=0,T=0,M=0,L=0,U=0,N=0,da=0,w=0,ea=0,z=s=0,H=g.__vertexArray,$=g.__uvArray,aa=g.__uv2Array,P=g.__normalArray,V=g.__tangentArray,fa=g.__colorArray,W=g.__skinVertexAArray,X=g.__skinVertexBArray,Y=g.__skinIndexArray,Z=g.__skinWeightArray,ca=g.__morphTargetsArrays,Q=g.__webglCustomAttributes,m=void 0,O=g.__faceArray,R=g.__lineArray,ha=g.__needsSmoothNormals, +x=g.__vertexColorType,t=g.__uvType,y=g.__normalType,ga=i.geometry,ja=ga.__dirtyVertices,ka=ga.__dirtyElements,ia=ga.__dirtyUvs,ma=ga.__dirtyNormals,na=ga.__dirtyTangents,oa=ga.__dirtyColors,pa=ga.__dirtyMorphTargets,la=ga.vertices,qa=g.faces,sa=ga.faces,ra=ga.faceVertexUvs[0],ta=ga.faceVertexUvs[1],ya=ga.skinVerticesA,za=ga.skinVerticesB,Aa=ga.skinIndices,wa=ga.skinWeights,xa=i instanceof THREE.ShadowVolume?ga.edgeFaces:void 0,ua=ga.morphTargets;if(Q)for(J in Q)Q[J].offset=0,Q[J].offsetSrc=0;k=0; +for(p=qa.length;k0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer), -c.bufferData(c.ARRAY_BUFFER,ea,j));ka&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,Q,j));na&&ga.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,U,j));fa&&O>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));fa&&P>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,$,j));ia&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER, -ma,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,S,j));w>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,V,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j));i.dynamic||(delete g.__inittedArrays, +10]=D.y,m.array[s+11]=D.z),m.offset+=12):(m.array[s+0]=u.x,m.array[s+1]=u.y,m.array[s+2]=u.z,m.array[s+3]=u.w,m.array[s+4]=I.x,m.array[s+5]=I.y,m.array[s+6]=I.z,m.array[s+7]=I.w,m.array[s+8]=K.x,m.array[s+9]=K.y,m.array[s+10]=K.z,m.array[s+11]=K.w,m.array[s+12]=D.x,m.array[s+13]=D.y,m.array[s+14]=D.z,m.array[s+15]=D.w,m.offset+=16));if(pa){s=0;for(z=ua.length;s0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglColorBuffer), +c.bufferData(c.ARRAY_BUFFER,fa,j));ma&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglNormalBuffer),c.bufferData(c.ARRAY_BUFFER,P,j));na&&ga.hasTangents&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglTangentBuffer),c.bufferData(c.ARRAY_BUFFER,V,j));ia&&S>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUVBuffer),c.bufferData(c.ARRAY_BUFFER,$,j));ia&&T>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglUV2Buffer),c.bufferData(c.ARRAY_BUFFER,aa,j));ka&&(c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER, +O,j),c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),c.bufferData(c.ELEMENT_ARRAY_BUFFER,R,j));w>0&&(c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexABuffer),c.bufferData(c.ARRAY_BUFFER,W,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),c.bufferData(c.ARRAY_BUFFER,X,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),c.bufferData(c.ARRAY_BUFFER,Y,j),c.bindBuffer(c.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),c.bufferData(c.ARRAY_BUFFER,Z,j));i.dynamic||(delete g.__inittedArrays, delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array,delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b= -f;e=c.DYNAMIC_DRAW;t=b.vertices;g=b.colors;z=t.length;i=g.length;y=b.__vertexArray;j=b.__colorArray;x=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k65535&&(o[j].counter+=1,k=o[j].hash+"_"+o[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:p})),b.geometryGroups[k].faces.push(f),b.geometryGroups[k].vertices+=h}function Q(b,c,d){b.push({buffer:c,object:d, -opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(b){if(b!=M){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}M= -b}}function B(b,d,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,E(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,E(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,E(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,E(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_MAG_FILTER,aa(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,aa(d.minFilter)))} -function x(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=c.deleteTexture(b.__webglTexture);b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);B(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function R(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer=== -void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,E(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,E(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,E(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,E(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,E(b.format),b.width,b.height,0, -E(b.format),E(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER, -c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=O,b=H);d!=Ba&&(c.bindFramebuffer(c.FRAMEBUFFER,d),c.viewport(F,Z,e,b),Ba=d)}function J(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER): -b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function aa(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function E(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT; -case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT; -case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var $=this,c,ja=[],oa=null,Ba=null,ra=!0,pa=null,ka=null,M=null,ha=null,F=0,Z=0,O=0,H=0,N=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4],P=new THREE.Matrix4,fa=new Float32Array(16),la=new Float32Array(16),qa=new THREE.Vector4,Ca={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ia=b.canvas!==void 0?b.canvas:document.createElement("canvas"),sa=b.stencil!==void 0?b.stencil:!0,ta=b.antialias!==void 0?b.antialias:!1,na=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Da=b.clearAlpha!==void 0?b.clearAlpha: -0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ia;this.sortObjects=this.autoClear=!0;try{if(!(c=ia.getContext("experimental-webgl",{antialias:ta,stencil:sa})))throw"Error creating WebGL context.";}catch(Ha){console.error(Ha)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST); -c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(na.r,na.g,na.b,Da);this.context=c;var Ga=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(sa){var u={};u.vertices=new Float32Array(12);u.faces=new Uint16Array(6);u.darkness=0.5;u.vertices[0]=-20;u.vertices[1]=-20;u.vertices[2]=-1;u.vertices[3]=20;u.vertices[4]=-20;u.vertices[5]=-1;u.vertices[6]=20;u.vertices[7]= -20;u.vertices[8]=-1;u.vertices[9]=-20;u.vertices[10]=20;u.vertices[11]=-1;u.faces[0]=0;u.faces[1]=1;u.faces[2]=2;u.faces[3]=0;u.faces[4]=2;u.faces[5]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,u.faces,c.STATIC_DRAW);u.program=c.createProgram();c.attachShader(u.program,J("fragment",THREE.ShaderLib.shadowPost.fragmentShader)); -c.attachShader(u.program,J("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(u.program);u.vertexLocation=c.getAttribLocation(u.program,"position");u.projectionLocation=c.getUniformLocation(u.program,"projectionMatrix");u.darknessLocation=c.getUniformLocation(u.program,"darkness")}var t={};t.vertices=new Float32Array(16);t.faces=new Uint16Array(6);b=0;t.vertices[b++]=-1;t.vertices[b++]=-1;t.vertices[b++]=0;t.vertices[b++]=0;t.vertices[b++]=1;t.vertices[b++]=-1;t.vertices[b++]=1;t.vertices[b++]= -0;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=-1;t.vertices[b++]=1;t.vertices[b++]=0;t.vertices[b++]=1;b=0;t.faces[b++]=0;t.faces[b++]=1;t.faces[b++]=2;t.faces[b++]=0;t.faces[b++]=2;t.faces[b++]=3;t.vertexBuffer=c.createBuffer();t.elementBuffer=c.createBuffer();t.tempTexture=c.createTexture();t.occlusionTexture=c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,t.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,t.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -t.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,t.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,t.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,t.occlusionTexture);c.texImage2D(c.TEXTURE_2D, -0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(t.hasVertexTexture=!1,t.program=c.createProgram(),c.attachShader(t.program,J("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(t.program, -J("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(t.hasVertexTexture=!0,t.program=c.createProgram(),c.attachShader(t.program,J("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(t.program,J("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.vertex=c.getAttribLocation(t.program,"position");t.attributes.uv=c.getAttribLocation(t.program,"UV");t.uniforms.renderType=c.getUniformLocation(t.program, -"renderType");t.uniforms.map=c.getUniformLocation(t.program,"map");t.uniforms.occlusionMap=c.getUniformLocation(t.program,"occlusionMap");t.uniforms.opacity=c.getUniformLocation(t.program,"opacity");t.uniforms.scale=c.getUniformLocation(t.program,"scale");t.uniforms.rotation=c.getUniformLocation(t.program,"rotation");t.uniforms.screenPosition=c.getUniformLocation(t.program,"screenPosition");var Fa=!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= -c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program,J("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,J("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program); -_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation=c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment= -c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix= -c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var Ea=!1;this.setSize=function(b,c){ia.width=b;ia.height=c;this.setViewport(0,0,ia.width,ia.height)};this.setViewport=function(b,d,e,f){F=b;Z=d;O=e;H=f;c.viewport(F,Z,O,H)};this.setScissor=function(b,d,e,f){c.scissor(b,d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){ra= -b;c.depthMask(b)};this.setClearColorHex=function(b,d){na.setHex(b);Da=d;c.clearColor(na.r,na.g,na.b,Da)};this.setClearColor=function(b,d){na.copy(b);Da=d;c.clearColor(na.r,na.g,na.b,Da)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){u.darkness=b};this.getContext=function(){return c};this.initMaterial=function(b,d,e,f){var g,h,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial? -i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms=THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,p,o;k=o=j=0;for(p=d.length;k< -p;k++)h=d[k],h instanceof THREE.DirectionalLight&&o++,h instanceof THREE.PointLight&&j++;j+o<=4?d=o:(d=Math.ceil(4*o/(j+o)),j=4-d);h={directional:d,point:j};o=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)o=f.bones.length;var n;a:{k=b.fragmentShader;p=b.vertexShader;var j=b.uniforms,d=b.attributes,e={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:e,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets, -maxDirLights:h.directional,maxPointLights:h.point,maxBones:o},q;h=[];i?h.push(i):(h.push(k),h.push(p));for(q in e)h.push(q),h.push(e[q]);i=h.join();q=0;for(h=ja.length;q=0&&c.enableVertexAttribArray(n.position);n.color>=0&&c.enableVertexAttribArray(n.color);n.normal>= +f;e=c.DYNAMIC_DRAW;t=b.vertices;g=b.colors;x=t.length;i=g.length;y=b.__vertexArray;j=b.__colorArray;A=b.__dirtyColors;if(b.__dirtyVertices){for(k=0;k=0;d--)b[d].object==c&&b.splice(d,1)}function ha(b){function c(b){var f=[];d=0;for(e=b.length;d65535&&(o[j].counter+=1,k=o[j].hash+"_"+o[j].counter,b.geometryGroups[k]==void 0&&(b.geometryGroups[k]={faces:[],materials:i,vertices:0,numMorphTargets:p})),b.geometryGroups[k].faces.push(f), +b.geometryGroups[k].vertices+=h}function T(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function E(b){if(b!=R){switch(b){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD, +c.FUNC_ADD),c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}R=b}}function x(b,d,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(c.texParameteri(b,c.TEXTURE_WRAP_S,$(d.wrapS)),c.texParameteri(b,c.TEXTURE_WRAP_T,$(d.wrapT)),c.texParameteri(b,c.TEXTURE_MAG_FILTER,$(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,$(d.minFilter)),c.generateMipmap(b)):(c.texParameteri(b,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(b,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texParameteri(b, +c.TEXTURE_MAG_FILTER,Q(d.magFilter)),c.texParameteri(b,c.TEXTURE_MIN_FILTER,Q(d.minFilter)))}function ca(b,d){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=c.deleteTexture(b.__webglTexture);b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,b.image);x(c.TEXTURE_2D,b,b.image);c.bindTexture(c.TEXTURE_2D,null);b.needsUpdate=!1}c.activeTexture(c.TEXTURE0+d);c.bindTexture(c.TEXTURE_2D,b.__webglTexture)}function M(b){if(b&& +!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=c.createFramebuffer();b.__webglRenderbuffer=c.createRenderbuffer();b.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,b.__webglTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,$(b.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,$(b.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,$(b.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER, +$(b.minFilter));c.texImage2D(c.TEXTURE_2D,0,$(b.format),b.width,b.height,0,$(b.format),$(b.type),null);c.bindRenderbuffer(c.RENDERBUFFER,b.__webglRenderbuffer);c.bindFramebuffer(c.FRAMEBUFFER,b.__webglFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)): +b.depthBuffer&&b.stencilBuffer?(c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_STENCIL,b.width,b.height),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_STENCIL_ATTACHMENT,c.RENDERBUFFER,b.__webglRenderbuffer)):c.renderbufferStorage(c.RENDERBUFFER,c.RGBA4,b.width,b.height);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var d,e;b?(d=b.__webglFramebuffer,e=b.width,b=b.height):(d=null,e=L,b=N);d!=Ba&&(c.bindFramebuffer(c.FRAMEBUFFER,d),c.viewport(H, +S,e,b),Ba=d)}function C(b,d){var e;b=="fragment"?e=c.createShader(c.FRAGMENT_SHADER):b=="vertex"&&(e=c.createShader(c.VERTEX_SHADER));c.shaderSource(e,d);c.compileShader(e);if(!c.getShaderParameter(e,c.COMPILE_STATUS))return console.error(c.getShaderInfoLog(e)),console.error(d),null;return e}function Q(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function $(b){switch(b){case THREE.RepeatWrapping:return c.REPEAT; +case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE; +case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var aa=this,c,ta=[],ma= +null,Ba=null,ia=!0,ka=null,P=null,R=null,J=null,H=0,S=0,L=0,N=0,F=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,la=new Float32Array(16),ra=new Float32Array(16),qa=new THREE.Vector4,pa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},na=b.canvas!==void 0?b.canvas:document.createElement("canvas"),sa=b.stencil!==void 0?b.stencil:!0,Ga=b.antialias!== +void 0?b.antialias:!1,oa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ca=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=na;this.sortObjects=this.autoClear=!0;try{if(!(c=na.getContext("experimental-webgl",{antialias:Ga,stencil:sa})))throw"Error creating WebGL context.";}catch(Ha){console.error(Ha)}console.log(navigator.userAgent+" | "+c.getParameter(c.VERSION)+" | "+c.getParameter(c.VENDOR)+" | "+c.getParameter(c.RENDERER)+ +" | "+c.getParameter(c.SHADING_LANGUAGE_VERSION));c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(oa.r,oa.g,oa.b,Ca);this.context=c;var Fa=c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(sa){var u={};u.vertices=new Float32Array(12);u.faces=new Uint16Array(6);u.darkness=0.5;u.vertices[0]=-20;u.vertices[1]= +-20;u.vertices[2]=-1;u.vertices[3]=20;u.vertices[4]=-20;u.vertices[5]=-1;u.vertices[6]=20;u.vertices[7]=20;u.vertices[8]=-1;u.vertices[9]=-20;u.vertices[10]=20;u.vertices[11]=-1;u.faces[0]=0;u.faces[1]=1;u.faces[2]=2;u.faces[3]=0;u.faces[4]=2;u.faces[5]=3;u.vertexBuffer=c.createBuffer();u.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,u.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,u.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,u.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER, +u.faces,c.STATIC_DRAW);u.program=c.createProgram();c.attachShader(u.program,C("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(u.program,C("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(u.program);u.vertexLocation=c.getAttribLocation(u.program,"position");u.projectionLocation=c.getUniformLocation(u.program,"projectionMatrix");u.darknessLocation=c.getUniformLocation(u.program,"darkness")}var t={};t.vertices=new Float32Array(16);t.faces=new Uint16Array(6);b=0; +t.vertices[b++]=-1;t.vertices[b++]=-1;t.vertices[b++]=0;t.vertices[b++]=0;t.vertices[b++]=1;t.vertices[b++]=-1;t.vertices[b++]=1;t.vertices[b++]=0;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=1;t.vertices[b++]=-1;t.vertices[b++]=1;t.vertices[b++]=0;t.vertices[b++]=1;b=0;t.faces[b++]=0;t.faces[b++]=1;t.faces[b++]=2;t.faces[b++]=0;t.faces[b++]=2;t.faces[b++]=3;t.vertexBuffer=c.createBuffer();t.elementBuffer=c.createBuffer();t.tempTexture=c.createTexture();t.occlusionTexture= +c.createTexture();c.bindBuffer(c.ARRAY_BUFFER,t.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,t.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,t.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,t.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,t.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER, +c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.bindTexture(c.TEXTURE_2D,t.occlusionTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,16,16,0,c.RGBA,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(t.hasVertexTexture= +!1,t.program=c.createProgram(),c.attachShader(t.program,C("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),c.attachShader(t.program,C("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(t.hasVertexTexture=!0,t.program=c.createProgram(),c.attachShader(t.program,C("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),c.attachShader(t.program,C("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));c.linkProgram(t.program);t.attributes={};t.uniforms={};t.attributes.vertex= +c.getAttribLocation(t.program,"position");t.attributes.uv=c.getAttribLocation(t.program,"UV");t.uniforms.renderType=c.getUniformLocation(t.program,"renderType");t.uniforms.map=c.getUniformLocation(t.program,"map");t.uniforms.occlusionMap=c.getUniformLocation(t.program,"occlusionMap");t.uniforms.opacity=c.getUniformLocation(t.program,"opacity");t.uniforms.scale=c.getUniformLocation(t.program,"scale");t.uniforms.rotation=c.getUniformLocation(t.program,"rotation");t.uniforms.screenPosition=c.getUniformLocation(t.program, +"screenPosition");var Ea=!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=c.createBuffer();_sprite.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,_sprite.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,_sprite.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,_sprite.faces,c.STATIC_DRAW);_sprite.program=c.createProgram();c.attachShader(_sprite.program, +C("fragment",THREE.ShaderLib.sprite.fragmentShader));c.attachShader(_sprite.program,C("vertex",THREE.ShaderLib.sprite.vertexShader));c.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=c.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=c.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=c.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=c.getUniformLocation(_sprite.program,"uvScale");_sprite.uniforms.rotation= +c.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=c.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=c.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=c.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=c.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=c.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance=c.getUniformLocation(_sprite.program, +"affectedByDistance");_sprite.uniforms.screenPosition=c.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=c.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=c.getUniformLocation(_sprite.program,"projectionMatrix");var Da=!1;this.setSize=function(b,c){na.width=b;na.height=c;this.setViewport(0,0,na.width,na.height)};this.setViewport=function(b,d,e,f){H=b;S=d;L=e;N=f;c.viewport(H,S,L,N)};this.setScissor=function(b,d,e,f){c.scissor(b, +d,e,f)};this.enableScissorTest=function(b){b?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){ia=b;c.depthMask(b)};this.setClearColorHex=function(b,d){oa.setHex(b);Ca=d;c.clearColor(oa.r,oa.g,oa.b,Ca)};this.setClearColor=function(b,d){oa.copy(b);Ca=d;c.clearColor(oa.r,oa.g,oa.b,Ca)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){u.darkness=b};this.getContext=function(){return c}; +this.initMaterial=function(b,d,e,f){var g,h,i;b instanceof THREE.MeshDepthMaterial?i="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?i="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?i="normal":b instanceof THREE.MeshBasicMaterial?i="basic":b instanceof THREE.MeshLambertMaterial?i="lambert":b instanceof THREE.MeshPhongMaterial?i="phong":b instanceof THREE.LineBasicMaterial?i="basic":b instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var j=THREE.ShaderLib[i];b.uniforms= +THREE.UniformsUtils.clone(j.uniforms);b.vertexShader=j.vertexShader;b.fragmentShader=j.fragmentShader}var k,p,o;k=o=j=0;for(p=d.length;k=0&&c.enableVertexAttribArray(n.position);n.color>=0&&c.enableVertexAttribArray(n.color);n.normal>= 0&&c.enableVertexAttribArray(n.normal);n.tangent>=0&&c.enableVertexAttribArray(n.tangent);b.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(c.enableVertexAttribArray(n.skinVertexA),c.enableVertexAttribArray(n.skinVertexB),c.enableVertexAttribArray(n.skinIndex),c.enableVertexAttribArray(n.skinWeight));if(b.attributes)for(g in b.attributes)n[g]!==void 0&&n[g]>=0&&c.enableVertexAttribArray(n[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;n.morphTarget0>=0&&(c.enableVertexAttribArray(n.morphTarget0), b.numSupportedMorphTargets++);n.morphTarget1>=0&&(c.enableVertexAttribArray(n.morphTarget1),b.numSupportedMorphTargets++);n.morphTarget2>=0&&(c.enableVertexAttribArray(n.morphTarget2),b.numSupportedMorphTargets++);n.morphTarget3>=0&&(c.enableVertexAttribArray(n.morphTarget3),b.numSupportedMorphTargets++);n.morphTarget4>=0&&(c.enableVertexAttribArray(n.morphTarget4),b.numSupportedMorphTargets++);n.morphTarget5>=0&&(c.enableVertexAttribArray(n.morphTarget5),b.numSupportedMorphTargets++);n.morphTarget6>= -0&&(c.enableVertexAttribArray(n.morphTarget6),b.numSupportedMorphTargets++);n.morphTarget7>=0&&(c.enableVertexAttribArray(n.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b0||q.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(q.faceUvs.length>1||q.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray= -new Float32Array(k*4);i.__faceArray=new Uint16Array(t*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(v*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];q=0;for(r=i.numMorphTargets;q=0;g--){if(f=e.__webglObjects[g].object,d==f){e.__webglObjects.splice(g,1);break}}else if(d instanceof THREE.Sprite)for(g=e.__webglSprites.length-1;g>=0;g--)if(f=e.__webglSprites[g],d==f){e.__webglSprites.splice(g,1);break}b.__objectsRemoved.splice(0,1)}d=0;for(e=b.__webglObjects.length;d=0&&(c.enableVertexAttribArray(n.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b0||q.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(q.faceUvs.length>1||q.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(j.geometry.skinWeights.length&&j.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4), +i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(t*3+(j.geometry.edgeFaces?j.geometry.edgeFaces.length*6:0));i.__lineArray=new Uint16Array(v*2);if(i.numMorphTargets){i.__morphTargetsArrays=[];q=0;for(r=i.numMorphTargets;q - - + + @@ -50,12 +50,11 @@ + - - @@ -65,6 +64,8 @@ + + @@ -74,6 +75,7 @@ + @@ -81,24 +83,37 @@ + + + - - - - - - - - + + + + + + + + + + + + + + + + + + @@ -171,7 +186,7 @@ objects = []; - geometry = new THREE.Sphere( 100, 16, 8 ); + geometry = new THREE.SphereGeometry( 100, 16, 8 ); material = new THREE.MeshBasicMaterial( { envMap: THREE.ImageUtils.loadTexture( 'textures/metal.jpg', new THREE.SphericalReflectionMapping() ) } ); for ( var i = 0; i < 10; i ++ ) { diff --git a/examples/misc_camera_path.html b/examples/misc_camera_path.html index 41808bf9..d9eef97f 100644 --- a/examples/misc_camera_path.html +++ b/examples/misc_camera_path.html @@ -84,7 +84,7 @@ // world - var cube = new THREE.Cube( 20, 60, 20 ); + var cube = new THREE.CubeGeometry( 20, 60, 20 ); cube.vertices[ 0 ].position.multiplyScalar( 0.01 ); cube.vertices[ 1 ].position.multiplyScalar( 0.01 ); diff --git a/examples/misc_camera_roll.html b/examples/misc_camera_roll.html index d674fe23..1fb05577 100644 --- a/examples/misc_camera_roll.html +++ b/examples/misc_camera_roll.html @@ -67,7 +67,7 @@ // world - var cube = new THREE.Cube( 20, 60, 20 ); + var cube = new THREE.CubeGeometry( 20, 60, 20 ); cube.vertices[ 0 ].position.multiplyScalar( 0.01 ); cube.vertices[ 1 ].position.multiplyScalar( 0.01 ); diff --git a/examples/misc_camera_trackball.html b/examples/misc_camera_trackball.html index 370f5f7c..3eb58fa5 100644 --- a/examples/misc_camera_trackball.html +++ b/examples/misc_camera_trackball.html @@ -84,7 +84,7 @@ // world - var cube = new THREE.Cube( 20, 60, 20 ); + var cube = new THREE.CubeGeometry( 20, 60, 20 ); cube.vertices[ 0 ].position.multiplyScalar( 0.01 ); cube.vertices[ 1 ].position.multiplyScalar( 0.01 ); diff --git a/examples/misc_lights_test.html b/examples/misc_lights_test.html index 31a4932c..73a1d424 100644 --- a/examples/misc_lights_test.html +++ b/examples/misc_lights_test.html @@ -90,7 +90,7 @@ // Spheres - var geometry = new THREE.Sphere( 100, 16, 8 ); + var geometry = new THREE.SphereGeometry( 100, 16, 8 ); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, shading: THREE.FlatShading } ); for ( var i = 0; i < 30; i ++ ) { diff --git a/examples/misc_lookat.html b/examples/misc_lookat.html index e4ec172f..b1686498 100644 --- a/examples/misc_lookat.html +++ b/examples/misc_lookat.html @@ -64,10 +64,10 @@ scene = new THREE.Scene(); - var geometry = new THREE.Cylinder( 3, 10, 0.1, 100 ); + var geometry = new THREE.CylinderGeometry( 3, 10, 0.1, 100 ); var material = new THREE.MeshNormalMaterial( { shading: THREE.SmoothShading } ); - target = new THREE.Mesh( new THREE.Sphere( 100, 20, 20 ), material ); + target = new THREE.Mesh( new THREE.SphereGeometry( 100, 20, 20 ), material ); scene.addObject( target ); for ( var i = 0; i < 1000; i ++ ) { diff --git a/examples/misc_materials_multimaterials.html b/examples/misc_materials_multimaterials.html index 5d33ce31..b5681c85 100644 --- a/examples/misc_materials_multimaterials.html +++ b/examples/misc_materials_multimaterials.html @@ -96,7 +96,7 @@ // SPHERES - sphere = new THREE.Sphere( 100, 16, 8 ); + sphere = new THREE.SphereGeometry( 100, 16, 8 ); for ( var i = 0; i < 10; i ++ ) { @@ -242,7 +242,7 @@ for ( var i = 0; i < materials.length; i ++ ) { // material - mesh = new THREE.Mesh( new THREE.Plane( size, size ), materials[i] ); + mesh = new THREE.Mesh( new THREE.PlaneGeometry( size, size ), materials[i] ); mesh.position.x = i * ( size + 5 ) - ( ( materials.length - 1 ) * ( size + 5 ) / 2 ); mesh.position.y = FLOOR + size / 2 + bottom; mesh.position.z = -100; @@ -264,7 +264,7 @@ var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ) } ); xm.map.needsUpdate = true; - mesh = new THREE.Mesh( new THREE.Plane( size, size ), xm ); + mesh = new THREE.Mesh( new THREE.PlaneGeometry( size, size ), xm ); mesh.position.x = i * ( size + 5 ) - ( ( materials.length - 1 ) * ( size + 5 ) / 2 ); mesh.position.y = FLOOR + size / 2 + bottom; mesh.position.z = - 99; diff --git a/examples/misc_sound.html b/examples/misc_sound.html index 24757a4a..f61b7985 100644 --- a/examples/misc_sound.html +++ b/examples/misc_sound.html @@ -82,12 +82,12 @@ light.position.normalize(); scene.addLight( light ); - var sphere = new THREE.Sphere( 20, 32, 16 ); + var sphere = new THREE.SphereGeometry( 20, 32, 16 ); material_sphere1 = new THREE.MeshLambertMaterial( { color: 0xffaa00, shading: THREE.FlatShading } ); material_sphere2 = new THREE.MeshLambertMaterial( { color: 0xff2200, shading: THREE.FlatShading } ); - var cube = new THREE.Cube( 5, 40, 5 ); + var cube = new THREE.CubeGeometry( 5, 40, 5 ); var material_cube = new THREE.MeshLambertMaterial( { color: 0xffff00, shading: THREE.FlatShading } ); material_cube.color.setHSV( 0.1, 0.7, 1 ); @@ -132,7 +132,7 @@ material_wireframe.color.setHSV( 0.1, 0.2, 0.25 ); - var plane = new THREE.Plane( 1000, 1000, 100, 100 ); + var plane = new THREE.PlaneGeometry( 1000, 1000, 100, 100 ); mesh = new THREE.Mesh( plane, material_wireframe ); mesh.position.y = 0.1; mesh.rotation.x = -1.57; @@ -201,7 +201,7 @@ } ); - postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); + postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); postprocessing.quad.position.z = - 500; postprocessing.scene.addObject( postprocessing.quad ); diff --git a/examples/misc_ubiquity_test.html b/examples/misc_ubiquity_test.html index c903817b..9f9ae5c6 100644 --- a/examples/misc_ubiquity_test.html +++ b/examples/misc_ubiquity_test.html @@ -84,30 +84,37 @@ - - + + + - - - - - - - - + + + + + + + + + + + + + + @@ -155,7 +162,7 @@ // CUBES - var cube = new THREE.Cube( 100, 100, 100 ); + var cube = new THREE.CubeGeometry( 100, 100, 100 ); mesh = new THREE.Mesh( cube, new THREE.MeshBasicMaterial( { color: 0x0000ff, opacity: 0.5 } ) ); mesh.position.x = 500; @@ -174,7 +181,7 @@ // PLANE - mesh = new THREE.Mesh( new THREE.Plane( 100, 100 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); + mesh = new THREE.Mesh( new THREE.PlaneGeometry( 100, 100 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); mesh.position.y = -500; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; mesh.doubleSided = true; @@ -182,7 +189,7 @@ // CYLINDER - mesh = new THREE.Mesh( new THREE.Cylinder( 10, 20, 100, 200, - 50, - 20 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); + mesh = new THREE.Mesh( new THREE.CylinderGeometry( 10, 20, 100, 200, - 50, - 20 ), new THREE.MeshBasicMaterial( { color: Math.random() * 0xffffff } ) ); mesh.position.x = -500; mesh.scale.x = mesh.scale.y = mesh.scale.z = 2; scene.addObject( mesh ); diff --git a/examples/webgl_collisions_box.html b/examples/webgl_collisions_box.html index c5c3ecbb..330b6df9 100644 --- a/examples/webgl_collisions_box.html +++ b/examples/webgl_collisions_box.html @@ -87,8 +87,8 @@ function init() { function createCube( s, p ) { cube = new THREE.Mesh ( - new THREE.Cube( s,s,s, 1,1,1 ), - new THREE.MeshLambertMaterial( { color: 0x003300 }) + new THREE.CubeGeometry( s, s, s ), + new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); cube.position = p; diff --git a/examples/webgl_collisions_primitives.html b/examples/webgl_collisions_primitives.html index 53431132..87d5c2a2 100644 --- a/examples/webgl_collisions_primitives.html +++ b/examples/webgl_collisions_primitives.html @@ -85,22 +85,20 @@ //makeWall(-360); //makeWall(-480); - plane = new THREE.Mesh(new THREE.Plane(30000, 30000, 10, 10), new THREE.MeshLambertMaterial({ - color: 0x003300 - })); - plane.position.y = -480; - plane.rotation.x = Math.PI / -2; - scene.addObject(plane); - geoms.push(plane); + plane = new THREE.Mesh( new THREE.PlaneGeometry( 30000, 30000, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); + plane.position.y = - 480; + plane.rotation.x = Math.PI / - 2; + scene.addObject( plane ); + geoms.push( plane ); - var cplane = new THREE.PlaneCollider(plane.position, new THREE.Vector3(0, 1, 0)); + var cplane = new THREE.PlaneCollider( plane.position, new THREE.Vector3( 0, 1, 0 ) ); cplane.mesh = plane; - THREE.Collisions.colliders.push(cplane); + THREE.Collisions.colliders.push( cplane ); - stats = new Stats(); - stats.domElement.style.position = 'absolute'; - stats.domElement.style.top = '0px'; - container.appendChild( stats.domElement ); + stats = new Stats(); + stats.domElement.style.position = 'absolute'; + stats.domElement.style.top = '0px'; + container.appendChild( stats.domElement ); container.onmousemove = onDocumentMouseMove; animate(); @@ -120,9 +118,7 @@ } function createCube(s, p){ - var cube = new THREE.Mesh(new THREE.Cube(s, s, s, 1, 1, 1), new THREE.MeshLambertMaterial({ - color: 0x003300 - })); + var cube = new THREE.Mesh(new THREE.CubeGeometry( s, s, s ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); cube.position = p; scene.addObject(cube); geoms.push(cube); @@ -130,9 +126,7 @@ } function createSphere(rad, p){ - var sphere = new THREE.Mesh(new THREE.Sphere(rad, 10, 10), new THREE.MeshLambertMaterial({ - color: 0x003300 - })); + var sphere = new THREE.Mesh( new THREE.SphereGeometry( rad, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); sphere.position = p; scene.addObject(sphere); geoms.push(sphere); diff --git a/examples/webgl_collisions_reaction.html b/examples/webgl_collisions_reaction.html index 536285b2..ed7358b7 100644 --- a/examples/webgl_collisions_reaction.html +++ b/examples/webgl_collisions_reaction.html @@ -73,10 +73,8 @@ scene = new THREE.Scene(); - sphere = new THREE.Mesh(new THREE.Sphere(sphereSize, 10, 10), new THREE.MeshLambertMaterial({ - color: 0xff0000 - })); - scene.addObject(sphere); + sphere = new THREE.Mesh( new THREE.SphereGeometry( sphereSize, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0xff0000 } ) ); + scene.addObject( sphere ); renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); @@ -108,11 +106,10 @@ } function createCube(sx, sy, sz, p, ry){ - var cube = new THREE.Mesh(new THREE.Cube(sx, sy, sz, 1, 1, 1), new THREE.MeshLambertMaterial({ - color: 0x003300//, wireframe: true - })); + + var cube = new THREE.Mesh( new THREE.CubeGeometry( sx, sy, sz ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); cube.position = p; - cube.rotation.y = ry; + cube.rotation.y = ry; scene.addObject(cube); THREE.Collisions.colliders.push( THREE.CollisionUtils.MeshOBB(cube) ); cubes.push(cube); diff --git a/examples/webgl_collisions_terrain.html b/examples/webgl_collisions_terrain.html index 5592e050..74f8005a 100644 --- a/examples/webgl_collisions_terrain.html +++ b/examples/webgl_collisions_terrain.html @@ -69,7 +69,7 @@ function init() { ray.origin.y = 10000; ray.direction = new THREE.Vector3(0, -1, 0); - sphere = new THREE.Mesh( new THREE.Sphere( sphereSize, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0xff0000 } ) ); + sphere = new THREE.Mesh( new THREE.SphereGeometry( sphereSize, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0xff0000 } ) ); scene.addObject(sphere); camera.target = sphere; diff --git a/examples/webgl_collisions_trigger.html b/examples/webgl_collisions_trigger.html index bc5504f5..f86962a5 100644 --- a/examples/webgl_collisions_trigger.html +++ b/examples/webgl_collisions_trigger.html @@ -70,16 +70,14 @@ camera.position.x = 300; camera.position.z = 0; - mouse2d = new THREE.Vector3(0, 0, 1); + mouse2d = new THREE.Vector3( 0, 0, 1 ); - loader = new THREE.Loader(true); + loader = new THREE.Loader( true ); scene = new THREE.Scene(); - sphere = new THREE.Mesh(new THREE.Sphere(sphereSize, 10, 10), new THREE.MeshLambertMaterial({ - color: 0xff0000 - })); - scene.addObject(sphere); + sphere = new THREE.Mesh( new THREE.SphereGeometry( sphereSize, 10, 10 ), new THREE.MeshLambertMaterial( { color: 0xff0000 } ) ); + scene.addObject( sphere ); renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); @@ -105,9 +103,7 @@ } function createCube(sx, sy, sz, p){ - var cube = new THREE.Mesh(new THREE.Cube(sx, sy, sz, 1, 1, 1), new THREE.MeshLambertMaterial({ - color: 0x003300//, wireframe: true - })); + var cube = new THREE.Mesh(new THREE.CubeGeometry( sx, sy, sz ), new THREE.MeshLambertMaterial( { color: 0x003300 } ) ); cube.position = p; scene.addObject(cube); THREE.Collisions.colliders.push( THREE.CollisionUtils.MeshOBB(cube) ); diff --git a/examples/webgl_flycamera_earth.html b/examples/webgl_flycamera_earth.html index e7bb84c1..69374603 100644 --- a/examples/webgl_flycamera_earth.html +++ b/examples/webgl_flycamera_earth.html @@ -151,7 +151,7 @@ // planet - geometry = new THREE.Sphere( radius, 100, 50 ); + geometry = new THREE.SphereGeometry( radius, 100, 50 ); geometry.computeTangents(); meshPlanet = new THREE.Mesh( geometry, materialNormalMap ); @@ -344,7 +344,7 @@ postprocessing.materialFilm.uniforms.sIntensity.value = 0.75; postprocessing.materialFilm.uniforms.sCount.value = 2048; - postprocessing.quad = new THREE.Mesh( new THREE.Plane( SCREEN_WIDTH, SCREEN_HEIGHT ), postprocessing.materialConvolution ); + postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ), postprocessing.materialConvolution ); postprocessing.quad.position.z = - 500; postprocessing.scene.addObject( postprocessing.quad ); diff --git a/examples/webgl_geometries.html b/examples/webgl_geometries.html index 1c047808..c3e5f31d 100644 --- a/examples/webgl_geometries.html +++ b/examples/webgl_geometries.html @@ -60,27 +60,27 @@ new THREE.MeshBasicMaterial( { color: 0xffffff, wireframe: true, opacity: 0.1 } ) ]; - objects[ 0 ] = object = new THREE.Mesh( new THREE.Cube( 100, 100, 100, 4, 4, 4 ), material ); + objects[ 0 ] = object = new THREE.Mesh( new THREE.CubeGeometry( 100, 100, 100, 4, 4, 4 ), material ); object.position.x = - 200; object.position.z = 200; scene.addObject( object ); - objects[ 1 ] = object = new THREE.Mesh( new THREE.Cylinder( 50, 25, 75, 100 ), material ); + objects[ 1 ] = object = new THREE.Mesh( new THREE.CylinderGeometry( 50, 25, 75, 100 ), material ); object.position.z = 200; scene.addObject( object ); - objects[ 2 ] = object = new THREE.Mesh( new THREE.Icosahedron( 2 ), material ); + objects[ 2 ] = object = new THREE.Mesh( new THREE.IcosahedronGeometry( 2 ), material ); object.position.x = 200; object.position.z = 200; object.scale.x = object.scale.y = object.scale.z = 75; scene.addObject( object ); - objects[ 3 ] = object = new THREE.Mesh( new THREE.Plane( 100, 100, 4, 4 ), material ); + objects[ 3 ] = object = new THREE.Mesh( new THREE.PlaneGeometry( 100, 100, 4, 4 ), material ); object.position.x = - 200; scene.addObject( object ); - objects[ 4 ] = object = new THREE.Mesh( new THREE.Sphere( 75, 20, 10 ), material ); + objects[ 4 ] = object = new THREE.Mesh( new THREE.SphereGeometry( 75, 20, 10 ), material ); scene.addObject( object ); var points = []; @@ -91,16 +91,16 @@ } - objects[ 5 ] = object = new THREE.Mesh( new THREE.Lathe( points, 20 ), material ); + objects[ 5 ] = object = new THREE.Mesh( new THREE.LatheGeometry( points, 20 ), material ); object.position.x = 200; scene.addObject( object ); - objects[ 6 ] = object = new THREE.Mesh( new THREE.Torus( 50, 20, 20, 20 ), material ); + objects[ 6 ] = object = new THREE.Mesh( new THREE.TorusGeometry( 50, 20, 20, 20 ), material ); object.position.x = - 200; object.position.z = - 200; scene.addObject( object ); - objects[ 7 ] = object = new THREE.Mesh( new THREE.TorusKnot( 50, 10, 50, 20 ), material ); + objects[ 7 ] = object = new THREE.Mesh( new THREE.TorusKnotGeometry( 50, 10, 50, 20 ), material ); object.position.z = - 200; scene.addObject( object ); diff --git a/examples/webgl_geometry_colors.html b/examples/webgl_geometry_colors.html index 155e190a..d64be5a6 100644 --- a/examples/webgl_geometry_colors.html +++ b/examples/webgl_geometry_colors.html @@ -72,7 +72,7 @@ scene.addLight( light ); var shadowMaterial = new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ); - var shadowGeo = new THREE.Plane( 300, 300, 1, 1 ); + var shadowGeo = new THREE.PlaneGeometry( 300, 300, 1, 1 ); mesh = new THREE.Mesh( shadowGeo, shadowMaterial ); mesh.position.y = - 250; @@ -95,9 +95,9 @@ var color, f, f2, f3, p, n, vertexIndex, - geometry = new THREE.Icosahedron( 1 ), - geometry2 = new THREE.Icosahedron( 1 ), - geometry3 = new THREE.Icosahedron( 1 ); + geometry = new THREE.IcosahedronGeometry( 1 ), + geometry2 = new THREE.IcosahedronGeometry( 1 ), + geometry3 = new THREE.IcosahedronGeometry( 1 ); for ( var i = 0; i < geometry.faces.length; i++ ) { diff --git a/examples/webgl_geometry_dynamic.html b/examples/webgl_geometry_dynamic.html index 64dcce8c..c42d4e30 100644 --- a/examples/webgl_geometry_dynamic.html +++ b/examples/webgl_geometry_dynamic.html @@ -89,7 +89,7 @@ camera.position.y = 200; camera.target.position.y = camera.position.y; - geometry = new THREE.Plane( 20000, 20000, worldWidth - 1, worldDepth - 1 ); + geometry = new THREE.PlaneGeometry( 20000, 20000, worldWidth - 1, worldDepth - 1 ); var i, j, il, jl; diff --git a/examples/webgl_geometry_hierarchy.html b/examples/webgl_geometry_hierarchy.html index 8f9b3b13..da7d1548 100644 --- a/examples/webgl_geometry_hierarchy.html +++ b/examples/webgl_geometry_hierarchy.html @@ -49,7 +49,7 @@ scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0xffffff, 1, 10000 ); - var geometry = new THREE.Cube( 100, 100, 100 ); + var geometry = new THREE.CubeGeometry( 100, 100, 100 ); var material = new THREE.MeshNormalMaterial(); group = new THREE.Object3D(); diff --git a/examples/webgl_geometry_hierarchy2.html b/examples/webgl_geometry_hierarchy2.html index 7005df09..37d53986 100644 --- a/examples/webgl_geometry_hierarchy2.html +++ b/examples/webgl_geometry_hierarchy2.html @@ -49,7 +49,7 @@ scene = new THREE.Scene(); scene.fog = new THREE.Fog( 0xffffff, 1, 10000 ); - var geometry = new THREE.Cube( 100, 100, 100 ); + var geometry = new THREE.CubeGeometry( 100, 100, 100 ); var material = new THREE.MeshNormalMaterial(); var mesh = new THREE.Mesh( geometry, material ); diff --git a/examples/webgl_geometry_large_mesh.html b/examples/webgl_geometry_large_mesh.html index 90ba6d6d..05564824 100644 --- a/examples/webgl_geometry_large_mesh.html +++ b/examples/webgl_geometry_large_mesh.html @@ -131,7 +131,7 @@ scene.addLight( pointLight ); // light representation - sphere = new THREE.Sphere( 100, 16, 8, 1 ); + sphere = new THREE.SphereGeometry( 100, 16, 8, 1 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; lightMesh.position = pointLight.position; diff --git a/examples/webgl_geometry_minecraft.html b/examples/webgl_geometry_minecraft.html index fb96d6af..5664e530 100644 --- a/examples/webgl_geometry_minecraft.html +++ b/examples/webgl_geometry_minecraft.html @@ -109,7 +109,7 @@ nx = ( i & 4 ) == 4; pz = ( i & 2 ) == 2; nz = ( i & 1 ) == 1; - cubes[ i ] = new THREE.Cube( 100, 100, 100, 1, 1, 1, materials, false, { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz } ); + cubes[ i ] = new THREE.CubeGeometry( 100, 100, 100, 1, 1, 1, materials, false, { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz } ); } diff --git a/examples/webgl_geometry_minecraft_ao.html b/examples/webgl_geometry_minecraft_ao.html index 0f17739f..c150fbb4 100644 --- a/examples/webgl_geometry_minecraft_ao.html +++ b/examples/webgl_geometry_minecraft_ao.html @@ -371,7 +371,7 @@ sides = { px: px, nx: nx, py: true, ny: false, pz: pz, nz: nz }; - cube = new THREE.Cube( 100, 100, 100, 1, 1, 1, materials, false, sides ); + cube = new THREE.CubeGeometry( 100, 100, 100, 1, 1, 1, materials, false, sides ); // set UV tiles diff --git a/examples/webgl_geometry_terrain.html b/examples/webgl_geometry_terrain.html index 72ca2426..f415e42e 100644 --- a/examples/webgl_geometry_terrain.html +++ b/examples/webgl_geometry_terrain.html @@ -83,7 +83,7 @@ camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] + 500; camera.target.position.y = camera.position.y; - var geometry = new THREE.Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 ); + var geometry = new THREE.PlaneGeometry( 7500, 7500, worldWidth - 1, worldDepth - 1 ); for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) { diff --git a/examples/webgl_geometry_terrain_fog.html b/examples/webgl_geometry_terrain_fog.html index 6160daab..9351640b 100644 --- a/examples/webgl_geometry_terrain_fog.html +++ b/examples/webgl_geometry_terrain_fog.html @@ -83,7 +83,7 @@ camera.position.y = data[ worldHalfWidth + worldHalfDepth * worldWidth ] * 10 + 500; camera.target.position.y = camera.position.y; - var geometry = new THREE.Plane( 7500, 7500, worldWidth - 1, worldDepth - 1 ); + var geometry = new THREE.PlaneGeometry( 7500, 7500, worldWidth - 1, worldDepth - 1 ); for ( var i = 0, l = geometry.vertices.length; i < l; i ++ ) { diff --git a/examples/webgl_geometry_text.html b/examples/webgl_geometry_text.html index 014867c6..e8def5ae 100644 --- a/examples/webgl_geometry_text.html +++ b/examples/webgl_geometry_text.html @@ -1,55 +1,116 @@ - three.js canvas/webgl - geometry - text + three.js webgl - geometry - text -
- Drag to spin the text -
Simple Dynamic 3D Text WebGL Example by zz85 -
- + +
+ three.js - procedural 3D text by zz85 & alteredq + (fonts from typeface.js and Droid) +
type to enter new text, drag to spin the text +
change color, + change font, + change weight, + change bezel, + change postprocessing, + +
+ + + - - - - + + + + + + + + + + + + + + - - \ No newline at end of file + diff --git a/examples/webgl_hdr.html b/examples/webgl_hdr.html index 77d0c89d..2c657add 100644 --- a/examples/webgl_hdr.html +++ b/examples/webgl_hdr.html @@ -143,7 +143,7 @@ } ); - var plane = new THREE.Plane( 512, 768 ); + var plane = new THREE.PlaneGeometry( 512, 768 ); quad = new THREE.Mesh( plane, materialHDR ); quad.position.z = -100; diff --git a/examples/webgl_interactive_cubes.html b/examples/webgl_interactive_cubes.html index 60203efb..8560234c 100644 --- a/examples/webgl_interactive_cubes.html +++ b/examples/webgl_interactive_cubes.html @@ -62,7 +62,7 @@ light.position.normalize(); scene.addLight( light ); - var geometry = new THREE.Cube( 20, 20, 20 ); + var geometry = new THREE.CubeGeometry( 20, 20, 20 ); for ( var i = 0; i < 500; i ++ ) { diff --git a/examples/webgl_interactive_voxelpainter.html b/examples/webgl_interactive_voxelpainter.html index f61f79ff..557d1854 100644 --- a/examples/webgl_interactive_voxelpainter.html +++ b/examples/webgl_interactive_voxelpainter.html @@ -61,7 +61,7 @@ // roll-over helpers - rollOverGeo = new THREE.Cube( 50, 50, 50 ); + rollOverGeo = new THREE.CubeGeometry( 50, 50, 50 ); rollOverMaterial = new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, transparent: true } ); rollOverMesh = new THREE.Mesh( rollOverGeo, rollOverMaterial ); scene.addObject( rollOverMesh ); @@ -69,7 +69,7 @@ // cubes - cubeGeo = new THREE.Cube( 50, 50, 50 ); + cubeGeo = new THREE.CubeGeometry( 50, 50, 50 ); cubeMaterial = new THREE.MeshLambertMaterial( { color: 0x00ff80, shading: THREE.FlatShading, map: THREE.ImageUtils.loadTexture( "textures/square-outline-textured.png" ) } ); cubeMaterial.color.setHSV( 0.1, 0.7, 1.0 ); // picking @@ -78,7 +78,7 @@ // grid - plane = new THREE.Mesh( new THREE.Plane( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) ); + plane = new THREE.Mesh( new THREE.PlaneGeometry( 1000, 1000, 20, 20 ), new THREE.MeshBasicMaterial( { color: 0x555555, wireframe: true } ) ); plane.rotation.x = - 90 * Math.PI / 180; scene.addObject( plane ); diff --git a/examples/webgl_lights_pointlights.html b/examples/webgl_lights_pointlights.html index c3424ce1..096b345d 100644 --- a/examples/webgl_lights_pointlights.html +++ b/examples/webgl_lights_pointlights.html @@ -106,7 +106,7 @@ light3 = new THREE.PointLight( 0x80ff80, 2, 50 ); scene.addLight( light3 ); - var sphere = new THREE.Sphere( 0.5, 16, 8 ); + var sphere = new THREE.SphereGeometry( 0.5, 16, 8 ); var l1 = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xff0040 } ) ); l1.position = light1.position; diff --git a/examples/webgl_lines_colors.html b/examples/webgl_lines_colors.html index a450319c..c6538a4d 100644 --- a/examples/webgl_lines_colors.html +++ b/examples/webgl_lines_colors.html @@ -239,7 +239,7 @@ } ); - postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); + postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); postprocessing.quad.position.z = - 500; postprocessing.scene.addObject( postprocessing.quad ); diff --git a/examples/webgl_lines_splines.html b/examples/webgl_lines_splines.html index aacf4fa4..392b6a5f 100644 --- a/examples/webgl_lines_splines.html +++ b/examples/webgl_lines_splines.html @@ -191,7 +191,7 @@ } ); - var plane = new THREE.Plane( window.innerWidth, window.innerHeight ); + var plane = new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ); quadScreen = new THREE.Mesh( plane, materialConvolution ); quadScreen.position.z = -100; diff --git a/examples/webgl_lod.html b/examples/webgl_lod.html index 62f9d44f..720e906f 100644 --- a/examples/webgl_lod.html +++ b/examples/webgl_lod.html @@ -85,10 +85,10 @@ var geometry = [ - [ new THREE.Sphere( 100, 64, 32 ), 300 ], - [ new THREE.Sphere( 100, 32, 16 ), 1000 ], - [ new THREE.Sphere( 100, 16, 8 ), 2000 ], - [ new THREE.Sphere( 100, 8, 4 ), 10000 ] + [ new THREE.SphereGeometry( 100, 64, 32 ), 300 ], + [ new THREE.SphereGeometry( 100, 32, 16 ), 1000 ], + [ new THREE.SphereGeometry( 100, 16, 8 ), 2000 ], + [ new THREE.SphereGeometry( 100, 8, 4 ), 10000 ] ]; diff --git a/examples/webgl_materials.html b/examples/webgl_materials.html index da4b38ac..75fcd74a 100644 --- a/examples/webgl_materials.html +++ b/examples/webgl_materials.html @@ -88,9 +88,9 @@ // Spheres geometry - var geometry_smooth = new THREE.Sphere( 70, 32, 16 ); - var geometry_flat = new THREE.Sphere( 70, 32, 16 ); - var geometry_pieces = new THREE.Sphere( 70, 32, 16 ); // Extra geometry to be broken down for MeshFaceMaterial + var geometry_smooth = new THREE.SphereGeometry( 70, 32, 16 ); + var geometry_flat = new THREE.SphereGeometry( 70, 32, 16 ); + var geometry_pieces = new THREE.SphereGeometry( 70, 32, 16 ); // Extra geometry to be broken down for MeshFaceMaterial for ( var i = 0, l = geometry_pieces.faces.length; i < l; i ++ ) { @@ -127,7 +127,7 @@ } - particleLight = new THREE.Mesh( new THREE.Sphere( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) ); + particleLight = new THREE.Mesh( new THREE.SphereGeometry( 4, 8, 8 ), new THREE.MeshBasicMaterial( { color: 0xffffff } ) ); scene.addObject( particleLight ); // Lights diff --git a/examples/webgl_materials_cars_camaro.html b/examples/webgl_materials_cars_camaro.html index 7fa604e0..092f3644 100644 --- a/examples/webgl_materials_cars_camaro.html +++ b/examples/webgl_materials_cars_camaro.html @@ -92,7 +92,7 @@ scene.addLight( pointLight ); - sphere = new THREE.Sphere( 100, 16, 8, 1 ); + sphere = new THREE.SphereGeometry( 100, 16, 8, 1 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; lightMesh.position = pointLight.position; diff --git a/examples/webgl_materials_cars_camaro_crosseyed.html b/examples/webgl_materials_cars_camaro_crosseyed.html index 6a1910c6..1e4422b0 100644 --- a/examples/webgl_materials_cars_camaro_crosseyed.html +++ b/examples/webgl_materials_cars_camaro_crosseyed.html @@ -95,7 +95,7 @@ scene.addLight( pointLight ); - sphere = new THREE.Sphere( 100, 16, 8, 1 ); + sphere = new THREE.SphereGeometry( 100, 16, 8, 1 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; lightMesh.position = pointLight.position; diff --git a/examples/webgl_materials_cubemap.html b/examples/webgl_materials_cubemap.html index baa87eae..5c408c2f 100644 --- a/examples/webgl_materials_cubemap.html +++ b/examples/webgl_materials_cubemap.html @@ -90,7 +90,7 @@ scene.addLight( pointLight ); // light representation - sphere = new THREE.Sphere( 100, 16, 8 ); + sphere = new THREE.SphereGeometry( 100, 16, 8 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) ); lightMesh.position = pointLight.position; lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; diff --git a/examples/webgl_materials_cubemap_balls_reflection.html b/examples/webgl_materials_cubemap_balls_reflection.html index 73dc55e1..809804be 100644 --- a/examples/webgl_materials_cubemap_balls_reflection.html +++ b/examples/webgl_materials_cubemap_balls_reflection.html @@ -77,7 +77,7 @@ scene = new THREE.Scene(); sceneCube = new THREE.Scene(); - var geometry = new THREE.Sphere( 100, 32, 16 ); + var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var path = "textures/cube/pisa/"; var format = '.png'; diff --git a/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html b/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html index 869ddbcf..67768849 100644 --- a/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html +++ b/examples/webgl_materials_cubemap_balls_reflection_anaglyph.html @@ -73,7 +73,7 @@ scene = new THREE.Scene(); - var geometry = new THREE.Sphere( 100, 32, 16 ); + var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var path = "textures/cube/pisa/"; var format = '.png'; diff --git a/examples/webgl_materials_cubemap_balls_refraction.html b/examples/webgl_materials_cubemap_balls_refraction.html index 12522e8a..08632833 100644 --- a/examples/webgl_materials_cubemap_balls_refraction.html +++ b/examples/webgl_materials_cubemap_balls_refraction.html @@ -76,7 +76,7 @@ scene = new THREE.Scene(); sceneCube = new THREE.Scene(); - var geometry = new THREE.Sphere( 100, 32, 16 ); + var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var path = "textures/cube/skybox/"; var format = '.jpg'; diff --git a/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html b/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html index 09037dc2..e82b2e4a 100644 --- a/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html +++ b/examples/webgl_materials_cubemap_balls_refraction_crosseyed.html @@ -75,7 +75,7 @@ scene = new THREE.Scene(); - var geometry = new THREE.Sphere( 100, 32, 16 ); + var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var path = "textures/cube/skybox/"; var format = '.jpg'; diff --git a/examples/webgl_materials_cubemap_escher.html b/examples/webgl_materials_cubemap_escher.html index 36d80f82..5011220e 100644 --- a/examples/webgl_materials_cubemap_escher.html +++ b/examples/webgl_materials_cubemap_escher.html @@ -81,7 +81,7 @@ var textureCube = THREE.ImageUtils.loadTextureCube( urls ); var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube } ) - var geometry = new THREE.Sphere( 100, 96, 64 ); + var geometry = new THREE.SphereGeometry( 100, 96, 64 ); var mesh = new THREE.Mesh( geometry, material ); mesh.scale.x = mesh.scale.y = mesh.scale.z = 16; diff --git a/examples/webgl_materials_cubemap_refraction.html b/examples/webgl_materials_cubemap_refraction.html index e3835a36..706b2340 100644 --- a/examples/webgl_materials_cubemap_refraction.html +++ b/examples/webgl_materials_cubemap_refraction.html @@ -88,7 +88,7 @@ scene.addLight( pointLight ); // light representation - sphere = new THREE.Sphere( 100, 16, 8 ); + sphere = new THREE.SphereGeometry( 100, 16, 8 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) ); lightMesh.position = pointLight.position; lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; diff --git a/examples/webgl_materials_grass.html b/examples/webgl_materials_grass.html index 93281b8b..a9a925e2 100644 --- a/examples/webgl_materials_grass.html +++ b/examples/webgl_materials_grass.html @@ -40,7 +40,7 @@ scene = new THREE.Scene(); - var geometry = new THREE.Plane( 100, 100 ); + var geometry = new THREE.PlaneGeometry( 100, 100 ); var bitmap = generateTextureBase(); diff --git a/examples/webgl_materials_normalmap.html b/examples/webgl_materials_normalmap.html index bf2ec2f4..cd6b32ff 100644 --- a/examples/webgl_materials_normalmap.html +++ b/examples/webgl_materials_normalmap.html @@ -116,7 +116,7 @@ // light representation - var sphere = new THREE.Sphere( 100, 16, 8 ); + var sphere = new THREE.SphereGeometry( 100, 16, 8 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color:0xffaa00 } ) ); lightMesh.position = pointLight.position; lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; diff --git a/examples/webgl_materials_shaders.html b/examples/webgl_materials_shaders.html index d242fb65..aac018be 100644 --- a/examples/webgl_materials_shaders.html +++ b/examples/webgl_materials_shaders.html @@ -125,7 +125,7 @@ scene.addLight( pointLight ); // light representation - sphere = new THREE.Sphere( 100, 16, 8 ); + sphere = new THREE.SphereGeometry( 100, 16, 8 ); lightMesh = new THREE.Mesh( sphere, new THREE.MeshBasicMaterial( { color: 0xffaa00 } ) ); lightMesh.scale.x = lightMesh.scale.y = lightMesh.scale.z = 0.05; lightMesh.position = pointLight.position; @@ -134,7 +134,7 @@ scene.addObject( lightMesh ); // material samples - sphere = new THREE.Sphere( 100, 32, 32 ); + sphere = new THREE.SphereGeometry( 100, 32, 32 ); var y1 = 0, y2 = - 200; diff --git a/examples/webgl_materials_shaders_fresnel.html b/examples/webgl_materials_shaders_fresnel.html index cf01e10b..bcc060ec 100644 --- a/examples/webgl_materials_shaders_fresnel.html +++ b/examples/webgl_materials_shaders_fresnel.html @@ -79,7 +79,7 @@ scene = new THREE.Scene(); sceneCube = new THREE.Scene(); - var geometry = new THREE.Sphere( 100, 32, 16 ); + var geometry = new THREE.SphereGeometry( 100, 32, 16 ); var path = "textures/cube/Park2/"; var format = '.jpg'; diff --git a/examples/webgl_materials_texture_filters.html b/examples/webgl_materials_texture_filters.html index e5a103f9..c494d382 100644 --- a/examples/webgl_materials_texture_filters.html +++ b/examples/webgl_materials_texture_filters.html @@ -123,7 +123,7 @@ textureCanvas2.needsUpdate = true; - var i, j, uvs, geometryRepeat = new THREE.Plane( 100, 100, 1, 1 ); + var i, j, uvs, geometryRepeat = new THREE.PlaneGeometry( 100, 100, 1, 1 ); for ( i = 0; i < geometryRepeat.faceVertexUvs[ 0 ].length; i ++ ) { @@ -160,7 +160,7 @@ scene.addObject( meshCanvas ); scene2.addObject( meshCanvas2 ); - var geometry = new THREE.Plane( 100, 100, 1, 1 ), + var geometry = new THREE.PlaneGeometry( 100, 100, 1, 1 ), mesh = new THREE.Mesh( geometry, materialPainting ), mesh2 = new THREE.Mesh( geometry, materialPainting2 ); diff --git a/examples/webgl_materials_video.html b/examples/webgl_materials_video.html index 0413f0bf..214ccc11 100644 --- a/examples/webgl_materials_video.html +++ b/examples/webgl_materials_video.html @@ -130,7 +130,7 @@ ox = i; oy = j; - geometry = new THREE.Cube( xsize, ysize, xsize ); + geometry = new THREE.CubeGeometry( xsize, ysize, xsize ); change_uvs( geometry, ux, uy, ox, oy ); materials[ cube_count ] = new THREE.MeshLambertMaterial( parameters ); @@ -242,7 +242,7 @@ } ); - postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); + postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution ); postprocessing.quad.position.z = -500; postprocessing.scene.addObject( postprocessing.quad ); diff --git a/examples/webgl_morphtargets.html b/examples/webgl_morphtargets.html index db42917b..0a48affb 100644 --- a/examples/webgl_morphtargets.html +++ b/examples/webgl_morphtargets.html @@ -109,7 +109,7 @@ scene.addLight( light ); - var geometry = new THREE.Cube( 100, 100, 100 ); + var geometry = new THREE.CubeGeometry( 100, 100, 100 ); var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true } ); // construct 8 blend shapes diff --git a/examples/webgl_multiple_canvases_complex.html b/examples/webgl_multiple_canvases_complex.html index 76af9762..9976c822 100755 --- a/examples/webgl_multiple_canvases_complex.html +++ b/examples/webgl_multiple_canvases_complex.html @@ -132,7 +132,7 @@ scene.addLight( light ); var shadowMaterial = new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ); - var shadowGeo = new THREE.Plane( 300, 300, 1, 1 ); + var shadowGeo = new THREE.PlaneGeometry( 300, 300, 1, 1 ); mesh = new THREE.Mesh( shadowGeo, shadowMaterial ); mesh.position.y = - 250; @@ -155,9 +155,9 @@ var color, f, f2, f3, p, n, vertexIndex, - geometry = new THREE.Icosahedron( 1 ), - geometry2 = new THREE.Icosahedron( 1 ), - geometry3 = new THREE.Icosahedron( 1 ); + geometry = new THREE.IcosahedronGeometry( 1 ), + geometry2 = new THREE.IcosahedronGeometry( 1 ), + geometry3 = new THREE.IcosahedronGeometry( 1 ); for ( var i = 0; i < geometry.faces.length; i++ ) { diff --git a/examples/webgl_multiple_canvases_grid.html b/examples/webgl_multiple_canvases_grid.html index db3da19e..cf835f64 100755 --- a/examples/webgl_multiple_canvases_grid.html +++ b/examples/webgl_multiple_canvases_grid.html @@ -148,7 +148,7 @@ scene.addLight( light ); var shadowMaterial = new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/shadow.png' ) } ); - var shadowGeo = new THREE.Plane( 300, 300, 1, 1 ); + var shadowGeo = new THREE.PlaneGeometry( 300, 300, 1, 1 ); mesh = new THREE.Mesh( shadowGeo, shadowMaterial ); mesh.position.y = - 250; @@ -171,9 +171,9 @@ var color, f, f2, f3, p, n, vertexIndex, - geometry = new THREE.Icosahedron( 1 ), - geometry2 = new THREE.Icosahedron( 1 ), - geometry3 = new THREE.Icosahedron( 1 ); + geometry = new THREE.IcosahedronGeometry( 1 ), + geometry2 = new THREE.IcosahedronGeometry( 1 ), + geometry3 = new THREE.IcosahedronGeometry( 1 ); for ( var i = 0; i < geometry.faces.length; i++ ) { diff --git a/examples/webgl_objconvert_test.html b/examples/webgl_objconvert_test.html index afac0555..923a1ca7 100644 --- a/examples/webgl_objconvert_test.html +++ b/examples/webgl_objconvert_test.html @@ -32,12 +32,6 @@

Models by Reallusion iClone. - -

Using a modified version of Three.js by mrdoob. - -
-

Best viewed in Chrome 9 or Firefox 4 using WebGL renderer. -

Canvas renderer is very slow on anything other than Chrome.


@@ -112,7 +106,7 @@
 				xm.map.needsUpdate = true;
 				xm.map.repeat.set( 10, 10 );
 
-				geometry = new THREE.Plane( 100, 100, 15, 10 );
+				geometry = new THREE.PlaneGeometry( 100, 100, 15, 10 );
 	
 				mesh = new THREE.Mesh( geometry, xm );
 				mesh.position.x = 0;
@@ -127,7 +121,7 @@
 				// SPHERES
 
 				var material_spheres = new THREE.MeshLambertMaterial( { color: 0xdddddd } ),
-					sphere = new THREE.Sphere( 100, 16, 8 );
+					sphere = new THREE.SphereGeometry( 100, 16, 8 );
 
 				for ( var i=0; i<10; i++ ) {
 					mesh = new THREE.Mesh( sphere, material_spheres );
@@ -216,7 +210,7 @@
 				for ( var i = 0; i < materials.length; i ++ ) {
 
 					// material
-					mesh = new THREE.Mesh( new THREE.Plane( size, size ), materials[i] );
+					mesh = new THREE.Mesh( new THREE.PlaneGeometry( size, size ), materials[i] );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
 					mesh.position.y = FLOOR + size/2 + bottom;
 					mesh.position.z = -100;
@@ -238,7 +232,7 @@
 					var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( x ) } );
 					xm.map.needsUpdate = true;
 
-					mesh = new THREE.Mesh( new THREE.Plane( size, size ), xm );
+					mesh = new THREE.Mesh( new THREE.PlaneGeometry( size, size ), xm );
 					mesh.position.x = i * (size + 5) - ( ( materials.length - 1 )* ( size + 5 )/2);
 					mesh.position.y = FLOOR + size/2 + bottom;
 					mesh.position.z = -99;
diff --git a/examples/webgl_panorama_equirectangular.html b/examples/webgl_panorama_equirectangular.html
index 0cc4fa91..6b8e7e2f 100644
--- a/examples/webgl_panorama_equirectangular.html
+++ b/examples/webgl_panorama_equirectangular.html
@@ -59,7 +59,7 @@
 
 				scene = new THREE.Scene();
 
-				mesh = new THREE.Mesh( new THREE.Sphere( 500, 60, 40 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' ) } ) );
+				mesh = new THREE.Mesh( new THREE.SphereGeometry( 500, 60, 40 ), new THREE.MeshBasicMaterial( { map: THREE.ImageUtils.loadTexture( 'textures/2294472375_24a3b8ef46_o.jpg' ) } ) );
 				mesh.scale.x = -1;
 				scene.addObject( mesh );
 
diff --git a/examples/webgl_particles_dynamic.html b/examples/webgl_particles_dynamic.html
index 929c0f61..db3c512d 100644
--- a/examples/webgl_particles_dynamic.html
+++ b/examples/webgl_particles_dynamic.html
@@ -146,7 +146,7 @@
 				parent = new THREE.Object3D();
 				scene.addObject( parent );
 
-				var grid = new THREE.ParticleSystem( new THREE.Plane( 15000, 15000, 64, 64 ), new THREE.ParticleBasicMaterial( { color: 0xff0000, size: 10 } ) );
+				var grid = new THREE.ParticleSystem( new THREE.PlaneGeometry( 15000, 15000, 64, 64 ), new THREE.ParticleBasicMaterial( { color: 0xff0000, size: 10 } ) );
 				grid.rotation.x = 1.57;
 				grid.position.y = -400;
 				parent.addChild( grid );
@@ -335,7 +335,7 @@
 
 				} );
 				
-				effect.quad = new THREE.Mesh( new THREE.Plane( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialHeat );
+				effect.quad = new THREE.Mesh( new THREE.PlaneGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialHeat );
 				effect.quad.position.z = -500;
 				effect.scene.addObject( effect.quad );
 
@@ -402,7 +402,7 @@
 				effect.materialFilm.uniforms.sIntensity.value = 0.5;
 				effect.materialFilm.uniforms.sCount.value = 1448;
 
-				effect.quad = new THREE.Mesh( new THREE.Plane( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialConvolution );
+				effect.quad = new THREE.Mesh( new THREE.PlaneGeometry( SCREEN_WIDTH, SCREEN_HEIGHT ), effect.materialConvolution );
 				effect.quad.position.z = -500;
 				effect.scene.addObject( effect.quad );
 
diff --git a/examples/webgl_postprocessing.html b/examples/webgl_postprocessing.html
index 9ee5a839..0eb8e553 100644
--- a/examples/webgl_postprocessing.html
+++ b/examples/webgl_postprocessing.html
@@ -173,7 +173,7 @@
 
 				} );
 
-				var plane = new THREE.Plane( window.innerWidth, window.innerHeight );
+				var plane = new THREE.PlaneGeometry( window.innerWidth, window.innerHeight );
 
 				quadBG = new THREE.Mesh( plane, materialColor );
 				quadBG.position.z = -500;
diff --git a/examples/webgl_postprocessing_dof.html b/examples/webgl_postprocessing_dof.html
index 1c1eb8e6..76cf8df7 100644
--- a/examples/webgl_postprocessing_dof.html
+++ b/examples/webgl_postprocessing_dof.html
@@ -102,9 +102,9 @@
 
 				if( singleMaterial ) zmaterial = [ cubeMaterial ];
 
-				//var geo = new THREE.Cube( 1, 1, 1 );
-				//var geo = new THREE.Icosahedron( 2 );
-				var geo = new THREE.Sphere( 1, 20, 10 );
+				//var geo = new THREE.CubeGeometry( 1, 1, 1 );
+				//var geo = new THREE.IcosahedronGeometry( 2 );
+				var geo = new THREE.SphereGeometry( 1, 20, 10 );
 
 				var start = new Date().getTime();
 
@@ -259,7 +259,7 @@
 
 				} );
 
-				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialBokeh );
+				postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialBokeh );
 				postprocessing.quad.position.z = - 500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
diff --git a/examples/webgl_ribbons.html b/examples/webgl_ribbons.html
index eca5acdd..a2148243 100644
--- a/examples/webgl_ribbons.html
+++ b/examples/webgl_ribbons.html
@@ -270,7 +270,7 @@
 
 				} );
 
-				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
 				postprocessing.quad.position.z = -500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
diff --git a/examples/webgl_rtt.html b/examples/webgl_rtt.html
index f258d3d2..09c9b3de 100644
--- a/examples/webgl_rtt.html
+++ b/examples/webgl_rtt.html
@@ -150,7 +150,7 @@
 
 				// var mt = new THREE.MeshBasicMaterial( { color:0xffffff, map: ImageUtils.loadTexture( "textures/land_ocean_ice_cloud_2048.jpg" ) } );
 
-				var plane = new THREE.Plane( window.innerWidth, window.innerHeight );
+				var plane = new THREE.PlaneGeometry( window.innerWidth, window.innerHeight );
 
 				quad = new THREE.Mesh( plane, material );
 				quad.position.z = -100;
@@ -164,7 +164,7 @@
 				sceneScreen.addObject( quad );
 
 				var n = 5,
-					geometry = new THREE.Sphere( 10, 64, 32 ),
+					geometry = new THREE.SphereGeometry( 10, 64, 32 ),
 					material2 = new THREE.MeshLambertMaterial( { color:0xffffff, map: rtTexture } );
 					//material2 = new THREE.MeshBasicMaterial( { color:0xffffff, map: rtTexture } );
 
diff --git a/examples/webgl_sandbox.html b/examples/webgl_sandbox.html
index 3fac70f2..81b5f275 100644
--- a/examples/webgl_sandbox.html
+++ b/examples/webgl_sandbox.html
@@ -102,30 +102,37 @@
 		
 		
 		
-		
-		
+		
 		
 		
 		
 		
+		
+		
 		
 		
 		
-		
-		
-		
-		
-		
-		
-		
-		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
+		
 		
 		
 		
 		
 		
+		
 		
 		
+		
+		
 
 		
 		
@@ -159,7 +166,7 @@
 				scene = new THREE.Scene();
 				scene.fog = new THREE.Fog( 0xffffff, 1, 10000 );
 
-				var geometry = new THREE.Sphere( 50, 32, 16 );
+				var geometry = new THREE.SphereGeometry( 50, 32, 16 );
 
 				var uniforms = THREE.ShaderUtils.lib[ 'basic' ].uniforms;
 				var vertexShader = THREE.ShaderUtils.lib[ 'basic' ].vertexShader;
diff --git a/examples/webgl_scene_test.html b/examples/webgl_scene_test.html
index e041589e..12ed7e8a 100644
--- a/examples/webgl_scene_test.html
+++ b/examples/webgl_scene_test.html
@@ -359,7 +359,7 @@
 				var object, geometry, material, light, count = 500, range = 200;
 
 				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
-				geometry = new THREE.Cube( 5, 5, 5 );
+				geometry = new THREE.CubeGeometry( 5, 5, 5 );
 
 				for( var i = 0; i < count; i++ ) {
 
diff --git a/examples/webgl_scene_test_blender.html b/examples/webgl_scene_test_blender.html
index 74191c9c..b0614148 100644
--- a/examples/webgl_scene_test_blender.html
+++ b/examples/webgl_scene_test_blender.html
@@ -324,7 +324,7 @@
 				var object, geometry, material, light, count = 500, range = 200;
 
 				material = new THREE.MeshLambertMaterial( { color:0xffffff } );
-				geometry = new THREE.Cube( 5, 5, 5 );
+				geometry = new THREE.CubeGeometry( 5, 5, 5 );
 
 				for( var i = 0; i < count; i++ ) {
 
diff --git a/examples/webgl_shader.html b/examples/webgl_shader.html
index 0facee39..434bb11c 100644
--- a/examples/webgl_shader.html
+++ b/examples/webgl_shader.html
@@ -125,7 +125,7 @@
 
 					} );
 
-				mesh = new THREE.Mesh( new THREE.Plane( 2, 2 ), material );
+				mesh = new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), material );
 				scene.addObject( mesh );
 
 				renderer = new THREE.WebGLRenderer();
diff --git a/examples/webgl_shader2.html b/examples/webgl_shader2.html
index 3f185123..ed0f5e75 100644
--- a/examples/webgl_shader2.html
+++ b/examples/webgl_shader2.html
@@ -228,7 +228,7 @@
 
 					mlib[ i ] = material;
 
-					mesh = new THREE.Mesh( new THREE.Cube( size, size, size, 1, 1, 1, [ mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ] ], false ), new THREE.MeshFaceMaterial() );
+					mesh = new THREE.Mesh( new THREE.CubeGeometry( size, size, size, 1, 1, 1, [ mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ], mlib[ i ] ], false ), new THREE.MeshFaceMaterial() );
 					mesh.position.x = i - ( params.length - 1 ) / 2;
 					mesh.position.y = i % 2 - 0.5;
 					scene.addObject( mesh );
diff --git a/examples/webgl_shader_lava.html b/examples/webgl_shader_lava.html
index 0cf00ee9..6338f9a1 100644
--- a/examples/webgl_shader_lava.html
+++ b/examples/webgl_shader_lava.html
@@ -163,7 +163,7 @@
 
 				} );
 
-				mesh = new THREE.Mesh( new THREE.Torus( size, 0.3, 30, 30 ), [ material /*, new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 2 } ) */ ] );
+				mesh = new THREE.Mesh( new THREE.TorusGeometry( size, 0.3, 30, 30 ), [ material /*, new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 2 } ) */ ] );
 				mesh.position.x = 0;
 				mesh.position.y = 0;
 				mesh.rotation.x = 0.3;
@@ -257,7 +257,7 @@
 				postprocessing.materialFilm.uniforms.sIntensity.value = 0.95;
 				postprocessing.materialFilm.uniforms.sCount.value = 2048;
 
-				postprocessing.quad = new THREE.Mesh( new THREE.Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad = new THREE.Mesh( new THREE.PlaneGeometry( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
 				postprocessing.quad.position.z = - 500;
 				postprocessing.scene.addObject( postprocessing.quad );
 
diff --git a/examples/webgl_stencil.html b/examples/webgl_stencil.html
index 9ac76338..c2bd1a20 100644
--- a/examples/webgl_stencil.html
+++ b/examples/webgl_stencil.html
@@ -51,7 +51,7 @@
 
 				// world
 
-				var cube = new THREE.Cube( 300, 300, 10 );
+				var cube = new THREE.CubeGeometry( 300, 300, 10 );
 				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
 				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
 				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
@@ -77,10 +77,10 @@
 
 				// moving objects
 
-				var cube = new THREE.Cube( 40, 40, 40 );
-				var torus = new THREE.Torus( 40, 10 );
-				var sphere = new THREE.Sphere( 40 );
-				var cylinder = new THREE.Cylinder( 10, 10, 20, 40, 0, 0 );
+				var cube = new THREE.CubeGeometry( 40, 40, 40 );
+				var torus = new THREE.TorusGeometry( 40, 10 );
+				var sphere = new THREE.SphereGeometry( 40 );
+				var cylinder = new THREE.CylinderGeometry( 10, 10, 20, 40, 0, 0 );
 				mesh = new THREE.Mesh( torus, material1 );
 				scene.addChild( mesh );
 
@@ -98,7 +98,7 @@
 				light.position.set( 0, 1, 0 );
 				scene.addChild( light );
 
-				var cube = new THREE.Sphere( 5 );
+				var cube = new THREE.SphereGeometry( 5 );
 				lightCube = new THREE.Mesh( cube, material2 );
 				scene.addChild( lightCube );
 
diff --git a/examples/webgl_stencilLensFlare.html b/examples/webgl_stencilLensFlare.html
index 8b6b3f5b..0d5d5275 100644
--- a/examples/webgl_stencilLensFlare.html
+++ b/examples/webgl_stencilLensFlare.html
@@ -50,7 +50,7 @@
 
 				// world
 
-				var cube = new THREE.Cube( 300, 300, 10 );
+				var cube = new THREE.CubeGeometry( 300, 300, 10 );
 				var material0 = new THREE.MeshPhongMaterial( { color:0xff00ff } );
 				var material1 = new THREE.MeshLambertMaterial( { color:0x00ff00 } );
 				var material2 = new THREE.MeshLambertMaterial( { color:0x0000ff } );
@@ -76,10 +76,10 @@
 
 				// moving objects
 
-				var cube = new THREE.Cube( 40, 40, 40 );
-				var torus = new THREE.Torus( 40, 10 );
-				var sphere = new THREE.Sphere( 40 );
-				var cylinder = new THREE.Cylinder( 10, 10, 20, 40, 0, 0 );
+				var cube = new THREE.CubeGeometry( 40, 40, 40 );
+				var torus = new THREE.TorusGeometry( 40, 10 );
+				var sphere = new THREE.SphereGeometry( 40 );
+				var cylinder = new THREE.CylinderGeometry( 10, 10, 20, 40, 0, 0 );
 				mesh = new THREE.Mesh( torus, material1 );
 				scene.addChild( mesh );
 
@@ -102,7 +102,7 @@
 				scene.addChild( light );
 
 
-				var cube = new THREE.Sphere( 2 );
+				var cube = new THREE.SphereGeometry( 2 );
 				lightCube = new THREE.Mesh( cube, material2 );
 				lightCube.visible = false;
 				scene.addChild( lightCube );
diff --git a/examples/webgl_text.html b/examples/webgl_text.html
deleted file mode 100644
index 04c5dcd1..00000000
--- a/examples/webgl_text.html
+++ /dev/null
@@ -1,651 +0,0 @@
-
-
-	
-		three.js webgl - geometry - text
-		
-		
-		
-	
-	
-
-		
- three.js - procedural 3D text by zz85 & alteredq - (fonts from typeface.js and Droid) -
type to enter new text, drag to spin the text -
change color, - change font, - change weight, - change postprocessing, - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/webgl_trackballcamera_earth.html b/examples/webgl_trackballcamera_earth.html index 2255efcb..3b82a64f 100644 --- a/examples/webgl_trackballcamera_earth.html +++ b/examples/webgl_trackballcamera_earth.html @@ -170,7 +170,7 @@ // planet - geometry = new THREE.Sphere( radius, 100, 50 ); + geometry = new THREE.SphereGeometry( radius, 100, 50 ); geometry.computeTangents(); meshPlanet = new THREE.Mesh( geometry, materialNormalMap ); diff --git a/src/extras/SceneUtils.js b/src/extras/SceneUtils.js index c7990a25..05142232 100644 --- a/src/extras/SceneUtils.js +++ b/src/extras/SceneUtils.js @@ -33,7 +33,7 @@ THREE.SceneUtils = { } ), - mesh = new THREE.Mesh( new THREE.Cube( size, size, size, 1, 1, 1, null, true ), material ); + mesh = new THREE.Mesh( new THREE.CubeGeometry( size, size, size, 1, 1, 1, null, true ), material ); scene.addObject( mesh ); return mesh; diff --git a/src/extras/cameras/PathCamera.js b/src/extras/cameras/PathCamera.js index d19c0137..3f555845 100644 --- a/src/extras/cameras/PathCamera.js +++ b/src/extras/cameras/PathCamera.js @@ -281,7 +281,7 @@ THREE.PathCamera = function ( parameters ) { parent.addChild( particleObj ); var waypoint, - geo = new THREE.Sphere( 1, 16, 8 ), + geo = new THREE.SphereGeometry( 1, 16, 8 ), mat = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); for ( i = 0; i < spline.points.length; i++ ) { @@ -310,8 +310,8 @@ THREE.PathCamera = function ( parameters ) { var dummyParentMaterial = new THREE.MeshLambertMaterial( { color: 0x0077ff } ), dummyChildMaterial = new THREE.MeshLambertMaterial( { color: 0x00ff00 } ), - dummyParentGeo = new THREE.Cube( 10, 10, 20 ), - dummyChildGeo = new THREE.Cube( 2, 2, 10 ); + dummyParentGeo = new THREE.CubeGeometry( 10, 10, 20 ), + dummyChildGeo = new THREE.CubeGeometry( 2, 2, 10 ); this.animationParent = new THREE.Mesh( dummyParentGeo, dummyParentMaterial ); diff --git a/src/extras/geometries/Cube.js b/src/extras/geometries/CubeGeometry.js similarity index 94% rename from src/extras/geometries/Cube.js rename to src/extras/geometries/CubeGeometry.js index 121de59c..39c34ab5 100644 --- a/src/extras/geometries/Cube.js +++ b/src/extras/geometries/CubeGeometry.js @@ -3,7 +3,7 @@ * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Cube.as */ -THREE.Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, flipped, sides ) { +THREE.CubeGeometry = function ( width, height, depth, segmentsWidth, segmentsHeight, segmentsDepth, materials, flipped, sides ) { THREE.Geometry.call( this ); @@ -182,5 +182,5 @@ THREE.Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, seg }; -THREE.Cube.prototype = new THREE.Geometry(); -THREE.Cube.prototype.constructor = THREE.Cube; +THREE.CubeGeometry.prototype = new THREE.Geometry(); +THREE.CubeGeometry.prototype.constructor = THREE.CubeGeometry; diff --git a/src/extras/geometries/Cylinder.js b/src/extras/geometries/CylinderGeometry.js similarity index 91% rename from src/extras/geometries/Cylinder.js rename to src/extras/geometries/CylinderGeometry.js index e6930dcb..8f21012d 100644 --- a/src/extras/geometries/Cylinder.js +++ b/src/extras/geometries/CylinderGeometry.js @@ -4,7 +4,7 @@ * @author fuzzthink */ -THREE.Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) { +THREE.CylinderGeometry = function ( numSegs, topRad, botRad, height, topOffset, botOffset ) { THREE.Geometry.call( this ); @@ -119,5 +119,5 @@ THREE.Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffse }; -THREE.Cylinder.prototype = new THREE.Geometry(); -THREE.Cylinder.prototype.constructor = THREE.Cylinder; +THREE.CylinderGeometry.prototype = new THREE.Geometry(); +THREE.CylinderGeometry.prototype.constructor = THREE.CylinderGeometry; diff --git a/src/extras/geometries/Icosahedron.js b/src/extras/geometries/IcosahedronGeometry.js similarity index 95% rename from src/extras/geometries/Icosahedron.js rename to src/extras/geometries/IcosahedronGeometry.js index 3abf1940..fb1e836f 100644 --- a/src/extras/geometries/Icosahedron.js +++ b/src/extras/geometries/IcosahedronGeometry.js @@ -6,7 +6,7 @@ * so it draws the entire texture on the seam-faces, I think... */ -THREE.Icosahedron = function ( subdivisions ) { +THREE.IcosahedronGeometry = function ( subdivisions ) { var scope = this; var tempScope = new THREE.Geometry(); @@ -173,5 +173,5 @@ THREE.Icosahedron = function ( subdivisions ) { } -THREE.Icosahedron.prototype = new THREE.Geometry(); -THREE.Icosahedron.prototype.constructor = THREE.Icosahedron; +THREE.IcosahedronGeometry.prototype = new THREE.Geometry(); +THREE.IcosahedronGeometry.prototype.constructor = THREE.IcosahedronGeometry; diff --git a/src/extras/geometries/Lathe.js b/src/extras/geometries/LatheGeometry.js similarity index 89% rename from src/extras/geometries/Lathe.js rename to src/extras/geometries/LatheGeometry.js index f2bb47cc..1461583b 100644 --- a/src/extras/geometries/Lathe.js +++ b/src/extras/geometries/LatheGeometry.js @@ -2,7 +2,7 @@ * @author astrodud / http://astrodud.isgreat.org/ */ -THREE.Lathe = function ( points, steps, angle ) { +THREE.LatheGeometry = function ( points, steps, angle ) { THREE.Geometry.call( this ); @@ -67,5 +67,5 @@ THREE.Lathe = function ( points, steps, angle ) { }; -THREE.Lathe.prototype = new THREE.Geometry(); -THREE.Lathe.prototype.constructor = THREE.Lathe; +THREE.LatheGeometry.prototype = new THREE.Geometry(); +THREE.LatheGeometry.prototype.constructor = THREE.LatheGeometry; diff --git a/src/extras/geometries/Plane.js b/src/extras/geometries/PlaneGeometry.js similarity index 86% rename from src/extras/geometries/Plane.js rename to src/extras/geometries/PlaneGeometry.js index 17cc4687..09fda51a 100644 --- a/src/extras/geometries/Plane.js +++ b/src/extras/geometries/PlaneGeometry.js @@ -3,7 +3,7 @@ * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Plane.as */ -THREE.Plane = function ( width, height, segmentsWidth, segmentsHeight ) { +THREE.PlaneGeometry = function ( width, height, segmentsWidth, segmentsHeight ) { THREE.Geometry.call( this ); @@ -57,5 +57,5 @@ THREE.Plane = function ( width, height, segmentsWidth, segmentsHeight ) { }; -THREE.Plane.prototype = new THREE.Geometry(); -THREE.Plane.prototype.constructor = THREE.Plane; +THREE.PlaneGeometry.prototype = new THREE.Geometry(); +THREE.PlaneGeometry.prototype.constructor = THREE.PlaneGeometry; diff --git a/src/extras/geometries/Sphere.js b/src/extras/geometries/SphereGeometry.js similarity index 91% rename from src/extras/geometries/Sphere.js rename to src/extras/geometries/SphereGeometry.js index f9e6bc60..97347db8 100644 --- a/src/extras/geometries/Sphere.js +++ b/src/extras/geometries/SphereGeometry.js @@ -3,11 +3,12 @@ * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Sphere.as */ -THREE.Sphere = function ( radius, segmentsWidth, segmentsHeight ) { +THREE.SphereGeometry = function ( radius, segmentsWidth, segmentsHeight ) { THREE.Geometry.call( this ); - var gridX = segmentsWidth || 8, + var radius = radius || 50, + gridX = segmentsWidth || 8, gridY = segmentsHeight || 6; var i, j, pi = Math.PI; @@ -111,5 +112,5 @@ THREE.Sphere = function ( radius, segmentsWidth, segmentsHeight ) { }; -THREE.Sphere.prototype = new THREE.Geometry(); -THREE.Sphere.prototype.constructor = THREE.Sphere; +THREE.SphereGeometry.prototype = new THREE.Geometry(); +THREE.SphereGeometry.prototype.constructor = THREE.SphereGeometry; diff --git a/src/extras/geometries/Text.js b/src/extras/geometries/Text.js deleted file mode 100644 index 2d4b9700..00000000 --- a/src/extras/geometries/Text.js +++ /dev/null @@ -1,1133 +0,0 @@ -/** - * @author zz85 / http://www.lab4games.net/zz85/blog - * @author alteredq / http://alteredqualia.com/ - * - * For creating 3D text geometry in three.js - * - * Text = 3D Text - * - * parameters = { - * size: size of the text - * height: thickness to extrude text, - * curveSegments: number of points on the curves, - * font: font name, - * } - * - * It utilizes techniques used in - * - * typeface.js and canvastext - * For converting fonts and rendering with javascript - * http://typeface.neocracy.org - * - * Triangulation ported from AS3 - * Simple Polygon Triangulation - * http://actionsnippet.com/?p=1462 - * - * A Method to triangulate shapes with holes - * http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/ - * - */ - -THREE.Text = function ( text, parameters ) { - - THREE.Geometry.call( this ); - - this.parameters = parameters || {}; - this.set( text ); - -}; - -THREE.Text.prototype = new THREE.Geometry(); -THREE.Text.prototype.constructor = THREE.Text; - -THREE.Text.prototype.set = function ( text, parameters ) { - - this.text = text; - var parameters = parameters || this.parameters; - - var size = parameters.size !== undefined ? parameters.size : 100; - var height = parameters.height !== undefined ? parameters.height : 50; - var curveSegments = parameters.curveSegments !== undefined ? parameters.curveSegments: 4; - - var font = parameters.font !== undefined ? parameters.font : "helvetiker"; - var weight = parameters.weight !== undefined ? parameters.weight : "normal"; - var style = parameters.style !== undefined ? parameters.style : "normal"; - var bezelThickness = 10; - var bezelSize = 8; - var needsChezel = true; - - THREE.FontUtils.size = size; - THREE.FontUtils.divisions = curveSegments; - - THREE.FontUtils.face = font; - THREE.FontUtils.weight = weight; - THREE.FontUtils.style = style; - THREE.FontUtils.bezelSize = bezelSize; - - // Get a Font data json object - - var data = THREE.FontUtils.drawText( text ); - - //console.log("data", data); - - var vertices = data.points; - var faces = data.faces; - var contour = data.contour; - var bezelPoints = data.bezel; - - var scope = this; - - scope.vertices = []; - scope.faces = []; - - //console.log(this); - - var i, - vert, vlen = vertices.length, - face, flen = faces.length, - bezelPt, blen = bezelPoints.length; - - // Back facing Vertices - for ( i = 0; i < vlen; i++ ) { - - vert = vertices[ i ]; - v( vert.x, vert.y, 0 ); - - } - - // Front faces Vertices - for ( i = 0; i < vlen; i++ ) { - - vert = vertices[ i ]; - v( vert.x, vert.y, height ); - - } - - if (needsChezel) { - - for ( i = 0; i < blen; i++ ) { - - bezelPt = bezelPoints[ i ]; - v( bezelPt.x, bezelPt.y, bezelThickness ); - - } - - for ( i = 0; i < blen; i++ ) { - - bezelPt = bezelPoints[ i ]; - v( bezelPt.x, bezelPt.y, height - bezelThickness ); - - } - - - } - - // Bottom faces - - for ( i = 0; i < flen; i++ ) { - - face = faces[ i ]; - f3( face[ 2 ], face[ 1 ], face[ 0 ] ); - - } - - // Top faces - - for ( i = 0; i < flen; i++ ) { - - face = faces[ i ]; - f3( face[ 0 ] + vlen, face[ 1 ] + vlen, face[ 2 ] + vlen ); - - } - - var lastV; - var j, k, l, m; - - if (needsChezel) { - - i = bezelPoints.length; - - while ( --i > 0 ) { - - if ( !lastV ) { - - lastV = contour[ i ]; - - } else if ( lastV.equals( contour[ i ] ) ) { - - // We reached the last point of a closed loop - lastV = null; - continue; - - } - - l = vlen*2 + i; - m = vlen*2 + i - 1; - - // Create faces for the z-sides of the text - f4( l, m, m+blen, l+blen ); - - for ( j = 0; j < vlen; j++ ) { - - if ( vertices[ j ].equals( contour[ i ] ) ) break; - - } - - for ( k = 0; k < vlen; k++ ) { - - if ( vertices[ k ].equals( contour[ i - 1 ] ) ) break; - - } - - // Create faces for the z-sides of the text - f4( j, k, m, l ); - f4( l + blen, m + blen, k+vlen, j+vlen ); - - - - } - - - } else { - - i = contour.length; - - while ( --i > 0 ) { - - if ( !lastV ) { - - lastV = contour[ i ]; - - } else if ( lastV.equals( contour[ i ] ) ) { - - // We reached the last point of a closed loop - lastV = null; - continue; - - } - - for ( j = 0; j < vlen; j++ ) { - - if ( vertices[ j ].equals( contour[ i ] ) ) break; - - } - - for ( k = 0; k < vlen; k++ ) { - - if ( vertices[ k ].equals( contour[ i - 1 ] ) ) break; - - } - - // Create faces for the z-sides of the text - f4( j, k, k+vlen, j+vlen ); - - } - } - - - // UVs to be added - - this.computeCentroids(); - this.computeFaceNormals(); - //this.computeVertexNormals(); - - function v( x, y, z ) { - - scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); - - } - - function f3( a, b, c ) { - - scope.faces.push( new THREE.Face3( a, b, c) ); - - } - - function f4( a, b, c, d ) { - - scope.faces.push( new THREE.Face4( a, b, c, d) ); - - } - - -}; - -THREE.FontUtils = { - - faces : {}, - - // Just for now. face[weight][style] - - face : "helvetiker", - weight: "normal", - style : "normal", - size : 150, - divisions : 10, - - getFace : function() { - - return this.faces[ this.face ][ this.weight ][ this.style ]; - - }, - - loadFace : function( data ) { - - var family = data.familyName.toLowerCase(); - - var ThreeFont = this; - - ThreeFont.faces[ family ] = ThreeFont.faces[ family ] || {}; - - ThreeFont.faces[ family ][ data.cssFontWeight ] = ThreeFont.faces[ family ][ data.cssFontWeight ] || {}; - ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data; - - var face = ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data; - - return data; - - }, - - - extractPoints : function( points, characters ) { - - // Quick exit - - if ( points.length < 3 ) { - - //throw "not valid polygon"; - - console.log( "not valid polygon" ); - - return { - - points: points, - faces: [] - - }; - - } - - // Try to split shapes and holes. - - var p, point, shape, - all, - isolatedShapes = []; - - // Use a quick hashmap for locating duplicates - - for (var c in characters) { - points = characters[c]; - - - all = []; - // Use a quick hashmap for locating duplicates - for (var p in points) { - point = points[p]; - all.push(point.x +","+ point.y); - } - - var firstIndex, firstPt, endPt, holes; - - // We check the first loop whether its CW or CCW direction to determine - // whether its shapes or holes first - endPt = all.slice(1).indexOf(all[0]); - var shapesFirst = this.Triangulate.area(points.slice(0, endPt+1))<0; - - //console.log(points.length, "shapesFirst",shapesFirst); - - holes = []; - endPt = -1; - - while (endPt < all.length) { - firstIndex = endPt+1; - firstPt = all[firstIndex]; - endPt = all.slice(firstIndex+1).indexOf(firstPt) + firstIndex; - if (endPt <= firstIndex ) break; - - var contours = points.slice(firstIndex, endPt+1); - - if (shapesFirst) { - if (this.Triangulate.area(contours)<0) { - // we got new isolated shape - if (firstIndex>0) { - isolatedShapes.push({shape: shape, holes: holes}); - } - // Save the old shapes, then work on new additional seperated shape - - shape = contours; - holes = []; - - } else { - holes.push(contours); - } - } else { - if (this.Triangulate.area(contours)<0) { - - isolatedShapes.push({shape: contours, holes: holes}); - holes = []; - - } else { - holes.push(contours); - } - } - endPt++; - - } - - if (shapesFirst) { - 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 with - // 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 prevShapeVert, nextShapeVert, - prevHoleVert, nextHoleVert, - holeIndex, shapeIndex, - shapeId, shapeGroup, - h, h2, - hole, shortest, d, - p, pts1, pts2, - tmpShape1, tmpShape2, - tmpHole1, tmpHole2, - verts = []; - - for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { - - shapeGroup = isolatedShapes[ shapeId ]; - - shape = shapeGroup.shape; - holes = shapeGroup.holes; - - for ( h = 0; h < holes.length; h++ ) { - - // we slice to each hole when neccessary - - hole = holes[ h ]; - shortest = Number.POSITIVE_INFINITY; - - for ( h2 = 0; h2 < hole.length; h2++ ) { - - pts1 = hole[ h2 ]; - - for ( p = 0; p < shape.length; p++ ) { - - pts2 = shape[ p ]; - d = pts1.distanceTo( pts2 ); - - if ( d < shortest ) { - - shortest = d; - holeIndex = h2; - shapeIndex = p; - - } - - } - - } - - - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - - - var areaapts = []; - areaapts.push( hole[ holeIndex ] ); - areaapts.push( shape[ shapeIndex ] ); - areaapts.push( shape[ prevShapeVert ] ); - - var areaa = this.Triangulate.area(areaapts); - - var areabpts = []; - areabpts.push( hole[ holeIndex ] ); - areabpts.push( hole[ prevHoleVert ] ); - areabpts.push( shape[ shapeIndex ] ); - - var areab = this.Triangulate.area(areabpts); - - - var shapeOffset =1; - var holeOffset = -1; - - var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex; - shapeIndex += shapeOffset; - holeIndex += holeOffset; - - if (shapeIndex<0) { shapeIndex += shape.length; } - shapeIndex %= shape.length; - if (holeIndex<0) { holeIndex += hole.length; } - holeIndex %= shape.length; - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - - - areaapts = []; - areaapts.push( hole[ holeIndex ] ); - areaapts.push( shape[ shapeIndex ] ); - areaapts.push( shape[ prevShapeVert ] ); - - var areaa2 = this.Triangulate.area(areaapts); - - areabpts = []; - areabpts.push( hole[ holeIndex ] ); - areabpts.push( hole[ prevHoleVert ] ); - areabpts.push( shape[ shapeIndex ] ); - - var areab2 = this.Triangulate.area(areabpts); - - if ( (areaa+areab) > (areaa2+areab2) ) { - shapeIndex = oldShapeIndex; - holeIndex = oldHoleIndex ; - - - if (shapeIndex<0) { shapeIndex += shape.length; } - shapeIndex %= shape.length; - if (holeIndex<0) { holeIndex += hole.length; } - holeIndex %= shape.length; - - - prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; - nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; - - prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; - nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; - } - - tmpShape1 = shape.slice( 0, shapeIndex ); - tmpShape2 = shape.slice( shapeIndex ); - tmpHole1 = hole.slice( holeIndex ); - tmpHole2 = hole.slice( 0, holeIndex ); - - verts.push( hole[ holeIndex ] ); - verts.push( shape[ shapeIndex ] ); - verts.push( shape[ prevShapeVert ] ); - - verts.push( hole[ holeIndex ] ); - verts.push( hole[ prevHoleVert ] ); - verts.push( shape[ shapeIndex ] ); - - - shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 ); - - } - - shapeGroup.shape = shape; - - } - - var points = []; - var triangulatedVertices = []; - var lastTriangles = 0; - - for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { - - shapeGroup = isolatedShapes[ shapeId ]; - - shape = shapeGroup.shape; - points = points.concat( shape ); - - var triangles = THREE.FontUtils.Triangulate( shape, true ); - - // We need to offset vertex indices for faces - - for ( var v = 0; v < triangles.length; v++ ) { - - var face = triangles[ v ]; - - face[ 0 ] += lastTriangles; - face[ 1 ] += lastTriangles; - face[ 2 ] += lastTriangles; - - } - - triangulatedVertices = triangulatedVertices.concat( triangles ); - lastTriangles += shape.length; - - } - - - // Now we push the "cut" vertices back to the triangulated indices. - - //console.log("we have verts.length",verts.length,verts); - - var v, j, k, l, found, face; - - for ( v = 0; v < verts.length / 3; v++ ) { - - face = []; - - for ( k = 0; k < 3; k++ ) { - - found = false; - - for ( j=0; j < points.length && !found; j++ ) { - - l = v * 3 + k; - - if ( points[ j ].equals( verts[ l ] ) ) { - - face.push( j ); - found = true; - - } - - } - - // you would not wish to reach this point of code, something went wrong - - if ( !found ) { - - points.push( verts[ l ] ); - face.push( points.length - 1 ); - - console.log( "not found" ) - - } - - } - - triangulatedVertices.push( face ); - - } - - - //console.log("triangles", triangulatedVertices.length, "points", points); - - return { - - points: points, - faces: triangulatedVertices - - }; - - }, - - drawText : function( text ) { - - var characterpts = [], pts = []; - - // RenderText - - var i, p, - face = this.getFace(), - scale = this.size / face.resolution, - offset = 0, - chars = String( text ).split( '' ), - length = chars.length; - - for ( i = 0; i < length; i++ ) { - - var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset ); - offset += ret.offset; - characterpts.push(ret.points); - pts = pts.concat(ret.points); - - } - - // get the width - - var width = offset / 2; - - for ( p = 0; p < pts.length; p++ ) { - - pts[ p ].x -= width; - - } - - var extract = this.extractPoints( pts, characterpts ); - - extract.contour = pts; - - //this.bezelSize; - var bezelPoints = []; - - - - var centroids = [], forCentroids = [], expandOutwards = [], sum = new THREE.Vector2(), lastV; - - i = pts.length; - - while ( --i >= 0 ) { - if ( !lastV ) { - - lastV = pts[ i ]; - - } else if ( lastV.equals( pts[ i ] ) ) { - - // We reached the last point of a closed loop - lastV = null; - var bool = this.Triangulate.area(forCentroids) > 0; - expandOutwards.push(bool); - centroids.push(sum.divideScalar(forCentroids.length)); - forCentroids = []; - - sum = new THREE.Vector2(); - continue; - - } - - sum.addSelf(pts[i]); - forCentroids.push(pts[i]); - - } - - - i = pts.length; - p = 0; - var pt, centroid ; - var dirV, adj; - while ( --i >= 0 ) { - pt = pts[ i ]; - centroid = centroids[p]; - - - - dirV = pt.clone().subSelf(centroid); - adj = this.bezelSize / dirV.length(); - - if (expandOutwards[p]) { - adj += 1; - } else { - adj = 1 - adj; - } - - adj = dirV.multiplyScalar(adj).addSelf(centroid); - bezelPoints.unshift(adj); - - - if ( !lastV ) { - - lastV = pts[ i ]; - - } else if ( lastV.equals( pts[ i ] ) ) { - - // We reached the last point of a closed loop - lastV = null; - p++; - continue; - - } - - - } - - - /* - for ( p = 0; p < pts.length; p++ ) { - pt = pts[ p ]; - bezelPoints.push (new THREE.Vector2(pt.x + this.bezelSize, pt.y + this.bezelSize)); - - }*/ - - - extract.bezel = bezelPoints; - - return extract; - - }, - - - // Bezier Curves formulas obtained from - // http://en.wikipedia.org/wiki/B%C3%A9zier_curve - - // Quad Bezier Functions - - b2p0: function ( t, p ) { - - var k = 1 - t; - return k * k * p; - - }, - - b2p1: function ( t, p ) { - - return 2 * ( 1 - t ) * t * p; - - }, - - b2p2: function ( t, p ) { - - return t * t * p; - - }, - - b2: function ( t, p0, p1, p2 ) { - - return this.b2p0( t, p0 ) + this.b2p1( t, p1 ) + this.b2p2( t, p2 ); - - }, - - // Cubic Bezier Functions - - b3p0: function ( t, p ) { - - var k = 1 - t; - return k * k * k * p; - - }, - - b3p1: function ( t, p ) { - - var k = 1 - t; - return 3 * k * k * t * p; - - }, - - b3p2: function ( t, p ) { - - var k = 1 - t; - return 3 * k * t * t * p; - - }, - - b3p3: function ( t, p ) { - - return t * t * t * p; - - }, - - b3: function ( t, p0, p1, p2, p3 ) { - - return this.b3p0( t, p0 ) + this.b3p1( t, p1 ) + this.b3p2( t, p2 ) + this.b3p3( t, p3 ); - - }, - - - extractGlyphPoints : function( c, face, scale, offset ) { - var pts = []; - var i, i2, - outline, action, length, - scaleX, scaleY, - x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, - laste, - glyph = face.glyphs[ c ] || face.glyphs[ ctxt.options.fallbackCharacter ]; - - if ( !glyph ) return; - - if ( glyph.o ) { - - outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) ); - length = outline.length; - - scaleX = scale; - scaleY = scale; - - for ( i = 0; i < length; ) { - - action = outline[ i++ ]; - - switch( action ) { - - case 'm': - - // Move To - - x = outline[ i++ ] * scaleX + offset; - y = outline[ i++ ] * scaleY; - pts.push( new THREE.Vector2( x, y ) ); - break; - - case 'l': - - // Line To - - x = outline[ i++ ] * scaleX + offset; - y = outline[ i++ ] * scaleY; - pts.push( new THREE.Vector2( x, y ) ); - break; - - case 'q': - - // QuadraticCurveTo - - cpx = outline[ i++ ] * scaleX + offset; - cpy = outline[ i++ ] * scaleY; - cpx1 = outline[ i++ ] * scaleX + offset; - cpy1 = outline[ i++ ] * scaleY; - - laste = pts[ pts.length - 1 ]; - - if ( laste ) { - - cpx0 = laste.x; - cpy0 = laste.y; - - for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { - - var t = i2 / divisions; - var tx = THREE.FontUtils.b2( t, cpx0, cpx1, cpx ); - var ty = THREE.FontUtils.b2( t, cpy0, cpy1, cpy ); - pts.push( new THREE.Vector2( tx, ty ) ); - - } - - } - - break; - - case 'b': - - // Cubic Bezier Curve - - cpx = outline[ i++ ] * scaleX + offset; - cpy = outline[ i++ ] * scaleY; - cpx1 = outline[ i++ ] * scaleX + offset; - cpy1 = outline[ i++ ] * -scaleY; - cpx2 = outline[ i++ ] * scaleX + offset; - cpy2 = outline[ i++ ] * -scaleY; - - laste = pts[ pts.length - 1 ]; - - if ( laste ) { - - cpx0 = laste.x; - cpy0 = laste.y; - - for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { - - var t = i2 / divisions; - var tx = THREE.FontUtils.b3( t, cpx0, cpx1, cpx2, cpx ); - var ty = THREE.FontUtils.b3( t, cpy0, cpy1, cpy2, cpy ); - pts.push( new THREE.Vector2( tx, ty ) ); - - } - - } - - break; - - } - - } - } - - return { offset: glyph.ha*scale, points:pts }; - } - -}; - - - -/** - * This code is a quick port of code written in C++ which was submitted to - * flipcode.com by John W. Ratcliff // July 22, 2000 - * See original code and more information here: - * http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml - * - * ported to actionscript by Zevan Rosser - * www.actionsnippet.com - * - * ported to javascript by Joshua Koo - * http://www.lab4games.net/zz85/blog - * - */ - - -( function( namespace ) { - - var EPSILON = 0.0000000001; - - // takes in an contour array and returns - - var process = function( contour, indices ) { - - var n = contour.length; - - if ( n < 3 ) return null; - - var result = [], - verts = [], - vertIndices = []; - - /* we want a counter-clockwise polygon in verts */ - - var u, v, w; - - if ( area( contour ) > 0.0 ) { - - for ( v = 0; v < n; v++ ) verts[ v ] = v; - - } else { - - for ( v = 0; v < n; v++ ) verts[ v ] = ( n - 1 ) - v; - - } - - var nv = n; - - /* remove nv - 2 vertices, creating 1 triangle every time */ - - var count = 2 * nv; /* error detection */ - - for( v = nv - 1; nv > 2; ) { - - /* if we loop, it is probably a non-simple polygon */ - - if ( ( count-- ) <= 0 ) { - - //** Triangulate: ERROR - probable bad polygon! - - //throw ( "Warning, unable to triangulate polygon!" ); - //return null; - - console.log( "Warning, unable to triangulate polygon!" ); - - if ( indices ) return vertIndices; - return result; - - } - - /* three consecutive vertices in current polygon, */ - - u = v; if ( nv <= u ) u = 0; /* previous */ - v = u + 1; if ( nv <= v ) v = 0; /* new v */ - 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 ] ); - - vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] ); - - /* remove v from the remaining polygon */ - - for( s = v, t = v + 1; t < nv; s++, t++ ) { - - verts[ s ] = verts[ t ]; - - } - - nv--; - - /* reset error detection counter */ - - count = 2 * nv; - - } - - } - - if ( indices ) return vertIndices; - return result; - - }; - - // calculate area of the contour polygon - - var area = function ( contour ) { - - var n = contour.length; - var a = 0.0; - - for( var p = n - 1, q = 0; q < n; p = q++ ) { - - a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; - - } - - return a * 0.5; - - }; - - // see if p is inside triangle abc - - var insideTriangle = function( ax, ay, - bx, by, - cx, cy, - px, py ) { - - var aX, aY, bX, bY; - var cX, cY, apx, apy; - var bpx, bpy, cpx, cpy; - var cCROSSap, bCROSScp, aCROSSbp; - - aX = cx - bx; aY = cy - by; - bX = ax - cx; bY = ay - cy; - cX = bx - ax; cY = by - ay; - apx= px -ax; apy= py - ay; - bpx= px - bx; bpy= py - by; - cpx= px - cx; cpy= py - cy; - - aCROSSbp = aX*bpy - aY*bpx; - cCROSSap = cX*apy - cY*apx; - bCROSScp = bX*cpy - bY*cpx; - - return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) ); - - }; - - - var snip = function ( contour, u, v, w, n, verts ) { - - var p; - var ax, ay, bx, by; - var cx, cy, px, py; - - ax = contour[ verts[ u ] ].x; - ay = contour[ verts[ u ] ].y; - - bx = contour[ verts[ v ] ].x; - by = contour[ verts[ v ] ].y; - - cx = contour[ verts[ w ] ].x; - cy = contour[ verts[ w ] ].y; - - if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false; - - for ( p = 0; p < n; p++ ) { - - if( (p == u) || (p == v) || (p == w) ) continue; - - px = contour[ verts[ p ] ].x - py = contour[ verts[ p ] ].y - - if ( insideTriangle( ax, ay, bx, by, cx, cy, px, py ) ) return false; - - } - - return true; - - }; - - - namespace.Triangulate = process; - namespace.Triangulate.area = area; - - return namespace; - -})(THREE.FontUtils); - -// To use the typeface.js face files, hook up the API -window._typeface_js = { faces: THREE.FontUtils.faces, loadFace: THREE.FontUtils.loadFace }; diff --git a/src/extras/geometries/TextGeometry.js b/src/extras/geometries/TextGeometry.js new file mode 100644 index 00000000..b0eee419 --- /dev/null +++ b/src/extras/geometries/TextGeometry.js @@ -0,0 +1,1171 @@ +/** + * @author zz85 / http://www.lab4games.net/zz85/blog + * @author alteredq / http://alteredqualia.com/ + * + * For creating 3D text geometry in three.js + * + * Text = 3D Text + * + * parameters = { + * size: , // size of the text + * height: , // thickness to extrude text + * curveSegments: , // number of points on the curves + * + * font: , // font name + * weight: , // font weight (normal, bold) + * style: , // font style (normal, italics) + * + * bezelEnabled: , // turn on bezel + * bezelThickness: , // how deep into text bezel goes + * bezelSize: , // how far from text outline is bezel + * } + * + * It uses techniques used in + * + * typeface.js and canvastext + * For converting fonts and rendering with javascript + * http://typeface.neocracy.org + * + * Triangulation ported from AS3 + * Simple Polygon Triangulation + * http://actionsnippet.com/?p=1462 + * + * A Method to triangulate shapes with holes + * http://www.sakri.net/blog/2009/06/12/an-approach-to-triangulating-polygons-with-holes/ + * + */ + +THREE.TextGeometry = function ( text, parameters ) { + + THREE.Geometry.call( this ); + + this.parameters = parameters || {}; + this.set( text ); + +}; + +THREE.TextGeometry.prototype = new THREE.Geometry(); +THREE.TextGeometry.prototype.constructor = THREE.TextGeometry; + +THREE.TextGeometry.prototype.set = function ( text, parameters ) { + + this.text = text; + var parameters = parameters || this.parameters; + + var size = parameters.size !== undefined ? parameters.size : 100; + var height = parameters.height !== undefined ? parameters.height : 50; + var curveSegments = parameters.curveSegments !== undefined ? parameters.curveSegments: 4; + + var font = parameters.font !== undefined ? parameters.font : "helvetiker"; + var weight = parameters.weight !== undefined ? parameters.weight : "normal"; + var style = parameters.style !== undefined ? parameters.style : "normal"; + + var bezelThickness = parameters.bezelThickness !== undefined ? parameters.bezelThickness : 10; + var bezelSize = parameters.bezelSize !== undefined ? parameters.bezelSize : 8; + var bezelEnabled = parameters.bezelEnabled !== undefined ? parameters.bezelEnabled : false; + + THREE.FontUtils.size = size; + THREE.FontUtils.divisions = curveSegments; + + THREE.FontUtils.face = font; + THREE.FontUtils.weight = weight; + THREE.FontUtils.style = style; + + THREE.FontUtils.bezelSize = bezelSize; + + // Get a Font data json object + + var data = THREE.FontUtils.drawText( text ); + + //console.log("data", data); + + var vertices = data.points; + var faces = data.faces; + var contour = data.contour; + var bezelPoints = data.bezel; + + var scope = this; + + scope.vertices = []; + scope.faces = []; + + //console.log(this); + + var i, + vert, vlen = vertices.length, + face, flen = faces.length, + bezelPt, blen = bezelPoints.length; + + // Back facing vertices + + for ( i = 0; i < vlen; i++ ) { + + vert = vertices[ i ]; + v( vert.x, vert.y, 0 ); + + } + + // Front facing vertices + + for ( i = 0; i < vlen; i++ ) { + + vert = vertices[ i ]; + v( vert.x, vert.y, height ); + + } + + if ( bezelEnabled ) { + + for ( i = 0; i < blen; i++ ) { + + bezelPt = bezelPoints[ i ]; + v( bezelPt.x, bezelPt.y, bezelThickness ); + + } + + for ( i = 0; i < blen; i++ ) { + + bezelPt = bezelPoints[ i ]; + v( bezelPt.x, bezelPt.y, height - bezelThickness ); + + } + + } + + // Bottom faces + + for ( i = 0; i < flen; i++ ) { + + face = faces[ i ]; + f3( face[ 2 ], face[ 1 ], face[ 0 ] ); + + } + + // Top faces + + for ( i = 0; i < flen; i++ ) { + + face = faces[ i ]; + f3( face[ 0 ] + vlen, face[ 1 ] + vlen, face[ 2 ] + vlen ); + + } + + var lastV; + var j, k, l, m; + + if ( bezelEnabled ) { + + i = bezelPoints.length; + + while ( --i > 0 ) { + + if ( !lastV ) { + + lastV = contour[ i ]; + + } else if ( lastV.equals( contour[ i ] ) ) { + + // We reached the last point of a closed loop + + lastV = null; + continue; + + } + + l = vlen * 2 + i; + m = l - 1; + + // Create faces for the z-sides of the text + + f4( l, m, m + blen, l + blen ); + + for ( j = 0; j < vlen; j++ ) { + + if ( vertices[ j ].equals( contour[ i ] ) ) break; + + } + + for ( k = 0; k < vlen; k++ ) { + + if ( vertices[ k ].equals( contour[ i - 1 ] ) ) break; + + } + + // Create faces for the z-sides of the text + + f4( j, k, m, l ); + f4( l + blen, m + blen, k + vlen, j + vlen ); + + } + + } else { + + i = contour.length; + + while ( --i > 0 ) { + + if ( !lastV ) { + + lastV = contour[ i ]; + + } else if ( lastV.equals( contour[ i ] ) ) { + + // We reached the last point of a closed loop + + lastV = null; + continue; + + } + + for ( j = 0; j < vlen; j++ ) { + + if ( vertices[ j ].equals( contour[ i ] ) ) break; + + } + + for ( k = 0; k < vlen; k++ ) { + + if ( vertices[ k ].equals( contour[ i - 1 ] ) ) break; + + } + + // Create faces for the z-sides of the text + + f4( j, k, k + vlen, j + vlen ); + + } + } + + + // UVs to be added + + this.computeCentroids(); + this.computeFaceNormals(); + //this.computeVertexNormals(); + + function v( x, y, z ) { + + scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); + + } + + function f3( a, b, c ) { + + scope.faces.push( new THREE.Face3( a, b, c) ); + + } + + function f4( a, b, c, d ) { + + scope.faces.push( new THREE.Face4( a, b, c, d) ); + + } + + +}; + +THREE.FontUtils = { + + faces : {}, + + // Just for now. face[weight][style] + + face : "helvetiker", + weight: "normal", + style : "normal", + size : 150, + divisions : 10, + + getFace : function() { + + return this.faces[ this.face ][ this.weight ][ this.style ]; + + }, + + loadFace : function( data ) { + + var family = data.familyName.toLowerCase(); + + var ThreeFont = this; + + ThreeFont.faces[ family ] = ThreeFont.faces[ family ] || {}; + + ThreeFont.faces[ family ][ data.cssFontWeight ] = ThreeFont.faces[ family ][ data.cssFontWeight ] || {}; + ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data; + + var face = ThreeFont.faces[ family ][ data.cssFontWeight ][ data.cssFontStyle ] = data; + + return data; + + }, + + + extractPoints : function( points, characters ) { + + // Quick exit + + if ( points.length < 3 ) { + + //throw "not valid polygon"; + + console.log( "not valid polygon" ); + + return { + + points: points, + faces: [] + + }; + + } + + // Try to split shapes and holes. + + var p, point, shape, + all, + isolatedShapes = []; + + // Use a quick hashmap for locating duplicates + + for ( var c in characters ) { + + points = characters[ c ]; + + + all = []; + + // Use a quick hashmap for locating duplicates + + for ( var p in points ) { + + point = points[ p ]; + all.push( point.x + "," + point.y ); + + } + + var firstIndex, firstPt, endPt, holes; + + // We check the first loop whether its CW or CCW direction to determine + // whether its shapes or holes first + + endPt = all.slice(1).indexOf( all[0] ); + var shapesFirst = this.Triangulate.area( points.slice( 0, endPt + 1 ) ) < 0; + + //console.log(points.length, "shapesFirst",shapesFirst); + + holes = []; + endPt = -1; + + while ( endPt < all.length ) { + + firstIndex = endPt + 1; + firstPt = all[ firstIndex ]; + endPt = all.slice( firstIndex + 1 ).indexOf( firstPt ) + firstIndex; + + if ( endPt <= firstIndex ) break; + + var contours = points.slice( firstIndex, endPt + 1 ); + + if ( shapesFirst ) { + + if ( this.Triangulate.area( contours ) < 0 ) { + + // we got new isolated shape + + if ( firstIndex > 0 ) { + + isolatedShapes.push( { shape: shape, holes: holes } ); + + } + + // Save the old shapes, then work on new additional separated shape + + shape = contours; + holes = []; + + } else { + + holes.push( contours ); + + } + + } else { + + if ( this.Triangulate.area( contours ) < 0 ) { + + isolatedShapes.push( {shape: contours, holes: holes } ); + holes = []; + + } else { + + holes.push( contours ); + + } + + } + + endPt++; + + } + + if ( shapesFirst ) { + + 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 with + // 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 prevShapeVert, nextShapeVert, + prevHoleVert, nextHoleVert, + holeIndex, shapeIndex, + shapeId, shapeGroup, + h, h2, + hole, shortest, d, + p, pts1, pts2, + tmpShape1, tmpShape2, + tmpHole1, tmpHole2, + verts = []; + + for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { + + shapeGroup = isolatedShapes[ shapeId ]; + + shape = shapeGroup.shape; + holes = shapeGroup.holes; + + for ( h = 0; h < holes.length; h++ ) { + + // we slice to each hole when neccessary + + hole = holes[ h ]; + shortest = Number.POSITIVE_INFINITY; + + for ( h2 = 0; h2 < hole.length; h2++ ) { + + pts1 = hole[ h2 ]; + + for ( p = 0; p < shape.length; p++ ) { + + pts2 = shape[ p ]; + d = pts1.distanceTo( pts2 ); + + if ( d < shortest ) { + + shortest = d; + holeIndex = h2; + shapeIndex = p; + + } + + } + + } + + prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; + nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; + + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; + + var areaapts = []; + areaapts.push( hole[ holeIndex ] ); + areaapts.push( shape[ shapeIndex ] ); + areaapts.push( shape[ prevShapeVert ] ); + + var areaa = this.Triangulate.area( areaapts ); + + var areabpts = []; + areabpts.push( hole[ holeIndex ] ); + areabpts.push( hole[ prevHoleVert ] ); + areabpts.push( shape[ shapeIndex ] ); + + var areab = this.Triangulate.area( areabpts ); + + var shapeOffset =1; + var holeOffset = -1; + + var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex; + shapeIndex += shapeOffset; + holeIndex += holeOffset; + + if ( shapeIndex < 0 ) { shapeIndex += shape.length; } + shapeIndex %= shape.length; + + if ( holeIndex < 0 ) { holeIndex += hole.length; } + holeIndex %= shape.length; + + prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; + nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; + + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; + + + areaapts = []; + areaapts.push( hole[ holeIndex ] ); + areaapts.push( shape[ shapeIndex ] ); + areaapts.push( shape[ prevShapeVert ] ); + + var areaa2 = this.Triangulate.area( areaapts ); + + areabpts = []; + areabpts.push( hole[ holeIndex ] ); + areabpts.push( hole[ prevHoleVert ] ); + areabpts.push( shape[ shapeIndex ] ); + + var areab2 = this.Triangulate.area( areabpts ); + + if ( ( areaa + areab ) > ( areaa2 + areab2 ) ) { + + shapeIndex = oldShapeIndex; + holeIndex = oldHoleIndex ; + + if ( shapeIndex < 0 ) { shapeIndex += shape.length; } + shapeIndex %= shape.length; + + if ( holeIndex < 0 ) { holeIndex += hole.length; } + holeIndex %= shape.length; + + + prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1; + nextShapeVert = ( shapeIndex + 1 ) < shape.length ? shapeIndex + 1 : 0; + + prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1; + nextHoleVert = ( holeIndex + 1 ) < hole.length ? holeIndex + 1 : 0 ; + + } + + tmpShape1 = shape.slice( 0, shapeIndex ); + tmpShape2 = shape.slice( shapeIndex ); + tmpHole1 = hole.slice( holeIndex ); + tmpHole2 = hole.slice( 0, holeIndex ); + + verts.push( hole[ holeIndex ] ); + verts.push( shape[ shapeIndex ] ); + verts.push( shape[ prevShapeVert ] ); + + verts.push( hole[ holeIndex ] ); + verts.push( hole[ prevHoleVert ] ); + verts.push( shape[ shapeIndex ] ); + + shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 ); + + } + + shapeGroup.shape = shape; + + } + + var points = []; + var triangulatedVertices = []; + var lastTriangles = 0; + + for ( shapeId = 0; shapeId < isolatedShapes.length; shapeId ++ ) { + + shapeGroup = isolatedShapes[ shapeId ]; + + shape = shapeGroup.shape; + points = points.concat( shape ); + + var triangles = THREE.FontUtils.Triangulate( shape, true ); + + // We need to offset vertex indices for faces + + for ( var v = 0; v < triangles.length; v++ ) { + + var face = triangles[ v ]; + + face[ 0 ] += lastTriangles; + face[ 1 ] += lastTriangles; + face[ 2 ] += lastTriangles; + + } + + triangulatedVertices = triangulatedVertices.concat( triangles ); + lastTriangles += shape.length; + + } + + + // Now we push the "cut" vertices back to the triangulated indices. + + //console.log("we have verts.length",verts.length,verts); + + var v, j, k, l, found, face; + + for ( v = 0; v < verts.length / 3; v++ ) { + + face = []; + + for ( k = 0; k < 3; k++ ) { + + found = false; + + for ( j=0; j < points.length && !found; j++ ) { + + l = v * 3 + k; + + if ( points[ j ].equals( verts[ l ] ) ) { + + face.push( j ); + found = true; + + } + + } + + // you would not wish to reach this point of code, something went wrong + + if ( !found ) { + + points.push( verts[ l ] ); + face.push( points.length - 1 ); + + console.log( "not found" ) + + } + + } + + triangulatedVertices.push( face ); + + } + + + //console.log("triangles", triangulatedVertices.length, "points", points); + + return { + + points: points, + faces: triangulatedVertices + + }; + + }, + + drawText : function( text ) { + + var characterpts = [], pts = []; + + // RenderText + + var i, p, + face = this.getFace(), + scale = this.size / face.resolution, + offset = 0, + chars = String( text ).split( '' ), + length = chars.length; + + for ( i = 0; i < length; i++ ) { + + var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset ); + offset += ret.offset; + characterpts.push(ret.points); + pts = pts.concat(ret.points); + + } + + // get the width + + var width = offset / 2; + + for ( p = 0; p < pts.length; p++ ) { + + pts[ p ].x -= width; + + } + + var extract = this.extractPoints( pts, characterpts ); + + extract.contour = pts; + + var bezelPoints = []; + + var centroids = [], forCentroids = [], expandOutwards = [], sum = new THREE.Vector2(), lastV; + + i = pts.length; + + while ( --i >= 0 ) { + + if ( !lastV ) { + + lastV = pts[ i ]; + + } else if ( lastV.equals( pts[ i ] ) ) { + + // We reached the last point of a closed loop + + lastV = null; + + var bool = this.Triangulate.area( forCentroids ) > 0; + expandOutwards.push( bool ); + centroids.push( sum.divideScalar( forCentroids.length ) ); + forCentroids = []; + + sum = new THREE.Vector2(); + continue; + + } + + sum.addSelf( pts[ i ] ); + forCentroids.push( pts[ i ] ); + + } + + + i = pts.length; + p = 0; + var pt, centroid ; + var dirV, adj; + + while ( --i >= 0 ) { + + pt = pts[ i ]; + centroid = centroids[p]; + + dirV = pt.clone().subSelf( centroid) ; + adj = this.bezelSize / dirV.length(); + + if ( expandOutwards[ p ] ) { + + adj += 1; + + } else { + + adj = 1 - adj; + + } + + adj = dirV.multiplyScalar( adj ).addSelf( centroid ); + bezelPoints.unshift( adj ); + + + if ( !lastV ) { + + lastV = pts[ i ]; + + } else if ( lastV.equals( pts[ i ] ) ) { + + // We reached the last point of a closed loop + + lastV = null; + p++; + continue; + + } + + } + + + /* + for ( p = 0; p < pts.length; p++ ) { + pt = pts[ p ]; + bezelPoints.push (new THREE.Vector2(pt.x + this.bezelSize, pt.y + this.bezelSize)); + + }*/ + + extract.bezel = bezelPoints; + + return extract; + + }, + + + // Bezier Curves formulas obtained from + // http://en.wikipedia.org/wiki/B%C3%A9zier_curve + + // Quad Bezier Functions + + b2p0: function ( t, p ) { + + var k = 1 - t; + return k * k * p; + + }, + + b2p1: function ( t, p ) { + + return 2 * ( 1 - t ) * t * p; + + }, + + b2p2: function ( t, p ) { + + return t * t * p; + + }, + + b2: function ( t, p0, p1, p2 ) { + + return this.b2p0( t, p0 ) + this.b2p1( t, p1 ) + this.b2p2( t, p2 ); + + }, + + // Cubic Bezier Functions + + b3p0: function ( t, p ) { + + var k = 1 - t; + return k * k * k * p; + + }, + + b3p1: function ( t, p ) { + + var k = 1 - t; + return 3 * k * k * t * p; + + }, + + b3p2: function ( t, p ) { + + var k = 1 - t; + return 3 * k * t * t * p; + + }, + + b3p3: function ( t, p ) { + + return t * t * t * p; + + }, + + b3: function ( t, p0, p1, p2, p3 ) { + + return this.b3p0( t, p0 ) + this.b3p1( t, p1 ) + this.b3p2( t, p2 ) + this.b3p3( t, p3 ); + + }, + + + extractGlyphPoints : function( c, face, scale, offset ) { + + var pts = []; + + var i, i2, + outline, action, length, + scaleX, scaleY, + x, y, cpx, cpy, cpx0, cpy0, cpx1, cpy1, cpx2, cpy2, + laste, + glyph = face.glyphs[ c ] || face.glyphs[ ctxt.options.fallbackCharacter ]; + + if ( !glyph ) return; + + if ( glyph.o ) { + + outline = glyph._cachedOutline || ( glyph._cachedOutline = glyph.o.split( ' ' ) ); + length = outline.length; + + scaleX = scale; + scaleY = scale; + + for ( i = 0; i < length; ) { + + action = outline[ i++ ]; + + switch( action ) { + + case 'm': + + // Move To + + x = outline[ i++ ] * scaleX + offset; + y = outline[ i++ ] * scaleY; + pts.push( new THREE.Vector2( x, y ) ); + break; + + case 'l': + + // Line To + + x = outline[ i++ ] * scaleX + offset; + y = outline[ i++ ] * scaleY; + pts.push( new THREE.Vector2( x, y ) ); + break; + + case 'q': + + // QuadraticCurveTo + + cpx = outline[ i++ ] * scaleX + offset; + cpy = outline[ i++ ] * scaleY; + cpx1 = outline[ i++ ] * scaleX + offset; + cpy1 = outline[ i++ ] * scaleY; + + laste = pts[ pts.length - 1 ]; + + if ( laste ) { + + cpx0 = laste.x; + cpy0 = laste.y; + + for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { + + var t = i2 / divisions; + var tx = THREE.FontUtils.b2( t, cpx0, cpx1, cpx ); + var ty = THREE.FontUtils.b2( t, cpy0, cpy1, cpy ); + pts.push( new THREE.Vector2( tx, ty ) ); + + } + + } + + break; + + case 'b': + + // Cubic Bezier Curve + + cpx = outline[ i++ ] * scaleX + offset; + cpy = outline[ i++ ] * scaleY; + cpx1 = outline[ i++ ] * scaleX + offset; + cpy1 = outline[ i++ ] * -scaleY; + cpx2 = outline[ i++ ] * scaleX + offset; + cpy2 = outline[ i++ ] * -scaleY; + + laste = pts[ pts.length - 1 ]; + + if ( laste ) { + + cpx0 = laste.x; + cpy0 = laste.y; + + for ( i2 = 1, divisions = this.divisions; i2 <= divisions; i2++ ) { + + var t = i2 / divisions; + var tx = THREE.FontUtils.b3( t, cpx0, cpx1, cpx2, cpx ); + var ty = THREE.FontUtils.b3( t, cpy0, cpy1, cpy2, cpy ); + pts.push( new THREE.Vector2( tx, ty ) ); + + } + + } + + break; + + } + + } + } + + return { offset: glyph.ha*scale, points:pts }; + } + +}; + + + +/** + * This code is a quick port of code written in C++ which was submitted to + * flipcode.com by John W. Ratcliff // July 22, 2000 + * See original code and more information here: + * http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml + * + * ported to actionscript by Zevan Rosser + * www.actionsnippet.com + * + * ported to javascript by Joshua Koo + * http://www.lab4games.net/zz85/blog + * + */ + + +( function( namespace ) { + + var EPSILON = 0.0000000001; + + // takes in an contour array and returns + + var process = function( contour, indices ) { + + var n = contour.length; + + if ( n < 3 ) return null; + + var result = [], + verts = [], + vertIndices = []; + + /* we want a counter-clockwise polygon in verts */ + + var u, v, w; + + if ( area( contour ) > 0.0 ) { + + for ( v = 0; v < n; v++ ) verts[ v ] = v; + + } else { + + for ( v = 0; v < n; v++ ) verts[ v ] = ( n - 1 ) - v; + + } + + var nv = n; + + /* remove nv - 2 vertices, creating 1 triangle every time */ + + var count = 2 * nv; /* error detection */ + + for( v = nv - 1; nv > 2; ) { + + /* if we loop, it is probably a non-simple polygon */ + + if ( ( count-- ) <= 0 ) { + + //** Triangulate: ERROR - probable bad polygon! + + //throw ( "Warning, unable to triangulate polygon!" ); + //return null; + + console.log( "Warning, unable to triangulate polygon!" ); + + if ( indices ) return vertIndices; + return result; + + } + + /* three consecutive vertices in current polygon, */ + + u = v; if ( nv <= u ) u = 0; /* previous */ + v = u + 1; if ( nv <= v ) v = 0; /* new v */ + 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 ] ); + + vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] ); + + /* remove v from the remaining polygon */ + + for( s = v, t = v + 1; t < nv; s++, t++ ) { + + verts[ s ] = verts[ t ]; + + } + + nv--; + + /* reset error detection counter */ + + count = 2 * nv; + + } + + } + + if ( indices ) return vertIndices; + return result; + + }; + + // calculate area of the contour polygon + + var area = function ( contour ) { + + var n = contour.length; + var a = 0.0; + + for( var p = n - 1, q = 0; q < n; p = q++ ) { + + a += contour[ p ].x * contour[ q ].y - contour[ q ].x * contour[ p ].y; + + } + + return a * 0.5; + + }; + + // see if p is inside triangle abc + + var insideTriangle = function( ax, ay, + bx, by, + cx, cy, + px, py ) { + + var aX, aY, bX, bY; + var cX, cY, apx, apy; + var bpx, bpy, cpx, cpy; + var cCROSSap, bCROSScp, aCROSSbp; + + aX = cx - bx; aY = cy - by; + bX = ax - cx; bY = ay - cy; + cX = bx - ax; cY = by - ay; + apx= px -ax; apy= py - ay; + bpx= px - bx; bpy= py - by; + cpx= px - cx; cpy= py - cy; + + aCROSSbp = aX*bpy - aY*bpx; + cCROSSap = cX*apy - cY*apx; + bCROSScp = bX*cpy - bY*cpx; + + return ( (aCROSSbp >= 0.0) && (bCROSScp >= 0.0) && (cCROSSap >= 0.0) ); + + }; + + + var snip = function ( contour, u, v, w, n, verts ) { + + var p; + var ax, ay, bx, by; + var cx, cy, px, py; + + ax = contour[ verts[ u ] ].x; + ay = contour[ verts[ u ] ].y; + + bx = contour[ verts[ v ] ].x; + by = contour[ verts[ v ] ].y; + + cx = contour[ verts[ w ] ].x; + cy = contour[ verts[ w ] ].y; + + if ( EPSILON > (((bx-ax)*(cy-ay)) - ((by-ay)*(cx-ax))) ) return false; + + for ( p = 0; p < n; p++ ) { + + if( (p == u) || (p == v) || (p == w) ) continue; + + px = contour[ verts[ p ] ].x + py = contour[ verts[ p ] ].y + + if ( insideTriangle( ax, ay, bx, by, cx, cy, px, py ) ) return false; + + } + + return true; + + }; + + + namespace.Triangulate = process; + namespace.Triangulate.area = area; + + return namespace; + +})(THREE.FontUtils); + +// To use the typeface.js face files, hook up the API +window._typeface_js = { faces: THREE.FontUtils.faces, loadFace: THREE.FontUtils.loadFace }; diff --git a/src/extras/geometries/Torus.js b/src/extras/geometries/TorusGeometry.js similarity index 89% rename from src/extras/geometries/Torus.js rename to src/extras/geometries/TorusGeometry.js index 926aadc9..23621f1f 100644 --- a/src/extras/geometries/Torus.js +++ b/src/extras/geometries/TorusGeometry.js @@ -3,7 +3,7 @@ * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3DLite/src/away3dlite/primitives/Torus.as?r=2888 */ -THREE.Torus = function ( radius, tube, segmentsR, segmentsT ) { +THREE.TorusGeometry = function ( radius, tube, segmentsR, segmentsT ) { THREE.Geometry.call( this ); @@ -74,5 +74,5 @@ THREE.Torus = function ( radius, tube, segmentsR, segmentsT ) { }; -THREE.Torus.prototype = new THREE.Geometry(); -THREE.Torus.prototype.constructor = THREE.Torus; +THREE.TorusGeometry.prototype = new THREE.Geometry(); +THREE.TorusGeometry.prototype.constructor = THREE.TorusGeometry; diff --git a/src/extras/geometries/TorusKnot.js b/src/extras/geometries/TorusKnotGeometry.js similarity index 92% rename from src/extras/geometries/TorusKnot.js rename to src/extras/geometries/TorusKnotGeometry.js index 1475a9e2..4c26a3e7 100644 --- a/src/extras/geometries/TorusKnot.js +++ b/src/extras/geometries/TorusKnotGeometry.js @@ -3,7 +3,7 @@ * based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473 */ -THREE.TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) { +THREE.TorusKnotGeometry = function ( radius, tube, segmentsR, segmentsT, p, q, heightScale ) { THREE.Geometry.call( this ); @@ -104,5 +104,5 @@ THREE.TorusKnot = function ( radius, tube, segmentsR, segmentsT, p, q, heightSca }; -THREE.TorusKnot.prototype = new THREE.Geometry(); -THREE.TorusKnot.prototype.constructor = THREE.TorusKnot; +THREE.TorusKnotGeometry.prototype = new THREE.Geometry(); +THREE.TorusKnotGeometry.prototype.constructor = THREE.TorusKnotGeometry; diff --git a/src/extras/io/SceneLoader.js b/src/extras/io/SceneLoader.js index d23afdb3..1fcc7919 100644 --- a/src/extras/io/SceneLoader.js +++ b/src/extras/io/SceneLoader.js @@ -473,32 +473,32 @@ THREE.SceneLoader.prototype = { if ( g.type == "cube" ) { - geometry = new THREE.Cube( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides ); + geometry = new THREE.CubeGeometry( g.width, g.height, g.depth, g.segmentsWidth, g.segmentsHeight, g.segmentsDepth, null, g.flipped, g.sides ); result.geometries[ dg ] = geometry; } else if ( g.type == "plane" ) { - geometry = new THREE.Plane( g.width, g.height, g.segmentsWidth, g.segmentsHeight ); + geometry = new THREE.PlaneGeometry( g.width, g.height, g.segmentsWidth, g.segmentsHeight ); result.geometries[ dg ] = geometry; } else if ( g.type == "sphere" ) { - geometry = new THREE.Sphere( g.radius, g.segmentsWidth, g.segmentsHeight ); + geometry = new THREE.SphereGeometry( g.radius, g.segmentsWidth, g.segmentsHeight ); result.geometries[ dg ] = geometry; } else if ( g.type == "cylinder" ) { - geometry = new THREE.Cylinder( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset ); + geometry = new THREE.CylinderGeometry( g.numSegs, g.topRad, g.botRad, g.height, g.topOffset, g.botOffset ); result.geometries[ dg ] = geometry; } else if ( g.type == "torus" ) { - geometry = new THREE.Torus( g.radius, g.tube, g.segmentsR, g.segmentsT ); + geometry = new THREE.TorusGeometry( g.radius, g.tube, g.segmentsR, g.segmentsT ); result.geometries[ dg ] = geometry; } else if ( g.type == "icosahedron" ) { - geometry = new THREE.Icosahedron( g.subdivisions ); + geometry = new THREE.IcosahedronGeometry( g.subdivisions ); result.geometries[ dg ] = geometry; } else if ( g.type == "bin_mesh" ) { diff --git a/src/extras/objects/Trident.js b/src/extras/objects/Trident.js index 4f0a23ed..6dfcf652 100644 --- a/src/extras/objects/Trident.js +++ b/src/extras/objects/Trident.js @@ -54,7 +54,7 @@ THREE.Trident = function ( params /** Object */) { function getCone ( color ) { //0.1 required to get a cone with a mapped bottom face - return new THREE.Mesh( new THREE.Cylinder( 30, 0.1, params.length / 20, params.length / 5 ), new THREE.MeshBasicMaterial( { color : color } ) ); + return new THREE.Mesh( new THREE.CylinderGeometry( 30, 0.1, params.length / 20, params.length / 5 ), new THREE.MeshBasicMaterial( { color : color } ) ); } function getSegment ( point, color ){ diff --git a/src/extras/renderers/AnaglyphWebGLRenderer.js b/src/extras/renderers/AnaglyphWebGLRenderer.js index 77022614..029e23a2 100644 --- a/src/extras/renderers/AnaglyphWebGLRenderer.js +++ b/src/extras/renderers/AnaglyphWebGLRenderer.js @@ -2,98 +2,99 @@ * @author mrdoob / http://mrdoob.com/ */ -THREE.AnaglyphWebGLRenderer = function ( parameters ) { +if ( THREE.WebGLRenderer ) { - THREE.WebGLRenderer.call( this, parameters ); + THREE.AnaglyphWebGLRenderer = function ( parameters ) { - var _this = this, _setSize = this.setSize, _render = this.render; - var _cameraL = new THREE.Camera(), _cameraR = new THREE.Camera(); + THREE.WebGLRenderer.call( this, parameters ); - var _params = { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat }; - var _renderTargetL = new THREE.WebGLRenderTarget( 512, 512, _params ), _renderTargetR = new THREE.WebGLRenderTarget( 512, 512, _params ); + var _this = this, _setSize = this.setSize, _render = this.render; + var _cameraL = new THREE.Camera(), _cameraR = new THREE.Camera(); - var _camera = new THREE.Camera( 53, 1, 1, 10000 ); - _camera.position.z = 2; + var _params = { minFilter: THREE.LinearFilter, magFilter: THREE.NearestFilter, format: THREE.RGBAFormat }; + var _renderTargetL = new THREE.WebGLRenderTarget( 512, 512, _params ), _renderTargetR = new THREE.WebGLRenderTarget( 512, 512, _params ); - _material = new THREE.MeshShaderMaterial( { + var _camera = new THREE.Camera( 53, 1, 1, 10000 ); + _camera.position.z = 2; - uniforms: { + _material = new THREE.MeshShaderMaterial( { - "mapLeft": { type: "t", value: 0, texture: _renderTargetL }, - "mapRight": { type: "t", value: 1, texture: _renderTargetR } + uniforms: { - }, - vertexShader: [ + "mapLeft": { type: "t", value: 0, texture: _renderTargetL }, + "mapRight": { type: "t", value: 1, texture: _renderTargetR } - "varying vec2 vUv;", + }, + vertexShader: [ - "void main() {", + "varying vec2 vUv;", - "vUv = vec2( uv.x, 1.0 - uv.y );", - "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", + "void main() {", - "}" + "vUv = vec2( uv.x, 1.0 - uv.y );", + "gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );", - ].join("\n"), - fragmentShader: [ + "}" - "uniform sampler2D mapLeft;", - "uniform sampler2D mapRight;", - "varying vec2 vUv;", + ].join("\n"), + fragmentShader: [ - "void main() {", + "uniform sampler2D mapLeft;", + "uniform sampler2D mapRight;", + "varying vec2 vUv;", - "vec4 colorL, colorR;", - "vec2 uv = vUv;", + "void main() {", - "colorL = texture2D( mapLeft, uv );", - "colorR = texture2D( mapRight, uv );", + "vec4 colorL, colorR;", + "vec2 uv = vUv;", - // http://3dtv.at/Knowhow/AnaglyphComparison_en.aspx + "colorL = texture2D( mapLeft, uv );", + "colorR = texture2D( mapRight, uv );", - "gl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;", + // http://3dtv.at/Knowhow/AnaglyphComparison_en.aspx - "}" + "gl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;", - ].join("\n") + "}" - } ); + ].join("\n") - var _scene = new THREE.Scene(); - _scene.addObject( new THREE.Mesh( new THREE.Plane( 2, 2 ), _material ) ); + } ); - this.setSize = function ( width, height ) { + var _scene = new THREE.Scene(); + _scene.addObject( new THREE.Mesh( new THREE.PlaneGeometry( 2, 2 ), _material ) ); - _setSize.call( _this, width, height ); + this.setSize = function ( width, height ) { - _renderTargetL.width = width; - _renderTargetL.height = height; + _setSize.call( _this, width, height ); - _renderTargetR.width = width; - _renderTargetR.height = height; + _renderTargetL.width = width; + _renderTargetL.height = height; + + _renderTargetR.width = width; + _renderTargetR.height = height; + + }; + + this.render = function ( scene, camera, renderTarget, forceClear ) { + + _cameraL.projectionMatrix = camera.projectionMatrix; + _cameraL.position.copy( camera.position ); + _cameraL.target.position.copy( camera.target.position ); + _cameraL.translateX( - 10 ); + + _cameraR.projectionMatrix = camera.projectionMatrix; + _cameraR.position.copy( camera.position ); + _cameraR.target.position.copy( camera.target.position ); + _cameraR.translateX( 10 ); + + _render.call( _this, scene, _cameraL, _renderTargetL, true ); + _render.call( _this, scene, _cameraR, _renderTargetR, true ); + + _render.call( _this, _scene, _camera ); + + }; }; - - this.render = function ( scene, camera, renderTarget, forceClear ) { - - _cameraL.projectionMatrix = camera.projectionMatrix; - _cameraL.position.copy( camera.position ); - _cameraL.target.position.copy( camera.target.position ); - _cameraL.translateX( - 10 ); - - _cameraR.projectionMatrix = camera.projectionMatrix; - _cameraR.position.copy( camera.position ); - _cameraR.target.position.copy( camera.target.position ); - _cameraR.translateX( 10 ); - - _render.call( _this, scene, _cameraL, _renderTargetL, true ); - _render.call( _this, scene, _cameraR, _renderTargetR, true ); - - _render.call( _this, _scene, _camera ); - - }; - -}; - -THREE.AnaglyphWebGLRenderer.prototype = new THREE.WebGLRenderer(); -THREE.AnaglyphWebGLRenderer.prototype.constructor = THREE.AnaglyphWebGLRenderer; + +} diff --git a/src/extras/renderers/CrosseyedWebGLRenderer.js b/src/extras/renderers/CrosseyedWebGLRenderer.js index 8e186646..aa1c2133 100644 --- a/src/extras/renderers/CrosseyedWebGLRenderer.js +++ b/src/extras/renderers/CrosseyedWebGLRenderer.js @@ -2,68 +2,69 @@ * @author alteredq / http://alteredqualia.com/ */ -THREE.CrosseyedWebGLRenderer = function ( parameters ) { +if ( THREE.WebGLRenderer ) { - THREE.WebGLRenderer.call( this, parameters ); + THREE.CrosseyedWebGLRenderer = function ( parameters ) { - this.autoClear = false; + THREE.WebGLRenderer.call( this, parameters ); - var _this = this, _setSize = this.setSize, _render = this.render; + this.autoClear = false; - var _width, _height; + var _this = this, _setSize = this.setSize, _render = this.render; + + var _width, _height; - var _cameraL = new THREE.Camera(), - _cameraR = new THREE.Camera(); + var _cameraL = new THREE.Camera(), + _cameraR = new THREE.Camera(); - _this.separation = 10; - if ( parameters && parameters.separation !== undefined ) _this.separation = parameters.separation; + _this.separation = 10; + if ( parameters && parameters.separation !== undefined ) _this.separation = parameters.separation; - var SCREEN_WIDTH = window.innerWidth; - var SCREEN_HEIGHT = window.innerHeight; - var HALF_WIDTH = SCREEN_WIDTH / 2; + var SCREEN_WIDTH = window.innerWidth; + var SCREEN_HEIGHT = window.innerHeight; + var HALF_WIDTH = SCREEN_WIDTH / 2; - var _camera = new THREE.Camera( 53, HALF_WIDTH / SCREEN_HEIGHT, 1, 10000 ); - _camera.position.z = -10; + var _camera = new THREE.Camera( 53, HALF_WIDTH / SCREEN_HEIGHT, 1, 10000 ); + _camera.position.z = -10; - this.setSize = function ( width, height ) { + this.setSize = function ( width, height ) { - _setSize.call( _this, width, height ); + _setSize.call( _this, width, height ); - _width = width/2; - _height = height; + _width = width/2; + _height = height; + + }; + + this.render = function ( scene, camera, renderTarget, forceClear ) { + + this.clear(); + + _cameraL.fov = camera.fov; + _cameraL.aspect = 0.5 * camera.aspect; + _cameraL.near = camera.near; + _cameraL.far = camera.far; + _cameraL.updateProjectionMatrix(); + + _cameraL.position.copy( camera.position ); + _cameraL.target.position.copy( camera.target.position ); + _cameraL.translateX( _this.separation ); + + _cameraR.projectionMatrix = _cameraL.projectionMatrix; + + _cameraR.position.copy( camera.position ); + _cameraR.target.position.copy( camera.target.position ); + _cameraR.translateX( - _this.separation ); + + this.setViewport( 0, 0, _width, _height ); + _render.call( _this, scene, _cameraL ); + + this.setViewport( _width, 0, _width, _height ); + _render.call( _this, scene, _cameraR, false ); + + }; }; - - this.render = function ( scene, camera, renderTarget, forceClear ) { - - this.clear(); - - _cameraL.fov = camera.fov; - _cameraL.aspect = 0.5 * camera.aspect; - _cameraL.near = camera.near; - _cameraL.far = camera.far; - _cameraL.updateProjectionMatrix(); - - _cameraL.position.copy( camera.position ); - _cameraL.target.position.copy( camera.target.position ); - _cameraL.translateX( _this.separation ); - - _cameraR.projectionMatrix = _cameraL.projectionMatrix; - - _cameraR.position.copy( camera.position ); - _cameraR.target.position.copy( camera.target.position ); - _cameraR.translateX( - _this.separation ); - - this.setViewport( 0, 0, _width, _height ); - _render.call( _this, scene, _cameraL ); - - this.setViewport( _width, 0, _width, _height ); - _render.call( _this, scene, _cameraR, false ); - - }; - -}; - -THREE.CrosseyedWebGLRenderer.prototype = new THREE.WebGLRenderer(); -THREE.CrosseyedWebGLRenderer.prototype.constructor = THREE.CrosseyedWebGLRenderer; + +} diff --git a/src/objects/Sprite.js b/src/objects/Sprite.js index 1c50fcf0..ae1f6790 100644 --- a/src/objects/Sprite.js +++ b/src/objects/Sprite.js @@ -14,7 +14,7 @@ THREE.Sprite = function( parameters ) { } else if( parameters.map !== undefined ) { - this.map = parameters.map instanceof THREE.Texture ? parameters.map : ImageUtils.loadTexture( parameters.map ); + this.map = parameters.map instanceof THREE.Texture ? parameters.map : THREE.ImageUtils.loadTexture( parameters.map ); this.material = undefined; this.blending = parameters.blending !== undefined ? parameters.blending : THREE.NormalBlending; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 56de174c..1cb19120 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -3835,6 +3835,7 @@ THREE.WebGLRenderer = function ( parameters ) { scene.__webglShadowVolumes = []; scene.__webglLensFlares = []; scene.__webglSprites = []; + } while ( scene.__objectsAdded.length ) { @@ -4003,6 +4004,7 @@ THREE.WebGLRenderer = function ( parameters ) { } else if ( object instanceof THREE.Sprite ) { scene.__webglSprites.push( object ); + } /*else if ( object instanceof THREE.Particle ) { @@ -4111,43 +4113,50 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function removeObject( object, scene ) { + function removeInstances( objlist, object ) { - var o, ol, zobject; + var o, ol; - if ( object instanceof THREE.Mesh ) { + for ( o = objlist.length - 1; o >= 0; o -- ) { - for ( o = scene.__webglObjects.length - 1; o >= 0; o -- ) { + if ( objlist[ o ].object == object ) { - zobject = scene.__webglObjects[ o ].object; - - if ( object == zobject ) { - - scene.__webglObjects.splice( o, 1 ); - return; - - } - - } - - } else if ( object instanceof THREE.Sprite ) { - - for ( o = scene.__webglSprites.length - 1; o >= 0; o -- ) { - - zobject = scene.__webglSprites[ o ]; - - if ( object == zobject ) { - - scene.__webglSprites.splice( o, 1 ); - return; - - } + objlist.splice( o, 1 ); } } - // add shadows, etc + }; + + function removeObject( object, scene ) { + + // must check as shadow volume before mesh (as they are also meshes) + + if ( object instanceof THREE.ShadowVolume ) { + + removeInstances( scene.__webglShadowVolumes, object ); + + } else if ( object instanceof THREE.Mesh || + object instanceof THREE.ParticleSystem || + object instanceof THREE.Ribbon || + object instanceof THREE.Line ) { + + removeInstances( scene.__webglObjects, object ); + + } else if ( object instanceof THREE.Sprite ) { + + removeInstances( scene.__webglSprites, object ); + + } else if ( object instanceof THREE.LensFlare ) { + + removeInstances( scene.__webglLensFlares, object ); + + } else if ( object instanceof THREE.MarchingCubes ) { + + removeInstances( scene.__webglObjectsImmediate, object ); + + } }; diff --git a/utils/build.bat b/utils/build.bat index 53b09a72..276a8875 100644 --- a/utils/build.bat +++ b/utils/build.bat @@ -1 +1 @@ -python build.py --common --includes +python build.py --common --minified diff --git a/utils/build.py b/utils/build.py index d1a65a50..bcbc760d 100644 --- a/utils/build.py +++ b/utils/build.py @@ -94,15 +94,15 @@ EXTRAS_FILES = [ 'extras/cameras/FlyCamera.js', 'extras/cameras/RollCamera.js', 'extras/cameras/TrackballCamera.js', -'extras/geometries/Cube.js', -'extras/geometries/Cylinder.js', -'extras/geometries/Icosahedron.js', -'extras/geometries/Lathe.js', -'extras/geometries/Plane.js', -'extras/geometries/Sphere.js', -'extras/geometries/Torus.js', -'extras/geometries/TorusKnot.js', -'extras/geometries/Text.js', +'extras/geometries/CubeGeometry.js', +'extras/geometries/CylinderGeometry.js', +'extras/geometries/IcosahedronGeometry.js', +'extras/geometries/LatheGeometry.js', +'extras/geometries/PlaneGeometry.js', +'extras/geometries/SphereGeometry.js', +'extras/geometries/TextGeometry.js', +'extras/geometries/TorusGeometry.js', +'extras/geometries/TorusKnotGeometry.js', 'extras/io/Loader.js', 'extras/io/JSONLoader.js', 'extras/io/BinaryLoader.js', @@ -356,7 +356,7 @@ def makeDebug(text): return text -def buildLib(files, debug, unminified, filename): +def buildLib(files, debug, minified, filename): text = merge(files) @@ -375,7 +375,7 @@ def buildLib(files, debug, unminified, filename): print "Compiling", filename print "=" * 40 - if not unminified: + if minified: text = compress(text) output(addHeader(text, filename), folder + filename) @@ -401,7 +401,7 @@ def parse_args(): parser.add_argument('--svg', help='Build ThreeSVG.js', action='store_true') parser.add_argument('--dom', help='Build ThreeDOM.js', action='store_true') parser.add_argument('--debug', help='Generate debug versions', action='store_const', const=True, default=False) - parser.add_argument('--unminified', help='Generate unminified versions', action='store_const', const=True, default=False) + parser.add_argument('--minified', help='Generate minified versions', action='store_const', const=True, default=False) parser.add_argument('--all', help='Build all Three.js versions', action='store_true') args = parser.parse_args() @@ -416,7 +416,7 @@ def parse_args(): parser.add_option('--svg', dest='svg', help='Build ThreeSVG.js', action='store_true') parser.add_option('--dom', dest='dom', help='Build ThreeDOM.js', action='store_true') parser.add_option('--debug', dest='debug', help='Generate debug versions', action='store_const', const=True, default=False) - parser.add_option('--unminified', help='Generate unminified versions', action='store_const', const=True, default=False) + parser.add_option('--minified', help='Generate minified versions', action='store_const', const=True, default=False) parser.add_option('--all', dest='all', help='Build all Three.js versions', action='store_true') args, remainder = parser.parse_args() @@ -433,7 +433,7 @@ def main(argv=None): args = parse_args() debug = args.debug - unminified = args.unminified + minified = args.minified config = [ ['Three', 'includes', COMMON_FILES + EXTRAS_FILES, args.common], @@ -446,7 +446,7 @@ def main(argv=None): for fname_lib, fname_inc, files, enabled in config: if enabled or args.all: - buildLib(files, debug, unminified, fname_lib) + buildLib(files, debug, minified, fname_lib) if args.includes: buildIncludes(files, fname_inc) diff --git a/utils/build.sh b/utils/build.sh index 277b419d..4229a523 100755 --- a/utils/build.sh +++ b/utils/build.sh @@ -1,3 +1,3 @@ #!/bin/sh -python build.py --common +python build.py --common --minified diff --git a/utils/build.xml b/utils/build.xml index ad305d4f..61137140 100644 --- a/utils/build.xml +++ b/utils/build.xml @@ -27,11 +27,11 @@ - + - + - \ No newline at end of file + diff --git a/utils/build_all.bat b/utils/build_all.bat index 73405931..ea84ddc4 100644 --- a/utils/build_all.bat +++ b/utils/build_all.bat @@ -1 +1 @@ -python build.py --all --includes +python build.py --all --minified diff --git a/utils/build_all.sh b/utils/build_all.sh index 79d38f95..e2bffe29 100755 --- a/utils/build_all.sh +++ b/utils/build_all.sh @@ -1,3 +1,3 @@ #!/bin/sh -python build.py --all +python build.py --all --minified