|
@@ -56,17 +56,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){thi
|
|
|
b)return h;if(c&&(h=h.getChildByName(b,c),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},update:function(b,c,e){this.matrixAutoUpdate&&
|
|
|
this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,e)},addChild:function(b){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(b)},removeChild:function(b){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
|
|
|
this.remove(b)}};THREE.Object3DCount=0;
|
|
|
-THREE.Projector=function(){function b(){var b=p[n]=p[n]||new THREE.RenderableVertex;n++;return b}function c(b,c){return c.z-b.z}function e(b,c){var e=0,f=1,k=b.z+b.w,h=c.z+c.w,m=-b.z+b.w,n=-c.z+c.w;return k>=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?e=Math.max(e,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?e=Math.max(e,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),f<e?!1:(b.lerpSelf(c,e),c.lerpSelf(b,1-f),!0))}var f,h,k=[],m,n,p=[],t,w,u=[],x,v=[],A,z,y=[],E,F,C=[],G=[],J=[],M=new THREE.Vector4,K=new THREE.Vector4,
|
|
|
+THREE.Projector=function(){function b(){var b=p[n]=p[n]||new THREE.RenderableVertex;n++;return b}function c(b,c){return c.z-b.z}function e(b,c){var e=0,f=1,h=b.z+b.w,k=c.z+c.w,m=-b.z+b.w,n=-c.z+c.w;return h>=0&&k>=0&&m>=0&&n>=0?!0:h<0&&k<0||m<0&&n<0?!1:(h<0?e=Math.max(e,h/(h-k)):k<0&&(f=Math.min(f,h/(h-k))),m<0?e=Math.max(e,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),f<e?!1:(b.lerpSelf(c,e),c.lerpSelf(b,1-f),!0))}var f,h,k=[],m,n,p=[],t,w,u=[],x,v=[],A,z,y=[],E,F,C=[],G=[],J=[],M=new THREE.Vector4,K=new THREE.Vector4,
|
|
|
B=new THREE.Matrix4,L=new THREE.Matrix4,Y=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],H=new THREE.Vector4,T=new THREE.Vector4;this.projectVector=function(b,c){B.multiply(c.projectionMatrix,c.matrixWorldInverse);B.multiplyVector3(b);return b};this.unprojectVector=function(b,c){B.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));B.multiplyVector3(b);return b};this.pickingRay=function(b,c){var e;b.z=-1;e=new THREE.Vector3(b.x,
|
|
|
b.y,1);this.unprojectVector(b,c);this.unprojectVector(e,c);e.subSelf(b).normalize();return new THREE.Ray(b,e)};this.projectObjects=function(b,e,m){var n,o;h=G.length=0;n=b.objects;b=0;for(e=n.length;b<e;b++){o=n[b];var p;if(!(p=!o.visible))if(p=o instanceof THREE.Mesh)if(p=o.frustumCulled){a:{p=void 0;for(var t=o.matrixWorld,v=-o.geometry.boundingSphere.radius*Math.max(o.scale.x,Math.max(o.scale.y,o.scale.z)),u=0;u<6;u++)if(p=Y[u].x*t.n14+Y[u].y*t.n24+Y[u].z*t.n34+Y[u].w,p<=v){p=!1;break a}p=!0}p=
|
|
|
-!p}if(!p)p=k[h]=k[h]||new THREE.RenderableObject,h++,f=p,M.copy(o.position),B.multiplyVector3(M),f.object=o,f.z=M.z,G.push(f)}m&&G.sort(c);return G};this.projectScene=function(f,k,h){var G=k.near,o=k.far,M,fa,ea,ha,ga,ka,na,aa,W,U,ia,ja,ta,la,ca,pa,ra;F=z=x=w=J.length=0;k.matrixAutoUpdate&&k.update(void 0,!0);f.update(void 0,!1,k);B.multiply(k.projectionMatrix,k.matrixWorldInverse);Y[0].set(B.n41-B.n11,B.n42-B.n12,B.n43-B.n13,B.n44-B.n14);Y[1].set(B.n41+B.n11,B.n42+B.n12,B.n43+B.n13,B.n44+B.n14);
|
|
|
-Y[2].set(B.n41+B.n21,B.n42+B.n22,B.n43+B.n23,B.n44+B.n24);Y[3].set(B.n41-B.n21,B.n42-B.n22,B.n43-B.n23,B.n44-B.n24);Y[4].set(B.n41-B.n31,B.n42-B.n32,B.n43-B.n33,B.n44-B.n34);Y[5].set(B.n41+B.n31,B.n42+B.n32,B.n43+B.n33,B.n44+B.n34);for(M=0;M<6;M++)W=Y[M],W.divideScalar(Math.sqrt(W.x*W.x+W.y*W.y+W.z*W.z));W=this.projectObjects(f,k,!0);f=0;for(M=W.length;f<M;f++)if(U=W[f].object,U.visible)if(ia=U.matrixWorld,ja=U.matrixRotationWorld,ta=U.materials,la=U.overdraw,n=0,U instanceof THREE.Mesh){ca=U.geometry;
|
|
|
+!p}if(!p)p=k[h]=k[h]||new THREE.RenderableObject,h++,f=p,M.copy(o.position),B.multiplyVector3(M),f.object=o,f.z=M.z,G.push(f)}m&&G.sort(c);return G};this.projectScene=function(f,h,k){var G=h.near,o=h.far,M,fa,ea,ha,ga,ka,na,aa,W,U,ia,ja,ta,la,ca,pa,ra;F=z=x=w=J.length=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);B.multiply(h.projectionMatrix,h.matrixWorldInverse);Y[0].set(B.n41-B.n11,B.n42-B.n12,B.n43-B.n13,B.n44-B.n14);Y[1].set(B.n41+B.n11,B.n42+B.n12,B.n43+B.n13,B.n44+B.n14);
|
|
|
+Y[2].set(B.n41+B.n21,B.n42+B.n22,B.n43+B.n23,B.n44+B.n24);Y[3].set(B.n41-B.n21,B.n42-B.n22,B.n43-B.n23,B.n44-B.n24);Y[4].set(B.n41-B.n31,B.n42-B.n32,B.n43-B.n33,B.n44-B.n34);Y[5].set(B.n41+B.n31,B.n42+B.n32,B.n43+B.n33,B.n44+B.n34);for(M=0;M<6;M++)W=Y[M],W.divideScalar(Math.sqrt(W.x*W.x+W.y*W.y+W.z*W.z));W=this.projectObjects(f,h,!0);f=0;for(M=W.length;f<M;f++)if(U=W[f].object,U.visible)if(ia=U.matrixWorld,ja=U.matrixRotationWorld,ta=U.materials,la=U.overdraw,n=0,U instanceof THREE.Mesh){ca=U.geometry;
|
|
|
ha=ca.vertices;pa=ca.faces;ca=ca.faceVertexUvs;fa=0;for(ea=ha.length;fa<ea;fa++)m=b(),m.positionWorld.copy(ha[fa].position),ia.multiplyVector3(m.positionWorld),m.positionScreen.copy(m.positionWorld),B.multiplyVector4(m.positionScreen),m.positionScreen.x/=m.positionScreen.w,m.positionScreen.y/=m.positionScreen.w,m.visible=m.positionScreen.z>G&&m.positionScreen.z<o;ha=0;for(fa=pa.length;ha<fa;ha++){ea=pa[ha];if(ea instanceof THREE.Face3)if(ga=p[ea.a],ka=p[ea.b],na=p[ea.c],ga.visible&&ka.visible&&na.visible&&
|
|
|
(U.doubleSided||U.flipSided!=(na.positionScreen.x-ga.positionScreen.x)*(ka.positionScreen.y-ga.positionScreen.y)-(na.positionScreen.y-ga.positionScreen.y)*(ka.positionScreen.x-ga.positionScreen.x)<0))aa=u[w]=u[w]||new THREE.RenderableFace3,w++,t=aa,t.v1.copy(ga),t.v2.copy(ka),t.v3.copy(na);else continue;else if(ea instanceof THREE.Face4)if(ga=p[ea.a],ka=p[ea.b],na=p[ea.c],aa=p[ea.d],ga.visible&&ka.visible&&na.visible&&aa.visible&&(U.doubleSided||U.flipSided!=((aa.positionScreen.x-ga.positionScreen.x)*
|
|
|
(ka.positionScreen.y-ga.positionScreen.y)-(aa.positionScreen.y-ga.positionScreen.y)*(ka.positionScreen.x-ga.positionScreen.x)<0||(ka.positionScreen.x-na.positionScreen.x)*(aa.positionScreen.y-na.positionScreen.y)-(ka.positionScreen.y-na.positionScreen.y)*(aa.positionScreen.x-na.positionScreen.x)<0)))ra=v[x]=v[x]||new THREE.RenderableFace4,x++,t=ra,t.v1.copy(ga),t.v2.copy(ka),t.v3.copy(na),t.v4.copy(aa);else continue;t.normalWorld.copy(ea.normal);ja.multiplyVector3(t.normalWorld);t.centroidWorld.copy(ea.centroid);
|
|
|
ia.multiplyVector3(t.centroidWorld);t.centroidScreen.copy(t.centroidWorld);B.multiplyVector3(t.centroidScreen);na=ea.vertexNormals;ga=0;for(ka=na.length;ga<ka;ga++)aa=t.vertexNormalsWorld[ga],aa.copy(na[ga]),ja.multiplyVector3(aa);ga=0;for(ka=ca.length;ga<ka;ga++)if(ra=ca[ga][ha]){na=0;for(aa=ra.length;na<aa;na++)t.uvs[ga][na]=ra[na]}t.meshMaterials=ta;t.faceMaterials=ea.materials;t.overdraw=la;t.z=t.centroidScreen.z;J.push(t)}}else if(U instanceof THREE.Line){L.multiply(B,ia);ha=U.geometry.vertices;
|
|
|
ga=b();ga.positionScreen.copy(ha[0].position);L.multiplyVector4(ga.positionScreen);fa=1;for(ea=ha.length;fa<ea;fa++)if(ga=b(),ga.positionScreen.copy(ha[fa].position),L.multiplyVector4(ga.positionScreen),ka=p[n-2],H.copy(ga.positionScreen),T.copy(ka.positionScreen),e(H,T))H.multiplyScalar(1/H.w),T.multiplyScalar(1/T.w),ia=y[z]=y[z]||new THREE.RenderableLine,z++,A=ia,A.v1.positionScreen.copy(H),A.v2.positionScreen.copy(T),A.z=Math.max(H.z,T.z),A.materials=U.materials,J.push(A)}else if(U instanceof THREE.Particle&&
|
|
|
-(K.set(U.matrixWorld.n14,U.matrixWorld.n24,U.matrixWorld.n34,1),B.multiplyVector4(K),K.z/=K.w,K.z>0&&K.z<1))ia=C[F]=C[F]||new THREE.RenderableParticle,F++,E=ia,E.x=K.x/K.w,E.y=K.y/K.w,E.z=K.z,E.rotation=U.rotation.z,E.scale.x=U.scale.x*Math.abs(E.x-(K.x+k.projectionMatrix.n11)/(K.w+k.projectionMatrix.n14)),E.scale.y=U.scale.y*Math.abs(E.y-(K.y+k.projectionMatrix.n22)/(K.w+k.projectionMatrix.n24)),E.materials=U.materials,J.push(E);h&&J.sort(c);return J}};
|
|
|
+(K.set(U.matrixWorld.n14,U.matrixWorld.n24,U.matrixWorld.n34,1),B.multiplyVector4(K),K.z/=K.w,K.z>0&&K.z<1))ia=C[F]=C[F]||new THREE.RenderableParticle,F++,E=ia,E.x=K.x/K.w,E.y=K.y/K.w,E.z=K.z,E.rotation=U.rotation.z,E.scale.x=U.scale.x*Math.abs(E.x-(K.x+h.projectionMatrix.n11)/(K.w+h.projectionMatrix.n14)),E.scale.y=U.scale.y*Math.abs(E.y-(K.y+h.projectionMatrix.n22)/(K.w+h.projectionMatrix.n24)),E.materials=U.materials,J.push(E);k&&J.sort(c);return J}};
|
|
|
THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
|
|
|
THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),m=b*c,n=f*h;this.w=m*k-n*e;this.x=m*e+n*k;this.y=f*c*k+b*h*e;this.z=b*h*k-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);
|
|
|
this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z);
|
|
@@ -81,15 +81,15 @@ c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid
|
|
|
e,f,h,k,m,n=new THREE.Vector3,p=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){k=this.faces[f];if(b&&k.vertexNormals.length){n.set(0,0,0);c=0;for(e=k.vertexNormals.length;c<e;c++)n.addSelf(k.vertexNormals[c]);n.divideScalar(3)}else c=this.vertices[k.a],e=this.vertices[k.b],m=this.vertices[k.c],n.sub(m.position,e.position),p.sub(c.position,e.position),n.crossSelf(p);n.isZero()||n.normalize();k.normal.copy(n)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=
|
|
|
Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof
|
|
|
THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),
|
|
|
-e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,c,e,f,k,h,B){n=b.vertices[c].position;p=b.vertices[e].position;t=b.vertices[f].position;w=m[k];u=m[h];x=m[B];v=p.x-n.x;A=t.x-n.x;z=p.y-n.y;y=t.y-n.y;E=p.z-n.z;F=t.z-n.z;C=u.u-w.u;G=x.u-w.u;J=u.v-w.v;M=x.v-w.v;K=1/(C*M-G*J);H.set((M*v-J*A)*K,(M*z-J*y)*K,(M*E-J*F)*K);T.set((C*A-G*v)*K,(C*y-G*z)*K,(C*F-G*E)*K);L[c].addSelf(H);L[e].addSelf(H);L[f].addSelf(H);Y[c].addSelf(T);
|
|
|
+e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,c,e,f,h,k,B){n=b.vertices[c].position;p=b.vertices[e].position;t=b.vertices[f].position;w=m[h];u=m[k];x=m[B];v=p.x-n.x;A=t.x-n.x;z=p.y-n.y;y=t.y-n.y;E=p.z-n.z;F=t.z-n.z;C=u.u-w.u;G=x.u-w.u;J=u.v-w.v;M=x.v-w.v;K=1/(C*M-G*J);H.set((M*v-J*A)*K,(M*z-J*y)*K,(M*E-J*F)*K);T.set((C*A-G*v)*K,(C*y-G*z)*K,(C*F-G*E)*K);L[c].addSelf(H);L[e].addSelf(H);L[f].addSelf(H);Y[c].addSelf(T);
|
|
|
Y[e].addSelf(T);Y[f].addSelf(T)}var c,e,f,h,k,m,n,p,t,w,u,x,v,A,z,y,E,F,C,G,J,M,K,B,L=[],Y=[],H=new THREE.Vector3,T=new THREE.Vector3,Q=new THREE.Vector3,Z=new THREE.Vector3,$=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)L[c]=new THREE.Vector3,Y[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)k=this.faces[c],m=this.faceVertexUvs[0][c],k instanceof THREE.Face3?b(this,k.a,k.b,k.c,0,1,2):k instanceof THREE.Face4&&(b(this,k.a,k.b,k.c,0,1,2),b(this,k.a,k.b,k.d,0,1,3));var P=["a","b",
|
|
|
"c","d"];c=0;for(e=this.faces.length;c<e;c++){k=this.faces[c];for(f=0;f<k.vertexNormals.length;f++)$.copy(k.vertexNormals[f]),h=k[P[f]],B=L[h],Q.copy(B),Q.subSelf($.multiplyScalar($.dot(B))).normalize(),Z.cross(k.vertexNormals[f],B),h=Z.dot(Y[h]),h=h<0?-1:1,k.vertexTangents[f]=new THREE.Vector4(Q.x,Q.y,Q.z,h)}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,
|
|
|
this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,e=this.vertices.length;c<e;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
|
|
|
b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},mergeVertices:function(){var b={},c=[],e=[],f,h=Math.pow(10,4),k,m;k=0;for(m=this.vertices.length;k<m;k++)f=this.vertices[k].position,f=[Math.round(f.x*h),Math.round(f.y*h),Math.round(f.z*h)].join("_"),b[f]===void 0?(b[f]=k,c.push(this.vertices[k]),
|
|
|
e[k]=c.length-1):e[k]=e[b[f]];k=0;for(m=this.faces.length;k<m;k++){b=this.faces[k];if(b instanceof THREE.Face3)b.a=e[b.a],b.b=e[b.b],b.c=e[b.c];if(b instanceof THREE.Face4)b.a=e[b.a],b.b=e[b.b],b.c=e[b.c],b.d=e[b.d]}this.vertices=c}};THREE.GeometryCount=0;
|
|
|
-THREE.Spline=function(b){function c(b,c,e,f,k,h,m){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*m+(-3*(c-e)-2*b-f)*h+b*k+c}this.points=b;var e=[],f={x:0,y:0,z:0},h,k,m,n,p,t,w,u,x;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;k=Math.floor(h);m=h-k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>this.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;t=this.points[e[0]];w=this.points[e[1]];
|
|
|
-u=this.points[e[2]];x=this.points[e[3]];n=m*m;p=m*n;f.x=c(t.x,w.x,u.x,x.x,m,n,p);f.y=c(t.y,w.y,u.y,x.y,m,n,p);f.z=c(t.z,w.z,u.z,x.z,m,n,p);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b<e;b++)c=this.points[b],f[b]=[c.x,c.y,c.z];return f};this.getLength=function(b){var c,e,f=c=c=0,k=new THREE.Vector3,h=new THREE.Vector3,m=[],n=0;m[0]=0;b||(b=100);e=this.points.length*b;k.copy(this.points[0]);for(b=1;b<e;b++)c=b/e,position=this.getPoint(c),h.copy(position),
|
|
|
-n+=h.distanceTo(k),k.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=f&&(m[c]=n,f=c);m[m.length]=n;return{chunks:m,total:n}};this.reparametrizeByArcLength=function(b){var c,e,f,k,h,m,n=[],p=new THREE.Vector3,t=this.getLength();n.push(p.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){e=t.chunks[c]-t.chunks[c-1];m=Math.ceil(b*e/t.total);k=(c-1)/(this.points.length-1);h=c/(this.points.length-1);for(e=1;e<m-1;e++)f=k+e*(1/m)*(h-k),position=this.getPoint(f),n.push(p.copy(position).clone());
|
|
|
+THREE.Spline=function(b){function c(b,c,e,f,h,k,m){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*m+(-3*(c-e)-2*b-f)*k+b*h+c}this.points=b;var e=[],f={x:0,y:0,z:0},h,k,m,n,p,t,w,u,x;this.initFromArray=function(b){this.points=[];for(var c=0;c<b.length;c++)this.points[c]={x:b[c][0],y:b[c][1],z:b[c][2]}};this.getPoint=function(b){h=(this.points.length-1)*b;k=Math.floor(h);m=h-k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>this.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;t=this.points[e[0]];w=this.points[e[1]];
|
|
|
+u=this.points[e[2]];x=this.points[e[3]];n=m*m;p=m*n;f.x=c(t.x,w.x,u.x,x.x,m,n,p);f.y=c(t.y,w.y,u.y,x.y,m,n,p);f.z=c(t.z,w.z,u.z,x.z,m,n,p);return f};this.getControlPointsArray=function(){var b,c,e=this.points.length,f=[];for(b=0;b<e;b++)c=this.points[b],f[b]=[c.x,c.y,c.z];return f};this.getLength=function(b){var c,e,f=c=c=0,h=new THREE.Vector3,k=new THREE.Vector3,m=[],n=0;m[0]=0;b||(b=100);e=this.points.length*b;h.copy(this.points[0]);for(b=1;b<e;b++)c=b/e,position=this.getPoint(c),k.copy(position),
|
|
|
+n+=k.distanceTo(h),h.copy(position),c*=this.points.length-1,c=Math.floor(c),c!=f&&(m[c]=n,f=c);m[m.length]=n;return{chunks:m,total:n}};this.reparametrizeByArcLength=function(b){var c,e,f,h,k,m,n=[],p=new THREE.Vector3,t=this.getLength();n.push(p.copy(this.points[0]).clone());for(c=1;c<this.points.length;c++){e=t.chunks[c]-t.chunks[c-1];m=Math.ceil(b*e/t.total);h=(c-1)/(this.points.length-1);k=c/(this.points.length-1);for(e=1;e<m-1;e++)f=h+e*(1/m)*(k-h),position=this.getPoint(f),n.push(p.copy(position).clone());
|
|
|
n.push(p.copy(this.points[c]).clone())}this.points=n}};THREE.Edge=function(b,c,e,f){this.vertices=[b,c];this.vertexIndices=[e,f];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};
|
|
|
THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};
|
|
|
THREE.Camera.prototype.update=function(b,c,e){this.matrixAutoUpdate&&this.updateMatrix();if(c||this.matrixWorldNeedsUpdate)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,c=!0,THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,c,e)};
|
|
@@ -157,10 +157,10 @@ THREE.CanvasRenderer=function(b){function c(b){if(y!=b)v.globalAlpha=y=b}functio
|
|
|
t,w,u,x,v=p.getContext("2d"),A=new THREE.Color(0),z=0,y=1,E=0,F=null,C=null,G=null,J=null,M=null,K,B,L,Y,H=new THREE.RenderableVertex,T=new THREE.RenderableVertex,Q,Z,$,P,o,V,fa,ea,ha,ga,ka,na,aa=new THREE.Color(0),W=new THREE.Color(0),U=new THREE.Color(0),ia=new THREE.Color(0),ja=new THREE.Color(0),ta=[],la,ca,pa,ra,sa,ya,Ca,Ga,Fa,Da,za=new THREE.Rectangle,S=new THREE.Rectangle,O=new THREE.Rectangle,da=!1,qa=new THREE.Color,N=new THREE.Color,ma=new THREE.Color,ua=new THREE.Color,oa=new THREE.Vector3,
|
|
|
Ea,Ia,Ba,va,Ka,Ha,b=16;Ea=document.createElement("canvas");Ea.width=Ea.height=2;Ia=Ea.getContext("2d");Ia.fillStyle="rgba(0,0,0,1)";Ia.fillRect(0,0,2,2);Ba=Ia.getImageData(0,0,2,2);va=Ba.data;Ka=document.createElement("canvas");Ka.width=Ka.height=b;Ha=Ka.getContext("2d");Ha.translate(-b/2,-b/2);Ha.scale(b,b);b--;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(b,c){t=b;w=c;u=Math.floor(t/2);x=Math.floor(w/2);p.width=
|
|
|
t;p.height=w;za.set(-u,-x,u,x);S.set(-u,-x,u,x);y=1;E=0;M=J=G=C=F=null};this.setClearColor=function(b,c){A.copy(b);z=c;S.set(-u,-x,u,x)};this.setClearColorHex=function(b,c){A.setHex(b);z=c;S.set(-u,-x,u,x)};this.clear=function(){v.setTransform(1,0,0,-1,u,x);S.isEmpty()||(S.minSelf(za),S.inflate(2),z<1&&v.clearRect(Math.floor(S.getX()),Math.floor(S.getY()),Math.floor(S.getWidth()),Math.floor(S.getHeight())),z>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(A.r*255)+","+Math.floor(A.g*255)+","+
|
|
|
-Math.floor(A.b*255)+","+z+")"),v.fillRect(Math.floor(S.getX()),Math.floor(S.getY()),Math.floor(S.getWidth()),Math.floor(S.getHeight()))),S.empty())};this.render=function(b,p){function t(b){var c,e,f,k=b.lights;N.setRGB(0,0,0);ma.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(c=k.length;b<c;b++)e=k[b],f=e.color,e instanceof THREE.AmbientLight?(N.r+=f.r,N.g+=f.g,N.b+=f.b):e instanceof THREE.DirectionalLight?(ma.r+=f.r,ma.g+=f.g,ma.b+=f.b):e instanceof THREE.PointLight&&(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b)}function w(b,
|
|
|
-c,e,f){var k,h,m,o,n=b.lights,b=0;for(k=n.length;b<k;b++)h=n[b],m=h.color,h instanceof THREE.DirectionalLight?(o=e.dot(h.position),o<=0||(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)):h instanceof THREE.PointLight&&(o=e.dot(oa.sub(h.position,c).normalize()),o<=0||(o*=h.distance==0?1:1-Math.min(c.distanceTo(h.position)/h.distance,1),o!=0&&(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)))}function z(b,k,m){c(m.opacity);e(m.blending);var o,n,p,t,w,xa;if(m instanceof THREE.ParticleBasicMaterial){if(m.map)t=
|
|
|
+Math.floor(A.b*255)+","+z+")"),v.fillRect(Math.floor(S.getX()),Math.floor(S.getY()),Math.floor(S.getWidth()),Math.floor(S.getHeight()))),S.empty())};this.render=function(b,p){function t(b){var c,e,f,h=b.lights;N.setRGB(0,0,0);ma.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(c=h.length;b<c;b++)e=h[b],f=e.color,e instanceof THREE.AmbientLight?(N.r+=f.r,N.g+=f.g,N.b+=f.b):e instanceof THREE.DirectionalLight?(ma.r+=f.r,ma.g+=f.g,ma.b+=f.b):e instanceof THREE.PointLight&&(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b)}function w(b,
|
|
|
+c,e,f){var h,k,m,o,n=b.lights,b=0;for(h=n.length;b<h;b++)k=n[b],m=k.color,k instanceof THREE.DirectionalLight?(o=e.dot(k.position),o<=0||(o*=k.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)):k instanceof THREE.PointLight&&(o=e.dot(oa.sub(k.position,c).normalize()),o<=0||(o*=k.distance==0?1:1-Math.min(c.distanceTo(k.position)/k.distance,1),o!=0&&(o*=k.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)))}function z(b,k,m){c(m.opacity);e(m.blending);var o,n,p,t,w,xa;if(m instanceof THREE.ParticleBasicMaterial){if(m.map)t=
|
|
|
m.map.image,w=t.width>>1,xa=t.height>>1,m=k.scale.x*u,p=k.scale.y*x,o=m*w,n=p*xa,O.set(b.x-o,b.y-n,b.x+o,b.y+n),za.intersects(O)&&(v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(m,-p),v.translate(-w,-xa),v.drawImage(t,0,0),v.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*u,n=k.scale.y*x,O.set(b.x-o,b.y-n,b.x+o,b.y+n),za.intersects(O)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(o,n),m.program(v),
|
|
|
-v.restore()))}function eb(b,k,h,m){c(m.opacity);e(m.blending);v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(k.positionScreen.x,k.positionScreen.y);v.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)v.lineWidth=G=b;b=m.linecap;if(J!=b)v.lineCap=J=b;b=m.linejoin;if(M!=b)v.lineJoin=M=b;f(m.color.getContextStyle());v.stroke();O.inflate(m.linewidth*2)}}function y(b,f,h,m,n,t,u,v,xa){k.info.render.vertices+=3;k.info.render.faces++;c(v.opacity);e(v.blending);
|
|
|
+v.restore()))}function eb(b,h,k,m){c(m.opacity);e(m.blending);v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(h.positionScreen.x,h.positionScreen.y);v.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)v.lineWidth=G=b;b=m.linecap;if(J!=b)v.lineCap=J=b;b=m.linejoin;if(M!=b)v.lineJoin=M=b;f(m.color.getContextStyle());v.stroke();O.inflate(m.linewidth*2)}}function y(b,f,h,m,n,t,u,v,xa){k.info.render.vertices+=3;k.info.render.faces++;c(v.opacity);e(v.blending);
|
|
|
Q=b.positionScreen.x;Z=b.positionScreen.y;$=f.positionScreen.x;P=f.positionScreen.y;o=h.positionScreen.x;V=h.positionScreen.y;F(Q,Z,$,P,o,V);if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&(ra=u.uvs[0],ab(Q,Z,$,P,o,V,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map));else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=p.matrixWorldInverse,oa.copy(u.vertexNormalsWorld[0]),sa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,ya=
|
|
|
-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(u.vertexNormalsWorld[1]),Ca=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Ga=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(u.vertexNormalsWorld[2]),Fa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Da=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,ab(Q,Z,$,P,o,V,sa,ya,Ca,Ga,Fa,Da,v.envMap)}else v.wireframe?Na(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):C(v.color);else if(v instanceof THREE.MeshLambertMaterial)v.map&&!v.wireframe&&
|
|
|
(v.map.mapping instanceof THREE.UVMapping&&(ra=u.uvs[0],ab(Q,Z,$,P,o,V,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map)),e(THREE.SubtractiveBlending)),da?!v.wireframe&&v.shading==THREE.SmoothShading&&u.vertexNormalsWorld.length==3?(W.r=U.r=ia.r=N.r,W.g=U.g=ia.g=N.g,W.b=U.b=ia.b=N.b,w(xa,u.v1.positionWorld,u.vertexNormalsWorld[0],W),w(xa,u.v2.positionWorld,u.vertexNormalsWorld[1],U),w(xa,u.v3.positionWorld,u.vertexNormalsWorld[2],ia),W.r=Math.max(0,Math.min(v.color.r*W.r,1)),W.g=Math.max(0,Math.min(v.color.g*
|
|
@@ -171,18 +171,18 @@ $=f.positionScreen.x,P=f.positionScreen.y,o=h.positionScreen.x,V=h.positionScree
|
|
|
U.r=ia.r=ja.r=N.r,W.g=U.g=ia.g=ja.g=N.g,W.b=U.b=ia.b=ja.b=N.b,w(xa,v.v1.positionWorld,v.vertexNormalsWorld[0],W),w(xa,v.v2.positionWorld,v.vertexNormalsWorld[1],U),w(xa,v.v4.positionWorld,v.vertexNormalsWorld[3],ia),w(xa,v.v3.positionWorld,v.vertexNormalsWorld[2],ja),W.r=Math.max(0,Math.min(u.color.r*W.r,1)),W.g=Math.max(0,Math.min(u.color.g*W.g,1)),W.b=Math.max(0,Math.min(u.color.b*W.b,1)),U.r=Math.max(0,Math.min(u.color.r*U.r,1)),U.g=Math.max(0,Math.min(u.color.g*U.g,1)),U.b=Math.max(0,Math.min(u.color.b*
|
|
|
U.b,1)),ia.r=Math.max(0,Math.min(u.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(u.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(u.color.b*ia.b,1)),ja.r=Math.max(0,Math.min(u.color.r*ja.r,1)),ja.g=Math.max(0,Math.min(u.color.g*ja.g,1)),ja.b=Math.max(0,Math.min(u.color.b*ja.b,1)),pa=Ya(W,U,ia,ja),F(Q,Z,$,P,fa,ea),Ua(Q,Z,$,P,fa,ea,0,0,1,0,0,1,pa),F(ha,ga,o,V,ka,na),Ua(ha,ga,o,V,ka,na,1,0,1,1,0,1,pa)):(qa.r=N.r,qa.g=N.g,qa.b=N.b,w(xa,v.centroidWorld,v.normalWorld,qa),aa.r=Math.max(0,Math.min(u.color.r*qa.r,
|
|
|
1)),aa.g=Math.max(0,Math.min(u.color.g*qa.g,1)),aa.b=Math.max(0,Math.min(u.color.b*qa.b,1)),E(Q,Z,$,P,o,V,fa,ea),u.wireframe?Na(aa,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):C(aa)):(E(Q,Z,$,P,o,V,fa,ea),u.wireframe?Na(u.color,u.wireframeLinewidth,u.wireframeLinecap,u.wireframeLinejoin):C(u.color));else if(u instanceof THREE.MeshNormalMaterial)aa.r=Va(v.normalWorld.x),aa.g=Va(v.normalWorld.y),aa.b=Va(v.normalWorld.z),E(Q,Z,$,P,o,V,fa,ea),u.wireframe?Na(aa,u.wireframeLinewidth,u.wireframeLinecap,
|
|
|
-u.wireframeLinejoin):C(aa);else if(u instanceof THREE.MeshDepthMaterial)la=p.near,ca=p.far,W.r=W.g=W.b=1-Qa(b.positionScreen.z,la,ca),U.r=U.g=U.b=1-Qa(f.positionScreen.z,la,ca),ia.r=ia.g=ia.b=1-Qa(m.positionScreen.z,la,ca),ja.r=ja.g=ja.b=1-Qa(h.positionScreen.z,la,ca),pa=Ya(W,U,ia,ja),F(Q,Z,$,P,fa,ea),Ua(Q,Z,$,P,fa,ea,0,0,1,0,0,1,pa),F(ha,ga,o,V,ka,na),Ua(ha,ga,o,V,ka,na,1,0,1,1,0,1,pa)}function F(b,c,e,f,k,h){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(k,h);v.lineTo(b,c);v.closePath()}function E(b,
|
|
|
-c,e,f,k,h,m,o){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(k,h);v.lineTo(m,o);v.lineTo(b,c);v.closePath()}function Na(b,c,e,k){if(G!=c)v.lineWidth=G=c;if(J!=e)v.lineCap=J=e;if(M!=k)v.lineJoin=M=k;f(b.getContextStyle());v.stroke();O.inflate(c*2)}function C(b){h(b.getContextStyle());v.fill()}function ab(b,c,e,f,k,m,o,n,p,u,t,xa,w){if(w.image.width!=0){if(w.needsUpdate==!0||ta[w.id]==void 0){var x=w.wrapS==THREE.RepeatWrapping,S=w.wrapT==THREE.RepeatWrapping;ta[w.id]=v.createPattern(w.image,x&&
|
|
|
-S?"repeat":x&&!S?"repeat-x":!x&&S?"repeat-y":"no-repeat");w.needsUpdate=!1}h(ta[w.id]);var x=w.offset.x/w.repeat.x,S=w.offset.y/w.repeat.y,z=(w.image.width-1)*w.repeat.x,w=(w.image.height-1)*w.repeat.y,o=(o+x)*z,n=(n+S)*w,p=(p+x)*z,u=(u+S)*w,t=(t+x)*z,xa=(xa+S)*w;e-=b;f-=c;k-=b;m-=c;p-=o;u-=n;t-=o;xa-=n;x=1/(p*xa-t*u);w=(xa*e-u*k)*x;u=(xa*f-u*m)*x;e=(p*k-t*e)*x;f=(p*m-t*f)*x;b=b-w*o-e*n;c=c-u*o-f*n;v.save();v.transform(w,u,e,f,b,c);v.fill();v.restore()}}function Ua(b,c,e,f,k,h,m,o,n,p,u,t,w){var xa,
|
|
|
-x;xa=w.width-1;x=w.height-1;m*=xa;o*=x;n*=xa;p*=x;u*=xa;t*=x;e-=b;f-=c;k-=b;h-=c;n-=m;p-=o;u-=m;t-=o;x=1/(n*t-u*p);xa=(t*e-p*k)*x;p=(t*f-p*h)*x;e=(n*k-u*e)*x;f=(n*h-u*f)*x;b=b-xa*m-e*o;c=c-p*m-f*o;v.save();v.transform(xa,p,e,f,b,c);v.clip();v.drawImage(w,0,0);v.restore()}function Ya(b,c,e,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),n=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);va[0]=k<0?0:k>255?255:k;va[1]=h<0?0:
|
|
|
-h>255?255:h;va[2]=b<0?0:b>255?255:b;va[4]=m<0?0:m>255?255:m;va[5]=o<0?0:o>255?255:o;va[6]=c<0?0:c>255?255:c;va[8]=n<0?0:n>255?255:n;va[9]=p<0?0:p>255?255:p;va[10]=e<0?0:e>255?255:e;va[12]=u<0?0:u>255?255:u;va[13]=t<0?0:t>255?255:t;va[14]=f<0?0:f>255?255:f;Ia.putImageData(Ba,0,0);Ha.drawImage(Ea,0,0);return Ka}function Qa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Va(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Oa(b,c){var e=c.x-b.x,f=c.y-b.y,k=e*e+f*f;k!=0&&(k=1/Math.sqrt(k),e*=k,f*=k,c.x+=
|
|
|
+u.wireframeLinejoin):C(aa);else if(u instanceof THREE.MeshDepthMaterial)la=p.near,ca=p.far,W.r=W.g=W.b=1-Qa(b.positionScreen.z,la,ca),U.r=U.g=U.b=1-Qa(f.positionScreen.z,la,ca),ia.r=ia.g=ia.b=1-Qa(m.positionScreen.z,la,ca),ja.r=ja.g=ja.b=1-Qa(h.positionScreen.z,la,ca),pa=Ya(W,U,ia,ja),F(Q,Z,$,P,fa,ea),Ua(Q,Z,$,P,fa,ea,0,0,1,0,0,1,pa),F(ha,ga,o,V,ka,na),Ua(ha,ga,o,V,ka,na,1,0,1,1,0,1,pa)}function F(b,c,e,f,h,k){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(h,k);v.lineTo(b,c);v.closePath()}function E(b,
|
|
|
+c,e,f,h,k,m,o){v.beginPath();v.moveTo(b,c);v.lineTo(e,f);v.lineTo(h,k);v.lineTo(m,o);v.lineTo(b,c);v.closePath()}function Na(b,c,e,h){if(G!=c)v.lineWidth=G=c;if(J!=e)v.lineCap=J=e;if(M!=h)v.lineJoin=M=h;f(b.getContextStyle());v.stroke();O.inflate(c*2)}function C(b){h(b.getContextStyle());v.fill()}function ab(b,c,e,f,k,m,o,n,p,u,t,xa,w){if(w.image.width!=0){if(w.needsUpdate==!0||ta[w.id]==void 0){var x=w.wrapS==THREE.RepeatWrapping,S=w.wrapT==THREE.RepeatWrapping;ta[w.id]=v.createPattern(w.image,x&&
|
|
|
+S?"repeat":x&&!S?"repeat-x":!x&&S?"repeat-y":"no-repeat");w.needsUpdate=!1}h(ta[w.id]);var x=w.offset.x/w.repeat.x,S=w.offset.y/w.repeat.y,z=(w.image.width-1)*w.repeat.x,w=(w.image.height-1)*w.repeat.y,o=(o+x)*z,n=(n+S)*w,p=(p+x)*z,u=(u+S)*w,t=(t+x)*z,xa=(xa+S)*w;e-=b;f-=c;k-=b;m-=c;p-=o;u-=n;t-=o;xa-=n;x=1/(p*xa-t*u);w=(xa*e-u*k)*x;u=(xa*f-u*m)*x;e=(p*k-t*e)*x;f=(p*m-t*f)*x;b=b-w*o-e*n;c=c-u*o-f*n;v.save();v.transform(w,u,e,f,b,c);v.fill();v.restore()}}function Ua(b,c,e,f,h,k,m,o,n,p,u,t,w){var xa,
|
|
|
+x;xa=w.width-1;x=w.height-1;m*=xa;o*=x;n*=xa;p*=x;u*=xa;t*=x;e-=b;f-=c;h-=b;k-=c;n-=m;p-=o;u-=m;t-=o;x=1/(n*t-u*p);xa=(t*e-p*h)*x;p=(t*f-p*k)*x;e=(n*h-u*e)*x;f=(n*k-u*f)*x;b=b-xa*m-e*o;c=c-p*m-f*o;v.save();v.transform(xa,p,e,f,b,c);v.clip();v.drawImage(w,0,0);v.restore()}function Ya(b,c,e,f){var h=~~(b.r*255),k=~~(b.g*255),b=~~(b.b*255),m=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),n=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);va[0]=h<0?0:h>255?255:h;va[1]=k<0?0:
|
|
|
+k>255?255:k;va[2]=b<0?0:b>255?255:b;va[4]=m<0?0:m>255?255:m;va[5]=o<0?0:o>255?255:o;va[6]=c<0?0:c>255?255:c;va[8]=n<0?0:n>255?255:n;va[9]=p<0?0:p>255?255:p;va[10]=e<0?0:e>255?255:e;va[12]=u<0?0:u>255?255:u;va[13]=t<0?0:t>255?255:t;va[14]=f<0?0:f>255?255:f;Ia.putImageData(Ba,0,0);Ha.drawImage(Ea,0,0);return Ka}function Qa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Va(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Oa(b,c){var e=c.x-b.x,f=c.y-b.y,h=e*e+f*f;h!=0&&(h=1/Math.sqrt(h),e*=h,f*=h,c.x+=
|
|
|
e,c.y+=f,b.x-=e,b.y-=f)}var Za,bb,wa,Ja,Pa,Wa,$a,Aa;this.autoClear?this.clear():v.setTransform(1,0,0,-1,u,x);k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,p,this.sortElements);(da=b.lights.length>0)&&t(b);Za=0;for(bb=m.length;Za<bb;Za++){wa=m[Za];O.empty();if(wa instanceof THREE.RenderableParticle){K=wa;K.x*=u;K.y*=x;Ja=0;for(Pa=wa.materials.length;Ja<Pa;)Aa=wa.materials[Ja++],Aa.opacity!=0&&z(K,wa,Aa,b)}else if(wa instanceof THREE.RenderableLine){if(K=wa.v1,B=wa.v2,K.positionScreen.x*=
|
|
|
u,K.positionScreen.y*=x,B.positionScreen.x*=u,B.positionScreen.y*=x,O.addPoint(K.positionScreen.x,K.positionScreen.y),O.addPoint(B.positionScreen.x,B.positionScreen.y),za.intersects(O)){Ja=0;for(Pa=wa.materials.length;Ja<Pa;)Aa=wa.materials[Ja++],Aa.opacity!=0&&eb(K,B,wa,Aa,b)}}else if(wa instanceof THREE.RenderableFace3){if(K=wa.v1,B=wa.v2,L=wa.v3,K.positionScreen.x*=u,K.positionScreen.y*=x,B.positionScreen.x*=u,B.positionScreen.y*=x,L.positionScreen.x*=u,L.positionScreen.y*=x,wa.overdraw&&(Oa(K.positionScreen,
|
|
|
B.positionScreen),Oa(B.positionScreen,L.positionScreen),Oa(L.positionScreen,K.positionScreen)),O.add3Points(K.positionScreen.x,K.positionScreen.y,B.positionScreen.x,B.positionScreen.y,L.positionScreen.x,L.positionScreen.y),za.intersects(O)){Ja=0;for(Pa=wa.meshMaterials.length;Ja<Pa;)if(Aa=wa.meshMaterials[Ja++],Aa instanceof THREE.MeshFaceMaterial){Wa=0;for($a=wa.faceMaterials.length;Wa<$a;)(Aa=wa.faceMaterials[Wa++])&&Aa.opacity!=0&&y(K,B,L,0,1,2,wa,Aa,b)}else Aa.opacity!=0&&y(K,B,L,0,1,2,wa,Aa,
|
|
|
b)}}else if(wa instanceof THREE.RenderableFace4&&(K=wa.v1,B=wa.v2,L=wa.v3,Y=wa.v4,K.positionScreen.x*=u,K.positionScreen.y*=x,B.positionScreen.x*=u,B.positionScreen.y*=x,L.positionScreen.x*=u,L.positionScreen.y*=x,Y.positionScreen.x*=u,Y.positionScreen.y*=x,H.positionScreen.copy(B.positionScreen),T.positionScreen.copy(Y.positionScreen),wa.overdraw&&(Oa(K.positionScreen,B.positionScreen),Oa(B.positionScreen,Y.positionScreen),Oa(Y.positionScreen,K.positionScreen),Oa(L.positionScreen,H.positionScreen),
|
|
|
Oa(L.positionScreen,T.positionScreen)),O.addPoint(K.positionScreen.x,K.positionScreen.y),O.addPoint(B.positionScreen.x,B.positionScreen.y),O.addPoint(L.positionScreen.x,L.positionScreen.y),O.addPoint(Y.positionScreen.x,Y.positionScreen.y),za.intersects(O))){Ja=0;for(Pa=wa.meshMaterials.length;Ja<Pa;)if(Aa=wa.meshMaterials[Ja++],Aa instanceof THREE.MeshFaceMaterial){Wa=0;for($a=wa.faceMaterials.length;Wa<$a;)(Aa=wa.faceMaterials[Wa++])&&Aa.opacity!=0&&A(K,B,L,Y,H,T,wa,Aa,b)}else Aa.opacity!=0&&A(K,
|
|
|
B,L,Y,H,T,wa,Aa,b)}S.addRectangle(O)}v.setTransform(1,0,0,1,0,0)}};
|
|
|
-THREE.SVGRenderer=function(){function b(b,c,e){var f,k,h,m;f=0;for(k=b.lights.length;f<k;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(m=c.normalWorld.dot(h.position)*h.intensity,m>0&&(e.r+=h.color.r*m,e.g+=h.color.g*m,e.b+=h.color.b*m)):h instanceof THREE.PointLight&&(Y.sub(h.position,c.centroidWorld),Y.normalize(),m=c.normalWorld.dot(Y)*h.intensity,m>0&&(e.r+=h.color.r*m,e.g+=h.color.g*m,e.b+=h.color.b*m))}function c(c,e,m,n,u,t){k.info.render.vertices+=3;k.info.render.faces++;Q=f(Z++);
|
|
|
+THREE.SVGRenderer=function(){function b(b,c,e){var f,h,k,m;f=0;for(h=b.lights.length;f<h;f++)k=b.lights[f],k instanceof THREE.DirectionalLight?(m=c.normalWorld.dot(k.position)*k.intensity,m>0&&(e.r+=k.color.r*m,e.g+=k.color.g*m,e.b+=k.color.b*m)):k instanceof THREE.PointLight&&(Y.sub(k.position,c.centroidWorld),Y.normalize(),m=c.normalWorld.dot(Y)*k.intensity,m>0&&(e.r+=k.color.r*m,e.g+=k.color.g*m,e.b+=k.color.b*m))}function c(c,e,m,n,u,t){k.info.render.vertices+=3;k.info.render.faces++;Q=f(Z++);
|
|
|
Q.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");u instanceof THREE.MeshBasicMaterial?G.copy(u.color):u instanceof THREE.MeshLambertMaterial?C?(J.r=M.r,J.g=M.g,J.b=M.b,b(t,n,J),G.r=Math.max(0,Math.min(u.color.r*J.r,1)),G.g=Math.max(0,Math.min(u.color.g*J.g,1)),G.b=Math.max(0,Math.min(u.color.b*J.b,1))):G.copy(u.color):u instanceof THREE.MeshDepthMaterial?(L=1-u.__2near/(u.__farPlusNear-
|
|
|
n.z*u.__farMinusNear),G.setRGB(L,L,L)):u instanceof THREE.MeshNormalMaterial&&G.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));u.wireframe?Q.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+u.wireframeLinewidth+"; stroke-opacity: "+u.opacity+"; stroke-linecap: "+u.wireframeLinecap+"; stroke-linejoin: "+u.wireframeLinejoin):Q.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+u.opacity);p.appendChild(Q)}function e(c,e,m,n,u,t,v){k.info.render.vertices+=
|
|
|
4;k.info.render.faces++;Q=f(Z++);Q.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.copy(t.color):t instanceof THREE.MeshLambertMaterial?C?(J.r=M.r,J.g=M.g,J.b=M.b,b(v,u,J),G.r=Math.max(0,Math.min(t.color.r*J.r,1)),G.g=Math.max(0,Math.min(t.color.g*J.g,1)),G.b=Math.max(0,Math.min(t.color.b*J.b,1))):
|
|
@@ -227,9 +227,9 @@ THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.Shader
|
|
|
THREE.ShaderChunk.shadowmap_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;",THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,
|
|
|
THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,
|
|
|
THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
|
|
|
-THREE.WebGLRenderer=function(b){function c(b,c,e){var f,k,h,m=b.vertices,n=m.length,u=b.colors,p=u.length,t=b.__vertexArray,v=b.__colorArray,w=b.__sortArray,x=b.__dirtyVertices,S=b.__dirtyColors,z=b.__webglCustomAttributes,y,A;if(z)for(y in z)z[y].offset=0;if(e.sortParticles){Ca.multiplySelf(e.matrixWorld);for(f=0;f<n;f++)k=m[f].position,Da.copy(k),Ca.multiplyVector3(Da),w[f]=[Da.z,f];w.sort(function(b,c){return c[0]-b[0]});for(f=0;f<n;f++)k=m[w[f][1]].position,h=f*3,t[h]=k.x,t[h+1]=k.y,t[h+2]=k.z;
|
|
|
-for(f=0;f<p;f++)h=f*3,color=u[w[f][1]],v[h]=color.r,v[h+1]=color.g,v[h+2]=color.b;if(z)for(y in z){f=z[y];u=f.value.length;for(h=0;h<u;h++){index=w[h][1];p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")A=f.value[index];f.size===2?(f.array[p]=A.x,f.array[p+1]=A.y):f.size===3?f.type==="c"?(f.array[p]=A.r,f.array[p+1]=A.g,f.array[p+2]=A.b):(f.array[p]=A.x,f.array[p+1]=A.y,f.array[p+2]=A.z):(f.array[p]=
|
|
|
-A.x,f.array[p+1]=A.y,f.array[p+2]=A.z,f.array[p+3]=A.w)}f.offset+=f.size}}}else{if(x)for(f=0;f<n;f++)k=m[f].position,h=f*3,t[h]=k.x,t[h+1]=k.y,t[h+2]=k.z;if(S)for(f=0;f<p;f++)color=u[f],h=f*3,v[h]=color.r,v[h+1]=color.g,v[h+2]=color.b;if(z)for(y in z)if(f=z[y],f.__original.needsUpdate){u=f.value.length;for(h=0;h<u;h++){p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")A=f.value[h];f.size===2?(f.array[p]=
|
|
|
+THREE.WebGLRenderer=function(b){function c(b,c,e){var f,h,k,m=b.vertices,n=m.length,u=b.colors,p=u.length,t=b.__vertexArray,v=b.__colorArray,w=b.__sortArray,x=b.__dirtyVertices,S=b.__dirtyColors,z=b.__webglCustomAttributes,y,A;if(z)for(y in z)z[y].offset=0;if(e.sortParticles){Ca.multiplySelf(e.matrixWorld);for(f=0;f<n;f++)h=m[f].position,Da.copy(h),Ca.multiplyVector3(Da),w[f]=[Da.z,f];w.sort(function(b,c){return c[0]-b[0]});for(f=0;f<n;f++)h=m[w[f][1]].position,k=f*3,t[k]=h.x,t[k+1]=h.y,t[k+2]=h.z;
|
|
|
+for(f=0;f<p;f++)k=f*3,color=u[w[f][1]],v[k]=color.r,v[k+1]=color.g,v[k+2]=color.b;if(z)for(y in z){f=z[y];u=f.value.length;for(k=0;k<u;k++){index=w[k][1];p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")A=f.value[index];f.size===2?(f.array[p]=A.x,f.array[p+1]=A.y):f.size===3?f.type==="c"?(f.array[p]=A.r,f.array[p+1]=A.g,f.array[p+2]=A.b):(f.array[p]=A.x,f.array[p+1]=A.y,f.array[p+2]=A.z):(f.array[p]=
|
|
|
+A.x,f.array[p+1]=A.y,f.array[p+2]=A.z,f.array[p+3]=A.w)}f.offset+=f.size}}}else{if(x)for(f=0;f<n;f++)h=m[f].position,k=f*3,t[k]=h.x,t[k+1]=h.y,t[k+2]=h.z;if(S)for(f=0;f<p;f++)color=u[f],k=f*3,v[k]=color.r,v[k+1]=color.g,v[k+2]=color.b;if(z)for(y in z)if(f=z[y],f.__original.needsUpdate){u=f.value.length;for(k=0;k<u;k++){p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[k]}else{if(f.boundTo===void 0||f.boundTo==="vertices")A=f.value[k];f.size===2?(f.array[p]=
|
|
|
A.x,f.array[p+1]=A.y):f.size===3?f.type==="c"?(f.array[p]=A.r,f.array[p+1]=A.g,f.array[p+2]=A.b):(f.array[p]=A.x,f.array[p+1]=A.y,f.array[p+2]=A.z):(f.array[p]=A.x,f.array[p+1]=A.y,f.array[p+2]=A.z,f.array[p+3]=A.w)}f.offset+=f.size}}}if(x||e.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,t,c);if(S||e.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,v,c);if(z)for(y in z)if(f=z[y],f.__original.needsUpdate||e.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,
|
|
|
f.buffer),o.bufferData(o.ARRAY_BUFFER,f.array,c)}function e(b,c,e,f,h){f.program||P.initMaterial(f,c,e,h);if(f.morphTargets&&!h.__webglMorphTargetInfluences){h.__webglMorphTargetInfluences=new Float32Array(P.maxMorphTargets);for(var k=0,m=P.maxMorphTargets;k<m;k++)h.__webglMorphTargetInfluences[k]=0}var n=!1,k=f.program,m=k.uniforms,p=f.uniforms;k!=fa&&(o.useProgram(k),fa=k,n=!0);if(f.id!=ha)ha=f.id,n=!0;if(n){o.uniformMatrix4fv(m.projectionMatrix,!1,Ga);if(e&&f.fog)if(p.fogColor.value=e.color,e instanceof
|
|
|
THREE.Fog)p.fogNear.value=e.near,p.fogFar.value=e.far;else if(e instanceof THREE.FogExp2)p.fogDensity.value=e.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){for(var u,t,v=0,w=0,x=0,z,y,A,O=za,da=O.directional.colors,F=O.directional.positions,E=O.point.colors,C=O.point.positions,G=O.point.distances,qa=0,la=0,e=u=A=0,n=c.length;e<n;e++)if(u=c[e],t=u.color,z=u.position,y=u.intensity,A=u.distance,u instanceof THREE.AmbientLight)P.gammaInput?(v+=t.r*
|
|
@@ -446,15 +446,14 @@ this.cameraNY,e);e.activeCubeFace=4;b.render(c,this.cameraPZ,e);e.activeCubeFace
|
|
|
THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(b,c,e,f,h,k,m){THREE.Camera.call(this);this.cameraO=new THREE.OrthographicCamera(b/-2,b/2,c/2,c/-2,k,m);this.cameraP=new THREE.PerspectiveCamera(e,b/c,f,h);this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
|
|
|
THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.projectionMatrix=this.cameraP.projectionMatrix};THREE.CombinedCamera.prototype.toOrthographic=function(){this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix};THREE.CombinedCamera.prototype.setFov=function(b){this.cameraP.fov=b;this.cameraP.updateProjectionMatrix();this.toPerspective()};
|
|
|
THREE.CombinedCamera.prototype.setLens=function(b,c){c||(c=43.25);var e=2*Math.atan(c/(b*2));e*=180/Math.PI;this.setFov(e);return e};
|
|
|
-THREE.FirstPersonControls=function(b,c){function e(b,e){return function(){e.apply(b,arguments)}}this.object=b;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.lastUpdate=(new Date).getTime();this.theta=this.phi=this.lon=this.lat=
|
|
|
-this.mouseY=this.mouseX=this.autoSpeedFactor=this.tdiff=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(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation();
|
|
|
-if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=
|
|
|
-b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
|
|
|
-!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff*(THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin)*this.heightCoef:0;var e=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(e+
|
|
|
-this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(e);this.moveLeft&&this.object.translateX(-e);this.moveRight&&this.object.translateX(e);this.moveUp&&this.object.translateY(e);this.moveDown&&this.object.translateY(-e);e=this.tdiff*this.lookSpeed;this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;
|
|
|
-b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);
|
|
|
-b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(b)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",
|
|
|
-e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};
|
|
|
+THREE.FirstPersonControls=function(b,c){function e(b,e){return function(){e.apply(b,arguments)}}this.object=b;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=
|
|
|
+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(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=
|
|
|
+!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
|
|
|
+function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
|
|
|
+!1;break;case 70:this.moveDown=!1}};this.update=function(b){b*=0.0010;if(!this.freeze){if(this.heightSpeed){var e=THREE.Math.clamp(this.object.position.y,this.heightMin,this.heightMax)-this.heightMin;this.autoSpeedFactor=b*e*this.heightCoef}else this.autoSpeedFactor=0;e=b*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.object.translateZ(-(e+this.autoSpeedFactor));this.moveBackward&&this.object.translateZ(e);this.moveLeft&&this.object.translateX(-e);this.moveRight&&
|
|
|
+this.object.translateX(e);this.moveUp&&this.object.translateY(e);this.moveDown&&this.object.translateY(-e);e=b*this.lookSpeed;this.activeLook||(e=0);this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=
|
|
|
+1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*e;this.lookVertical&&(this.lat-=this.mouseY*e*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*
|
|
|
+Math.sin(this.theta);this.object.lookAt(b)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",e(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",e(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",e(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",e(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",e(this,this.onKeyUp),!1)};
|
|
|
THREE.PathControls=function(b,c){function e(b){if((b*=2)<1)return 0.5*b*b;return-0.5*(--b*(b-2)-1)}function f(b,e){return function(){e.apply(b,arguments)}}function h(b,e,c,f){var k={name:c,fps:0.6,length:f,hierarchy:[]},h,m=e.getControlPointsArray(),n=e.getLength(),y=m.length,E=0;h=y-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[h]={time:f,pos:m[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<y-1;h++)E=f*n.chunks[h]/n.total,e.keys[h]={time:E,pos:m[h]};k.hierarchy[0]=
|
|
|
e;THREE.AnimationHandler.add(k);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function k(b,e){var c,f,k=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),k.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return k}this.object=b;this.domElement=c!==void 0?c:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=
|
|
|
new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=
|
|
@@ -498,10 +497,10 @@ this.vertices[e].position.clone().setY(0).normalize(),z=this.vertices[u].positio
|
|
|
1],x=this.vertices.length-1,A=new THREE.Vector3(0,1,0),z=new THREE.Vector3(0,1,0),y=new THREE.Vector3(0,1,0),F=w[0][n].clone(),C=w[0][n+1].clone(),G=new THREE.UV(C.u,0),this.faces.push(new THREE.Face3(e,u,x,[A,z,y])),this.faceVertexUvs[0].push([F,C,G])}if(!k&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-m,0)));for(n=0;n<f;n++)e=t[p][n+1],u=t[p][n],x=this.vertices.length-1,A=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),y=new THREE.Vector3(0,-1,0),F=w[p][n+1].clone(),C=w[p][n].clone(),
|
|
|
G=new THREE.UV(C.u,1),this.faces.push(new THREE.Face3(e,u,x,[A,z,y])),this.faceVertexUvs[0].push([F,C,G])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
|
|
|
THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,h;this.shapebb=b[f-1].getBoundingBox();for(e=0;e<f;e++)h=b[e],this.addShape(h,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
|
|
|
-THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,k=THREE.ExtrudeGeometry.__v2,h=THREE.ExtrudeGeometry.__v3,m=THREE.ExtrudeGeometry.__v4,n=THREE.ExtrudeGeometry.__v5,o=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);k.set(b.x-e.x,b.y-e.y);f=f.normalize();k=k.normalize();h.set(-f.y,f.x);m.set(k.y,-k.x);n.copy(b).addSelf(h);o.copy(b).addSelf(m);if(n.equals(o))return m.clone();
|
|
|
-n.copy(c).addSelf(h);o.copy(e).addSelf(m);h=f.dot(m);m=o.subSelf(n).dot(m);h==0&&(console.log("Either infinite or no solutions!"),m==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));m/=h;if(m<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(H=b.length;--H>=0;){ka=H;na=H-1;na<0&&(na=b.length-
|
|
|
-1);for(var c=0,e=v+w*2,c=0;c<e;c++){var f=o*c,k=o*(c+1),m=aa+ka+f,h=aa+ka+k,t=m,f=aa+na+f,k=aa+na+k,u=h;t+=Y;f+=Y;k+=Y;u+=Y;L.faces.push(new THREE.Face4(t,f,k,u,null,null,G));G&&(t=c/e,f=(c+1)/e,k=n+p*2,m=(L.vertices[m].position.z+p)/k,h=(L.vertices[h].position.z+p)/k,L.faceVertexUvs[0].push([new THREE.UV(m,t),new THREE.UV(h,t),new THREE.UV(h,f),new THREE.UV(m,f)]))}}}function k(b,c,e){L.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function m(b,c,e){b+=Y;c+=Y;e+=Y;L.faces.push(new THREE.Face3(b,
|
|
|
-c,e,null,null,C));if(C){var f=J.maxY,k=J.maxX,m=L.vertices[c].position.x,c=L.vertices[c].position.y,h=L.vertices[e].position.x,e=L.vertices[e].position.y;L.faceVertexUvs[0].push([new THREE.UV(L.vertices[b].position.x/k,L.vertices[b].position.y/f),new THREE.UV(m/k,c/f),new THREE.UV(h/k,e/f)])}}var n=c.amount!==void 0?c.amount:100,p=c.bevelThickness!==void 0?c.bevelThickness:6,t=c.bevelSize!==void 0?c.bevelSize:p-2,w=c.bevelSegments!==void 0?c.bevelSegments:3,u=c.bevelEnabled!==void 0?c.bevelEnabled:
|
|
|
+THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,k=THREE.ExtrudeGeometry.__v2,m=THREE.ExtrudeGeometry.__v3,h=THREE.ExtrudeGeometry.__v4,n=THREE.ExtrudeGeometry.__v5,o=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);k.set(b.x-e.x,b.y-e.y);f=f.normalize();k=k.normalize();m.set(-f.y,f.x);h.set(k.y,-k.x);n.copy(b).addSelf(m);o.copy(b).addSelf(h);if(n.equals(o))return h.clone();
|
|
|
+n.copy(c).addSelf(m);o.copy(e).addSelf(h);m=f.dot(h);h=o.subSelf(n).dot(h);m==0&&(console.log("Either infinite or no solutions!"),h==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));h/=m;if(h<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(h).addSelf(n).subSelf(b).clone()}function h(b){for(H=b.length;--H>=0;){ka=H;na=H-1;na<0&&(na=b.length-
|
|
|
+1);for(var c=0,e=v+w*2,c=0;c<e;c++){var f=o*c,k=o*(c+1),h=aa+ka+f,m=aa+ka+k,t=h,f=aa+na+f,k=aa+na+k,u=m;t+=Y;f+=Y;k+=Y;u+=Y;L.faces.push(new THREE.Face4(t,f,k,u,null,null,G));G&&(t=c/e,f=(c+1)/e,k=n+p*2,h=(L.vertices[h].position.z+p)/k,m=(L.vertices[m].position.z+p)/k,L.faceVertexUvs[0].push([new THREE.UV(h,t),new THREE.UV(m,t),new THREE.UV(m,f),new THREE.UV(h,f)]))}}}function k(b,c,e){L.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function m(b,c,e){b+=Y;c+=Y;e+=Y;L.faces.push(new THREE.Face3(b,
|
|
|
+c,e,null,null,C));if(C){var f=J.maxY,k=J.maxX,h=L.vertices[c].position.x,c=L.vertices[c].position.y,m=L.vertices[e].position.x,e=L.vertices[e].position.y;L.faceVertexUvs[0].push([new THREE.UV(L.vertices[b].position.x/k,L.vertices[b].position.y/f),new THREE.UV(h/k,c/f),new THREE.UV(m/k,e/f)])}}var n=c.amount!==void 0?c.amount:100,p=c.bevelThickness!==void 0?c.bevelThickness:6,t=c.bevelSize!==void 0?c.bevelSize:p-2,w=c.bevelSegments!==void 0?c.bevelSegments:3,u=c.bevelEnabled!==void 0?c.bevelEnabled:
|
|
|
!0,x=c.curveSegments!==void 0?c.curveSegments:12,v=c.steps!==void 0?c.steps:1,A=c.bendPath,z=c.extrudePath,y,E=!1,F=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,C=c.material,G=c.extrudeMaterial,J=this.shapebb;if(z)y=z.getPoints(x),v=y.length,E=!0,u=!1;u||(t=p=w=0);var M,K,B,L=this,Y=this.vertices.length;A&&b.addWrapPath(A);x=F?b.extractAllSpacedPoints(x):b.extractAllPoints(x);A=x.shape;x=x.holes;if(z=!THREE.Shape.Utils.isClockWise(A)){A=A.reverse();K=0;for(B=x.length;K<B;K++)M=x[K],THREE.Shape.Utils.isClockWise(M)&&
|
|
|
(x[K]=M.reverse());z=!1}z=THREE.Shape.Utils.triangulateShape(A,x);F=A;K=0;for(B=x.length;K<B;K++)M=x[K],A=A.concat(M);var H,T,Q,Z,$,P,o=A.length,V=z.length,fa=[];H=0;T=F.length;ka=T-1;for(na=H+1;H<T;H++,ka++,na++)ka==T&&(ka=0),na==T&&(na=0),fa[H]=f(F[H],F[ka],F[na]);var ea=[],ha,ga=fa.concat();K=0;for(B=x.length;K<B;K++){M=x[K];ha=[];H=0;T=M.length;ka=T-1;for(na=H+1;H<T;H++,ka++,na++)ka==T&&(ka=0),na==T&&(na=0),ha[H]=f(M[H],M[ka],M[na]);ea.push(ha);ga=ga.concat(ha)}for(Q=0;Q<w;Q++){Z=Q/w;$=p*(1-Z);
|
|
|
Z=t*Math.sin(Z*Math.PI/2);H=0;for(T=F.length;H<T;H++)P=e(F[H],fa[H],Z),k(P.x,P.y,-$);K=0;for(B=x.length;K<B;K++){M=x[K];ha=ea[K];H=0;for(T=M.length;H<T;H++)P=e(M[H],ha[H],Z),k(P.x,P.y,-$)}}Z=t;for(H=0;H<o;H++)P=u?e(A[H],ga[H],Z):A[H],E?k(P.x,P.y+y[0].y,y[0].x):k(P.x,P.y,0);for(Q=1;Q<=v;Q++)for(H=0;H<o;H++)P=u?e(A[H],ga[H],Z):A[H],E?k(P.x,P.y+y[Q-1].y,y[Q-1].x):k(P.x,P.y,n/v*Q);for(Q=w-1;Q>=0;Q--){Z=Q/w;$=p*(1-Z);Z=t*Math.sin(Z*Math.PI/2);H=0;for(T=F.length;H<T;H++)P=e(F[H],fa[H],Z),k(P.x,P.y,n+$);
|
|
@@ -534,21 +533,21 @@ J=void 0,M=void 0,K=void 0,B=void 0,L=void 0,Y=void 0,C=x[E[v]].x,G=x[E[v]].y,J=
|
|
|
THREE.TorusGeometry=function(b,c,e,f,h){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;this.arc=h||Math.PI*2;h=new THREE.Vector3;b=[];c=[];for(e=0;e<=this.segmentsR;e++)for(f=0;f<=this.segmentsT;f++){var k=f/this.segmentsT*this.arc,m=e/this.segmentsR*Math.PI*2;h.x=this.radius*Math.cos(k);h.y=this.radius*Math.sin(k);var n=new THREE.Vector3;n.x=(this.radius+this.tube*Math.cos(m))*Math.cos(k);n.y=(this.radius+this.tube*Math.cos(m))*Math.sin(k);n.z=
|
|
|
this.tube*Math.sin(m);this.vertices.push(new THREE.Vertex(n));b.push(new THREE.UV(f/this.segmentsT,1-e/this.segmentsR));c.push(n.clone().subSelf(h).normalize())}for(e=1;e<=this.segmentsR;e++)for(f=1;f<=this.segmentsT;f++){var h=(this.segmentsT+1)*e+f-1,k=(this.segmentsT+1)*(e-1)+f-1,m=(this.segmentsT+1)*(e-1)+f,n=(this.segmentsT+1)*e+f,p=new THREE.Face4(h,k,m,n,[c[h],c[k],c[m],c[n]]);p.normal.addSelf(c[h]);p.normal.addSelf(c[k]);p.normal.addSelf(c[m]);p.normal.addSelf(c[n]);p.normal.normalize();this.faces.push(p);
|
|
|
this.faceVertexUvs[0].push([b[h].clone(),b[k].clone(),b[m].clone(),b[n].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
|
|
|
-THREE.TorusKnotGeometry=function(b,c,e,f,h,k,m){function n(b,c,e,f,k,m){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(k*(2+e)*0.5*Math.cos(b),k*(2+e)*Math.sin(b)*0.5,m*k*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=h||2;this.q=k||3;this.heightScale=m||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
|
|
|
+THREE.TorusKnotGeometry=function(b,c,e,f,h,k,m){function n(b,c,e,f,k,h){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(k*(2+e)*0.5*Math.cos(b),k*(2+e)*Math.sin(b)*0.5,h*k*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=h||2;this.q=k||3;this.heightScale=m||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
|
|
|
this.segmentsT;++c){var p=b/this.segmentsR*2*this.p*Math.PI,m=c/this.segmentsT*2*Math.PI,h=n(p,m,this.q,this.p,this.radius,this.heightScale),p=n(p+0.01,m,this.q,this.p,this.radius,this.heightScale);e.x=p.x-h.x;e.y=p.y-h.y;e.z=p.z-h.z;f.x=p.x+h.x;f.y=p.y+h.y;f.z=p.z+h.z;k.cross(e,f);f.cross(k,e);k.normalize();f.normalize();p=-this.tube*Math.cos(m);m=this.tube*Math.sin(m);h.x+=p*f.x+m*k.x;h.y+=p*f.y+m*k.y;h.z+=p*f.z+m*k.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(h.x,h.y,
|
|
|
h.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,k=(c+1)%this.segmentsT,h=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][k],k=this.grid[b][k],m=new THREE.UV(b/this.segmentsR,c/this.segmentsT),p=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),t=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),w=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(h,e,f,k));this.faceVertexUvs[0].push([m,p,t,w])}this.computeCentroids();
|
|
|
this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(b){this.subdivisions=b===void 0?1:b;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(b){for(var c=this.subdivisions;c-- >0;)this.smooth(b)};
|
|
|
THREE.SubdivisionModifier.prototype.smooth=function(b){function c(b,c,e,f,n,p){var t=new THREE.Face4(b,c,e,f,null,n.color,n.material);if(m.useOldVertexColors){t.vertexColors=[];for(var v,o,w,x=0;x<4;x++){w=p[x];v=new THREE.Color;v.setRGB(0,0,0);for(var y=0;y<w.length;y++)o=n.vertexColors[w[y]-1],v.r+=o.r,v.g+=o.g,v.b+=o.b;v.r/=w.length;v.g/=w.length;v.b/=w.length;t.vertexColors[x]=v}}h.push(t);(!m.supportUVs||u.length!=0)&&k.push([u[b],u[c],u[e],u[f]])}function e(b,c){return Math.min(b,c)+"_"+Math.max(b,
|
|
|
c)}var f=[],h=[],k=[],m=this,n=b.vertices,f=b.faces,p=n.concat(),t=[],w={},u=[],x,v,A,z,y,E=b.faceVertexUvs[0];x=0;for(v=E.length;x<v;x++){A=0;for(z=E[x].length;A<z;A++)y=f[x]["abcd".charAt(A)],u[y]||(u[y]=E[x][A])}var F;x=0;for(v=f.length;x<v;x++)if(y=f[x],t.push(y.centroid),p.push(new THREE.Vertex(y.centroid)),m.supportUVs&&u.length!=0){F=new THREE.UV;if(y instanceof THREE.Face3)F.u=u[y.a].u+u[y.b].u+u[y.c].u,F.v=u[y.a].v+u[y.b].v+u[y.c].v,F.u/=3,F.v/=3;else if(y instanceof THREE.Face4)F.u=u[y.a].u+
|
|
|
-u[y.b].u+u[y.c].u+u[y.d].u,F.v=u[y.a].v+u[y.b].v+u[y.c].v+u[y.d].v,F.u/=4,F.v/=4;u.push(F)}z=function(b){function c(b,e,f){b[e]===void 0&&(b[e]=[]);b[e].push(f)}var f,k,m,h,n={};f=0;for(k=b.faces.length;f<k;f++)m=b.faces[f],m instanceof THREE.Face3?(h=e(m.a,m.b),c(n,h,f),h=e(m.b,m.c),c(n,h,f),h=e(m.c,m.a),c(n,h,f)):m instanceof THREE.Face4&&(h=e(m.a,m.b),c(n,h,f),h=e(m.b,m.c),c(n,h,f),h=e(m.c,m.d),c(n,h,f),h=e(m.d,m.a),c(n,h,f));return n}(b);var C,G,J=0,E=n.length,M;for(x in z)if(y=z[x],F=y[0],C=
|
|
|
+u[y.b].u+u[y.c].u+u[y.d].u,F.v=u[y.a].v+u[y.b].v+u[y.c].v+u[y.d].v,F.u/=4,F.v/=4;u.push(F)}z=function(b){function c(b,e,f){b[e]===void 0&&(b[e]=[]);b[e].push(f)}var f,k,h,m,n={};f=0;for(k=b.faces.length;f<k;f++)h=b.faces[f],h instanceof THREE.Face3?(m=e(h.a,h.b),c(n,m,f),m=e(h.b,h.c),c(n,m,f),m=e(h.c,h.a),c(n,m,f)):h instanceof THREE.Face4&&(m=e(h.a,h.b),c(n,m,f),m=e(h.b,h.c),c(n,m,f),m=e(h.c,h.d),c(n,m,f),m=e(h.d,h.a),c(n,m,f));return n}(b);var C,G,J=0,E=n.length,M;for(x in z)if(y=z[x],F=y[0],C=
|
|
|
y[1],M=x.split("_"),v=M[0],M=M[1],G=new THREE.Vector3,y.length!=2?(G.addSelf(n[v].position),G.addSelf(n[M].position),G.multiplyScalar(0.5)):(G.addSelf(t[F]),G.addSelf(t[C]),G.addSelf(n[v].position),G.addSelf(n[M].position),G.multiplyScalar(0.25)),w[x]=E+f.length+J,p.push(new THREE.Vertex(G)),J++,m.supportUVs&&u.length!=0)F=new THREE.UV,F.u=u[v].u+u[M].u,F.v=u[v].v+u[M].v,F.u/=2,F.v/=2,u.push(F);x=0;for(v=t.length;x<v;x++)y=f[x],F=E+x,y instanceof THREE.Face3?(C=e(y.a,y.b),M=e(y.b,y.c),J=e(y.c,y.a),
|
|
|
c(F,w[C],y.b,w[M],y,["123","12","2","23"]),c(F,w[M],y.c,w[J],y,["123","23","3","31"]),c(F,w[J],y.a,w[C],y,["123","31","1","12"])):y instanceof THREE.Face4?(C=e(y.a,y.b),M=e(y.b,y.c),J=e(y.c,y.d),G=e(y.d,y.a),c(F,w[C],y.b,w[M],y,["1234","12","2","23"]),c(F,w[M],y.c,w[J],y,["1234","23","3","34"]),c(F,w[J],y.d,w[G],y,["1234","34","4","41"]),c(F,w[G],y.a,w[C],y,["1234","41","1","12"])):console.log("face should be a face!",y);var f=p,K={},B={},p=function(b,c){K[b]===void 0&&(K[b]=[]);K[b].push(c)},w=function(b,
|
|
|
c){B[b]===void 0&&(B[b]={});B[b][c]=null};for(x in z)y=z[x],M=x.split("_"),v=M[0],M=M[1],p(v,[v,M]),p(M,[v,M]),F=y[0],C=y[1],w(v,F),C?w(v,C):w(v,F),w(M,F),C?w(M,C):w(M,F);p=new THREE.Vector3;w=new THREE.Vector3;x=0;for(v=n.length;x<v;x++)if(K[x]!==void 0){p.set(0,0,0);w.set(0,0,0);z=new THREE.Vector3(0,0,0);E=0;for(A in B[x])p.addSelf(t[A]),E++;p.divideScalar(E);E=K[x].length;for(A=0;A<E;A++)y=K[x][A],y=n[y[0]].position.clone().addSelf(n[y[1]].position).divideScalar(2),w.addSelf(y);w.divideScalar(E);
|
|
|
z.addSelf(n[x].position);z.multiplyScalar(E-3);z.addSelf(p);z.addSelf(w.multiplyScalar(2));z.divideScalar(E);f[x].position=z}b.vertices=f;b.faces=h;b.faceVertexUvs[0]=k;delete b.__tmpVertices;b.computeCentroids();b.computeFaceNormals();b.computeVertexNormals()};THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
|
|
|
THREE.Loader.prototype={constructor:THREE.Loader,addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var c="Loaded ";c+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/
|
|
|
1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML=c},extractUrlbase:function(b){b=b.split("/");b.pop();return b.length<1?"":b.join("/")+"/"},init_materials:function(b,c,e){b.materials=[];for(var f=0;f<c.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(c[f],e)]},hasNormals:function(b){var c,e,f=b.materials.length;for(e=0;e<f;e++)if(c=b.materials[e][0],c instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(b,c){function e(b){b=Math.log(b)/Math.LN2;return Math.floor(b)==
|
|
|
-b}function f(b,c){var f=new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}function h(b,e,k,m,h,n){var p=document.createElement("canvas");b[e]=new THREE.Texture(p);b[e].sourceFile=k;if(m){b[e].repeat.set(m[0],m[1]);if(m[0]!=1)b[e].wrapS=THREE.RepeatWrapping;
|
|
|
-if(m[1]!=1)b[e].wrapT=THREE.RepeatWrapping}h&&b[e].offset.set(h[0],h[1]);if(n){m={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(m[n[0]]!==void 0)b[e].wrapS=m[n[0]];if(m[n[1]]!==void 0)b[e].wrapT=m[n[1]]}f(b[e],c+"/"+k)}function k(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var m,n,p;n="MeshLambertMaterial";m={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?n="MeshPhongMaterial":b.shading=="Basic"&&(n="MeshBasicMaterial"));
|
|
|
+b}function f(b,c){var f=new Image;f.onload=function(){if(!e(this.width)||!e(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));b.image.width=c;b.image.height=f;b.image.getContext("2d").drawImage(this,0,0,c,f)}else b.image=this;b.needsUpdate=!0};f.src=c}function h(b,e,k,h,m,n){var p=document.createElement("canvas");b[e]=new THREE.Texture(p);b[e].sourceFile=k;if(h){b[e].repeat.set(h[0],h[1]);if(h[0]!=1)b[e].wrapS=THREE.RepeatWrapping;
|
|
|
+if(h[1]!=1)b[e].wrapT=THREE.RepeatWrapping}m&&b[e].offset.set(m[0],m[1]);if(n){h={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(h[n[0]]!==void 0)b[e].wrapS=h[n[0]];if(h[n[1]]!==void 0)b[e].wrapT=h[n[1]]}f(b[e],c+"/"+k)}function k(b){return(b[0]*255<<16)+(b[1]*255<<8)+b[2]*255}var m,n,p;n="MeshLambertMaterial";m={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:b.wireframe};b.shading&&(b.shading=="Phong"?n="MeshPhongMaterial":b.shading=="Basic"&&(n="MeshBasicMaterial"));
|
|
|
if(b.blending)if(b.blending=="Additive")m.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")m.blending=THREE.SubtractiveBlending;else if(b.blending=="Multiply")m.blending=THREE.MultiplyBlending;if(b.transparent!==void 0||b.opacity<1)m.transparent=b.transparent;if(b.depthTest!==void 0)m.depthTest=b.depthTest;if(b.vertexColors!==void 0)if(b.vertexColors=="face")m.vertexColors=THREE.FaceColors;else if(b.vertexColors)m.vertexColors=THREE.VertexColors;if(b.colorDiffuse)m.color=k(b.colorDiffuse);
|
|
|
else if(b.DbgColor)m.color=b.DbgColor;if(b.colorSpecular)m.specular=k(b.colorSpecular);if(b.colorAmbient)m.ambient=k(b.colorAmbient);if(b.transparency)m.opacity=b.transparency;if(b.specularCoef)m.shininess=b.specularCoef;b.mapDiffuse&&c&&h(m,"map",b.mapDiffuse,b.mapDiffuseRepeat,b.mapDiffuseOffset,b.mapDiffuseWrap);b.mapLight&&c&&h(m,"lightMap",b.mapLight,b.mapLightRepeat,b.mapLightOffset,b.mapLightWrap);b.mapNormal&&c&&h(m,"normalMap",b.mapNormal,b.mapNormalRepeat,b.mapNormalOffset,b.mapNormalWrap);
|
|
|
b.mapSpecular&&c&&h(m,"specularMap",b.mapSpecular,b.mapSpecularRepeat,b.mapSpecularOffset,b.mapSpecularWrap);if(b.mapNormal){var t=THREE.ShaderUtils.lib.normal,w=THREE.UniformsUtils.clone(t.uniforms),u=m.color;n=m.specular;p=m.ambient;var x=m.shininess;w.tNormal.texture=m.normalMap;if(b.mapNormalFactor)w.uNormalScale.value=b.mapNormalFactor;if(m.map)w.tDiffuse.texture=m.map,w.enableDiffuse.value=!0;if(m.specularMap)w.tSpecular.texture=m.specularMap,w.enableSpecular.value=!0;if(m.lightMap)w.tAO.texture=
|