提交 d90f5e68 编写于 作者: Z zz85

Fixed text geo error

上级 faf189c3
......@@ -486,10 +486,10 @@ THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f
j-1:f];p=c[e-1][p?0:f+1];v=e/(h-1);u=(e-1)/(h-1);w=(f+1)/j;var t=f/j,n=new THREE.UV(1-w,v),v=new THREE.UV(1-t,v),t=new THREE.UV(1-t,u),y=new THREE.UV(1-w,u);e<c.length-1&&(u=this.vertices[g].position.clone(),w=this.vertices[m].position.clone(),A=this.vertices[o].position.clone(),u.normalize(),w.normalize(),A.normalize(),this.faces.push(new THREE.Face3(g,m,o,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z)])),this.faceVertexUvs[0].push([n,v,t]));e>1&&(u=
this.vertices[g].position.clone(),w=this.vertices[o].position.clone(),A=this.vertices[p].position.clone(),u.normalize(),w.normalize(),A.normalize(),this.faces.push(new THREE.Face3(g,o,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z)])),this.faceVertexUvs[0].push([n,t,y]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){var c,
e=this.getFace(),f=this.size/e.resolution,h=0,j=String(b).split(""),g=j.length,b=[];for(c=0;c<g;c++){var m=new THREE.Path,m=this.extractGlyphPoints(j[c],e,f,h,m);h+=m.offset;b.push(m.path)}e=h/2;f=this.extractPoints([],[]);f.paths=b;f.offset=e;return f},extractGlyphPoints:function(b,c,e,f,h){var j=[],g,m,o,p,n,t,v,u,w,A,y=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(y){if(y.o){c=y._cachedOutline||(y._cachedOutline=y.o.split(" "));o=c.length;for(b=0;b<o;)switch(m=c[b++],m){case "m":m=c[b++]*
e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,p));h.moveTo(m,p);break;case "l":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,p));h.lineTo(m,p);break;case "q":m=c[b++]*e+f;p=c[b++]*e;v=c[b++]*e+f;u=c[b++]*e;h.quadraticCurveTo(v,u,m,p);if(g=j[j.length-1]){n=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var x=g/divisions,I=THREE.Shape.Utils.b2(x,n,v,m),x=THREE.Shape.Utils.b2(x,t,u,p);j.push(new THREE.Vector2(I,x))}}break;case "b":if(m=c[b++]*e+f,p=c[b++]*e,v=c[b++]*e+f,u=c[b++]*-e,w=
c[b++]*e+f,A=c[b++]*-e,h.bezierCurveTo(m,p,v,u,w,A),g=j[j.length-1]){n=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)x=g/divisions,I=THREE.Shape.Utils.b3(x,n,v,w,m),x=THREE.Shape.Utils.b3(x,t,u,A,p),j.push(new THREE.Vector2(I,x))}}}return{offset:y.ha*e,points:j,path:h}}}};
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c=
this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),j=h.length,g=[],b=0;b<j;b++){var m=new THREE.Path,m=this.extractGlyphPoints(h[b],c,e,f,m);f+=m.offset;g.push(m.path)}return{paths:g,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var j=[],g,m,o,p,n,t,v,u,w,A,y=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(y){if(y.o){c=y._cachedOutline||(y._cachedOutline=y.o.split(" "));o=c.length;for(b=0;b<o;)switch(m=c[b++],m){case "m":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,
p));h.moveTo(m,p);break;case "l":m=c[b++]*e+f;p=c[b++]*e;j.push(new THREE.Vector2(m,p));h.lineTo(m,p);break;case "q":m=c[b++]*e+f;p=c[b++]*e;v=c[b++]*e+f;u=c[b++]*e;h.quadraticCurveTo(v,u,m,p);if(g=j[j.length-1]){n=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++){var x=g/divisions,I=THREE.Shape.Utils.b2(x,n,v,m),x=THREE.Shape.Utils.b2(x,t,u,p);j.push(new THREE.Vector2(I,x))}}break;case "b":if(m=c[b++]*e+f,p=c[b++]*e,v=c[b++]*e+f,u=c[b++]*-e,w=c[b++]*e+f,A=c[b++]*-e,h.bezierCurveTo(m,p,
v,u,w,A),g=j[j.length-1]){n=g.x;t=g.y;g=1;for(divisions=this.divisions;g<=divisions;g++)x=g/divisions,I=THREE.Shape.Utils.b3(x,n,v,w,m),x=THREE.Shape.Utils.b3(x,t,u,A,p),j.push(new THREE.Vector2(I,x))}}}return{offset:y.ha*e,points:j,path:h}}}};
(function(b){var c=function(b){for(var c=b.length,h=0,j=c-1,g=0;g<c;j=g++)h+=b[j].x*b[g].y-b[g].x*b[j].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var j=[],g=[],m=[],o,p,n;if(c(b)>0)for(p=0;p<h;p++)g[p]=p;else for(p=0;p<h;p++)g[p]=h-1-p;var t=2*h;for(p=h-1;h>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return j}o=p;h<=o&&(o=0);p=o+1;h<=p&&(p=0);n=p+1;h<=n&&(n=0);var v;a:{v=b;var u=o,w=p,A=n,y=h,x=g,I=void 0,B=void 0,E=void 0,
G=void 0,H=void 0,Q=void 0,F=void 0,C=void 0,N=void 0,B=v[x[u]].x,E=v[x[u]].y,G=v[x[w]].x,H=v[x[w]].y,Q=v[x[A]].x,F=v[x[A]].y;if(1.0E-10>(G-B)*(F-E)-(H-E)*(Q-B))v=!1;else{for(I=0;I<y;I++)if(!(I==u||I==w||I==A)){var C=v[x[I]].x,N=v[x[I]].y,W=void 0,K=void 0,X=void 0,L=void 0,U=void 0,k=void 0,Z=void 0,P=void 0,aa=void 0,ea=void 0,Y=void 0,$=void 0,W=X=U=void 0,W=Q-G,K=F-H,X=B-Q,L=E-F,U=G-B,k=H-E,Z=C-B,P=N-E,aa=C-G,ea=N-H,Y=C-Q,$=N-F,W=W*ea-K*aa,U=U*P-k*Z,X=X*$-L*Y;if(W>=0&&X>=0&&U>=0){v=!1;break a}}v=
!0}}if(v){j.push([b[g[o]],b[g[p]],b[g[n]]]);m.push([g[o],g[p],g[n]]);o=p;for(n=p+1;n<h;o++,n++)g[o]=g[n];h--;t=2*h}}if(f)return m;return j};b.Triangulate.area=c;return b})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
......
......@@ -142,10 +142,10 @@ THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,f
h-1:f];l=c[b-1][l?0:f+1];p=b/(g-1);o=(b-1)/(g-1);x=(f+1)/h;var n=f/h,m=new THREE.UV(1-x,p),p=new THREE.UV(1-n,p),n=new THREE.UV(1-n,o),u=new THREE.UV(1-x,o);b<c.length-1&&(o=this.vertices[e].position.clone(),x=this.vertices[j].position.clone(),w=this.vertices[k].position.clone(),o.normalize(),x.normalize(),w.normalize(),this.faces.push(new THREE.Face3(e,j,k,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)])),this.faceVertexUvs[0].push([m,p,n]));b>1&&(o=
this.vertices[e].position.clone(),x=this.vertices[k].position.clone(),w=this.vertices[l].position.clone(),o.normalize(),x.normalize(),w.normalize(),this.faces.push(new THREE.Face3(e,k,l,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)])),this.faceVertexUvs[0].push([m,n,u]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,c){var b=(new THREE.TextPath(a,c)).toShapes();THREE.ExtrudeGeometry.call(this,b,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,c){return(new TextPath(a,c)).toShapes()},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){var c,
b=this.getFace(),f=this.size/b.resolution,g=0,h=String(a).split(""),e=h.length,a=[];for(c=0;c<e;c++){var j=new THREE.Path,j=this.extractGlyphPoints(h[c],b,f,g,j);g+=j.offset;a.push(j.path)}b=g/2;f=this.extractPoints([],[]);f.paths=a;f.offset=b;return f},extractGlyphPoints:function(a,c,b,f,g){var h=[],e,j,k,l,m,n,p,o,x,w,u=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){c=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=c.length;for(a=0;a<k;)switch(j=c[a++],j){case "m":j=c[a++]*
b+f;l=c[a++]*b;h.push(new THREE.Vector2(j,l));g.moveTo(j,l);break;case "l":j=c[a++]*b+f;l=c[a++]*b;h.push(new THREE.Vector2(j,l));g.lineTo(j,l);break;case "q":j=c[a++]*b+f;l=c[a++]*b;p=c[a++]*b+f;o=c[a++]*b;g.quadraticCurveTo(p,o,j,l);if(e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++){var v=e/divisions,y=THREE.Shape.Utils.b2(v,m,p,j),v=THREE.Shape.Utils.b2(v,n,o,l);h.push(new THREE.Vector2(y,v))}}break;case "b":if(j=c[a++]*b+f,l=c[a++]*b,p=c[a++]*b+f,o=c[a++]*-b,x=
c[a++]*b+f,w=c[a++]*-b,g.bezierCurveTo(j,l,p,o,x,w),e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++)v=e/divisions,y=THREE.Shape.Utils.b3(v,m,p,x,j),v=THREE.Shape.Utils.b3(v,n,o,w,l),h.push(new THREE.Vector2(y,v))}}}return{offset:u.ha*b,points:h,path:g}}}};
THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(a,c){return(new TextPath(a,c)).toShapes()},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var c=
this.getFace(),b=this.size/c.resolution,f=0,g=String(a).split(""),h=g.length,e=[],a=0;a<h;a++){var j=new THREE.Path,j=this.extractGlyphPoints(g[a],c,b,f,j);f+=j.offset;e.push(j.path)}return{paths:e,offset:f/2}},extractGlyphPoints:function(a,c,b,f,g){var h=[],e,j,k,l,m,n,p,o,x,w,u=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){c=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=c.length;for(a=0;a<k;)switch(j=c[a++],j){case "m":j=c[a++]*b+f;l=c[a++]*b;h.push(new THREE.Vector2(j,
l));g.moveTo(j,l);break;case "l":j=c[a++]*b+f;l=c[a++]*b;h.push(new THREE.Vector2(j,l));g.lineTo(j,l);break;case "q":j=c[a++]*b+f;l=c[a++]*b;p=c[a++]*b+f;o=c[a++]*b;g.quadraticCurveTo(p,o,j,l);if(e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++){var v=e/divisions,y=THREE.Shape.Utils.b2(v,m,p,j),v=THREE.Shape.Utils.b2(v,n,o,l);h.push(new THREE.Vector2(y,v))}}break;case "b":if(j=c[a++]*b+f,l=c[a++]*b,p=c[a++]*b+f,o=c[a++]*-b,x=c[a++]*b+f,w=c[a++]*-b,g.bezierCurveTo(j,l,
p,o,x,w),e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++)v=e/divisions,y=THREE.Shape.Utils.b3(v,m,p,x,j),v=THREE.Shape.Utils.b3(v,n,o,w,l),h.push(new THREE.Vector2(y,v))}}}return{offset:u.ha*b,points:h,path:g}}}};
(function(a){var c=function(a){for(var c=a.length,g=0,h=c-1,e=0;e<c;h=e++)g+=a[h].x*a[e].y-a[e].x*a[h].y;return g*0.5};a.Triangulate=function(a,f){var g=a.length;if(g<3)return null;var h=[],e=[],j=[],k,l,m;if(c(a)>0)for(l=0;l<g;l++)e[l]=l;else for(l=0;l<g;l++)e[l]=g-1-l;var n=2*g;for(l=g-1;g>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return j;return h}k=l;g<=k&&(k=0);l=k+1;g<=l&&(l=0);m=l+1;g<=m&&(m=0);var p;a:{p=a;var o=k,x=l,w=m,u=g,v=e,y=void 0,t=void 0,A=void 0,
B=void 0,G=void 0,F=void 0,z=void 0,D=void 0,J=void 0,t=p[v[o]].x,A=p[v[o]].y,B=p[v[x]].x,G=p[v[x]].y,F=p[v[w]].x,z=p[v[w]].y;if(1.0E-10>(B-t)*(z-A)-(G-A)*(F-t))p=!1;else{for(y=0;y<u;y++)if(!(y==o||y==x||y==w)){var D=p[v[y]].x,J=p[v[y]].y,K=void 0,E=void 0,L=void 0,H=void 0,I=void 0,O=void 0,Q=void 0,C=void 0,P=void 0,M=void 0,N=void 0,R=void 0,K=L=I=void 0,K=F-B,E=z-G,L=t-F,H=A-z,I=B-t,O=G-A,Q=D-t,C=J-A,P=D-B,M=J-G,N=D-F,R=J-z,K=K*M-E*P,I=I*C-O*Q,L=L*R-H*N;if(K>=0&&L>=0&&I>=0){p=!1;break a}}p=!0}}if(p){h.push([a[e[k]],
a[e[l]],a[e[m]]]);j.push([e[k],e[l],e[m]]);k=l;for(m=l+1;m<g;k++,m++)e[k]=e[m];g--;n=2*g}}if(f)return j;return h};a.Triangulate.area=c;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
......
......@@ -501,13 +501,13 @@ THREE.FontUtils = {
//
// }
var extract = this.extractPoints( allPts, characterPts );
//var extract = this.extractPoints( allPts, characterPts );
//extract.contour = allPts;
extract.paths = fontPaths;
extract.offset = width;
//extract.paths = fontPaths;
//extract.offset = width;
return extract;
return {paths : fontPaths,offset : width };
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册