From b406568dce1713e201fc0e55d4779ef538dbe11a Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Mon, 7 Nov 2011 02:34:38 +0100 Subject: [PATCH] Refactored SphereGeometry Now uses Face4 where posible. Adde phiStart, phiLenght, thetaStart and thetaLength as extra parameters (useful for doing google-earth-like stuff). --- build/Three.js | 350 ++++++++++++------------ build/custom/ThreeCanvas.js | 2 +- build/custom/ThreeDOM.js | 2 +- build/custom/ThreeExtras.js | 200 +++++++------- build/custom/ThreeSVG.js | 2 +- build/custom/ThreeWebGL.js | 2 +- src/extras/geometries/SphereGeometry.js | 119 ++++---- 7 files changed, 328 insertions(+), 349 deletions(-) diff --git a/build/Three.js b/build/Three.js index 80572f87..f23bee50 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,6 +1,6 @@ // Three.js r46dev - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Clock=function(a){this.autoStart=a!==void 0?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){this.elapsedTime+=this.getDelta();return this.elapsedTime}; -THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.0010*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this}; +THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var c=Date.now(),a=0.001*(c-this.oldTime);this.oldTime=c;this.elapsedTime+=a}return a};THREE.Color=function(a){a!==void 0&&this.setHex(a);return this}; THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;return this},setHSV:function(a,c,b){var d,g,e;if(b===0)this.r=this.g=this.b=0;else switch(d=Math.floor(a*6),g=a*6-d,a=b*(1-c),e=b*(1- c*g),c=b*(1-c*(1-g)),d){case 1:this.r=e;this.g=b;this.b=a;break;case 2:this.r=a;this.g=b;this.b=c;break;case 3:this.r=a;this.g=e;this.b=b;break;case 4:this.r=c;this.g=a;this.b=b;break;case 5:this.r=b;this.g=a;this.b=e;break;case 6:case 0:this.r=b,this.g=c,this.b=a}return this},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+ Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; @@ -28,7 +28,7 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,c= THREE.Matrix4=function(a,c,b,d,g,e,f,h,i,l,k,p,q,m,t,n){this.set(a!==void 0?a:1,c||0,b||0,d||0,g||0,e!==void 0?e:1,f||0,h||0,i||0,l||0,k!==void 0?k:1,p||0,q||0,m||0,t||0,n!==void 0?n:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,d,g,e,f,h,i,l,k,p,q,m,t,n){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=g;this.n22=e;this.n23=f;this.n24=h;this.n31=i;this.n32=l;this.n33=k;this.n34=p;this.n41=q;this.n42=m;this.n43=t;this.n44=n;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, c,b){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,c).normalize();if(e.length()===0)e.z=1;d.cross(b,e).normalize();d.length()===0&&(e.x+=1.0E-4,d.cross(b,e).normalize());g.cross(e,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=e.x;this.n21=d.y;this.n22=g.y;this.n23=e.y;this.n31=d.z;this.n32=g.z;this.n33=e.z;return this},multiply:function(a,c){var b=a.n11,d=a.n12,g=a.n13,e=a.n14,f=a.n21,h=a.n22,i=a.n23,l=a.n24,k=a.n31,p=a.n32,q=a.n33,m=a.n34,t=a.n41,n=a.n42,o=a.n43, -s=a.n44,u=c.n11,r=c.n12,z=c.n13,E=c.n14,G=c.n21,v=c.n22,w=c.n23,C=c.n24,F=c.n31,B=c.n32,L=c.n33,J=c.n34,W=c.n41,X=c.n42,T=c.n43,ea=c.n44;this.n11=b*u+d*G+g*F+e*W;this.n12=b*r+d*v+g*B+e*X;this.n13=b*z+d*w+g*L+e*T;this.n14=b*E+d*C+g*J+e*ea;this.n21=f*u+h*G+i*F+l*W;this.n22=f*r+h*v+i*B+l*X;this.n23=f*z+h*w+i*L+l*T;this.n24=f*E+h*C+i*J+l*ea;this.n31=k*u+p*G+q*F+m*W;this.n32=k*r+p*v+q*B+m*X;this.n33=k*z+p*w+q*L+m*T;this.n34=k*E+p*C+q*J+m*ea;this.n41=t*u+n*G+o*F+s*W;this.n42=t*r+n*v+o*B+s*X;this.n43=t* +s=a.n44,u=c.n11,r=c.n12,z=c.n13,E=c.n14,G=c.n21,v=c.n22,w=c.n23,C=c.n24,F=c.n31,B=c.n32,L=c.n33,J=c.n34,X=c.n41,Y=c.n42,T=c.n43,ea=c.n44;this.n11=b*u+d*G+g*F+e*X;this.n12=b*r+d*v+g*B+e*Y;this.n13=b*z+d*w+g*L+e*T;this.n14=b*E+d*C+g*J+e*ea;this.n21=f*u+h*G+i*F+l*X;this.n22=f*r+h*v+i*B+l*Y;this.n23=f*z+h*w+i*L+l*T;this.n24=f*E+h*C+i*J+l*ea;this.n31=k*u+p*G+q*F+m*X;this.n32=k*r+p*v+q*B+m*Y;this.n33=k*z+p*w+q*L+m*T;this.n34=k*E+p*C+q*J+m*ea;this.n41=t*u+n*G+o*F+s*X;this.n42=t*r+n*v+o*B+s*Y;this.n43=t* z+n*w+o*L+s*T;this.n44=t*E+n*C+o*J+s*ea;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);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 this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a; this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,g=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*g;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*g;a.z=(this.n31*c+this.n32*b+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,g=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*g;a.y=this.n21* c+this.n22*b+this.n23*d+this.n24*g;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*g;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*g;return a},rotateAxis:function(a){var c=a.x,b=a.y,d=a.z;a.x=c*this.n11+b*this.n12+d*this.n13;a.y=c*this.n21+b*this.n22+d*this.n23;a.z=c*this.n31+b*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32* @@ -60,20 +60,20 @@ k,p,q=[],m,t=[],n,o,s=[],u,r,z=[],E={objects:[],sprites:[],lights:[],elements:[] a.n23,a.n44+a.n24);F[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);F[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);F[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=F[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);w.multiply(b.projectionMatrix,b.matrixWorldInverse);w.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix); w.multiply(b.matrixWorld,b.projectionMatrixInverse);w.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(c,d){e=0;E.objects.length=0;E.sprites.length=0;E.lights.length=0;var f=function(b){if(b.visible!==!1){var c;if(c=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(c=b.frustumCulled===!1))a:{for(var d=b.matrixWorld, e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),h=0;h<6;h++)if(c=F[h].x*d.n14+F[h].y*d.n24+F[h].z*d.n34+F[h].w,c<=e){c=!1;break a}c=!0}c?(w.multiplyVector3(G.copy(b.position)),g=a(),g.object=b,g.z=G.z,E.objects.push(g)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(w.multiplyVector3(G.copy(b.position)),g=a(),g.object=b,g.z=G.z,E.sprites.push(g)):b instanceof THREE.Light&&E.lights.push(b);c=0;for(d=b.children.length;cf&&h.positionScreen.z0&&v.z<1))f=z[r]=z[r]||new THREE.RenderableParticle,r++,u=f,u.x=v.x/v.w,u.y=v.y/v.w,u.z=v.z,u.rotation=V.rotation.z,u.scale.x=V.scale.x*Math.abs(u.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),u.scale.y=V.scale.y*Math.abs(u.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),u.material=V.material,E.elements.push(u); +E.objects.sort(b);return E};this.projectScene=function(a,e,g){var f=e.near,F=e.far,G,x,I,O,M,j,P,ha,W,Q,K,fa,U,ia,pa,na;r=o=m=p=0;E.elements.length=0;e.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);w.multiply(e.projectionMatrix,e.matrixWorldInverse);this.computeFrustum(w);E=this.projectGraph(a,!1);a=0;for(G=E.objects.length;af&&h.positionScreen.z0&&v.z<1))f=z[r]=z[r]||new THREE.RenderableParticle,r++,u=f,u.x=v.x/v.w,u.y=v.y/v.w,u.z=v.z,u.rotation=W.rotation.z,u.scale.x=W.scale.x*Math.abs(u.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),u.scale.y=W.scale.y*Math.abs(u.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),u.material=W.material,E.elements.push(u); g&&E.elements.sort(b);return E}};THREE.Quaternion=function(a,c,b,d){this.set(a||0,c||0,b||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,d=a.y*c,g=a.z*c,a=Math.cos(d),d=Math.sin(d),c=Math.cos(-g),g=Math.sin(-g),e=Math.cos(b),b=Math.sin(b),f=a*c,h=d*g;this.w=f*e-h*b;this.x=f*b+h*e;this.y=d*c*e+a*g*b;this.z=a*g*e-d*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,d=Math.sin(b); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var c= this.x,b=this.y,d=this.z,g=this.w,e=a.x,f=a.y,h=a.z,a=a.w;this.x=c*a+g*e+b*h-d*f;this.y=b*a+g*f+d*e-c*h;this.z=d*a+g*h+c*f-b*e;this.w=g*a-c*e-b*f-d*h;return this},multiply:function(a,c){this.x=a.x*c.w+a.y*c.z-a.z*c.y+a.w*c.x;this.y=-a.x*c.z+a.y*c.w+a.z*c.x+a.w*c.y;this.z=a.x*c.y-a.y*c.x+a.z*c.w+a.w*c.z;this.w=-a.x*c.x-a.y*c.y-a.z*c.z+a.w*c.w;return this},multiplyVector3:function(a,c){c||(c=a);var b=a.x,d=a.y,g=a.z,e=this.x,f=this.y,h=this.z,i=this.w,l=i*b+f*g-h*d,k=i*d+h*b-e*g,p=i*g+e*d-f*b,b=-e* b-f*d-h*g;c.x=l*i+b*-e+k*-h-p*-f;c.y=k*i+b*-f+p*-e-l*-h;c.z=p*i+b*-h+l*-f-k*-e;return c}}; -THREE.Quaternion.slerp=function(a,c,b,d){var g=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;g<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,g=-g):b.copy(c);if(Math.abs(g)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var e=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.0010)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,c,b,d){var g=a.w*c.w+a.x*c.x+a.y*c.y+a.z*c.z;g<0?(b.w=-c.w,b.x=-c.x,b.y=-c.y,b.z=-c.z,g=-g):b.copy(c);if(Math.abs(g)>=1)return b.w=a.w,b.x=a.x,b.y=a.y,b.z=a.z,b;var e=Math.acos(g),g=Math.sqrt(1-g*g);if(Math.abs(g)<0.001)return b.w=0.5*(a.w+c.w),b.x=0.5*(a.x+c.x),b.y=0.5*(a.y+c.y),b.z=0.5*(a.z+c.z),b;c=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;b.w=a.w*c+b.w*d;b.x=a.x*c+b.x*d;b.y=a.y*c+b.y*d;b.z=a.z*c+b.z*d;return b};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,c,b,d,g,e){this.a=a;this.b=c;this.c=b;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,c,b,d,g,e,f){this.a=a;this.b=c;this.c=b;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,c){this.u=a||0;this.v=c||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; @@ -84,8 +84,8 @@ b,d,g,e,f,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(g=this.faces.length;d< Array(this.vertices.length);a=0;for(c=this.vertices.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +F[c].addSelf(L);F[d].addSelf(L)}var c,b,d,g,e,f,h,i,l,k,p,q,m,t,n,o,s,u,r,z,E,G,v,w,C=[],F=[],B=new THREE.Vector3,L=new THREE.Vector3,J=new THREE.Vector3,X=new THREE.Vector3,Y=new THREE.Vector3;c=0;for(b=this.vertices.length;c0){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,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,c=0,b=this.vertices.length;c0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+s+")"),n.fillRect(Math.floor(H.getX()), +p,q,m,t,n=k.getContext("2d"),o=new THREE.Color(0),s=0,u=1,r=0,z=null,E=null,G=null,v=null,w=null,C,F,B,L,J=new THREE.RenderableVertex,X=new THREE.RenderableVertex,Y,T,ea,ba,x,I,O,M,j,P,ha,W,Q=new THREE.Color,K=new THREE.Color,fa=new THREE.Color,U=new THREE.Color,ia=new THREE.Color,pa=[],na=[],ka,oa,la,ma,ya,ra,sa,xa,R,A,V=new THREE.Rectangle,H=new THREE.Rectangle,$=new THREE.Rectangle,ca=!1,aa=new THREE.Color,S=new THREE.Color,ga=new THREE.Color,Z=new THREE.Vector3,va,N,ua,ta,da,Fa,a=16;va=document.createElement("canvas"); +va.width=va.height=2;N=va.getContext("2d");N.fillStyle="rgba(0,0,0,1)";N.fillRect(0,0,2,2);ua=N.getImageData(0,0,2,2);ta=ua.data;da=document.createElement("canvas");da.width=da.height=a;Fa=da.getContext("2d");Fa.translate(-a/2,-a/2);Fa.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;q=b;m=Math.floor(p/2);t=Math.floor(q/2);k.width=p;k.height=q;V.set(-m,-t,m,t);H.set(-m,-t,m,t);u=1;r=0;w=v=G= +E=z=null};this.setClearColor=function(a,b){o.copy(a);s=b;H.set(-m,-t,m,t)};this.setClearColorHex=function(a,b){o.setHex(a);s=b;H.set(-m,-t,m,t)};this.clear=function(){n.setTransform(1,0,0,-1,m,t);H.isEmpty()||(H.minSelf(V),H.inflate(2),s<1&&n.clearRect(Math.floor(H.getX()),Math.floor(H.getY()),Math.floor(H.getWidth()),Math.floor(H.getHeight())),s>0&&(b(THREE.NormalBlending),c(1),g("rgba("+Math.floor(o.r*255)+","+Math.floor(o.g*255)+","+Math.floor(o.b*255)+","+s+")"),n.fillRect(Math.floor(H.getX()), Math.floor(H.getY()),Math.floor(H.getWidth()),Math.floor(H.getHeight()))),H.empty())};this.render=function(a,k){function q(a){var b,c,d,e;aa.setRGB(0,0,0);S.setRGB(0,0,0);ga.setRGB(0,0,0);b=0;for(c=a.length;b>1,da=k.height>> -1,f=e.scale.x*m,i=e.scale.y*t,j=f*l,h=i*da,$.set(a.x-j,a.y-h,a.x+j,a.y+h),Z.intersects($)&&(n.save(),n.translate(a.x,a.y),n.rotate(-e.rotation),n.scale(f,-i),n.translate(-l,-da),n.drawImage(k,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*m,h=e.scale.y*t,$.set(a.x-j,a.y-h,a.x+j,a.y+h),Z.intersects($)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-e.rotation),n.scale(j,h),f.program(n),n.restore()))}function s(a,e, -f,g){c(g.opacity);b(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(G!=a)n.lineWidth=G=a;a=g.linecap;if(v!=a)n.lineCap=v=a;a=g.linejoin;if(w!=a)n.lineJoin=w=a;d(g.color.getContextStyle());n.stroke();$.inflate(g.linewidth*2)}}function u(a,d,g,f,j,h,m,l){e.info.render.vertices+=3;e.info.render.faces++;c(l.opacity);b(l.blending);X=a.positionScreen.x;T=a.positionScreen.y; -ea=d.positionScreen.x;ba=d.positionScreen.y;x=g.positionScreen.x;I=g.positionScreen.y;Ea(X,T,ea,ba,x,I);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(ma=m.uvs[0],E(X,T,ea,ba,x,I,ma[f].u,ma[f].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,Y.copy(m.vertexNormalsWorld[f]),ya=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,ra=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5, -Y.copy(m.vertexNormalsWorld[j]),sa=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,xa=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5,Y.copy(m.vertexNormalsWorld[h]),R=(Y.x*a.n11+Y.y*a.n12+Y.z*a.n13)*0.5+0.5,A=-(Y.x*a.n21+Y.y*a.n22+Y.z*a.n23)*0.5+0.5,E(X,T,ea,ba,x,I,ya,ra,sa,xa,R,A,l.envMap)}else l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&&!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&(ma=m.uvs[0], -E(X,T,ea,ba,x,I,ma[f].u,ma[f].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,l.map)),b(THREE.SubtractiveBlending)),ca?!l.wireframe&&l.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(K.r=fa.r=U.r=aa.r,K.g=fa.g=U.g=aa.g,K.b=fa.b=U.b=aa.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],K),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],fa),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],U),K.r=Math.max(0,Math.min(l.color.r*K.r,1)),K.g=Math.max(0,Math.min(l.color.g*K.g,1)),K.b=Math.max(0,Math.min(l.color.b* -K.b,1)),fa.r=Math.max(0,Math.min(l.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(l.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(l.color.b*fa.b,1)),U.r=Math.max(0,Math.min(l.color.r*U.r,1)),U.g=Math.max(0,Math.min(l.color.g*U.g,1)),U.b=Math.max(0,Math.min(l.color.b*U.b,1)),ia.r=(fa.r+U.r)*0.5,ia.g=(fa.g+U.g)*0.5,ia.b=(fa.b+U.b)*0.5,la=Ga(K,fa,U,ia),Ca(X,T,ea,ba,x,I,0,0,1,0,0,1,la)):(Q.r=aa.r,Q.g=aa.g,Q.b=aa.b,p(i,m.centroidWorld,m.normalWorld,Q),Q.r=Math.max(0,Math.min(l.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(l.color.g* -Q.g,1)),Q.b=Math.max(0,Math.min(l.color.b*Q.b,1)),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(Q)):l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshDepthMaterial)ka=k.near,oa=k.far,K.r=K.g=K.b=1-Ba(a.positionScreen.z,ka,oa),fa.r=fa.g=fa.b=1-Ba(d.positionScreen.z,ka,oa),U.r=U.g=U.b=1-Ba(g.positionScreen.z,ka,oa),ia.r=(fa.r+U.r)*0.5,ia.g=(fa.g+U.g)*0.5,ia.b=(fa.b+U.b)*0.5,la=Ga(K,fa,U,ia), -Ca(X,T,ea,ba,x,I,0,0,1,0,0,1,la);else if(l instanceof THREE.MeshNormalMaterial)Q.r=Da(m.normalWorld.x),Q.g=Da(m.normalWorld.y),Q.b=Da(m.normalWorld.z),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(Q)}function r(a,d,g,f,h,l,m,n,da){e.info.render.vertices+=4;e.info.render.faces++;c(n.opacity);b(n.blending);if(n.map||n.envMap)u(a,d,f,0,1,3,m,n,da),u(h,g,l,1,2,3,m,n,da);else if(X=a.positionScreen.x,T=a.positionScreen.y,ea=d.positionScreen.x,ba=d.positionScreen.y,x=g.positionScreen.x, -I=g.positionScreen.y,O=f.positionScreen.x,M=f.positionScreen.y,j=h.positionScreen.x,P=h.positionScreen.y,ha=l.positionScreen.x,V=l.positionScreen.y,n instanceof THREE.MeshBasicMaterial)Ha(X,T,ea,ba,x,I,O,M),n.wireframe?z(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(n.color);else if(n instanceof THREE.MeshLambertMaterial)ca?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4?(K.r=fa.r=U.r=ia.r=aa.r,K.g=fa.g=U.g=ia.g=aa.g,K.b=fa.b=U.b=ia.b=aa.b,p(i, +f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),i<=0||(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):f instanceof THREE.PointLight&&(h=f.matrixWorld.getPosition(),i=c.dot(Z.sub(h,b).normalize()),i<=0||(i*=f.distance==0?1:1-Math.min(b.distanceTo(h)/f.distance,1),i!=0&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function o(a,e,f){c(f.opacity);b(f.blending);var j,h,i,k,l,da;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)k=f.map.image,l=k.width>>1,da=k.height>> +1,f=e.scale.x*m,i=e.scale.y*t,j=f*l,h=i*da,$.set(a.x-j,a.y-h,a.x+j,a.y+h),V.intersects($)&&(n.save(),n.translate(a.x,a.y),n.rotate(-e.rotation),n.scale(f,-i),n.translate(-l,-da),n.drawImage(k,0,0),n.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=e.scale.x*m,h=e.scale.y*t,$.set(a.x-j,a.y-h,a.x+j,a.y+h),V.intersects($)&&(d(f.color.getContextStyle()),g(f.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-e.rotation),n.scale(j,h),f.program(n),n.restore()))}function s(a,e, +g,f){c(f.opacity);b(f.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(G!=a)n.lineWidth=G=a;a=f.linecap;if(v!=a)n.lineCap=v=a;a=f.linejoin;if(w!=a)n.lineJoin=w=a;d(f.color.getContextStyle());n.stroke();$.inflate(f.linewidth*2)}}function u(a,d,f,g,j,h,m,l){e.info.render.vertices+=3;e.info.render.faces++;c(l.opacity);b(l.blending);Y=a.positionScreen.x;T=a.positionScreen.y; +ea=d.positionScreen.x;ba=d.positionScreen.y;x=f.positionScreen.x;I=f.positionScreen.y;Ea(Y,T,ea,ba,x,I);if(l instanceof THREE.MeshBasicMaterial)if(l.map)l.map.mapping instanceof THREE.UVMapping&&(ma=m.uvs[0],E(Y,T,ea,ba,x,I,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,l.map));else if(l.envMap){if(l.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,Z.copy(m.vertexNormalsWorld[g]),ya=(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)*0.5+0.5,ra=-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)*0.5+0.5, +Z.copy(m.vertexNormalsWorld[j]),sa=(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)*0.5+0.5,xa=-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)*0.5+0.5,Z.copy(m.vertexNormalsWorld[h]),R=(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)*0.5+0.5,A=-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)*0.5+0.5,E(Y,T,ea,ba,x,I,ya,ra,sa,xa,R,A,l.envMap)}else l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshLambertMaterial)l.map&&!l.wireframe&&(l.map.mapping instanceof THREE.UVMapping&&(ma=m.uvs[0], +E(Y,T,ea,ba,x,I,ma[g].u,ma[g].v,ma[j].u,ma[j].v,ma[h].u,ma[h].v,l.map)),b(THREE.SubtractiveBlending)),ca?!l.wireframe&&l.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==3?(K.r=fa.r=U.r=aa.r,K.g=fa.g=U.g=aa.g,K.b=fa.b=U.b=aa.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],K),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],fa),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],U),K.r=Math.max(0,Math.min(l.color.r*K.r,1)),K.g=Math.max(0,Math.min(l.color.g*K.g,1)),K.b=Math.max(0,Math.min(l.color.b* +K.b,1)),fa.r=Math.max(0,Math.min(l.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(l.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(l.color.b*fa.b,1)),U.r=Math.max(0,Math.min(l.color.r*U.r,1)),U.g=Math.max(0,Math.min(l.color.g*U.g,1)),U.b=Math.max(0,Math.min(l.color.b*U.b,1)),ia.r=(fa.r+U.r)*0.5,ia.g=(fa.g+U.g)*0.5,ia.b=(fa.b+U.b)*0.5,la=Ga(K,fa,U,ia),Ca(Y,T,ea,ba,x,I,0,0,1,0,0,1,la)):(Q.r=aa.r,Q.g=aa.g,Q.b=aa.b,p(i,m.centroidWorld,m.normalWorld,Q),Q.r=Math.max(0,Math.min(l.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(l.color.g* +Q.g,1)),Q.b=Math.max(0,Math.min(l.color.b*Q.b,1)),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(Q)):l.wireframe?z(l.color,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(l.color);else if(l instanceof THREE.MeshDepthMaterial)ka=k.near,oa=k.far,K.r=K.g=K.b=1-Ba(a.positionScreen.z,ka,oa),fa.r=fa.g=fa.b=1-Ba(d.positionScreen.z,ka,oa),U.r=U.g=U.b=1-Ba(f.positionScreen.z,ka,oa),ia.r=(fa.r+U.r)*0.5,ia.g=(fa.g+U.g)*0.5,ia.b=(fa.b+U.b)*0.5,la=Ga(K,fa,U,ia), +Ca(Y,T,ea,ba,x,I,0,0,1,0,0,1,la);else if(l instanceof THREE.MeshNormalMaterial)Q.r=Da(m.normalWorld.x),Q.g=Da(m.normalWorld.y),Q.b=Da(m.normalWorld.z),l.wireframe?z(Q,l.wireframeLinewidth,l.wireframeLinecap,l.wireframeLinejoin):za(Q)}function r(a,d,f,g,h,l,m,n,da){e.info.render.vertices+=4;e.info.render.faces++;c(n.opacity);b(n.blending);if(n.map||n.envMap)u(a,d,g,0,1,3,m,n,da),u(h,f,l,1,2,3,m,n,da);else if(Y=a.positionScreen.x,T=a.positionScreen.y,ea=d.positionScreen.x,ba=d.positionScreen.y,x=f.positionScreen.x, +I=f.positionScreen.y,O=g.positionScreen.x,M=g.positionScreen.y,j=h.positionScreen.x,P=h.positionScreen.y,ha=l.positionScreen.x,W=l.positionScreen.y,n instanceof THREE.MeshBasicMaterial)Ha(Y,T,ea,ba,x,I,O,M),n.wireframe?z(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(n.color);else if(n instanceof THREE.MeshLambertMaterial)ca?!n.wireframe&&n.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length==4?(K.r=fa.r=U.r=ia.r=aa.r,K.g=fa.g=U.g=ia.g=aa.g,K.b=fa.b=U.b=ia.b=aa.b,p(i, m.v1.positionWorld,m.vertexNormalsWorld[0],K),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],fa),p(i,m.v4.positionWorld,m.vertexNormalsWorld[3],U),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ia),K.r=Math.max(0,Math.min(n.color.r*K.r,1)),K.g=Math.max(0,Math.min(n.color.g*K.g,1)),K.b=Math.max(0,Math.min(n.color.b*K.b,1)),fa.r=Math.max(0,Math.min(n.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(n.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(n.color.b*fa.b,1)),U.r=Math.max(0,Math.min(n.color.r*U.r,1)),U.g= -Math.max(0,Math.min(n.color.g*U.g,1)),U.b=Math.max(0,Math.min(n.color.b*U.b,1)),ia.r=Math.max(0,Math.min(n.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(n.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(n.color.b*ia.b,1)),la=Ga(K,fa,U,ia),Ea(X,T,ea,ba,O,M),Ca(X,T,ea,ba,O,M,0,0,1,0,0,1,la),Ea(j,P,x,I,ha,V),Ca(j,P,x,I,ha,V,1,0,1,1,0,1,la)):(Q.r=aa.r,Q.g=aa.g,Q.b=aa.b,p(i,m.centroidWorld,m.normalWorld,Q),Q.r=Math.max(0,Math.min(n.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(n.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(n.color.b* -Q.b,1)),Ha(X,T,ea,ba,x,I,O,M),n.wireframe?z(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(Q)):(Ha(X,T,ea,ba,x,I,O,M),n.wireframe?z(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(n.color));else if(n instanceof THREE.MeshNormalMaterial)Q.r=Da(m.normalWorld.x),Q.g=Da(m.normalWorld.y),Q.b=Da(m.normalWorld.z),Ha(X,T,ea,ba,x,I,O,M),n.wireframe?z(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(Q);else if(n instanceof THREE.MeshDepthMaterial)ka= -k.near,oa=k.far,K.r=K.g=K.b=1-Ba(a.positionScreen.z,ka,oa),fa.r=fa.g=fa.b=1-Ba(d.positionScreen.z,ka,oa),U.r=U.g=U.b=1-Ba(f.positionScreen.z,ka,oa),ia.r=ia.g=ia.b=1-Ba(g.positionScreen.z,ka,oa),la=Ga(K,fa,U,ia),Ea(X,T,ea,ba,O,M),Ca(X,T,ea,ba,O,M,0,0,1,0,0,1,la),Ea(j,P,x,I,ha,V),Ca(j,P,x,I,ha,V,1,0,1,1,0,1,la)}function Ea(a,b,c,d,e,g){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(a,b);n.closePath()}function Ha(a,b,c,d,e,g,f,j){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e, -g);n.lineTo(f,j);n.lineTo(a,b);n.closePath()}function z(a,b,c,e){if(G!=b)n.lineWidth=G=b;if(v!=c)n.lineCap=v=c;if(w!=e)n.lineJoin=w=e;d(a.getContextStyle());n.stroke();$.inflate(b*2)}function za(a){g(a.getContextStyle());n.fill()}function E(a,b,c,d,e,f,j,h,i,m,l,k,da){if(da.image.width!=0){if(da.needsUpdate==!0||pa[da.id]==void 0){var p=da.wrapS==THREE.RepeatWrapping,q=da.wrapT==THREE.RepeatWrapping;pa[da.id]=n.createPattern(da.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");da.needsUpdate= -!1}g(pa[da.id]);var p=da.offset.x/da.repeat.x,q=da.offset.y/da.repeat.y,R=da.image.width*da.repeat.x,t=da.image.height*da.repeat.y,j=(j+p)*R,h=(h+q)*t,i=(i+p)*R,m=(m+q)*t,l=(l+p)*R,k=(k+q)*t;c-=a;d-=b;e-=a;f-=b;i-=j;m-=h;l-=j;k-=h;p=i*k-l*m;if(p==0){if(na[da.id]==void 0)b=document.createElement("canvas"),b.width=da.image.width,b.height=da.image.height,a=b.getContext("2d"),a.drawImage(da.image,0,0),na[da.id]=a.getImageData(0,0,da.image.width,da.image.height).data,delete b;b=na[da.id];j=(Math.floor(j)+ -Math.floor(h)*da.image.width)*4;Q.setRGB(b[j]/255,b[j+1]/255,b[j+2]/255);za(Q)}else p=1/p,da=(k*c-m*e)*p,m=(k*d-m*f)*p,c=(i*e-l*c)*p,d=(i*f-l*d)*p,a=a-da*j-c*h,j=b-m*j-d*h,n.save(),n.transform(da,m,c,d,a,j),n.fill(),n.restore()}}function Ca(a,b,c,d,e,g,f,j,h,i,m,l,k){var da,p;da=k.width-1;p=k.height-1;f*=da;j*=p;h*=da;i*=p;m*=da;l*=p;c-=a;d-=b;e-=a;g-=b;h-=f;i-=j;m-=f;l-=j;p=1/(h*l-m*i);da=(l*c-i*e)*p;i=(l*d-i*g)*p;c=(h*e-m*c)*p;d=(h*g-m*d)*p;a=a-da*f-c*j;b=b-i*f-d*j;n.save();n.transform(da,i,c,d, +Math.max(0,Math.min(n.color.g*U.g,1)),U.b=Math.max(0,Math.min(n.color.b*U.b,1)),ia.r=Math.max(0,Math.min(n.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(n.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(n.color.b*ia.b,1)),la=Ga(K,fa,U,ia),Ea(Y,T,ea,ba,O,M),Ca(Y,T,ea,ba,O,M,0,0,1,0,0,1,la),Ea(j,P,x,I,ha,W),Ca(j,P,x,I,ha,W,1,0,1,1,0,1,la)):(Q.r=aa.r,Q.g=aa.g,Q.b=aa.b,p(i,m.centroidWorld,m.normalWorld,Q),Q.r=Math.max(0,Math.min(n.color.r*Q.r,1)),Q.g=Math.max(0,Math.min(n.color.g*Q.g,1)),Q.b=Math.max(0,Math.min(n.color.b* +Q.b,1)),Ha(Y,T,ea,ba,x,I,O,M),n.wireframe?z(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(Q)):(Ha(Y,T,ea,ba,x,I,O,M),n.wireframe?z(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(n.color));else if(n instanceof THREE.MeshNormalMaterial)Q.r=Da(m.normalWorld.x),Q.g=Da(m.normalWorld.y),Q.b=Da(m.normalWorld.z),Ha(Y,T,ea,ba,x,I,O,M),n.wireframe?z(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):za(Q);else if(n instanceof THREE.MeshDepthMaterial)ka= +k.near,oa=k.far,K.r=K.g=K.b=1-Ba(a.positionScreen.z,ka,oa),fa.r=fa.g=fa.b=1-Ba(d.positionScreen.z,ka,oa),U.r=U.g=U.b=1-Ba(g.positionScreen.z,ka,oa),ia.r=ia.g=ia.b=1-Ba(f.positionScreen.z,ka,oa),la=Ga(K,fa,U,ia),Ea(Y,T,ea,ba,O,M),Ca(Y,T,ea,ba,O,M,0,0,1,0,0,1,la),Ea(j,P,x,I,ha,W),Ca(j,P,x,I,ha,W,1,0,1,1,0,1,la)}function Ea(a,b,c,d,e,f){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,f);n.lineTo(a,b);n.closePath()}function Ha(a,b,c,d,e,f,g,j){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e, +f);n.lineTo(g,j);n.lineTo(a,b);n.closePath()}function z(a,b,c,e){if(G!=b)n.lineWidth=G=b;if(v!=c)n.lineCap=v=c;if(w!=e)n.lineJoin=w=e;d(a.getContextStyle());n.stroke();$.inflate(b*2)}function za(a){g(a.getContextStyle());n.fill()}function E(a,b,c,d,e,f,j,h,i,m,l,k,da){if(da.image.width!=0){if(da.needsUpdate==!0||pa[da.id]==void 0){var p=da.wrapS==THREE.RepeatWrapping,q=da.wrapT==THREE.RepeatWrapping;pa[da.id]=n.createPattern(da.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");da.needsUpdate= +!1}g(pa[da.id]);var p=da.offset.x/da.repeat.x,q=da.offset.y/da.repeat.y,R=da.image.width*da.repeat.x,o=da.image.height*da.repeat.y,j=(j+p)*R,h=(h+q)*o,i=(i+p)*R,m=(m+q)*o,l=(l+p)*R,k=(k+q)*o;c-=a;d-=b;e-=a;f-=b;i-=j;m-=h;l-=j;k-=h;p=i*k-l*m;if(p==0){if(na[da.id]==void 0)b=document.createElement("canvas"),b.width=da.image.width,b.height=da.image.height,a=b.getContext("2d"),a.drawImage(da.image,0,0),na[da.id]=a.getImageData(0,0,da.image.width,da.image.height).data,delete b;b=na[da.id];j=(Math.floor(j)+ +Math.floor(h)*da.image.width)*4;Q.setRGB(b[j]/255,b[j+1]/255,b[j+2]/255);za(Q)}else p=1/p,da=(k*c-m*e)*p,m=(k*d-m*f)*p,c=(i*e-l*c)*p,d=(i*f-l*d)*p,a=a-da*j-c*h,j=b-m*j-d*h,n.save(),n.transform(da,m,c,d,a,j),n.fill(),n.restore()}}function Ca(a,b,c,d,e,f,g,j,h,i,m,l,k){var da,p;da=k.width-1;p=k.height-1;g*=da;j*=p;h*=da;i*=p;m*=da;l*=p;c-=a;d-=b;e-=a;f-=b;h-=g;i-=j;m-=g;l-=j;p=1/(h*l-m*i);da=(l*c-i*e)*p;i=(l*d-i*f)*p;c=(h*e-m*c)*p;d=(h*f-m*d)*p;a=a-da*g-c*j;b=b-i*g-d*j;n.save();n.transform(da,i,c,d, a,b);n.clip();n.drawImage(k,0,0);n.restore()}function Ga(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),h=~~(c.r*255),i=~~(c.g*255),c=~~(c.b*255),m=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ta[0]=e<0?0:e>255?255:e;ta[1]=f<0?0:f>255?255:f;ta[2]=a<0?0:a>255?255:a;ta[4]=g<0?0:g>255?255:g;ta[5]=j<0?0:j>255?255:j;ta[6]=b<0?0:b>255?255:b;ta[8]=h<0?0:h>255?255:h;ta[9]=i<0?0:i>255?255:i;ta[10]=c<0?0:c>255?255:c;ta[12]=m<0?0:m>255?255:m;ta[13]=l<0?0:l>255?255: l;ta[14]=d<0?0:d>255?255:d;N.putImageData(ua,0,0);Fa.drawImage(va,0,0);return da}function Ba(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Da(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Aa(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var Ia,Ja,qa,wa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,m,t);e.info.render.vertices=0;e.info.render.faces=0;f=l.projectScene(a,k,this.sortElements);h=f.elements;i=f.lights;(ca=i.length>0)&&q(i); -Ia=0;for(Ja=h.length;Ia1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,p,q,m,t,n,o,s=new THREE.Rectangle,u=new THREE.Rectangle,r=!1,z=new THREE.Color,E=new THREE.Color,G=new THREE.Color,v=new THREE.Color,w,C=new THREE.Vector3,F=[],B=[],L,J,W,X=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, -faces:0}};this.setQuality=function(a){switch(a){case "high":X=1;break;case "low":X=0}};this.setSize=function(a,b){l=a;k=b;p=l/2;q=k/2;i.setAttribute("viewBox",-p+" "+-q+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);s.set(-p,-q,p,q)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(l,k){var F,x,I,O;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(l,k,this.sortElements);e=g.elements; -f=g.lights;W=J=0;if(r=f.length>0){E.setRGB(0,0,0);G.setRGB(0,0,0);v.setRGB(0,0,0);F=0;for(x=f.length;F1?1:a}var d=this,g,e,f,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,p,q,m,t,n,o,s=new THREE.Rectangle,u=new THREE.Rectangle,r=!1,z=new THREE.Color,E=new THREE.Color,G=new THREE.Color,v=new THREE.Color,w,C=new THREE.Vector3,F=[],B=[],L,J,X,Y=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, +faces:0}};this.setQuality=function(a){switch(a){case "high":Y=1;break;case "low":Y=0}};this.setSize=function(a,b){l=a;k=b;p=l/2;q=k/2;i.setAttribute("viewBox",-p+" "+-q+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);s.set(-p,-q,p,q)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(l,k){var F,x,I,O;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;g=h.projectScene(l,k,this.sortElements);e=g.elements; +f=g.lights;X=J=0;if(r=f.length>0){E.setRGB(0,0,0);G.setRGB(0,0,0);v.setRGB(0,0,0);F=0;for(x=f.length;F=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,g,f,h=a.vertices;f=h.length;var i=a.colors,m=i.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,p=a.__dirtyVertices,q=a.__dirtyColors,R=a.__webglCustomAttributesList;if(c.sortParticles){Z.multiplySelf(c.matrixWorld);for(d=0;d=0)a&&(j.bindBuffer(j.ARRAY_BUFFER, -e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;g.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){f=0;var i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;fm&&(l=n,m=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[f]= -m;i[l]=1;m=-1;f++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){f=0;for(h=e.__webglCustomAttributesList.length;f=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color, +THREE.WebGLRenderer=function(a){function c(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(a.__webglCustomAttributesList===void 0)a.__webglCustomAttributesList=[];for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;f.type==="v2"?g=2:f.type==="v3"?g=3:f.type==="v4"?g=4:f.type==="c"&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=j.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}} +function b(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;else if(b.materialIndex>=0)return a.geometry.materials[b.materialIndex]}function d(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;var i=a.colors,m=i.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,p=a.__dirtyVertices,q=a.__dirtyColors,R=a.__webglCustomAttributesList;if(c.sortParticles){V.multiplySelf(c.matrixWorld);for(d=0;d=0)a&&(j.bindBuffer(j.ARRAY_BUFFER, +e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;f.morphTargetBase!==-1?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):c.position>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;gm&&(l=n,m=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]= +m;i[l]=1;m=-1;g++}}d.program.uniforms.morphTargetInfluences!==null&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList){g=0;for(h=e.__webglCustomAttributesList.length;g=0&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0))}b.color>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color, 3,j.FLOAT,!1,0,0));b.normal>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));b.tangent>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));b.uv>=0&&(e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));b.uv2>=0&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer), j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex, -4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ya&&(j.lineWidth(d),ya=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),M.info.render.calls++,M.info.render.vertices+= -e.__webglFaceCount,M.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ya&&(j.lineWidth(d),ya=d),j.drawArrays(g,0,e.__webglLineCount),M.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),M.info.render.calls++):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),M.info.render.calls++)}}function f(a){A[0].set(a.n41-a.n11,a.n42-a.n12,a.n43- +4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ya&&(j.lineWidth(d),ya=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),M.info.render.calls++,M.info.render.vertices+= +e.__webglFaceCount,M.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ya&&(j.lineWidth(d),ya=d),j.drawArrays(f,0,e.__webglLineCount),M.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),M.info.render.calls++):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),M.info.render.calls++)}}function f(a){A[0].set(a.n41-a.n11,a.n42-a.n12,a.n43- a.n13,a.n44-a.n14);A[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);A[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);A[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);A[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);A[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=A[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function h(a){for(var b=a.matrixWorld,c=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y, a.scale.z)),d=0;d<6;d++)if(a=A[d].x*b.n14+A[d].y*b.n24+A[d].z*b.n34+A[d].w,a<=c)return!1;return!0}function i(a,b){return b.z-a.z}function l(a){var b,c,d,i,m,l,n,k,p=0,q=a.lights;S||(S=new THREE.PerspectiveCamera(M.shadowCameraFov,M.shadowMapWidth/M.shadowMapHeight,M.shadowCameraNear,M.shadowCameraFar));b=0;for(c=q.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function o(a,b,c,d,e){d.program||M.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(M.maxMorphTargets); -for(var g=0,f=M.maxMorphTargets;g=0;c--)a[c].object===b&&a.splice(c,1)}function o(a,b,c,d,e){d.program||M.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(M.maxMorphTargets); +for(var f=0,g=M.maxMorphTargets;f0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return ta};this.setSize=function(a,b){W.width=a;W.height=b;this.setViewport(0,0,W.width,W.height)};this.setViewport=function(a,b,c,d){ra=a;sa=b;xa=c;R=d;j.viewport(ra,sa,xa,R)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)}; +j.getUniformLocation(N.program,"screenPosition");N.uniforms.modelViewMatrix=j.getUniformLocation(N.program,"modelViewMatrix");N.uniforms.projectionMatrix=j.getUniformLocation(N.program,"projectionMatrix")})();(function(){var a=THREE.ShaderLib.depthRGBA,b=THREE.UniformsUtils.clone(a.uniforms);Z=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b});va=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:b,morphTargets:!0}); +Z._shadowPass=!0;va._shadowPass=!0})();this.context=j;var ta=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;this.getContext=function(){return j};this.supportsVertexTextures=function(){return ta};this.setSize=function(a,b){X.width=a;X.height=b;this.setViewport(0,0,X.width,X.height)};this.setViewport=function(a,b,c,d){ra=a;sa=b;xa=c;R=d;j.viewport(ra,sa,xa,R)};this.setScissor=function(a,b,c,d){j.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)}; this.setClearColorHex=function(a,b){x.setHex(a);I=b;j.clearColor(x.r,x.g,x.b,I)};this.setClearColor=function(a,b){x.copy(a);I=b;j.clearColor(x.r,x.g,x.b,I)};this.getClearColor=function(){return x};this.getClearAlpha=function(){return I};this.clear=function(a,b,c){var d=0;if(a===void 0||a)d|=j.COLOR_BUFFER_BIT;if(b===void 0||b)d|=j.DEPTH_BUFFER_BIT;if(c===void 0||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=function(a,b,c,d){B(a);this.clear(b,c,d)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit= !1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer); j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d=0)F=A.geometry.materials[F], -F.transparent?(o.transparent=F,o.opaque=null):(o.opaque=F,o.transparent=null)}else if(F)F.transparent?(o.transparent=F,o.opaque=null):(o.opaque=F,o.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(ca.copy(m.position),Z.multiplyVector3(ca),g.z=ca.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(e=n.length;d=0)F=A.geometry.materials[F], +F.transparent?(t.transparent=F,t.opaque=null):(t.opaque=F,t.transparent=null)}else if(F)F.transparent?(t.transparent=F,t.opaque=null):(t.opaque=F,t.transparent=null);g.render=!0;if(this.sortObjects)m.renderDepth?g.z=m.renderDepth:(ca.copy(m.position),V.multiplyVector3(ca),g.z=ca.z)}this.sortObjects&&n.sort(i);n=a.__webglObjectsImmediate;d=0;for(e=n.length;d65535&&(s[A].counter+=1,Z=s[A].hash+"_"+s[A].counter,i.geometryGroups[Z]===void 0&&(i.geometryGroups[Z]={faces3:[],faces4:[],materialIndex:R,vertices:0,numMorphTargets:u})),p instanceof -THREE.Face3?i.geometryGroups[Z].faces3.push(k):i.geometryGroups[Z].faces4.push(k),i.geometryGroups[Z].vertices+=o;i.geometryGroupsList=[];k=void 0;for(k in i.geometryGroups)i.geometryGroups[k].id=fa++,i.geometryGroupsList.push(i.geometryGroups[k])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){k=i;k.__webglVertexBuffer=j.createBuffer();k.__webglNormalBuffer=j.createBuffer();k.__webglTangentBuffer=j.createBuffer();k.__webglColorBuffer=j.createBuffer();k.__webglUVBuffer= -j.createBuffer();k.__webglUV2Buffer=j.createBuffer();k.__webglSkinVertexABuffer=j.createBuffer();k.__webglSkinVertexBBuffer=j.createBuffer();k.__webglSkinIndicesBuffer=j.createBuffer();k.__webglSkinWeightsBuffer=j.createBuffer();k.__webglFaceBuffer=j.createBuffer();k.__webglLineBuffer=j.createBuffer();if(k.numMorphTargets){p=l=void 0;k.__webglMorphTargetsBuffers=[];l=0;for(p=k.numMorphTargets;l0||o.faceVertexUvs.length>0)i.__uvArray=new Float32Array(k*2);if(o.faceUvs.length>1||o.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(k*2)}if(R.geometry.skinWeights.length&&R.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(k*4),i.__skinVertexBArray=new Float32Array(k*4),i.__skinIndexArray=new Float32Array(k*4),i.__skinWeightArray=new Float32Array(k*4);i.__faceArray=new Uint16Array(p*3);i.__lineArray=new Uint16Array(A* -2);if(i.numMorphTargets){i.__morphTargetsArrays=[];R=0;for(o=i.numMorphTargets;R65535&&(V[A].counter+=1,s=V[A].hash+"_"+V[A].counter,i.geometryGroups[s]===void 0&&(i.geometryGroups[s]={faces3:[],faces4:[],materialIndex:R,vertices:0,numMorphTargets:u})),p instanceof +THREE.Face3?i.geometryGroups[s].faces3.push(l):i.geometryGroups[s].faces4.push(l),i.geometryGroups[s].vertices+=o;i.geometryGroupsList=[];l=void 0;for(l in i.geometryGroups)i.geometryGroups[l].id=fa++,i.geometryGroupsList.push(i.geometryGroups[l])}for(f in h.geometryGroups)if(i=h.geometryGroups[f],!i.__webglVertexBuffer){l=i;l.__webglVertexBuffer=j.createBuffer();l.__webglNormalBuffer=j.createBuffer();l.__webglTangentBuffer=j.createBuffer();l.__webglColorBuffer=j.createBuffer();l.__webglUVBuffer= +j.createBuffer();l.__webglUV2Buffer=j.createBuffer();l.__webglSkinVertexABuffer=j.createBuffer();l.__webglSkinVertexBBuffer=j.createBuffer();l.__webglSkinIndicesBuffer=j.createBuffer();l.__webglSkinWeightsBuffer=j.createBuffer();l.__webglFaceBuffer=j.createBuffer();l.__webglLineBuffer=j.createBuffer();if(l.numMorphTargets){p=k=void 0;l.__webglMorphTargetsBuffers=[];k=0;for(p=l.numMorphTargets;k0||o.faceVertexUvs.length>0)i.__uvArray=new Float32Array(l*2);if(o.faceUvs.length>1||o.faceVertexUvs.length>1)i.__uv2Array=new Float32Array(l*2)}if(R.geometry.skinWeights.length&&R.geometry.skinIndices.length)i.__skinVertexAArray=new Float32Array(l*4),i.__skinVertexBArray=new Float32Array(l*4),i.__skinIndexArray=new Float32Array(l*4),i.__skinWeightArray=new Float32Array(l*4);i.__faceArray=new Uint16Array(p*3);i.__lineArray=new Uint16Array(A* +2);if(i.numMorphTargets){i.__morphTargetsArrays=[];R=0;for(o=i.numMorphTargets;R=0;h--)g[h]===f&&g.splice(h,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&n(g.__webglObjectsImmediate,e);e.__webglActive=!1;a.__objectsRemoved.splice(0,1)}e=0;for(g=a.__webglObjects.length;e0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ca,p),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,N,p),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,J,p),j.bindBuffer(j.ARRAY_BUFFER,l.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER, -Y,p))}if(na&&G){o=0;for(A=s.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,$,p))}if(ta&&I.hasTangents){o=0;for(A=s.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER, -X,p))}if(va&&ma&&O){o=0;for(A=s.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,l.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,D,p))}if(ia){o=0;for(A=s.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,k.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ca,p),j.bindBuffer(j.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,N,p),j.bindBuffer(j.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,J,p),j.bindBuffer(j.ARRAY_BUFFER,k.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER, +Z,p))}if(na&&G){o=0;for(A=V.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,k.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,$,p))}if(ta&&I.hasTangents){o=0;for(A=V.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,k.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER, +Y,p))}if(va&&ma&&O){o=0;for(A=V.length;o0&&(j.bindBuffer(j.ARRAY_BUFFER,k.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,D,p))}if(ia){o=0;for(A=V.length;o=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); -o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(g in a.attributes)o[g]!==void 0&&o[g]>=0&&j.enableVertexAttribArray(o[g]);if(a.morphTargets)for(g=a.numSupportedMorphTargets=0;g=0&&(j.enableVertexAttribArray(o[q]), +g=["#ifdef GL_ES","precision "+Y+" float;","#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",M.gammaInput?"#define GAMMA_INPUT":"",M.gammaOutput?"#define GAMMA_OUTPUT":"",M.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP": +"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(p,v("fragment",g+l));j.attachShader(p, +v("vertex",d+k));j.linkProgram(p);j.getProgramParameter(p,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(p,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");p.uniforms={};p.attributes={};var q,d=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(q in i)d.push(q);q=d;d=0;for(i=q.length;d=0&&j.enableVertexAttribArray(o.position);o.color>=0&&j.enableVertexAttribArray(o.color);o.normal>=0&&j.enableVertexAttribArray(o.normal); +o.tangent>=0&&j.enableVertexAttribArray(o.tangent);a.skinning&&o.skinVertexA>=0&&o.skinVertexB>=0&&o.skinIndex>=0&&o.skinWeight>=0&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(f in a.attributes)o[f]!==void 0&&o[f]>=0&&j.enableVertexAttribArray(o[f]);if(a.morphTargets)for(f=a.numSupportedMorphTargets=0;f=0&&(j.enableVertexAttribArray(o[q]), a.numSupportedMorphTargets++);a.uniformsList=[];for(e in a.uniforms)a.uniformsList.push([a.uniforms[e],e])};this.setFaceCulling=function(a,b){a?(!b||b==="ccw"?j.frontFace(j.CCW):j.frontFace(j.CW),a==="back"?j.cullFace(j.BACK):a==="front"?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)}}; THREE.WebGLRenderTarget=function(a,c,b){this.width=a;this.height=c;b=b||{};this.wrapS=b.wrapS!==void 0?b.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=b.wrapT!==void 0?b.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=b.magFilter!==void 0?b.magFilter:THREE.LinearFilter;this.minFilter=b.minFilter!==void 0?b.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=b.format!==void 0?b.format:THREE.RGBAFormat;this.type=b.type!==void 0?b.type: THREE.UnsignedByteType;this.depthBuffer=b.depthBuffer!==void 0?b.depthBuffer:!0;this.stencilBuffer=b.stencilBuffer!==void 0?b.stencilBuffer:!0}; @@ -446,7 +446,7 @@ THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()}; THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; -THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;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=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= +THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward= !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown= function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp= @@ -456,14 +456,14 @@ this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&& Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),o=g.length,s=0;f=o-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+f;c=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;c=THREE.Math.mapLinear(this.phi,c[0],c[1],a[0],a[1]);var d=a[1]-a[0];this.phi=b((c-a[0])/d)*d+a[0];c=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;c=THREE.Math.mapLinear(this.theta,c[0],c[1],a[0],a[1]);d=a[1]-a[0];this.theta=b((c-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= this.debugPath,b=this.spline,f=e(b,10),c=e(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),m=0;m0?1:-1;for(h=0;h0?1:-1;for(h=0;h=0;J--){W=J/k;X=i*(1-W);W=l*Math.sin(W*Math.PI/2);B=0;for(L=u.length;B=0;J--){X=J/k;Y=i*(1-X);X=l*Math.sin(X*Math.PI/2);B=0;for(L=u.length;B0||(k=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,h,q)))-1);l.push(k)}c.push(l)}for(var m,t,n,g=c.length,b=0;b0)for(d=0;d1&&(m= -this.vertices[f].position.clone(),t=this.vertices[i].position.clone(),n=this.vertices[l].position.clone(),m.normalize(),t.normalize(),n.normalize(),this.faces.push(new THREE.Face3(f,i,l,[new THREE.Vector3(m.x,m.y,m.z),new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(n.x,n.y,n.z)])),this.faceVertexUvs[0].push([k,p,o]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; -THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; +THREE.SphereGeometry=function(a,c,b,d,g,e,f){THREE.Geometry.call(this);var a=a||50,c=c||8,b=b||6,d=d!=void 0?d:0,g=g!=void 0?g:Math.PI*2,e=e!=void 0?e:0,f=f!=void 0?f:Math.PI,h,i,l=[],k=[];for(i=0;i<=b;i++){var p=[],q=[];for(h=0;h<=c;h++){var m=h/c,t=i/b;this.vertices.push(new THREE.Vertex(new THREE.Vector3(-a*Math.cos(d+m*g)*Math.sin(e+t*f),a*Math.cos(e+t*f),a*Math.sin(d+m*g)*Math.sin(e+t*f))));p.push(this.vertices.length-1);q.push(new THREE.UV(m,t))}l.push(p);k.push(q)}for(i=0;i0)for(l=0;l2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return e}i=l;g<=i&&(i=0);l=i+1;g<=l&&(l=0);k=l+1;g<=k&&(k=0);var q;a:{q=a;var m=i,t=l,n=k,o=g,s=f,u=void 0,r=void 0,z=void 0, -E=void 0,G=void 0,v=void 0,w=void 0,C=void 0,F=void 0,r=q[s[m]].x,z=q[s[m]].y,E=q[s[t]].x,G=q[s[t]].y,v=q[s[n]].x,w=q[s[n]].y;if(1.0E-10>(E-r)*(w-z)-(G-z)*(v-r))q=!1;else{for(u=0;u=0&&J>=0&&X>=0){q=!1;break a}}q= +E=void 0,G=void 0,v=void 0,w=void 0,C=void 0,F=void 0,r=q[s[m]].x,z=q[s[m]].y,E=q[s[t]].x,G=q[s[t]].y,v=q[s[n]].x,w=q[s[n]].y;if(1.0E-10>(E-r)*(w-z)-(G-z)*(v-r))q=!1;else{for(u=0;u=0&&J>=0&&Y>=0){q=!1;break a}}q= !0}}if(q){e.push([a[f[i]],a[f[l]],a[f[k]]]);h.push([f[i],f[l],f[k]]);i=l;for(k=l+1;k0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.useOldVertexColors){k.vertexColors=[];for(var j,l,m,n=0;n<4;n++){m=i[n];j=new THREE.Color;j.setRGB(0,0,0);for(var o=0;o=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length1?c[1].substr(0,b):"0";c[1].length=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;ab){l=j.output[i];break}g=l!==void 0?l instanceof THREE.Matrix4?g.multiply(g,l):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(d=ia[this.effect.surface.init_from]))a.map= THREE.ImageUtils.loadTexture(ya+d.init_from),a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=xa;return this.material=new THREE.MeshLambertMaterial(a)};B.prototype.parse=function(a){for(var b=0;b=0,d=a.indexOf("(")>=0,e,f;if(c)b=a.split("."),a=b.shift(),f=b.shift();else if(d){e=a.split("(");a=e.shift();for(b=0;b1&&(L=new THREE.MeshFaceMaterial); a=new THREE.Mesh(C,L);a.name=q;a.position.set(z[0],z[1],z[2]);G?(a.quaternion.set(G[0],G[1],G[2],G[3]),a.useQuaternion=!0):a.rotation.set(E[0],E[1],E[2]);a.scale.set(v[0],v[1],v[2]);a.visible=s.visible;x.scene.add(a);x.objects[q]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);x.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(C),x.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&s.trigger.toLowerCase()!="none"&&(b= {type:s.trigger,object:s},x.triggers[a.name]=b)}}else z=s.position,E=s.rotation,G=s.quaternion,v=s.scale,G=0,a=new THREE.Object3D,a.name=q,a.position.set(z[0],z[1],z[2]),G?(a.quaternion.set(G[0],G[1],G[2],G[3]),a.useQuaternion=!0):a.rotation.set(E[0],E[1],E[2]),a.scale.set(v[0],v[1],v[2]),a.visible=s.visible!==void 0?s.visible:!1,x.scene.add(a),x.objects[q]=a,x.empties[q]=a,s.trigger&&s.trigger.toLowerCase()!="none"&&(b={type:s.trigger,object:s},x.triggers[a.name]=b)}function e(a){return function(b){x.geometries[a]= -b;g();X-=1;i.onLoadComplete();h()}}function f(a){return function(b){x.geometries[a]=b}}function h(){i.callbackProgress({totalModels:ea,totalTextures:ba,loadedModels:ea-X,loadedTextures:ba-T},x);i.onLoadProgress();X==0&&T==0&&c(x)}var i=this,l=THREE.Loader.prototype.extractUrlbase(b),k,p,q,m,t,n,o,s,u,r,z,E,G,v,w,C,F,B,L,J,W,X,T,ea,ba,x;J=a;b=new THREE.BinaryLoader;W=new THREE.JSONLoader;T=X=0;x={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +b;g();Y-=1;i.onLoadComplete();h()}}function f(a){return function(b){x.geometries[a]=b}}function h(){i.callbackProgress({totalModels:ea,totalTextures:ba,loadedModels:ea-Y,loadedTextures:ba-T},x);i.onLoadProgress();Y==0&&T==0&&c(x)}var i=this,l=THREE.Loader.prototype.extractUrlbase(b),k,p,q,m,t,n,o,s,u,r,z,E,G,v,w,C,F,B,L,J,X,Y,T,ea,ba,x;J=a;b=new THREE.BinaryLoader;X=new THREE.JSONLoader;T=Y=0;x={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, empties:{}};a=!1;for(q in J.objects)if(s=J.objects[q],s.meshCollider){a=!0;break}if(a)x.scene.collisions=new THREE.CollisionSystem;if(J.transform){a=J.transform.position;u=J.transform.rotation;var I=J.transform.scale;a&&x.scene.position.set(a[0],a[1],a[2]);u&&x.scene.rotation.set(u[0],u[1],u[2]);I&&x.scene.scale.set(I[0],I[1],I[2]);(a||u||I)&&x.scene.updateMatrix()}a=function(){T-=1;h();i.onLoadComplete()};for(t in J.cameras)u=J.cameras[t],u.type=="perspective"?F=new THREE.PerspectiveCamera(u.fov, u.aspect,u.near,u.far):u.type=="ortho"&&(F=new THREE.OrthographicCamera(u.left,u.right,u.top,u.bottom,u.near,u.far)),z=u.position,u=u.target,F.position.set(z[0],z[1],z[2]),F.target=new THREE.Vector3(u[0],u[1],u[2]),x.cameras[t]=F;for(m in J.lights)u=J.lights[m],t=u.color!==void 0?u.color:16777215,F=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(z=u.direction,r=new THREE.DirectionalLight(t,F),r.position.set(z[0],z[1],z[2]),r.position.normalize()):u.type=="point"?(z=u.position,r=u.distance, r=new THREE.PointLight(t,F,r),r.position.set(z[0],z[1],z[2])):u.type=="ambient"&&(r=new THREE.AmbientLight(t)),x.scene.add(r),x.lights[m]=r;for(n in J.fogs)m=J.fogs[n],m.type=="linear"?B=new THREE.Fog(0,m.near,m.far):m.type=="exp2"&&(B=new THREE.FogExp2(0,m.density)),u=m.color,B.color.setRGB(u[0],u[1],u[2]),x.fogs[n]=B;if(x.cameras&&J.defaults.camera)x.currentCamera=x.cameras[J.defaults.camera];if(x.fogs&&J.defaults.fog)x.scene.fog=x.fogs[J.defaults.fog];u=J.defaults.bgcolor;x.bgColor=new THREE.Color; -x.bgColor.setRGB(u[0],u[1],u[2]);x.bgColorAlpha=J.defaults.bgalpha;for(k in J.geometries)if(n=J.geometries[k],n.type=="bin_mesh"||n.type=="ascii_mesh")X+=1,i.onLoadStart();ea=X;for(k in J.geometries)n=J.geometries[k],n.type=="cube"?(C=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),x.geometries[k]=C):n.type=="plane"?(C=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),x.geometries[k]=C):n.type=="sphere"? -(C=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),x.geometries[k]=C):n.type=="cylinder"?(C=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),x.geometries[k]=C):n.type=="torus"?(C=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),x.geometries[k]=C):n.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(n.subdivisions),x.geometries[k]=C):n.type=="bin_mesh"?b.load(d(n.url,J.urlBaseType),e(k)):n.type=="ascii_mesh"?W.load(d(n.url,J.urlBaseType), -e(k)):n.type=="embedded_mesh"&&(n=J.embeds[n.id])&&W.createModel(n,f(k),"");for(o in J.textures)if(k=J.textures[o],k.url instanceof Array){T+=k.url.length;for(n=0;n=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var e=0,f=0;f>1^-(h&1);b[8*f+g]=e}d+=c}c=a.length-d;e=new Uint16Array(c);for(g=f=0;g=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; diff --git a/build/custom/ThreeDOM.js b/build/custom/ThreeDOM.js index 3da6f470..81e2a806 100644 --- a/build/custom/ThreeDOM.js +++ b/build/custom/ThreeDOM.js @@ -72,7 +72,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo 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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,m=k*c+g*e-h*d,j=k*d+h*c-f*e,i=k*e+f*d-g*c,c=-f* c-g*d-h*e;b.x=m*k+c*-f+j*-h-i*-g;b.y=j*k+c*-g+i*-f-m*-h;b.z=i*k+c*-h+m*-g-j*-f;return b}}; -THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;e<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/e;d=Math.sin(d*f)/e;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; diff --git a/build/custom/ThreeExtras.js b/build/custom/ThreeExtras.js index 22b4642b..091e50d1 100644 --- a/build/custom/ThreeExtras.js +++ b/build/custom/ThreeExtras.js @@ -1,19 +1,19 @@ // ThreeExtras.js r46dev - http://github.com/mrdoob/three.js THREE.ColorUtils={adjustHSV:function(a,c,b,d){var g=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,g);g.h=THREE.Math.clamp(g.h+c,0,1);g.s=THREE.Math.clamp(g.s+b,0,1);g.v=THREE.Math.clamp(g.v+d,0,1);a.setHSV(g.h,g.s,g.v)},rgbToHsv:function(a,c){var b=a.r,d=a.g,g=a.b,f=Math.max(Math.max(b,d),g),e=Math.min(Math.min(b,d),g);if(e===f)e=b=0;else{var h=f-e,e=h/f,b=b===f?(d-g)/h:d===f?2+(g-b)/h:4+(b-d)/h;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=e;c.v=f;return c}}; THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(a,c){for(var b,d,g=a.vertices.length,f=c instanceof THREE.Mesh?c.geometry:c,e=a.vertices,h=f.vertices,i=a.faces,k=f.faces,j=a.faceVertexUvs[0],q=f.faceVertexUvs[0],o={},l=0;l1&&(d=1-d,g=1-g);f=1-d-g;e.copy(a);e.multiplyScalar(d);h.copy(c);h.multiplyScalar(g);e.addSelf(h);h.copy(b);h.multiplyScalar(f);e.addSelf(h);return e},randomPointInFace:function(a,c,b){var d,g,f;if(a instanceof THREE.Face3)return d=c.vertices[a.a].position,g=c.vertices[a.b].position, f=c.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,g,f);else if(a instanceof THREE.Face4){d=c.vertices[a.a].position;g=c.vertices[a.b].position;f=c.vertices[a.c].position;var c=c.vertices[a.d].position,e;b?a._area1&&a._area2?(b=a._area1,e=a._area2):(b=THREE.GeometryUtils.triangleArea(d,g,c),e=THREE.GeometryUtils.triangleArea(g,f,c),a._area1=b,a._area2=e):(b=THREE.GeometryUtils.triangleArea(d,g,c),e=THREE.GeometryUtils.triangleArea(g,f,c));return THREE.GeometryUtils.random()*(b+ -e)a?b(d,e-1):k[e]a?b(d,e-1):k[e]0?(e=b[b.length-1],l=e.x,s=e.y):(e=this.actions[d-1].args,l=e[e.length-2],s=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,f=THREE.Shape.Utils.b2(m,l,q,h),m=THREE.Shape.Utils.b2(m,s,o, -i),b.push(new THREE.Vector2(f,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];q=f[0];o=f[1];k=f[2];j=f[3];b.length>0?(e=b[b.length-1],l=e.x,s=e.y):(e=this.actions[d-1].args,l=e[e.length-2],s=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,f=THREE.Shape.Utils.b3(m,l,q,k,h),m=THREE.Shape.Utils.b3(m,s,o,j,i),b.push(new THREE.Vector2(f,m));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[d-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];m=a*f[0].length;e=e.concat(f[0]);f=new THREE.SplineCurve(e); -for(e=1;e<=m;e++)b.push(f.getPointAt(e/m));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;h=f[0];i=f[1];k=f[2];q=f[3];m=f[4];o=!!f[5];j=e[e.length-2];l=e[e.length-1];e.length==0&&(j=l=0);s=m-q;var p=a*2;for(e=1;e<=p;e++)m=e/p,o||(m=1-m),m=q+m*s,f=j+h+k*Math.cos(m),m=l+i+k*Math.sin(m),b.push(new THREE.Vector2(f,m))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; +THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],d,g,f,e,h,i,k,j,q,o,n,s,m;d=0;for(g=this.actions.length;d0?(e=b[b.length-1],n=e.x,s=e.y):(e=this.actions[d-1].args,n=e[e.length-2],s=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,f=THREE.Shape.Utils.b2(m,n,q,h),m=THREE.Shape.Utils.b2(m,s,o, +i),b.push(new THREE.Vector2(f,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];q=f[0];o=f[1];k=f[2];j=f[3];b.length>0?(e=b[b.length-1],n=e.x,s=e.y):(e=this.actions[d-1].args,n=e[e.length-2],s=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,f=THREE.Shape.Utils.b3(m,n,q,k,h),m=THREE.Shape.Utils.b3(m,s,o,j,i),b.push(new THREE.Vector2(f,m));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[d-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];m=a*f[0].length;e=e.concat(f[0]);f=new THREE.SplineCurve(e); +for(e=1;e<=m;e++)b.push(f.getPointAt(e/m));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;h=f[0];i=f[1];k=f[2];q=f[3];m=f[4];o=!!f[5];j=e[e.length-2];n=e[e.length-1];e.length==0&&(j=n=0);s=m-q;var p=a*2;for(e=1;e<=p;e++)m=e/p,o||(m=1-m),m=q+m*s,f=j+h+k*Math.cos(m),m=n+i+k*Math.sin(m),b.push(new THREE.Vector2(f,m))}c&&b.push(b[0]);return b};THREE.Path.prototype.transform=function(a,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),a)}; THREE.Path.prototype.nltransform=function(a,c,b,d,g,f){var e=this.getPoints(),h,i,k,j,q;h=0;for(i=e.length;h=0?h-1:b.length-1;f=e-1>=0?e-1:k.length-1;var m=[k[e],b[h],b[g]];q=THREE.FontUtils.Triangulate.area(m);var p=[k[e],k[f],b[h]];o=THREE.FontUtils.Triangulate.area(p);l=h;j=e;h+=1;e+=-1;h< -0&&(h+=b.length);h%=b.length;e<0&&(e+=k.length);e%=k.length;g=h-1>=0?h-1:b.length-1;f=e-1>=0?e-1:k.length-1;m=[k[e],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(m);p=[k[e],k[f],b[h]];p=THREE.FontUtils.Triangulate.area(p);q+o>m+p&&(h=l,e=j,h<0&&(h+=b.length),h%=b.length,e<0&&(e+=k.length),e%=k.length,g=h-1>=0?h-1:b.length-1,f=e-1>=0?e-1:k.length-1);q=b.slice(0,h);o=b.slice(h);l=k.slice(e);j=k.slice(0,e);f=[k[e],k[f],b[h]];s.push([k[e],b[h],b[g]]);s.push(f);b=q.concat(l).concat(j).concat(o)}return{shape:b, +THREE.Shape.Utils={removeHoles:function(a,c){var b=a.concat(),d=b.concat(),g,f,e,h,i,k,j,q,o,n,s=[];for(i=0;i=0?h-1:b.length-1;f=e-1>=0?e-1:k.length-1;var m=[k[e],b[h],b[g]];q=THREE.FontUtils.Triangulate.area(m);var p=[k[e],k[f],b[h]];o=THREE.FontUtils.Triangulate.area(p);n=h;j=e;h+=1;e+=-1;h< +0&&(h+=b.length);h%=b.length;e<0&&(e+=k.length);e%=k.length;g=h-1>=0?h-1:b.length-1;f=e-1>=0?e-1:k.length-1;m=[k[e],b[h],b[g]];m=THREE.FontUtils.Triangulate.area(m);p=[k[e],k[f],b[h]];p=THREE.FontUtils.Triangulate.area(p);q+o>m+p&&(h=n,e=j,h<0&&(h+=b.length),h%=b.length,e<0&&(e+=k.length),e%=k.length,g=h-1>=0?h-1:b.length-1,f=e-1>=0?e-1:k.length-1);q=b.slice(0,h);o=b.slice(h);n=k.slice(e);j=k.slice(0,e);f=[k[e],k[f],b[h]];s.push([k[e],b[h],b[g]]);s.push(f);b=q.concat(n).concat(j).concat(o)}return{shape:b, isolatedPts:s,allpoints:d}},triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),d=b.allpoints,g=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),f,e,h,i,k={};f=0;for(e=d.length;f1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+l),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",l,e.index-1).pos,this.points[1]=g,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",l,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== -"rot")THREE.Quaternion.slerp(g,f,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(l=0;l1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=d<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",n,e.index-1).pos,this.points[1]=g,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=d*0.33+0.33,g=this.interpolateCatmullRom(this.points,d),b.x=g[0],b.y=g[1],b.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,d*1.01),this.target.set(d[0],d[1],d[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if(b=== +"rot")THREE.Quaternion.slerp(g,f,a.quaternion,d);else if(b==="scl")b=a.scale,b.x=g[0]+(f[0]-g[0])*d,b.y=g[1]+(f[1]-g[1])*d,b.z=g[2]+(f[2]-g[2])*d}}if(this.JITCompile&&j[0][k]===void 0){this.hierarchy[0].update(null,!0);for(n=0;na.length-2?f:f+1;b[3]=f>a.length-3?f:f+2;f=a[b[0]];h=a[b[1]];i=a[b[2]];k=a[b[3]];b=g*g;e=g*b;d[0]=this.interpolate(f[0],h[0],i[0],k[0],g,b,e);d[1]=this.interpolate(f[1],h[1],i[1],k[1],g,b,e);d[2]=this.interpolate(f[2],h[2],i[2],k[2],g,b,e);return d}; THREE.Animation.prototype.interpolate=function(a,c,b,d,g,f,e){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*e+(-3*(c-b)-2*a-d)*f+a*g+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b0?b:0:b>=0?b:b+d.length;b>=0;b--)if(d[b][a]!==void 0)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; @@ -96,7 +96,7 @@ THREE.CombinedCamera.prototype.toOrthographic=function(){var a=Math.tan(this.fov THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,c){c||(c=43.25);var b=2*Math.atan(c/(a*2));b*=180/Math.PI;this.setFov(b);return b};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()}; THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1}; THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1}; -THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;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=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= +THREE.FirstPersonControls=function(a,c){function b(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=c!==void 0?c:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor= 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward= !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown= function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp= @@ -104,16 +104,16 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37: this.object.translateX(b);this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);c=a*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)*Math.sin(this.theta)}a= 1;this.constrainVertical&&(a=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c*a);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=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);a=this.target;b=this.object.position;a.x=b.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=b.y+100*Math.cos(this.phi);a.z=b.z+100*Math.sin(this.phi)* Math.sin(this.theta);this.object.lookAt(a)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)}; -THREE.PathControls=function(a,c){function b(a){if((a*=2)<1)return 0.5*a*a;return-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function g(a,b,d,c){var e={name:d,fps:0.6,length:c,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),p=g.length,n=0;f=p-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:c,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f=0?a:a+e;d=this.verticalAngleMap.srcRange; a=this.verticalAngleMap.dstRange;d=THREE.Math.mapLinear(this.phi,d[0],d[1],a[0],a[1]);var c=a[1]-a[0];this.phi=b((d-a[0])/c)*c+a[0];d=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;d=THREE.Math.mapLinear(this.theta,d[0],d[1],a[0],a[1]);c=a[1]-a[0];this.theta=b((d-a[0])/c)*c+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove= function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}), c=new THREE.CubeGeometry(10,10,20),e=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(e,b);a.position.set(0,10,0);this.animation=g(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=g(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a= -this.debugPath,b=this.spline,e=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Line(e,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));e.scale.set(1,1,1);a.add(e);c.scale.set(1,1,1);a.add(c);for(var e=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),l=0;l0||this.autoForward&&!(i<0)?1:i));this.object.translateX(c*k);this.object.translateY(c*j);e&&(this.roll+=this.rollSpeed*a*h);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();else if(this.forward.y0?1:-1;for(h=0;h0?1:-1;for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(h=0;h0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-e,0)));for(h=0;ha&&(a+=Math.PI*2),a=(b+a)/2,new THREE.Vector2(-Math.cos(a),-Math.sin(a));return d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function g(a){for(u=a.length;--u>=0;){J=u;N=u-1;N<0&&(N=a.length-1);for(var b= -0,c=l+j*2,b=0;b=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);u=0;for(D=r.length;u=0;B--){G=B/j;I=i*(1-G);G=k*Math.sin(G*Math.PI/2);u=0;for(D=r.length;u0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(q,h,o)))-1);k.push(j)}c.push(k)}for(var l,s,m,g=c.length,b=0;b0)for(d=0;d1&&(l= -this.vertices[e].position.clone(),s=this.vertices[i].position.clone(),m=this.vertices[k].position.clone(),l.normalize(),s.normalize(),m.normalize(),this.faces.push(new THREE.Face3(e,i,k,[new THREE.Vector3(l.x,l.y,l.z),new THREE.Vector3(s.x,s.y,s.z),new THREE.Vector3(m.x,m.y,m.z)])),this.faceVertexUvs[0].push([j,q,p]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry; -THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; +THREE.SphereGeometry=function(a,c,b,d,g,f,e){THREE.Geometry.call(this);var a=a||50,c=c||8,b=b||6,d=d!=void 0?d:0,g=g!=void 0?g:Math.PI*2,f=f!=void 0?f:0,e=e!=void 0?e:Math.PI,h,i,k=[],j=[];for(i=0;i<=b;i++){var q=[],o=[];for(h=0;h<=c;h++){var n=h/c,s=i/b;this.vertices.push(new THREE.Vertex(new THREE.Vector3(-a*Math.cos(d+n*g)*Math.sin(f+s*e),a*Math.cos(f+s*e),a*Math.sin(d+n*g)*Math.sin(f+s*e))));q.push(this.vertices.length-1);o.push(new THREE.UV(n,s))}k.push(q);j.push(o)}for(i=0;i0)for(k=0;k2;){if(q--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=k;g<=i&&(i=0);k=i+1;g<=k&&(k=0);j=k+1;g<=j&&(j=0);var o;a:{o=a;var l=i,s=k,m=j,p=g,n=e,r=void 0,t=void 0,w=void 0, -z=void 0,v=void 0,x=void 0,y=void 0,A=void 0,F=void 0,t=o[n[l]].x,w=o[n[l]].y,z=o[n[s]].x,v=o[n[s]].y,x=o[n[m]].x,y=o[n[m]].y;if(1.0E-10>(z-t)*(y-w)-(v-w)*(x-t))o=!1;else{for(r=0;r=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){f.push([a[e[i]], +0,g=String(a).split(""),f=g.length,e=[],a=0;a0)for(k=0;k2;){if(q--<=0){console.log("Warning, unable to triangulate polygon!");if(d)return h;return f}i=k;g<=i&&(i=0);k=i+1;g<=k&&(k=0);j=k+1;g<=j&&(j=0);var o;a:{o=a;var n=i,s=k,m=j,p=g,l=e,r=void 0,t=void 0,w=void 0, +z=void 0,v=void 0,x=void 0,y=void 0,A=void 0,F=void 0,t=o[l[n]].x,w=o[l[n]].y,z=o[l[s]].x,v=o[l[s]].y,x=o[l[m]].x,y=o[l[m]].y;if(1.0E-10>(z-t)*(y-w)-(v-w)*(x-t))o=!1;else{for(r=0;r=0&&B>=0&&I>=0){o=!1;break a}}o=!0}}if(o){f.push([a[e[i]], a[e[k]],a[e[j]]]);h.push([e[i],e[k],e[j]]);i=k;for(j=k+1;j0;)this.smooth(a)}; -THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,d,h,i){var j=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(e.useOldVertexColors){j.vertexColors=[];for(var k,l,m,n=0;n<4;n++){m=i[n];k=new THREE.Color;k.setRGB(0,0,0);for(var p=0;p=0){p=i.invBindMatrices[m];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p=0){p=i.invBindMatrices[n];j.invBindMatrix=p;j.skinningMatrix=new THREE.Matrix4;j.skinningMatrix.multiply(j.world,p);j.weights=[];for(p=0;p1){j=new THREE.MeshFaceMaterial;for(h=0;h1){j=new THREE.MeshFaceMaterial;for(h=0;h1?b.add(j):b=j}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation,b.scale);for(e=0;e=0,g=e.indexOf("(")>=0,h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;db){k=j.output[i];break}g=k!==void 0?k instanceof THREE.Matrix4?g.multiply(g,k):g.multiply(g,h.matrix):g.multiply(g,h.matrix)}else g=g.multiply(g,h.matrix);b=g;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};q.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a1&&(D=new THREE.MeshFaceMaterial); -a=new THREE.Mesh(A,D);a.name=o;a.position.set(w[0],w[1],w[2]);v?(a.quaternion.set(v[0],v[1],v[2],v[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]);a.scale.set(x[0],x[1],x[2]);a.visible=n.visible;C.scene.add(a);C.objects[o]=a;if(n.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(n.castsShadow)b=new THREE.ShadowVolume(A),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;n.trigger&&n.trigger.toLowerCase()!="none"&&(b= -{type:n.trigger,object:n},C.triggers[a.name]=b)}}else w=n.position,z=n.rotation,v=n.quaternion,x=n.scale,v=0,a=new THREE.Object3D,a.name=o,a.position.set(w[0],w[1],w[2]),v?(a.quaternion.set(v[0],v[1],v[2],v[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]),a.scale.set(x[0],x[1],x[2]),a.visible=n.visible!==void 0?n.visible:!1,C.scene.add(a),C.objects[o]=a,C.empties[o]=a,n.trigger&&n.trigger.toLowerCase()!="none"&&(b={type:n.trigger,object:n},C.triggers[a.name]=b)}function f(a){return function(b){C.geometries[a]= -b;g();I-=1;i.onLoadComplete();h()}}function e(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},C);i.onLoadProgress();I==0&&E==0&&c(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(b),j,q,o,l,s,m,p,n,r,t,w,z,v,x,y,A,F,u,D,B,G,I,E,K,O,C;B=a;b=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, -empties:{}};a=!1;for(o in B.objects)if(n=B.objects[o],n.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform){a=B.transform.position;r=B.transform.rotation;var L=B.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);r&&C.scene.rotation.set(r[0],r[1],r[2]);L&&C.scene.scale.set(L[0],L[1],L[2]);(a||r||L)&&C.scene.updateMatrix()}a=function(){E-=1;h();i.onLoadComplete()};for(s in B.cameras)r=B.cameras[s],r.type=="perspective"?F=new THREE.PerspectiveCamera(r.fov, -r.aspect,r.near,r.far):r.type=="ortho"&&(F=new THREE.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)),w=r.position,r=r.target,F.position.set(w[0],w[1],w[2]),F.target=new THREE.Vector3(r[0],r[1],r[2]),C.cameras[s]=F;for(l in B.lights)r=B.lights[l],s=r.color!==void 0?r.color:16777215,F=r.intensity!==void 0?r.intensity:1,r.type=="directional"?(w=r.direction,t=new THREE.DirectionalLight(s,F),t.position.set(w[0],w[1],w[2]),t.position.normalize()):r.type=="point"?(w=r.position,t=r.distance, -t=new THREE.PointLight(s,F,t),t.position.set(w[0],w[1],w[2])):r.type=="ambient"&&(t=new THREE.AmbientLight(s)),C.scene.add(t),C.lights[l]=t;for(m in B.fogs)l=B.fogs[m],l.type=="linear"?u=new THREE.Fog(0,l.near,l.far):l.type=="exp2"&&(u=new THREE.FogExp2(0,l.density)),r=l.color,u.color.setRGB(r[0],r[1],r[2]),C.fogs[m]=u;if(C.cameras&&B.defaults.camera)C.currentCamera=C.cameras[B.defaults.camera];if(C.fogs&&B.defaults.fog)C.scene.fog=C.fogs[B.defaults.fog];r=B.defaults.bgcolor;C.bgColor=new THREE.Color; +THREE.SceneLoader.prototype.createScene=function(a,c,b){function d(a,b){return b=="relativeToHTML"?a:k+"/"+a}function g(){var a;for(o in B.objects)if(!C.objects[o])if(l=B.objects[o],l.geometry!==void 0){if(A=C.geometries[l.geometry]){a=!1;for(H=0;H1&&(D=new THREE.MeshFaceMaterial); +a=new THREE.Mesh(A,D);a.name=o;a.position.set(w[0],w[1],w[2]);v?(a.quaternion.set(v[0],v[1],v[2],v[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]);a.scale.set(x[0],x[1],x[2]);a.visible=l.visible;C.scene.add(a);C.objects[o]=a;if(l.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(l.castsShadow)b=new THREE.ShadowVolume(A),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;l.trigger&&l.trigger.toLowerCase()!="none"&&(b= +{type:l.trigger,object:l},C.triggers[a.name]=b)}}else w=l.position,z=l.rotation,v=l.quaternion,x=l.scale,v=0,a=new THREE.Object3D,a.name=o,a.position.set(w[0],w[1],w[2]),v?(a.quaternion.set(v[0],v[1],v[2],v[3]),a.useQuaternion=!0):a.rotation.set(z[0],z[1],z[2]),a.scale.set(x[0],x[1],x[2]),a.visible=l.visible!==void 0?l.visible:!1,C.scene.add(a),C.objects[o]=a,C.empties[o]=a,l.trigger&&l.trigger.toLowerCase()!="none"&&(b={type:l.trigger,object:l},C.triggers[a.name]=b)}function f(a){return function(b){C.geometries[a]= +b;g();I-=1;i.onLoadComplete();h()}}function e(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:K,totalTextures:O,loadedModels:K-I,loadedTextures:O-E},C);i.onLoadProgress();I==0&&E==0&&c(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(b),j,q,o,n,s,m,p,l,r,t,w,z,v,x,y,A,F,u,D,B,G,I,E,K,O,C;B=a;b=new THREE.BinaryLoader;G=new THREE.JSONLoader;E=I=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{}, +empties:{}};a=!1;for(o in B.objects)if(l=B.objects[o],l.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform){a=B.transform.position;r=B.transform.rotation;var L=B.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);r&&C.scene.rotation.set(r[0],r[1],r[2]);L&&C.scene.scale.set(L[0],L[1],L[2]);(a||r||L)&&C.scene.updateMatrix()}a=function(){E-=1;h();i.onLoadComplete()};for(s in B.cameras)r=B.cameras[s],r.type=="perspective"?F=new THREE.PerspectiveCamera(r.fov, +r.aspect,r.near,r.far):r.type=="ortho"&&(F=new THREE.OrthographicCamera(r.left,r.right,r.top,r.bottom,r.near,r.far)),w=r.position,r=r.target,F.position.set(w[0],w[1],w[2]),F.target=new THREE.Vector3(r[0],r[1],r[2]),C.cameras[s]=F;for(n in B.lights)r=B.lights[n],s=r.color!==void 0?r.color:16777215,F=r.intensity!==void 0?r.intensity:1,r.type=="directional"?(w=r.direction,t=new THREE.DirectionalLight(s,F),t.position.set(w[0],w[1],w[2]),t.position.normalize()):r.type=="point"?(w=r.position,t=r.distance, +t=new THREE.PointLight(s,F,t),t.position.set(w[0],w[1],w[2])):r.type=="ambient"&&(t=new THREE.AmbientLight(s)),C.scene.add(t),C.lights[n]=t;for(m in B.fogs)n=B.fogs[m],n.type=="linear"?u=new THREE.Fog(0,n.near,n.far):n.type=="exp2"&&(u=new THREE.FogExp2(0,n.density)),r=n.color,u.color.setRGB(r[0],r[1],r[2]),C.fogs[m]=u;if(C.cameras&&B.defaults.camera)C.currentCamera=C.cameras[B.defaults.camera];if(C.fogs&&B.defaults.fog)C.scene.fog=C.fogs[B.defaults.fog];r=B.defaults.bgcolor;C.bgColor=new THREE.Color; C.bgColor.setRGB(r[0],r[1],r[2]);C.bgColorAlpha=B.defaults.bgalpha;for(j in B.geometries)if(m=B.geometries[j],m.type=="bin_mesh"||m.type=="ascii_mesh")I+=1,i.onLoadStart();K=I;for(j in B.geometries)m=B.geometries[j],m.type=="cube"?(A=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),C.geometries[j]=A):m.type=="plane"?(A=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),C.geometries[j]=A):m.type=="sphere"? (A=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),C.geometries[j]=A):m.type=="cylinder"?(A=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),C.geometries[j]=A):m.type=="torus"?(A=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),C.geometries[j]=A):m.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(m.subdivisions),C.geometries[j]=A):m.type=="bin_mesh"?b.load(d(m.url,B.urlBaseType),f(j)):m.type=="ascii_mesh"?G.load(d(m.url,B.urlBaseType), f(j)):m.type=="embedded_mesh"&&(m=B.embeds[m.id])&&G.createModel(m,e(j),"");for(p in B.textures)if(j=B.textures[p],j.url instanceof Array){E+=j.url.length;for(m=0;m=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),d=1,g=0;g<8;g++){for(var f=0,e=0;e>1^-(h&1);b[8*e+g]=f}d+=c}c=a.length-d;f=new Uint16Array(c);for(g=e=0;g=this.maxCount-3&&h(this)};this.begin= -function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;cthis.size-1&&(i=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var l=Math.floor(j-h);l<1&&(l=1);h=Math.floor(j+h); -h>this.size-1&&(h=this.size-1);for(var s,m,p,n,r,t;q0&&(this.field[p+s]+=n)}}};this.addPlaneX=function(a,c){var g,f,e,h,i,k=this.size,j=this.yd,q=this.zd,o=this.field,l=k*Math.sqrt(a/c);l>k&&(l=k);for(g=0;g0)for(f=0;fj&&(s=j);for(f=0;f0){i=f*q;for(g=0;gj&&(s=j);for(e=0;e0){i=o*e;for(f=0;fthis.size-1&&(i=this.size-1);var o=Math.floor(k-h);o<1&&(o=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var n=Math.floor(j-h);n<1&&(n=1);h=Math.floor(j+h); +h>this.size-1&&(h=this.size-1);for(var s,m,p,l,r,t;q0&&(this.field[p+s]+=l)}}};this.addPlaneX=function(a,c){var g,f,e,h,i,k=this.size,j=this.yd,q=this.zd,o=this.field,n=k*Math.sqrt(a/c);n>k&&(n=k);for(g=0;g0)for(f=0;fj&&(s=j);for(f=0;f0){i=f*q;for(g=0;gj&&(s=j);for(e=0;e0){i=o*e;for(f=0;fc.max.z)return Number.MAX_VALUE;c.normal.set(0,h,0);break;case THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq=0)return Math.abs(d)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,e=new THREE.Matrix4,h=new THREE.Matrix4,i,k,j,q;g.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),l=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53, -1,1,1E4);s.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:l}},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}"}), -m=new THREE.Scene;m.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));m.add(s);this.setSize=function(a,d){b.call(c,a,d);o.width=a;o.height=d;l.width=a;l.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||j!==b.far||q!==b.fov){i=b.aspect;k=b.near;j=b.far;q=b.fov;var r=b.projectionMatrix.clone(),t=125/30*0.5,w=t*k/125,z=k*Math.tan(q*Math.PI/360),v;e.n14=t;h.n14=-t;t=-z*i+w;v=z*i+w;r.n11=2*k/(v-t);r.n13=(v+t)/(v-t);g.projectionMatrix.copy(r);t=-z*i-w;v=z*i-w;r.n11= -2*k/(v-t);r.n13=(v+t)/(v-t);f.projectionMatrix.copy(r)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,o,!0);f.matrixWorld.copy(b.matrixWorld).multiplySelf(e);f.position.copy(b.position);f.near=b.near;f.far=b.far;d.call(c,a,f,l,!0);m.updateMatrixWorld();d.call(c,m,s)}}; +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var c=this,b=this.setSize,d=this.render,g=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,e=new THREE.Matrix4,h=new THREE.Matrix4,i,k,j,q;g.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),s=new THREE.PerspectiveCamera(53, +1,1,1E4);s.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:n}},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}"}), +m=new THREE.Scene;m.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));m.add(s);this.setSize=function(a,d){b.call(c,a,d);o.width=a;o.height=d;n.width=a;n.height=d};this.render=function(a,b){a.updateMatrixWorld();if(i!==b.aspect||k!==b.near||j!==b.far||q!==b.fov){i=b.aspect;k=b.near;j=b.far;q=b.fov;var r=b.projectionMatrix.clone(),t=125/30*0.5,w=t*k/125,z=k*Math.tan(q*Math.PI/360),v;e.n14=t;h.n14=-t;t=-z*i+w;v=z*i+w;r.n11=2*k/(v-t);r.n13=(v+t)/(v-t);g.projectionMatrix.copy(r);t=-z*i-w;v=z*i-w;r.n11= +2*k/(v-t);r.n13=(v+t)/(v-t);f.projectionMatrix.copy(r)}g.matrixWorld.copy(b.matrixWorld).multiplySelf(h);g.position.copy(b.position);g.near=b.near;g.far=b.far;d.call(c,a,g,o,!0);f.matrixWorld.copy(b.matrixWorld).multiplySelf(e);f.position.copy(b.position);f.near=b.near;f.far=b.far;d.call(c,a,f,n,!0);m.updateMatrixWorld();d.call(c,m,s)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,d=this.render,g,f,e=new THREE.PerspectiveCamera;e.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;this.setSize=function(a,d){b.call(c,a,d);g=a/2;f=d};this.render=function(a,b){this.clear();e.fov=b.fov;e.aspect=0.5*b.aspect;e.near=b.near;e.far= b.far;e.updateProjectionMatrix();e.position.copy(b.position);e.target.copy(b.target);e.translateX(c.separation);e.lookAt(e.target);h.projectionMatrix=e.projectionMatrix;h.position.copy(b.position);h.target.copy(b.target);h.translateX(-c.separation);h.lookAt(h.target);this.setViewport(0,0,g,f);d.call(c,a,e);this.setViewport(g,0,g,f);d.call(c,a,h,!1)}}; diff --git a/build/custom/ThreeSVG.js b/build/custom/ThreeSVG.js index 0a09dc7f..9411c492 100644 --- a/build/custom/ThreeSVG.js +++ b/build/custom/ThreeSVG.js @@ -72,7 +72,7 @@ this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRo 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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= this.x,c=this.y,d=this.z,f=this.w,e=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+f*e+c*h-d*g;this.y=c*a+f*g+d*e-b*h;this.z=d*a+f*h+b*g-c*e;this.w=f*a-b*e-c*g-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,e=this.x,g=this.y,h=this.z,l=this.w,m=l*c+g*f-h*d,i=l*d+h*c-e*f,j=l*f+e*d-g*c,c=-e* c-g*d-h*f;b.x=m*l+c*-e+i*-h-j*-g;b.y=i*l+c*-g+j*-e-m*-h;b.z=j*l+c*-h+m*-g-i*-e;return b}}; -THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/f;d=Math.sin(d*e)/f;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,d,f,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,f,e,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; diff --git a/build/custom/ThreeWebGL.js b/build/custom/ThreeWebGL.js index b961efcd..dd73e3fe 100644 --- a/build/custom/ThreeWebGL.js +++ b/build/custom/ThreeWebGL.js @@ -72,7 +72,7 @@ this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(c);return this},setFromRo 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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= this.x,c=this.y,e=this.z,f=this.w,g=a.x,i=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-e*i;this.y=c*a+f*i+e*g-b*h;this.z=e*a+f*h+b*i-c*g;this.w=f*a-b*g-c*i-e*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,f=a.z,g=this.x,i=this.y,h=this.z,r=this.w,p=r*c+i*f-h*e,j=r*e+h*c-g*f,n=r*f+g*e-i*c,c=-g* c-i*e-h*f;b.x=p*r+c*-g+j*-h-n*-i;b.y=j*r+c*-i+n*-g-p*-h;b.z=n*r+c*-h+p*-i-j*-g;return b}}; -THREE.Quaternion.slerp=function(a,b,c,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*b+c.w*e;c.x=a.x*b+c.x*e;c.y=a.y*b+c.y*e;c.z=a.z*b+c.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; +THREE.Quaternion.slerp=function(a,b,c,e){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;f<0?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,f=-f):c.copy(b);if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),f=Math.sqrt(1-f*f);if(Math.abs(f)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*b+c.w*e;c.x=a.x*b+c.x*e;c.y=a.y*b+c.y*e;c.z=a.z*b+c.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3}; THREE.Face3=function(a,b,c,e,f,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,e,f,g,i){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=i;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; diff --git a/src/extras/geometries/SphereGeometry.js b/src/extras/geometries/SphereGeometry.js index 97347db8..bd14210f 100644 --- a/src/extras/geometries/SphereGeometry.js +++ b/src/extras/geometries/SphereGeometry.js @@ -1,112 +1,91 @@ /** * @author mr.doob / http://mrdoob.com/ - * based on http://papervision3d.googlecode.com/svn/trunk/as3/trunk/src/org/papervision3d/objects/primitives/Sphere.as */ -THREE.SphereGeometry = function ( radius, segmentsWidth, segmentsHeight ) { +THREE.SphereGeometry = function ( radius, segmentsWidth, segmentsHeight, phiStart, phiLength, thetaStart, thetaLength ) { THREE.Geometry.call( this ); - var radius = radius || 50, - gridX = segmentsWidth || 8, - gridY = segmentsHeight || 6; + var radius = radius || 50; + var segmentsX = segmentsWidth || 8; + var segmentsY = segmentsHeight || 6; - var i, j, pi = Math.PI; - var iHor = Math.max( 3, gridX ); - var iVer = Math.max( 2, gridY ); - var aVtc = []; + var phiStart = phiStart != undefined ? phiStart : 0; + var phiLength = phiLength != undefined ? phiLength : Math.PI * 2; - for ( j = 0; j < ( iVer + 1 ) ; j++ ) { + var thetaStart = thetaStart != undefined ? thetaStart : 0; + var thetaLength = thetaLength != undefined ? thetaLength : Math.PI; - var fRad1 = j / iVer; - var fZ = radius * Math.cos( fRad1 * pi ); - var fRds = radius * Math.sin( fRad1 * pi ); - var aRow = []; - var oVtx = 0; + var x, y, vertices = [], uvs = []; - for ( i = 0; i < iHor; i++ ) { + for ( y = 0; y <= segmentsY; y ++ ) { - var fRad2 = 2 * i / iHor; - var fX = fRds * Math.sin( fRad2 * pi ); - var fY = fRds * Math.cos( fRad2 * pi ); + var verticesRow = []; + var uvsRow = []; - if ( !( ( j == 0 || j == iVer ) && i > 0 ) ) { + for ( x = 0; x <= segmentsX; x ++ ) { - oVtx = this.vertices.push( new THREE.Vertex( new THREE.Vector3( fY, fZ, fX ) ) ) - 1; + var u = x / segmentsX; + var v = y / segmentsY; - } + var xpos = - radius * Math.cos( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); + var ypos = radius * Math.cos( thetaStart + v * thetaLength ); + var zpos = radius * Math.sin( phiStart + u * phiLength ) * Math.sin( thetaStart + v * thetaLength ); - aRow.push( oVtx ); + this.vertices.push( new THREE.Vertex( new THREE.Vector3( xpos, ypos, zpos ) ) ); + + verticesRow.push( this.vertices.length - 1 ); + uvsRow.push( new THREE.UV( u, v ) ); } - aVtc.push( aRow ); + vertices.push( verticesRow ); + uvs.push( uvsRow ); } - var n1, n2, n3, iVerNum = aVtc.length; + for ( y = 0; y < segmentsY; y ++ ) { - for ( j = 0; j < iVerNum; j++ ) { + for ( x = 0; x < segmentsX; x ++ ) { - var iHorNum = aVtc[ j ].length; + var v1 = vertices[ y ][ x + 1 ]; + var v2 = vertices[ y ][ x ]; + var v3 = vertices[ y + 1 ][ x ]; + var v4 = vertices[ y + 1 ][ x + 1 ]; - if ( j > 0 ) { + var n1 = this.vertices[ v1 ].position.clone().normalize(); + var n2 = this.vertices[ v2 ].position.clone().normalize(); + var n3 = this.vertices[ v3 ].position.clone().normalize(); + var n4 = this.vertices[ v4 ].position.clone().normalize(); - for ( i = 0; i < iHorNum; i++ ) { + var uv1 = uvs[ y ][ x + 1 ].clone(); + var uv2 = uvs[ y ][ x ].clone(); + var uv3 = uvs[ y + 1 ][ x ].clone(); + var uv4 = uvs[ y + 1 ][ x + 1 ].clone(); - var bEnd = i == ( iHorNum - 1 ); - var aP1 = aVtc[ j ][ bEnd ? 0 : i + 1 ]; - var aP2 = aVtc[ j ][ ( bEnd ? iHorNum - 1 : i ) ]; - var aP3 = aVtc[ j - 1 ][ ( bEnd ? iHorNum - 1 : i ) ]; - var aP4 = aVtc[ j - 1 ][ bEnd ? 0 : i + 1 ]; + if ( Math.abs( this.vertices[ v1 ].position.y ) == radius ) { - var fJ0 = j / ( iVerNum - 1 ); - var fJ1 = ( j - 1 ) / ( iVerNum - 1 ); - var fI0 = ( i + 1 ) / iHorNum; - var fI1 = i / iHorNum; + this.faces.push( new THREE.Face3( v1, v3, v4, [ n1, n3, n4 ] ) ); + this.faceVertexUvs[ 0 ].push( [ uv1, uv3, uv4 ] ); - var aP1uv = new THREE.UV( 1 - fI0, fJ0 ); - var aP2uv = new THREE.UV( 1 - fI1, fJ0 ); - var aP3uv = new THREE.UV( 1 - fI1, fJ1 ); - var aP4uv = new THREE.UV( 1 - fI0, fJ1 ); + } else if ( Math.abs( this.vertices[ v3 ].position.y ) == radius ) { - if ( j < ( aVtc.length - 1 ) ) { + this.faces.push( new THREE.Face3( v1, v2, v3, [ n1, n2, n3 ] ) ); + this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3 ] ); - n1 = this.vertices[ aP1 ].position.clone(); - n2 = this.vertices[ aP2 ].position.clone(); - n3 = this.vertices[ aP3 ].position.clone(); - n1.normalize(); - n2.normalize(); - n3.normalize(); + } else { - this.faces.push( new THREE.Face3( aP1, aP2, aP3, [ new THREE.Vector3( n1.x, n1.y, n1.z ), new THREE.Vector3( n2.x, n2.y, n2.z ), new THREE.Vector3( n3.x, n3.y, n3.z ) ] ) ); - - this.faceVertexUvs[ 0 ].push( [ aP1uv, aP2uv, aP3uv ] ); - - } - - if ( j > 1 ) { - - n1 = this.vertices[aP1].position.clone(); - n2 = this.vertices[aP3].position.clone(); - n3 = this.vertices[aP4].position.clone(); - n1.normalize(); - n2.normalize(); - n3.normalize(); - - this.faces.push( new THREE.Face3( aP1, aP3, aP4, [ new THREE.Vector3( n1.x, n1.y, n1.z ), new THREE.Vector3( n2.x, n2.y, n2.z ), new THREE.Vector3( n3.x, n3.y, n3.z ) ] ) ); - - this.faceVertexUvs[ 0 ].push( [ aP1uv, aP3uv, aP4uv ] ); - - } + this.faces.push( new THREE.Face4( v1, v2, v3, v4, [ n1, n2, n3, n4 ] ) ); + this.faceVertexUvs[ 0 ].push( [ uv1, uv2, uv3, uv4 ] ); } + } + } this.computeCentroids(); this.computeFaceNormals(); - this.computeVertexNormals(); this.boundingSphere = { radius: radius };