poly-extrude 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/poly-extrude.js +43 -5
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +43 -5
- package/package.json +1 -1
- package/readme.md +71 -20
- package/src/polyline.js +43 -3
package/dist/poly-extrude.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.6.0
|
3
3
|
*/
|
4
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).polyextrude=t.polyextrude||{})}(this,(function(t){"use strict";var n={exports:{}};function r(t,n,r){r=r||2;var e,o,h,a,u,p,x,f=n&&n.length,y=f?n[0]*r:t.length,d=i(t,0,y,r,!0),g=[];if(!d||d.next===d.prev)return g;if(f&&(d=function(t,n,r,e){var s,o,h,a=[];for(s=0,o=n.length;s<o;s++)(h=i(t,n[s]*e,s<o-1?n[s+1]*e:t.length,e,!1))===h.next&&(h.steiner=!0),a.push(v(h));for(a.sort(c),s=0;s<a.length;s++)r=l(a[s],r);return r}(t,n,d,r)),t.length>80*r){e=h=t[0],o=a=t[1];for(var z=r;z<y;z+=r)(u=t[z])<e&&(e=u),(p=t[z+1])<o&&(o=p),u>h&&(h=u),p>a&&(a=p);x=0!==(x=Math.max(h-e,a-o))?32767/x:0}return s(d,g,r,e,o,x,0),g}function i(t,n,r,i,e){var s,o;if(e===V(t,n,r,i)>0)for(s=n;s<r;s+=i)o=P(s,t[s],t[s+1],o);else for(s=r-i;s>=n;s-=i)o=P(s,t[s],t[s+1],o);return o&&g(o,o.next)&&(A(o),o=o.next),o}function e(t,n){if(!t)return t;n||(n=t);var r,i=t;do{if(r=!1,i.steiner||!g(i,i.next)&&0!==d(i.prev,i,i.next))i=i.next;else{if(A(i),(i=n=i.prev)===i.next)break;r=!0}}while(r||i!==n);return n}function s(t,n,r,i,c,l,p){if(t){!p&&l&&function(t,n,r,i){var e=t;do{0===e.z&&(e.z=x(e.x,e.y,n,r,i)),e.prevZ=e.prev,e.nextZ=e.next,e=e.next}while(e!==t);e.prevZ.nextZ=null,e.prevZ=null,function(t){var n,r,i,e,s,o,h,a,u=1;do{for(r=t,t=null,s=null,o=0;r;){for(o++,i=r,h=0,n=0;n<u&&(h++,i=i.nextZ);n++);for(a=u;h>0||a>0&&i;)0!==h&&(0===a||!i||r.z<=i.z)?(e=r,r=r.nextZ,h--):(e=i,i=i.nextZ,a--),s?s.nextZ=e:t=e,e.prevZ=s,s=e;r=i}s.nextZ=null,u*=2}while(o>1)}(e)}(t,i,c,l);for(var v,f,y=t;t.prev!==t.next;)if(v=t.prev,f=t.next,l?h(t,i,c,l):o(t))n.push(v.i/r|0),n.push(t.i/r|0),n.push(f.i/r|0),A(t),t=f.next,y=f.next;else if((t=f)===y){p?1===p?s(t=a(e(t),n,r),n,r,i,c,l,2):2===p&&u(t,n,r,i,c,l):s(e(t),n,r,i,c,l,1);break}}}function o(t){var n=t.prev,r=t,i=t.next;if(d(n,r,i)>=0)return!1;for(var e=n.x,s=r.x,o=i.x,h=n.y,a=r.y,u=i.y,c=e<s?e<o?e:o:s<o?s:o,l=h<a?h<u?h:u:a<u?a:u,p=e>s?e>o?e:o:s>o?s:o,x=h>a?h>u?h:u:a>u?a:u,v=i.next;v!==n;){if(v.x>=c&&v.x<=p&&v.y>=l&&v.y<=x&&f(e,h,s,a,o,u,v.x,v.y)&&d(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function h(t,n,r,i){var e=t.prev,s=t,o=t.next;if(d(e,s,o)>=0)return!1;for(var h=e.x,a=s.x,u=o.x,c=e.y,l=s.y,p=o.y,v=h<a?h<u?h:u:a<u?a:u,y=c<l?c<p?c:p:l<p?l:p,g=h>a?h>u?h:u:a>u?a:u,z=c>l?c>p?c:p:l>p?l:p,m=x(v,y,n,r,i),M=x(g,z,n,r,i),w=t.prevZ,b=t.nextZ;w&&w.z>=m&&b&&b.z<=M;){if(w.x>=v&&w.x<=g&&w.y>=y&&w.y<=z&&w!==e&&w!==o&&f(h,c,a,l,u,p,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,b.x>=v&&b.x<=g&&b.y>=y&&b.y<=z&&b!==e&&b!==o&&f(h,c,a,l,u,p,b.x,b.y)&&d(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;w&&w.z>=m;){if(w.x>=v&&w.x<=g&&w.y>=y&&w.y<=z&&w!==e&&w!==o&&f(h,c,a,l,u,p,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;b&&b.z<=M;){if(b.x>=v&&b.x<=g&&b.y>=y&&b.y<=z&&b!==e&&b!==o&&f(h,c,a,l,u,p,b.x,b.y)&&d(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function a(t,n,r){var i=t;do{var s=i.prev,o=i.next.next;!g(s,o)&&z(s,i,i.next,o)&&w(s,o)&&w(o,s)&&(n.push(s.i/r|0),n.push(i.i/r|0),n.push(o.i/r|0),A(i),A(i.next),i=t=o),i=i.next}while(i!==t);return e(i)}function u(t,n,r,i,o,h){var a=t;do{for(var u=a.next.next;u!==a.prev;){if(a.i!==u.i&&y(a,u)){var c=b(a,u);return a=e(a,a.next),c=e(c,c.next),s(a,n,r,i,o,h,0),void s(c,n,r,i,o,h,0)}u=u.next}a=a.next}while(a!==t)}function c(t,n){return t.x-n.x}function l(t,n){var r=function(t,n){var r,i=n,e=t.x,s=t.y,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var h=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(h<=e&&h>o&&(o=h,r=i.x<i.next.x?i:i.next,h===e))return r}i=i.next}while(i!==n);if(!r)return null;var a,u=r,c=r.x,l=r.y,x=1/0;i=r;do{e>=i.x&&i.x>=c&&e!==i.x&&f(s<l?e:o,s,c,l,s<l?o:e,s,i.x,i.y)&&(a=Math.abs(s-i.y)/(e-i.x),w(i,t)&&(a<x||a===x&&(i.x>r.x||i.x===r.x&&p(r,i)))&&(r=i,x=a)),i=i.next}while(i!==u);return r}(t,n);if(!r)return n;var i=b(r,t);return e(i,i.next),e(r,r.next)}function p(t,n){return d(t.prev,t,n.prev)<0&&d(n.next,t,t.next)<0}function x(t,n,r,i,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*e|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-i)*e|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function v(t){var n=t,r=t;do{(n.x<r.x||n.x===r.x&&n.y<r.y)&&(r=n),n=n.next}while(n!==t);return r}function f(t,n,r,i,e,s,o,h){return(e-o)*(n-h)>=(t-o)*(s-h)&&(t-o)*(i-h)>=(r-o)*(n-h)&&(r-o)*(s-h)>=(e-o)*(i-h)}function y(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==n.i&&r.next.i!==n.i&&z(r,r.next,t,n))return!0;r=r.next}while(r!==t);return!1}(t,n)&&(w(t,n)&&w(n,t)&&function(t,n){var r=t,i=!1,e=(t.x+n.x)/2,s=(t.y+n.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&e<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,n)&&(d(t.prev,t,n.prev)||d(t,n.prev,n))||g(t,n)&&d(t.prev,t,t.next)>0&&d(n.prev,n,n.next)>0)}function d(t,n,r){return(n.y-t.y)*(r.x-n.x)-(n.x-t.x)*(r.y-n.y)}function g(t,n){return t.x===n.x&&t.y===n.y}function z(t,n,r,i){var e=M(d(t,n,r)),s=M(d(t,n,i)),o=M(d(r,i,t)),h=M(d(r,i,n));return e!==s&&o!==h||(!(0!==e||!m(t,r,n))||(!(0!==s||!m(t,i,n))||(!(0!==o||!m(r,t,i))||!(0!==h||!m(r,n,i)))))}function m(t,n,r){return n.x<=Math.max(t.x,r.x)&&n.x>=Math.min(t.x,r.x)&&n.y<=Math.max(t.y,r.y)&&n.y>=Math.min(t.y,r.y)}function M(t){return t>0?1:t<0?-1:0}function w(t,n){return d(t.prev,t,t.next)<0?d(t,n,t.next)>=0&&d(t,t.prev,n)>=0:d(t,n,t.prev)<0||d(t,t.next,n)<0}function b(t,n){var r=new S(t.i,t.x,t.y),i=new S(n.i,n.x,n.y),e=t.next,s=n.prev;return t.next=n,n.prev=t,r.next=e,e.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function P(t,n,r,i){var e=new S(t,n,r);return i?(e.next=i.next,e.prev=i,i.next.prev=e,i.next=e):(e.prev=e,e.next=e),e}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function S(t,n,r){this.i=t,this.x=n,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function V(t,n,r,i){for(var e=0,s=n,o=r-i;s<r;s+=i)e+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return e}n.exports=r,n.exports.default=r,r.deviation=function(t,n,r,i){var e=n&&n.length,s=e?n[0]*r:t.length,o=Math.abs(V(t,0,s,r));if(e)for(var h=0,a=n.length;h<a;h++){var u=n[h]*r,c=h<a-1?n[h+1]*r:t.length;o-=Math.abs(V(t,u,c,r))}var l=0;for(h=0;h<i.length;h+=3){var p=i[h]*r,x=i[h+1]*r,v=i[h+2]*r;l+=Math.abs((t[p]-t[v])*(t[x+1]-t[p+1])-(t[p]-t[x])*(t[v+1]-t[p+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},r.flatten=function(t){for(var n=t[0][0].length,r={vertices:[],holes:[],dimensions:n},i=0,e=0;e<t.length;e++){for(var s=0;s<t[e].length;s++)for(var o=0;o<n;o++)r.vertices.push(t[e][s][o]);e>0&&(i+=t[e-1].length,r.holes.push(i))}return r};var Z=n.exports;function _(t){for(var n,r,i=0,e=1,s=t.length;e<s;)n=r||t[0],i+=((r=t[e])[0]-n[0])*(r[1]+n[1]),e++;return i>0}function L(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t}function F(t,n){var r=n[0],i=n[1],e=n[2],s=Math.sqrt(r*r+i*i+e*e)||1;return t[0]=r/s,t[1]=i/s,t[2]=e/s,t}function O(t,n){function r(t,n,r,i){t[0]=n,t[1]=r,t[2]=i}for(var i,e,s,o,h,a,u,c,l,p=[],x=[],v=[],f=[],y=[],d=[],g=t.length,z=new Float32Array(n.length),m=0;m<g;){var M=3*t[m],w=3*t[m+1],b=3*t[m+2];r(p,n[M],n[M+1],n[M+2]),r(x,n[w],n[w+1],n[w+2]),r(v,n[b],n[b+1],n[b+2]),L(y,v,x),L(f,p,x),i=d,s=f,o=void 0,h=void 0,a=void 0,u=void 0,c=void 0,l=void 0,o=(e=y)[0],h=e[1],a=e[2],u=s[0],c=s[1],l=s[2],i[0]=h*l-a*c,i[1]=a*u-o*l,i[2]=o*c-h*u;for(var P=0;P<3;P++)z[M+P]+=d[P],z[w+P]+=d[P],z[b+P]+=d[P];m+=3}for(var A=0,S=z.length;A<S;)r(d,z[A],z[A+1],z[A+2]),F(d,d),z[A]=d[0]||0,z[A+1]=d[1]||0,z[A+2]=d[2]||0,A+=3;return z}function I(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var n=0,r=0,i=0,e=t.length;i<e;i++){var s=t[i],o=s.position,h=s.indices;n+=o.length,r+=h.length}for(var a={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(r),results:t},u=0,c=0,l=0,p=0,x=0,v=t.length;x<v;x++){var f=t[x],y=f.position,d=f.indices,g=f.normal,z=f.uv;a.position.set(y,u),a.normal.set(g,u),a.uv.set(z,p);for(var m=0,M=d.length;m<M;){var w=d[m]+c;a.indices[l]=w,l++,m++}p+=z.length,u+=y.length,c+=y.length/3}return a}function U(t){return 180*t/Math.PI}function j(t){return t/180*Math.PI}function q(t,n,r,i,e,s){var o=3*r,h=3*i,a=3*e,u=3*s,c=n[o],l=n[o+1],p=n[o+2],x=n[h],v=n[h+1],f=n[h+2],y=n[a],d=n[a+1],g=n[a+2],z=n[u],m=n[u+1],M=n[u+2];Math.abs(l-v)<Math.abs(c-x)?(t.push(c,1-p),t.push(x,1-f),t.push(y,1-g),t.push(z,1-M)):(t.push(l,1-p),t.push(v,1-f),t.push(d,1-g),t.push(m,1-M))}function C(t){T(t)||t.push(t[0])}function T(t){var n=t.length,r=t[0],i=r[0],e=r[1],s=t[n-1],o=s[0],h=s[1];return i===o&&e===h}function k(t,n){var r=n.depth,i=t.depths,e=r,s=r;i&&(e=i[0],s=i[1]);for(var o=[],h=[],a=[],u=t.leftPoints,c=t.rightPoints,l=0,p=u.length;l<p;){var x=3*l,v=u[l],f=v[0],y=v[1],d=v[2];o[x]=f,o[x+1]=y,o[x+2]=e+d;var g=c[l],z=g[0],m=g[1],M=g[2],w=3*p+x;o[w]=z,o[w+1]=m,o[w+2]=s+M;var b=2*p*3+x;o[b]=f,o[b+1]=y,o[b+2]=d;var P=2*p*3+3*p+x;o[P]=z,o[P+1]=m,o[P+2]=M,l++}for(l=0,p=o.length;l<p;){var A=o[l],S=o[l+1];a.push(A,S),l+=3}for(l=0,p=u.length;l<p-1;){var V=l,Z=l+1,_=V+p,L=Z+p;h.push(V,_,Z),h.push(_,L,Z);var F=l+2*p,O=F+1,I=F+p,U=O+p;h.push(F,I,O),h.push(I,U,O),l++}if(t.index=h,t.points=o,t.uvs=a,i)for(p=u.length,l=0;l<p;)u[l].depth=e,c[l].depth=s,l++}function B(t,n){var r=t.points,i=t.index,e=t.leftPoints,s=t.rightPoints,o=t.uvs,h=n.depth,a=[e,s],u=t.depths;function c(t,n){var e=r.length/3;r.push(t[0],t[1],(u?t.depth:h)+t[2],n[0],n[1],(u?n.depth:h)+n[2],t[0],t[1],t[2],n[0],n[1],n[2]);var s=e+2,a=e+3,c=e,l=e+1;i.push(s,c,a,c,l,a),q(o,r,s,a,c,l)}for(var l=0,p=a.length;l<p;l++){var x=a[l];l>0&&(x=(x=x.map((function(t){return t}))).reverse());for(var v=0,f=x.length-1;v<f;){c(x[v],x[v+1]),v++}}for(var y=e.length,d=[s[0],e[0],e[y-1],s[y-1]],g=0;g<d.length;g+=2){c(d[g],d[g+1])}}var R={x:0,y:0},E={x:0,y:0};function N(t,n){for(var r=n.lineWidth/2,i=[],e=[],s=[],o=t.length,h=0;h<o;){var a=t[h],u=t[h+1],c=t[h];h===o-1&&(a=t[o-2],u=t[o-1]);var l=u[1]-a[1],p=u[0]-a[0],x=0,v=U(Math.atan(l/p));if(0===h||h===o-1)x=v,x-=90;else{var f=t[h-1];R.x=f[0]-a[0],R.y=f[1]-a[1],E.x=u[0]-a[0],E.y=u[1]-a[1],x=v-W(R,E)/2}var y=j(x),d=c,g=[Math.cos(y)+d[0],Math.sin(y)+d[1]],z=Q(a,u,r),m=z[0],M=z[1],w=H(m[0],m[1],d,g),b=H(M[0],M[1],d,g);if(!w||!b){var P=i.length,A=i[P-2],S=i[P-1];if(!A||!S)continue;w=[A[0],A[1]],b=[S[0],S[1]]}w[2]=c[2]||0,b[2]=c[2]||0,i.push(w,b),D(w,a,u)?(e.push(w),s.push(b)):(e.push(b),s.push(w)),h++}return{offsetPoints:i,leftPoints:e,rightPoints:s}}var W=function(t,n){var r=t.x,i=t.y,e=n.x,s=n.y,o=r*e+i*s,h=r*s-i*e;return(Math.atan2(h,o)/Math.PI*180+360)%360};function D(t,n,r){var i=n[0],e=n[1],s=r[0],o=r[1];return(e-o)*t[0]+(s-i)*t[1]+i*o-s*e>0}function Q(t,n,r){var i=n[1]-t[1],e=n[0]-t[0],s=Math.atan2(i,e),o=s+Math.PI/2,h=Math.cos(o)*r,a=Math.sin(o)*r,u=[t[0]+h,t[1]+a],c=[n[0]+h,n[1]+a],l=s-Math.PI/2;return h=Math.cos(l)*r,a=Math.sin(l)*r,[[u,c],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function H(t,n,r,i){var e=n[0]-t[0],s=n[1]-t[1],o=i[0]-r[0],h=i[1]-r[1];if(0===e&&0===o)return null;if(0===s&&0===h)return null;var a,u,c=s/e,l=h/o,p=t[1]-c*t[0],x=r[1]-l*r[0];return 0===e?u=l*(a=t[0])+x:0===o?u=c*(a=r[0])+p:0===s?a=((u=t[1])-x)/l:0===h?a=((u=r[1])-p)/c:u=c*(a=(x-p)/(c-l))+p,[a,u]}var X=function(){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=t,this.y=n,this.z=r}var n=t.prototype;return n.set=function(t,n,r){return void 0===r&&(r=this.z),this.x=t,this.y=n,this.z=r,this},n.clone=function(){return new this.constructor(this.x,this.y,this.z)},n.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},n.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.addVectors=function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this},n.addScaledVector=function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this},n.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.subVectors=function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this},n.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.multiplyVectors=function(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this},n.applyMatrix4=function(t){var n=this.x,r=this.y,i=this.z,e=t.elements,s=1/(e[3]*n+e[7]*r+e[11]*i+e[15]);return this.x=(e[0]*n+e[4]*r+e[8]*i+e[12])*s,this.y=(e[1]*n+e[5]*r+e[9]*i+e[13])*s,this.z=(e[2]*n+e[6]*r+e[10]*i+e[14])*s,this},n.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.divideScalar=function(t){return this.multiplyScalar(1/t)},n.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},n.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},n.clamp=function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this},n.clampScalar=function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this},n.clampLength=function(t,n){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(n,r)))},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.normalize=function(){return this.divideScalar(this.length()||1)},n.setLength=function(t){return this.normalize().multiplyScalar(t)},n.lerp=function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this},n.lerpVectors=function(t,n,r){return this.x=t.x+(n.x-t.x)*r,this.y=t.y+(n.y-t.y)*r,this.z=t.z+(n.z-t.z)*r,this},n.cross=function(t){return this.crossVectors(this,t)},n.crossVectors=function(t,n){var r=t.x,i=t.y,e=t.z,s=n.x,o=n.y,h=n.z;return this.x=i*h-e*o,this.y=e*s-r*h,this.z=r*o-i*s,this},n.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.fromArray=function(t,n){return void 0===n&&(n=0),this.x=t[n],this.y=t[n+1],this.z=t[n+2],this},n.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t}(),G=function(){function t(){this.pos=new X,this.dir=new X,this.right=new X,this.up=new X,this.dist=0,this.widthScale=1,this.sharp=!1}var n=t.prototype;return n.lerpPathPoints=function(t,n,r){this.pos.lerpVectors(t.pos,n.pos,r),this.dir.lerpVectors(t.dir,n.dir,r),this.up.lerpVectors(t.up,n.up,r),this.right.lerpVectors(t.right,n.right,r),this.dist=(n.dist-t.dist)*r+t.dist,this.widthScale=(n.widthScale-t.widthScale)*r+t.widthScale},n.copy=function(t){this.pos.copy(t.pos),this.dir.copy(t.dir),this.up.copy(t.up),this.right.copy(t.right),this.dist=t.dist,this.widthScale=t.widthScale},t}(),J=function(){function t(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f)}var n=t.prototype;return n.set=function(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f){var y=this.elements;return y[0]=t,y[4]=n,y[8]=r,y[12]=i,y[1]=e,y[5]=s,y[9]=o,y[13]=h,y[2]=a,y[6]=u,y[10]=c,y[14]=l,y[3]=p,y[7]=x,y[11]=v,y[15]=f,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var r=Math.cos(n),i=Math.sin(n),e=1-r,s=t.x,o=t.y,h=t.z,a=e*s,u=e*o;return this.set(a*s+r,a*o-i*h,a*h+i*o,0,a*o+i*h,u*o+r,u*h-i*s,0,a*h-i*o,u*h+i*s,e*h*h+r,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,r=t.elements,i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0},t}();function K(t,n){return K=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},K(t,n)}function Y(t,n,r,i){return function(t,n){var r=1-t;return r*r*n}(t,n)+function(t,n){return 2*(1-t)*t*n}(t,r)+function(t,n){return t*t*n}(t,i)}var $=function(t){var n,r;function i(n,r,i){var e;return void 0===n&&(n=new X),void 0===r&&(r=new X),void 0===i&&(i=new X),(e=t.call(this)||this).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=n,e.v1=r,e.v2=i,e}return r=t,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,K(n,r),i.prototype.getPoint=function(t,n){void 0===n&&(n=new X);var r=n,i=this.v0,e=this.v1,s=this.v2;return r.set(Y(t,i.x,e.x,s.x),Y(t,i.y,e.y,s.y),Y(t,i.z,e.z,s.z)),r},i}(function(){function t(){this.type="Curve",this.arcLengthDivisions=200}var n=t.prototype;return n.getPoint=function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},n.getPointAt=function(t,n){var r=this.getUtoTmapping(t);return this.getPoint(r,n)},n.getPoints=function(t){void 0===t&&(t=5);for(var n=[],r=0;r<=t;r++)n.push(this.getPoint(r/t));return n},n.getLength=function(){var t=this.getLengths();return t[t.length-1]},n.getLengths=function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,r=[],i=this.getPoint(0),e=0;r.push(0);for(var s=1;s<=t;s++)e+=(n=this.getPoint(s/t)).distanceTo(i),r.push(e),i=n;return this.cacheArcLengths=r,r},n.getUtoTmapping=function(t,n){var r,i=this.getLengths(),e=0,s=i.length;r=n||t*i[s-1];for(var o,h=0,a=s-1;h<=a;)if((o=i[e=Math.floor(h+(a-h)/2)]-r)<0)h=e+1;else{if(!(o>0)){a=e;break}a=e-1}if(i[e=a]===r)return e/(s-1);var u=i[e];return(e+(r-u)/(i[e+1]-u))/(s-1)},t}()),tt=new X,nt=new X,rt=new X,it=new J,et=new $;var st=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,r,i,e){if(void 0===n&&(n=.1),void 0===r&&(r=10),void 0===i&&(i=null),void 0===e&&(e=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);e&&!t[0].equals(t[t.length-1])&&t.push((new X).copy(t[0]));for(var s=0,o=t.length;s<o;s++)if(0===s)this._start(t[s],t[s+1],i);else if(s===o-1)if(e){this._corner(t[s],t[1],n,r,i);var h=this.array[0].dist;this.array[0].copy(this.array[this.count-1]),this.array[0].dist=h}else this._end(t[s]);else this._corner(t[s],t[s+1],n,r,i)},n.distance=function(){return this.count>0?this.array[this.count-1].dist:0},n._getByIndex=function(t){return this.array[t]||(this.array[t]=new G),this.array[t]},n._start=function(t,n,r){this.count=0;var i=this._getByIndex(this.count);if(i.pos.copy(t),i.dir.subVectors(n,t),r)i.up.copy(r);else{var e=Number.MAX_VALUE,s=Math.abs(i.dir.x),o=Math.abs(i.dir.y),h=Math.abs(i.dir.z);s<e&&(e=s,i.up.set(1,0,0)),o<e&&(e=o,i.up.set(0,1,0)),h<e&&i.up.set(0,0,1)}i.right.crossVectors(i.dir,i.up).normalize(),i.up.crossVectors(i.right,i.dir).normalize(),i.dist=0,i.widthScale=1,i.sharp=!1,i.dir.normalize(),this.count++},n._end=function(t){var n=this.array[this.count-1],r=this._getByIndex(this.count);r.pos.copy(t),r.dir.subVectors(t,n.pos);var i=r.dir.length();r.dir.normalize(),r.up.copy(n.up);var e=tt.crossVectors(n.dir,r.dir);if(e.length()>Number.EPSILON){e.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(r.dir),-1),1));r.up.applyMatrix4(it.makeRotationAxis(e,s))}r.right.crossVectors(r.dir,r.up).normalize(),r.dist=n.dist+i,r.widthScale=1,r.sharp=!1,this.count++},n._corner=function(t,n,r,i,e){if(r>0&&i>0){for(var s=function(t,n,r,i,e,s){var o=tt.subVectors(n,t),h=nt.subVectors(r,n),a=o.length(),u=h.length();o.normalize(),h.normalize();var c=Math.min(.999999*(e?a/2:a),i);s.v0.copy(n).sub(o.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/2*.999999,i);return s.v2.copy(n).add(h.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,r,this.count-1==0,et),o=s.getPoints(i),h=0;h<i;h++)this._sharpCorner(o[h],o[h+1],e,0===h?1:0);o[i].equals(n)||this._sharpCorner(o[i],n,e,2)}else this._sharpCorner(t,n,e,0,!0)},n._sharpCorner=function(t,n,r,i,e){void 0===i&&(i=0),void 0===e&&(e=!1);var s=this.array[this.count-1],o=this._getByIndex(this.count),h=tt.subVectors(t,s.pos),a=nt.subVectors(n,t),u=h.length();if(h.normalize(),a.normalize(),o.pos.copy(t),1===i?o.dir.copy(h):2===i?o.dir.copy(a):(o.dir.addVectors(h,a),o.dir.normalize()),r)1===o.dir.dot(r)?o.right.crossVectors(a,r).normalize():o.right.crossVectors(o.dir,r).normalize(),o.up.crossVectors(o.right,o.dir).normalize();else{o.up.copy(s.up);var c=rt.crossVectors(s.dir,o.dir);if(c.length()>Number.EPSILON){c.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(o.dir),-1),1));o.up.applyMatrix4(it.makeRotationAxis(c,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+u;var p=h.dot(a);o.widthScale=Math.min(1/Math.sqrt((1+p)/2),1.415)||1,o.sharp=Math.abs(p-1)>.05&&e,this.count++},t}(),ot=new X(0,0,1);t.cylinder=function(t,n){void 0===n&&(n={}),n=Object.assign({},{radius:1,height:2,radialSegments:6},n);for(var r=Math.round(Math.max(4,n.radialSegments)),i=n,e=i.radius,s=i.height,o=360/r/360*Math.PI*2,h=r+1,a=new Float32Array(3*h*2),u=t[0],c=t[1],l=0,p=0,x=3*h,v=2*h,f=[],y=[],d=-1;d<r;d++){var g=o*d,z=Math.cos(g)*e+u,m=Math.sin(g)*e+c;a[l]=z,a[l+1]=m,a[l+2]=0,a[l+x]=z,a[l+1+x]=m,a[l+2+x]=s;var M,w;M=.5+z/e/2,w=.5+m/e/2,y[p]=M,y[p+1]=w,y[p+v]=M,y[p+1+v]=w,l+=3,p+=2,d>1&&f.push(0,d-1,d)}a[l-=3]=a[0],a[l+1]=a[1],a[l+2]=a[2];var b=a.length;a[b-3]=a[0],a[b-2]=a[1],a[b-1]=s;for(var P=f.length,A=0;A<P;A++){var S=f[A];f.push(S+h)}var V=new Float32Array(2*(3*h*2-6)),Z=-1;l=2*h,p=0;for(var _=0,L=a.length/2;_<L-3;_+=3){var F=a[_],I=a[_+1],U=a[_+3],j=a[_+4];V[++Z]=F,V[++Z]=I,V[++Z]=s,V[++Z]=U,V[++Z]=j,V[++Z]=s,V[++Z]=F,V[++Z]=I,V[++Z]=0,V[++Z]=U,V[++Z]=j,V[++Z]=0;var q=l+2,C=l+3,T=l,k=l+1;f.push(T,q,k,q,C,k),l+=4;var B=p/h,R=(p+1)/h;y.push(B,s/e/2,R,s/e/2,B,0,R,0),p++}var E=new Float32Array(a.length+V.length);E.set(a,0),E.set(V,a.length);var N=O(f,E);return{points:a,indices:new Uint32Array(f),position:E,normal:N,uv:new Float32Array(y)}},t.expandLine=N,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);var r=t.map((function(t){var r=t.map((function(t){var n=t[0],r=t[1],i=t[2];return new X(n,r,i||0)})),i=new st;i.set(r,n.cornerRadius,n.cornerSplit,ot);var e=function(t,n){var r=n.lineWidth||.1,i=1,e=r/2,s=r,o=t.distance(),h=i*o;if(0===o)return null;var a,u=e/s,c=0,l=[],p=[],x=[],v=[],f=0,y=new X,d=new X,g=new X,z=new X,m=new X,M=new X;function w(t){var n=0===l.length,r=t.sharp&&!n,i=t.dist/s,o=t.dir,h=t.up,a=t.right;if(y.copy(a).multiplyScalar(e*t.widthScale),d.copy(a).multiplyScalar(-e*t.widthScale),y.add(t.pos),d.add(t.pos),r){g.fromArray(l,l.length-6).sub(d),z.fromArray(l,l.length-3).sub(y);var w,b,P=g.length()-z.length();P>0?(w=g,b=d):(w=z,b=y),m.copy(w).setLength(Math.abs(P)).add(b);var A=M.copy(b).sub(m).normalize().dot(o)*M.copy(b).sub(m).length()*2;M.copy(o).setLength(A).add(m),P>0?(l.push(m.x,m.y,m.z,y.x,y.y,y.z,d.x,d.y,d.z,y.x,y.y,y.z,M.x,M.y,M.z,y.x,y.y,y.z),f+=6,v.push(f-6,f-8,f-7,f-6,f-7,f-5,f-4,f-6,f-5,f-2,f-4,f-1),c+=12):(l.push(d.x,d.y,d.z,m.x,m.y,m.z,d.x,d.y,d.z,y.x,y.y,y.z,d.x,d.y,d.z,M.x,M.y,M.z),f+=6,v.push(f-6,f-8,f-7,f-6,f-7,f-5,f-6,f-5,f-3,f-2,f-3,f-1),c+=12),p.push(h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z),x.push(i-u,0,i-u,1,i,0,i,1,i+u,0,i+u,1)}else l.push(d.x,d.y,d.z,y.x,y.y,y.z),p.push(h.x,h.y,h.z,h.x,h.y,h.z),x.push(i,0,i,1),f+=2,n||(v.push(f-2,f-4,f-3,f-2,f-3,f-1),c+=6)}if(h>0)for(var b=0;b<t.count;b++){var P=t.array[b];if(P.dist>h){var A=t.array[b-1];a=new G;var S=(h-A.dist)/(P.dist-A.dist);a.lerpPathPoints(A,P,S),w(a);break}w(P)}else a=t.array[0];return{points:l,normal:p,uvs:x,index:v,count:c}}(i,n);return e.line=t,e.position=new Float32Array(e.points),e.indices=new Uint32Array(e.index),e.uv=new Float32Array(e.uvs),e.normal=new Float32Array(e.normal),e})),i=I(r);return i.lines=t,i},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);var r=t.map((function(t){for(var r=0,i=t.length;r<i;r++){var e=t[r];C(e),0===r?_(e)||(t[r]=e.reverse()):_(e)&&(t[r]=e.reverse()),T(e)&&e.splice(e.length-1,1)}var s=function(t,n){for(var r=function(t){var n=0,r=0,i=t.length;for(;r<i;)n+=t[r].length,r++;return n}(t),i=t.length,e=[],s=new Float32Array(2*r),o=[],h=[],a=3*r,u=2*r,c=n.depth,l=0,p=0,x=0,v=0;v<i;v++){var f=t[v];v>0&&e.push(l/2);for(var y=0,d=f.length;y<d;){var g=f[y],z=g[0],m=g[1];s[l++]=z,s[l++]=m,o[p]=z,o[p+1]=m,o[p+2]=c,o[a+p]=z,o[a+p+1]=m,o[a+p+2]=0,h[x]=z,h[x+1]=m,h[u+x]=z,h[u+x+1]=m,p+=3,x+=2,y++}}return{flatVertices:s,holes:e,points:o,count:r,uvs:h}}(t,n);return s.polygon=t,function(t,n){for(var r=[],i=t.count,e=0,s=n.length;e<s;e+=3){var o=n[e],h=n[e+1],a=n[e+2];r[e]=o,r[e+1]=h,r[e+2]=a;var u=s+e,c=i+o,l=i+h,p=i+a;r[u]=c,r[u+1]=l,r[u+2]=p}t.index=r}(s,Z(s.flatVertices,s.holes,2)),function(t,n){for(var r=t.points,i=t.index,e=t.polygon,s=t.uvs,o=n.depth,h=0,a=e.length;h<a;h++)for(var u=e[h],c=0,l=u.length;c<l;){var p=u[c],x=u[c+1];c===l-1&&(x=u[0]);var v=r.length/3,f=p[0],y=p[1],d=x[0],g=x[1];r.push(f,y,o,d,g,o,f,y,0,d,g,0);var z=v+2,m=v+3,M=v,w=v+1;i.push(z,M,m,M,w,m),q(s,r,z,m,M,w),c++}}(s,n),s.position=new Float32Array(s.points),s.indices=new Uint32Array(s.index),s.uv=new Float32Array(s.uvs),s.normal=O(s.indices,s.position),s})),i=I(r);return i.polygons=t,i},t.extrudePolylines=function(t,n){n=Object.assign({},{depth:2,lineWidth:1},n);var r=t.map((function(t){var r=N(t,n);return r.line=t,k(r,n),B(r,n),r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.index),r.uv=new Float32Array(r.uvs),r.normal=O(r.indices,r.position),r})),i=I(r);return i.lines=t,i},t.extrudeSlopes=function(t,n){var r=n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0},n),i=r.depth,e=r.side,s=r.sideDepth,o=t.map((function(t){var r=N(t,n);r.line=t;for(var o,h=r.leftPoints,a=r.rightPoints,u={line:t},c=0,l=t.length;c<l;c++)t[c][2]=t[c][2]||0;return"left"===e?(u.leftPoints=h,u.rightPoints=t,o=[s,i]):(u.leftPoints=t,u.rightPoints=a,o=[i,s]),u.depths=o,k(u,n),B(u,n),u.position=new Float32Array(u.points),u.indices=new Uint32Array(u.index),u.uv=new Float32Array(u.uvs),u.normal=O(u.indices,u.position),u})),h=I(o);return h.lines=t,h},t.leftOnLine=D,Object.defineProperty(t,"__esModule",{value:!0})}));
|
4
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).polyextrude=t.polyextrude||{})}(this,(function(t){"use strict";var n={exports:{}};function r(t,n,r){r=r||2;var e,o,h,a,u,p,x,f=n&&n.length,y=f?n[0]*r:t.length,d=i(t,0,y,r,!0),g=[];if(!d||d.next===d.prev)return g;if(f&&(d=function(t,n,r,e){var s,o,h,a=[];for(s=0,o=n.length;s<o;s++)(h=i(t,n[s]*e,s<o-1?n[s+1]*e:t.length,e,!1))===h.next&&(h.steiner=!0),a.push(v(h));for(a.sort(c),s=0;s<a.length;s++)r=l(a[s],r);return r}(t,n,d,r)),t.length>80*r){e=h=t[0],o=a=t[1];for(var m=r;m<y;m+=r)(u=t[m])<e&&(e=u),(p=t[m+1])<o&&(o=p),u>h&&(h=u),p>a&&(a=p);x=0!==(x=Math.max(h-e,a-o))?32767/x:0}return s(d,g,r,e,o,x,0),g}function i(t,n,r,i,e){var s,o;if(e===V(t,n,r,i)>0)for(s=n;s<r;s+=i)o=P(s,t[s],t[s+1],o);else for(s=r-i;s>=n;s-=i)o=P(s,t[s],t[s+1],o);return o&&g(o,o.next)&&(S(o),o=o.next),o}function e(t,n){if(!t)return t;n||(n=t);var r,i=t;do{if(r=!1,i.steiner||!g(i,i.next)&&0!==d(i.prev,i,i.next))i=i.next;else{if(S(i),(i=n=i.prev)===i.next)break;r=!0}}while(r||i!==n);return n}function s(t,n,r,i,c,l,p){if(t){!p&&l&&function(t,n,r,i){var e=t;do{0===e.z&&(e.z=x(e.x,e.y,n,r,i)),e.prevZ=e.prev,e.nextZ=e.next,e=e.next}while(e!==t);e.prevZ.nextZ=null,e.prevZ=null,function(t){var n,r,i,e,s,o,h,a,u=1;do{for(r=t,t=null,s=null,o=0;r;){for(o++,i=r,h=0,n=0;n<u&&(h++,i=i.nextZ);n++);for(a=u;h>0||a>0&&i;)0!==h&&(0===a||!i||r.z<=i.z)?(e=r,r=r.nextZ,h--):(e=i,i=i.nextZ,a--),s?s.nextZ=e:t=e,e.prevZ=s,s=e;r=i}s.nextZ=null,u*=2}while(o>1)}(e)}(t,i,c,l);for(var v,f,y=t;t.prev!==t.next;)if(v=t.prev,f=t.next,l?h(t,i,c,l):o(t))n.push(v.i/r|0),n.push(t.i/r|0),n.push(f.i/r|0),S(t),t=f.next,y=f.next;else if((t=f)===y){p?1===p?s(t=a(e(t),n,r),n,r,i,c,l,2):2===p&&u(t,n,r,i,c,l):s(e(t),n,r,i,c,l,1);break}}}function o(t){var n=t.prev,r=t,i=t.next;if(d(n,r,i)>=0)return!1;for(var e=n.x,s=r.x,o=i.x,h=n.y,a=r.y,u=i.y,c=e<s?e<o?e:o:s<o?s:o,l=h<a?h<u?h:u:a<u?a:u,p=e>s?e>o?e:o:s>o?s:o,x=h>a?h>u?h:u:a>u?a:u,v=i.next;v!==n;){if(v.x>=c&&v.x<=p&&v.y>=l&&v.y<=x&&f(e,h,s,a,o,u,v.x,v.y)&&d(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function h(t,n,r,i){var e=t.prev,s=t,o=t.next;if(d(e,s,o)>=0)return!1;for(var h=e.x,a=s.x,u=o.x,c=e.y,l=s.y,p=o.y,v=h<a?h<u?h:u:a<u?a:u,y=c<l?c<p?c:p:l<p?l:p,g=h>a?h>u?h:u:a>u?a:u,m=c>l?c>p?c:p:l>p?l:p,z=x(v,y,n,r,i),M=x(g,m,n,r,i),w=t.prevZ,b=t.nextZ;w&&w.z>=z&&b&&b.z<=M;){if(w.x>=v&&w.x<=g&&w.y>=y&&w.y<=m&&w!==e&&w!==o&&f(h,c,a,l,u,p,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,b.x>=v&&b.x<=g&&b.y>=y&&b.y<=m&&b!==e&&b!==o&&f(h,c,a,l,u,p,b.x,b.y)&&d(b.prev,b,b.next)>=0)return!1;b=b.nextZ}for(;w&&w.z>=z;){if(w.x>=v&&w.x<=g&&w.y>=y&&w.y<=m&&w!==e&&w!==o&&f(h,c,a,l,u,p,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;b&&b.z<=M;){if(b.x>=v&&b.x<=g&&b.y>=y&&b.y<=m&&b!==e&&b!==o&&f(h,c,a,l,u,p,b.x,b.y)&&d(b.prev,b,b.next)>=0)return!1;b=b.nextZ}return!0}function a(t,n,r){var i=t;do{var s=i.prev,o=i.next.next;!g(s,o)&&m(s,i,i.next,o)&&w(s,o)&&w(o,s)&&(n.push(s.i/r|0),n.push(i.i/r|0),n.push(o.i/r|0),S(i),S(i.next),i=t=o),i=i.next}while(i!==t);return e(i)}function u(t,n,r,i,o,h){var a=t;do{for(var u=a.next.next;u!==a.prev;){if(a.i!==u.i&&y(a,u)){var c=b(a,u);return a=e(a,a.next),c=e(c,c.next),s(a,n,r,i,o,h,0),void s(c,n,r,i,o,h,0)}u=u.next}a=a.next}while(a!==t)}function c(t,n){return t.x-n.x}function l(t,n){var r=function(t,n){var r,i=n,e=t.x,s=t.y,o=-1/0;do{if(s<=i.y&&s>=i.next.y&&i.next.y!==i.y){var h=i.x+(s-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(h<=e&&h>o&&(o=h,r=i.x<i.next.x?i:i.next,h===e))return r}i=i.next}while(i!==n);if(!r)return null;var a,u=r,c=r.x,l=r.y,x=1/0;i=r;do{e>=i.x&&i.x>=c&&e!==i.x&&f(s<l?e:o,s,c,l,s<l?o:e,s,i.x,i.y)&&(a=Math.abs(s-i.y)/(e-i.x),w(i,t)&&(a<x||a===x&&(i.x>r.x||i.x===r.x&&p(r,i)))&&(r=i,x=a)),i=i.next}while(i!==u);return r}(t,n);if(!r)return n;var i=b(r,t);return e(i,i.next),e(r,r.next)}function p(t,n){return d(t.prev,t,n.prev)<0&&d(n.next,t,t.next)<0}function x(t,n,r,i,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*e|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-i)*e|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function v(t){var n=t,r=t;do{(n.x<r.x||n.x===r.x&&n.y<r.y)&&(r=n),n=n.next}while(n!==t);return r}function f(t,n,r,i,e,s,o,h){return(e-o)*(n-h)>=(t-o)*(s-h)&&(t-o)*(i-h)>=(r-o)*(n-h)&&(r-o)*(s-h)>=(e-o)*(i-h)}function y(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==n.i&&r.next.i!==n.i&&m(r,r.next,t,n))return!0;r=r.next}while(r!==t);return!1}(t,n)&&(w(t,n)&&w(n,t)&&function(t,n){var r=t,i=!1,e=(t.x+n.x)/2,s=(t.y+n.y)/2;do{r.y>s!=r.next.y>s&&r.next.y!==r.y&&e<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(i=!i),r=r.next}while(r!==t);return i}(t,n)&&(d(t.prev,t,n.prev)||d(t,n.prev,n))||g(t,n)&&d(t.prev,t,t.next)>0&&d(n.prev,n,n.next)>0)}function d(t,n,r){return(n.y-t.y)*(r.x-n.x)-(n.x-t.x)*(r.y-n.y)}function g(t,n){return t.x===n.x&&t.y===n.y}function m(t,n,r,i){var e=M(d(t,n,r)),s=M(d(t,n,i)),o=M(d(r,i,t)),h=M(d(r,i,n));return e!==s&&o!==h||(!(0!==e||!z(t,r,n))||(!(0!==s||!z(t,i,n))||(!(0!==o||!z(r,t,i))||!(0!==h||!z(r,n,i)))))}function z(t,n,r){return n.x<=Math.max(t.x,r.x)&&n.x>=Math.min(t.x,r.x)&&n.y<=Math.max(t.y,r.y)&&n.y>=Math.min(t.y,r.y)}function M(t){return t>0?1:t<0?-1:0}function w(t,n){return d(t.prev,t,t.next)<0?d(t,n,t.next)>=0&&d(t,t.prev,n)>=0:d(t,n,t.prev)<0||d(t,t.next,n)<0}function b(t,n){var r=new A(t.i,t.x,t.y),i=new A(n.i,n.x,n.y),e=t.next,s=n.prev;return t.next=n,n.prev=t,r.next=e,e.prev=r,i.next=r,r.prev=i,s.next=i,i.prev=s,i}function P(t,n,r,i){var e=new A(t,n,r);return i?(e.next=i.next,e.prev=i,i.next.prev=e,i.next=e):(e.prev=e,e.next=e),e}function S(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,n,r){this.i=t,this.x=n,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function V(t,n,r,i){for(var e=0,s=n,o=r-i;s<r;s+=i)e+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return e}n.exports=r,n.exports.default=r,r.deviation=function(t,n,r,i){var e=n&&n.length,s=e?n[0]*r:t.length,o=Math.abs(V(t,0,s,r));if(e)for(var h=0,a=n.length;h<a;h++){var u=n[h]*r,c=h<a-1?n[h+1]*r:t.length;o-=Math.abs(V(t,u,c,r))}var l=0;for(h=0;h<i.length;h+=3){var p=i[h]*r,x=i[h+1]*r,v=i[h+2]*r;l+=Math.abs((t[p]-t[v])*(t[x+1]-t[p+1])-(t[p]-t[x])*(t[v+1]-t[p+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},r.flatten=function(t){for(var n=t[0][0].length,r={vertices:[],holes:[],dimensions:n},i=0,e=0;e<t.length;e++){for(var s=0;s<t[e].length;s++)for(var o=0;o<n;o++)r.vertices.push(t[e][s][o]);e>0&&(i+=t[e-1].length,r.holes.push(i))}return r};var Z=n.exports;function _(t){for(var n,r,i=0,e=1,s=t.length;e<s;)n=r||t[0],i+=((r=t[e])[0]-n[0])*(r[1]+n[1]),e++;return i>0}function L(t,n,r){return t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2],t}function F(t,n){var r=n[0],i=n[1],e=n[2],s=Math.sqrt(r*r+i*i+e*e)||1;return t[0]=r/s,t[1]=i/s,t[2]=e/s,t}function O(t,n){function r(t,n,r,i){t[0]=n,t[1]=r,t[2]=i}for(var i,e,s,o,h,a,u,c,l,p=[],x=[],v=[],f=[],y=[],d=[],g=t.length,m=new Float32Array(n.length),z=0;z<g;){var M=3*t[z],w=3*t[z+1],b=3*t[z+2];r(p,n[M],n[M+1],n[M+2]),r(x,n[w],n[w+1],n[w+2]),r(v,n[b],n[b+1],n[b+2]),L(y,v,x),L(f,p,x),i=d,s=f,o=void 0,h=void 0,a=void 0,u=void 0,c=void 0,l=void 0,o=(e=y)[0],h=e[1],a=e[2],u=s[0],c=s[1],l=s[2],i[0]=h*l-a*c,i[1]=a*u-o*l,i[2]=o*c-h*u;for(var P=0;P<3;P++)m[M+P]+=d[P],m[w+P]+=d[P],m[b+P]+=d[P];z+=3}for(var S=0,A=m.length;S<A;)r(d,m[S],m[S+1],m[S+2]),F(d,d),m[S]=d[0]||0,m[S+1]=d[1]||0,m[S+2]=d[2]||0,S+=3;return m}function I(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var n=0,r=0,i=0,e=t.length;i<e;i++){var s=t[i],o=s.position,h=s.indices;n+=o.length,r+=h.length}for(var a={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(r),results:t},u=0,c=0,l=0,p=0,x=0,v=t.length;x<v;x++){var f=t[x],y=f.position,d=f.indices,g=f.normal,m=f.uv;a.position.set(y,u),a.normal.set(g,u),a.uv.set(m,p);for(var z=0,M=d.length;z<M;){var w=d[z]+c;a.indices[l]=w,l++,z++}p+=m.length,u+=y.length,c+=y.length/3}return a}function k(t){return 180*t/Math.PI}function U(t){return t/180*Math.PI}function j(t,n,r,i,e,s){var o=3*r,h=3*i,a=3*e,u=3*s,c=n[o],l=n[o+1],p=n[o+2],x=n[h],v=n[h+1],f=n[h+2],y=n[a],d=n[a+1],g=n[a+2],m=n[u],z=n[u+1],M=n[u+2];Math.abs(l-v)<Math.abs(c-x)?(t.push(c,1-p),t.push(x,1-f),t.push(y,1-g),t.push(m,1-M)):(t.push(l,1-p),t.push(v,1-f),t.push(d,1-g),t.push(z,1-M))}function q(t){C(t)||t.push(t[0])}function C(t){var n=t.length,r=t[0],i=r[0],e=r[1],s=t[n-1],o=s[0],h=s[1];return i===o&&e===h}function T(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function W(t,n){var r=n.bottomStickGround,i=n.depth,e=t.depths,s=i,o=i;e&&(s=e[0],o=e[1]);for(var h=[],a=[],u=[],c=t.leftPoints,l=t.rightPoints,p=0,x=c.length;p<x;){var v=3*p,f=c[p],y=f[0],d=f[1],g=f[2];h[v]=y,h[v+1]=d,h[v+2]=s+g;var m=l[p],z=m[0],M=m[1],w=m[2],b=3*x+v;h[b]=z,h[b+1]=M,h[b+2]=o+w;var P=2*x*3+v;h[P]=y,h[P+1]=d,h[P+2]=g,r&&(h[P+2]=0);var S=2*x*3+3*x+v;h[S]=z,h[S+1]=M,h[S+2]=w,r&&(h[S+2]=0),p++}for(p=0,x=h.length;p<x;){var A=h[p],V=h[p+1];u.push(A,V),p+=3}for(p=0,x=c.length;p<x-1;){var Z=p,_=p+1,L=Z+x,F=_+x;a.push(Z,L,_),a.push(L,F,_);var O=p+2*x,I=O+1,k=O+x,U=I+x;a.push(O,k,I),a.push(k,U,I),p++}if(t.index=a,t.points=h,t.uvs=u,e)for(x=c.length,p=0;p<x;)c[p].depth=s,l[p].depth=o,p++}function B(t,n){var r=t.points,i=t.index,e=t.leftPoints,s=t.rightPoints,o=t.uvs,h=n.depth,a=n.bottomStickGround,u=[e,s],c=t.depths;function l(t,n){var e=r.length/3,s=r.length-1;r[++s]=t[0],r[++s]=t[1],r[++s]=(c?t.depth:h)+t[2],r[++s]=n[0],r[++s]=n[1],r[++s]=(c?n.depth:h)+n[2],r[++s]=t[0],r[++s]=t[1],r[++s]=a?0:t[2],r[++s]=n[0],r[++s]=n[1],r[++s]=a?0:n[2];var u=e+2,l=e+3,p=e,x=e+1;i.push(u,p,l,p,x,l),j(o,r,u,l,p,x)}for(var p=0,x=u.length;p<x;p++){var v=u[p];p>0&&(v=(v=v.map((function(t){return t}))).reverse());for(var f=0,y=v.length-1;f<y;){l(v[f],v[f+1]),f++}}for(var d=e.length,g=[s[0],e[0],e[d-1],s[d-1]],m=0;m<g.length;m+=2){l(g[m],g[m+1])}}var D={x:0,y:0},R={x:0,y:0};function E(t,n){for(var r=n.lineWidth/2,i=[],e=[],s=[],o=t.length,h=0;h<o;){var a=t[h],u=t[h+1],c=t[h];h===o-1&&(a=t[o-2],u=t[o-1]);var l=u[1]-a[1],p=u[0]-a[0],x=0,v=k(Math.atan(l/p));if(0===h||h===o-1)x=v,x-=90;else{var f=t[h-1];D.x=f[0]-a[0],D.y=f[1]-a[1],R.x=u[0]-a[0],R.y=u[1]-a[1],x=v-N(D,R)/2}var y=U(x),d=c,g=[Math.cos(y)+d[0],Math.sin(y)+d[1]],m=Q(a,u,r),z=m[0],M=m[1],w=H(z[0],z[1],d,g),b=H(M[0],M[1],d,g);if(!w||!b){var P=i.length,S=i[P-2],A=i[P-1];if(!S||!A)continue;w=[S[0],S[1]],b=[A[0],A[1]]}w[2]=c[2]||0,b[2]=c[2]||0,i.push(w,b),G(w,a,u)?(e.push(w),s.push(b)):(e.push(b),s.push(w)),h++}return{offsetPoints:i,leftPoints:e,rightPoints:s}}var N=function(t,n){var r=t.x,i=t.y,e=n.x,s=n.y,o=r*e+i*s,h=r*s-i*e;return(Math.atan2(h,o)/Math.PI*180+360)%360};function G(t,n,r){var i=n[0],e=n[1],s=r[0],o=r[1];return(e-o)*t[0]+(s-i)*t[1]+i*o-s*e>0}function Q(t,n,r){var i=n[1]-t[1],e=n[0]-t[0],s=Math.atan2(i,e),o=s+Math.PI/2,h=Math.cos(o)*r,a=Math.sin(o)*r,u=[t[0]+h,t[1]+a],c=[n[0]+h,n[1]+a],l=s-Math.PI/2;return h=Math.cos(l)*r,a=Math.sin(l)*r,[[u,c],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function H(t,n,r,i){var e=n[0]-t[0],s=n[1]-t[1],o=i[0]-r[0],h=i[1]-r[1];if(0===e&&0===o)return null;if(0===s&&0===h)return null;var a,u,c=s/e,l=h/o,p=t[1]-c*t[0],x=r[1]-l*r[0];return 0===e?u=l*(a=t[0])+x:0===o?u=c*(a=r[0])+p:0===s?a=((u=t[1])-x)/l:0===h?a=((u=r[1])-p)/c:u=c*(a=(x-p)/(c-l))+p,[a,u]}var X=function(){function t(t,n,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=t,this.y=n,this.z=r}var n=t.prototype;return n.set=function(t,n,r){return void 0===r&&(r=this.z),this.x=t,this.y=n,this.z=r,this},n.clone=function(){return new this.constructor(this.x,this.y,this.z)},n.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},n.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},n.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.addVectors=function(t,n){return this.x=t.x+n.x,this.y=t.y+n.y,this.z=t.z+n.z,this},n.addScaledVector=function(t,n){return this.x+=t.x*n,this.y+=t.y*n,this.z+=t.z*n,this},n.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.subVectors=function(t,n){return this.x=t.x-n.x,this.y=t.y-n.y,this.z=t.z-n.z,this},n.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.multiplyVectors=function(t,n){return this.x=t.x*n.x,this.y=t.y*n.y,this.z=t.z*n.z,this},n.applyMatrix4=function(t){var n=this.x,r=this.y,i=this.z,e=t.elements,s=1/(e[3]*n+e[7]*r+e[11]*i+e[15]);return this.x=(e[0]*n+e[4]*r+e[8]*i+e[12])*s,this.y=(e[1]*n+e[5]*r+e[9]*i+e[13])*s,this.z=(e[2]*n+e[6]*r+e[10]*i+e[14])*s,this},n.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.divideScalar=function(t){return this.multiplyScalar(1/t)},n.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this},n.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this},n.clamp=function(t,n){return this.x=Math.max(t.x,Math.min(n.x,this.x)),this.y=Math.max(t.y,Math.min(n.y,this.y)),this.z=Math.max(t.z,Math.min(n.z,this.z)),this},n.clampScalar=function(t,n){return this.x=Math.max(t,Math.min(n,this.x)),this.y=Math.max(t,Math.min(n,this.y)),this.z=Math.max(t,Math.min(n,this.z)),this},n.clampLength=function(t,n){var r=this.length();return this.divideScalar(r||1).multiplyScalar(Math.max(t,Math.min(n,r)))},n.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.normalize=function(){return this.divideScalar(this.length()||1)},n.setLength=function(t){return this.normalize().multiplyScalar(t)},n.lerp=function(t,n){return this.x+=(t.x-this.x)*n,this.y+=(t.y-this.y)*n,this.z+=(t.z-this.z)*n,this},n.lerpVectors=function(t,n,r){return this.x=t.x+(n.x-t.x)*r,this.y=t.y+(n.y-t.y)*r,this.z=t.z+(n.z-t.z)*r,this},n.cross=function(t){return this.crossVectors(this,t)},n.crossVectors=function(t,n){var r=t.x,i=t.y,e=t.z,s=n.x,o=n.y,h=n.z;return this.x=i*h-e*o,this.y=e*s-r*h,this.z=r*o-i*s,this},n.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.fromArray=function(t,n){return void 0===n&&(n=0),this.x=t[n],this.y=t[n+1],this.z=t[n+2],this},n.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t}(),J=function(){function t(){this.pos=new X,this.dir=new X,this.right=new X,this.up=new X,this.dist=0,this.widthScale=1,this.sharp=!1}var n=t.prototype;return n.lerpPathPoints=function(t,n,r){this.pos.lerpVectors(t.pos,n.pos,r),this.dir.lerpVectors(t.dir,n.dir,r),this.up.lerpVectors(t.up,n.up,r),this.right.lerpVectors(t.right,n.right,r),this.dist=(n.dist-t.dist)*r+t.dist,this.widthScale=(n.widthScale-t.widthScale)*r+t.widthScale},n.copy=function(t){this.pos.copy(t.pos),this.dir.copy(t.dir),this.up.copy(t.up),this.right.copy(t.right),this.dist=t.dist,this.widthScale=t.widthScale},t}(),K=function(){function t(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f)}var n=t.prototype;return n.set=function(t,n,r,i,e,s,o,h,a,u,c,l,p,x,v,f){var y=this.elements;return y[0]=t,y[4]=n,y[8]=r,y[12]=i,y[1]=e,y[5]=s,y[9]=o,y[13]=h,y[2]=a,y[6]=u,y[10]=c,y[14]=l,y[3]=p,y[7]=x,y[11]=v,y[15]=f,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var r=Math.cos(n),i=Math.sin(n),e=1-r,s=t.x,o=t.y,h=t.z,a=e*s,u=e*o;return this.set(a*s+r,a*o-i*h,a*h+i*o,0,a*o+i*h,u*o+r,u*h-i*s,0,a*h-i*o,u*h+i*s,e*h*h+r,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,r=t.elements,i=0;i<16;i++)if(n[i]!==r[i])return!1;return!0},t}();function Y(t,n){return Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Y(t,n)}function $(t,n,r,i){return function(t,n){var r=1-t;return r*r*n}(t,n)+function(t,n){return 2*(1-t)*t*n}(t,r)+function(t,n){return t*t*n}(t,i)}var tt=function(t){var n,r;function i(n,r,i){var e;return void 0===n&&(n=new X),void 0===r&&(r=new X),void 0===i&&(i=new X),(e=t.call(this)||this).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=n,e.v1=r,e.v2=i,e}return r=t,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,Y(n,r),i.prototype.getPoint=function(t,n){void 0===n&&(n=new X);var r=n,i=this.v0,e=this.v1,s=this.v2;return r.set($(t,i.x,e.x,s.x),$(t,i.y,e.y,s.y),$(t,i.z,e.z,s.z)),r},i}(function(){function t(){this.type="Curve",this.arcLengthDivisions=200}var n=t.prototype;return n.getPoint=function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},n.getPointAt=function(t,n){var r=this.getUtoTmapping(t);return this.getPoint(r,n)},n.getPoints=function(t){void 0===t&&(t=5);for(var n=[],r=0;r<=t;r++)n.push(this.getPoint(r/t));return n},n.getLength=function(){var t=this.getLengths();return t[t.length-1]},n.getLengths=function(t){if(void 0===t&&(t=this.arcLengthDivisions),this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var n,r=[],i=this.getPoint(0),e=0;r.push(0);for(var s=1;s<=t;s++)e+=(n=this.getPoint(s/t)).distanceTo(i),r.push(e),i=n;return this.cacheArcLengths=r,r},n.getUtoTmapping=function(t,n){var r,i=this.getLengths(),e=0,s=i.length;r=n||t*i[s-1];for(var o,h=0,a=s-1;h<=a;)if((o=i[e=Math.floor(h+(a-h)/2)]-r)<0)h=e+1;else{if(!(o>0)){a=e;break}a=e-1}if(i[e=a]===r)return e/(s-1);var u=i[e];return(e+(r-u)/(i[e+1]-u))/(s-1)},t}()),nt=new X,rt=new X,it=new X,et=new K,st=new tt;var ot=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,r,i,e){if(void 0===n&&(n=.1),void 0===r&&(r=10),void 0===i&&(i=null),void 0===e&&(e=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);e&&!t[0].equals(t[t.length-1])&&t.push((new X).copy(t[0]));for(var s=0,o=t.length;s<o;s++)if(0===s)this._start(t[s],t[s+1],i);else if(s===o-1)if(e){this._corner(t[s],t[1],n,r,i);var h=this.array[0].dist;this.array[0].copy(this.array[this.count-1]),this.array[0].dist=h}else this._end(t[s]);else this._corner(t[s],t[s+1],n,r,i)},n.distance=function(){return this.count>0?this.array[this.count-1].dist:0},n._getByIndex=function(t){return this.array[t]||(this.array[t]=new J),this.array[t]},n._start=function(t,n,r){this.count=0;var i=this._getByIndex(this.count);if(i.pos.copy(t),i.dir.subVectors(n,t),r)i.up.copy(r);else{var e=Number.MAX_VALUE,s=Math.abs(i.dir.x),o=Math.abs(i.dir.y),h=Math.abs(i.dir.z);s<e&&(e=s,i.up.set(1,0,0)),o<e&&(e=o,i.up.set(0,1,0)),h<e&&i.up.set(0,0,1)}i.right.crossVectors(i.dir,i.up).normalize(),i.up.crossVectors(i.right,i.dir).normalize(),i.dist=0,i.widthScale=1,i.sharp=!1,i.dir.normalize(),this.count++},n._end=function(t){var n=this.array[this.count-1],r=this._getByIndex(this.count);r.pos.copy(t),r.dir.subVectors(t,n.pos);var i=r.dir.length();r.dir.normalize(),r.up.copy(n.up);var e=nt.crossVectors(n.dir,r.dir);if(e.length()>Number.EPSILON){e.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(r.dir),-1),1));r.up.applyMatrix4(et.makeRotationAxis(e,s))}r.right.crossVectors(r.dir,r.up).normalize(),r.dist=n.dist+i,r.widthScale=1,r.sharp=!1,this.count++},n._corner=function(t,n,r,i,e){if(r>0&&i>0){for(var s=function(t,n,r,i,e,s){var o=nt.subVectors(n,t),h=rt.subVectors(r,n),a=o.length(),u=h.length();o.normalize(),h.normalize();var c=Math.min(.999999*(e?a/2:a),i);s.v0.copy(n).sub(o.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/2*.999999,i);return s.v2.copy(n).add(h.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,r,this.count-1==0,st),o=s.getPoints(i),h=0;h<i;h++)this._sharpCorner(o[h],o[h+1],e,0===h?1:0);o[i].equals(n)||this._sharpCorner(o[i],n,e,2)}else this._sharpCorner(t,n,e,0,!0)},n._sharpCorner=function(t,n,r,i,e){void 0===i&&(i=0),void 0===e&&(e=!1);var s=this.array[this.count-1],o=this._getByIndex(this.count),h=nt.subVectors(t,s.pos),a=rt.subVectors(n,t),u=h.length();if(h.normalize(),a.normalize(),o.pos.copy(t),1===i?o.dir.copy(h):2===i?o.dir.copy(a):(o.dir.addVectors(h,a),o.dir.normalize()),r)1===o.dir.dot(r)?o.right.crossVectors(a,r).normalize():o.right.crossVectors(o.dir,r).normalize(),o.up.crossVectors(o.right,o.dir).normalize();else{o.up.copy(s.up);var c=it.crossVectors(s.dir,o.dir);if(c.length()>Number.EPSILON){c.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(o.dir),-1),1));o.up.applyMatrix4(et.makeRotationAxis(c,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+u;var p=h.dot(a);o.widthScale=Math.min(1/Math.sqrt((1+p)/2),1.415)||1,o.sharp=Math.abs(p-1)>.05&&e,this.count++},t}(),ht=new X(0,0,1);t.cylinder=function(t,n){void 0===n&&(n={}),n=Object.assign({},{radius:1,height:2,radialSegments:6},n);for(var r=Math.round(Math.max(4,n.radialSegments)),i=n,e=i.radius,s=i.height,o=360/r/360*Math.PI*2,h=r+1,a=new Float32Array(3*h*2),u=t[0],c=t[1],l=0,p=0,x=3*h,v=2*h,f=[],y=[],d=-1;d<r;d++){var g=o*d,m=Math.cos(g)*e+u,z=Math.sin(g)*e+c;a[l]=m,a[l+1]=z,a[l+2]=0,a[l+x]=m,a[l+1+x]=z,a[l+2+x]=s;var M,w;M=.5+m/e/2,w=.5+z/e/2,y[p]=M,y[p+1]=w,y[p+v]=M,y[p+1+v]=w,l+=3,p+=2,d>1&&f.push(0,d-1,d)}a[l-=3]=a[0],a[l+1]=a[1],a[l+2]=a[2];var b=a.length;a[b-3]=a[0],a[b-2]=a[1],a[b-1]=s;for(var P=f.length,S=0;S<P;S++){var A=f[S];f.push(A+h)}var V=new Float32Array(2*(3*h*2-6)),Z=-1;l=2*h,p=0;for(var _=0,L=a.length/2;_<L-3;_+=3){var F=a[_],I=a[_+1],k=a[_+3],U=a[_+4];V[++Z]=F,V[++Z]=I,V[++Z]=s,V[++Z]=k,V[++Z]=U,V[++Z]=s,V[++Z]=F,V[++Z]=I,V[++Z]=0,V[++Z]=k,V[++Z]=U,V[++Z]=0;var j=l+2,q=l+3,C=l,T=l+1;f.push(C,j,T,j,q,T),l+=4;var W=p/h,B=(p+1)/h;y.push(W,s/e/2,B,s/e/2,W,0,B,0),p++}var D=new Float32Array(a.length+V.length);D.set(a,0),D.set(V,a.length);var R=O(f,D);return{points:a,indices:new Uint32Array(f),position:D,normal:R,uv:new Float32Array(y)}},t.expandLine=E,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);var r=t.map((function(t){var r=t.map((function(t){var n=t[0],r=t[1],i=t[2];return new X(n,r,i||0)})),i=new ot;i.set(r,n.cornerRadius,n.cornerSplit,ht);var e=function(t,n){var r=n.lineWidth||.1,i=1,e=r/2,s=r,o=t.distance(),h=i*o;if(0===o)return null;var a,u=e/s,c=0,l=[],p=[],x=[],v=[],f=0,y=new X,d=new X,g=new X,m=new X,z=new X,M=new X;function w(t){var n=0===l.length,r=t.sharp&&!n,i=t.dist/s,o=t.dir,h=t.up,a=t.right;if(y.copy(a).multiplyScalar(e*t.widthScale),d.copy(a).multiplyScalar(-e*t.widthScale),y.add(t.pos),d.add(t.pos),r){g.fromArray(l,l.length-6).sub(d),m.fromArray(l,l.length-3).sub(y);var w,b,P=g.length()-m.length();P>0?(w=g,b=d):(w=m,b=y),z.copy(w).setLength(Math.abs(P)).add(b);var S=M.copy(b).sub(z).normalize().dot(o)*M.copy(b).sub(z).length()*2;M.copy(o).setLength(S).add(z),P>0?(l.push(z.x,z.y,z.z,y.x,y.y,y.z,d.x,d.y,d.z,y.x,y.y,y.z,M.x,M.y,M.z,y.x,y.y,y.z),f+=6,v.push(f-6,f-8,f-7,f-6,f-7,f-5,f-4,f-6,f-5,f-2,f-4,f-1),c+=12):(l.push(d.x,d.y,d.z,z.x,z.y,z.z,d.x,d.y,d.z,y.x,y.y,y.z,d.x,d.y,d.z,M.x,M.y,M.z),f+=6,v.push(f-6,f-8,f-7,f-6,f-7,f-5,f-6,f-5,f-3,f-2,f-3,f-1),c+=12),p.push(h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z,h.x,h.y,h.z),x.push(i-u,0,i-u,1,i,0,i,1,i+u,0,i+u,1)}else l.push(d.x,d.y,d.z,y.x,y.y,y.z),p.push(h.x,h.y,h.z,h.x,h.y,h.z),x.push(i,0,i,1),f+=2,n||(v.push(f-2,f-4,f-3,f-2,f-3,f-1),c+=6)}if(h>0)for(var b=0;b<t.count;b++){var P=t.array[b];if(P.dist>h){var S=t.array[b-1];a=new J;var A=(h-S.dist)/(P.dist-S.dist);a.lerpPathPoints(S,P,A),w(a);break}w(P)}else a=t.array[0];return{points:l,normal:p,uvs:x,index:v,count:c}}(i,n);return e.line=t,e.position=new Float32Array(e.points),e.indices=new Uint32Array(e.index),e.uv=new Float32Array(e.uvs),e.normal=new Float32Array(e.normal),e})),i=I(r);return i.lines=t,i},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);var r=t.map((function(t){for(var r=0,i=t.length;r<i;r++){var e=t[r];q(e),0===r?_(e)||(t[r]=e.reverse()):_(e)&&(t[r]=e.reverse()),C(e)&&e.splice(e.length-1,1)}var s=function(t,n){for(var r=function(t){var n=0,r=0,i=t.length;for(;r<i;)n+=t[r].length,r++;return n}(t),i=t.length,e=[],s=new Float32Array(2*r),o=[],h=[],a=3*r,u=2*r,c=n.depth,l=0,p=0,x=0,v=0;v<i;v++){var f=t[v];v>0&&e.push(l/2);for(var y=0,d=f.length;y<d;){var g=f[y],m=g[0],z=g[1];s[l++]=m,s[l++]=z,o[p]=m,o[p+1]=z,o[p+2]=c,o[a+p]=m,o[a+p+1]=z,o[a+p+2]=0,h[x]=m,h[x+1]=z,h[u+x]=m,h[u+x+1]=z,p+=3,x+=2,y++}}return{flatVertices:s,holes:e,points:o,count:r,uvs:h}}(t,n);return s.polygon=t,function(t,n){for(var r=[],i=t.count,e=0,s=n.length;e<s;e+=3){var o=n[e],h=n[e+1],a=n[e+2];r[e]=o,r[e+1]=h,r[e+2]=a;var u=s+e,c=i+o,l=i+h,p=i+a;r[u]=c,r[u+1]=l,r[u+2]=p}t.index=r}(s,Z(s.flatVertices,s.holes,2)),function(t,n){for(var r=t.points,i=t.index,e=t.polygon,s=t.uvs,o=n.depth,h=0,a=e.length;h<a;h++)for(var u=e[h],c=0,l=u.length;c<l;){var p=u[c],x=u[c+1];c===l-1&&(x=u[0]);var v=r.length/3,f=p[0],y=p[1],d=x[0],g=x[1];r.push(f,y,o,d,g,o,f,y,0,d,g,0);var m=v+2,z=v+3,M=v,w=v+1;i.push(m,M,z,M,w,z),j(s,r,m,z,M,w),c++}}(s,n),s.position=new Float32Array(s.points),s.indices=new Uint32Array(s.index),s.uv=new Float32Array(s.uvs),s.normal=O(s.indices,s.position),s})),i=I(r);return i.polygons=t,i},t.extrudePolylines=function(t,n){T(n=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1},n));var r=t.map((function(t){var r=E(t,n);return r.line=t,W(r,n),B(r,n),r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.index),r.uv=new Float32Array(r.uvs),r.normal=O(r.indices,r.position),r})),i=I(r);return i.lines=t,i},t.extrudeSlopes=function(t,n){T(n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1},n));var r=n,i=r.depth,e=r.side,s=r.sideDepth,o=t.map((function(t){var r=E(t,n);r.line=t;for(var o,h=r.leftPoints,a=r.rightPoints,u={line:t},c=0,l=t.length;c<l;c++)t[c][2]=t[c][2]||0;return"left"===e?(u.leftPoints=h,u.rightPoints=t,o=[s,i]):(u.leftPoints=t,u.rightPoints=a,o=[i,s]),u.depths=o,W(u,n),B(u,n),u.position=new Float32Array(u.points),u.indices=new Uint32Array(u.index),u.uv=new Float32Array(u.uvs),u.normal=O(u.indices,u.position),u})),h=I(o);return h.lines=t,h},t.leftOnLine=G,Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/poly-extrude.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.6.0
|
3
3
|
*/
|
4
4
|
var earcut$2 = {exports: {}};
|
5
5
|
|
@@ -1065,11 +1065,19 @@ function isClosedRing(ring) {
|
|
1065
1065
|
return x1 === x2 && y1 === y2;
|
1066
1066
|
}
|
1067
1067
|
|
1068
|
+
function checkOptions(options) {
|
1069
|
+
options.lineWidth = Math.max(0, options.lineWidth);
|
1070
|
+
options.depth = Math.max(0, options.depth);
|
1071
|
+
options.sideDepth = Math.max(0, options.sideDepth);
|
1072
|
+
}
|
1073
|
+
|
1068
1074
|
function extrudePolylines(lines, options) {
|
1069
1075
|
options = Object.assign({}, {
|
1070
1076
|
depth: 2,
|
1071
|
-
lineWidth: 1
|
1077
|
+
lineWidth: 1,
|
1078
|
+
bottomStickGround: false
|
1072
1079
|
}, options);
|
1080
|
+
checkOptions(options);
|
1073
1081
|
var results = lines.map(function (line) {
|
1074
1082
|
var result = expandLine(line, options);
|
1075
1083
|
result.line = line;
|
@@ -1090,8 +1098,10 @@ function extrudeSlopes(lines, options) {
|
|
1090
1098
|
depth: 2,
|
1091
1099
|
lineWidth: 1,
|
1092
1100
|
side: 'left',
|
1093
|
-
sideDepth: 0
|
1101
|
+
sideDepth: 0,
|
1102
|
+
bottomStickGround: false
|
1094
1103
|
}, options);
|
1104
|
+
checkOptions(options);
|
1095
1105
|
var _options = options,
|
1096
1106
|
depth = _options.depth,
|
1097
1107
|
side = _options.side,
|
@@ -1135,6 +1145,7 @@ function extrudeSlopes(lines, options) {
|
|
1135
1145
|
}
|
1136
1146
|
|
1137
1147
|
function generateTopAndBottom(result, options) {
|
1148
|
+
var bottomStickGround = options.bottomStickGround;
|
1138
1149
|
var z = options.depth;
|
1139
1150
|
var depths = result.depths;
|
1140
1151
|
var lz = z,
|
@@ -1176,12 +1187,22 @@ function generateTopAndBottom(result, options) {
|
|
1176
1187
|
var idx2 = len * 2 * 3 + idx0;
|
1177
1188
|
points[idx2] = x1;
|
1178
1189
|
points[idx2 + 1] = y1;
|
1179
|
-
points[idx2 + 2] = z1;
|
1190
|
+
points[idx2 + 2] = z1;
|
1191
|
+
|
1192
|
+
if (bottomStickGround) {
|
1193
|
+
points[idx2 + 2] = 0;
|
1194
|
+
} // bottom right
|
1195
|
+
|
1180
1196
|
|
1181
1197
|
var idx3 = len * 2 * 3 + len * 3 + idx0;
|
1182
1198
|
points[idx3] = x2;
|
1183
1199
|
points[idx3 + 1] = y2;
|
1184
1200
|
points[idx3 + 2] = z2;
|
1201
|
+
|
1202
|
+
if (bottomStickGround) {
|
1203
|
+
points[idx3 + 2] = 0;
|
1204
|
+
}
|
1205
|
+
|
1185
1206
|
i++;
|
1186
1207
|
}
|
1187
1208
|
|
@@ -1242,12 +1263,29 @@ function generateSides(result, options) {
|
|
1242
1263
|
rightPoints = result.rightPoints,
|
1243
1264
|
uvs = result.uvs;
|
1244
1265
|
var z = options.depth;
|
1266
|
+
var bottomStickGround = options.bottomStickGround;
|
1245
1267
|
var rings = [leftPoints, rightPoints];
|
1246
1268
|
var depthsEnable = result.depths;
|
1247
1269
|
|
1248
1270
|
function addOneSideIndex(v1, v2) {
|
1249
1271
|
var idx = points.length / 3;
|
1250
|
-
|
1272
|
+
var pIndex = points.length - 1; // top
|
1273
|
+
|
1274
|
+
points[++pIndex] = v1[0];
|
1275
|
+
points[++pIndex] = v1[1];
|
1276
|
+
points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
|
1277
|
+
points[++pIndex] = v2[0];
|
1278
|
+
points[++pIndex] = v2[1];
|
1279
|
+
points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
|
1280
|
+
// bottom
|
1281
|
+
|
1282
|
+
points[++pIndex] = v1[0];
|
1283
|
+
points[++pIndex] = v1[1];
|
1284
|
+
points[++pIndex] = bottomStickGround ? 0 : v1[2];
|
1285
|
+
points[++pIndex] = v2[0];
|
1286
|
+
points[++pIndex] = v2[1];
|
1287
|
+
points[++pIndex] = bottomStickGround ? 0 : v2[2]; // points.push(v1[0], v1[1], v1[2], v2[0], v2[1], v2[2]);
|
1288
|
+
|
1251
1289
|
var a = idx + 2,
|
1252
1290
|
b = idx + 3,
|
1253
1291
|
c = idx,
|
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
# poly-extrude
|
2
2
|
|
3
|
-
|
4
3
|
Extrude polygons/polylines. Born in [maptalks.three](https://github.com/maptalks/maptalks.three) project<br>
|
5
4
|
|
6
5
|
## Examples
|
7
|
-
|
8
|
-
|
9
|
-
[
|
10
|
-
|
6
|
+
|
7
|
+
[building](https://deyihu.github.io/poly-extrude/test/building.html)
|
8
|
+
<!-- <br> -->
|
9
|
+
[buildings](https://deyihu.github.io/poly-extrude/test/buildings.html)
|
10
|
+
<!-- <br> -->
|
11
11
|
[multi-polygon](https://deyihu.github.io/poly-extrude/test/multi-polygon.html)<br>
|
12
|
-
<br>
|
12
|
+
<!-- <br> -->
|
13
13
|
[street](https://deyihu.github.io/poly-extrude/test/street.html)<br>
|
14
|
-
<br>
|
14
|
+
<!-- <br> -->
|
15
15
|
[line-uv](https://deyihu.github.io/poly-extrude/test/line-uv.html)<br>
|
16
|
-

|
16
|
+
<!--  -->
|
17
17
|
[ny-building](https://deyihu.github.io/poly-extrude/test/ny-building.html)<br>
|
18
|
-

|
18
|
+
<!--  -->
|
19
19
|
[cylinder](https://deyihu.github.io/poly-extrude/test/cylinder.html)<br>
|
20
|
-

|
20
|
+
<!--  -->
|
21
21
|
[brige](https://deyihu.github.io/poly-extrude/test/brige.html)<br>
|
22
|
-

|
22
|
+
<!--  -->
|
23
23
|
[spring](https://deyihu.github.io/poly-extrude/test/spring.html)<br>
|
24
|
-

|
24
|
+
<!--  -->
|
25
25
|
[expand paths](https://deyihu.github.io/poly-extrude/test/expand-paths-brige.html)<br>
|
26
|
-

|
26
|
+
<!--  -->
|
27
|
+
[slope](https://deyihu.github.io/poly-extrude/test/slope.html)<br>
|
27
28
|
|
28
29
|
## Install
|
29
30
|
|
@@ -48,7 +49,8 @@ pnpm i poly-extrude
|
|
48
49
|
extrudePolygons,
|
49
50
|
extrudePolylines,
|
50
51
|
cylinder,
|
51
|
-
expandPaths
|
52
|
+
expandPaths,
|
53
|
+
extrudeSlopes
|
52
54
|
} from 'poly-extrude';
|
53
55
|
const polygons = [
|
54
56
|
//polygon
|
@@ -120,8 +122,6 @@ pnpm i poly-extrude
|
|
120
122
|
} = result;
|
121
123
|
//do something
|
122
124
|
|
123
|
-
|
124
|
-
|
125
125
|
const polylines = [
|
126
126
|
// polyline
|
127
127
|
[
|
@@ -147,6 +147,32 @@ pnpm i poly-extrude
|
|
147
147
|
} = result;
|
148
148
|
//do something
|
149
149
|
|
150
|
+
const polylines = [
|
151
|
+
// polyline
|
152
|
+
[
|
153
|
+
[x, y],
|
154
|
+
[x, y], ...........
|
155
|
+
],
|
156
|
+
//polyline
|
157
|
+
[
|
158
|
+
[x, y],
|
159
|
+
[x, y], ...........
|
160
|
+
],
|
161
|
+
];
|
162
|
+
|
163
|
+
const result = extrudeSlopes(polylines, {
|
164
|
+
depth: 1,
|
165
|
+
side: 'left',
|
166
|
+
sideDepth: 0,
|
167
|
+
lineWidth: 2
|
168
|
+
});
|
169
|
+
const {
|
170
|
+
positon,
|
171
|
+
normal,
|
172
|
+
uv,
|
173
|
+
indices
|
174
|
+
} = result;
|
175
|
+
//do something
|
150
176
|
```
|
151
177
|
|
152
178
|
### CDN
|
@@ -225,9 +251,32 @@ pnpm i poly-extrude
|
|
225
251
|
} = result;
|
226
252
|
//do something
|
227
253
|
|
254
|
+
const polylines = [
|
255
|
+
// polyline
|
256
|
+
[
|
257
|
+
[x, y],
|
258
|
+
[x, y], ...........
|
259
|
+
],
|
260
|
+
//polyline
|
261
|
+
[
|
262
|
+
[x, y],
|
263
|
+
[x, y], ...........
|
264
|
+
],
|
265
|
+
];
|
228
266
|
|
229
|
-
|
230
|
-
|
267
|
+
const result = polyextrude.expandPaths(polylines, {
|
268
|
+
cornerRadius: 0.5,
|
269
|
+
lineWidth: 2
|
270
|
+
});
|
271
|
+
const {
|
272
|
+
positon,
|
273
|
+
normal,
|
274
|
+
uv,
|
275
|
+
indices
|
276
|
+
} = result;
|
277
|
+
//do something
|
278
|
+
|
279
|
+
const polylines = [
|
231
280
|
// polyline
|
232
281
|
[
|
233
282
|
[x, y],
|
@@ -240,8 +289,10 @@ pnpm i poly-extrude
|
|
240
289
|
],
|
241
290
|
];
|
242
291
|
|
243
|
-
const result = polyextrude.
|
244
|
-
|
292
|
+
const result = polyextrude.extrudeSlopes(polylines, {
|
293
|
+
depth: 1,
|
294
|
+
side: 'left',
|
295
|
+
sideDepth: 0,
|
245
296
|
lineWidth: 2
|
246
297
|
});
|
247
298
|
const {
|
package/src/polyline.js
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
import { degToRad, generateNormal, generateSideWallUV, merge, radToDeg } from './util';
|
2
2
|
|
3
|
+
function checkOptions(options) {
|
4
|
+
options.lineWidth = Math.max(0, options.lineWidth);
|
5
|
+
options.depth = Math.max(0, options.depth);
|
6
|
+
options.sideDepth = Math.max(0, options.sideDepth);
|
7
|
+
}
|
8
|
+
|
3
9
|
export function extrudePolylines(lines, options) {
|
4
|
-
options = Object.assign({}, { depth: 2, lineWidth: 1 }, options);
|
10
|
+
options = Object.assign({}, { depth: 2, lineWidth: 1, bottomStickGround: false }, options);
|
11
|
+
checkOptions(options);
|
5
12
|
const results = lines.map(line => {
|
6
13
|
const result = expandLine(line, options);
|
7
14
|
result.line = line;
|
@@ -19,7 +26,8 @@ export function extrudePolylines(lines, options) {
|
|
19
26
|
}
|
20
27
|
|
21
28
|
export function extrudeSlopes(lines, options) {
|
22
|
-
options = Object.assign({}, { depth: 2, lineWidth: 1, side: 'left', sideDepth: 0 }, options);
|
29
|
+
options = Object.assign({}, { depth: 2, lineWidth: 1, side: 'left', sideDepth: 0, bottomStickGround: false }, options);
|
30
|
+
checkOptions(options);
|
23
31
|
const { depth, side, sideDepth } = options;
|
24
32
|
const results = lines.map(line => {
|
25
33
|
const tempResult = expandLine(line, options);
|
@@ -54,6 +62,7 @@ export function extrudeSlopes(lines, options) {
|
|
54
62
|
}
|
55
63
|
|
56
64
|
function generateTopAndBottom(result, options) {
|
65
|
+
const bottomStickGround = options.bottomStickGround;
|
57
66
|
const z = options.depth;
|
58
67
|
const depths = result.depths;
|
59
68
|
let lz = z, rz = z;
|
@@ -84,12 +93,18 @@ function generateTopAndBottom(result, options) {
|
|
84
93
|
points[idx2] = x1;
|
85
94
|
points[idx2 + 1] = y1;
|
86
95
|
points[idx2 + 2] = z1;
|
96
|
+
if (bottomStickGround) {
|
97
|
+
points[idx2 + 2] = 0;
|
98
|
+
}
|
87
99
|
|
88
100
|
// bottom right
|
89
101
|
const idx3 = (len * 2) * 3 + len * 3 + idx0;
|
90
102
|
points[idx3] = x2;
|
91
103
|
points[idx3 + 1] = y2;
|
92
104
|
points[idx3 + 2] = z2;
|
105
|
+
if (bottomStickGround) {
|
106
|
+
points[idx3 + 2] = 0;
|
107
|
+
}
|
93
108
|
|
94
109
|
i++;
|
95
110
|
}
|
@@ -134,12 +149,37 @@ function generateTopAndBottom(result, options) {
|
|
134
149
|
function generateSides(result, options) {
|
135
150
|
const { points, index, leftPoints, rightPoints, uvs } = result;
|
136
151
|
const z = options.depth;
|
152
|
+
const bottomStickGround = options.bottomStickGround;
|
137
153
|
const rings = [leftPoints, rightPoints];
|
138
154
|
const depthsEnable = result.depths;
|
139
155
|
|
140
156
|
function addOneSideIndex(v1, v2) {
|
141
157
|
const idx = points.length / 3;
|
142
|
-
|
158
|
+
let pIndex = points.length - 1;
|
159
|
+
|
160
|
+
// top
|
161
|
+
points[++pIndex] = v1[0];
|
162
|
+
points[++pIndex] = v1[1];
|
163
|
+
points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
|
164
|
+
|
165
|
+
points[++pIndex] = v2[0];
|
166
|
+
points[++pIndex] = v2[1];
|
167
|
+
points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2];
|
168
|
+
|
169
|
+
// points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
|
170
|
+
|
171
|
+
// bottom
|
172
|
+
|
173
|
+
points[++pIndex] = v1[0];
|
174
|
+
points[++pIndex] = v1[1];
|
175
|
+
points[++pIndex] = bottomStickGround ? 0 : v1[2];
|
176
|
+
|
177
|
+
points[++pIndex] = v2[0];
|
178
|
+
points[++pIndex] = v2[1];
|
179
|
+
points[++pIndex] = bottomStickGround ? 0 : v2[2];
|
180
|
+
|
181
|
+
// points.push(v1[0], v1[1], v1[2], v2[0], v2[1], v2[2]);
|
182
|
+
|
143
183
|
const a = idx + 2, b = idx + 3, c = idx, d = idx + 1;
|
144
184
|
index.push(a, c, b, c, d, b);
|
145
185
|
generateSideWallUV(uvs, points, a, b, c, d);
|