diff --git a/build/Three.js b/build/Three.js index 317c7f05..15175c4c 100644 --- a/build/Three.js +++ b/build/Three.js @@ -14,38 +14,38 @@ b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w||1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;this.w= b.w-c.w;return this},subSelf:function(b){this.x-=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.z=this.y=this.x=0,this.w=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={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&j+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x, -Math.max(b.scale.y,b.scale.z)))return[];var h,k,j,m,o,t,p,v,w,u,y=b.geometry,x=y.vertices,B=[],f=0;for(h=y.faces.length;f0:v<0)))if(v=p.dot((new THREE.Vector3).sub(j,w))/v,w=w.addSelf(u.multiplyScalar(v)),k instanceof THREE.Face3)e(w,j,m,o)&&(k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(w,j,m,t)||e(w,m,o,t)))k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k);B.sort(function(b,c){return b.distance-c.distance});return B}else return[]}}; -THREE.Rectangle=function(){function b(){k=f-c;j=h-e}var c,e,f,h,k,j,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(j,k,p,v){m=!1;c=j;e=k;f=p;h=v;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,h=k):(c=cj?f:j,h=h>k?h:k);b()};this.add3Points= -function(j,k,p,v,w,u){m?(m=!1,c=jp?j>w?j:w:p>w?p:w,h=k>v?k>u?k:u:v>u?v:u):(c=jp?j>w?j>f?j:f:w>f?w:f:p>w?p>f?p:f:w>f?w:f,h=k>v?k>u?k>h?k:h:u>h?u:h:v>u?v>h?v:h:u>h?u:h);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),h=j.getBottom()):(c=cj.getRight()?f:j.getRight(),h=h> +THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&j+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x, +Math.max(b.scale.y,b.scale.z)))return[];var h,k,j,m,p,o,t,v,w,u,y=b.geometry,x=y.vertices,B=[],f=0;for(h=y.faces.length;f0:v<0)))if(v=t.dot((new THREE.Vector3).sub(j,w))/v,w=w.addSelf(u.multiplyScalar(v)),k instanceof THREE.Face3)e(w,j,m,p)&&(k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(w,j,m,o)||e(w,m,p,o)))k={distance:this.origin.distanceTo(w),point:w,face:k,object:b},B.push(k);B.sort(function(b,e){return b.distance-e.distance});return B}else return[]}}; +THREE.Rectangle=function(){function b(){k=f-c;j=h-e}var c,e,f,h,k,j,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(j,k,t,v){m=!1;c=j;e=k;f=t;h=v;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,h=k):(c=cj?f:j,h=h>k?h:k);b()};this.add3Points= +function(j,k,t,v,w,u){m?(m=!1,c=jt?j>w?j:w:t>w?t:w,h=k>v?k>u?k:u:v>u?v:u):(c=jt?j>w?j>f?j:f:w>f?w:f:t>w?t>f?t:f:w>f?w:f,h=k>v?k>u?k>h?k:h:u>h?u:h:v>u?v>h?v:h:u>h?u:h);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),h=j.getBottom()):(c=cj.getRight()?f:j.getRight(),h=h> j.getBottom()?h:j.getBottom());b()};this.inflate=function(j){c-=j;e-=j;f+=j;h+=j;b()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();e=e>j.getTop()?e:j.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){m=!0;h=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,e,f,h,k,j,m,o,t,p,v,w,u,y,x){this.set(b||1,c||0,e||0,f||0,h||0,k||1,j||0,m||0,o||0,t||0,p||1,v||0,w||0,u||0,y||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,j,m,o,t,p,v,w,u,y,x){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=j;this.n24=m;this.n31=o;this.n32=t;this.n33=p;this.n34=v;this.n41=w;this.n42=u;this.n43=y;this.n44=x;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, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,e,f,h,k,j,m,p,o,t,v,w,u,y,x){this.set(b||1,c||0,e||0,f||0,h||0,k||1,j||0,m||0,p||0,o||0,t||1,v||0,w||0,u||0,y||0,x||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,j,m,p,o,t,v,w,u,y,x){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=j;this.n24=m;this.n31=p;this.n32=o;this.n33=t;this.n34=v;this.n41=w;this.n42=u;this.n43=y;this.n44=x;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,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ -e*this.n32+f*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 e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,o=b.n23,t=b.n24,p=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44,H=c.n11,D=c.n12, -I=c.n13,K=c.n14,M=c.n21,C=c.n22,J=c.n23,E=c.n24,Y=c.n31,F=c.n32,L=c.n33,N=c.n34,P=c.n41,n=c.n42,V=c.n43,ha=c.n44;this.n11=e*H+f*M+h*Y+k*P;this.n12=e*D+f*C+h*F+k*n;this.n13=e*I+f*J+h*L+k*V;this.n14=e*K+f*E+h*N+k*ha;this.n21=j*H+m*M+o*Y+t*P;this.n22=j*D+m*C+o*F+t*n;this.n23=j*I+m*J+o*L+t*V;this.n24=j*K+m*E+o*N+t*ha;this.n31=p*H+v*M+w*Y+u*P;this.n32=p*D+v*C+w*F+u*n;this.n33=p*I+v*J+w*L+u*V;this.n34=p*K+v*E+w*N+u*ha;this.n41=y*H+x*M+B*Y+z*P;this.n42=y*D+x*C+B*F+z*n;this.n43=y*I+x*J+B*L+z*V;this.n44=y* -K+x*E+B*N+z*ha;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);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,c=this.n12,e=this.n13,f=this.n14,h=this.n21,k=this.n22,j=this.n23,m=this.n24,o=this.n31,t=this.n32,p=this.n33,v=this.n34,w=this.n41,u=this.n42,y=this.n43,x=this.n44;return f*j*t*w-e*m*t*w-f*k*p*w+c*m*p*w+e*k*v*w-c*j*v*w-f*j*o*u+e*m*o*u+f*h*p*u-b*m*p*u-e*h*v*u+b*j*v*u+f*k*o*y-c*m*o*y-f*h*t*y+b*m*t*y+c*h*v*y-b*k*v*y-e*k*o*x+c*j*o*x+e*h*t*x-b*j*t*x-c*h* -p*x+b*k*p*x},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= +e*this.n32+f*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 e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,p=b.n23,o=b.n24,t=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44,D=c.n11,C=c.n12, +E=c.n13,J=c.n14,O=c.n21,K=c.n22,I=c.n23,F=c.n24,Y=c.n31,G=c.n32,M=c.n33,L=c.n34,S=c.n41,n=c.n42,V=c.n43,fa=c.n44;this.n11=e*D+f*O+h*Y+k*S;this.n12=e*C+f*K+h*G+k*n;this.n13=e*E+f*I+h*M+k*V;this.n14=e*J+f*F+h*L+k*fa;this.n21=j*D+m*O+p*Y+o*S;this.n22=j*C+m*K+p*G+o*n;this.n23=j*E+m*I+p*M+o*V;this.n24=j*J+m*F+p*L+o*fa;this.n31=t*D+v*O+w*Y+u*S;this.n32=t*C+v*K+w*G+u*n;this.n33=t*E+v*I+w*M+u*V;this.n34=t*J+v*F+w*L+u*fa;this.n41=y*D+x*O+B*Y+z*S;this.n42=y*C+x*K+B*G+z*n;this.n43=y*E+x*I+B*M+z*V;this.n44=y* +J+x*F+B*L+z*fa;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);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,c=this.n12,e=this.n13,f=this.n14,h=this.n21,k=this.n22,j=this.n23,m=this.n24,p=this.n31,o=this.n32,t=this.n33,v=this.n34,w=this.n41,u=this.n42,y=this.n43,x=this.n44;return f*j*o*w-e*m*o*w-f*k*t*w+c*m*t*w+e*k*v*w-c*j*v*w-f*j*p*u+e*m*p*u+f*h*t*u-b*m*t*u-e*h*v*u+b*j*v*u+f*k*p*y-c*m*p*y-f*h*o*y+b*m*o*y+c*h*v*y-b*k*v*y-e*k*p*x+c*j*p*x+e*h*o*x-b*j*o*x-c*h* +t*x+b*k*t*x},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,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,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 e=Math.cos(c),f=Math.sin(c),h=1-e,k=b.x,j=b.y,m=b.z,o=h*k,t=h*j;this.set(o*k+e,o*j-f*m,o*m+f*j,0,o*j+f*m,t*j+e,t*m-f*k,0,o*m-f*j,t*m+f*k,h*m*m+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,c){var e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),m=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var o= -j*m,t=j*h,p=f*m,v=f*h;this.n11=o+v*e;this.n12=p*e-t;this.n13=k*f;this.n21=k*h;this.n22=k*m;this.n23=-e;this.n31=t*e-p;this.n32=v+o*e;this.n33=k*j;break;case "ZXY":o=j*m;t=j*h;p=f*m;v=f*h;this.n11=o-v*e;this.n12=-k*h;this.n13=p+t*e;this.n21=t+p*e;this.n22=k*m;this.n23=v-o*e;this.n31=-k*f;this.n32=e;this.n33=k*j;break;case "ZYX":o=k*m;t=k*h;p=e*m;v=e*h;this.n11=j*m;this.n12=p*f-t;this.n13=o*f+v;this.n21=j*h;this.n22=v*f+o;this.n23=t*f-p;this.n31=-f;this.n32=e*j;this.n33=k*j;break;case "YZX":o=k*j;t= -k*f;p=e*j;v=e*f;this.n11=j*m;this.n12=v-o*h;this.n13=p*h+t;this.n21=h;this.n22=k*m;this.n23=-e*m;this.n31=-f*m;this.n32=t*h+p;this.n33=o-v*h;break;case "XZY":o=k*j;t=k*f;p=e*j;v=e*f;this.n11=j*m;this.n12=-h;this.n13=f*m;this.n21=o*h+v;this.n22=k*m;this.n23=t*h-p;this.n31=p*h-t;this.n32=e*m;this.n33=v*h+o;break;default:o=k*m,t=k*h,p=e*m,v=e*h,this.n11=j*m,this.n12=-j*h,this.n13=f,this.n21=t+p*f,this.n22=o-v*f,this.n23=-e*j,this.n31=v-o*f,this.n32=p+t*f,this.n33=k*j}return this},setRotationFromQuaternion:function(b){var c= -b.x,e=b.y,f=b.z,h=b.w,k=c+c,j=e+e,m=f+f,b=c*k,o=c*j;c*=m;var t=e*j;e*=m;f*=m;k*=h;j*=h;h*=m;this.n11=1-(t+f);this.n12=o-h;this.n13=c+j;this.n21=o+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-j;this.n32=e+k;this.n33=1-(b+t);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2; +0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),h=1-e,k=b.x,j=b.y,m=b.z,p=h*k,o=h*j;this.set(p*k+e,p*j-f*m,p*m+f*j,0,p*j+f*m,o*j+e,o*m-f*k,0,p*m-f*j,o*m+f*k,h*m*m+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,c){var e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),m=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var p= +j*m,o=j*h,t=f*m,v=f*h;this.n11=p+v*e;this.n12=t*e-o;this.n13=k*f;this.n21=k*h;this.n22=k*m;this.n23=-e;this.n31=o*e-t;this.n32=v+p*e;this.n33=k*j;break;case "ZXY":p=j*m;o=j*h;t=f*m;v=f*h;this.n11=p-v*e;this.n12=-k*h;this.n13=t+o*e;this.n21=o+t*e;this.n22=k*m;this.n23=v-p*e;this.n31=-k*f;this.n32=e;this.n33=k*j;break;case "ZYX":p=k*m;o=k*h;t=e*m;v=e*h;this.n11=j*m;this.n12=t*f-o;this.n13=p*f+v;this.n21=j*h;this.n22=v*f+p;this.n23=o*f-t;this.n31=-f;this.n32=e*j;this.n33=k*j;break;case "YZX":p=k*j;o= +k*f;t=e*j;v=e*f;this.n11=j*m;this.n12=v-p*h;this.n13=t*h+o;this.n21=h;this.n22=k*m;this.n23=-e*m;this.n31=-f*m;this.n32=o*h+t;this.n33=p-v*h;break;case "XZY":p=k*j;o=k*f;t=e*j;v=e*f;this.n11=j*m;this.n12=-h;this.n13=f*m;this.n21=p*h+v;this.n22=k*m;this.n23=o*h-t;this.n31=t*h-o;this.n32=e*m;this.n33=v*h+p;break;default:p=k*m,o=k*h,t=e*m,v=e*h,this.n11=j*m,this.n12=-j*h,this.n13=f,this.n21=o+t*f,this.n22=p-v*f,this.n23=-e*j,this.n31=v-p*f,this.n32=t+o*f,this.n33=k*j}return this},setRotationFromQuaternion:function(b){var c= +b.x,e=b.y,f=b.z,h=b.w,k=c+c,j=e+e,m=f+f,b=c*k,p=c*j;c*=m;var o=e*j;e*=m;f*=m;k*=h;j*=h;h*=m;this.n11=1-(o+f);this.n12=p-h;this.n13=c+j;this.n21=p+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-j;this.n32=e+k;this.n33=1-(b+o);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2; f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);k.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length(); e.y=h.length();e.z=k.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=1/c.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,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,o=b.n23,t=b.n24,p=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=o*u*x-t*w*x+t*v*B-m*u*B-o*v*z+m*w*z;c.n12=k*w*x-h*u*x-k*v*B+f*u*B+h*v*z-f*w*z;c.n13=h*t*x-k*o*x+k*m*B-f*t*B-h*m*z+f*o*z;c.n14=k*o*v-h*t*v-k*m*w+f*t*w+h*m*u-f*o*u;c.n21=t*w*y-o*u*y-t*p*B+j*u*B+o*p*z-j*w*z;c.n22=h*u*y-k*w*y+k*p*B-e*u*B-h*p*z+e*w*z;c.n23=k*o*y-h*t*y-k*j*B+e*t*B+h*j*z-e*o*z;c.n24= -h*t*p-k*o*p+k*j*w-e*t*w-h*j*u+e*o*u;c.n31=m*u*y-t*v*y+t*p*x-j*u*x-m*p*z+j*v*z;c.n32=k*v*y-f*u*y-k*p*x+e*u*x+f*p*z-e*v*z;c.n33=h*t*y-k*m*y+k*j*x-e*t*x-f*j*z+e*m*z;c.n34=k*m*p-f*t*p-k*j*v+e*t*v+f*j*u-e*m*u;c.n41=o*v*y-m*w*y-o*p*x+j*w*x+m*p*B-j*v*B;c.n42=f*w*y-h*v*y+h*p*x-e*w*x-f*p*B+e*v*B;c.n43=h*m*y-f*o*y-h*j*x+e*o*x+f*j*B-e*m*B;c.n44=f*o*p-h*m*p+h*j*v-e*o*v-f*j*w+e*m*w;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,o=-b.n32*b.n11+b.n31*b.n12,t=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*t;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*j;e[4]=b*m;e[5]=b*o;e[6]=b*t;e[7]=b*p;e[8]=b*v;return c}; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,j=b.n21,m=b.n22,p=b.n23,o=b.n24,t=b.n31,v=b.n32,w=b.n33,u=b.n34,y=b.n41,x=b.n42,B=b.n43,z=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=p*u*x-o*w*x+o*v*B-m*u*B-p*v*z+m*w*z;c.n12=k*w*x-h*u*x-k*v*B+f*u*B+h*v*z-f*w*z;c.n13=h*o*x-k*p*x+k*m*B-f*o*B-h*m*z+f*p*z;c.n14=k*p*v-h*o*v-k*m*w+f*o*w+h*m*u-f*p*u;c.n21=o*w*y-p*u*y-o*t*B+j*u*B+p*t*z-j*w*z;c.n22=h*u*y-k*w*y+k*t*B-e*u*B-h*t*z+e*w*z;c.n23=k*p*y-h*o*y-k*j*B+e*o*B+h*j*z-e*p*z;c.n24= +h*o*t-k*p*t+k*j*w-e*o*w-h*j*u+e*p*u;c.n31=m*u*y-o*v*y+o*t*x-j*u*x-m*t*z+j*v*z;c.n32=k*v*y-f*u*y-k*t*x+e*u*x+f*t*z-e*v*z;c.n33=h*o*y-k*m*y+k*j*x-e*o*x-f*j*z+e*m*z;c.n34=k*m*t-f*o*t-k*j*v+e*o*v+f*j*u-e*m*u;c.n41=p*v*y-m*w*y-p*t*x+j*w*x+m*t*B-j*v*B;c.n42=f*w*y-h*v*y+h*t*x-e*w*x-f*t*B+e*v*B;c.n43=h*m*y-f*p*y-h*j*x+e*p*x+f*j*B-e*m*B;c.n44=f*p*t-h*m*t+h*j*v-e*p*v-f*j*w+e*m*w;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,t=-b.n23*b.n11+b.n21*b.n13,v=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*j;e[4]=b*m;e[5]=b*p;e[6]=b*o;e[7]=b*t;e[8]=b*v;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,h,k){var j;j=new THREE.Matrix4;j.n11=2*h/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*h/(f-e);j.n23=(f+e)/(f-e);j.n24=0;j.n31=0;j.n32=0;j.n33=-(k+h)/(k-h);j.n34=-2*k*h/(k-h);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var j,m,o,t;j=new THREE.Matrix4;m=c-b;o=e-f;t=k-h;j.n11=2/m;j.n12=0;j.n13=0;j.n14=-((c+b)/m);j.n21=0;j.n22=2/o;j.n23=0;j.n24=-((e+f)/o);j.n31=0;j.n32=0;j.n33=-2/t;j.n34=-((k+h)/t);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.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var j,m,p,o;j=new THREE.Matrix4;m=c-b;p=e-f;o=k-h;j.n11=2/m;j.n12=0;j.n13=0;j.n14=-((c+b)/m);j.n21=0;j.n22=2/p;j.n23=0;j.n24=-((e+f)/p);j.n31=0;j.n32=0;j.n33=-2/o;j.n34=-((k+h)/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.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.id=THREE.Object3DCount++;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.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;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.receiveShadow=this.castShadow=!1;this._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={constructor:THREE.Object3D,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)=== @@ -55,27 +55,27 @@ this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matri THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),j=b*c,m=f*h;this.w=j*k-m*e;this.x=j*e+m*k;this.y=f*c*k+b*h*e;this.z=b*h*k-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= -this.x,e=this.y,f=this.z,h=this.w,k=b.x,j=b.y,m=b.z,b=b.w;this.x=c*b+h*k+e*m-f*j;this.y=e*b+h*j+f*k-c*m;this.z=f*b+h*m+c*j-e*k;this.w=h*b-c*k-e*j-f*m;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 e=b.x,f=b.y,h=b.z,k=this.x,j=this.y,m=this.z,o=this.w,t=o*e+j*h-m*f,p=o*f+m*e-k*h,v=o*h+k*f-j*e,e=-k* -e-j*f-m*h;c.x=t*o+e*-k+p*-m-v*-j;c.y=p*o+e*-j+v*-k-t*-m;c.z=v*o+e*-m+t*-j-p*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),j=Math.sqrt(1-h*h);if(Math.abs(j)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;h=Math.sin((1-f)*k)/j;f=Math.sin(f*k)/j;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e}; +this.x,e=this.y,f=this.z,h=this.w,k=b.x,j=b.y,m=b.z,b=b.w;this.x=c*b+h*k+e*m-f*j;this.y=e*b+h*j+f*k-c*m;this.z=f*b+h*m+c*j-e*k;this.w=h*b-c*k-e*j-f*m;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 e=b.x,f=b.y,h=b.z,k=this.x,j=this.y,m=this.z,p=this.w,o=p*e+j*h-m*f,t=p*f+m*e-k*h,v=p*h+k*f-j*e,e=-k* +e-j*f-m*h;c.x=o*p+e*-k+t*-m-v*-j;c.y=t*p+e*-j+v*-k-o*-m;c.z=v*p+e*-m+o*-j-t*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),j=Math.sqrt(1-h*h);if(Math.abs(j)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;h=Math.sin((1-f)*k)/j;f=Math.sin(f*k)/j;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e}; THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,h,k){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,h,k,j){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; THREE.Geometry=function(){this.id=THREE.GeometryCount++;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.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,c,e;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,e=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,e=this.vertices.length;cthis.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,e=this.vertices.length;cthis.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;t=this.points[e[0]];p=this.points[e[1]]; -v=this.points[e[2]];w=this.points[e[3]];m=j*j;o=j*m;f.x=c(t.x,p.x,v.x,w.x,j,m,o);f.y=c(t.y,p.y,v.y,w.y,j,m,o);f.z=c(t.z,p.z,v.z,w.z,j,m,o);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;bthis.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;o=this.points[e[0]];t=this.points[e[1]]; +v=this.points[e[2]];w=this.points[e[3]];m=j*j;p=j*m;f.x=c(o.x,t.x,v.x,w.x,j,m,p);f.y=c(o.y,t.y,v.y,w.y,j,m,p);f.z=c(o.z,t.z,v.z,w.z,j,m,p);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b=0&&h>=0&&k>=0&&m>=0?!0:j<0&&h<0||k<0&&m<0?!1:(j<0?e=Math.max(e,j/(j-h)):h<0&&(f=Math.min(f,j/(j-h))),k<0?e=Math.max(e,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),fI&&j.positionScreen.z0&&C.z<1))da=D[H]=D[H]||new THREE.RenderableParticle,H++,z=da,z.x=C.x/C.w,z.y=C.y/C.w,z.z=C.z,z.rotation=W.rotation.z,z.scale.x=W.scale.x*Math.abs(z.x- -(C.x+h.projectionMatrix.n11)/(C.w+h.projectionMatrix.n14)),z.scale.y=W.scale.y*Math.abs(z.y-(C.y+h.projectionMatrix.n22)/(C.w+h.projectionMatrix.n24)),z.materials=W.materials,K.push(z);k&&K.sort(c);return K}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;k=f/2};this.render=function(e,f){var o,t,p,v,w,u,y,x;b=c.projectScene(e,f);o=0;for(t=b.length;o0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+ -Math.floor(y.b*255)+","+x+")"),u.fillRect(Math.floor(na.getX()),Math.floor(na.getY()),Math.floor(na.getWidth()),Math.floor(na.getHeight()))),na.empty())};this.render=function(b,o){function t(b){var c,e,f,j=b.lights;oa.setRGB(0,0,0);Ea.setRGB(0,0,0);Ha.setRGB(0,0,0);b=0;for(c=j.length;b>1,p=t.height>>1,k=j.scale.x*v,o=j.scale.y*w,m=k*sa,n=o*p,ca.set(b.x-m,b.y-n,b.x+m,b.y+n),ra.instersects(ca)&&(u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(k,-o),u.translate(-sa,-p),u.drawImage(t,0,0),u.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(m=j.scale.x*v,n=j.scale.y*w,ca.set(b.x-m,b.y-n,b.x+m,b.y+n),ra.instersects(ca)&&(f(k.color.getContextStyle()),h(k.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(m, -n),k.program(u),u.restore()))}function x(b,j,h,k){c(k.opacity);e(k.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(j.positionScreen.x,j.positionScreen.y);u.closePath();if(k instanceof THREE.LineBasicMaterial){b=k.linewidth;if(I!=b)u.lineWidth=I=b;b=k.linecap;if(K!=b)u.lineCap=K=b;b=k.linejoin;if(M!=b)u.lineJoin=M=b;f(k.color.getContextStyle());u.stroke();ca.inflate(k.linewidth*2)}}function B(b,f,j,h,m,v,t,u,sa){k.data.vertices+=3;k.data.faces++;c(u.opacity);e(u.blending); -N=b.positionScreen.x;P=b.positionScreen.y;n=f.positionScreen.x;V=f.positionScreen.y;ha=j.positionScreen.x;R=j.positionScreen.y;D(N,P,n,V,ha,R);if(u instanceof THREE.MeshBasicMaterial)if(u.map)u.map.mapping instanceof THREE.UVMapping&&(ka=t.uvs[0],$a(N,P,n,V,ha,R,ka[h].u,ka[h].v,ka[m].u,ka[m].v,ka[v].u,ka[v].v,u.map));else if(u.envMap){if(u.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=o.matrixWorldInverse,ta.copy(t.vertexNormalsWorld[0]),ma=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5, -Ga=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,ta.copy(t.vertexNormalsWorld[1]),za=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5,Ja=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,ta.copy(t.vertexNormalsWorld[2]),Ka=(ta.x*b.n11+ta.y*b.n12+ta.z*b.n13)*0.5+0.5,Ua=-(ta.x*b.n21+ta.y*b.n22+ta.z*b.n23)*0.5+0.5,$a(N,P,n,V,ha,R,ma,Ga,za,Ja,Ka,Ua,u.envMap)}else u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshLambertMaterial)u.map&&!u.wireframe&& -(u.map.mapping instanceof THREE.UVMapping&&(ka=t.uvs[0],$a(N,P,n,V,ha,R,ka[h].u,ka[h].v,ka[m].u,ka[m].v,ka[v].u,ka[v].v,u.map)),e(THREE.SubtractiveBlending)),ya?!u.wireframe&&u.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==3?(S.r=W.r=da.r=oa.r,S.g=W.g=da.g=oa.g,S.b=W.b=da.b=oa.b,p(sa,t.v1.positionWorld,t.vertexNormalsWorld[0],S),p(sa,t.v2.positionWorld,t.vertexNormalsWorld[1],W),p(sa,t.v3.positionWorld,t.vertexNormalsWorld[2],da),fa.r=(W.r+da.r)*0.5,fa.g=(W.g+da.g)*0.5,fa.b=(W.b+da.b)* -0.5,qa=Ya(S,W,da,fa),Va(N,P,n,V,ha,R,0,0,1,0,0,1,qa)):(wa.r=oa.r,wa.g=oa.g,wa.b=oa.b,p(sa,t.centroidWorld,t.normalWorld,wa),$.r=Math.max(0,Math.min(u.color.r*wa.r,1)),$.g=Math.max(0,Math.min(u.color.g*wa.g,1)),$.b=Math.max(0,Math.min(u.color.b*wa.b,1)),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)):u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color);else if(u instanceof THREE.MeshDepthMaterial)X=o.near,ja=o.far,S.r= -S.g=S.b=1-Pa(b.positionScreen.z,X,ja),W.r=W.g=W.b=1-Pa(f.positionScreen.z,X,ja),da.r=da.g=da.b=1-Pa(j.positionScreen.z,X,ja),fa.r=(W.r+da.r)*0.5,fa.g=(W.g+da.g)*0.5,fa.b=(W.b+da.b)*0.5,qa=Ya(S,W,da,fa),Va(N,P,n,V,ha,R,0,0,1,0,0,1,qa);else if(u instanceof THREE.MeshNormalMaterial)$.r=Wa(t.normalWorld.x),$.g=Wa(t.normalWorld.y),$.b=Wa(t.normalWorld.z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)}function z(b,f,j,h,m,v,t,u,sa){k.data.vertices+=4;k.data.faces++; -c(u.opacity);e(u.blending);if(u.map||u.envMap)B(b,f,h,0,1,3,t,u,sa),B(m,j,v,1,2,3,t,u,sa);else if(N=b.positionScreen.x,P=b.positionScreen.y,n=f.positionScreen.x,V=f.positionScreen.y,ha=j.positionScreen.x,R=j.positionScreen.y,aa=h.positionScreen.x,Z=h.positionScreen.y,ia=m.positionScreen.x,U=m.positionScreen.y,ea=v.positionScreen.x,ga=v.positionScreen.y,u instanceof THREE.MeshBasicMaterial)H(N,P,n,V,ha,R,aa,Z),u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color); -else if(u instanceof THREE.MeshLambertMaterial)ya?!u.wireframe&&u.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(S.r=W.r=da.r=fa.r=oa.r,S.g=W.g=da.g=fa.g=oa.g,S.b=W.b=da.b=fa.b=oa.b,p(sa,t.v1.positionWorld,t.vertexNormalsWorld[0],S),p(sa,t.v2.positionWorld,t.vertexNormalsWorld[1],W),p(sa,t.v4.positionWorld,t.vertexNormalsWorld[3],da),p(sa,t.v3.positionWorld,t.vertexNormalsWorld[2],fa),qa=Ya(S,W,da,fa),D(N,P,n,V,aa,Z),Va(N,P,n,V,aa,Z,0,0,1,0,0,1,qa),D(ia,U,ha,R,ea,ga),Va(ia,U,ha,R,ea, -ga,1,0,1,1,0,1,qa)):(wa.r=oa.r,wa.g=oa.g,wa.b=oa.b,p(sa,t.centroidWorld,t.normalWorld,wa),$.r=Math.max(0,Math.min(u.color.r*wa.r,1)),$.g=Math.max(0,Math.min(u.color.g*wa.g,1)),$.b=Math.max(0,Math.min(u.color.b*wa.b,1)),H(N,P,n,V,ha,R,aa,Z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($)):(H(N,P,n,V,ha,R,aa,Z),u.wireframe?La(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma(u.color));else if(u instanceof THREE.MeshNormalMaterial)$.r=Wa(t.normalWorld.x), -$.g=Wa(t.normalWorld.y),$.b=Wa(t.normalWorld.z),H(N,P,n,V,ha,R,aa,Z),u.wireframe?La($,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):Ma($);else if(u instanceof THREE.MeshDepthMaterial)X=o.near,ja=o.far,S.r=S.g=S.b=1-Pa(b.positionScreen.z,X,ja),W.r=W.g=W.b=1-Pa(f.positionScreen.z,X,ja),da.r=da.g=da.b=1-Pa(h.positionScreen.z,X,ja),fa.r=fa.g=fa.b=1-Pa(j.positionScreen.z,X,ja),qa=Ya(S,W,da,fa),D(N,P,n,V,aa,Z),Va(N,P,n,V,aa,Z,0,0,1,0,0,1,qa),D(ia,U,ha,R,ea,ga),Va(ia,U,ha,R,ea,ga,1,0,1,1, -0,1,qa)}function D(b,c,e,f,j,h){u.beginPath();u.moveTo(b,c);u.lineTo(e,f);u.lineTo(j,h);u.lineTo(b,c);u.closePath()}function H(b,c,e,f,j,h,k,m){u.beginPath();u.moveTo(b,c);u.lineTo(e,f);u.lineTo(j,h);u.lineTo(k,m);u.lineTo(b,c);u.closePath()}function La(b,c,e,j){if(I!=c)u.lineWidth=I=c;if(K!=e)u.lineCap=K=e;if(M!=j)u.lineJoin=M=j;f(b.getContextStyle());u.stroke();ca.inflate(c*2)}function Ma(b){h(b.getContextStyle());u.fill()}function $a(b,c,e,f,j,k,m,n,o,t,v,sa,p){if(p.image.width!=0){if(p.needsUpdate== -!0||la[p.id]==void 0){var w=p.wrapS==THREE.RepeatWrapping,Ca=p.wrapT==THREE.RepeatWrapping;la[p.id]=u.createPattern(p.image,w&&Ca?"repeat":w&&!Ca?"repeat-x":!w&&Ca?"repeat-y":"no-repeat");p.needsUpdate=!1}h(la[p.id]);var w=p.offset.x/p.repeat.x,Ca=p.offset.y/p.repeat.y,y=(p.image.width-1)*p.repeat.x,p=(p.image.height-1)*p.repeat.y,m=(m+w)*y,n=(n+Ca)*p,o=(o+w)*y,t=(t+Ca)*p,v=(v+w)*y,sa=(sa+Ca)*p;e-=b;f-=c;j-=b;k-=c;o-=m;t-=n;v-=m;sa-=n;w=1/(o*sa-v*t);p=(sa*e-t*j)*w;t=(sa*f-t*k)*w;e=(o*j-v*e)*w;f=(o* -k-v*f)*w;b=b-p*m-e*n;c=c-t*m-f*n;u.save();u.transform(p,t,e,f,b,c);u.fill();u.restore()}}function Va(b,c,e,f,j,h,k,m,n,o,t,v,sa){var p,w;p=sa.width-1;w=sa.height-1;k*=p;m*=w;n*=p;o*=w;t*=p;v*=w;e-=b;f-=c;j-=b;h-=c;n-=k;o-=m;t-=k;v-=m;w=1/(n*v-t*o);p=(v*e-o*j)*w;o=(v*f-o*h)*w;e=(n*j-t*e)*w;f=(n*h-t*f)*w;b=b-p*k-e*m;c=c-o*k-f*m;u.save();u.transform(p,o,e,f,b,c);u.clip();u.drawImage(sa,0,0);u.restore()}function Ya(b,c,e,f){var j=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),k=~~(c.r*255),m=~~(c.g*255),c=~~(c.b* -255),n=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);Aa[0]=j<0?0:j>255?255:j;Aa[1]=h<0?0:h>255?255:h;Aa[2]=b<0?0:b>255?255:b;Aa[4]=k<0?0:k>255?255:k;Aa[5]=m<0?0:m>255?255:m;Aa[6]=c<0?0:c>255?255:c;Aa[8]=n<0?0:n>255?255:n;Aa[9]=o<0?0:o>255?255:o;Aa[10]=e<0?0:e>255?255:e;Aa[12]=u<0?0:u>255?255:u;Aa[13]=t<0?0:t>255?255:t;Aa[14]=f<0?0:f>255?255:f;Ba.putImageData(sa,0,0);Ca.drawImage(T,0,0);return Xa}function Pa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Wa(b){b= -(b+1)*0.5;return b<0?0:b>1?1:b}function Na(b,c){var e=c.x-b.x,f=c.y-b.y,j=e*e+f*f;j!=0&&(j=1/Math.sqrt(j),e*=j,f*=j,c.x+=e,c.y+=f,b.x-=e,b.y-=f)}var Za,ab,pa,Da,Oa,G,A,O;this.autoClear?this.clear():u.setTransform(1,0,0,-1,v,w);k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,o,this.sortElements);(ya=b.lights.length>0)&&t(b);Za=0;for(ab=j.length;Za0&&(e.r+=h.color.r*k,e.g+=h.color.g*k,e.b+=h.color.b*k)):h instanceof THREE.PointLight&&(Y.sub(h.position,c.centroidWorld),Y.normalize(),k=c.normalWorld.dot(Y)*h.intensity,k>0&&(e.r+=h.color.r*k,e.g+=h.color.g*k,e.b+=h.color.b*k))}function c(c,e,j,m,n,u){k.data.vertices+=3;k.data.faces++;N=f(P++);N.setAttribute("d", -"M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?I.copy(n.color):n instanceof THREE.MeshLambertMaterial?D?(K.r=M.r,K.g=M.g,K.b=M.b,b(u,m,K),I.r=Math.max(0,Math.min(n.color.r*K.r,1)),I.g=Math.max(0,Math.min(n.color.g*K.g,1)),I.b=Math.max(0,Math.min(n.color.b*K.b,1))):I.copy(n.color):n instanceof THREE.MeshDepthMaterial?(E=1-n.__2near/(n.__farPlusNear-m.z*n.__farMinusNear), -I.setRGB(E,E,E)):n instanceof THREE.MeshNormalMaterial&&I.setRGB(h(m.normalWorld.x),h(m.normalWorld.y),h(m.normalWorld.z));n.wireframe?N.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):N.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+n.opacity);o.appendChild(N)}function e(c,e,j,m,n,u,t){k.data.vertices+=4;k.data.faces++; -N=f(P++);N.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?I.copy(u.color):u instanceof THREE.MeshLambertMaterial?D?(K.r=M.r,K.g=M.g,K.b=M.b,b(t,n,K),I.r=Math.max(0,Math.min(u.color.r*K.r,1)),I.g=Math.max(0,Math.min(u.color.g*K.g,1)),I.b=Math.max(0,Math.min(u.color.b*K.b,1))):I.copy(u.color):u instanceof -THREE.MeshDepthMaterial?(E=1-u.__2near/(u.__farPlusNear-n.z*u.__farMinusNear),I.setRGB(E,E,E)):u instanceof THREE.MeshNormalMaterial&&I.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));u.wireframe?N.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):N.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+ -u.opacity);o.appendChild(N)}function f(b){F[b]==null&&(F[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&F[b].setAttribute("shape-rendering","crispEdges"));return F[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,j=null,m=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,p,v,w,u,y,x,B,z=new THREE.Rectangle,H=new THREE.Rectangle,D=!1,I=new THREE.Color(16777215),K=new THREE.Color(16777215),M=new THREE.Color(0),C=new THREE.Color(0), -J=new THREE.Color(0),E,Y=new THREE.Vector3,F=[],L=[],N,P,n,V=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":V=1;break;case "low":V=0}};this.setSize=function(b,c){t=b;p=c;v=t/2;w=p/2;o.setAttribute("viewBox",-v+" "+-w+" "+t+" "+p);o.setAttribute("width",t);o.setAttribute("height",p);z.set(-v,-w,v,w)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render= -function(b,f){var h,t,p,I,K,F,E,S;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,f,this.sortElements);n=P=0;if(D=b.lights.length>0){E=b.lights;M.setRGB(0,0,0);C.setRGB(0,0,0);J.setRGB(0,0,0);h=0;for(t=E.length;h=0&&h>=0&&k>=0&&m>=0?!0:j<0&&h<0||k<0&&m<0?!1:(j<0?c=Math.max(c,j/(j-h)):h<0&&(f=Math.min(f,j/(j-h))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),fE&&j.positionScreen.z0&&K.z<1))ga=C[D]=C[D]||new THREE.RenderableParticle,D++,z=ga,z.x=K.x/K.w,z.y=K.y/K.w,z.z=K.z,z.rotation=ca.rotation.z,z.scale.x= +ca.scale.x*Math.abs(z.x-(K.x+h.projectionMatrix.n11)/(K.w+h.projectionMatrix.n14)),z.scale.y=ca.scale.y*Math.abs(z.y-(K.y+h.projectionMatrix.n22)/(K.w+h.projectionMatrix.n24)),z.materials=ca.materials,J.push(z);k&&J.sort(c);return J}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;k=f/2};this.render=function(e,f){var p,o,t,v,w,u,y,x;b=c.projectScene(e,f);p=0;for(o=b.length;p0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* +255)+","+x+")"),u.fillRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(b,p){function o(b){var e,c,f,j=b.lights;wa.setRGB(0,0,0);Ea.setRGB(0,0,0);Fa.setRGB(0,0,0);b=0;for(e=j.length;b>1,t=o.height>>1,k=j.scale.x*v,p=j.scale.y*w,n=k*W,m=p*t,ea.set(b.x-n,b.y-m,b.x+n,b.y+m),pa.instersects(ea)&&(u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(k,-p),u.translate(-W,-t),u.drawImage(o,0,0),u.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(n=j.scale.x*v,m=j.scale.y*w,ea.set(b.x-n,b.y-m,b.x+n,b.y+m),pa.instersects(ea)&&(f(k.color.getContextStyle()),h(k.color.getContextStyle()),u.save(),u.translate(b.x,b.y),u.rotate(-j.rotation),u.scale(n,m), +k.program(u),u.restore()))}function B(b,j,h,k){c(k.opacity);e(k.blending);u.beginPath();u.moveTo(b.positionScreen.x,b.positionScreen.y);u.lineTo(j.positionScreen.x,j.positionScreen.y);u.closePath();if(k instanceof THREE.LineBasicMaterial){b=k.linewidth;if(E!=b)u.lineWidth=E=b;b=k.linecap;if(J!=b)u.lineCap=J=b;b=k.linejoin;if(O!=b)u.lineJoin=O=b;f(k.color.getContextStyle());u.stroke();ea.inflate(k.linewidth*2)}}function x(b,f,j,h,m,v,o,W,u){k.data.vertices+=3;k.data.faces++;c(W.opacity);e(W.blending); +L=b.positionScreen.x;S=b.positionScreen.y;n=f.positionScreen.x;V=f.positionScreen.y;fa=j.positionScreen.x;Q=j.positionScreen.y;D(L,S,n,V,fa,Q);if(W instanceof THREE.MeshBasicMaterial)if(W.map)W.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Ya(L,S,n,V,fa,Q,la[h].u,la[h].v,la[m].u,la[m].v,la[v].u,la[v].v,W.map));else if(W.envMap){if(W.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=p.matrixWorldInverse,na.copy(o.vertexNormalsWorld[0]),sa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5, +Ha=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[1]),oa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,va=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[2]),Ja=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,Da=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,Ya(L,S,n,V,fa,Q,sa,Ha,oa,va,Ja,Da,W.envMap)}else W.wireframe?Ka(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(W.color);else if(W instanceof THREE.MeshLambertMaterial)W.map&&!W.wireframe&& +(W.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Ya(L,S,n,V,fa,Q,la[h].u,la[h].v,la[m].u,la[m].v,la[v].u,la[v].v,W.map)),e(THREE.SubtractiveBlending)),ya?!W.wireframe&&W.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(X.r=ca.r=ga.r=wa.r,X.g=ca.g=ga.g=wa.g,X.b=ca.b=ga.b=wa.b,t(u,o.v1.positionWorld,o.vertexNormalsWorld[0],X),t(u,o.v2.positionWorld,o.vertexNormalsWorld[1],ca),t(u,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),ia.r=(ca.r+ga.r)*0.5,ia.g=(ca.g+ga.g)*0.5,ia.b=(ca.b+ +ga.b)*0.5,ra=Wa(X,ca,ga,ia),Ta(L,S,n,V,fa,Q,0,0,1,0,0,1,ra)):(xa.r=wa.r,xa.g=wa.g,xa.b=wa.b,t(u,o.centroidWorld,o.normalWorld,xa),ha.r=Math.max(0,Math.min(W.color.r*xa.r,1)),ha.g=Math.max(0,Math.min(W.color.g*xa.g,1)),ha.b=Math.max(0,Math.min(W.color.b*xa.b,1)),W.wireframe?Ka(ha,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(ha)):W.wireframe?Ka(W.color,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(W.color);else if(W instanceof THREE.MeshDepthMaterial)Z=p.near,N= +p.far,X.r=X.g=X.b=1-Oa(b.positionScreen.z,Z,N),ca.r=ca.g=ca.b=1-Oa(f.positionScreen.z,Z,N),ga.r=ga.g=ga.b=1-Oa(j.positionScreen.z,Z,N),ia.r=(ca.r+ga.r)*0.5,ia.g=(ca.g+ga.g)*0.5,ia.b=(ca.b+ga.b)*0.5,ra=Wa(X,ca,ga,ia),Ta(L,S,n,V,fa,Q,0,0,1,0,0,1,ra);else if(W instanceof THREE.MeshNormalMaterial)ha.r=Ua(o.normalWorld.x),ha.g=Ua(o.normalWorld.y),ha.b=Ua(o.normalWorld.z),W.wireframe?Ka(ha,W.wireframeLinewidth,W.wireframeLinecap,W.wireframeLinejoin):La(ha)}function z(b,f,j,h,m,v,W,o,u){k.data.vertices+= +4;k.data.faces++;c(o.opacity);e(o.blending);if(o.map||o.envMap)x(b,f,h,0,1,3,W,o,u),x(m,j,v,1,2,3,W,o,u);else if(L=b.positionScreen.x,S=b.positionScreen.y,n=f.positionScreen.x,V=f.positionScreen.y,fa=j.positionScreen.x,Q=j.positionScreen.y,da=h.positionScreen.x,$=h.positionScreen.y,ka=m.positionScreen.x,U=m.positionScreen.y,aa=v.positionScreen.x,ja=v.positionScreen.y,o instanceof THREE.MeshBasicMaterial)C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin): +La(o.color);else if(o instanceof THREE.MeshLambertMaterial)ya?!o.wireframe&&o.shading==THREE.SmoothShading&&W.vertexNormalsWorld.length==4?(X.r=ca.r=ga.r=ia.r=wa.r,X.g=ca.g=ga.g=ia.g=wa.g,X.b=ca.b=ga.b=ia.b=wa.b,t(u,W.v1.positionWorld,W.vertexNormalsWorld[0],X),t(u,W.v2.positionWorld,W.vertexNormalsWorld[1],ca),t(u,W.v4.positionWorld,W.vertexNormalsWorld[3],ga),t(u,W.v3.positionWorld,W.vertexNormalsWorld[2],ia),ra=Wa(X,ca,ga,ia),D(L,S,n,V,da,$),Ta(L,S,n,V,da,$,0,0,1,0,0,1,ra),D(ka,U,fa,Q,aa,ja),Ta(ka, +U,fa,Q,aa,ja,1,0,1,1,0,1,ra)):(xa.r=wa.r,xa.g=wa.g,xa.b=wa.b,t(u,W.centroidWorld,W.normalWorld,xa),ha.r=Math.max(0,Math.min(o.color.r*xa.r,1)),ha.g=Math.max(0,Math.min(o.color.g*xa.g,1)),ha.b=Math.max(0,Math.min(o.color.b*xa.b,1)),C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(ha,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(ha)):(C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(o.color));else if(o instanceof THREE.MeshNormalMaterial)ha.r= +Ua(W.normalWorld.x),ha.g=Ua(W.normalWorld.y),ha.b=Ua(W.normalWorld.z),C(L,S,n,V,fa,Q,da,$),o.wireframe?Ka(ha,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):La(ha);else if(o instanceof THREE.MeshDepthMaterial)Z=p.near,N=p.far,X.r=X.g=X.b=1-Oa(b.positionScreen.z,Z,N),ca.r=ca.g=ca.b=1-Oa(f.positionScreen.z,Z,N),ga.r=ga.g=ga.b=1-Oa(h.positionScreen.z,Z,N),ia.r=ia.g=ia.b=1-Oa(j.positionScreen.z,Z,N),ra=Wa(X,ca,ga,ia),D(L,S,n,V,da,$),Ta(L,S,n,V,da,$,0,0,1,0,0,1,ra),D(ka,U,fa,Q,aa,ja),Ta(ka, +U,fa,Q,aa,ja,1,0,1,1,0,1,ra)}function D(b,e,c,f,j,h){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(j,h);u.lineTo(b,e);u.closePath()}function C(b,e,c,f,j,h,k,n){u.beginPath();u.moveTo(b,e);u.lineTo(c,f);u.lineTo(j,h);u.lineTo(k,n);u.lineTo(b,e);u.closePath()}function Ka(b,e,c,j){if(E!=e)u.lineWidth=E=e;if(J!=c)u.lineCap=J=c;if(O!=j)u.lineJoin=O=j;f(b.getContextStyle());u.stroke();ea.inflate(e*2)}function La(b){h(b.getContextStyle());u.fill()}function Ya(b,e,c,f,j,k,n,m,o,W,p,v,t){if(t.image.width!= +0){if(t.needsUpdate==!0||ma[t.id]==void 0){var w=t.wrapS==THREE.RepeatWrapping,Ba=t.wrapT==THREE.RepeatWrapping;ma[t.id]=u.createPattern(t.image,w&&Ba?"repeat":w&&!Ba?"repeat-x":!w&&Ba?"repeat-y":"no-repeat");t.needsUpdate=!1}h(ma[t.id]);var w=t.offset.x/t.repeat.x,Ba=t.offset.y/t.repeat.y,y=(t.image.width-1)*t.repeat.x,t=(t.image.height-1)*t.repeat.y,n=(n+w)*y,m=(m+Ba)*t,o=(o+w)*y,W=(W+Ba)*t,p=(p+w)*y,v=(v+Ba)*t;c-=b;f-=e;j-=b;k-=e;o-=n;W-=m;p-=n;v-=m;w=1/(o*v-p*W);t=(v*c-W*j)*w;W=(v*f-W*k)*w;c= +(o*j-p*c)*w;f=(o*k-p*f)*w;b=b-t*n-c*m;e=e-W*n-f*m;u.save();u.transform(t,W,c,f,b,e);u.fill();u.restore()}}function Ta(b,e,c,f,j,h,k,n,m,o,W,p,v){var t,w;t=v.width-1;w=v.height-1;k*=t;n*=w;m*=t;o*=w;W*=t;p*=w;c-=b;f-=e;j-=b;h-=e;m-=k;o-=n;W-=k;p-=n;w=1/(m*p-W*o);t=(p*c-o*j)*w;o=(p*f-o*h)*w;c=(m*j-W*c)*w;f=(m*h-W*f)*w;b=b-t*k-c*n;e=e-o*k-f*n;u.save();u.transform(t,o,c,f,b,e);u.clip();u.drawImage(v,0,0);u.restore()}function Wa(b,e,c,f){var j=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),k=~~(e.r*255),n=~~(e.g* +255),e=~~(e.b*255),m=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),v=~~(f.g*255),f=~~(f.b*255);za[0]=j<0?0:j>255?255:j;za[1]=h<0?0:h>255?255:h;za[2]=b<0?0:b>255?255:b;za[4]=k<0?0:k>255?255:k;za[5]=n<0?0:n>255?255:n;za[6]=e<0?0:e>255?255:e;za[8]=m<0?0:m>255?255:m;za[9]=o<0?0:o>255?255:o;za[10]=c<0?0:c>255?255:c;za[12]=p<0?0:p>255?255:p;za[13]=v<0?0:v>255?255:v;za[14]=f<0?0:f>255?255:f;Aa.putImageData(W,0,0);Ba.drawImage(T,0,0);return Va}function Oa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Ua(b){b= +(b+1)*0.5;return b<0?0:b>1?1:b}function Ma(b,e){var c=e.x-b.x,f=e.y-b.y,j=c*c+f*f;j!=0&&(j=1/Math.sqrt(j),c*=j,f*=j,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Xa,Za,qa,Ca,Na,H,A,P;this.autoClear?this.clear():u.setTransform(1,0,0,-1,v,w);k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,p,this.sortElements);(ya=b.lights.length>0)&&o(b);Xa=0;for(Za=j.length;Xa0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k)):h instanceof THREE.PointLight&&(Y.sub(h.position,e.centroidWorld),Y.normalize(),k=e.normalWorld.dot(Y)*h.intensity,k>0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k))}function c(e,c,j,n,m,o){k.data.vertices+=3;k.data.faces++;L=f(S++);L.setAttribute("d", +"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?E.copy(m.color):m instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(o,n,J),E.r=Math.max(0,Math.min(m.color.r*J.r,1)),E.g=Math.max(0,Math.min(m.color.g*J.g,1)),E.b=Math.max(0,Math.min(m.color.b*J.b,1))):E.copy(m.color):m instanceof THREE.MeshDepthMaterial?(F=1-m.__2near/(m.__farPlusNear-n.z*m.__farMinusNear), +E.setRGB(F,F,F)):m instanceof THREE.MeshNormalMaterial&&E.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));m.wireframe?L.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):L.setAttribute("style","fill: "+E.getContextStyle()+"; fill-opacity: "+m.opacity);p.appendChild(L)}function e(e,c,j,n,m,o,v){k.data.vertices+=4;k.data.faces++; +L=f(S++);L.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");o instanceof THREE.MeshBasicMaterial?E.copy(o.color):o instanceof THREE.MeshLambertMaterial?C?(J.r=O.r,J.g=O.g,J.b=O.b,b(v,m,J),E.r=Math.max(0,Math.min(o.color.r*J.r,1)),E.g=Math.max(0,Math.min(o.color.g*J.g,1)),E.b=Math.max(0,Math.min(o.color.b*J.b,1))):E.copy(o.color):o instanceof +THREE.MeshDepthMaterial?(F=1-o.__2near/(o.__farPlusNear-m.z*o.__farMinusNear),E.setRGB(F,F,F)):o instanceof THREE.MeshNormalMaterial&&E.setRGB(h(m.normalWorld.x),h(m.normalWorld.y),h(m.normalWorld.z));o.wireframe?L.setAttribute("style","fill: none; stroke: "+E.getContextStyle()+"; stroke-width: "+o.wireframeLinewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframeLinecap+"; stroke-linejoin: "+o.wireframeLinejoin):L.setAttribute("style","fill: "+E.getContextStyle()+"; fill-opacity: "+ +o.opacity);p.appendChild(L)}function f(b){G[b]==null&&(G[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&G[b].setAttribute("shape-rendering","crispEdges"));return G[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,j=null,m=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,v,w,u,y,x,B,z=new THREE.Rectangle,D=new THREE.Rectangle,C=!1,E=new THREE.Color(16777215),J=new THREE.Color(16777215),O=new THREE.Color(0),K=new THREE.Color(0), +I=new THREE.Color(0),F,Y=new THREE.Vector3,G=[],M=[],L,S,n,V=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":V=1;break;case "low":V=0}};this.setSize=function(b,e){o=b;t=e;v=o/2;w=t/2;p.setAttribute("viewBox",-v+" "+-w+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);z.set(-v,-w,v,w)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render= +function(b,f){var h,o,t,E,J,G,F,X;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;j=m.projectScene(b,f,this.sortElements);n=S=0;if(C=b.lights.length>0){F=b.lights;O.setRGB(0,0,0);K.setRGB(0,0,0);I.setRGB(0,0,0);h=0;for(o=F.length;h=0)n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer),n.vertexAttribPointer(b.position, -3,n.FLOAT,!1,0,0);else if(k.morphTargetBase){c=j.program.attributes;k.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,o=k.morphTargetForcedOrder,u=k.morphTargetInfluences;ft&&(v=p,t=u[v]);n.bindBuffer(n.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[v]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=t;o[v]=1;t= --1;f++}}j.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[m],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglNormalBuffer), -n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglTangentBuffer),n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,h.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)): -n.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,h.__webglSkinWeightsBuffer), -n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(n.lineWidth(j.wireframeLinewidth),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),n.drawElements(n.LINES,h.__webglLineCount,n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),n.drawElements(n.TRIANGLES,h.__webglFaceCount,n.UNSIGNED_SHORT,0)),P.data.vertices+=h.__webglFaceCount,P.data.faces+=h.__webglFaceCount/3,P.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip? -n.LINE_STRIP:n.LINES,n.lineWidth(j.linewidth),n.drawArrays(k,0,h.__webglLineCount),P.data.drawCalls++):k instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,h.__webglParticleCount),P.data.drawCalls++):k instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,h.__webglVertexCount),P.data.drawCalls++)}}function h(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer), -n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(c.attributes.position),n.vertexAttribPointer(c.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,h,j,k,m,o,u,t,v,p,w=b.count*3;for(p=0;p=0;e--)b[e].object==c&&b.splice(e,1)}function I(b){function c(b){var h=[];e=0;for(f=b.length;e65535&&(u[n].counter+=1,o=u[n].hash+"_"+u[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[], -materials:m,vertices:0,numMorphTargets:v})),b.geometryGroups[o].faces.push(h),b.geometryGroups[o].vertices+=k}function K(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(b){if(b!=U){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO, -n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}U=b}}function C(b,c,e){(e.width&e.width-1)==0&&(e.height&e.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,N(c.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,N(c.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,N(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,N(c.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE), -n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,L(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,L(c.minFilter)))}function J(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=n.createTexture();n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,N(b.format),b.image.width,b.image.height,0,N(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D, -0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);C(n.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function E(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();if(c){n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture);C(n.TEXTURE_CUBE_MAP, -b,b);b.__webglFramebuffer=[];for(var e=0;e<6;e++)b.__webglFramebuffer[e]=n.createFramebuffer(),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,N(b.format),b.width,b.height,0,N(b.format),N(b.type),null)}else b.__webglFramebuffer=n.createFramebuffer(),n.bindTexture(n.TEXTURE_2D,b.__webglTexture),C(n.TEXTURE_2D,b,b),n.texImage2D(n.TEXTURE_2D,0,N(b.format),b.width,b.height,0,N(b.format),N(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(e=0;e<6;++e)n.bindFramebuffer(n.FRAMEBUFFER, -b.__webglFramebuffer[e]),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+e,b.__webglTexture,0);else n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&& -b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,b.width,b.height);c?n.bindTexture(n.TEXTURE_CUBE_MAP,null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,e=b.width,b=b.height, -h=f=0):(c=null,e=fa,b=la,f=W,h=da);c!=R&&(n.bindFramebuffer(n.FRAMEBUFFER,c),n.viewport(f,h,e,b),R=c)}function Y(b){b instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP),n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D,b.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function F(b,c){var e;b=="fragment"?e=n.createShader(n.FRAGMENT_SHADER):b=="vertex"&&(e=n.createShader(n.VERTEX_SHADER)); -n.shaderSource(e,c);n.compileShader(e);if(!n.getShaderParameter(e,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(e)),console.error(c),null;return e}function L(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST;default:return n.LINEAR}}function N(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT; +THREE.WebGLRenderer=function(b){function c(b,e,c){var f,j,h,k=b.vertices,m=k.length,o=b.colors,p=o.length,v=b.__vertexArray,t=b.__colorArray,u=b.__sortArray,w=b.__dirtyVertices,y=b.__dirtyColors,x=b.__webglCustomAttributes,B,z;if(x)for(B in x)x[B].offset=0;if(c.sortParticles){N.multiplySelf(c.matrixWorld);for(f=0;f=0)n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer),n.vertexAttribPointer(b.position, +3,n.FLOAT,!1,0,0);else if(k.morphTargetBase){c=h.program.attributes;k.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[k.morphTargetBase]),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,o=k.morphTargetForcedOrder,p=k.morphTargetInfluences;fv&&(t=u,v=p[t]);n.bindBuffer(n.ARRAY_BUFFER,j.__webglMorphTargetsBuffers[t]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=v;o[t]=1;v= +-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(h.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(j.__webglCustomAttributes)for(m in j.__webglCustomAttributes)b[m]>=0&&(c=j.__webglCustomAttributes[m],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[m],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglNormalBuffer), +n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglTangentBuffer),n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(j.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(j.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,j.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)): +n.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,j.__webglSkinWeightsBuffer), +n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));k instanceof THREE.Mesh?(h.wireframe?(n.lineWidth(h.wireframeLinewidth),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,j.__webglLineBuffer),n.drawElements(n.LINES,j.__webglLineCount,n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,j.__webglFaceBuffer),n.drawElements(n.TRIANGLES,j.__webglFaceCount,n.UNSIGNED_SHORT,0)),S.data.vertices+=j.__webglFaceCount,S.data.faces+=j.__webglFaceCount/3,S.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip? +n.LINE_STRIP:n.LINES,n.lineWidth(h.linewidth),n.drawArrays(k,0,j.__webglLineCount),S.data.drawCalls++):k instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,j.__webglParticleCount),S.data.drawCalls++):k instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,j.__webglVertexCount),S.data.drawCalls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer), +n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(e.attributes.position),n.vertexAttribPointer(e.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,j,h,k,m,o,p,v,t,u,w=b.count*3;for(u=0;u=0;c--)b[c].object==e&&b.splice(c,1)}function E(b){function e(b){var j=[];c=0;for(f=b.length;c65535&&(p[n].counter+=1,o=p[n].hash+"_"+p[n].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[], +materials:m,vertices:0,numMorphTargets:v})),b.geometryGroups[o].faces.push(j),b.geometryGroups[o].vertices+=k}function J(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function O(b){if(b!=U){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO, +n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}U=b}}function K(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,L(e.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,L(e.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,L(e.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,L(e.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE), +n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,M(e.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,M(e.minFilter)))}function I(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=n.createTexture();n.activeTexture(n.TEXTURE0+e);n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,L(b.format),b.image.width,b.image.height,0,L(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D, +0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);K(n.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+e),n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function F(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();if(e){n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture);K(n.TEXTURE_CUBE_MAP, +b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=n.createFramebuffer(),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,L(b.format),b.width,b.height,0,L(b.format),L(b.type),null)}else b.__webglFramebuffer=n.createFramebuffer(),n.bindTexture(n.TEXTURE_2D,b.__webglTexture),K(n.TEXTURE_2D,b,b),n.texImage2D(n.TEXTURE_2D,0,L(b.format),b.width,b.height,0,L(b.format),L(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)n.bindFramebuffer(n.FRAMEBUFFER, +b.__webglFramebuffer[c]),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&& +b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER,n.RGBA4,b.width,b.height);e?n.bindTexture(n.TEXTURE_CUBE_MAP,null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var f,j;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height, +j=f=0):(e=null,c=ia,b=ma,f=ca,j=ga);e!=Q&&(n.bindFramebuffer(n.FRAMEBUFFER,e),n.viewport(f,j,c,b),Q=e)}function Y(b){b instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP),n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D,b.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function G(b,e){var c;b=="fragment"?c=n.createShader(n.FRAGMENT_SHADER):b=="vertex"&&(c=n.createShader(n.VERTEX_SHADER)); +n.shaderSource(c,e);n.compileShader(c);if(!n.getShaderParameter(c,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(c)),console.error(e),null;return c}function M(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST;default:return n.LINEAR}}function L(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT; case THREE.NearestFilter:return n.NEAREST;case THREE.NearestMipMapNearestFilter:return n.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return n.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return n.LINEAR;case THREE.LinearMipMapNearestFilter:return n.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return n.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return n.BYTE;case THREE.UnsignedByteType:return n.UNSIGNED_BYTE;case THREE.ShortType:return n.SHORT;case THREE.UnsignedShortType:return n.UNSIGNED_SHORT; -case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0}var P=this,n,V=[],ha=null,R=null,aa=!0,Z=null,ia=null,U=null,ea=null,ga=null,$=null,S=null,W=0,da=0,fa=0,la=0,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, -new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,qa=new Float32Array(16),ka=new Float32Array(16),ma=new THREE.Vector4,Ga={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},za=b.canvas!==void 0?b.canvas:document.createElement("canvas"),Ja=b.stencil!==void 0?b.stencil:!0,Ka=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Ua=b.antialias!==void 0?b.antialias:!1,ra=b.clearColor!==void 0?new THREE.Color(b.clearColor): -new THREE.Color(0),na=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=za;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ca,ya=[],b=THREE.ShaderLib.depthRGBA, -wa=THREE.UniformsUtils.clone(b.uniforms),oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa}),Ea=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:wa,morphTargets:!0});oa._shadowPass=!0;Ea._shadowPass=!0;try{if(!(n=za.getContext("experimental-webgl",{antialias:Ua,stencil:Ja,preserveDrawingBuffer:Ka})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+ -" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Ha){console.error(Ha)}n.clearColor(0,0,0,1);n.clearDepth(1);n.clearStencil(0);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(ra.r,ra.g,ra.b,na);this.context=n;var ta=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0, +case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0}var S=this,n,V=[],fa=null,Q=null,da=!0,$=null,ka=null,U=null,aa=null,ja=null,ha=null,X=null,ca=0,ga=0,ia=0,ma=0,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, +new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Matrix4,ra=new Float32Array(16),la=new Float32Array(16),sa=new THREE.Vector4,Ha={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},oa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),va=b.stencil!==void 0?b.stencil:!0,Ja=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Da=b.antialias!==void 0?b.antialias:!1,pa=b.clearColor!==void 0?new THREE.Color(b.clearColor): +new THREE.Color(0),ta=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=oa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ea,ya=[],b=THREE.ShaderLib.depthRGBA, +xa=THREE.UniformsUtils.clone(b.uniforms),wa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa}),Ea=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa,morphTargets:!0});wa._shadowPass=!0;Ea._shadowPass=!0;try{if(!(n=oa.getContext("experimental-webgl",{antialias:Da,stencil:va,preserveDrawingBuffer:Ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+ +" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Fa){console.error(Fa)}n.clearColor(0,0,0,1);n.clearDepth(1);n.clearStencil(0);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(pa.r,pa.g,pa.b,ta);this.context=n;var na=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0, T={};T.vertices=new Float32Array(16);T.faces=new Uint16Array(6);i=0;T.vertices[i++]=-1;T.vertices[i++]=-1;T.vertices[i++]=0;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=-1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=1;T.vertices[i++]=0;T.vertices[i++]=-1;T.vertices[i++]=1;T.vertices[i++]=0;i=T.vertices[i++]=0;T.faces[i++]=0;T.faces[i++]=1;T.faces[i++]=2;T.faces[i++]=0;T.faces[i++]=2;T.faces[i++]=3;T.vertexBuffer=n.createBuffer();T.elementBuffer=n.createBuffer(); -n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,T.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,T.faces,n.STATIC_DRAW);T.program=n.createProgram();n.attachShader(T.program,F("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(T.program,F("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.position=n.getAttribLocation(T.program,"position"); +n.bindBuffer(n.ARRAY_BUFFER,T.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,T.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,T.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,T.faces,n.STATIC_DRAW);T.program=n.createProgram();n.attachShader(T.program,G("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(T.program,G("vertex",THREE.ShaderLib.sprite.vertexShader));n.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.position=n.getAttribLocation(T.program,"position"); T.attributes.uv=n.getAttribLocation(T.program,"uv");T.uniforms.uvOffset=n.getUniformLocation(T.program,"uvOffset");T.uniforms.uvScale=n.getUniformLocation(T.program,"uvScale");T.uniforms.rotation=n.getUniformLocation(T.program,"rotation");T.uniforms.scale=n.getUniformLocation(T.program,"scale");T.uniforms.alignment=n.getUniformLocation(T.program,"alignment");T.uniforms.map=n.getUniformLocation(T.program,"map");T.uniforms.opacity=n.getUniformLocation(T.program,"opacity");T.uniforms.useScreenCoordinates= -n.getUniformLocation(T.program,"useScreenCoordinates");T.uniforms.affectedByDistance=n.getUniformLocation(T.program,"affectedByDistance");T.uniforms.screenPosition=n.getUniformLocation(T.program,"screenPosition");T.uniforms.modelViewMatrix=n.getUniformLocation(T.program,"modelViewMatrix");T.uniforms.projectionMatrix=n.getUniformLocation(T.program,"projectionMatrix");var Ba=!1;this.setSize=function(b,c){za.width=b;za.height=c;this.setViewport(0,0,za.width,za.height)};this.setViewport=function(b,c, -e,f){W=b;da=c;fa=e;la=f;n.viewport(W,da,fa,la)};this.setScissor=function(b,c,e,f){n.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){aa=b;n.depthMask(b)};this.setClearColorHex=function(b,c){ra.setHex(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.setClearColor=function(b,c){ra.copy(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)}; -this.getContext=function(){return n};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];n.deleteBuffer(c.__webglVertexBuffer);n.deleteBuffer(c.__webglNormalBuffer);n.deleteBuffer(c.__webglTangentBuffer);n.deleteBuffer(c.__webglColorBuffer);n.deleteBuffer(c.__webglUVBuffer); -n.deleteBuffer(c.__webglUV2Buffer);n.deleteBuffer(c.__webglSkinVertexABuffer);n.deleteBuffer(c.__webglSkinVertexBBuffer);n.deleteBuffer(c.__webglSkinIndicesBuffer);n.deleteBuffer(c.__webglSkinWeightsBuffer);n.deleteBuffer(c.__webglFaceBuffer);n.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var e=0,f=c.numMorphTargets;e=0&&n.enableVertexAttribArray(p.position);p.color>=0&&n.enableVertexAttribArray(p.color);p.normal>=0&&n.enableVertexAttribArray(p.normal);p.tangent>=0&&n.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(n.enableVertexAttribArray(p.skinVertexA),n.enableVertexAttribArray(p.skinVertexB),n.enableVertexAttribArray(p.skinIndex), -n.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(h in b.attributes)p[h]!==void 0&&p[h]>=0&&n.enableVertexAttribArray(p[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(n.enableVertexAttribArray(p[y]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,e,f){E(b);b=0;c&&(b|=n.COLOR_BUFFER_BIT);e&&(b|=n.DEPTH_BUFFER_BIT);f&&(b|=n.STENCIL_BUFFER_BIT);n.clear(b)};this.render=function(b,c,n,p){var z,D,H,I,X,J,K,F,C=b.lights, -N=b.fog;this.shadowMapEnabled&&y(b,c);P.data.vertices=0;P.data.faces=0;P.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(ka);c.projectionMatrix.flattenToArray(qa);ja.multiply(c.projectionMatrix,c.matrixWorldInverse);o(ja);this.initWebGLObjects(b);E(n);(this.autoClear||p)&&this.clear();X=b.__webglObjects.length;for(p=0;p=0;p--)if(z=b.__webglObjects[p],z.render){K=z.object;F=z.buffer;H=z.opaque;k(K);for(z=0;z=0&&n.enableVertexAttribArray(u.position);u.color>=0&&n.enableVertexAttribArray(u.color);u.normal>=0&&n.enableVertexAttribArray(u.normal);u.tangent>=0&&n.enableVertexAttribArray(u.tangent);b.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(n.enableVertexAttribArray(u.skinVertexA),n.enableVertexAttribArray(u.skinVertexB),n.enableVertexAttribArray(u.skinIndex), +n.enableVertexAttribArray(u.skinWeight));if(b.attributes)for(j in b.attributes)u[j]!==void 0&&u[j]>=0&&n.enableVertexAttribArray(u[j]);if(b.morphTargets)for(j=b.numSupportedMorphTargets=0;j=0&&(n.enableVertexAttribArray(u[x]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,e,f){F(b);b=0;c&&(b|=n.COLOR_BUFFER_BIT);e&&(b|=n.DEPTH_BUFFER_BIT);f&&(b|=n.STENCIL_BUFFER_BIT);n.clear(b)};this.render=function(b,c,n,t){var z,D,C,E,Z,I,J,G,K=b.lights, +M=b.fog;this.shadowMapEnabled&&y(b,c);S.data.vertices=0;S.data.faces=0;S.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(la);c.projectionMatrix.flattenToArray(ra);N.multiply(c.projectionMatrix,c.matrixWorldInverse);p(N);this.initWebGLObjects(b);F(n);(this.autoClear||t)&&this.clear();Z=b.__webglObjects.length;for(t=0;t=0;t--)if(z=b.__webglObjects[t],z.render){J=z.object;G=z.buffer;C=z.opaque;k(J);for(z=0;z0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)m.__skinVertexAArray= -new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(x*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(y=m.numMorphTargets;w=0;j--)e[j]==f&&e.splice(j,1)}else f instanceof THREE.MarchingCubes&&D(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,la,p));Ba&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,ea,p));Ja&&xa.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,ma,p));ya&&Y>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ga,p));ya&&T>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER, -ha,p));wa&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ra,p),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,oa,p));Q>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,aa,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,ca,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,ua,p),n.bindBuffer(n.ARRAY_BUFFER, -o.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,va,p));J&&(delete o.__inittedArrays,delete o.__colorArray,delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements=!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors= -!1;H(m)}else if(h instanceof THREE.Ribbon){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=n.DYNAMIC_DRAW;m=B=x=x=void 0;w=h.vertices;o=h.colors;u=w.length;p=o.length;v=h.__vertexArray;J=h.__colorArray;y=h.__dirtyColors;if(h.__dirtyVertices){for(x=0;x0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(o.geometry.skinWeights.length&&o.geometry.skinIndices.length)m.__skinVertexAArray= +new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(y*3+(o.geometry.edgeFaces?o.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(x=m.numMorphTargets;w=0;h--)e[h]==f&&e.splice(h,1)}else f instanceof THREE.MarchingCubes&&C(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,ma,p));ya&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,fa,p));Aa&&va.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,aa,p));Da&&Y>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ha,p));Da&&T>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,ja,p));Ja&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, +o.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ta,p),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,na,p));R>0&&(n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,da,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,ea,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,oa,p),n.bindBuffer(n.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER, +ua,p));I&&(delete o.__inittedArrays,delete o.__colorArray,delete o.__normalArray,delete o.__tangentArray,delete o.__uvArray,delete o.__uv2Array,delete o.__faceArray,delete o.__vertexArray,delete o.__lineArray,delete o.__skinVertexAArray,delete o.__skinVertexBArray,delete o.__skinIndexArray,delete o.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;D(m)}else if(j instanceof THREE.Ribbon){h= +j.geometry;if(h.__dirtyVertices||h.__dirtyColors){j=h;k=n.DYNAMIC_DRAW;m=B=y=y=void 0;w=j.vertices;o=j.colors;t=w.length;p=o.length;v=j.__vertexArray;I=j.__colorArray;x=j.__dirtyColors;if(j.__dirtyVertices){for(y=0;y1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=j;c.v=k;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,h=e?c.geometry:c,k=b.vertices,j=h.vertices,m=b.faces,o=h.faces,t=b.faceVertexUvs[0],h=h.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,v=j.length;p1&&(f=1-f,h=1-h);k=1-f-h;j.copy(b);j.multiplyScalar(f);m.copy(c);m.multiplyScalar(h);j.addSelf(m);m.copy(e);m.multiplyScalar(k);j.addSelf(m);return j},randomPointInFace:function(b, +THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,h=e?c.geometry:c,k=b.vertices,j=h.vertices,m=b.faces,p=h.faces,o=b.faceVertexUvs[0],h=h.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var t=0,v=j.length;t1&&(f=1-f,h=1-h);k=1-f-h;j.copy(b);j.multiplyScalar(f);m.copy(c);m.multiplyScalar(h);j.addSelf(m);m.copy(e);m.multiplyScalar(k);j.addSelf(m);return j},randomPointInFace:function(b, c,e){var f,h,k;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,k=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,k);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;k=c.vertices[b.c].position;var c=c.vertices[b.d].position,j;e?b._area1&&b._area2?(e=b._area1,j=b._area2):(e=THREE.GeometryUtils.triangleArea(f,h,c),j=THREE.GeometryUtils.triangleArea(h,k,c),b._area1=e,b._area2=j):(e=THREE.GeometryUtils.triangleArea(f, -h,c),j=THREE.GeometryUtils.triangleArea(h,k,c));return THREE.GeometryUtils.random()*(e+j)b?c(e,h-1):t[h]b?e(c,j-1):o[j] 0\nvec4 pointTotal = vec4( vec3( 0.0 ), 1.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\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 = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( vec3( 0.0 ), 1.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 + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}}; -THREE.AnimationHandler=function(){var b=[],c={},e={update:function(c){for(var e=0;e1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +THREE.Animation.prototype.update=function(b){if(this.isPlaying){var c=["pos","rot","scl"],e,f,h,k,j,m,p,o,t=this.data.JIT.hierarchy,v,w;this.currentTime+=b*this.timeScale;w=this.currentTime;v=this.currentTime%=this.data.length;o=parseInt(Math.min(v*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,y=this.hierarchy.length;u1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;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]=h,this.points[2]=k,this.points[3]=this.getNextKeyWith("pos",u,m.index+1).pos,f=f*0.33+0.33,h=this.interpolateCatmullRom(this.points,f),e.x=h[0],e.y=h[1],e.z=h[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== -"rot")THREE.Quaternion.slerp(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&p[0][t]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];m=b[e[1]];o=b[e[2]];t=b[e[3]];e=h*h;j=h*e;f[0]=this.interpolate(k[0],m[0],o[0],t[0],h,e,j);f[1]=this.interpolate(k[1],m[1],o[1],t[1],h,e,j);f[2]=this.interpolate(k[2],m[2],o[2],t[2],h,e,j);return f}; +"rot")THREE.Quaternion.slerp(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&t[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];m=b[e[1]];p=b[e[2]];o=b[e[3]];e=h*h;j=h*e;f[0]=this.interpolate(k[0],m[0],p[0],o[0],h,e,j);f[1]=this.interpolate(k[1],m[1],p[1],o[1],h,e,j);f[2]=this.interpolate(k[2],m[2],p[2],o[2],h,e,j);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,h,k,j){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*j+(-3*(c-e)-2*b-f)*k+b*h+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; THREE.FirstPersonCamera=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= @@ -386,15 +386,15 @@ this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown 1;this.constrainVertical&&(b=3.14/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*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;b=this.target.position;h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.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.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.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,e,f){var h={name:e,fps:0.6,length:f,hierarchy:[]},j,k=c.getControlPointsArray(),m=c.getLength(),o=k.length,H=0;j=o-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[j]={time:f,pos:k[j],rot:[0,0,0,1],scl:[1,1,1]};for(j=1;j=0?f:f+h;f=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var m=j[1]-j[0];this.phi= -TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;m=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,e)};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}),m=new THREE.CubeGeometry(10,10,20),o=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(o,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&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.apply(b,arguments)}}(this,this.onMouseMove), +window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var h=Math.PI*2,k=Math.PI/180;this.update=function(b,e,c){var f,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)*k;this.theta=this.lon*k;f=this.phi%h;this.phi=f>=0?f:f+h;f=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var m=j[1]-j[0];this.phi= +TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;m=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};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}),m=new THREE.CubeGeometry(10,10,20),p=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(p,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&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.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= @@ -406,27 +406,27 @@ this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVec 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,e,f){THREE.Camera.call(this,b,c,e,f);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 h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Matrix4,o=!1,t=1,p=0,v=0,w=0,u=0,y=0,x=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*y));b=this.delta*this.movementSpeed;this.translateZ(b*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(b*v);this.translateY(b*w);o&&(this.roll+=this.rollSpeed*this.delta*t);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);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 h=new THREE.Vector3,k=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Matrix4,p=!1,o=1,t=0,v=0,w=0,u=0,y=0,x=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*y));b=this.delta*this.movementSpeed;this.translateZ(b*(t>0||this.autoForward&&!(t<0)?1:t));this.translateX(b*v);this.translateY(b*w);p&&(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?e.normalize():e.z=Math.sqrt(1-f*f);h=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(h).setLength(e.x));f.addSelf(h.setLength(e.z));return f}; -this.rotateCamera=function(){var b=Math.acos(k.dot(j)/k.length()/j.length());if(b){var c=(new THREE.Vector3).cross(k,j).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(j);this.staticMoving?k=j:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(o.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?m=o:m.y+=(o.y-m.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var b=p.clone().subSelf(t);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.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?t=p:t.addSelf(b.sub(p,t).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +this.rotateCamera=function(){var b=Math.acos(k.dot(j)/k.length()/j.length());if(b){var c=(new THREE.Vector3).cross(k,j).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(j);this.staticMoving?k=j:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(p.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?m=p:m.y+=(p.y-m.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var b=t.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.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=t:o.addSelf(b.sub(t,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), h.lengthSq()0)m=f-1;else{m=f;break}f=m;if(e[f]==k)return f/(h-1);j=e[f];return e=(f+(k-j)/(e[f+1]-j))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; +THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,k;k=c?c:b*e[h-1];time=Date.now();for(var j=0,m=h-1,p;j<=m;)if(f=Math.floor(j+(m-j)/2),p=e[f]-k,p<0)j=f+1;else if(p>0)m=f-1;else{m=f;break}f=m;if(e[f]==k)return f/(h-1);j=e[f];return e=(f+(k-j)/(e[f+1]-j))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; THREE.Curve.prototype.getTangent=function(b){var c=b-1.0E-4;b+=1.0E-4;c<0&&(c=0);b>1&&(b=1);var c=this.getPoint(c),b=this.getPoint(b),e=new THREE.Vector2;e.sub(b,c);return e.unit()};THREE.LineCurve=function(b,c){b instanceof THREE.Vector2?(this.v1=b,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,c,e,f){this.constructor(new THREE.Vector2(b,c),new THREE.Vector2(e,f))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(b).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b}; THREE.QuadraticBezierCurve=function(b,c,e){if(!(c instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),c=new THREE.Vector2(f[2],f[3]),e=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=c;this.v2=e};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; @@ -441,142 +441,142 @@ THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constru THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)});THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(b){this.curves.push(b)}; THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){};THREE.CurvePath.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.getCurveLengths(),b=0;b=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],c=0,e,f=this.curves.length;for(e=0;ec)c=k.x;else if(k.xe)e=k.y;else if(k.yc)c=k.x;else if(k.xe)e=k.y;else if(k.y0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b2(x,u,v,m),x=THREE.Shape.Utils.b2(x,y,w, -o),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.BEZIER_CURVE_TO:m=k[4];o=k[5];v=k[0];w=k[1];t=k[2];p=k[3];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b3(x,u,v,t,m),x=THREE.Shape.Utils.b3(x,y,w,p,o),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.CSPLINE_THRU:j=this.actions[f-1].args;j=[new THREE.Vector2(j[j.length-2],j[j.length-1])];x=b*k[0].length;j=j.concat(k[0]);k=new THREE.SplineCurve(j); -for(j=1;j<=x;j++)e.push(k.getPointAt(j/x));break;case THREE.PathActions.ARC:j=this.actions[f-1].args;m=k[0];o=k[1];t=k[2];v=k[3];x=k[4];w=!!k[5];p=j[j.length-2];u=j[j.length-1];j.length==0&&(p=u=0);y=x-v;var B=b*2;for(j=1;j<=B;j++)x=j/B,w||(x=1-x),x=v+x*y,k=p+m+t*Math.cos(x),x=u+o+t*Math.sin(x),e.push(new THREE.Vector2(k,x))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; -THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var j=this.getPoints(),m,o,t,p,v;m=0;for(o=j.length;m0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b2(x,u,v,m),x=THREE.Shape.Utils.b2(x,y,w, +p),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.BEZIER_CURVE_TO:m=k[4];p=k[5];v=k[0];w=k[1];o=k[2];t=k[3];e.length>0?(j=e[e.length-1],u=j.x,y=j.y):(j=this.actions[f-1].args,u=j[j.length-2],y=j[j.length-1]);for(j=1;j<=b;j++)x=j/b,k=THREE.Shape.Utils.b3(x,u,v,o,m),x=THREE.Shape.Utils.b3(x,y,w,t,p),e.push(new THREE.Vector2(k,x));break;case THREE.PathActions.CSPLINE_THRU:j=this.actions[f-1].args;j=[new THREE.Vector2(j[j.length-2],j[j.length-1])];x=b*k[0].length;j=j.concat(k[0]);k=new THREE.SplineCurve(j); +for(j=1;j<=x;j++)e.push(k.getPointAt(j/x));break;case THREE.PathActions.ARC:j=this.actions[f-1].args;m=k[0];p=k[1];o=k[2];v=k[3];x=k[4];w=!!k[5];t=j[j.length-2];u=j[j.length-1];j.length==0&&(t=u=0);y=x-v;var B=b*2;for(j=1;j<=B;j++)x=j/B,w||(x=1-x),x=v+x*y,k=t+m+o*Math.cos(x),x=u+p+o*Math.sin(x),e.push(new THREE.Vector2(k,x))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; +THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var j=this.getPoints(),m,p,o,t,v;m=0;for(p=j.length;m=0?m-1:e.length-1;k=j-1>=0?j-1:t.length-1;var x=[t[j],e[m],e[h]];v=THREE.FontUtils.Triangulate.area(x);var B=[t[j],t[k],e[m]];w=THREE.FontUtils.Triangulate.area(B);u=m;p=j;m+=1;j+=-1;m<0&&(m+=e.length);m%= -e.length;j<0&&(j+=t.length);j%=t.length;h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:t.length-1;x=[t[j],e[m],e[h]];x=THREE.FontUtils.Triangulate.area(x);B=[t[j],t[k],e[m]];B=THREE.FontUtils.Triangulate.area(B);v+w>x+B&&(m=u,j=p,m<0&&(m+=e.length),m%=e.length,j<0&&(j+=t.length),j%=t.length,h=m-1>=0?m-1:e.length-1,k=j-1>=0?j-1:t.length-1);v=e.slice(0,m);w=e.slice(m);u=t.slice(j);p=t.slice(0,j);k=[t[j],t[k],e[m]];y.push([t[j],e[m],e[h]]);y.push(k);e=v.concat(u).concat(p).concat(w)}return{shape:e,isolatedPts:y, -allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,j,m,o,t={};k=0;for(j=f.length;k=0?m-1:e.length-1;k=j-1>=0?j-1:o.length-1;var x=[o[j],e[m],e[h]];v=THREE.FontUtils.Triangulate.area(x);var B=[o[j],o[k],e[m]];w=THREE.FontUtils.Triangulate.area(B);u=m;t=j;m+=1;j+=-1;m<0&&(m+=e.length);m%= +e.length;j<0&&(j+=o.length);j%=o.length;h=m-1>=0?m-1:e.length-1;k=j-1>=0?j-1:o.length-1;x=[o[j],e[m],e[h]];x=THREE.FontUtils.Triangulate.area(x);B=[o[j],o[k],e[m]];B=THREE.FontUtils.Triangulate.area(B);v+w>x+B&&(m=u,j=t,m<0&&(m+=e.length),m%=e.length,j<0&&(j+=o.length),j%=o.length,h=m-1>=0?m-1:e.length-1,k=j-1>=0?j-1:o.length-1);v=e.slice(0,m);w=e.slice(m);u=o.slice(j);t=o.slice(0,j);k=[o[j],o[k],e[m]];y.push([o[j],e[m],e[h]]);y.push(k);e=v.concat(u).concat(t).concat(w)}return{shape:e,isolatedPts:y, +allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,j,m,p,o={};k=0;for(j=f.length;k0){e=new THREE.Vector3(0,0,-1);j(0,0,-p-(k||0));for(o=b;o0){c=new THREE.Vector3(0,0,1);j(0,0,p+(h||0));for(o=b+b/2;o<2*b;o++)m.faces.push(new THREE.Face4(2*b+1,(2*o-2*b+2)%b+b,(2*o-2*b+1)%b+b,(2*o-2*b)%b+b,[c,c,c,c]))}o= -0;for(b=this.faces.length;o0){e=new THREE.Vector3(0,0,-1);j(0,0,-t-(k||0));for(p=b;p0){c=new THREE.Vector3(0,0,1);j(0,0,t+(h||0));for(p=b+b/2;p<2*b;p++)m.faces.push(new THREE.Face4(2*b+1,(2*p-2*b+2)%b+b,(2*p-2*b+1)%b+b,(2*p-2*b)%b+b,[c,c,c,c]))}p= +0;for(b=this.faces.length;pb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(k).addSelf(m).subSelf(b).clone()}function h(b){for(F=b.length;--F>=0;){ea=F;ga=F-1;ga<0&&(ga=b.length- -1);for(var c=0,e=u+p*2,c=0;c=0;N--){P=N/p;n=o*(1-P);P=t*Math.sin(P*Math.PI/2);F=0;for(L=H.length;Fb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(k).addSelf(m).subSelf(b).clone()}function h(b){for(G=b.length;--G>=0;){aa=G;ja=G-1;ja<0&&(ja=b.length- +1);for(var c=0,e=u+t*2,c=0;c=0;L--){S=L/t;n=p*(1-S);S=o*Math.sin(S*Math.PI/2);G=0;for(M=D.length;G0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,m,w)))-1);t.push(p)}c.push(t)}for(var u,y,x,h=c.length,e=0;e0)for(f=0;f1&&(u= -this.vertices[j].position.clone(),y=this.vertices[o].position.clone(),x=this.vertices[t].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,o,t,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([p,v,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,h=Math.PI,k=Math.max(3,c||8),j=Math.max(2,e||6),c=[],e=0;e0||(t=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,m,w)))-1);o.push(t)}c.push(o)}for(var u,y,x,h=c.length,e=0;e0)for(f=0;f1&&(u= +this.vertices[j].position.clone(),y=this.vertices[p].position.clone(),x=this.vertices[o].position.clone(),u.normalize(),y.normalize(),x.normalize(),this.faces.push(new THREE.Face3(j,p,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(x.x,x.y,x.z)])),this.faceVertexUvs[0].push([t,v,B]))}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){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c= -this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),k=h.length,j=[],b=0;b0)for(t=0;t2;){if(v--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return k}o=t;h<=o&&(o=0);t=o+1;h<=t&&(t=0);p=t+1;h<=p&&(p=0);var w;a:{w=b;var u=o,y=t,x=p,B=h,z=j,H=void 0,D=void 0,I=void 0, -K=void 0,M=void 0,C=void 0,J=void 0,E=void 0,Y=void 0,D=w[z[u]].x,I=w[z[u]].y,K=w[z[y]].x,M=w[z[y]].y,C=w[z[x]].x,J=w[z[x]].y;if(1.0E-10>(K-D)*(J-I)-(M-I)*(C-D))w=!1;else{for(H=0;H=0&&N>=0&&n>=0){w=!1;break a}}w= -!0}}if(w){k.push([b[j[o]],b[j[t]],b[j[p]]]);m.push([j[o],j[t],j[p]]);o=t;for(p=t+1;p0)for(o=0;o2;){if(v--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return k}p=o;h<=p&&(p=0);o=p+1;h<=o&&(o=0);t=o+1;h<=t&&(t=0);var w;a:{w=b;var u=p,y=o,x=t,B=h,z=j,D=void 0,C=void 0,E=void 0, +J=void 0,O=void 0,K=void 0,I=void 0,F=void 0,Y=void 0,C=w[z[u]].x,E=w[z[u]].y,J=w[z[y]].x,O=w[z[y]].y,K=w[z[x]].x,I=w[z[x]].y;if(1.0E-10>(J-C)*(I-E)-(O-E)*(K-C))w=!1;else{for(D=0;D=0&&L>=0&&n>=0){w=!1;break a}}w= +!0}}if(w){k.push([b[j[p]],b[j[o]],b[j[t]]]);m.push([j[p],j[o],j[t]]);p=o;for(t=o+1;t>7)-127;f|=(j&127)<<16|h<<8;if(f==0&&m==-127)return 0;return(1-2*(k>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,m)}function h(b,c){var e=p(b,c),f=p(b,c+1),j=p(b,c+2);return(p(b,c+3)<<24)+(j<<16)+(f<<8)+e}function o(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function t(b,c){var e=p(b,c);return e>127?e-256:e}function p(b, -c){return b.charCodeAt(c)&255}function v(c){var e,f,j;e=h(b,c);f=h(b,c+M);j=h(b,c+C);c=o(b,c+J);THREE.BinaryLoader.prototype.f3(z,e,f,j,c)}function w(c){var e,f,j,k,n,t;e=h(b,c);f=h(b,c+M);j=h(b,c+C);k=o(b,c+J);n=h(b,c+E);t=h(b,c+Y);c=h(b,c+F);THREE.BinaryLoader.prototype.f3n(z,I,e,f,j,k,n,t,c)}function u(c){var e,f,j,k;e=h(b,c);f=h(b,c+L);j=h(b,c+N);k=h(b,c+P);c=o(b,c+n);THREE.BinaryLoader.prototype.f4(z,e,f,j,k,c)}function y(c){var e,f,j,k,t,p,u,v;e=h(b,c);f=h(b,c+L);j=h(b,c+N);k=h(b,c+P);t=o(b, -c+n);p=h(b,c+V);u=h(b,c+ha);v=h(b,c+R);c=h(b,c+aa);THREE.BinaryLoader.prototype.f4n(z,I,e,f,j,k,t,p,u,v,c)}function x(c){var e,f;e=h(b,c);f=h(b,c+Z);c=h(b,c+ia);THREE.BinaryLoader.prototype.uv3(z.faceVertexUvs[0],K[e*2],K[e*2+1],K[f*2],K[f*2+1],K[c*2],K[c*2+1])}function B(c){var e,f,j;e=h(b,c);f=h(b,c+U);j=h(b,c+ea);c=h(b,c+ga);THREE.BinaryLoader.prototype.uv4(z.faceVertexUvs[0],K[e*2],K[e*2+1],K[f*2],K[f*2+1],K[j*2],K[j*2+1],K[c*2],K[c*2+1])}var z=this,H=0,D,I=[],K=[],M,C,J,E,Y,F,L,N,P,n,V,ha,R, -aa,Z,ia,U,ea,ga,$,S,W,da,fa,la;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,f,c);D={signature:b.substr(H,8),header_bytes:p(b,H+8),vertex_coordinate_bytes:p(b,H+9),normal_coordinate_bytes:p(b,H+10),uv_coordinate_bytes:p(b,H+11),vertex_index_bytes:p(b,H+12),normal_index_bytes:p(b,H+13),uv_index_bytes:p(b,H+14),material_index_bytes:p(b,H+15),nvertices:h(b,H+16),nnormals:h(b,H+16+4),nuvs:h(b,H+16+8),ntri_flat:h(b,H+16+12),ntri_smooth:h(b,H+16+16),ntri_flat_uv:h(b,H+16+20),ntri_smooth_uv:h(b, -H+16+24),nquad_flat:h(b,H+16+28),nquad_smooth:h(b,H+16+32),nquad_flat_uv:h(b,H+16+36),nquad_smooth_uv:h(b,H+16+40)};H+=D.header_bytes;M=D.vertex_index_bytes;C=D.vertex_index_bytes*2;J=D.vertex_index_bytes*3;E=D.vertex_index_bytes*3+D.material_index_bytes;Y=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;F=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;L=D.vertex_index_bytes;N=D.vertex_index_bytes*2;P=D.vertex_index_bytes*3;n=D.vertex_index_bytes*4;V=D.vertex_index_bytes* -4+D.material_index_bytes;ha=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;R=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;aa=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;Z=D.uv_index_bytes;ia=D.uv_index_bytes*2;U=D.uv_index_bytes;ea=D.uv_index_bytes*2;ga=D.uv_index_bytes*3;c=D.vertex_index_bytes*3+D.material_index_bytes;la=D.vertex_index_bytes*4+D.material_index_bytes;$=D.ntri_flat*c;S=D.ntri_smooth*(c+D.normal_index_bytes*3);W=D.ntri_flat_uv* -(c+D.uv_index_bytes*3);da=D.ntri_smooth_uv*(c+D.normal_index_bytes*3+D.uv_index_bytes*3);fa=D.nquad_flat*la;c=D.nquad_smooth*(la+D.normal_index_bytes*4);la=D.nquad_flat_uv*(la+D.uv_index_bytes*4);H+=function(c){for(var f,h,k,m=D.vertex_coordinate_bytes*3,n=c+D.nvertices*m;c1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(M,Y);object.name=u;object.position.set(D[0],D[1],D[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=H.visible;R.scene.addObject(object);R.objects[u]=object;H.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),R.scene.collisions.colliders.push(b)); -if(H.castsShadow)b=new THREE.ShadowVolume(M),R.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},R.triggers[object.name]=b)}}else D=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(D[0],D[1],D[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=H.visible!==void 0?H.visible:!1,R.scene.addObject(object),R.objects[u]=object,R.empties[u]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},R.triggers[object.name]=b)}function o(b){return function(c){R.geometries[b]=c;m();P-=1;e.onLoadComplete();p()}}function t(b){return function(c){R.geometries[b]=c}}function p(){e.callbackProgress({totalModels:V,totalTextures:ha,loadedModels:V-P,loadedTextures:ha-n},R);e.onLoadProgress();P==0&&n==0&&c(R)} -var v,w,u,y,x,B,z,H,D,I,K,M,C,J,E,Y,F,L,N,P,n,V,ha,R;L=b.data;E=new THREE.BinaryLoader;N=new THREE.JSONLoader;n=P=0;R={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in L.objects)if(H=L.objects[u],H.meshCollider){b=!0;break}if(b)R.scene.collisions=new THREE.CollisionSystem;if(L.transform){b=L.transform.position;I=L.transform.rotation;var aa=L.transform.scale;b&&R.scene.position.set(b[0],b[1],b[2]);I&&R.scene.rotation.set(I[0], -I[1],I[2]);aa&&R.scene.scale.set(aa[0],aa[1],aa[2]);(b||I||aa)&&R.scene.updateMatrix()}b=function(){n-=1;p();e.onLoadComplete()};for(x in L.cameras){I=L.cameras[x];if(I.type=="perspective")C=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")C=new THREE.Camera,C.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);D=I.position;I=I.target;C.position.set(D[0],D[1],D[2]);C.target.position.set(I[0],I[1],I[2]);R.cameras[x]=C}for(y in L.lights)x=L.lights[y], -C=x.color!==void 0?x.color:16777215,I=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(D=x.direction,F=new THREE.DirectionalLight(C,I),F.position.set(D[0],D[1],D[2]),F.position.normalize()):x.type=="point"?(D=x.position,d=x.distance,F=new THREE.PointLight(C,I,d),F.position.set(D[0],D[1],D[2])):x.type=="ambient"&&(F=new THREE.AmbientLight(C)),R.scene.addLight(F),R.lights[y]=F;for(B in L.fogs)y=L.fogs[B],y.type=="linear"?J=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(J=new THREE.FogExp2(0, -y.density)),I=y.color,J.color.setRGB(I[0],I[1],I[2]),R.fogs[B]=J;if(R.cameras&&L.defaults.camera)R.currentCamera=R.cameras[L.defaults.camera];if(R.fogs&&L.defaults.fog)R.scene.fog=R.fogs[L.defaults.fog];I=L.defaults.bgcolor;R.bgColor=new THREE.Color;R.bgColor.setRGB(I[0],I[1],I[2]);R.bgColorAlpha=L.defaults.bgalpha;for(v in L.geometries)if(B=L.geometries[v],B.type=="bin_mesh"||B.type=="ascii_mesh")P+=1,e.onLoadStart();V=P;for(v in L.geometries)B=L.geometries[v],B.type=="cube"?(M=new THREE.CubeGeometry(B.width, -B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),R.geometries[v]=M):B.type=="plane"?(M=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),R.geometries[v]=M):B.type=="sphere"?(M=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),R.geometries[v]=M):B.type=="cylinder"?(M=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),R.geometries[v]=M):B.type=="torus"?(M=new THREE.TorusGeometry(B.radius, -B.tube,B.segmentsR,B.segmentsT),R.geometries[v]=M):B.type=="icosahedron"?(M=new THREE.IcosahedronGeometry(B.subdivisions),R.geometries[v]=M):B.type=="bin_mesh"?E.load({model:f(B.url,L.urlBaseType),callback:o(v)}):B.type=="ascii_mesh"?N.load({model:f(B.url,L.urlBaseType),callback:o(v)}):B.type=="embedded_mesh"&&(B=L.embeds[B.id])&&N.createModel(B,t(v),"");for(z in L.textures)if(v=L.textures[z],v.url instanceof Array){n+=v.url.length;for(E=0;E>7)-127;f|=(j&127)<<16|h<<8;if(f==0&&m==-127)return 0;return(1-2*(k>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,m)}function h(b,c){var e=t(b,c),f=t(b,c+1),j=t(b,c+2);return(t(b,c+3)<<24)+(j<<16)+(f<<8)+e}function p(b,c){var e=t(b,c);return(t(b,c+1)<<8)+e}function o(b,c){var e=t(b,c);return e>127?e-256:e}function t(b,c){return b.charCodeAt(c)&255}function v(c){var e, +f,j;e=h(b,c);f=h(b,c+O);j=h(b,c+K);c=p(b,c+I);z.faces.push(new THREE.Face3(e,f,j,null,null,z.materials[c]))}function w(c){var e,f,j,k,n,o;e=h(b,c);f=h(b,c+O);j=h(b,c+K);k=p(b,c+I);n=h(b,c+F);o=h(b,c+Y);c=h(b,c+G);k=z.materials[k];var t=E[o*3],u=E[o*3+1];o=E[o*3+2];var v=E[c*3],w=E[c*3+1],c=E[c*3+2];z.faces.push(new THREE.Face3(e,f,j,[new THREE.Vector3(E[n*3],E[n*3+1],E[n*3+2]),new THREE.Vector3(t,u,o),new THREE.Vector3(v,w,c)],null,k))}function u(c){var e,f,j,k;e=h(b,c);f=h(b,c+M);j=h(b,c+L);k=h(b, +c+S);c=p(b,c+n);z.faces.push(new THREE.Face4(e,f,j,k,null,null,z.materials[c]))}function y(c){var e,f,j,k,o,t,u,v;e=h(b,c);f=h(b,c+M);j=h(b,c+L);k=h(b,c+S);o=p(b,c+n);t=h(b,c+V);u=h(b,c+fa);v=h(b,c+Q);c=h(b,c+da);o=z.materials[o];var w=E[u*3],x=E[u*3+1];u=E[u*3+2];var y=E[v*3],B=E[v*3+1];v=E[v*3+2];var C=E[c*3],D=E[c*3+1],c=E[c*3+2];z.faces.push(new THREE.Face4(e,f,j,k,[new THREE.Vector3(E[t*3],E[t*3+1],E[t*3+2]),new THREE.Vector3(w,x,u),new THREE.Vector3(y,B,v),new THREE.Vector3(C,D,c)],null,o))} +function x(c){var e,f,j,k;e=h(b,c);f=h(b,c+$);j=h(b,c+ka);c=J[e*2];k=J[e*2+1];e=J[f*2];var n=z.faceVertexUvs[0];f=J[f*2+1];var o=J[j*2];j=J[j*2+1];var p=[];p.push(new THREE.UV(c,k));p.push(new THREE.UV(e,f));p.push(new THREE.UV(o,j));n.push(p)}function B(c){var e,f,j,k,n,o;e=h(b,c);f=h(b,c+U);j=h(b,c+aa);k=h(b,c+ja);c=J[e*2];n=J[e*2+1];e=J[f*2];o=J[f*2+1];f=J[j*2];var p=z.faceVertexUvs[0];j=J[j*2+1];var t=J[k*2];k=J[k*2+1];var u=[];u.push(new THREE.UV(c,n));u.push(new THREE.UV(e,o));u.push(new THREE.UV(f, +j));u.push(new THREE.UV(t,k));p.push(u)}var z=this,D=0,C,E=[],J=[],O,K,I,F,Y,G,M,L,S,n,V,fa,Q,da,$,ka,U,aa,ja,ha,X,ca,ga,ia,ma;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(z,f,c);C={signature:b.substr(D,8),header_bytes:t(b,D+8),vertex_coordinate_bytes:t(b,D+9),normal_coordinate_bytes:t(b,D+10),uv_coordinate_bytes:t(b,D+11),vertex_index_bytes:t(b,D+12),normal_index_bytes:t(b,D+13),uv_index_bytes:t(b,D+14),material_index_bytes:t(b,D+15),nvertices:h(b,D+16),nnormals:h(b,D+16+4),nuvs:h(b, +D+16+8),ntri_flat:h(b,D+16+12),ntri_smooth:h(b,D+16+16),ntri_flat_uv:h(b,D+16+20),ntri_smooth_uv:h(b,D+16+24),nquad_flat:h(b,D+16+28),nquad_smooth:h(b,D+16+32),nquad_flat_uv:h(b,D+16+36),nquad_smooth_uv:h(b,D+16+40)};D+=C.header_bytes;O=C.vertex_index_bytes;K=C.vertex_index_bytes*2;I=C.vertex_index_bytes*3;F=C.vertex_index_bytes*3+C.material_index_bytes;Y=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;G=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;M=C.vertex_index_bytes; +L=C.vertex_index_bytes*2;S=C.vertex_index_bytes*3;n=C.vertex_index_bytes*4;V=C.vertex_index_bytes*4+C.material_index_bytes;fa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;Q=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;da=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;$=C.uv_index_bytes;ka=C.uv_index_bytes*2;U=C.uv_index_bytes;aa=C.uv_index_bytes*2;ja=C.uv_index_bytes*3;c=C.vertex_index_bytes*3+C.material_index_bytes;ma=C.vertex_index_bytes* +4+C.material_index_bytes;ha=C.ntri_flat*c;X=C.ntri_smooth*(c+C.normal_index_bytes*3);ca=C.ntri_flat_uv*(c+C.uv_index_bytes*3);ga=C.ntri_smooth_uv*(c+C.normal_index_bytes*3+C.uv_index_bytes*3);ia=C.nquad_flat*ma;c=C.nquad_smooth*(ma+C.normal_index_bytes*4);ma=C.nquad_flat_uv*(ma+C.uv_index_bytes*4);D+=function(c){for(var f,h,k,m=C.vertex_coordinate_bytes*3,n=c+C.nvertices*m;c1&&(Y=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,Y);object.name=u;object.position.set(C[0],C[1],C[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;Q.scene.addObject(object);Q.objects[u]=object;D.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(b)); +if(D.castsShadow)b=new THREE.ShadowVolume(O),Q.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},Q.triggers[object.name]=b)}}else C=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(C[0],C[1],C[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,Q.scene.addObject(object),Q.objects[u]=object,Q.empties[u]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},Q.triggers[object.name]=b)}function p(b){return function(c){Q.geometries[b]=c;m();S-=1;e.onLoadComplete();t()}}function o(b){return function(c){Q.geometries[b]=c}}function t(){e.callbackProgress({totalModels:V,totalTextures:fa,loadedModels:V-S,loadedTextures:fa-n},Q);e.onLoadProgress();S==0&&n==0&&c(Q)} +var v,w,u,y,x,B,z,D,C,E,J,O,K,I,F,Y,G,M,L,S,n,V,fa,Q;M=b.data;F=new THREE.BinaryLoader;L=new THREE.JSONLoader;n=S=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(u in M.objects)if(D=M.objects[u],D.meshCollider){b=!0;break}if(b)Q.scene.collisions=new THREE.CollisionSystem;if(M.transform){b=M.transform.position;E=M.transform.rotation;var da=M.transform.scale;b&&Q.scene.position.set(b[0],b[1],b[2]);E&&Q.scene.rotation.set(E[0], +E[1],E[2]);da&&Q.scene.scale.set(da[0],da[1],da[2]);(b||E||da)&&Q.scene.updateMatrix()}b=function(){n-=1;t();e.onLoadComplete()};for(x in M.cameras){E=M.cameras[x];if(E.type=="perspective")K=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")K=new THREE.Camera,K.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);C=E.position;E=E.target;K.position.set(C[0],C[1],C[2]);K.target.position.set(E[0],E[1],E[2]);Q.cameras[x]=K}for(y in M.lights)x=M.lights[y], +K=x.color!==void 0?x.color:16777215,E=x.intensity!==void 0?x.intensity:1,x.type=="directional"?(C=x.direction,G=new THREE.DirectionalLight(K,E),G.position.set(C[0],C[1],C[2]),G.position.normalize()):x.type=="point"?(C=x.position,d=x.distance,G=new THREE.PointLight(K,E,d),G.position.set(C[0],C[1],C[2])):x.type=="ambient"&&(G=new THREE.AmbientLight(K)),Q.scene.addLight(G),Q.lights[y]=G;for(B in M.fogs)y=M.fogs[B],y.type=="linear"?I=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(I=new THREE.FogExp2(0, +y.density)),E=y.color,I.color.setRGB(E[0],E[1],E[2]),Q.fogs[B]=I;if(Q.cameras&&M.defaults.camera)Q.currentCamera=Q.cameras[M.defaults.camera];if(Q.fogs&&M.defaults.fog)Q.scene.fog=Q.fogs[M.defaults.fog];E=M.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(E[0],E[1],E[2]);Q.bgColorAlpha=M.defaults.bgalpha;for(v in M.geometries)if(B=M.geometries[v],B.type=="bin_mesh"||B.type=="ascii_mesh")S+=1,e.onLoadStart();V=S;for(v in M.geometries)B=M.geometries[v],B.type=="cube"?(O=new THREE.CubeGeometry(B.width, +B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),Q.geometries[v]=O):B.type=="plane"?(O=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),Q.geometries[v]=O):B.type=="sphere"?(O=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),Q.geometries[v]=O):B.type=="cylinder"?(O=new THREE.CylinderGeometry(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),Q.geometries[v]=O):B.type=="torus"?(O=new THREE.TorusGeometry(B.radius, +B.tube,B.segmentsR,B.segmentsT),Q.geometries[v]=O):B.type=="icosahedron"?(O=new THREE.IcosahedronGeometry(B.subdivisions),Q.geometries[v]=O):B.type=="bin_mesh"?F.load({model:f(B.url,M.urlBaseType),callback:p(v)}):B.type=="ascii_mesh"?L.load({model:f(B.url,M.urlBaseType),callback:p(v)}):B.type=="embedded_mesh"&&(B=M.embeds[B.id])&&L.createModel(B,o(v),"");for(z in M.textures)if(v=M.textures[z],v.url instanceof Array){n+=v.url.length;for(F=0;F=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,j=0;j>1^-(m&1);e[8*j+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=j=0;h=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,j=0;j>1^-(m&1);e[8*j+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=j=0;h=this.maxCount-3&&m(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&&(o=this.size-1);var w=Math.floor(t-m);w<1&&(w=1);t=Math.floor(t+m);t>this.size-1&&(t=this.size-1);var u=Math.floor(p-m);u<1&&(u=1);m=Math.floor(p+m);m>this.size-1&&(m=this.size- -1);for(var y,x,B,z,H,D;v0&&(this.field[B+y]+=z)}}};this.addPlaneX=function(b,c){var h,k,j,m,o,t=this.size,p=this.yd,v=this.zd,w=this.field,u=t*Math.sqrt(b/c);u>t&&(u=t);for(h=0;h0)for(k=0;kp&&(y=p);for(k=0;k0){o=k*v;for(h=0;hsize&&(dist=size);for(j=0;j0){o=zd*j;for(k=0;k=this.maxCount-3&&m(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&&(p=this.size-1);var w=Math.floor(o-m);w<1&&(w=1);o=Math.floor(o+m);o>this.size-1&&(o=this.size-1);var u=Math.floor(t-m);u<1&&(u=1);m=Math.floor(t+m);m>this.size-1&&(m=this.size- +1);for(var y,x,B,z,D,C;v0&&(this.field[B+y]+=z)}}};this.addPlaneX=function(b,c){var h,k,j,m,p,o=this.size,t=this.yd,v=this.zd,w=this.field,u=o*Math.sqrt(b/c);u>o&&(u=o);for(h=0;h0)for(k=0;kt&&(y=t);for(k=0;k0){p=k*v;for(h=0;hsize&&(dist=size);for(j=0;j0){p=zd*j;for(k=0;kk?this.hits.push(h):this.hits.unshift(h),k=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; 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 e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k=m*h))return Number.MAX_VALUE;j/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(j);m.addSelf(b.origin);Math.abs(k.x)> +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k=m*h))return Number.MAX_VALUE;j/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(j);m.addSelf(b.origin);Math.abs(k.x)> Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=m.y-c.y,k=e.y-c.y,h=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,k=e.x-c.x,h=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*h;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*h)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return j}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,h=0,k=0,j=0,m=0,o=0,t=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,t=!1,j=1);e.origin.yc.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y, -t=!1,m=1);e.origin.zc.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,t=!1,o=1);if(t)return-1;t=0;h>f&&(t=1,f=h);k>f&&(t=2,f=k);switch(t){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=e.origin.x+e.direction.x*f;if(jc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* -f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:j=e.origin.x+e.direction.x*f;if(jc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,o)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,h=0,k=0,j=0,m=0,p=0,o=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,j=1);e.origin.yc.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y, +o=!1,m=1);e.origin.zc.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,o=!1,p=1);if(o)return-1;o=0;h>f&&(o=1,f=h);k>f&&(o=2,f=k);switch(o){case 0:m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=e.origin.x+e.direction.x*f;if(jc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* +f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:j=e.origin.x+e.direction.x*f;if(jc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,p)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq=0)return Math.abs(f)-Math.sqrt(e);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,e=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]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};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))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,k=new THREE.Camera,j=new THREE.Matrix4,m=new THREE.Matrix4,o,t,p;h.useTarget=k.useTarget=!1;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},v=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z= +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,k=new THREE.Camera,j=new THREE.Matrix4,m=new THREE.Matrix4,p,o,t;h.useTarget=k.useTarget=!1;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},v=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.Camera(53,1,1,1E4);u.position.z= 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:v},mapRight:{type:"t",value:1,texture:w}},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 y=new THREE.Scene;y.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);v.width=b;v.height=f;w.width=b;w.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||t!==e.near||p!==e.fov){o=e.aspect;t=e.near;p=e.fov;var z=e.projectionMatrix.clone(),H=125/30*0.5,D=H*t/125,I=t*Math.tan(p*Math.PI/360),K;j.n14=H;m.n14=-H;H=-I*o+D;K=I*o+D;z.n11=2*t/(K-H);z.n13=(K+H)/(K-H);h.projectionMatrix=z.clone();H=-I*o-D;K=I*o-D;z.n11=2*t/(K-H); -z.n13=(K+H)/(K-H);k.projectionMatrix=z.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(m);h.update(null,!0);h.position.copy(e.position);h.near=t;h.far=e.far;f.call(c,b,h,v,!0);k.matrix=e.matrixWorld.clone().multiplySelf(j);k.update(null,!0);k.position.copy(e.position);k.near=t;k.far=e.far;f.call(c,b,k,w,!0);f.call(c,y,u)}}; +var y=new THREE.Scene;y.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);v.width=b;v.height=f;w.width=b;w.height=f};this.render=function(b,e){e.update(null,!0);if(p!==e.aspect||o!==e.near||t!==e.fov){p=e.aspect;o=e.near;t=e.fov;var z=e.projectionMatrix.clone(),D=125/30*0.5,C=D*o/125,E=o*Math.tan(t*Math.PI/360),J;j.n14=D;m.n14=-D;D=-E*p+C;J=E*p+C;z.n11=2*o/(J-D);z.n13=(J+D)/(J-D);h.projectionMatrix=z.clone();D=-E*p-C;J=E*p-C;z.n11=2*o/(J-D); +z.n13=(J+D)/(J-D);k.projectionMatrix=z.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(m);h.update(null,!0);h.position.copy(e.position);h.near=o;h.far=e.far;f.call(c,b,h,v,!0);k.matrix=e.matrixWorld.clone().multiplySelf(j);k.update(null,!0);k.position.copy(e.position);k.near=o;k.far=e.far;f.call(c,b,k,w,!0);f.call(c,y,u)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,k,j=new THREE.Camera,m=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,f){e.call(c,b,f);h=b/2;k=f};this.render=function(b,e){this.clear();j.fov=e.fov;j.aspect=0.5*e.aspect;j.near=e.near;j.far=e.far; j.updateProjectionMatrix();j.position.copy(e.position);j.target.position.copy(e.target.position);j.translateX(c.separation);m.projectionMatrix=j.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,h,k);f.call(c,b,j);this.setViewport(h,0,h,k);f.call(c,b,m,!1)}}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index 4120376b..9d2fd01f 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,8 +1,8 @@ // ThreeExtras.js r44dev - http://github.com/mrdoob/three.js THREE.ColorUtils={adjustHSV:function(a,b,c,e){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+b,0,1);f.s=THREE.ColorUtils.clamp(f.s+c,0,1);f.v=THREE.ColorUtils.clamp(f.v+e,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,e=a.g,f=a.b,h=Math.max(Math.max(c,e),f),g=Math.min(Math.min(c,e),f);if(g==h)g=c=0;else{var j=h-g,g=j/h,c=c==h?(e-f)/j:e==h?2+(f-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=h;return b}, clamp:function(a,b,c){return ac?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,f=c?b.geometry:b,h=a.vertices,g=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,n=g.length;m1&&(e=1-e,f=1-f);h=1-e-f;g.copy(a);g.multiplyScalar(e);j.copy(b);j.multiplyScalar(f);g.addSelf(j);j.copy(c);j.multiplyScalar(h);g.addSelf(j);return g},randomPointInFace:function(a, b,c){var e,f,h;if(a instanceof THREE.Face3)return e=b.vertices[a.a].position,f=b.vertices[a.b].position,h=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(e,f,h);else if(a instanceof THREE.Face4){e=b.vertices[a.a].position;f=b.vertices[a.b].position;h=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(e,f,b),g=THREE.GeometryUtils.triangleArea(f,h,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(e, @@ -10,9 +10,9 @@ f,b),g=THREE.GeometryUtils.triangleArea(f,h,b));return THREE.GeometryUtils.rando o=g[e.c].position,e._area=THREE.GeometryUtils.triangleArea(m,n,o);else if(e instanceof THREE.Face4)m=g[e.a].position,n=g[e.b].position,o=g[e.c].position,p=g[e.d].position,e._area1=THREE.GeometryUtils.triangleArea(m,n,p),e._area2=THREE.GeometryUtils.triangleArea(n,o,p),e._area=e._area1+e._area2;k+=e._area;l[f]=k}e=[];g={};for(f=0;f1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+p),e=e<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",p,g.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,j.index+1).pos,e=e*0.33+0.33,f=this.interpolateCatmullRom(this.points,e),c.x=f[0],c.y=f[1],c.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(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(f,h,a.quaternion,e);else if(c==="scl")c=a.scale,c.x=f[0]+(h[0]-f[0])*e,c.y=f[1]+(h[1]-f[1])*e,c.z=f[2]+(h[2]-f[2])*e}}if(this.JITCompile&&m[0][l]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;p0||this.autoForward&&!(m<0)?1:m));this.translateX(a*n);this.translateY(a*o);k&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?c.normalize():c.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(c.y);e.addSelf(this.up.clone().crossSelf(f).setLength(c.x));e.addSelf(f.setLength(c.z));return e}; -this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var b=(new THREE.Vector3).cross(h,g).normalize(),c=new THREE.Quaternion;a*=this.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(f);c.multiplyVector3(this.up);c.multiplyVector3(g);this.staticMoving?h=g:(c.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)}; +THREE.TrackballCamera=function(a){function b(a,c){return function(){c.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan|| +!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var c=!1,e=this.STATE.NONE,f=new THREE.Vector3,h=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,l=new THREE.Vector2,m=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a- +this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var b=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),e=b.length();e>1?b.normalize():b.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(b.y);e.addSelf(this.up.clone().crossSelf(f).setLength(b.x));e.addSelf(f.setLength(b.z));return e}; +this.rotateCamera=function(){var a=Math.acos(h.dot(g)/h.length()/g.length());if(a){var c=(new THREE.Vector3).cross(h,g).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(f);b.multiplyVector3(this.up);b.multiplyVector3(g);this.staticMoving?h=g:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var a=m.clone().subSelf(l);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var b=f.clone().crossSelf(this.up).setLength(a.x);b.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(b);this.target.position.addSelf(b);this.staticMoving?l=m:l.addSelf(a.sub(m,l).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?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)t=g/a,h=THREE.Shape.Utils.b2(t,p,n,j),t=THREE.Shape.Utils.b2(t,v,o, -k),c.push(new THREE.Vector2(h,t));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)t=g/a,h=THREE.Shape.Utils.b3(t,p,n,l,j),t=THREE.Shape.Utils.b3(t,v,o,m,k),c.push(new THREE.Vector2(h,t));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[e-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];t=a*h[0].length;g=g.concat(h[0]);h=new THREE.SplineCurve(g); -for(g=1;g<=t;g++)c.push(h.getPointAt(g/t));break;case THREE.PathActions.ARC:g=this.actions[e-1].args;j=h[0];k=h[1];l=h[2];n=h[3];t=h[4];o=!!h[5];m=g[g.length-2];p=g[g.length-1];g.length==0&&(m=p=0);v=t-n;var w=a*2;for(g=1;g<=w;g++)t=g/w,o||(t=1-t),t=n+t*v,h=m+j+l*Math.cos(t),t=p+k+l*Math.sin(t),c.push(new THREE.Vector2(h,t))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; +THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],e,f,h,g,j,k,l,m,n,o,p,v,u;e=0;for(f=this.actions.length;e0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)u=g/a,h=THREE.Shape.Utils.b2(u,p,n,j),u=THREE.Shape.Utils.b2(u,v,o, +k),c.push(new THREE.Vector2(h,u));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];c.length>0?(g=c[c.length-1],p=g.x,v=g.y):(g=this.actions[e-1].args,p=g[g.length-2],v=g[g.length-1]);for(g=1;g<=a;g++)u=g/a,h=THREE.Shape.Utils.b3(u,p,n,l,j),u=THREE.Shape.Utils.b3(u,v,o,m,k),c.push(new THREE.Vector2(h,u));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[e-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];u=a*h[0].length;g=g.concat(h[0]);h=new THREE.SplineCurve(g); +for(g=1;g<=u;g++)c.push(h.getPointAt(g/u));break;case THREE.PathActions.ARC:g=this.actions[e-1].args;j=h[0];k=h[1];l=h[2];n=h[3];u=h[4];o=!!h[5];m=g[g.length-2];p=g[g.length-1];g.length==0&&(m=p=0);v=u-n;var x=a*2;for(g=1;g<=x;g++)u=g/x,o||(u=1-u),u=n+u*v,h=m+j+l*Math.cos(u),u=p+k+l*Math.sin(u),c.push(new THREE.Vector2(h,u))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)}; THREE.Path.prototype.nltransform=function(a,b,c,e,f,h){var g=this.getPoints(),j,k,l,m,n;j=0;for(k=g.length;j=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;var t=[l[g],c[j],c[f]];n=THREE.FontUtils.Triangulate.area(t);var w=[l[g],l[h],c[j]];o=THREE.FontUtils.Triangulate.area(w);p=j;m=g;j+=1;g+=-1;j<0&&(j+=c.length);j%= -c.length;g<0&&(g+=l.length);g%=l.length;f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;t=[l[g],c[j],c[f]];t=THREE.FontUtils.Triangulate.area(t);w=[l[g],l[h],c[j]];w=THREE.FontUtils.Triangulate.area(w);n+o>t+w&&(j=p,g=m,j<0&&(j+=c.length),j%=c.length,g<0&&(g+=l.length),g%=l.length,f=j-1>=0?j-1:c.length-1,h=g-1>=0?g-1:l.length-1);n=c.slice(0,j);o=c.slice(j);p=l.slice(g);m=l.slice(0,g);h=[l[g],l[h],c[j]];v.push([l[g],c[j],c[f]]);v.push(h);c=n.concat(p).concat(m).concat(o)}return{shape:c,isolatedPts:v, +THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),e=c.concat(),f,h,g,j,k,l,m,n,o,p,v=[];for(k=0;k=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;var u=[l[g],c[j],c[f]];n=THREE.FontUtils.Triangulate.area(u);var x=[l[g],l[h],c[j]];o=THREE.FontUtils.Triangulate.area(x);p=j;m=g;j+=1;g+=-1;j<0&&(j+=c.length);j%= +c.length;g<0&&(g+=l.length);g%=l.length;f=j-1>=0?j-1:c.length-1;h=g-1>=0?g-1:l.length-1;u=[l[g],c[j],c[f]];u=THREE.FontUtils.Triangulate.area(u);x=[l[g],l[h],c[j]];x=THREE.FontUtils.Triangulate.area(x);n+o>u+x&&(j=p,g=m,j<0&&(j+=c.length),j%=c.length,g<0&&(g+=l.length),g%=l.length,f=j-1>=0?j-1:c.length-1,h=g-1>=0?g-1:l.length-1);n=c.slice(0,j);o=c.slice(j);p=l.slice(g);m=l.slice(0,g);h=[l[g],l[h],c[j]];v.push([l[g],c[j],c[f]]);v.push(h);c=n.concat(p).concat(m).concat(o)}return{shape:c,isolatedPts:v, allpoints:e}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),e=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),h,g,j,k,l={};h=0;for(g=e.length;h0){c=new THREE.Vector3(0,0,-1);g(0,0,-m-(h||0));for(k=a;k0){b=new THREE.Vector3(0,0,1);g(0,0,m+(f||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,[b,b,b,b]))}k= +THREE.CylinderGeometry=function(a,b,c,e,f,h){function g(a,b,c){j.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}THREE.Geometry.call(this);var j=this,k,l=Math.PI*2,m=e/2;for(k=0;k0){c=new THREE.Vector3(0,0,-1);g(0,0,-m-(h||0));for(k=a;k0){b=new THREE.Vector3(0,0,1);g(0,0,m+(f||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a,[b,b,b,b]))}k= 0;for(a=this.faces.length;ka&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(j).subSelf(a).clone()}function f(a){for(z=a.length;--z>=0;){Q=z;P=z-1;P<0&&(P=a.length- -1);for(var b=0,c=p+m*2,b=0;b=0;I--){K=I/m;L=k*(1-K);K=l*Math.sin(K*Math.PI/2);z=0;for(C=x.length;za&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(f).addSelf(j).subSelf(a).clone()}function f(a){for(A=a.length;--A>=0;){Q=A;P=A-1;P<0&&(P=a.length- +1);for(var b=0,c=p+m*2,b=0;b=0;I--){K=I/m;M=k*(1-K);K=l*Math.sin(K*Math.PI/2);A=0;for(D=w.length;A0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}b.push(l)}for(var p,v,t,f=b.length,c=0;c0)for(e=0;e1&&(p= -this.vertices[g].position.clone(),v=this.vertices[k].position.clone(),t=this.vertices[l].position.clone(),p.normalize(),v.normalize(),t.normalize(),this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,n,w]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,e,f=Math.PI,h=Math.max(3,b||8),g=Math.max(2,c||6),b=[],c=0;c0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}b.push(l)}for(var p,v,u,f=b.length,c=0;c0)for(e=0;e1&&(p= +this.vertices[g].position.clone(),v=this.vertices[k].position.clone(),u=this.vertices[l].position.clone(),p.normalize(),v.normalize(),u.normalize(),this.faces.push(new THREE.Face3(g,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(u.x,u.y,u.z)])),this.faceVertexUvs[0].push([m,n,x]))}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){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=b.height!==void 0?b.height:50;if(b.bevelThickness===void 0)b.bevelThickness=10;if(b.bevelSize===void 0)b.bevelSize=8;if(b.bevelEnabled===void 0)b.bevelEnabled=!1;if(b.bend){var e=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(e/2,120),new THREE.Vector2(e,0))}THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,b){return(new TextPath(a,b)).toShapes()},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b= -this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,g=[],a=0;a0)for(l=0;l2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,v=l,t=m,w=f,y=g,x=void 0,u=void 0,A=void 0, -B=void 0,F=void 0,E=void 0,H=void 0,G=void 0,M=void 0,u=o[y[p]].x,A=o[y[p]].y,B=o[y[v]].x,F=o[y[v]].y,E=o[y[t]].x,H=o[y[t]].y;if(1.0E-10>(B-u)*(H-A)-(F-A)*(E-u))o=!1;else{for(x=0;x=0&&I>=0&&L>=0){o=!1;break a}}o=!0}}if(o){h.push([a[g[k]], +this.getFace(),c=this.size/b.resolution,e=0,f=String(a).split(""),h=f.length,g=[],a=0;a0)for(l=0;l2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,v=l,u=m,x=f,y=g,w=void 0,t=void 0,z=void 0, +B=void 0,F=void 0,C=void 0,H=void 0,G=void 0,L=void 0,t=o[y[p]].x,z=o[y[p]].y,B=o[y[v]].x,F=o[y[v]].y,C=o[y[u]].x,H=o[y[u]].y;if(1.0E-10>(B-t)*(H-z)-(F-z)*(C-t))o=!1;else{for(w=0;w=0&&I>=0&&M>=0){o=!1;break a}}o=!0}}if(o){h.push([a[g[k]], a[g[l]],a[g[m]]]);j.push([g[k],g[l],g[m]]);k=l;for(m=l+1;m>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(a,b){var c=m(a,b),e=m(a,b+1),g=m(a,b+2);return(m(a,b+3)<<24)+(g<<16)+(e<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a, -b){return a.charCodeAt(b)&255}function n(b){var c,e,g;c=f(a,b);e=f(a,b+F);g=f(a,b+E);b=k(a,b+H);THREE.BinaryLoader.prototype.f3(y,c,e,g,b)}function o(b){var c,e,g,h,l,m;c=f(a,b);e=f(a,b+F);g=f(a,b+E);h=k(a,b+H);l=f(a,b+G);m=f(a,b+M);b=f(a,b+z);THREE.BinaryLoader.prototype.f3n(y,A,c,e,g,h,l,m,b)}function p(b){var c,e,g,h;c=f(a,b);e=f(a,b+C);g=f(a,b+I);h=f(a,b+K);b=k(a,b+L);THREE.BinaryLoader.prototype.f4(y,c,e,g,h,b)}function v(b){var c,e,g,h,l,m,n,o;c=f(a,b);e=f(a,b+C);g=f(a,b+I);h=f(a,b+K);l=k(a, -b+L);m=f(a,b+J);n=f(a,b+N);o=f(a,b+D);b=f(a,b+R);THREE.BinaryLoader.prototype.f4n(y,A,c,e,g,h,l,m,n,o,b)}function t(b){var c,e;c=f(a,b);e=f(a,b+O);b=f(a,b+S);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[b*2],B[b*2+1])}function w(b){var c,e,g;c=f(a,b);e=f(a,b+U);g=f(a,b+Q);b=f(a,b+P);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],B[c*2],B[c*2+1],B[e*2],B[e*2+1],B[g*2],B[g*2+1],B[b*2],B[b*2+1])}var y=this,x=0,u,A=[],B=[],F,E,H,G,M,z,C,I,K,L,J,N,D,R,O,S, -U,Q,P,T,W,X,Y,Z,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,b);u={signature:a.substr(x,8),header_bytes:m(a,x+8),vertex_coordinate_bytes:m(a,x+9),normal_coordinate_bytes:m(a,x+10),uv_coordinate_bytes:m(a,x+11),vertex_index_bytes:m(a,x+12),normal_index_bytes:m(a,x+13),uv_index_bytes:m(a,x+14),material_index_bytes:m(a,x+15),nvertices:f(a,x+16),nnormals:f(a,x+16+4),nuvs:f(a,x+16+8),ntri_flat:f(a,x+16+12),ntri_smooth:f(a,x+16+16),ntri_flat_uv:f(a,x+16+20),ntri_smooth_uv:f(a,x+ -16+24),nquad_flat:f(a,x+16+28),nquad_smooth:f(a,x+16+32),nquad_flat_uv:f(a,x+16+36),nquad_smooth_uv:f(a,x+16+40)};x+=u.header_bytes;F=u.vertex_index_bytes;E=u.vertex_index_bytes*2;H=u.vertex_index_bytes*3;G=u.vertex_index_bytes*3+u.material_index_bytes;M=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;z=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;C=u.vertex_index_bytes;I=u.vertex_index_bytes*2;K=u.vertex_index_bytes*3;L=u.vertex_index_bytes*4;J=u.vertex_index_bytes* -4+u.material_index_bytes;N=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes;D=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;R=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;O=u.uv_index_bytes;S=u.uv_index_bytes*2;U=u.uv_index_bytes;Q=u.uv_index_bytes*2;P=u.uv_index_bytes*3;b=u.vertex_index_bytes*3+u.material_index_bytes;V=u.vertex_index_bytes*4+u.material_index_bytes;T=u.ntri_flat*b;W=u.ntri_smooth*(b+u.normal_index_bytes*3);X=u.ntri_flat_uv* -(b+u.uv_index_bytes*3);Y=u.ntri_smooth_uv*(b+u.normal_index_bytes*3+u.uv_index_bytes*3);Z=u.nquad_flat*V;b=u.nquad_smooth*(V+u.normal_index_bytes*4);V=u.nquad_flat_uv*(V+u.uv_index_bytes*4);x+=function(b){for(var e,f,h,j=u.vertex_coordinate_bytes*3,k=b+u.nvertices*j;b1&&(M=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,M);object.name=p;object.position.set(u[0],u[1],u[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=x.visible;D.scene.addObject(object);D.objects[p]=object;x.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),D.scene.collisions.colliders.push(a)); -if(x.castsShadow)a=new THREE.ShadowVolume(F),D.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},D.triggers[object.name]=a)}}else u=x.position,r=x.rotation,q=x.quaternion,s=x.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(u[0],u[1],u[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=x.visible!==void 0?x.visible:!1,D.scene.addObject(object),D.objects[p]=object,D.empties[p]=object,x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},D.triggers[object.name]=a)}function k(a){return function(b){D.geometries[a]=b;j();K-=1;c.onLoadComplete();m()}}function l(a){return function(b){D.geometries[a]=b}}function m(){c.callbackProgress({totalModels:J,totalTextures:N,loadedModels:J-K,loadedTextures:N-L},D);c.onLoadProgress();K==0&&L==0&&b(D)}var n, -o,p,v,t,w,y,x,u,A,B,F,E,H,G,M,z,C,I,K,L,J,N,D;C=a.data;G=new THREE.BinaryLoader;I=new THREE.JSONLoader;L=K=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in C.objects)if(x=C.objects[p],x.meshCollider){a=!0;break}if(a)D.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;A=C.transform.rotation;var R=C.transform.scale;a&&D.scene.position.set(a[0],a[1],a[2]);A&&D.scene.rotation.set(A[0], -A[1],A[2]);R&&D.scene.scale.set(R[0],R[1],R[2]);(a||A||R)&&D.scene.updateMatrix()}a=function(){L-=1;m();c.onLoadComplete()};for(t in C.cameras){A=C.cameras[t];if(A.type=="perspective")E=new THREE.Camera(A.fov,A.aspect,A.near,A.far);else if(A.type=="ortho")E=new THREE.Camera,E.projectionMatrix=THREE.Matrix4.makeOrtho(A.left,A.right,A.top,A.bottom,A.near,A.far);u=A.position;A=A.target;E.position.set(u[0],u[1],u[2]);E.target.position.set(A[0],A[1],A[2]);D.cameras[t]=E}for(v in C.lights)t=C.lights[v], -E=t.color!==void 0?t.color:16777215,A=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(u=t.direction,z=new THREE.DirectionalLight(E,A),z.position.set(u[0],u[1],u[2]),z.position.normalize()):t.type=="point"?(u=t.position,d=t.distance,z=new THREE.PointLight(E,A,d),z.position.set(u[0],u[1],u[2])):t.type=="ambient"&&(z=new THREE.AmbientLight(E)),D.scene.addLight(z),D.lights[v]=z;for(w in C.fogs)v=C.fogs[w],v.type=="linear"?H=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(H=new THREE.FogExp2(0, -v.density)),A=v.color,H.color.setRGB(A[0],A[1],A[2]),D.fogs[w]=H;if(D.cameras&&C.defaults.camera)D.currentCamera=D.cameras[C.defaults.camera];if(D.fogs&&C.defaults.fog)D.scene.fog=D.fogs[C.defaults.fog];A=C.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(A[0],A[1],A[2]);D.bgColorAlpha=C.defaults.bgalpha;for(n in C.geometries)if(w=C.geometries[n],w.type=="bin_mesh"||w.type=="ascii_mesh")K+=1,c.onLoadStart();J=K;for(n in C.geometries)w=C.geometries[n],w.type=="cube"?(F=new THREE.CubeGeometry(w.width, -w.height,w.depth,w.segmentsWidth,w.segmentsHeight,w.segmentsDepth,null,w.flipped,w.sides),D.geometries[n]=F):w.type=="plane"?(F=new THREE.PlaneGeometry(w.width,w.height,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="sphere"?(F=new THREE.SphereGeometry(w.radius,w.segmentsWidth,w.segmentsHeight),D.geometries[n]=F):w.type=="cylinder"?(F=new THREE.CylinderGeometry(w.numSegs,w.topRad,w.botRad,w.height,w.topOffset,w.botOffset),D.geometries[n]=F):w.type=="torus"?(F=new THREE.TorusGeometry(w.radius, -w.tube,w.segmentsR,w.segmentsT),D.geometries[n]=F):w.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(w.subdivisions),D.geometries[n]=F):w.type=="bin_mesh"?G.load({model:e(w.url,C.urlBaseType),callback:k(n)}):w.type=="ascii_mesh"?I.load({model:e(w.url,C.urlBaseType),callback:k(n)}):w.type=="embedded_mesh"&&(w=C.embeds[w.id])&&I.createModel(w,l(n),"");for(y in C.textures)if(n=C.textures[y],n.url instanceof Array){L+=n.url.length;for(G=0;G>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(a,b){var c=m(a,b),e=m(a,b+1),g=m(a,b+2);return(m(a,b+3)<<24)+(g<<16)+(e<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a,b){return a.charCodeAt(b)&255}function n(b){var c, +e,g;c=f(a,b);e=f(a,b+F);g=f(a,b+C);b=k(a,b+H);y.faces.push(new THREE.Face3(c,e,g,null,null,y.materials[b]))}function o(b){var c,e,g,h,l,m;c=f(a,b);e=f(a,b+F);g=f(a,b+C);h=k(a,b+H);l=f(a,b+G);m=f(a,b+L);b=f(a,b+A);h=y.materials[h];var n=z[m*3],o=z[m*3+1];m=z[m*3+2];var p=z[b*3],u=z[b*3+1],b=z[b*3+2];y.faces.push(new THREE.Face3(c,e,g,[new THREE.Vector3(z[l*3],z[l*3+1],z[l*3+2]),new THREE.Vector3(n,o,m),new THREE.Vector3(p,u,b)],null,h))}function p(b){var c,e,g,h;c=f(a,b);e=f(a,b+D);g=f(a,b+I);h=f(a, +b+K);b=k(a,b+M);y.faces.push(new THREE.Face4(c,e,g,h,null,null,y.materials[b]))}function v(b){var c,e,g,h,l,m,n,o;c=f(a,b);e=f(a,b+D);g=f(a,b+I);h=f(a,b+K);l=k(a,b+M);m=f(a,b+J);n=f(a,b+N);o=f(a,b+E);b=f(a,b+R);l=y.materials[l];var p=z[n*3],u=z[n*3+1];n=z[n*3+2];var x=z[o*3],v=z[o*3+1];o=z[o*3+2];var t=z[b*3],w=z[b*3+1],b=z[b*3+2];y.faces.push(new THREE.Face4(c,e,g,h,[new THREE.Vector3(z[m*3],z[m*3+1],z[m*3+2]),new THREE.Vector3(p,u,n),new THREE.Vector3(x,v,o),new THREE.Vector3(t,w,b)],null,l))}function u(b){var c, +e,g,h;c=f(a,b);e=f(a,b+O);g=f(a,b+S);b=B[c*2];h=B[c*2+1];c=B[e*2];var k=y.faceVertexUvs[0];e=B[e*2+1];var l=B[g*2];g=B[g*2+1];var m=[];m.push(new THREE.UV(b,h));m.push(new THREE.UV(c,e));m.push(new THREE.UV(l,g));k.push(m)}function x(b){var c,e,g,h,k,l;c=f(a,b);e=f(a,b+U);g=f(a,b+Q);h=f(a,b+P);b=B[c*2];k=B[c*2+1];c=B[e*2];l=B[e*2+1];e=B[g*2];var m=y.faceVertexUvs[0];g=B[g*2+1];var n=B[h*2];h=B[h*2+1];var o=[];o.push(new THREE.UV(b,k));o.push(new THREE.UV(c,l));o.push(new THREE.UV(e,g));o.push(new THREE.UV(n, +h));m.push(o)}var y=this,w=0,t,z=[],B=[],F,C,H,G,L,A,D,I,K,M,J,N,E,R,O,S,U,Q,P,T,W,X,Y,Z,V;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,b);t={signature:a.substr(w,8),header_bytes:m(a,w+8),vertex_coordinate_bytes:m(a,w+9),normal_coordinate_bytes:m(a,w+10),uv_coordinate_bytes:m(a,w+11),vertex_index_bytes:m(a,w+12),normal_index_bytes:m(a,w+13),uv_index_bytes:m(a,w+14),material_index_bytes:m(a,w+15),nvertices:f(a,w+16),nnormals:f(a,w+16+4),nuvs:f(a,w+16+8),ntri_flat:f(a,w+16+12), +ntri_smooth:f(a,w+16+16),ntri_flat_uv:f(a,w+16+20),ntri_smooth_uv:f(a,w+16+24),nquad_flat:f(a,w+16+28),nquad_smooth:f(a,w+16+32),nquad_flat_uv:f(a,w+16+36),nquad_smooth_uv:f(a,w+16+40)};w+=t.header_bytes;F=t.vertex_index_bytes;C=t.vertex_index_bytes*2;H=t.vertex_index_bytes*3;G=t.vertex_index_bytes*3+t.material_index_bytes;L=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;A=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;D=t.vertex_index_bytes;I=t.vertex_index_bytes* +2;K=t.vertex_index_bytes*3;M=t.vertex_index_bytes*4;J=t.vertex_index_bytes*4+t.material_index_bytes;N=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;E=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;R=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;O=t.uv_index_bytes;S=t.uv_index_bytes*2;U=t.uv_index_bytes;Q=t.uv_index_bytes*2;P=t.uv_index_bytes*3;b=t.vertex_index_bytes*3+t.material_index_bytes;V=t.vertex_index_bytes*4+t.material_index_bytes; +T=t.ntri_flat*b;W=t.ntri_smooth*(b+t.normal_index_bytes*3);X=t.ntri_flat_uv*(b+t.uv_index_bytes*3);Y=t.ntri_smooth_uv*(b+t.normal_index_bytes*3+t.uv_index_bytes*3);Z=t.nquad_flat*V;b=t.nquad_smooth*(V+t.normal_index_bytes*4);V=t.nquad_flat_uv*(V+t.uv_index_bytes*4);w+=function(b){for(var e,f,h,j=t.vertex_coordinate_bytes*3,k=b+t.nvertices*j;b1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(F,L);object.name=p;object.position.set(t[0],t[1],t[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;E.scene.addObject(object);E.objects[p]=object;w.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),E.scene.collisions.colliders.push(a)); +if(w.castsShadow)a=new THREE.ShadowVolume(F),E.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},E.triggers[object.name]=a)}}else t=w.position,r=w.rotation,q=w.quaternion,s=w.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(t[0],t[1],t[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,E.scene.addObject(object),E.objects[p]=object,E.empties[p]=object,w.trigger&&w.trigger.toLowerCase()!="none"&&(a={type:w.trigger,object:w},E.triggers[object.name]=a)}function k(a){return function(b){E.geometries[a]=b;j();K-=1;c.onLoadComplete();m()}}function l(a){return function(b){E.geometries[a]=b}}function m(){c.callbackProgress({totalModels:J,totalTextures:N,loadedModels:J-K,loadedTextures:N-M},E);c.onLoadProgress();K==0&&M==0&&b(E)}var n, +o,p,v,u,x,y,w,t,z,B,F,C,H,G,L,A,D,I,K,M,J,N,E;D=a.data;G=new THREE.BinaryLoader;I=new THREE.JSONLoader;M=K=0;E={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(w=D.objects[p],w.meshCollider){a=!0;break}if(a)E.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;z=D.transform.rotation;var R=D.transform.scale;a&&E.scene.position.set(a[0],a[1],a[2]);z&&E.scene.rotation.set(z[0], +z[1],z[2]);R&&E.scene.scale.set(R[0],R[1],R[2]);(a||z||R)&&E.scene.updateMatrix()}a=function(){M-=1;m();c.onLoadComplete()};for(u in D.cameras){z=D.cameras[u];if(z.type=="perspective")C=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")C=new THREE.Camera,C.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);t=z.position;z=z.target;C.position.set(t[0],t[1],t[2]);C.target.position.set(z[0],z[1],z[2]);E.cameras[u]=C}for(v in D.lights)u=D.lights[v], +C=u.color!==void 0?u.color:16777215,z=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(t=u.direction,A=new THREE.DirectionalLight(C,z),A.position.set(t[0],t[1],t[2]),A.position.normalize()):u.type=="point"?(t=u.position,d=u.distance,A=new THREE.PointLight(C,z,d),A.position.set(t[0],t[1],t[2])):u.type=="ambient"&&(A=new THREE.AmbientLight(C)),E.scene.addLight(A),E.lights[v]=A;for(x in D.fogs)v=D.fogs[x],v.type=="linear"?H=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(H=new THREE.FogExp2(0, +v.density)),z=v.color,H.color.setRGB(z[0],z[1],z[2]),E.fogs[x]=H;if(E.cameras&&D.defaults.camera)E.currentCamera=E.cameras[D.defaults.camera];if(E.fogs&&D.defaults.fog)E.scene.fog=E.fogs[D.defaults.fog];z=D.defaults.bgcolor;E.bgColor=new THREE.Color;E.bgColor.setRGB(z[0],z[1],z[2]);E.bgColorAlpha=D.defaults.bgalpha;for(n in D.geometries)if(x=D.geometries[n],x.type=="bin_mesh"||x.type=="ascii_mesh")K+=1,c.onLoadStart();J=K;for(n in D.geometries)x=D.geometries[n],x.type=="cube"?(F=new THREE.CubeGeometry(x.width, +x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),E.geometries[n]=F):x.type=="plane"?(F=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),E.geometries[n]=F):x.type=="sphere"?(F=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),E.geometries[n]=F):x.type=="cylinder"?(F=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),E.geometries[n]=F):x.type=="torus"?(F=new THREE.TorusGeometry(x.radius, +x.tube,x.segmentsR,x.segmentsT),E.geometries[n]=F):x.type=="icosahedron"?(F=new THREE.IcosahedronGeometry(x.subdivisions),E.geometries[n]=F):x.type=="bin_mesh"?G.load({model:e(x.url,D.urlBaseType),callback:k(n)}):x.type=="ascii_mesh"?I.load({model:e(x.url,D.urlBaseType),callback:k(n)}):x.type=="embedded_mesh"&&(x=D.embeds[x.id])&&I.createModel(x,l(n),"");for(y in D.textures)if(n=D.textures[y],n.url instanceof Array){M+=n.url.length;for(G=0;G=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,g=0;g>1^-(j&1);c[8*g+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=g=0;f=57344&&(b-=2048);b++;for(var c=new Float32Array(8*b),e=1,f=0;f<8;f++){for(var h=0,g=0;g>1^-(j&1);c[8*g+f]=h}e+=b}b=a.length-e;h=new Uint16Array(b);for(f=g=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&&(k=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);j=Math.floor(m+j);j>this.size-1&&(j=this.size- -1);for(var v,t,w,y,x,u;n0&&(this.field[w+v]+=y)}}};this.addPlaneX=function(a,b){var f,h,g,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/b);p>l&&(p=l);for(f=0;f0)for(h=0;h0&&(this.field[x+v]+=y)}}};this.addPlaneX=function(a,b){var f,h,g,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/b);p>l&&(p=l);for(f=0;f0)for(h=0;hm&&(v=m);for(h=0;h0){k=h*n;for(f=0;fsize&&(dist=size);for(g=0;g0){k=zd*g;for(h=0;h> 7 ) ), + exponent = ((( b0 << 1 ) & 0xff) | ( b1 >> 7 )) - 127, + mantissa = (( b1 & 0x7f ) << 16) | (b2 << 8) | b3; + + if (mantissa == 0 && exponent == -127) + return 0.0; + + return sign * ( 1 + mantissa * Math.pow( 2, -23 ) ) * Math.pow( 2, exponent ); + + }; + + function parseUInt32( data, offset ) { + + var b0 = parseUChar8( data, offset ), + b1 = parseUChar8( data, offset + 1 ), + b2 = parseUChar8( data, offset + 2 ), + b3 = parseUChar8( data, offset + 3 ); + + return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; + + }; + + function parseUInt16( data, offset ) { + + var b0 = parseUChar8( data, offset ), + b1 = parseUChar8( data, offset + 1 ); + + return (b1 << 8) + b0; + + }; + + function parseSChar8( data, offset ) { + + var b = parseUChar8( data, offset ); + return b > 127 ? b - 256 : b; + + }; + + function parseUChar8( data, offset ) { + + return data.charCodeAt( offset ) & 0xff; + + }; + + function init_vertices( start ) { + + var i, x, y, z, + stride = md.vertex_coordinate_bytes * 3, + end = start + md.nvertices * stride; + + for( i = start; i < end; i += stride ) { + + x = parseFloat32( data, i ); + y = parseFloat32( data, i + md.vertex_coordinate_bytes ); + z = parseFloat32( data, i + md.vertex_coordinate_bytes*2 ); + + vertex( scope, x, y, z ); } - function parseString( data, offset, length ) { + return md.nvertices * stride; - return data.substr( offset, length ); + }; + + function init_normals( start ) { + + var i, x, y, z, + stride = md.normal_coordinate_bytes * 3, + end = start + md.nnormals * stride; + + for( i = start; i < end; i += stride ) { + + x = parseSChar8( data, i ); + y = parseSChar8( data, i + md.normal_coordinate_bytes ); + z = parseSChar8( data, i + md.normal_coordinate_bytes*2 ); + + normals.push( x/127, y/127, z/127 ); } - function parseFloat32( data, offset ) { + return md.nnormals * stride; - var b3 = parseUChar8( data, offset ), - b2 = parseUChar8( data, offset + 1 ), - b1 = parseUChar8( data, offset + 2 ), - b0 = parseUChar8( data, offset + 3 ), + }; - sign = 1 - ( 2 * ( b0 >> 7 ) ), - exponent = ((( b0 << 1 ) & 0xff) | ( b1 >> 7 )) - 127, - mantissa = (( b1 & 0x7f ) << 16) | (b2 << 8) | b3; + function init_uvs( start ) { - if (mantissa == 0 && exponent == -127) - return 0.0; + var i, u, v, + stride = md.uv_coordinate_bytes * 2, + end = start + md.nuvs * stride; - return sign * ( 1 + mantissa * Math.pow( 2, -23 ) ) * Math.pow( 2, exponent ); + for( i = start; i < end; i += stride ) { + + u = parseFloat32( data, i ); + v = parseFloat32( data, i + md.uv_coordinate_bytes ); + + uvs.push( u, v ); } - function parseUInt32( data, offset ) { + return md.nuvs * stride; - var b0 = parseUChar8( data, offset ), - b1 = parseUChar8( data, offset + 1 ), - b2 = parseUChar8( data, offset + 2 ), - b3 = parseUChar8( data, offset + 3 ); + }; - return (b3 << 24) + (b2 << 16) + (b1 << 8) + b0; - } + function add_tri( i ) { - function parseUInt16( data, offset ) { + var a, b, c, m; - var b0 = parseUChar8( data, offset ), - b1 = parseUChar8( data, offset + 1 ); + a = parseUInt32( data, i ); + b = parseUInt32( data, i + tri_b ); + c = parseUInt32( data, i + tri_c ); - return (b1 << 8) + b0; + m = parseUInt16( data, i + tri_m ); + + f3( scope, a, b, c, m ); + + }; + + function add_tri_n( i ) { + + var a, b, c, m, na, nb, nc; + + a = parseUInt32( data, i ); + b = parseUInt32( data, i + tri_b ); + c = parseUInt32( data, i + tri_c ); + + m = parseUInt16( data, i + tri_m ); + + na = parseUInt32( data, i + tri_na ); + nb = parseUInt32( data, i + tri_nb ); + nc = parseUInt32( data, i + tri_nc ); + + f3n( scope, normals, a, b, c, m, na, nb, nc ); + + }; + + function add_quad( i ) { + + var a, b, c, d, m; + + a = parseUInt32( data, i ); + b = parseUInt32( data, i + quad_b ); + c = parseUInt32( data, i + quad_c ); + d = parseUInt32( data, i + quad_d ); + + m = parseUInt16( data, i + quad_m ); + + f4( scope, a, b, c, d, m ); + + }; + + function add_quad_n( i ) { + + var a, b, c, d, m, na, nb, nc, nd; + + a = parseUInt32( data, i ); + b = parseUInt32( data, i + quad_b ); + c = parseUInt32( data, i + quad_c ); + d = parseUInt32( data, i + quad_d ); + + m = parseUInt16( data, i + quad_m ); + + na = parseUInt32( data, i + quad_na ); + nb = parseUInt32( data, i + quad_nb ); + nc = parseUInt32( data, i + quad_nc ); + nd = parseUInt32( data, i + quad_nd ); + + f4n( scope, normals, a, b, c, d, m, na, nb, nc, nd ); + + }; + + function add_uv3( i ) { + + var uva, uvb, uvc, u1, u2, u3, v1, v2, v3; + + uva = parseUInt32( data, i ); + uvb = parseUInt32( data, i + tri_uvb ); + uvc = parseUInt32( data, i + tri_uvc ); + + u1 = uvs[ uva*2 ]; + v1 = uvs[ uva*2 + 1 ]; + + u2 = uvs[ uvb*2 ]; + v2 = uvs[ uvb*2 + 1 ]; + + u3 = uvs[ uvc*2 ]; + v3 = uvs[ uvc*2 + 1 ]; + + uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 ); + + }; + + function add_uv4( i ) { + + var uva, uvb, uvc, uvd, u1, u2, u3, u4, v1, v2, v3, v4; + + uva = parseUInt32( data, i ); + uvb = parseUInt32( data, i + quad_uvb ); + uvc = parseUInt32( data, i + quad_uvc ); + uvd = parseUInt32( data, i + quad_uvd ); + + u1 = uvs[ uva*2 ]; + v1 = uvs[ uva*2 + 1 ]; + + u2 = uvs[ uvb*2 ]; + v2 = uvs[ uvb*2 + 1 ]; + + u3 = uvs[ uvc*2 ]; + v3 = uvs[ uvc*2 + 1 ]; + + u4 = uvs[ uvd*2 ]; + v4 = uvs[ uvd*2 + 1 ]; + + uv4( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3, u4, v4 ); + + }; + + function init_triangles_flat( start ) { + + var i, stride = md.vertex_index_bytes * 3 + md.material_index_bytes, + end = start + md.ntri_flat * stride; + + for( i = start; i < end; i += stride ) { + + add_tri( i ); } - function parseSChar8( data, offset ) { - - var b = parseUChar8( data, offset ); - return b > 127 ? b - 256 : b; - - } - - function parseUChar8( data, offset ) { - - return data.charCodeAt( offset ) & 0xff; - } - - function init_vertices( start ) { - - var i, x, y, z, - stride = md.vertex_coordinate_bytes * 3, - end = start + md.nvertices * stride; - - for( i = start; i < end; i += stride ) { - - x = parseFloat32( data, i ); - y = parseFloat32( data, i + md.vertex_coordinate_bytes ); - z = parseFloat32( data, i + md.vertex_coordinate_bytes*2 ); - - THREE.BinaryLoader.prototype.v( scope, x, y, z ); - - } - - return md.nvertices * stride; - - } - - function init_normals( start ) { - - var i, x, y, z, - stride = md.normal_coordinate_bytes * 3, - end = start + md.nnormals * stride; - - for( i = start; i < end; i += stride ) { - - x = parseSChar8( data, i ); - y = parseSChar8( data, i + md.normal_coordinate_bytes ); - z = parseSChar8( data, i + md.normal_coordinate_bytes*2 ); - - normals.push( x/127, y/127, z/127 ); - - } - - return md.nnormals * stride; - - } - - function init_uvs( start ) { - - var i, u, v, - stride = md.uv_coordinate_bytes * 2, - end = start + md.nuvs * stride; - - for( i = start; i < end; i += stride ) { - - u = parseFloat32( data, i ); - v = parseFloat32( data, i + md.uv_coordinate_bytes ); - - uvs.push( u, v ); - - } - - return md.nuvs * stride; - - } - - function add_tri( i ) { - - var a, b, c, m; - - a = parseUInt32( data, i ); - b = parseUInt32( data, i + tri_b ); - c = parseUInt32( data, i + tri_c ); - - m = parseUInt16( data, i + tri_m ); - - THREE.BinaryLoader.prototype.f3( scope, a, b, c, m ); - - } - - function add_tri_n( i ) { - - var a, b, c, m, na, nb, nc; - - a = parseUInt32( data, i ); - b = parseUInt32( data, i + tri_b ); - c = parseUInt32( data, i + tri_c ); - - m = parseUInt16( data, i + tri_m ); - - na = parseUInt32( data, i + tri_na ); - nb = parseUInt32( data, i + tri_nb ); - nc = parseUInt32( data, i + tri_nc ); - - THREE.BinaryLoader.prototype.f3n( scope, normals, a, b, c, m, na, nb, nc ); - - } - - function add_quad( i ) { - - var a, b, c, d, m; - - a = parseUInt32( data, i ); - b = parseUInt32( data, i + quad_b ); - c = parseUInt32( data, i + quad_c ); - d = parseUInt32( data, i + quad_d ); - - m = parseUInt16( data, i + quad_m ); - - THREE.BinaryLoader.prototype.f4( scope, a, b, c, d, m ); - - } - - function add_quad_n( i ) { - - var a, b, c, d, m, na, nb, nc, nd; - - a = parseUInt32( data, i ); - b = parseUInt32( data, i + quad_b ); - c = parseUInt32( data, i + quad_c ); - d = parseUInt32( data, i + quad_d ); - - m = parseUInt16( data, i + quad_m ); - - na = parseUInt32( data, i + quad_na ); - nb = parseUInt32( data, i + quad_nb ); - nc = parseUInt32( data, i + quad_nc ); - nd = parseUInt32( data, i + quad_nd ); - - THREE.BinaryLoader.prototype.f4n( scope, normals, a, b, c, d, m, na, nb, nc, nd ); - - } - - function add_uv3( i ) { - - var uva, uvb, uvc, u1, u2, u3, v1, v2, v3; - - uva = parseUInt32( data, i ); - uvb = parseUInt32( data, i + tri_uvb ); - uvc = parseUInt32( data, i + tri_uvc ); - - u1 = uvs[ uva*2 ]; - v1 = uvs[ uva*2 + 1 ]; - - u2 = uvs[ uvb*2 ]; - v2 = uvs[ uvb*2 + 1 ]; - - u3 = uvs[ uvc*2 ]; - v3 = uvs[ uvc*2 + 1 ]; - - THREE.BinaryLoader.prototype.uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 ); - - } - - function add_uv4( i ) { - - var uva, uvb, uvc, uvd, u1, u2, u3, u4, v1, v2, v3, v4; - - uva = parseUInt32( data, i ); - uvb = parseUInt32( data, i + quad_uvb ); - uvc = parseUInt32( data, i + quad_uvc ); - uvd = parseUInt32( data, i + quad_uvd ); - - u1 = uvs[ uva*2 ]; - v1 = uvs[ uva*2 + 1 ]; - - u2 = uvs[ uvb*2 ]; - v2 = uvs[ uvb*2 + 1 ]; - - u3 = uvs[ uvc*2 ]; - v3 = uvs[ uvc*2 + 1 ]; - - u4 = uvs[ uvd*2 ]; - v4 = uvs[ uvd*2 + 1 ]; - - THREE.BinaryLoader.prototype.uv4( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3, u4, v4 ); - - } - - function init_triangles_flat( start ) { - - var i, stride = md.vertex_index_bytes * 3 + md.material_index_bytes, - end = start + md.ntri_flat * stride; - - for( i = start; i < end; i += stride ) { - - add_tri( i ); - - } - - return end - start; - - } - - function init_triangles_flat_uv( start ) { - - var i, offset = md.vertex_index_bytes * 3 + md.material_index_bytes, - stride = offset + md.uv_index_bytes * 3, - end = start + md.ntri_flat_uv * stride; - - for( i = start; i < end; i += stride ) { - - add_tri( i ); - add_uv3( i + offset ); - - } - - return end - start; - - } - - function init_triangles_smooth( start ) { - - var i, stride = md.vertex_index_bytes * 3 + md.material_index_bytes + md.normal_index_bytes * 3, - end = start + md.ntri_smooth * stride; - - for( i = start; i < end; i += stride ) { - - add_tri_n( i ); - - } - - return end - start; - - } - - function init_triangles_smooth_uv( start ) { - - var i, offset = md.vertex_index_bytes * 3 + md.material_index_bytes + md.normal_index_bytes * 3, - stride = offset + md.uv_index_bytes * 3, - end = start + md.ntri_smooth_uv * stride; - - for( i = start; i < end; i += stride ) { - - add_tri_n( i ); - add_uv3( i + offset ); - - } - - return end - start; - - } - - function init_quads_flat( start ) { - - var i, stride = md.vertex_index_bytes * 4 + md.material_index_bytes, - end = start + md.nquad_flat * stride; - - for( i = start; i < end; i += stride ) { - - add_quad( i ); - - } - - return end - start; - - } - - function init_quads_flat_uv( start ) { - - var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes, - stride = offset + md.uv_index_bytes * 4, - end = start + md.nquad_flat_uv * stride; - - for( i = start; i < end; i += stride ) { - - add_quad( i ); - add_uv4( i + offset ); - - } - - return end - start; - - } - - function init_quads_smooth( start ) { - - var i, stride = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4, - end = start + md.nquad_smooth * stride; - - for( i = start; i < end; i += stride ) { - - add_quad_n( i ); - } - - return end - start; - - } - - function init_quads_smooth_uv( start ) { - - var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4, - stride = offset + md.uv_index_bytes * 4, - end = start + md.nquad_smooth_uv * stride; - - for( i = start; i < end; i += stride ) { - - add_quad_n( i ); - add_uv4( i + offset ); - - } - - return end - start; - - } + return end - start; } - Model.prototype = new THREE.Geometry(); - Model.prototype.constructor = Model; + function init_triangles_flat_uv( start ) { - callback( new Model( texture_path ) ); + var i, offset = md.vertex_index_bytes * 3 + md.material_index_bytes, + stride = offset + md.uv_index_bytes * 3, + end = start + md.ntri_flat_uv * stride; - }, + for( i = start; i < end; i += stride ) { + add_tri( i ); + add_uv3( i + offset ); - v: function( scope, x, y, z ) { + } + + return end - start; + + }; + + function init_triangles_smooth( start ) { + + var i, stride = md.vertex_index_bytes * 3 + md.material_index_bytes + md.normal_index_bytes * 3, + end = start + md.ntri_smooth * stride; + + for( i = start; i < end; i += stride ) { + + add_tri_n( i ); + + } + + return end - start; + + }; + + function init_triangles_smooth_uv( start ) { + + var i, offset = md.vertex_index_bytes * 3 + md.material_index_bytes + md.normal_index_bytes * 3, + stride = offset + md.uv_index_bytes * 3, + end = start + md.ntri_smooth_uv * stride; + + for( i = start; i < end; i += stride ) { + + add_tri_n( i ); + add_uv3( i + offset ); + + } + + return end - start; + + }; + + function init_quads_flat( start ) { + + var i, stride = md.vertex_index_bytes * 4 + md.material_index_bytes, + end = start + md.nquad_flat * stride; + + for( i = start; i < end; i += stride ) { + + add_quad( i ); + + } + + return end - start; + + }; + + function init_quads_flat_uv( start ) { + + var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes, + stride = offset + md.uv_index_bytes * 4, + end = start + md.nquad_flat_uv * stride; + + for( i = start; i < end; i += stride ) { + + add_quad( i ); + add_uv4( i + offset ); + + } + + return end - start; + + }; + + function init_quads_smooth( start ) { + + var i, stride = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4, + end = start + md.nquad_smooth * stride; + + for( i = start; i < end; i += stride ) { + + add_quad_n( i ); + + } + + return end - start; + + }; + + function init_quads_smooth_uv( start ) { + + var i, offset = md.vertex_index_bytes * 4 + md.material_index_bytes + md.normal_index_bytes * 4, + stride = offset + md.uv_index_bytes * 4, + end = start + md.nquad_smooth_uv * stride; + + for( i = start; i < end; i += stride ) { + + add_quad_n( i ); + add_uv4( i + offset ); + + } + + return end - start; + + }; + + }; + + function vertex ( scope, x, y, z ) { scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); - }, + }; - f3: function( scope, a, b, c, mi ) { + function f3 ( scope, a, b, c, mi ) { var material = scope.materials[ mi ]; scope.faces.push( new THREE.Face3( a, b, c, null, null, material ) ); - }, + }; - f4: function( scope, a, b, c, d, mi ) { + function f4 ( scope, a, b, c, d, mi ) { var material = scope.materials[ mi ]; scope.faces.push( new THREE.Face4( a, b, c, d, null, null, material ) ); - }, + }; - f3n: function( scope, normals, a, b, c, mi, na, nb, nc ) { + function f3n ( scope, normals, a, b, c, mi, na, nb, nc ) { var material = scope.materials[ mi ], nax = normals[ na*3 ], @@ -717,9 +710,9 @@ THREE.BinaryLoader.prototype = { null, material ) ); - }, + }; - f4n: function( scope, normals, a, b, c, d, mi, na, nb, nc, nd ) { + function f4n ( scope, normals, a, b, c, d, mi, na, nb, nc, nd ) { var material = scope.materials[ mi ], nax = normals[ na*3 ], @@ -746,9 +739,9 @@ THREE.BinaryLoader.prototype = { null, material ) ); - }, + }; - uv3: function( where, u1, v1, u2, v2, u3, v3 ) { + function uv3 ( where, u1, v1, u2, v2, u3, v3 ) { var uv = []; uv.push( new THREE.UV( u1, v1 ) ); @@ -756,9 +749,9 @@ THREE.BinaryLoader.prototype = { uv.push( new THREE.UV( u3, v3 ) ); where.push( uv ); - }, + }; - uv4: function( where, u1, v1, u2, v2, u3, v3, u4, v4 ) { + function uv4 ( where, u1, v1, u2, v2, u3, v3, u4, v4 ) { var uv = []; uv.push( new THREE.UV( u1, v1 ) ); @@ -767,8 +760,11 @@ THREE.BinaryLoader.prototype = { uv.push( new THREE.UV( u4, v4 ) ); where.push( uv ); - }, - - constructor : THREE.BinaryLoader + }; + + Model.prototype = new THREE.Geometry(); + Model.prototype.constructor = Model; + + callback( new Model( texture_path ) ); }; diff --git a/src/extras/loaders/ColladaLoader.js b/src/extras/loaders/ColladaLoader.js index 0c4d5498..60cbff21 100644 --- a/src/extras/loaders/ColladaLoader.js +++ b/src/extras/loaders/ColladaLoader.js @@ -2,7 +2,8 @@ * @author Tim Knip / http://www.floorplanner.com/ / tim at floorplanner.com */ -var ColladaLoader = function() { +var ColladaLoader = function () { + var COLLADA = null; var scene = null; var daeScene; @@ -21,8 +22,10 @@ var ColladaLoader = function() { var skins; var preferredShading = THREE.SmoothShading; - function load(url, readyCallback) { - if (document.implementation && document.implementation.createDocument) { + function load ( url, readyCallback ) { + + if ( document.implementation && document.implementation.createDocument ) { + var namespaceURL = "http://www.collada.org/2005/11/COLLADASchema"; var rootTagName = "COLLADA"; @@ -32,56 +35,77 @@ var ColladaLoader = function() { var req = new XMLHttpRequest(); - if(req.overrideMimeType) { + if( req.overrideMimeType ) { + // need this? yes... if extension is other then *.xml :-S req.overrideMimeType("text/xml"); + } req.onreadystatechange = function() { - if(req.readyState == 4) { - if(req.status == 0 || req.status == 200) { + + if( req.readyState == 4 ) { + + if( req.status == 0 || req.status == 200 ) { readyCallbackFunc = readyCallback; - parse(req.responseXML, undefined, url); + parse( req.responseXML, undefined, url ); + } + } + } - req.open("GET", url, true); - req.send(null); + + req.open( "GET", url, true ); + req.send( null ); + } else { + alert("Don't know how to parse XML!"); + } - } - - function parse(doc, callBack, url) { + + }; + + function parse ( doc, callBack, url ) { + COLLADA = doc; callBack = callBack || readyCallbackFunc; - if (url !== undefined) { + + if ( url !== undefined ) { + var parts = url.split('/'); parts.pop(); baseUrl = parts.join('/') + '/'; + } - images = parseLib("//dae:library_images/dae:image", _Image, "image"); - materials = parseLib("//dae:library_materials/dae:material", Material, "material"); - effects = parseLib("//dae:library_effects/dae:effect", Effect, "effect"); - geometries = parseLib("//dae:library_geometries/dae:geometry", Geometry, "geometry"); - controllers = parseLib("//dae:library_controllers/dae:controller", Controller, "controller"); - animations = parseLib("//dae:library_animations/dae:animation", Animation, "animation"); - visualScenes = parseLib(".//dae:library_visual_scenes/dae:visual_scene", VisualScene, "visual_scene"); - + + images = parseLib( "//dae:library_images/dae:image", _Image, "image" ); + materials = parseLib( "//dae:library_materials/dae:material", Material, "material") ; + effects = parseLib( "//dae:library_effects/dae:effect", Effect, "effect" ); + geometries = parseLib( "//dae:library_geometries/dae:geometry", Geometry, "geometry" ); + controllers = parseLib( "//dae:library_controllers/dae:controller", Controller, "controller" ); + animations = parseLib( "//dae:library_animations/dae:animation", Animation, "animation" ); + visualScenes = parseLib( ".//dae:library_visual_scenes/dae:visual_scene", VisualScene, "visual_scene" ); + morphs = []; skins = []; - + daeScene = parseScene(); scene = new THREE.Object3D(); - for (var i = 0; i < daeScene.nodes.length; i++) { - scene.addChild(createSceneGraph(daeScene.nodes[i])); + + for ( var i = 0; i < daeScene.nodes.length; i++ ) { + + scene.addChild( createSceneGraph( daeScene.nodes[ i ] ) ); + } createAnimations(); var result = { - scene: scene, + + scene: scene, morphs: morphs, skins: skins, dae: { @@ -94,125 +118,182 @@ var ColladaLoader = function() { visualScenes: visualScenes, scene: daeScene } + }; - - if (callBack) { - callBack(result); + + if ( callBack ) { + + callBack( result ); + } + return result; - } - - function setPreferredShading(shading) { + + }; + + function setPreferredShading ( shading ) { + preferredShading = shading; - } - function parseLib(q, classSpec, prefix) { - var elements = COLLADA.evaluate(q, - COLLADA, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, - null); + + }; + + function parseLib ( q, classSpec, prefix ) { + + var elements = COLLADA.evaluate(q, + COLLADA, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, + null) ; + var lib = {}; var element = elements.iterateNext(); var i = 0; - while (element) { - var daeElement = (new classSpec()).parse(element); - if (daeElement.id.length == 0) daeElement.id = prefix + (i++); - lib[daeElement.id] = daeElement; + + while ( element ) { + + var daeElement = ( new classSpec() ).parse( element ); + if ( daeElement.id.length == 0 ) daeElement.id = prefix + ( i++ ); + lib[ daeElement.id ] = daeElement; element = elements.iterateNext(); + } + return lib; - } - - function parseScene() { - var sceneElement = COLLADA.evaluate(".//dae:scene/dae:instance_visual_scene", - COLLADA, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, - null).iterateNext(); - - - if (sceneElement) { - var url = sceneElement.getAttribute('url').replace(/^#/, ''); - return visualScenes[url]; + + }; + + function parseScene () { + + var sceneElement = COLLADA.evaluate( ".//dae:scene/dae:instance_visual_scene", + COLLADA, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, + null ).iterateNext(); + + if ( sceneElement ) { + + var url = sceneElement.getAttribute( 'url' ).replace( /^#/, '' ); + return visualScenes[ url ]; + } else { + return null; + } - } - - function createAnimations() { + + }; + + function createAnimations () { + calcAnimationBounds(); - for (animation_id in animations) { - createAnimation(animations[animation_id]); + + for ( var animation_id in animations ) { + + createAnimation( animations[ animation_id ] ); + } - } - - function createAnimation(animation) { - } - - function calcAnimationBounds() { + + }; + + function createAnimation ( animation ) { + + }; + + function calcAnimationBounds () { + var start = 1000000; var end = -start; var frames = 0; - - for (id in animations) { - var animation = animations[id]; - for (var i = 0; i < animation.sampler.length; i++) { - var sampler = animation.sampler[i]; - sampler.create(); - start = Math.min(start, sampler.startTime); - end = Math.max(end, sampler.endTime); - frames = Math.max(frames, sampler.input.length); + + for ( var id in animations ) { + + var animation = animations[ id ]; + + for ( var i = 0; i < animation.sampler.length; i ++ ) { + + var sampler = animation.sampler[ i ]; + sampler.create(); + + start = Math.min( start, sampler.startTime ); + end = Math.max( end, sampler.endTime ); + frames = Math.max( frames, sampler.input.length ); + } + } - return {start:start, end:end, frames:frames} - } - - function createMorph(geometry, ctrl) { - var morphCtrl = ctrl instanceof InstanceController ? controllers[ctrl.url] : ctrl; - if (!morphCtrl || !morphCtrl.morph) { + + return { start:start, end:end, frames:frames }; + + }; + + function createMorph ( geometry, ctrl ) { + + var morphCtrl = ctrl instanceof InstanceController ? controllers[ ctrl.url ] : ctrl; + + if ( !morphCtrl || !morphCtrl.morph ) { + console.log("could not find morph controller!"); return; + } + var morph = morphCtrl.morph; - for (var i = 0; i < morph.targets.length; i++) { - var target_id = morph.targets[i]; - var daeGeometry = geometries[target_id]; - if (!daeGeometry.mesh || - !daeGeometry.mesh.primitives || - !daeGeometry.mesh.primitives.length) { - continue; + for ( var i = 0; i < morph.targets.length; i ++ ) { + + var target_id = morph.targets[ i ]; + var daeGeometry = geometries[ target_id ]; + + if ( !daeGeometry.mesh || + !daeGeometry.mesh.primitives || + !daeGeometry.mesh.primitives.length) { + continue; } - var target = daeGeometry.mesh.primitives[0].geometry; - if (target.vertices.length === geometry.vertices.length) { + + var target = daeGeometry.mesh.primitives[ 0 ].geometry; + + if ( target.vertices.length === geometry.vertices.length ) { + geometry.morphTargets.push( { name: "target_1", vertices: target.vertices } ); + } } + geometry.morphTargets.push( { name: "target_Z", vertices: geometry.vertices } ); - } - - function createSkin(geometry, ctrl, applyBindShape) { - var skinCtrl = controllers[ctrl.url]; - if (!skinCtrl || !skinCtrl.skin) { + + }; + + function createSkin ( geometry, ctrl, applyBindShape ) { + + var skinCtrl = controllers[ ctrl.url ]; + + if ( !skinCtrl || !skinCtrl.skin ) { + console.log("could not find skin controller!"); return; + } - if (!ctrl.skeleton || !ctrl.skeleton.length) { + + if ( !ctrl.skeleton || !ctrl.skeleton.length ) { + console.log("could not find the skeleton for the skin!"); return; + } + var skin = skinCtrl.skin; - var skeleton = daeScene.getChildById(ctrl.skeleton[0]); + var skeleton = daeScene.getChildById( ctrl.skeleton[ 0 ] ); var hierarchy = []; - + applyBindShape = applyBindShape !== undefined ? applyBindShape : true; - + var bones = []; geometry.skinWeights = []; geometry.skinIndices = []; - - createBones(geometry.bones, skin, hierarchy, skeleton, null, -1); - createWeights(skin, geometry.bones, geometry.skinIndices, geometry.skinWeights); + + createBones( geometry.bones, skin, hierarchy, skeleton, null, -1 ); + createWeights( skin, geometry.bones, geometry.skinIndices, geometry.skinWeights ); + /* geometry.animation = { name: 'take_001', @@ -222,158 +303,231 @@ var ColladaLoader = function() { hierarchy: hierarchy }; */ - if (applyBindShape) { - for (var i = 0; i < geometry.vertices.length; i++) { - skin.bindShapeMatrix.multiplyVector3(geometry.vertices[i].position); + + if ( applyBindShape ) { + + for ( var i = 0; i < geometry.vertices.length; i ++ ) { + + skin.bindShapeMatrix.multiplyVector3( geometry.vertices[ i ].position ); + } - } - } - - function setupSkeleton(node, bones, frame, parent) { - node.world = node.world || new THREE.Matrix4(); - node.world.copy(node.matrix); - - if (node.channels && node.channels.length) { - var channel = node.channels[0]; - var m = channel.sampler.output[frame]; - if (m instanceof THREE.Matrix4) { - node.world.copy(m); - } - } - - if (parent) { - node.world.multiply(parent, node.world); + } - bones.push(node); - - for (var i = 0; i < node.nodes.length; i++) { - setupSkeleton(node.nodes[i], bones, frame, node.world); + }; + + function setupSkeleton ( node, bones, frame, parent ) { + + node.world = node.world || new THREE.Matrix4(); + node.world.copy( node.matrix ); + + if ( node.channels && node.channels.length ) { + + var channel = node.channels[ 0 ]; + var m = channel.sampler.output[ frame ]; + + if ( m instanceof THREE.Matrix4 ) { + + node.world.copy(m); + + } + } - } - - function setupSkinningMatrices(bones, skin) { + + if ( parent ) { + + node.world.multiply( parent, node.world ); + + } + + bones.push( node ); + + for ( var i = 0; i < node.nodes.length; i ++ ) { + + setupSkeleton( node.nodes[ i ], bones, frame, node.world ); + + } + + }; + + function setupSkinningMatrices ( bones, skin ) { + // FIXME: this is dumb... - for (var i = 0; i < bones.length; i++) { - var bone = bones[i]; + + for ( var i = 0; i < bones.length; i ++ ) { + + var bone = bones[ i ]; var found = -1; - for (var j = 0; j < skin.joints.length; j++) { - if (bone.sid == skin.joints[j]) { + + for ( var j = 0; j < skin.joints.length; j ++ ) { + + if ( bone.sid == skin.joints[ j ] ) { + found = j; break; + } + } - if (found >= 0){ - var inv = skin.invBindMatrices[found]; + + if ( found >= 0 ){ + + var inv = skin.invBindMatrices[ found ]; + bone.invBindMatrix = inv; bone.skinningMatrix = new THREE.Matrix4(); bone.skinningMatrix.multiply(bone.world, inv); // (IBMi * JMi) + bone.weights = []; - for (var j = 0; j < skin.weights.length; j++) { - for (var k = 0; k < skin.weights[j].length; k++) { - var w = skin.weights[j][k]; - if (w.joint == found) { - bone.weights.push(w); + + for ( var j = 0; j < skin.weights.length; j ++ ) { + + for (var k = 0; k < skin.weights[ j ].length; k ++) { + + var w = skin.weights[ j ][ k ]; + + if ( w.joint == found ) { + + bone.weights.push( w ); + } + } + } + } else { + throw "could not find joint!"; + } - } - } - - function applySkin(geometry, instanceCtrl, frame) { - var skinController = controllers[instanceCtrl.url]; - - frame = frame !== undefined ? frame : 40; - - if (!skinController || !skinController.skin) { - console.log("could not find skin controller!"); - return; + } - if (!instanceCtrl.skeleton || !instanceCtrl.skeleton.length) { + }; + + function applySkin ( geometry, instanceCtrl, frame ) { + + var skinController = controllers[ instanceCtrl.url ]; + + frame = frame !== undefined ? frame : 40; + + if ( !skinController || !skinController.skin ) { + + console.log("could not find skin controller!"); + return; + + } + + if ( !instanceCtrl.skeleton || !instanceCtrl.skeleton.length ) { + console.log("could not find the skeleton for the skin!"); return; + } - + var animationBounds = calcAnimationBounds(); - var skeleton = daeScene.getChildById(instanceCtrl.skeleton[0], true) || - daeScene.getChildBySid(instanceCtrl.skeleton[0], true); + var skeleton = daeScene.getChildById( instanceCtrl.skeleton[0], true ) || + daeScene.getChildBySid( instanceCtrl.skeleton[0], true ); + var i, j, w, vidx, weight; var v = new THREE.Vector3(), o, s; // move vertices to bind shape - for (i = 0; i < geometry.vertices.length; i++) { - skinController.skin.bindShapeMatrix.multiplyVector3(geometry.vertices[i].position); + + for ( i = 0; i < geometry.vertices.length; i ++ ) { + + skinController.skin.bindShapeMatrix.multiplyVector3( geometry.vertices[i].position ); + } - + // process animation, or simply pose the rig if no animation - for (frame = 0; frame < animationBounds.frames; frame++) { + + for ( frame = 0; frame < animationBounds.frames; frame ++ ) { + var bones = []; var skinned = []; - + // zero skinned vertices - for (i = 0; i < geometry.vertices.length; i++) { + + for ( i = 0; i < geometry.vertices.length; i++ ) { + skinned.push( new THREE.Vertex( new THREE.Vector3() ) ); + } - - // process the frame and setup the rig with a fresh + + // process the frame and setup the rig with a fresh // transform, possibly from the bone's animation channel(s) - setupSkeleton(skeleton, bones, frame); - setupSkinningMatrices(bones, skinController.skin); - + + setupSkeleton( skeleton, bones, frame ); + setupSkinningMatrices( bones, skinController.skin ); + // skin 'm - for (i = 0; i < bones.length; i++) { - for (j = 0; j < bones[i].weights.length; j++) { - w = bones[i].weights[j]; + + for ( i = 0; i < bones.length; i ++ ) { + + for ( j = 0; j < bones[ i ].weights.length; j ++ ) { + + w = bones[ i ].weights[ j ]; vidx = w.index; weight = w.weight; - + o = geometry.vertices[vidx]; s = skinned[vidx]; - + v.x = o.position.x; v.y = o.position.y; v.z = o.position.z; - + bones[i].skinningMatrix.multiplyVector3(v); - + s.position.x += (v.x * weight); s.position.y += (v.y * weight); s.position.z += (v.z * weight); + } + } - + geometry.morphTargets.push( { name: "target_" + frame, vertices: skinned } ); + } - } - - function createSceneGraph(node, parent) { + + }; + + function createSceneGraph ( node, parent ) { + var obj = new THREE.Object3D(); var skinned = false; var skinController; var morphController; var i; - + obj.name = node.id || ""; obj.matrixAutoUpdate = false; obj.matrix = node.matrix; // FIXME: controllers - for (i =0; i < node.controllers.length; i++) { + + for ( i =0; i < node.controllers.length; i ++ ) { + var controller = controllers[node.controllers[i].url]; - switch (controller.type) { + + switch ( controller.type ) { + case 'skin': - if (geometries[controller.skin.source]) { + + if ( geometries[controller.skin.source] ) { + var inst_geom = new InstanceGeometry(); inst_geom.url = controller.skin.source; inst_geom.instance_material = node.controllers[i].instance_material; node.geometries.push(inst_geom); skinned = true; skinController = node.controllers[i]; + } else if (controllers[controller.skin.source]) { + // urgh: controller can be chained // handle the most basic case... var second = controllers[controller.skin.source]; @@ -386,329 +540,513 @@ var ColladaLoader = function() { node.geometries.push(inst_geom); } } + break; + case 'morph': - if (geometries[controller.morph.source]) { + + if ( geometries[controller.morph.source] ) { + var inst_geom = new InstanceGeometry(); inst_geom.url = controller.morph.source; inst_geom.instance_material = node.controllers[i].instance_material; node.geometries.push(inst_geom); morphController = node.controllers[i]; + } - console.log("DAE: morph-controller partially supported.") + + console.log("DAE: morph-controller partially supported."); + default: break; } } - + // FIXME: multi-material mesh? // geometries - for (i = 0; i < node.geometries.length; i++) { + + for ( i = 0; i < node.geometries.length; i ++ ) { + var instance_geometry = node.geometries[i]; var instance_materials = instance_geometry.instance_material; var geometry = geometries[instance_geometry.url]; var used_materials = {}; var num_materials = 0; var first_material; - - if (geometry) { + + if ( geometry ) { + if (!geometry.mesh || !geometry.mesh.primitives) continue; - + if (obj.name.length == 0) { + obj.name = geometry.id; + } - + // collect used fx for this geometry-instance - if (instance_materials) { - for (j = 0; j < instance_materials.length; j++) { + + if ( instance_materials ) { + + for ( j = 0; j < instance_materials.length; j ++ ) { + var inst_material = instance_materials[j]; var effect_id = materials[inst_material.target].instance_effect.url; var shader = effects[effect_id].shader; - + shader.material.opacity = !shader.material.opacity ? 1 : shader.material.opacity; used_materials[inst_material.symbol] = shader.material; first_material = shader.material; - num_materials++; + num_materials ++; + } + } - + var mesh; - var material = first_material || new THREE.MeshLambertMaterial({ color: 0xdddddd, shading: THREE.FlatShading }); + var material = first_material || new THREE.MeshLambertMaterial( { color: 0xdddddd, shading: THREE.FlatShading } ); var geom = geometry.mesh.geometry3js; - if (num_materials > 1) { + + if ( num_materials > 1 ) { + material = new THREE.MeshFaceMaterial(); - for (j = 0; j < geom.faces.length; j++) { - var face = geom.faces[j]; - face.materials = [ used_materials[face.daeMaterial] ]; + + for ( j = 0; j < geom.faces.length; j ++ ) { + + var face = geom.faces[ j ]; + face.materials = [ used_materials[ face.daeMaterial ] ]; + } + } - - if (skinController !== undefined) { - applySkin(geom, skinController); + + if ( skinController !== undefined) { + + applySkin( geom, skinController ); + material.morphTargets = true; + mesh = new THREE.SkinnedMesh( geom, material ); mesh.skeleton = skinController.skeleton; - mesh.skinController = controllers[skinController.url]; + mesh.skinController = controllers[ skinController.url ]; mesh.skinInstanceController = skinController; mesh.name = 'skin_' + skins.length; - skins.push(mesh); - } else if (morphController !== undefined) { - createMorph(geom, morphController); + + skins.push( mesh ); + + } else if ( morphController !== undefined ) { + + createMorph( geom, morphController ); + material.morphTargets = true; + mesh = new THREE.Mesh( geom, material ); mesh.name = 'morph_' + morphs.length; - morphs.push(mesh); + + morphs.push( mesh ); + } else { + mesh = new THREE.Mesh( geom, material ); + } - - obj.addChild(mesh); + + obj.addChild( mesh ); + } + } - - for (i = 0; i < node.nodes.length; i++) { + + for ( i = 0; i < node.nodes.length; i ++ ) { + obj.addChild(createSceneGraph(node.nodes[i], node)); + } - + return obj; - } - - function getJointId(skin, id) { - for (var i = 0; i < skin.joints.length; i++) { - if (skin.joints[i] == id) { + + }; + + function getJointId( skin, id ) { + + for ( var i = 0; i < skin.joints.length; i ++ ) { + + if ( skin.joints[ i ] == id ) { + return i; + } + } - } - - function getLibraryNode(id) { - return COLLADA.evaluate(".//dae:library_nodes//dae:node[@id='"+id+"']", - COLLADA, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, - null).iterateNext(); - } - - function getChannelsForNode(node) { + + }; + + function getLibraryNode( id ) { + + return COLLADA.evaluate(".//dae:library_nodes//dae:node[@id='"+id+"']", + COLLADA, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, + null).iterateNext(); + + }; + + function getChannelsForNode (node ) { + var channels = []; var startTime = 1000000; var endTime = -1000000; - for (var id in animations) { + + for ( var id in animations ) { + var animation = animations[id]; - for (var i = 0; i < animation.channel.length; i++) { + + for ( var i = 0; i < animation.channel.length; i ++ ) { + var channel = animation.channel[i]; var sampler = animation.sampler[i]; var id = channel.target.split('/')[0]; - if (id == node.id) { + + if ( id == node.id ) { + sampler.create(); channel.sampler = sampler; startTime = Math.min(startTime, sampler.startTime); endTime = Math.max(endTime, sampler.endTime); channels.push(channel); + } + } + } - if (channels.length) { + + if ( channels.length ) { + node.startTime = startTime; - node.endTime = endTime; + node.endTime = endTime; + } + return channels; - } - - function calcFrameDuration(node) { + + }; + + function calcFrameDuration( node ) { + var minT = 10000000; - for (i = 0; i < node.channels.length; i++) { + + for ( i = 0; i < node.channels.length; i ++ ) { + var sampler = node.channels[i].sampler; - - for (var j = 0; j < sampler.input.length - 1; j++) { + + for (var j = 0; j < sampler.input.length - 1; j ++ ) { + var t0 = sampler.input[j]; var t1 = sampler.input[j+1]; minT = Math.min(minT, t1 - t0); + } } + return minT; - } - - function calcMatrixAt(node, t) { + + }; + + function calcMatrixAt( node, t ) { + var animated = {}; + var i, j; - for (i = 0; i < node.channels.length; i++) { - var channel = node.channels[i]; + + for ( i = 0; i < node.channels.length; i ++ ) { + + var channel = node.channels[ i ]; animated[ channel.sid ] = channel; + } + var matrix = new THREE.Matrix4(); - for (i = 0; i < node.transforms.length; i++) { + + for ( i = 0; i < node.transforms.length; i ++ ) { + var transform = node.transforms[i]; var channel = animated[transform.sid]; - if (channel !== undefined) { + + if ( channel !== undefined ) { + var sampler = channel.sampler; var value; - for (var j = 0; j < sampler.input.length - 1; j++) { - if (sampler.input[j+1] > t) { + + for ( var j = 0; j < sampler.input.length - 1; j ++ ) { + + if ( sampler.input[j+1] > t ) { + value = sampler.output[j]; //console.log(value.flatten) break; + } + } - if (value !== undefined) { - if (value instanceof THREE.Matrix4) { - matrix = matrix.multiply(matrix, value); + + if ( value !== undefined ) { + + if ( value instanceof THREE.Matrix4 ) { + + matrix = matrix.multiply( matrix, value ); + } else { + // FIXME: handle other types - matrix = matrix.multiply(matrix, transform.matrix); + + matrix = matrix.multiply( matrix, transform.matrix ); + } + } else { - matrix = matrix.multiply(matrix, transform.matrix); + + matrix = matrix.multiply( matrix, transform.matrix ); + } + } else { - matrix = matrix.multiply(matrix, transform.matrix); + + matrix = matrix.multiply( matrix, transform.matrix ); + } + } + return matrix; - } - - function bakeAnimations(node) { - if (node.channels && node.channels.length) { - var frameDuration = calcFrameDuration(node); + + }; + + function bakeAnimations ( node ) { + + if ( node.channels && node.channels.length ) { + + var frameDuration = calcFrameDuration( node ); var t, matrix; var keys = []; - for (t = node.startTime; t < node.endTime; t += frameDuration) { - matrix = calcMatrixAt(node, t); + + for ( t = node.startTime; t < node.endTime; t += frameDuration ) { + + matrix = calcMatrixAt( node, t ); + //keys.push({time: t, mat: matrix.flatten()}) + keys.push({ time: t, pos: [matrix.n14, matrix.n24, matrix.n34], rotq: [0, 0, 0, 1], scl: [1,1,1] }); + } + node.keys = keys; + } - } - + + }; + function _Image() { + this.id = ""; this.init_from = ""; - } + + }; + _Image.prototype.parse = function(element) { + this.id = element.getAttribute('id'); - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeName == 'init_from') { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + + if ( child.nodeName == 'init_from' ) { + this.init_from = child.textContent; + } + } + return this; - } - + + }; + function Controller() { + this.id = ""; this.name = ""; this.type = ""; this.skin = null; this.morph = null; - } - Controller.prototype.parse = function(element) { + + }; + + Controller.prototype.parse = function( element ) { + this.id = element.getAttribute('id'); this.name = element.getAttribute('name'); this.type = "none"; - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i++ ) { + + var child = element.childNodes[ i ]; + + switch ( child.nodeName ) { + case 'skin': this.skin = (new Skin()).parse(child); this.type = child.nodeName; break; + case 'morph': this.morph = (new Morph()).parse(child); this.type = child.nodeName; break; + default: break; + } } + return this; - } + + }; + function Morph() { + this.method; this.source; this.targets; this.weights; - } - Morph.prototype.parse = function(element) { + + }; + + Morph.prototype.parse = function( element ) { + var sources = {}; var inputs = []; var i; - this.method = element.getAttribute('method'); - this.source = element.getAttribute('source').replace(/^#/, ''); - for (i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + this.method = element.getAttribute( 'method' ); + this.source = element.getAttribute( 'source' ).replace( /^#/, '' ); + + for ( i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'source': - var source = (new Source()).parse(child); - sources[source.id] = source; + + var source = ( new Source() ).parse( child ); + sources[ source.id ] = source; break; + case 'targets': - inputs = this.parseInputs(child); + + inputs = this.parseInputs( child ); break; + default: - console.log(child.nodeName); + + console.log( child.nodeName ); break; + } + } - for (i = 0; i < inputs.length; i++) { - var input = inputs[i]; - var source = sources[input.source]; - switch (input.semantic) { + + for ( i = 0; i < inputs.length; i ++ ) { + + var input = inputs[ i ]; + var source = sources[ input.source ]; + + switch ( input.semantic ) { + case 'MORPH_TARGET': + this.targets = source.read(); break; + case 'MORPH_WEIGHT': + this.weights = source.read(); break; + default: break; + } } + return this; - } + + }; + Morph.prototype.parseInputs = function(element) { + var inputs = []; - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + if ( child.nodeType != 1) continue; + + switch ( child.nodeName ) { + case 'input': - inputs.push((new Input()).parse(child)); + + inputs.push( (new Input()).parse(child) ); break; + default: break; } } + return inputs; - } - + + }; + function Skin() { + this.source = ""; this.bindShapeMatrix = null; this.invBindMatrices = []; this.joints = []; this.weights = []; - } - Skin.prototype.parse = function(element) { + + }; + + Skin.prototype.parse = function( element ) { + var sources = {}; var joints, weights; - this.source = element.getAttribute('source').replace(/^#/, ''); + + this.source = element.getAttribute( 'source' ).replace( /^#/, '' ); this.invBindMatrices = []; this.joints = []; this.weights = []; - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'bind_shape_matrix': + var f = _floats(child.textContent); this.bindShapeMatrix = new THREE.Matrix4(); this.bindShapeMatrix.set( @@ -718,137 +1056,232 @@ var ColladaLoader = function() { f[12], f[13], f[14], f[15] ); break; + case 'source': + var src = new Source().parse(child); - sources[src.id] = src; + sources[ src.id ] = src; break; + case 'joints': + joints = child; break; + case 'vertex_weights': + weights = child; break; + default: - console.log(child.nodeName); + + console.log( child.nodeName ); break; + } } - this.parseJoints(joints, sources); - this.parseWeights(weights, sources); + + this.parseJoints( joints, sources ); + this.parseWeights( weights, sources ); + return this; - } - Skin.prototype.parseJoints = function(element, sources) { - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + }; + + Skin.prototype.parseJoints = function ( element, sources ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'input': - var input = (new Input()).parse(child); - var source = sources[input.source]; - if (input.semantic == 'JOINT') { + + var input = ( new Input() ).parse( child ); + var source = sources[ input.source ]; + + if ( input.semantic == 'JOINT' ) { + this.joints = source.read(); - } else if (input.semantic == 'INV_BIND_MATRIX') { + + } else if ( input.semantic == 'INV_BIND_MATRIX' ) { + this.invBindMatrices = source.read(); + } + break; + default: break; } + } - } - Skin.prototype.parseWeights = function(element, sources) { + + }; + + Skin.prototype.parseWeights = function ( element, sources ) { + var v, vcount, inputs = []; - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'input': + inputs.push((new Input()).parse(child)); break; + case 'v': + v = _ints(child.textContent); break; + case 'vcount': + vcount = _ints(child.textContent); break; + default: break; + } + } + var index = 0; - for (var i = 0; i < vcount.length; i++) { + + for ( var i = 0; i < vcount.length; i ++ ) { + var numBones = vcount[i]; var vertex_weights = []; - for (var j = 0; j < numBones; j++) { + + for ( var j = 0; j < numBones; j++ ) { + var influence = {}; - for (var k = 0; k < inputs.length; k++) { - var input = inputs[k]; - var value = v[index + input.offset]; - switch (input.semantic) { + + for ( var k = 0; k < inputs.length; k ++ ) { + + var input = inputs[ k ]; + var value = v[ index + input.offset ]; + + switch ( input.semantic ) { + case 'JOINT': + influence.joint = value;//this.joints[value]; break; + case 'WEIGHT': - influence.weight = sources[input.source].data[value]; + + influence.weight = sources[ input.source ].data[ value ]; break; + default: break; + } + } - vertex_weights.push(influence); + + vertex_weights.push( influence ); index += inputs.length; } - for (var j = 0; j < vertex_weights.length; j++) { - vertex_weights[j].index = i; + + for ( var j = 0; j < vertex_weights.length; j ++ ) { + + vertex_weights[ j ].index = i; + } - this.weights.push(vertex_weights); + + this.weights.push( vertex_weights ); + } - } - - function VisualScene() { + + }; + + function VisualScene () { + this.id = ""; this.name = ""; this.nodes = []; this.scene = new THREE.Object3D(); - } - VisualScene.prototype.getChildById = function(id, recursive) { - for (var i = 0; i < this.nodes.length; i++) { - var node = this.nodes[i].getChildById(id, recursive); - if (node) { + + }; + + VisualScene.prototype.getChildById = function( id, recursive ) { + + for ( var i = 0; i < this.nodes.length; i ++ ) { + + var node = this.nodes[ i ].getChildById( id, recursive ); + + if ( node ) { + return node; + } + } + return null; - } - VisualScene.prototype.getChildBySid = function(sid, recursive) { - for (var i = 0; i < this.nodes.length; i++) { - var node = this.nodes[i].getChildBySid(sid, recursive); - if (node) { + + }; + + VisualScene.prototype.getChildBySid = function( sid, recursive ) { + + for ( var i = 0; i < this.nodes.length; i ++ ) { + + var node = this.nodes[ i ].getChildBySid( sid, recursive ); + + if ( node ) { + return node; + } + } + return null; - } - VisualScene.prototype.parse = function(element) { - this.id = element.getAttribute('id'); - this.name = element.getAttribute('name'); + + }; + + VisualScene.prototype.parse = function( element ) { + + this.id = element.getAttribute( 'id' ); + this.name = element.getAttribute( 'name' ); this.nodes = []; - - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'node': - this.nodes.push((new Node()).parse(child)); + + this.nodes.push( ( new Node() ).parse( child ) ); break; + default: break; + } + } + return this; - } - + + }; + function Node() { + this.id = ""; this.name = ""; this.sid = ""; @@ -858,9 +1291,13 @@ var ColladaLoader = function() { this.geometries = []; this.channels = []; this.matrix = new THREE.Matrix4(); - } - Node.prototype.getChannelForTransform = function(transformSid) { - for (var i = 0; i < this.channels.length; i++) { + + }; + + Node.prototype.getChannelForTransform = function( transformSid ) { + + for ( var i = 0; i < this.channels.length; i ++ ) { + var channel = this.channels[i]; var parts = channel.target.split('/'); var id = parts.shift(); @@ -869,144 +1306,238 @@ var ColladaLoader = function() { var arrSyntax = (sid.indexOf("(") >= 0); var arrIndices; var member; - - if (dotSyntax) { + + if ( dotSyntax ) { + parts = sid.split("."); sid = parts.shift(); member = parts.shift(); - } else if (arrSyntax) { + + } else if ( arrSyntax ) { + arrIndices = sid.split("("); sid = arrIndices.shift(); - for (var j = 0; j < arrIndices.length; j++) { - arrIndices[j] = parseInt(arrIndices[j].replace(/\)/, '')); + + for ( var j = 0; j < arrIndices.length; j ++ ) { + + arrIndices[ j ] = parseInt( arrIndices[ j ].replace( /\)/, '' ) ); + } + } + if (sid == transformSid) { + channel.info = {sid:sid, dotSyntax:dotSyntax, arrSyntax:arrSyntax, arrIndices:arrIndices}; return channel; + } + } + return null; - } - Node.prototype.getChildById = function(id, recursive) { - if (this.id == id) { + + }; + + Node.prototype.getChildById = function ( id, recursive ) { + + if ( this.id == id ) { + return this; + } - if (recursive) { - for (var i = 0; i < this.nodes.length; i++) { - var n = this.nodes[i].getChildById(id, recursive); - if (n) { + + if ( recursive ) { + + for ( var i = 0; i < this.nodes.length; i ++ ) { + + var n = this.nodes[ i ].getChildById( id, recursive ); + + if ( n ) { + return n; } + } + } + return null; - } - Node.prototype.getChildBySid = function(sid, recursive) { - if (this.sid == sid) { + + }; + + Node.prototype.getChildBySid = function ( sid, recursive ) { + + if ( this.sid == sid ) { + return this; + } - if (recursive) { - for (var i = 0; i < this.nodes.length; i++) { - var n = this.nodes[i].getChildBySid(sid, recursive); - if (n) { + + if ( recursive ) { + + for ( var i = 0; i < this.nodes.length; i ++ ) { + + var n = this.nodes[ i ].getChildBySid( sid, recursive ); + + if ( n ) { + return n; } + } } + return null; - } - Node.prototype.getTransformBySid = function(sid) { - for (var i = 0; i < this.transforms.length; i++) { - if (this.transforms[i].sid == sid) return this.transforms[i]; + + }; + + Node.prototype.getTransformBySid = function ( sid ) { + + for ( var i = 0; i < this.transforms.length; i ++ ) { + + if ( this.transforms[ i ].sid == sid ) return this.transforms[ i ]; + } + return null; - } - Node.prototype.parse = function(element) { + + }; + + Node.prototype.parse = function( element ) { + var url; - + this.id = element.getAttribute('id'); this.sid = element.getAttribute('sid'); this.name = element.getAttribute('name'); this.type = element.getAttribute('type'); + this.type = this.type == 'JOINT' ? this.type : 'NODE'; + this.nodes = []; this.transforms = []; this.geometries = []; this.controllers = []; this.matrix = new THREE.Matrix4(); - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; if (child.nodeType != 1) continue; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'node': - this.nodes.push((new Node()).parse(child)); + + this.nodes.push( ( new Node() ).parse( child ) ); break; + case 'instance_camera': + break; + case 'instance_controller': - this.controllers.push((new InstanceController()).parse(child)); + + this.controllers.push( ( new InstanceController() ).parse( child ) ); break; + case 'instance_geometry': - this.geometries.push((new InstanceGeometry()).parse(child)); + + this.geometries.push( ( new InstanceGeometry() ).parse( child ) ); break; + case 'instance_light': + break; + case 'instance_node': - url = child.getAttribute('url').replace(/^#/, ''); - var iNode = getLibraryNode(url); - if (iNode) { - this.nodes.push((new Node()).parse(iNode)); + + url = child.getAttribute( 'url' ).replace( /^#/, '' ); + var iNode = getLibraryNode( url ); + + if ( iNode ) { + + this.nodes.push( ( new Node() ).parse( iNode )) ; + } + break; + case 'rotate': case 'translate': case 'scale': case 'matrix': case 'lookat': case 'skew': - this.transforms.push((new Transform()).parse(child)); + + this.transforms.push( ( new Transform() ).parse( child ) ); break; + case 'extra': break; + default: - console.log(child.nodeName); + + console.log( child.nodeName ); break; + } + } - this.channels = getChannelsForNode(this); - bakeAnimations(this); + + this.channels = getChannelsForNode( this ); + bakeAnimations( this ); + this.updateMatrix(); - + return this; - } - Node.prototype.updateMatrix = function() { + + }; + + Node.prototype.updateMatrix = function () { + this.matrix.identity(); - for (var i = 0; i < this.transforms.length; i++) { - this.matrix.multiply(this.matrix, this.transforms[i].matrix); + + for ( var i = 0; i < this.transforms.length; i ++ ) { + + this.matrix.multiply( this.matrix, this.transforms[ i ].matrix ); + } - } - function Transform() { + + }; + + function Transform () { + this.sid = ""; this.type = ""; this.data = []; this.matrix = new THREE.Matrix4(); - } - Transform.prototype.parse = function(element) { - this.sid = element.getAttribute('sid'); + + }; + + Transform.prototype.parse = function ( element ) { + + this.sid = element.getAttribute( 'sid' ); this.type = element.nodeName; - this.data = _floats(element.textContent); + this.data = _floats( element.textContent ); + this.updateMatrix(); + return this; - } - Transform.prototype.updateMatrix = function() { + + }; + + Transform.prototype.updateMatrix = function () { + var angle = 0; - + this.matrix.identity(); - - switch (this.type) { + + switch ( this.type ) { + case 'matrix': + this.matrix.set( this.data[0], this.data[1], this.data[2], this.data[3], this.data[4], this.data[5], this.data[6], this.data[7], @@ -1014,399 +1545,638 @@ var ColladaLoader = function() { this.data[12], this.data[13], this.data[14], this.data[15] ); break; + case 'translate': + this.matrix.setTranslation(this.data[0], this.data[1], this.data[2]); break; + case 'rotate': + angle = this.data[3] * (Math.PI / 180.0); this.matrix.setRotationAxis(new THREE.Vector3(this.data[0], this.data[1], this.data[2]), angle); break; + case 'scale': + this.matrix.setScale(this.data[0], this.data[1], this.data[2]); break; + default: break; + } + return this.matrix; - } + + }; function InstanceController() { + this.url = ""; this.skeleton = []; this.instance_material = []; - } - InstanceController.prototype.parse = function(element) { + + }; + + InstanceController.prototype.parse = function ( element ) { + this.url = element.getAttribute('url').replace(/^#/, ''); this.skeleton = []; this.instance_material = []; - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; - - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'skeleton': - this.skeleton.push(child.textContent.replace(/^#/, '')); + + this.skeleton.push( child.textContent.replace(/^#/, '') ); break; + case 'bind_material': - var instances = COLLADA.evaluate(".//dae:instance_material", - child, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, - null); - if (instances) { + + var instances = COLLADA.evaluate(".//dae:instance_material", + child, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, + null); + + if ( instances ) { + var instance = instances.iterateNext(); - while (instance) { + + while ( instance ) { + this.instance_material.push((new InstanceMaterial()).parse(instance)); - instance = instances.iterateNext(); + instance = instances.iterateNext(); + } } + break; + case 'extra': break; + default: break; + } } + return this; - } - - function InstanceMaterial() { + + }; + + function InstanceMaterial () { + this.symbol = ""; this.target = ""; - } - InstanceMaterial.prototype.parse = function(element) { + + }; + + InstanceMaterial.prototype.parse = function ( element ) { + this.symbol = element.getAttribute('symbol'); this.target = element.getAttribute('target').replace(/^#/, ''); return this; - } - + + }; + function InstanceGeometry() { + this.url = ""; this.instance_material = []; - } - InstanceGeometry.prototype.parse = function(element) { + + }; + + InstanceGeometry.prototype.parse = function( element ) { + this.url = element.getAttribute('url').replace(/^#/, ''); this.instance_material = []; - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; - if (child.nodeName == 'bind_material') { - var instances = COLLADA.evaluate(".//dae:instance_material", - child, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, + + if ( child.nodeName == 'bind_material' ) { + + var instances = COLLADA.evaluate(".//dae:instance_material", + child, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); + if (instances) { + var instance = instances.iterateNext(); - while (instance) { - this.instance_material.push((new InstanceMaterial()).parse(instance)); - instance = instances.iterateNext(); + + while ( instance ) { + + this.instance_material.push( (new InstanceMaterial()).parse(instance) ); + instance = instances.iterateNext(); + } + } + break; + } + } + return this; - } - + + }; + function Geometry() { + this.id = ""; this.mesh = null; - } - Geometry.prototype.parse = function(element) { + + }; + + Geometry.prototype.parse = function ( element ) { + this.id = element.getAttribute('id'); - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'mesh': + this.mesh = (new Mesh(this)).parse(child); break; + default: break; } } + return this; - } - - function Mesh(geometry) { + + }; + + function Mesh( geometry ) { + this.geometry = geometry.id; this.primitives = []; this.vertices = null; this.geometry3js; - } - Mesh.prototype.parse = function(element) { + + }; + + Mesh.prototype.parse = function( element ) { + this.primitives = []; + var i, j; - for (i = 0; i < element.childNodes.length; i++) { + + for ( i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; + switch (child.nodeName) { + case 'source': + _source(child); break; + case 'vertices': + this.vertices = (new Vertices()).parse(child); break; + case 'triangles': + this.primitives.push((new Triangles().parse(child))); break; + case 'polygons': + console.warn('polygon holes not yet supported!'); + case 'polylist': + this.primitives.push((new Polylist().parse(child))); break; + default: break; + } - } - - var vertex_store = {}; - function get_vertex(v, index) { - var hash = _hash_vector3(v.position); - if (vertex_store[hash] === undefined) { - vertex_store[hash] = {v:v, index:index}; - } - return vertex_store[hash]; - } - - this.geometry3js = new THREE.Geometry(); - var vertexData = sources[this.vertices.input['POSITION'].source].data; - for (i = 0, j = 0; i < vertexData.length; i += 3, j++) { - var v = new THREE.Vertex(new THREE.Vector3(vertexData[i], vertexData[i+1], vertexData[i+2])); - get_vertex(v, j); - this.geometry3js.vertices.push(v); + } - for (i = 0; i < this.primitives.length; i++) { + var vertex_store = {}; + + function get_vertex ( v, index ) { + + var hash = _hash_vector3( v.position ); + + if ( vertex_store[ hash ] === undefined ) { + + vertex_store[ hash ] = { v:v, index:index }; + + } + + return vertex_store[ hash ]; + + } + + this.geometry3js = new THREE.Geometry(); + + var vertexData = sources[ this.vertices.input['POSITION'].source ].data; + + for ( i = 0, j = 0; i < vertexData.length; i += 3, j ++ ) { + + var v = new THREE.Vertex( new THREE.Vector3( vertexData[i], vertexData[i+1], vertexData[i+2] ) ); + get_vertex(v, j); + this.geometry3js.vertices.push(v); + + } + + for ( i = 0; i < this.primitives.length; i ++ ) { + primitive = this.primitives[i]; primitive.setVertices(this.vertices); - this.handlePrimitive(primitive, this.geometry3js, vertex_store); + this.handlePrimitive( primitive, this.geometry3js, vertex_store ); + } - + this.geometry3js.computeCentroids(); this.geometry3js.computeFaceNormals(); this.geometry3js.computeVertexNormals(); this.geometry3js.computeBoundingBox(); - + return this; - } - Mesh.prototype.handlePrimitive = function(primitive, geom, vertex_store) { + + }; + + Mesh.prototype.handlePrimitive = function( primitive, geom, vertex_store ) { + var i = 0, j, k, p = primitive.p, inputs = primitive.inputs; var input, index, idx32; var vcIndex = 0, vcount = 3; var texture_sets = []; - - for (j = 0; j < inputs.length; j++) { + + for ( j = 0; j < inputs.length; j ++ ) { + input = inputs[j]; - if (input.semantic == 'TEXCOORD') { + + if ( input.semantic == 'TEXCOORD' ) { + texture_sets.push(input.set); + } + } - - while (i < p.length) { + + while ( i < p.length ) { + var vs = []; var ns = []; var ts = {}; - if (primitive.vcount) { - vcount = primitive.vcount[vcIndex++]; + + if ( primitive.vcount ) { + + vcount = primitive.vcount[ vcIndex ++ ]; + } - for (j = 0; j < vcount; j++) { - for (k = 0; k < inputs.length; k++) { + + for ( j = 0; j < vcount; j ++ ) { + + for ( k = 0; k < inputs.length; k ++ ) { + input = inputs[k]; source = sources[input.source]; index = p[i + (j*inputs.length) + input.offset]; numParams = source.accessor.params.length; idx32 = index * numParams; + switch (input.semantic) { + case 'VERTEX': - var hash = _hash_vector3(geom.vertices[index].position); + + var hash = _hash_vector3( geom.vertices[index].position ); vs.push(vertex_store[hash].index); break; + case 'NORMAL': - ns.push(new THREE.Vector3(source.data[idx32+0], source.data[idx32+1], source.data[idx32+2])); + + ns.push( new THREE.Vector3( source.data[idx32+0], source.data[idx32+1], source.data[idx32+2] ) ); break; + case 'TEXCOORD': + if (ts[input.set] === undefined) ts[input.set] = []; - ts[input.set].push(new THREE.UV(source.data[idx32+0], source.data[idx32+1])); + ts[input.set].push( new THREE.UV( source.data[idx32+0], source.data[idx32+1] ) ); break; + default: break; + } + } + } - var face = new THREE.Face3(vs[0], vs[1], vs[2], [ns[0], ns[1], ns[2]]); + + var face = new THREE.Face3( vs[0], vs[1], vs[2], [ ns[0], ns[1], ns[2] ] ); var uv; + face.daeMaterial = primitive.material; - geom.faces.push(face); - for (k = 0; k < texture_sets.length; k++) { - uv = ts[texture_sets[k]]; - geom.faceVertexUvs[ k ].push( [uv[0], uv[1], uv[2]] ); + geom.faces.push( face ); + + for ( k = 0; k < texture_sets.length; k ++ ) { + + uv = ts[ texture_sets[ k ] ]; + geom.faceVertexUvs[ k ].push( [ uv[0], uv[1], uv[2] ] ); + } - if (vcount > 3) { - for (j = 2; j < vs.length -1; j++) { - face = new THREE.Face3(vs[0], vs[j], vs[j+1], [ns[0], ns[j], ns[j+1]]); + + if ( vcount > 3 ) { + + for ( j = 2; j < vs.length - 1; j ++ ) { + + face = new THREE.Face3( vs[0], vs[j], vs[j+1], [ns[0], ns[j], ns[j+1]] ); + face.daeMaterial = primitive.material; + geom.faces.push(face); - for (k = 0; k < texture_sets.length; k++) { - uv = ts[texture_sets[k]]; - geom.faceVertexUvs[ k ].push( [uv[0], uv[j], uv[j+1]] ); + + for ( k = 0; k < texture_sets.length; k ++ ) { + + uv = ts[ texture_sets[ k ] ]; + geom.faceVertexUvs[ k ].push( [ uv[0], uv[j], uv[j+1] ] ); + } + } + } - + i += inputs.length * vcount; + } - } - - function Polylist() { - } + + }; + + + function Polylist () { + }; + Polylist.prototype = new Triangles(); Polylist.prototype.constructor = Polylist; - - function Triangles(flip_uv) { + + function Triangles( flip_uv ) { + this.material = ""; this.count = 0; this.inputs = []; this.vcount; this.p = []; this.geometry = new THREE.Geometry(); - } - Triangles.prototype.setVertices = function(vertices) { - for (var i = 0; i < this.inputs.length; i++) { - if (this.inputs[i].source == vertices.id) { - this.inputs[i].source = vertices.input['POSITION'].source; + + }; + + Triangles.prototype.setVertices = function ( vertices ) { + + for ( var i = 0; i < this.inputs.length; i ++ ) { + + if ( this.inputs[ i ].source == vertices.id ) { + + this.inputs[ i ].source = vertices.input[ 'POSITION' ].source; + } + } - } + + }; + Triangles.prototype.parse = function(element) { + this.inputs = []; this.material = element.getAttribute('material'); this.count = _attr_as_int(element, 'count', 0); - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + + switch ( child.nodeName ) { + case 'input': + this.inputs.push((new Input()).parse(element.childNodes[i])); break; + case 'vcount': + this.vcount = _ints(child.textContent); break; + case 'p': + this.p = _ints(child.textContent); break; + default: break; + } + } + return this; - } - + + }; + function Accessor() { + this.source = ""; this.count = 0; this.stride = 0; this.params = []; - } - Accessor.prototype.parse = function(element) { + + }; + + Accessor.prototype.parse = function( element ) { + this.params = []; this.source = element.getAttribute('source'); this.count = _attr_as_int(element, 'count', 0); this.stride = _attr_as_int(element, 'stride', 0); - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; - if (child.nodeName == 'param') { + + if ( child.nodeName == 'param' ) { + var param = {}; param['name'] = child.getAttribute('name'); param['type'] = child.getAttribute('type'); this.params.push(param); + } + } + return this; - } - + + }; + function Vertices() { + this.input = {}; - } - Vertices.prototype.parse = function(element) { + + }; + + Vertices.prototype.parse = function ( element ) { + this.id = element.getAttribute('id'); - for (var i = 0; i < element.childNodes.length; i++) { - if (element.childNodes[i].nodeName == 'input') { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + if ( element.childNodes[i].nodeName == 'input' ) { + input = (new Input()).parse(element.childNodes[i]); this.input[input.semantic] = input; + } + } + return this; - } - - function Input() { + + }; + + function Input () { + this.semantic = ""; this.offset = 0; this.source = ""; this.set = 0; - } - Input.prototype.parse = function(element) { + + }; + + Input.prototype.parse = function ( element ) { + this.semantic = element.getAttribute('semantic'); this.source = element.getAttribute('source').replace(/^#/, ''); this.set = _attr_as_int(element, 'set', -1); this.offset = _attr_as_int(element, 'offset', 0); - if (this.semantic == 'TEXCOORD' && this.set < 0) { + + if ( this.semantic == 'TEXCOORD' && this.set < 0 ) { + this.set = 0; + } + return this; - } - - function Source(id) { + + }; + + function Source ( id ) { + this.id = id; this.type = null; - } - Source.prototype.parse = function(element) { - this.id = element.getAttribute('id'); - for (var i = 0; i < element.childNodes.length; i++) { + + }; + + Source.prototype.parse = function ( element ) { + + this.id = element.getAttribute( 'id' ); + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'bool_array': + this.data = _bools(child.textContent); this.type = child.nodeName; break; + case 'float_array': + this.data = _floats(child.textContent); this.type = child.nodeName; break; + case 'int_array': + this.data = _ints(child.textContent); this.type = child.nodeName; break; + case 'IDREF_array': case 'Name_array': + this.data = _strings(child.textContent); this.type = child.nodeName; break; + case 'technique_common': - for (var j = 0; j < child.childNodes.length; j++) { - if (child.childNodes[j].nodeName == 'accessor') { + + for ( var j = 0; j < child.childNodes.length; j ++ ) { + + if ( child.childNodes[j].nodeName == 'accessor' ) { + this.accessor = (new Accessor()).parse(child.childNodes[j]); break; + } } break; + default: //console.log(child.nodeName); break; + } + } + return this; - } - Source.prototype.read = function() { + + }; + + Source.prototype.read = function () { + var result = []; + //for (var i = 0; i < this.accessor.params.length; i++) { + var param = this.accessor.params[0]; + //console.log(param.name + " " + param.type); + switch (param.type) { + case 'IDREF': case 'Name': case 'float': + return this.data; + case 'float4x4': - for (var j = 0; j < this.data.length; j += 16) { + + for ( var j = 0; j < this.data.length; j += 16 ) { + var s = this.data.slice(j, j+16); var m = new THREE.Matrix4(); m.set( @@ -1417,188 +2187,303 @@ var ColladaLoader = function() { ); result.push(m); } + break; + default: + console.log('Dae::Source:read dont know how to read ' + param.type); break; + } + //} + return result; - } - function Material() { + + }; + + function Material () { + this.id = ""; this.name = ""; this.instance_effect = null; - } - Material.prototype.parse = function(element) { + + }; + + Material.prototype.parse = function ( element ) { + this.id = element.getAttribute('id'); this.name = element.getAttribute('name'); - for (var i = 0; i < element.childNodes.length; i++) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + if (element.childNodes[i].nodeName == 'instance_effect') { this.instance_effect = (new InstanceEffect()).parse(element.childNodes[i]); break; } + } + return this; - } - - function ColorOrTexture() { + + }; + + function ColorOrTexture () { + this.color = new THREE.Color(0); this.color.setRGB(Math.random(), Math.random(), Math.random()); this.color.a = 1.0; + this.texture = null; this.texcoord = null; - } - ColorOrTexture.prototype.isColor = function() { + + }; + + ColorOrTexture.prototype.isColor = function () { + return (this.texture == null); - } - ColorOrTexture.prototype.isTexture = function() { + + }; + + ColorOrTexture.prototype.isTexture = function () { + return (this.texture != null); - } - ColorOrTexture.prototype.parse = function(element) { - for (var i = 0; i < element.childNodes.length; i++) { + + }; + + ColorOrTexture.prototype.parse = function ( element ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'color': + var rgba = _floats(child.textContent); this.color = new THREE.Color(0); this.color.setRGB(rgba[0], rgba[1], rgba[2]); this.color.a = rgba[3]; break; + case 'texture': + this.texture = child.getAttribute('texture'); this.texcoord = child.getAttribute('texcoord'); break; + default: break; + } + } + return this; - } - - function Shader(type, effect) { + + }; + + function Shader ( type, effect ) { + this.type = type; this.effect = effect; this.material; - } - Shader.prototype.parse = function(element) { - for (var i = 0; i < element.childNodes.length; i++) { + + }; + + Shader.prototype.parse = function ( element ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; + switch (child.nodeName) { + case 'ambient': case 'emission': case 'diffuse': case 'specular': case 'transparent': + this[child.nodeName] = (new ColorOrTexture()).parse(child); break; + case 'shininess': case 'reflectivity': case 'transparency': + var f = evaluateXPath(child, ".//dae:float"); if (f.length > 0) this[child.nodeName] = parseFloat(f[0].textContent); break; + default: break; + } + } + this.create(); return this; - } + + }; + Shader.prototype.create = function() { + var props = {}; - var transparent = (this['transparency'] !== undefined && this['transparency'] < 1.0); - for (var prop in this) { - switch (prop) { + var transparent = ( this['transparency'] !== undefined && this['transparency'] < 1.0 ); + + for ( var prop in this ) { + + switch ( prop ) { + case 'ambient': case 'emission': case 'diffuse': case 'specular': + var cot = this[prop]; - if (cot instanceof ColorOrTexture) { - if (cot.isTexture()) { - if (this.effect.sampler && this.effect.surface) { + + if ( cot instanceof ColorOrTexture ) { + + if ( cot.isTexture() ) { + + if ( this.effect.sampler && this.effect.surface ) { + if (this.effect.sampler.source == this.effect.surface.sid) { + var image = images[this.effect.surface.init_from]; - if (image) { + + if ( image ) { + props['map'] = THREE.ImageUtils.loadTexture(baseUrl + image.init_from); props['map'].wrapS = THREE.RepeatWrapping; props['map'].wrapT = THREE.RepeatWrapping; props['map'].repeat.x = 1; props['map'].repeat.y = -1; + } } + } + } else { + if (prop == 'diffuse') { + props['color'] = cot.color.getHex(); - } else if (!transparent){ + + } else if (!transparent) { + props[prop] = cot.color.getHex(); + } + } + } + break; + case 'shininess': case 'reflectivity': + props[prop] = this[prop]; break; + case 'transparency': - if (transparent) { + + if ( transparent ) { + props['transparent'] = true; props['opacity'] = this[prop]; transparent = true; + } break; + default: break; + } + } - props['shading'] = preferredShading; - this.material = new THREE.MeshLambertMaterial(props); - - switch (this.type) { + props[ 'shading' ] = preferredShading; + this.material = new THREE.MeshLambertMaterial( props ); + + switch ( this.type ) { + case 'constant': case 'lambert': break; + case 'phong': case 'blinn': + default: - if (!transparent) { + + if ( !transparent ) { + // this.material = new THREE.MeshPhongMaterial(props); + } + break; + } + return this.material; - } - - function Surface(effect) { + + }; + + function Surface ( effect ) { + this.effect = effect; this.init_from; this.format; - } - Surface.prototype.parse = function(element) { - for (var i = 0; i < element.childNodes.length; i++) { + + }; + + Surface.prototype.parse = function ( element ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'init_from': + this.init_from = child.textContent; break; + case 'format': + this.format = child.textContent; break; + default: + console.log("unhandled Surface prop: " + child.nodeName); break; + } + } + return this; - } - function Sampler2D(effect) { + + }; + + function Sampler2D ( effect ) { + this.effect = effect; this.source; this.wrap_s; @@ -1606,172 +2491,282 @@ var ColladaLoader = function() { this.minfilter; this.magfilter; this.mipfilter; - } - Sampler2D.prototype.parse = function(element) { - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + }; + + Sampler2D.prototype.parse = function ( element ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName) { + case 'source': + this.source = child.textContent; break; + case 'minfilter': + this.minfilter = child.textContent; break; + case 'magfilter': + this.magfilter = child.textContent; break; + case 'mipfilter': + this.mipfilter = child.textContent; break; + case 'wrap_s': + this.wrap_s = child.textContent; break; + case 'wrap_t': + this.wrap_t = child.textContent; break; + default: + console.log("unhandled Sampler2D prop: " + child.nodeName); break; + } + } + return this; - } - - function Effect() { + + }; + + function Effect () { + this.id = ""; this.name = ""; this.shader = null; this.surface; this.sampler; - } - Effect.prototype.create = function() { - if (this.shader == null) { + + }; + + Effect.prototype.create = function () { + + if ( this.shader == null ) { + return null; + } - - } - Effect.prototype.parse = function(element) { - this.id = element.getAttribute('id'); - this.name = element.getAttribute('name'); + + }; + + Effect.prototype.parse = function ( element ) { + + this.id = element.getAttribute( 'id' ); + this.name = element.getAttribute( 'name' ); this.shader = null; - - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'profile_COMMON': - this.parseTechnique(this.parseProfileCOMMON(child)); + + this.parseTechnique( this.parseProfileCOMMON( child ) ); break; + default: break; + } + } + return this; - } - Effect.prototype.parseNewparam = function(element) { - var sid = element.getAttribute('sid'); - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + }; + + Effect.prototype.parseNewparam = function ( element ) { + + var sid = element.getAttribute( 'sid' ); + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'surface': - this.surface = (new Surface(this)).parse(child); + + this.surface = ( new Surface( this ) ).parse( child ); this.surface.sid = sid; break; + case 'sampler2D': - this.sampler = (new Sampler2D(this)).parse(child); + + this.sampler = ( new Sampler2D( this ) ).parse( child ); this.sampler.sid = sid; break; + case 'extra': + break; + default: - console.log(child.nodeName); + + console.log( child.nodeName ); break; + } + } - } - Effect.prototype.parseProfileCOMMON = function(element) { + + }; + + Effect.prototype.parseProfileCOMMON = function ( element ) { + var technique; - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'profile_COMMON': - this.parseProfileCOMMON(child); + + this.parseProfileCOMMON( child ); break; + case 'technique': + technique = child; break; + case 'newparam': - this.parseNewparam(child); + + this.parseNewparam( child ); break; + case 'extra': break; + default: - console.log(child.nodeName); + + console.log( child.nodeName ); break; + } + } + return technique; - } - Effect.prototype.parseTechnique= function(element) { - for (var i = 0; i < element.childNodes.length; i++) { + + }; + + Effect.prototype.parseTechnique= function ( element ) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + var child = element.childNodes[i]; if (child.nodeType != 1) continue; - switch (child.nodeName) { + + switch ( child.nodeName ) { + case 'lambert': case 'blinn': case 'phong': - this.shader = (new Shader(child.nodeName, this)).parse(child); + + this.shader = ( new Shader( child.nodeName, this ) ).parse( child ); break; + default: break; + } + } - } - - function InstanceEffect() { + + }; + + function InstanceEffect () { + this.url = ""; - } - InstanceEffect.prototype.parse = function(element) { - this.url = element.getAttribute('url').replace(/^#/, ''); + + }; + + InstanceEffect.prototype.parse = function ( element ) { + + this.url = element.getAttribute( 'url' ).replace( /^#/, '' ); return this; - } + + }; function Animation() { + this.id = ""; this.name = ""; this.source = {}; this.sampler = []; this.channel = []; - } - Animation.prototype.parse = function(element) { - this.id = element.getAttribute('id'); - this.name = element.getAttribute('name'); + + }; + + Animation.prototype.parse = function ( element ) { + + this.id = element.getAttribute( 'id' ); + this.name = element.getAttribute( 'name' ); this.source = {}; - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'source': - var src = (new Source()).parse(child); - this.source[src.id] = src; + + var src = ( new Source() ).parse( child ); + this.source[ src.id ] = src; break; + case 'sampler': - this.sampler.push((new Sampler(this)).parse(child)); + + this.sampler.push( ( new Sampler( this ) ).parse( child ) ); break; + case 'channel': - this.channel.push((new Channel(this)).parse(child)); + + this.channel.push( ( new Channel( this ) ).parse( child ) ); break; + default: break; - } - } - return this; - } - function Channel(animation) { + } + + } + + return this; + + }; + + function Channel( animation ) { + this.animation = animation; this.source = ""; this.target = ""; @@ -1780,38 +2775,56 @@ var ColladaLoader = function() { this.arrSyntax; this.arrIndices; this.member; - } - Channel.prototype.parse = function(element) { - this.source = element.getAttribute('source').replace(/^#/, ''); - this.target = element.getAttribute('target'); - - var parts = this.target.split('/'); + + }; + + Channel.prototype.parse = function ( element ) { + + this.source = element.getAttribute( 'source' ).replace( /^#/, '' ); + this.target = element.getAttribute( 'target' ); + + var parts = this.target.split( '/' ); + var id = parts.shift(); var sid = parts.shift(); - var dotSyntax = (sid.indexOf(".") >= 0); - var arrSyntax = (sid.indexOf("(") >= 0); + + var dotSyntax = ( sid.indexOf(".") >= 0 ); + var arrSyntax = ( sid.indexOf("(") >= 0 ); + var arrIndices; var member; - - if (dotSyntax) { + + if ( dotSyntax ) { + parts = sid.split("."); sid = parts.shift(); member = parts.shift(); - } else if (arrSyntax) { + + } else if ( arrSyntax ) { + arrIndices = sid.split("("); sid = arrIndices.shift(); - for (var j = 0; j < arrIndices.length; j++) { - arrIndices[j] = parseInt(arrIndices[j].replace(/\)/, '')); + + for (var j = 0; j < arrIndices.length; j ++ ) { + + arrIndices[j] = parseInt( arrIndices[j].replace(/\)/, '') ); + } + } + this.sid = sid; this.dotSyntax = dotSyntax; this.arrSyntax = arrSyntax; this.arrIndices = arrIndices; this.member = member; + return this; - } - function Sampler(animation) { + + }; + + function Sampler ( animation ) { + this.id = ""; this.animation = animation; this.inputs = []; @@ -1821,210 +2834,347 @@ var ColladaLoader = function() { this.startTime; this.endTime; this.duration = 0; - } - Sampler.prototype.parse = function(element) { - this.id = element.getAttribute('id'); + + }; + + Sampler.prototype.parse = function ( element ) { + + this.id = element.getAttribute( 'id' ); this.inputs = []; - for (var i = 0; i < element.childNodes.length; i++) { - var child = element.childNodes[i]; - if (child.nodeType != 1) continue; - switch (child.nodeName) { + + for ( var i = 0; i < element.childNodes.length; i ++ ) { + + var child = element.childNodes[ i ]; + if ( child.nodeType != 1 ) continue; + + switch ( child.nodeName ) { + case 'input': - this.inputs.push((new Input()).parse(child)); + + this.inputs.push( (new Input()).parse( child ) ); break; + default: break; + } + } + return this; - } - Sampler.prototype.create = function() { - for (var i = 0; i < this.inputs.length; i++) { - var input = this.inputs[i]; - var source = this.animation.source[input.source]; - switch (input.semantic) { + + }; + + Sampler.prototype.create = function () { + + for ( var i = 0; i < this.inputs.length; i ++ ) { + + var input = this.inputs[ i ]; + var source = this.animation.source[ input.source ]; + + switch ( input.semantic ) { + case 'INPUT': + this.input = source.read(); break; + case 'OUTPUT': + this.output = source.read(); break; + case 'INTERPOLATION': + this.interpolation = source.read(); break; + case 'IN_TANGENT': + break; + case 'OUT_TANGENT': + break; + default: + console.log(input.semantic); break; + } + } - + this.startTime = 0; this.endTime = 0; this.duration = 0; - if (this.input.length) { + + if ( this.input.length ) { + this.startTime = 100000000; this.endTime = -100000000; - for (var i = 0; i < this.input.length; i++) { - this.startTime = Math.min(this.startTime, this.input[i]); - this.endTime = Math.max(this.endTime, this.input[i]); + + for ( var i = 0; i < this.input.length; i ++ ) { + + this.startTime = Math.min( this.startTime, this.input[ i ] ); + this.endTime = Math.max( this.endTime, this.input[ i ] ); + } + this.duration = this.endTime - this.startTime; + } - } - - function _source(element) { - var id = element.getAttribute('id'); - if (sources[id] != undefined) { - return sources[id]; + + }; + + function _source ( element ) { + + var id = element.getAttribute( 'id' ); + + if ( sources[ id ] != undefined ) { + + return sources[ id ]; + } - sources[id] = (new Source(id)).parse(element); - return sources[id]; - } - - function _nsResolver (nsPrefix) { - if (nsPrefix == "dae") { + + sources[ id ] = ( new Source(id )).parse( element ); + return sources[ id ]; + + }; + + function _nsResolver ( nsPrefix ) { + + if ( nsPrefix == "dae" ) { + return "http://www.collada.org/2005/11/COLLADASchema"; } + return null; - } - + + }; + function _bools ( str ) { - var raw = _strings(str); + + var raw = _strings( str ); var data = []; - var i; - for (i = 0; i < raw.length; i++) { - data.push((raw[i] == 'true' || raw[i] == '1') ? true : false); + + for (var i = 0; i < raw.length; i ++ ) { + + data.push( (raw[i] == 'true' || raw[i] == '1') ? true : false ); } + return data; - } - + + }; + function _floats ( str ) { + var raw = _strings(str); var data = []; - var i; - for (i = 0; i < raw.length; i++) { - data.push( parseFloat(raw[i]) ); + + for ( var i = 0; i < raw.length; i ++ ) { + + data.push( parseFloat( raw[ i ] ) ); + } + return data; - } + + }; function _ints ( str ) { - var raw = _strings(str); + + var raw = _strings( str ); var data = []; - var i; - for (i = 0; i < raw.length; i++) { - data.push( parseInt(raw[i], 10) ); + + for ( var i = 0; i < raw.length; i ++ ) { + + data.push( parseInt( raw[ i ], 10 ) ); + } + return data; - } - + + }; + function _strings ( str ) { - return _trimString(str).split(/\s+/); - } + + return _trimString( str ).split( /\s+/ ); + + }; function _trimString ( str ) { - return str.replace(/^\s+/, "").replace(/\s+$/, ""); - } + + return str.replace( /^\s+/, "" ).replace( /\s+$/, "" ); + + }; function _attr_as_float ( element, name, defaultValue ) { - if ( element.hasAttribute(name) ) { - return parseFloat(element.getAttribute(name)); + + if ( element.hasAttribute( name ) ) { + + return parseFloat( element.getAttribute( name ) ); + } else { + return defaultValue; + } - } + + }; function _attr_as_int ( element, name, defaultValue ) { - if ( element.hasAttribute(name) ) { - return parseInt(element.getAttribute(name), 10); + + if ( element.hasAttribute( name ) ) { + + return parseInt( element.getAttribute( name ), 10) ; + } else { + return defaultValue; + } - } + + }; function _attr_as_string ( element, name, defaultValue ) { - if ( element.hasAttribute(name) ) { - return element.getAttribute(name); + + if ( element.hasAttribute( name ) ) { + + return element.getAttribute( name ); + } else { + return defaultValue; + } - } - - function _format_float(f, num) { - if (f === undefined) { + + }; + + function _format_float ( f, num ) { + + if ( f === undefined ) { + var s = '0.'; - while (s.length < num + 2) { + + while ( s.length < num + 2 ) { + s += '0'; + } + return s; + } - var parts = f.toString().split('.'); + num = num || 2; - parts[1] = parts.length > 1 ? parts[1].substr(0, num) : "0"; - while(parts[1].length < num) { - parts[1] += '0'; + + var parts = f.toString().split( '.' ); + parts[ 1 ] = parts.length > 1 ? parts[ 1 ].substr( 0, num ) : "0"; + + while( parts[ 1 ].length < num ) { + + parts[ 1 ] += '0'; + } - return parts.join('.'); - } - - function _hash_vertex(v, n, t0, t1, precision) { + + return parts.join( '.' ); + + }; + + function _hash_vertex ( v, n, t0, t1, precision ) { + precision = precision || 2; - var s = v instanceof THREE.Vertex ? _hash_vector3(v.position, precision) : _hash_vector3(v, precision); - if (n === undefined) { + + var s = v instanceof THREE.Vertex ? _hash_vector3( v.position, precision ) : _hash_vector3( v, precision ); + + if ( n === undefined ) { + s += '_0.00,0.00,0.00'; + } else { - s += '_' + _hash_vector3(n, precision); + + s += '_' + _hash_vector3( n, precision ); + } - if (t0 === undefined) { + + if ( t0 === undefined ) { + s += '_0.00,0.00'; + } else { - s += '_' + _hash_uv(t0, precision); + + s += '_' + _hash_uv( t0, precision ); + } - if (t1 === undefined) { + + if ( t1 === undefined ) { + s += '_0.00,0.00'; + } else { - s += '_' + _hash_uv(t1, precision); + + s += '_' + _hash_uv( t1, precision ); + } + return s; - } - - function _hash_uv(uv, num) { + + }; + + function _hash_uv ( uv, num ) { + var s = ''; - s += _format_float(uv.u, num) + ','; - s += _format_float(uv.v, num); + + s += _format_float( uv.u, num ) + ','; + s += _format_float( uv.v, num ); + return s; - } - - function _hash_vector3(vec, num) { + + }; + + function _hash_vector3 ( vec, num ) { + var s = ''; - s += _format_float(vec.x, num) + ','; - s += _format_float(vec.y, num) + ','; - s += _format_float(vec.z, num); + + s += _format_float( vec.x, num ) + ','; + s += _format_float( vec.y, num ) + ','; + s += _format_float( vec.z, num ); + return s; - } - - function evaluateXPath(node, query) { - var instances = COLLADA.evaluate(query, - node, - _nsResolver, - XPathResult.ORDERED_NODE_ITERATOR_TYPE, + + }; + + function evaluateXPath ( node, query ) { + + var instances = COLLADA.evaluate(query, + node, + _nsResolver, + XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); + var inst = instances.iterateNext(); var result = []; - while (inst) { - result.push(inst); + + while ( inst ) { + + result.push( inst ); inst = instances.iterateNext(); - } + + } + return result; - } + + }; + return { + load: load, setPreferredShading: setPreferredShading, applySkin: applySkin, geometries : geometries + }; + }; diff --git a/src/extras/loaders/JSONLoader.js b/src/extras/loaders/JSONLoader.js index 52abdb60..21edc6d0 100644 --- a/src/extras/loaders/JSONLoader.js +++ b/src/extras/loaders/JSONLoader.js @@ -405,4 +405,4 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path callback( geometry ); -} +}; diff --git a/src/extras/loaders/Loader.js b/src/extras/loaders/Loader.js index 888e3389..a0211b0b 100644 --- a/src/extras/loaders/Loader.js +++ b/src/extras/loaders/Loader.js @@ -55,7 +55,7 @@ THREE.Loader.prototype = { }, - extractUrlbase: function( url ) { + extractUrlbase: function ( url ) { var chunks = url.split( "/" ); chunks.pop(); @@ -63,11 +63,11 @@ THREE.Loader.prototype = { }, - init_materials: function( scope, materials, texture_path ) { + init_materials: function ( scope, materials, texture_path ) { scope.materials = []; - for ( var i = 0; i < materials.length; ++i ) { + for ( var i = 0; i < materials.length; ++ i ) { scope.materials[ i ] = [ THREE.Loader.prototype.createMaterial( materials[ i ], texture_path ) ]; @@ -75,7 +75,7 @@ THREE.Loader.prototype = { }, - hasNormals: function( scope ) { + hasNormals: function ( scope ) { var m, i, il = scope.materials.length; @@ -136,7 +136,7 @@ THREE.Loader.prototype = { } - function create_texture( where, name, sourceFile, repeat, offset, wrap ) { + function create_texture ( where, name, sourceFile, repeat, offset, wrap ) { var texture = document.createElement( 'canvas' ); @@ -174,7 +174,7 @@ THREE.Loader.prototype = { } - function rgb2hex( rgb ) { + function rgb2hex ( rgb ) { return ( rgb[ 0 ] * 255 << 16 ) + ( rgb[ 1 ] * 255 << 8 ) + rgb[ 2 ] * 255; @@ -367,7 +367,7 @@ THREE.Loader.prototype = { return material; }, - + constructor : THREE.Loader }; diff --git a/src/extras/loaders/UTF8Loader.js b/src/extras/loaders/UTF8Loader.js index d24e2cc9..18acabb4 100644 --- a/src/extras/loaders/UTF8Loader.js +++ b/src/extras/loaders/UTF8Loader.js @@ -21,297 +21,287 @@ THREE.UTF8Loader.prototype = new THREE.UTF8Loader(); THREE.UTF8Loader.prototype.constructor = THREE.UTF8Loader; -THREE.UTF8Loader.prototype = { +// Load UTF8 compressed models generated by objcompress +// - parameters +// - model (required) +// - callback (required) - // Load UTF8 compressed models generated by objcompress - // - parameters - // - model (required) - // - callback (required) +THREE.UTF8Loader.prototype.load = function( parameters ) { - load: function( parameters ) { + var xhr = new XMLHttpRequest(), + url = parameters.model, - var xhr = new XMLHttpRequest(), - url = parameters.model, + callback = parameters.callback, + callback_progress = null, - callback = parameters.callback, - callback_progress = null, + scale = parameters.scale !== undefined ? parameters.scale : 1, + offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0, + offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0, + offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0; - scale = parameters.scale !== undefined ? parameters.scale : 1, - offsetX = parameters.offsetX !== undefined ? parameters.offsetX : 0, - offsetY = parameters.offsetY !== undefined ? parameters.offsetY : 0, - offsetZ = parameters.offsetZ !== undefined ? parameters.offsetZ : 0; + var length = 0; - var length = 0; + xhr.onreadystatechange = function() { - xhr.onreadystatechange = function() { + if ( xhr.readyState == 4 ) { - if ( xhr.readyState == 4 ) { + if ( xhr.status == 200 || xhr.status == 0 ) { - if ( xhr.status == 200 || xhr.status == 0 ) { + THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ ); - THREE.UTF8Loader.prototype.createModel( xhr.responseText, callback, scale, offsetX, offsetY, offsetZ ); + } else { - } else { - - alert( "Couldn't load [" + url + "] [" + xhr.status + "]" ); - - } - - } else if ( xhr.readyState == 3 ) { - - if ( callback_progress ) { - - if ( length == 0 ) { - - length = xhr.getResponseHeader( "Content-Length" ); - - } - - callback_progress( { total: length, loaded: xhr.responseText.length } ); - - } - - } else if ( xhr.readyState == 2 ) { - - length = xhr.getResponseHeader( "Content-Length" ); + alert( "Couldn't load [" + url + "] [" + xhr.status + "]" ); } + } else if ( xhr.readyState == 3 ) { + + if ( callback_progress ) { + + if ( length == 0 ) { + + length = xhr.getResponseHeader( "Content-Length" ); + + } + + callback_progress( { total: length, loaded: xhr.responseText.length } ); + + } + + } else if ( xhr.readyState == 2 ) { + + length = xhr.getResponseHeader( "Content-Length" ); + } - xhr.open( "GET", url, true ); - xhr.send( null ); + } - }, + xhr.open( "GET", url, true ); + xhr.send( null ); - // UTF-8 decoder from webgl-loader - // http://code.google.com/p/webgl-loader/ +}; - // Copyright 2011 Google Inc. All Rights Reserved. - // - // Licensed under the Apache License, Version 2.0 (the "License"); you - // may not use this file except in compliance with the License. You - // may obtain a copy of the License at - // - // http://www.apache.org/licenses/LICENSE-2.0 - // - // Unless required by applicable law or agreed to in writing, software - // distributed under the License is distributed on an "AS IS" BASIS, - // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - // implied. See the License for the specific language governing - // permissions and limitations under the License. +// UTF-8 decoder from webgl-loader +// http://code.google.com/p/webgl-loader/ - decompressMesh: function ( str ) { +// Copyright 2011 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you +// may not use this file except in compliance with the License. You +// may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +// implied. See the License for the specific language governing +// permissions and limitations under the License. - var num_verts = str.charCodeAt( 0 ); +THREE.UTF8Loader.prototype.decompressMesh = function ( str ) { - if ( num_verts >= 0xE000 ) { + var num_verts = str.charCodeAt( 0 ); - num_verts -= 0x0800; + if ( num_verts >= 0xE000 ) { + + num_verts -= 0x0800; + + } + + num_verts ++; + + var attribs_out = new Float32Array( 8 * num_verts ); + + var offset = 1; + + for ( var i = 0; i < 8; i ++ ) { + + var prev_attrib = 0; + + for ( var j = 0; j < num_verts; ++ j ) { + + var code = str.charCodeAt( j + offset ); + + prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) ); + + attribs_out[ 8 * j + i ] = prev_attrib; } - num_verts ++; + offset += num_verts; - var attribs_out = new Float32Array( 8 * num_verts ); + } - var offset = 1; + var num_indices = str.length - offset; - for ( var i = 0; i < 8; i ++ ) { + var indices_out = new Uint16Array( num_indices ); - var prev_attrib = 0; + var index_high_water_mark = 0; - for ( var j = 0; j < num_verts; ++ j ) { + for ( var i = 0; i < num_indices; i ++ ) { - var code = str.charCodeAt( j + offset ); + var code = str.charCodeAt( i + offset ); - prev_attrib += ( code >> 1 ) ^ ( - ( code & 1 ) ); + indices_out[ i ] = index_high_water_mark - code; - attribs_out[ 8 * j + i ] = prev_attrib; + if ( code == 0 ) { - } - - offset += num_verts; + index_high_water_mark ++; } - var num_indices = str.length - offset; + } - var indices_out = new Uint16Array( num_indices ); + return [ attribs_out, indices_out ]; - var index_high_water_mark = 0; +}; - for ( var i = 0; i < num_indices; i ++ ) { +THREE.UTF8Loader.prototype.createModel = function ( data, callback, scale, offsetX, offsetY, offsetZ ) { - var code = str.charCodeAt( i + offset ); + var Model = function ( texture_path ) { - indices_out[ i ] = index_high_water_mark - code; + //var s = (new Date).getTime(); - if ( code == 0 ) { + var scope = this; - index_high_water_mark ++; + scope.materials = []; + + THREE.Geometry.call( this ); + + var buffers = THREE.UTF8Loader.prototype.decompressMesh( data ); + + var normals = [], + uvs = []; + + init_vertices( buffers[ 0 ], 8, 0 ); + init_uvs( buffers[ 0 ], 8, 3 ); + init_normals( buffers[ 0 ], 8, 5 ); + + init_faces( buffers[ 1 ] ); + + this.computeCentroids(); + this.computeFaceNormals(); + //this.computeTangents(); + + //var e = (new Date).getTime(); + + //console.log( "utf8 data parse time: " + (e-s) + " ms" ); + + function init_vertices( data, stride, offset ) { + + var i, x, y, z, + end = data.length; + + for( i = offset; i < end; i += stride ) { + + x = data[ i ]; + y = data[ i + 1 ]; + z = data[ i + 2 ]; + + // fix scale and offsets + + x = ( x / 16383 ) * scale; + y = ( y / 16383 ) * scale; + z = ( z / 16383 ) * scale; + + x += offsetX; + y += offsetY; + z += offsetZ; + + vertex( scope, x, y, z ); } + }; + + function init_normals( data, stride, offset ) { + + var i, x, y, z, + end = data.length; + + for( i = offset; i < end; i += stride ) { + + x = data[ i ]; + y = data[ i + 1 ]; + z = data[ i + 2 ]; + + // normalize to <-1,1> + + x = ( x - 512 ) / 511; + y = ( y - 512 ) / 511; + z = ( z - 512 ) / 511; + + normals.push( x, y, z ); + + } + + }; + + function init_uvs( data, stride, offset ) { + + var i, u, v, + end = data.length; + + for( i = offset; i < end; i += stride ) { + + u = data[ i ]; + v = data[ i + 1 ]; + + // normalize to <0,1> + + u /= 1023; + v /= 1023; + + uvs.push( u, v ); + + } + + }; + + function init_faces( indices ) { + + var i, + a, b, c, + u1, v1, u2, v2, u3, v3, + m, + end = indices.length; + + m = 0; // all faces defaulting to material 0 + + for( i = 0; i < end; i += 3 ) { + + a = indices[ i ]; + b = indices[ i + 1 ]; + c = indices[ i + 2 ]; + + f3n( scope, normals, a, b, c, m, a, b, c ); + + u1 = uvs[ a * 2 ]; + v1 = uvs[ a * 2 + 1 ]; + + u2 = uvs[ b * 2 ]; + v2 = uvs[ b * 2 + 1 ]; + + u3 = uvs[ c * 2 ]; + v3 = uvs[ c * 2 + 1 ]; + + uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 ); + + } + + } - return [ attribs_out, indices_out ]; + }; - }, - - createModel: function ( data, callback, scale, offsetX, offsetY, offsetZ ) { - - var Model = function ( texture_path ) { - - //var s = (new Date).getTime(); - - var scope = this; - - scope.materials = []; - - THREE.Geometry.call( this ); - - var buffers = THREE.UTF8Loader.prototype.decompressMesh( data ); - - var normals = [], - uvs = []; - - init_vertices( buffers[ 0 ], 8, 0 ); - init_uvs( buffers[ 0 ], 8, 3 ); - init_normals( buffers[ 0 ], 8, 5 ); - - init_faces( buffers[ 1 ] ); - - this.computeCentroids(); - this.computeFaceNormals(); - //this.computeTangents(); - - //var e = (new Date).getTime(); - - //console.log( "utf8 data parse time: " + (e-s) + " ms" ); - - function init_vertices( data, stride, offset ) { - - var i, x, y, z, - end = data.length; - - for( i = offset; i < end; i += stride ) { - - x = data[ i ]; - y = data[ i + 1 ]; - z = data[ i + 2 ]; - - // fix scale and offsets - - x = ( x / 16383 ) * scale; - y = ( y / 16383 ) * scale; - z = ( z / 16383 ) * scale; - - x += offsetX; - y += offsetY; - z += offsetZ; - - THREE.UTF8Loader.prototype.v( scope, x, y, z ); - - } - - } - - function init_normals( data, stride, offset ) { - - var i, x, y, z, - end = data.length; - - for( i = offset; i < end; i += stride ) { - - x = data[ i ]; - y = data[ i + 1 ]; - z = data[ i + 2 ]; - - // normalize to <-1,1> - - x = ( x - 512 ) / 511; - y = ( y - 512 ) / 511; - z = ( z - 512 ) / 511; - - normals.push( x, y, z ); - - } - - } - - function init_uvs( data, stride, offset ) { - - var i, u, v, - end = data.length; - - for( i = offset; i < end; i += stride ) { - - u = data[ i ]; - v = data[ i + 1 ]; - - // normalize to <0,1> - - u /= 1023; - v /= 1023; - - uvs.push( u, v ); - - } - - } - - function init_faces( indices ) { - - var i, - a, b, c, - u1, v1, u2, v2, u3, v3, - m, - end = indices.length; - - m = 0; // all faces defaulting to material 0 - - for( i = 0; i < end; i += 3 ) { - - a = indices[ i ]; - b = indices[ i + 1 ]; - c = indices[ i + 2 ]; - - THREE.UTF8Loader.prototype.f3n( scope, normals, a, b, c, m, a, b, c ); - - u1 = uvs[ a * 2 ]; - v1 = uvs[ a * 2 + 1 ]; - - u2 = uvs[ b * 2 ]; - v2 = uvs[ b * 2 + 1 ]; - - u3 = uvs[ c * 2 ]; - v3 = uvs[ c * 2 + 1 ]; - - THREE.UTF8Loader.prototype.uv3( scope.faceVertexUvs[ 0 ], u1, v1, u2, v2, u3, v3 ); - - } - - - } - - } - - Model.prototype = new THREE.Geometry(); - Model.prototype.constructor = Model; - - callback( new Model() ); - - }, - - - v: function( scope, x, y, z ) { + function vertex ( scope, x, y, z ) { scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); - }, + }; - f3n: function( scope, normals, a, b, c, mi, na, nb, nc ) { + function f3n ( scope, normals, a, b, c, mi, na, nb, nc ) { var material = scope.materials[ mi ], @@ -333,9 +323,9 @@ THREE.UTF8Loader.prototype = { scope.faces.push( new THREE.Face3( a, b, c, [ na, nb, nc ], null, material ) ); - }, + }; - uv3: function( where, u1, v1, u2, v2, u3, v3 ) { + function uv3 ( where, u1, v1, u2, v2, u3, v3 ) { var uv = []; uv.push( new THREE.UV( u1, v1 ) ); @@ -343,8 +333,12 @@ THREE.UTF8Loader.prototype = { uv.push( new THREE.UV( u3, v3 ) ); where.push( uv ); - }, + }; - constructor : THREE.UTF8Loader + + Model.prototype = new THREE.Geometry(); + Model.prototype.constructor = Model; + + callback( new Model() ); }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 5f58f17b..79cbfcef 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -290,7 +290,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.getContext = function() { + this.getContext = function () { return _gl;