提交 9211f744 编写于 作者: M Mr.doob

Updated builds.

上级 e314c2a5
......@@ -33488,31 +33488,29 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
for ( var i = 0; i < this.radialSegments; ++ i ) {
this.grid[ i ] = new Array( this.tubularSegments );
var u = i / this.radialSegments * 2 * this.p * Math.PI;
var p1 = getPos( u, this.q, this.p, this.radius, this.heightScale );
var p2 = getPos( u + 0.01, this.q, this.p, this.radius, this.heightScale );
tang.subVectors( p2, p1 );
n.addVectors( p2, p1 );
bitan.crossVectors( tang, n );
n.crossVectors( bitan, tang );
bitan.normalize();
n.normalize();
for ( var j = 0; j < this.tubularSegments; ++ j ) {
var u = i / this.radialSegments * 2 * this.p * Math.PI;
var v = j / this.tubularSegments * 2 * Math.PI;
var p1 = getPos( u, v, this.q, this.p, this.radius, this.heightScale );
var p2 = getPos( u + 0.01, v, this.q, this.p, this.radius, this.heightScale );
var cx, cy;
tang.subVectors( p2, p1 );
n.addVectors( p2, p1 );
bitan.crossVectors( tang, n );
n.crossVectors( bitan, tang );
bitan.normalize();
n.normalize();
var cx = - this.tube * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
var cy = this.tube * Math.sin( v );
cx = - this.tube * Math.cos( v ); // TODO: Hack: Negating it so it faces outside.
cy = this.tube * Math.sin( v );
var pos = new THREE.Vector3();
pos.x = p1.x + cx * n.x + cy * bitan.x;
pos.y = p1.y + cx * n.y + cy * bitan.y;
pos.z = p1.z + cx * n.z + cy * bitan.z;
p1.x += cx * n.x + cy * bitan.x;
p1.y += cx * n.y + cy * bitan.y;
p1.z += cx * n.z + cy * bitan.z;
this.grid[ i ][ j ] = vert( p1.x, p1.y, p1.z );
this.grid[ i ][ j ] = scope.vertices.push( pos ) - 1;
}
......@@ -33545,16 +33543,9 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
this.computeFaceNormals();
this.computeVertexNormals();
function vert( x, y, z ) {
return scope.vertices.push( new THREE.Vector3( x, y, z ) ) - 1;
}
function getPos( u, v, in_q, in_p, radius, heightScale ) {
function getPos( u, in_q, in_p, radius, heightScale ) {
var cu = Math.cos( u );
var cv = Math.cos( v );
var su = Math.sin( u );
var quOverP = in_q / in_p * u;
var cs = Math.cos( quOverP );
......
......@@ -619,7 +619,7 @@ t,p,r,[s,v,z,G]));this.faceVertexUvs[0].push([C,H,I,F])}}if(!1===f&&0<a){this.ve
t=j[i][h],p=this.vertices.length-1,s=new THREE.Vector3(0,-1,0),v=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),C=l[i][h+1].clone(),H=l[i][h].clone(),I=new THREE.Vector2(H.u,1),this.faces.push(new THREE.Face3(q,t,p,[s,v,z])),this.faceVertexUvs[0].push([C,H,I])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry=function(a,b){"undefined"!==typeof a&&(THREE.Geometry.call(this),a=a instanceof Array?a:[a],this.shapebb=a[a.length-1].getBoundingBox(),this.addShapeList(a,b),this.computeCentroids(),this.computeFaceNormals())};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).add(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).add(f);i.copy(a).add(g);if(h.equals(i))return g.clone();
h.copy(b).add(f);i.copy(c).add(g);f=d.dot(g);g=i.sub(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return 0>g?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).add(h).sub(a).clone()}function e(c,d){var e,f;for(O=c.length;0<=--O;){e=O;f=O-1;0>f&&(f=c.length-1);for(var g=0,h=q+2*l,
g=0;g<h;g++){var i=oa*g,j=oa*(g+1),n=d+e+i,i=d+f+i,m=d+f+j,j=d+e+j,p=c,s=g,r=h,t=e,w=f,n=n+J,i=i+J,m=m+J,j=j+J;B.faces.push(new THREE.Face4(n,i,m,j,null,null,v));n=z.generateSideWallUV(B,a,p,b,n,i,m,j,s,r,t,w);B.faceVertexUvs[0].push(n)}}}function f(a,b,c){B.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c+=J;d+=J;e+=J;B.faces.push(new THREE.Face3(c,d,e,null,null,s));c=f?z.generateBottomUV(B,a,b,c,d,e):z.generateTopUV(B,a,b,c,d,e);B.faceVertexUvs[0].push(c)}var h=void 0!==b.amount?b.amount:
g=0;g<h;g++){var i=oa*g,j=oa*(g+1),n=d+e+i,i=d+f+i,m=d+f+j,j=d+e+j,p=c,r=g,s=h,t=e,w=f,n=n+J,i=i+J,m=m+J,j=j+J;B.faces.push(new THREE.Face4(n,i,m,j,null,null,v));n=z.generateSideWallUV(B,a,p,b,n,i,m,j,r,s,t,w);B.faceVertexUvs[0].push(n)}}}function f(a,b,c){B.vertices.push(new THREE.Vector3(a,b,c))}function g(c,d,e,f){c+=J;d+=J;e+=J;B.faces.push(new THREE.Face3(c,d,e,null,null,s));c=f?z.generateBottomUV(B,a,b,c,d,e):z.generateTopUV(B,a,b,c,d,e);B.faceVertexUvs[0].push(c)}var h=void 0!==b.amount?b.amount:
100,i=void 0!==b.bevelThickness?b.bevelThickness:6,j=void 0!==b.bevelSize?b.bevelSize:i-2,l=void 0!==b.bevelSegments?b.bevelSegments:3,n=void 0!==b.bevelEnabled?b.bevelEnabled:!0,m=void 0!==b.curveSegments?b.curveSegments:12,q=void 0!==b.steps?b.steps:1,t=b.extrudePath,p,r=!1,s=b.material,v=b.extrudeMaterial,z=void 0!==b.UVGenerator?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,G,C,H,I;t&&(p=t.getSpacedPoints(q),r=!0,n=!1,G=void 0!==b.frames?b.frames:new THREE.TubeGeometry.FrenetFrames(t,q,
!1),C=new THREE.Vector3,H=new THREE.Vector3,I=new THREE.Vector3);n||(j=i=l=0);var F,A,K,B=this,J=this.vertices.length,m=a.extractPoints(m),N=m.shape,m=m.holes;if(t=!THREE.Shape.Utils.isClockWise(N)){N=N.reverse();A=0;for(K=m.length;A<K;A++)F=m[A],THREE.Shape.Utils.isClockWise(F)&&(m[A]=F.reverse());t=!1}var y=THREE.Shape.Utils.triangulateShape(N,m),t=N;A=0;for(K=m.length;A<K;A++)F=m[A],N=N.concat(F);var M,w,Z,L,oa=N.length,Pa=y.length,Va=[],O=0,qa=t.length;M=qa-1;for(w=O+1;O<qa;O++,M++,w++)M===qa&&
(M=0),w===qa&&(w=0),Va[O]=d(t[O],t[M],t[w]);var Fa=[],wa,D=Va.concat();A=0;for(K=m.length;A<K;A++){F=m[A];wa=[];O=0;qa=F.length;M=qa-1;for(w=O+1;O<qa;O++,M++,w++)M===qa&&(M=0),w===qa&&(w=0),wa[O]=d(F[O],F[M],F[w]);Fa.push(wa);D=D.concat(wa)}for(M=0;M<l;M++){F=M/l;Z=i*(1-F);w=j*Math.sin(F*Math.PI/2);O=0;for(qa=t.length;O<qa;O++)L=c(t[O],Va[O],w),f(L.x,L.y,-Z);A=0;for(K=m.length;A<K;A++){F=m[A];wa=Fa[A];O=0;for(qa=F.length;O<qa;O++)L=c(F[O],wa[O],w),f(L.x,L.y,-Z)}}w=j;for(O=0;O<oa;O++)L=n?c(N[O],D[O],
......@@ -636,10 +636,10 @@ j,n,[e,e,e]));this.faceVertexUvs[0].push([g[i],g[j],g[n]]);i=l+a;j=l+c+1+a;n=l+1
p.z=a*Math.sin(d+q*e)*Math.sin(f+t*g);this.vertices.push(p);n.push(this.vertices.length-1);m.push(new THREE.Vector2(q,1-t))}j.push(n);l.push(m)}for(i=0;i<this.heightSegments;i++)for(h=0;h<this.widthSegments;h++){var b=j[i][h+1],c=j[i][h],d=j[i+1][h],e=j[i+1][h+1],f=this.vertices[b].clone().normalize(),g=this.vertices[c].clone().normalize(),n=this.vertices[d].clone().normalize(),m=this.vertices[e].clone().normalize(),q=l[i][h+1].clone(),t=l[i][h].clone(),p=l[i+1][h].clone(),r=l[i+1][h+1].clone();Math.abs(this.vertices[b].y)===
this.radius?(this.faces.push(new THREE.Face3(b,d,e,[f,n,m])),this.faceVertexUvs[0].push([q,p,r])):Math.abs(this.vertices[d].y)===this.radius?(this.faces.push(new THREE.Face3(b,c,d,[f,g,n])),this.faceVertexUvs[0].push([q,t,p])):(this.faces.push(new THREE.Face4(b,c,d,e,[f,g,n,m])),this.faceVertexUvs[0].push([q,t,p,r]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TextGeometry=function(a,b){var b=b||{},c=THREE.FontUtils.generateShapes(a,b);b.amount=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);THREE.ExtrudeGeometry.call(this,c,b)};THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype);THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.radialSegments=c||8;this.tubularSegments=d||6;this.arc=e||2*Math.PI;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.radialSegments;c++)for(d=0;d<=this.tubularSegments;d++){var f=d/this.tubularSegments*this.arc,g=2*c/this.radialSegments*Math.PI;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*
Math.cos(g))*Math.sin(f);h.z=this.tube*Math.sin(g);this.vertices.push(h);a.push(new THREE.Vector2(d/this.tubularSegments,c/this.radialSegments));b.push(h.clone().sub(e).normalize())}for(c=1;c<=this.radialSegments;c++)for(d=1;d<=this.tubularSegments;d++){var e=(this.tubularSegments+1)*c+d-1,f=(this.tubularSegments+1)*(c-1)+d-1,g=(this.tubularSegments+1)*(c-1)+d,h=(this.tubularSegments+1)*c+d,i=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);i.normal.add(b[e]);i.normal.add(b[f]);i.normal.add(b[g]);i.normal.add(b[h]);
i.normal.normalize();this.faces.push(i);this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){var g=Math.cos(a);Math.cos(b);b=Math.sin(a);a*=c/d;c=Math.cos(a);g*=0.5*e*(2+c);b=0.5*e*(2+c)*b;e=0.5*f*e*Math.sin(a);return new THREE.Vector3(g,b,e)}THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.radialSegments=c||64;this.tubularSegments=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.radialSegments);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.radialSegments;++a){this.grid[a]=
Array(this.tubularSegments);for(b=0;b<this.tubularSegments;++b){var i=2*(a/this.radialSegments)*this.p*Math.PI,g=2*(b/this.tubularSegments)*Math.PI,f=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.subVectors(i,f);d.addVectors(i,f);e.crossVectors(c,d);d.crossVectors(e,c);e.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=i*d.x+g*e.x;f.y+=i*d.y+g*e.y;f.z+=i*d.z+g*e.z;this.grid[a][b]=this.vertices.push(new THREE.Vector3(f.x,
f.y,f.z))-1}}for(a=0;a<this.radialSegments;++a)for(b=0;b<this.tubularSegments;++b){var e=(a+1)%this.radialSegments,f=(b+1)%this.tubularSegments,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=new THREE.Vector2(a/this.radialSegments,b/this.tubularSegments),i=new THREE.Vector2((a+1)/this.radialSegments,b/this.tubularSegments),j=new THREE.Vector2((a+1)/this.radialSegments,(b+1)/this.tubularSegments),l=new THREE.Vector2(a/this.radialSegments,(b+1)/this.tubularSegments);this.faces.push(new THREE.Face4(c,
d,e,f));this.faceVertexUvs[0].push([g,i,j,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TubeGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.radialSegments=d||8;this.closed=e||!1;this.grid=[];var f,g,d=this.segments+1,h,i,j,e=new THREE.Vector3,l,n,b=new THREE.TubeGeometry.FrenetFrames(this.path,this.segments,this.closed);l=b.normals;n=b.binormals;this.tangents=b.tangents;this.normals=l;this.binormals=n;for(b=0;b<d;b++){this.grid[b]=[];c=b/(d-1);j=a.getPointAt(c);f=l[b];g=n[b];for(c=0;c<this.radialSegments;c++)h=2*(c/this.radialSegments)*
i.normal.normalize();this.faces.push(i);this.faceVertexUvs[0].push([a[e].clone(),a[f].clone(),a[g].clone(),a[h].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e){var f=Math.cos(a),g=Math.sin(a),a=b/c*a,b=Math.cos(a),f=0.5*(d*(2+b))*f,g=0.5*d*(2+b)*g,d=0.5*e*d*Math.sin(a);return new THREE.Vector3(f,g,d)}THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.radialSegments=c||64;this.tubularSegments=d||8;this.p=e||2;this.q=f||3;this.heightScale=g||1;this.grid=Array(this.radialSegments);c=new THREE.Vector3;d=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.radialSegments;++a){this.grid[a]=
Array(this.tubularSegments);b=2*(a/this.radialSegments)*this.p*Math.PI;f=h(b,this.q,this.p,this.radius,this.heightScale);b=h(b+0.01,this.q,this.p,this.radius,this.heightScale);c.subVectors(b,f);d.addVectors(b,f);e.crossVectors(c,d);d.crossVectors(e,c);e.normalize();d.normalize();for(b=0;b<this.tubularSegments;++b){var i=2*(b/this.tubularSegments)*Math.PI,g=-this.tube*Math.cos(i),i=this.tube*Math.sin(i),j=new THREE.Vector3;j.x=f.x+g*d.x+i*e.x;j.y=f.y+g*d.y+i*e.y;j.z=f.z+g*d.z+i*e.z;this.grid[a][b]=
this.vertices.push(j)-1}}for(a=0;a<this.radialSegments;++a)for(b=0;b<this.tubularSegments;++b){var e=(a+1)%this.radialSegments,f=(b+1)%this.tubularSegments,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=new THREE.Vector2(a/this.radialSegments,b/this.tubularSegments),i=new THREE.Vector2((a+1)/this.radialSegments,b/this.tubularSegments),j=new THREE.Vector2((a+1)/this.radialSegments,(b+1)/this.tubularSegments),l=new THREE.Vector2(a/this.radialSegments,(b+1)/this.tubularSegments);
this.faces.push(new THREE.Face4(c,d,e,f));this.faceVertexUvs[0].push([g,i,j,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TubeGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.path=a;this.segments=b||64;this.radius=c||1;this.radialSegments=d||8;this.closed=e||!1;this.grid=[];var f,g,d=this.segments+1,h,i,j,e=new THREE.Vector3,l,n,b=new THREE.TubeGeometry.FrenetFrames(this.path,this.segments,this.closed);l=b.normals;n=b.binormals;this.tangents=b.tangents;this.normals=l;this.binormals=n;for(b=0;b<d;b++){this.grid[b]=[];c=b/(d-1);j=a.getPointAt(c);f=l[b];g=n[b];for(c=0;c<this.radialSegments;c++)h=2*(c/this.radialSegments)*
Math.PI,i=-this.radius*Math.cos(h),h=this.radius*Math.sin(h),e.copy(j),e.x+=i*f.x+h*g.x,e.y+=i*f.y+h*g.y,e.z+=i*f.z+h*g.z,this.grid[b][c]=this.vertices.push(new THREE.Vector3(e.x,e.y,e.z))-1}for(b=0;b<this.segments;b++)for(c=0;c<this.radialSegments;c++)e=this.closed?(b+1)%this.segments:b+1,l=(c+1)%this.radialSegments,a=this.grid[b][c],d=this.grid[e][c],e=this.grid[e][l],l=this.grid[b][l],n=new THREE.Vector2(b/this.segments,c/this.radialSegments),f=new THREE.Vector2((b+1)/this.segments,c/this.radialSegments),
g=new THREE.Vector2((b+1)/this.segments,(c+1)/this.radialSegments),i=new THREE.Vector2(b/this.segments,(c+1)/this.radialSegments),this.faces.push(new THREE.Face4(a,d,e,l)),this.faceVertexUvs[0].push([n,f,g,i]);this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype);
THREE.TubeGeometry.FrenetFrames=function(a,b,c){new THREE.Vector3;var d=new THREE.Vector3;new THREE.Vector3;var e=[],f=[],g=[],h=new THREE.Vector3,i=new THREE.Matrix4,b=b+1,j,l,n;this.tangents=e;this.normals=f;this.binormals=g;for(j=0;j<b;j++)l=j/(b-1),e[j]=a.getTangentAt(l),e[j].normalize();f[0]=new THREE.Vector3;g[0]=new THREE.Vector3;a=Number.MAX_VALUE;j=Math.abs(e[0].x);l=Math.abs(e[0].y);n=Math.abs(e[0].z);j<=a&&(a=j,d.set(1,0,0));l<=a&&(a=l,d.set(0,1,0));n<=a&&d.set(0,0,1);h.crossVectors(e[0],
......
......@@ -47,7 +47,7 @@ THREE.TorusKnotGeometry = function ( radius, tube, radialSegments, tubularSegmen
pos.y = p1.y + cx * n.y + cy * bitan.y;
pos.z = p1.z + cx * n.z + cy * bitan.z;
this.grid[ i ][ j ] = scope.vertices.push( pos ) - 1;;
this.grid[ i ][ j ] = scope.vertices.push( pos ) - 1;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册