poly-extrude 0.20.0 → 0.20.1
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 +19 -9
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +19 -9
- package/dist/poly-extrude.mjs.map +1 -1
- package/dist/polyline.js +18 -8
- package/dist/polyline.js.map +1 -1
- package/package.json +1 -1
- package/src/polyline.ts +18 -8
package/dist/poly-extrude.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.20.
|
2
|
+
* poly-extrude v0.20.1
|
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 i(t,n,i){i=i||2;var r,o,h,a,c,f,y,p=n&&n.length,d=p?n[0]*i:t.length,g=e(t,0,d,i,!0),v=[];if(!g||g.next===g.prev)return v;if(p&&(g=function(t,n,i,r){var s,o,h,a=[];for(s=0,o=n.length;s<o;s++)(h=e(t,n[s]*r,s<o-1?n[s+1]*r:t.length,r,!1))===h.next&&(h.steiner=!0),a.push(x(h));for(a.sort(u),s=0;s<a.length;s++)i=l(a[s],i);return i}(t,n,g,i)),t.length>80*i){r=h=t[0],o=a=t[1];for(var _=i;_<d;_+=i)(c=t[_])<r&&(r=c),(f=t[_+1])<o&&(o=f),c>h&&(h=c),f>a&&(a=f);y=0!==(y=Math.max(h-r,a-o))?32767/y:0}return s(g,v,i,r,o,y,0),v}function e(t,n,i,e,r){var s,o;if(r===S(t,n,i,e)>0)for(s=n;s<i;s+=e)o=b(s,t[s],t[s+1],o);else for(s=i-e;s>=n;s-=e)o=b(s,t[s],t[s+1],o);return o&&v(o,o.next)&&(A(o),o=o.next),o}function r(t,n){if(!t)return t;n||(n=t);var i,e=t;do{if(i=!1,e.steiner||!v(e,e.next)&&0!==g(e.prev,e,e.next))e=e.next;else{if(A(e),(e=n=e.prev)===e.next)break;i=!0}}while(i||e!==n);return n}function s(t,n,i,e,u,l,f){if(t){!f&&l&&function(t,n,i,e){var r=t;do{0===r.z&&(r.z=y(r.x,r.y,n,i,e)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var n,i,e,r,s,o,h,a,c=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,e=i,h=0,n=0;n<c&&(h++,e=e.nextZ);n++);for(a=c;h>0||a>0&&e;)0!==h&&(0===a||!e||i.z<=e.z)?(r=i,i=i.nextZ,h--):(r=e,e=e.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=e}s.nextZ=null,c*=2}while(o>1)}(r)}(t,e,u,l);for(var x,p,d=t;t.prev!==t.next;)if(x=t.prev,p=t.next,l?h(t,e,u,l):o(t))n.push(x.i/i|0),n.push(t.i/i|0),n.push(p.i/i|0),A(t),t=p.next,d=p.next;else if((t=p)===d){f?1===f?s(t=a(r(t),n,i),n,i,e,u,l,2):2===f&&c(t,n,i,e,u,l):s(r(t),n,i,e,u,l,1);break}}}function o(t){var n=t.prev,i=t,e=t.next;if(g(n,i,e)>=0)return!1;for(var r=n.x,s=i.x,o=e.x,h=n.y,a=i.y,c=e.y,u=r<s?r<o?r:o:s<o?s:o,l=h<a?h<c?h:c:a<c?a:c,f=r>s?r>o?r:o:s>o?s:o,y=h>a?h>c?h:c:a>c?a:c,x=e.next;x!==n;){if(x.x>=u&&x.x<=f&&x.y>=l&&x.y<=y&&p(r,h,s,a,o,c,x.x,x.y)&&g(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function h(t,n,i,e){var r=t.prev,s=t,o=t.next;if(g(r,s,o)>=0)return!1;for(var h=r.x,a=s.x,c=o.x,u=r.y,l=s.y,f=o.y,x=h<a?h<c?h:c:a<c?a:c,d=u<l?u<f?u:f:l<f?l:f,v=h>a?h>c?h:c:a>c?a:c,_=u>l?u>f?u:f:l>f?l:f,z=y(x,d,n,i,e),m=y(v,_,n,i,e),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=x&&w.x<=v&&w.y>=d&&w.y<=_&&w!==r&&w!==o&&p(h,u,a,l,c,f,w.x,w.y)&&g(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=x&&M.x<=v&&M.y>=d&&M.y<=_&&M!==r&&M!==o&&p(h,u,a,l,c,f,M.x,M.y)&&g(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=x&&w.x<=v&&w.y>=d&&w.y<=_&&w!==r&&w!==o&&p(h,u,a,l,c,f,w.x,w.y)&&g(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=x&&M.x<=v&&M.y>=d&&M.y<=_&&M!==r&&M!==o&&p(h,u,a,l,c,f,M.x,M.y)&&g(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function a(t,n,i){var e=t;do{var s=e.prev,o=e.next.next;!v(s,o)&&_(s,e,e.next,o)&&w(s,o)&&w(o,s)&&(n.push(s.i/i|0),n.push(e.i/i|0),n.push(o.i/i|0),A(e),A(e.next),e=t=o),e=e.next}while(e!==t);return r(e)}function c(t,n,i,e,o,h){var a=t;do{for(var c=a.next.next;c!==a.prev;){if(a.i!==c.i&&d(a,c)){var u=M(a,c);return a=r(a,a.next),u=r(u,u.next),s(a,n,i,e,o,h,0),void s(u,n,i,e,o,h,0)}c=c.next}a=a.next}while(a!==t)}function u(t,n){return t.x-n.x}function l(t,n){var i=function(t,n){var i,e=n,r=t.x,s=t.y,o=-1/0;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var h=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=r&&h>o&&(o=h,i=e.x<e.next.x?e:e.next,h===r))return i}e=e.next}while(e!==n);if(!i)return null;var a,c=i,u=i.x,l=i.y,y=1/0;e=i;do{r>=e.x&&e.x>=u&&r!==e.x&&p(s<l?r:o,s,u,l,s<l?o:r,s,e.x,e.y)&&(a=Math.abs(s-e.y)/(r-e.x),w(e,t)&&(a<y||a===y&&(e.x>i.x||e.x===i.x&&f(i,e)))&&(i=e,y=a)),e=e.next}while(e!==c);return i}(t,n);if(!i)return n;var e=M(i,t);return r(e,e.next),r(i,i.next)}function f(t,n){return g(t.prev,t,n.prev)<0&&g(n.next,t,t.next)<0}function y(t,n,i,e,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-e)*r|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function x(t){var n=t,i=t;do{(n.x<i.x||n.x===i.x&&n.y<i.y)&&(i=n),n=n.next}while(n!==t);return i}function p(t,n,i,e,r,s,o,h){return(r-o)*(n-h)>=(t-o)*(s-h)&&(t-o)*(e-h)>=(i-o)*(n-h)&&(i-o)*(s-h)>=(r-o)*(e-h)}function d(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==n.i&&i.next.i!==n.i&&_(i,i.next,t,n))return!0;i=i.next}while(i!==t);return!1}(t,n)&&(w(t,n)&&w(n,t)&&function(t,n){var i=t,e=!1,r=(t.x+n.x)/2,s=(t.y+n.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(e=!e),i=i.next}while(i!==t);return e}(t,n)&&(g(t.prev,t,n.prev)||g(t,n.prev,n))||v(t,n)&&g(t.prev,t,t.next)>0&&g(n.prev,n,n.next)>0)}function g(t,n,i){return(n.y-t.y)*(i.x-n.x)-(n.x-t.x)*(i.y-n.y)}function v(t,n){return t.x===n.x&&t.y===n.y}function _(t,n,i,e){var r=m(g(t,n,i)),s=m(g(t,n,e)),o=m(g(i,e,t)),h=m(g(i,e,n));return r!==s&&o!==h||(!(0!==r||!z(t,i,n))||(!(0!==s||!z(t,e,n))||(!(0!==o||!z(i,t,e))||!(0!==h||!z(i,n,e)))))}function z(t,n,i){return n.x<=Math.max(t.x,i.x)&&n.x>=Math.min(t.x,i.x)&&n.y<=Math.max(t.y,i.y)&&n.y>=Math.min(t.y,i.y)}function m(t){return t>0?1:t<0?-1:0}function w(t,n){return g(t.prev,t,t.next)<0?g(t,n,t.next)>=0&&g(t,t.prev,n)>=0:g(t,n,t.prev)<0||g(t,t.next,n)<0}function M(t,n){var i=new P(t.i,t.x,t.y),e=new P(n.i,n.x,n.y),r=t.next,s=n.prev;return t.next=n,n.prev=t,i.next=r,r.prev=i,e.next=i,i.prev=e,s.next=e,e.prev=s,e}function b(t,n,i,e){var r=new P(t,n,i);return e?(r.next=e.next,r.prev=e,e.next.prev=r,e.next=r):(r.prev=r,r.next=r),r}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 P(t,n,i){this.i=t,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(t,n,i,e){for(var r=0,s=n,o=i-e;s<i;s+=e)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}n.exports=i,n.exports.default=i,i.deviation=function(t,n,i,e){var r=n&&n.length,s=r?n[0]*i:t.length,o=Math.abs(S(t,0,s,i));if(r)for(var h=0,a=n.length;h<a;h++){var c=n[h]*i,u=h<a-1?n[h+1]*i:t.length;o-=Math.abs(S(t,c,u,i))}var l=0;for(h=0;h<e.length;h+=3){var f=e[h]*i,y=e[h+1]*i,x=e[h+2]*i;l+=Math.abs((t[f]-t[x])*(t[y+1]-t[f+1])-(t[f]-t[y])*(t[x+1]-t[f+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},i.flatten=function(t){for(var n=t[0][0].length,i={vertices:[],holes:[],dimensions:n},e=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<n;o++)i.vertices.push(t[r][s][o]);r>0&&(e+=t[r-1].length,i.holes.push(e))}return i};var C=n.exports;function k(t,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function F(t,n){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},F(t,n)}var V=new(function(){function t(t,n,i,e){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===e&&(e=1),this.isQuaternion=!0,this._x=t,this._y=n,this._z=i,this._w=e}t.slerpFlat=function(t,n,i,e,r,s,o){var h=i[e+0],a=i[e+1],c=i[e+2],u=i[e+3],l=r[s+0],f=r[s+1],y=r[s+2],x=r[s+3];if(0===o)return t[n+0]=h,t[n+1]=a,t[n+2]=c,void(t[n+3]=u);if(1===o)return t[n+0]=l,t[n+1]=f,t[n+2]=y,void(t[n+3]=x);if(u!==x||h!==l||a!==f||c!==y){var p=1-o,d=h*l+a*f+c*y+u*x,g=d>=0?1:-1,v=1-d*d;if(v>Number.EPSILON){var _=Math.sqrt(v),z=Math.atan2(_,d*g);p=Math.sin(p*z)/_,o=Math.sin(o*z)/_}var m=o*g;if(h=h*p+l*m,a=a*p+f*m,c=c*p+y*m,u=u*p+x*m,p===1-o){var w=1/Math.sqrt(h*h+a*a+c*c+u*u);h*=w,a*=w,c*=w,u*=w}}t[n]=h,t[n+1]=a,t[n+2]=c,t[n+3]=u},t.multiplyQuaternionsFlat=function(t,n,i,e,r,s){var o=i[e],h=i[e+1],a=i[e+2],c=i[e+3],u=r[s],l=r[s+1],f=r[s+2],y=r[s+3];return t[n]=o*y+c*u+h*f-a*l,t[n+1]=h*y+c*l+a*u-o*f,t[n+2]=a*y+c*f+o*l-h*u,t[n+3]=c*y-o*u-h*l-a*f,t};var n,i,e,r=t.prototype;return r.set=function(t,n,i,e){return this._x=t,this._y=n,this._z=i,this._w=e,this._onChangeCallback(),this},r.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)},r.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},r.setFromEuler=function(t,n){void 0===n&&(n=!0);var i=t._x,e=t._y,r=t._z,s=t._order,o=Math.cos,h=Math.sin,a=o(i/2),c=o(e/2),u=o(r/2),l=h(i/2),f=h(e/2),y=h(r/2);switch(s){case"XYZ":this._x=l*c*u+a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u-l*f*y;break;case"YXZ":this._x=l*c*u+a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u+l*f*y;break;case"ZXY":this._x=l*c*u-a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u-l*f*y;break;case"ZYX":this._x=l*c*u-a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u+l*f*y;break;case"YZX":this._x=l*c*u+a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u-l*f*y;break;case"XZY":this._x=l*c*u-a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u+l*f*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===n&&this._onChangeCallback(),this},r.setFromAxisAngle=function(t,n){var i=n/2,e=Math.sin(i);return this._x=t.x*e,this._y=t.y*e,this._z=t.z*e,this._w=Math.cos(i),this._onChangeCallback(),this},r.setFromRotationMatrix=function(t){var n=t.elements,i=n[0],e=n[4],r=n[8],s=n[1],o=n[5],h=n[9],a=n[2],c=n[6],u=n[10],l=i+o+u;if(l>0){var f=.5/Math.sqrt(l+1);this._w=.25/f,this._x=(c-h)*f,this._y=(r-a)*f,this._z=(s-e)*f}else if(i>o&&i>u){var y=2*Math.sqrt(1+i-o-u);this._w=(c-h)/y,this._x=.25*y,this._y=(e+s)/y,this._z=(r+a)/y}else if(o>u){var x=2*Math.sqrt(1+o-i-u);this._w=(r-a)/x,this._x=(e+s)/x,this._y=.25*x,this._z=(h+c)/x}else{var p=2*Math.sqrt(1+u-i-o);this._w=(s-e)/p,this._x=(r+a)/p,this._y=(h+c)/p,this._z=.25*p}return this._onChangeCallback(),this},r.setFromUnitVectors=function(t,n){var i=t.dot(n)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=i),this.normalize()},r.rotateTowards=function(t,n){var i=this.angleTo(t);if(0===i)return this;var e=Math.min(1,n/i);return this.slerp(t,e),this},r.identity=function(){return this.set(0,0,0,1)},r.invert=function(){return this.conjugate()},r.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},r.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},r.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},r.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},r.normalize=function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},r.multiply=function(t){return this.multiplyQuaternions(this,t)},r.premultiply=function(t){return this.multiplyQuaternions(t,this)},r.multiplyQuaternions=function(t,n){var i=t._x,e=t._y,r=t._z,s=t._w,o=n._x,h=n._y,a=n._z,c=n._w;return this._x=i*c+s*o+e*a-r*h,this._y=e*c+s*h+r*o-i*a,this._z=r*c+s*a+i*h-e*o,this._w=s*c-i*o-e*h-r*a,this._onChangeCallback(),this},r.slerp=function(t,n){if(0===n)return this;if(1===n)return this.copy(t);var i=this._x,e=this._y,r=this._z,s=this._w,o=s*t._w+i*t._x+e*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=e,this._z=r,this;var h=1-o*o;if(h<=Number.EPSILON){var a=1-n;return this._w=a*s+n*this._w,this._x=a*i+n*this._x,this._y=a*e+n*this._y,this._z=a*r+n*this._z,this.normalize(),this}var c=Math.sqrt(h),u=Math.atan2(c,o),l=Math.sin((1-n)*u)/c,f=Math.sin(n*u)/c;return this._w=s*l+this._w*f,this._x=i*l+this._x*f,this._y=e*l+this._y*f,this._z=r*l+this._z*f,this._onChangeCallback(),this},r.slerpQuaternions=function(t,n,i){return this.copy(t).slerp(n,i)},r.random=function(){var t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),e=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(e*Math.sin(t),e*Math.cos(t),r*Math.sin(n),r*Math.cos(n))},r.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},r.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._w=t[n+3],this._onChangeCallback(),this},r.toArray=function(t,n){return void 0===t&&(t=[]),void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t},r.fromBufferAttribute=function(t,n){return this._x=t.getX(n),this._y=t.getY(n),this._z=t.getZ(n),this._w=t.getW(n),this._onChangeCallback(),this},r.toJSON=function(){return this.toArray()},r._onChange=function(t){return this._onChangeCallback=t,this},r._onChangeCallback=function(){},n=t,(i=[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}])&&k(n.prototype,i),e&&k(n,e),Object.defineProperty(n,"prototype",{writable:!1}),t}()),Z=function(){function t(t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=t,this.y=n,this.z=i}var n=t.prototype;return n.set=function(t,n,i){return void 0===i&&(i=this.z),this.x=t,this.y=n,this.z=i,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.applyAxisAngle=function(t,n){return this.applyQuaternion(V.setFromAxisAngle(t,n))},n.applyMatrix4=function(t){var n=this.x,i=this.y,e=this.z,r=t.elements,s=1/(r[3]*n+r[7]*i+r[11]*e+r[15]);return this.x=(r[0]*n+r[4]*i+r[8]*e+r[12])*s,this.y=(r[1]*n+r[5]*i+r[9]*e+r[13])*s,this.z=(r[2]*n+r[6]*i+r[10]*e+r[14])*s,this},n.applyQuaternion=function(t){var n=this.x,i=this.y,e=this.z,r=t.x,s=t.y,o=t.z,h=t.w,a=h*n+s*e-o*i,c=h*i+o*n-r*e,u=h*e+r*i-s*n,l=-r*n-s*i-o*e;return this.x=a*h+l*-r+c*-o-u*-s,this.y=c*h+l*-s+u*-r-a*-o,this.z=u*h+l*-o+a*-s-c*-r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(n,i)))},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,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this},n.cross=function(t){return this.crossVectors(this,t)},n.crossVectors=function(t,n){var i=t.x,e=t.y,r=t.z,s=n.x,o=n.y,h=n.z;return this.x=e*h-r*o,this.y=r*s-i*h,this.z=i*o-e*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}();function L(t,n){let i=t.length-1;for(let e=0,r=n.length;e<r;e++)t[++i]=n[e]}function O(t){let n,i,e=0,r=1;const s=t.length;for(;r<s;)n=i||t[0],i=t[r],e+=(i[0]-n[0])*(i[1]+n[1]),r++;return e>0}function q(t){U(t)||t.push(t[0])}function U(t){const n=t.length,[i,e]=t[0],[r,s]=t[n-1];return i===r&&e===s}function I(t){let n=0,i=0;const e=t.length;for(;i<e;)n+=t[i].length,i++;return n}function j(t,n){n=n||[1/0,1/0,-1/0,-1/0];for(let i=0,e=t.length;i<e;i++){const e=t[i];if(Array.isArray(e[0][0]))j(e,n);else for(let t=0,i=e.length;t<i;t++){const i=e[t],[r,s]=i;n[0]=Math.min(n[0],r),n[1]=Math.min(n[1],s),n[2]=Math.max(n[2],r),n[3]=Math.max(n[3],s)}}return n}function E(t,n){for(let i=0,e=t.length;i<e;i++){const e=t[i];q(e),0===i?O(e)||(t[i]=e.reverse()):O(e)&&(t[i]=e.reverse()),n&&U(e)&&e.splice(e.length-1,1)}}function N(t,n,i){return t[0]=n[0]-i[0],t[1]=n[1]-i[1],t[2]=n[2]-i[2],t}function R(t,n){const i=n[0],e=n[1],r=n[2],s=Math.sqrt(i*i+e*e+r*r)||1;return t[0]=i/s,t[1]=e/s,t[2]=r/s,t}function T(t,n,i){const e=n[0],r=n[1],s=n[2],o=i[0],h=i[1],a=i[2];return t[0]=r*a-s*h,t[1]=s*o-e*a,t[2]=e*h-r*o,t}function Q(t,n){function i(t,n,i,e){t[0]=n,t[1]=i,t[2]=e}const e=[],r=[],s=[],o=[],h=[],a=[],c=t.length,u=new Float32Array(n.length);let l=0;for(;l<c;){const c=3*t[l],f=3*t[l+1],y=3*t[l+2];i(e,n[c],n[c+1],n[c+2]),i(r,n[f],n[f+1],n[f+2]),i(s,n[y],n[y+1],n[y+2]),N(h,s,r),N(o,e,r),T(a,h,o);for(let t=0;t<3;t++)u[c+t]+=a[t],u[f+t]+=a[t],u[y+t]+=a[t];l+=3}let f=0;const y=u.length;for(;f<y;)i(a,u[f],u[f+1],u[f+2]),R(a,a),u[f]=a[0]||0,u[f+1]=a[1]||0,u[f+2]=a[2]||0,f+=3;return u}function W(t){if(1===t.length){return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t}}let n=0,i=0;for(let e=0,r=t.length;e<r;e++){const{position:r,indices:s}=t[e];n+=r.length,i+=s.length}const e={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(i),results:t};let r=0,s=0,o=0,h=0;for(let n=0,i=t.length;n<i;n++){const{position:i,indices:a,normal:c,uv:u}=t[n];e.position.set(i,r),e.normal.set(c,r),e.uv.set(u,h);let l=0;const f=a.length;for(;l<f;){const t=a[l]+s;e.indices[o]=t,o++,l++}h+=u.length,r+=i.length,s+=i.length/3}return e}function X(t){return 180*t/Math.PI}function B(t){return t/180*Math.PI}function Y(t,n,i,e,r,s){const o=3*i,h=3*e,a=3*r,c=3*s,u=n[o],l=n[o+1],f=n[o+2],y=n[h],x=n[h+1],p=n[h+2],d=n[a],g=n[a+1],v=n[a+2],_=n[c],z=n[c+1],m=n[c+2];let w=t.length-1;Math.abs(l-x)<Math.abs(u-y)?(t[++w]=u,t[++w]=1-f,t[++w]=y,t[++w]=1-p,t[++w]=d,t[++w]=1-v,t[++w]=_,t[++w]=1-m):(t[++w]=l,t[++w]=1-f,t[++w]=x,t[++w]=1-p,t[++w]=g,t[++w]=1-v,t[++w]=z,t[++w]=1-m)}function D(t){const n=[];for(let i=0,e=t.length;i<e;i++){const e=t[i],[r,s,o]=e,h=new Z(r,s,o||0);n[i]=h}return n}function G(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function H(t,n){const i=n.bottomStickGround,e=n.depth,r=t.depths;let s=e,o=e;r&&(s=r[0],o=r[1]);const{leftPoints:h,rightPoints:a}=t,c=t.line,u=n.pathUV;let l=c;if(h.length>l.length&&(l=h),u){!function(t){let n=0;for(let i=0,e=t.length;i<e;i++){const e=t[i],r=t[i+1];if(0===i&&(e.distance=0),e&&r){const[t,i,s]=e,[o,h,a]=r,c=t-o,u=i-h,l=(s||0)-(a||0);n+=Math.sqrt(c*c+u*u+l*l),r.distance=n}}}(l);for(let t=0,n=l.length;t<n;t++)h[t].distance=a[t].distance=l[t].distance}let f=0,y=h.length;const x=[],p=[],d=[];for(;f<y;){const t=3*f,[n,e,r]=h[f];x[t]=n,x[t+1]=e,x[t+2]=s+r;const[c,p,g]=a[f],v=3*y+t;x[v]=c,x[v+1]=p,x[v+2]=o+g;const _=2*y*3+t;x[_]=n,x[_+1]=e,x[_+2]=r,i&&(x[_+2]=0);const z=2*y*3+3*y+t;if(x[z]=c,x[z+1]=p,x[z+2]=g,i&&(x[z+2]=0),u){let t=l[f].distance;const n=2*f;d[n]=t,d[n+1]=1;const i=2*y+n;d[i]=t,d[i+1]=0;const e=2*y*2+n;d[e]=t,d[e+1]=1;const r=2*y*2+2*y+n;d[r]=t,d[r+1]=0}f++}if(!u){f=0,y=x.length;let t=d.length-1;for(;f<y;){const n=x[f],i=x[f+1];d[++t]=n,d[++t]=i,f+=3}}f=0,y=h.length;let g=p.length-1;for(;f<y-1;){const t=f,n=f+1,i=t+y,e=n+y;p[++g]=t,p[++g]=i,p[++g]=n,p[++g]=i,p[++g]=e,p[++g]=n;const r=f+2*y,s=r+1,o=r+y,h=s+y;p[++g]=r,p[++g]=o,p[++g]=s,p[++g]=o,p[++g]=h,p[++g]=s,f++}if(t.indices=p,t.points=x,t.uv=d,r)for(y=h.length,f=0;f<y;)h[f].depth=s,a[f].depth=o,f++}function J(t,n){const{points:i,indices:e,leftPoints:r,rightPoints:s,uv:o}=t,h=n.depth,a=n.bottomStickGround,c=[r,s],u=t.depths,l=n.pathUV,f=n.lineWidth;let y=i.length-1,x=e.length-1,p=o.length-1;function d(t,n){const r=i.length/3,s=u?t.depth:h,c=u?n.depth:h;i[++y]=t[0],i[++y]=t[1],i[++y]=s+t[2],i[++y]=n[0],i[++y]=n[1],i[++y]=c+n[2],i[++y]=t[0],i[++y]=t[1],i[++y]=a?0:t[2],i[++y]=n[0],i[++y]=n[1],i[++y]=a?0:n[2];const d=r+2,g=r+3,v=r,_=r+1;e[++x]=d,e[++x]=v,e[++x]=g,e[++x]=v,e[++x]=_,e[++x]=g,l?(o[++p]=t.distance,o[++p]=s/f,o[++p]=n.distance,o[++p]=c/f,o[++p]=t.distance,o[++p]=0,o[++p]=n.distance,o[++p]=0):Y(o,i,d,g,v,_)}for(let t=0,n=c.length;t<n;t++){let n=c[t];t>0&&(n=n.map((t=>t)),n=n.reverse());let i=0;const e=n.length-1;for(;i<e;){d(n[i],n[i+1]),i++}}const g=r.length,v=[s[0],r[0],r[g-1],s[g-1]];for(let t=0;t<v.length;t+=2){d(v[t],v[t+1])}}const K={x:0,y:0},$={x:0,y:0};function tt(t,n){let i=(n=Object.assign({},{lineWidth:1,cutCorner:!1},n)).lineWidth/2;n.isSlope&&(i*=2);const{cutCorner:e}=n,r=[],s=[],o=[],h=t.length,a=()=>{const t=s.length;if(t){s.push(s[t-1]),o.push(o[t-1]);const n=r.length;r.push(r[n-2],r[n-1])}},c=(t,n)=>t[0]===n[0]&&t[1]===n[1];let u,l,f=0;for(;f<h;){let n,y=t[f],x=t[f+1];const p=y;if(f===h-1){if(y=t[h-2],x=t[h-1],c(y,x))for(let n=t.indexOf(y);n>=0;n--){const i=t[n];if(!c(i,p)){y=i;break}}}else if(c(y,x))for(let n=t.indexOf(x);n<h;n++){const i=t[n];if(!c(i,p)){x=i;break}}if(c(y,x)){a(),f++;continue}let d=x[1]-y[1],g=x[0]-y[0],v=0;const _=X(Math.atan2(d,g));if(0===f||f===h-1)v=_,v-=90;else{if(n=t[f-1],c(n,x)||c(n,y))for(let i=t.indexOf(x);i>=0;i--){const e=t[i];if(!c(e,x)&&!c(e,y)){n=e;break}}if(c(n,x)||c(n,y)||c(y,x)){a(),f++;continue}K.x=n[0]-y[0],K.y=n[1]-y[1],$.x=x[0]-y[0],$.y=x[1]-y[1],(0===K.x&&0===K.y||0===$.x&&0===$.y)&&console.error("has repeat vertex,the index:",f);v=_-nt(K,$)/2}const z=B(v),m=p,w=[Math.cos(z)+m[0],Math.sin(z)+m[1]],[M,b]=rt(y,x,i);let A=st(M[0],M[1],m,w),P=st(b[0],b[1],m,w);if(!A||!P){const t=r.length,n=r[t-2],i=r[t-1];if(!n||!i){f++;continue}A=[n[0],n[1]],P=[i[0],i[1]]}A[2]=p[2]||0,P[2]=p[2]||0,r.push(A,P);let S=!1;if(e){const t=2*i;(it(p,A)>t||it(p,P)>t)&&(S=!0)}if(S&&n&&u&&l){let t=A;it(A,n)<it(P,n)&&(t=P);const e=t[1]-p[1],r=t[0]-p[0],h=Math.atan2(e,r)/Math.PI*180,a=B(h),c=Math.cos(a)*i+p[0],f=Math.sin(a)*i+p[1],d=[c,f],g=B(h+90),v=[Math.cos(g)+c,Math.sin(g)+f];let _=u,z=M,m=s,w=o;et(t,y,x)||(_=l,z=b,m=o,w=s);let S=st(_[0],_[1],d,v),C=st(z[0],z[1],d,v);S[2]=p[2]||0,C[2]=p[2]||0;const k=t===A?P:A;m.push(S,C),w.push(k,[...k])}else et(A,y,x)?(s.push(A),o.push(P)):(s.push(P),o.push(A));u=M,l=b,f++}return{offsetPoints:r,leftPoints:s,rightPoints:o,line:t}}const nt=({x:t,y:n},{x:i,y:e})=>{const r=t*i+n*e,s=t*e-n*i;return Math.atan2(s,r)/Math.PI*180};function it(t,n){const i=n[0]-t[0],e=n[1]-t[1];return Math.sqrt(i*i+e*e)}function et(t,n,i){const[e,r]=n,[s,o]=i,[h,a]=t;return(r-o)*h+(s-e)*a+e*o-s*r>0}function rt(t,n,i){const e=n[1]-t[1],r=n[0]-t[0];if(0===e&&0===r)return null;const s=Math.atan2(e,r),o=s+Math.PI/2;let h=Math.cos(o)*i,a=Math.sin(o)*i;const c=[t[0]+h,t[1]+a],u=[n[0]+h,n[1]+a],l=s-Math.PI/2;h=Math.cos(l)*i,a=Math.sin(l)*i;return[[c,u],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function st(t,n,i,e){const r=n[0]-t[0],s=n[1]-t[1],o=e[0]-i[0],h=e[1]-i[1];if(0===r&&0===o)return null;if(0===s&&0===h)return null;const a=s/r,c=h/o,u=t[1]-a*t[0],l=i[1]-c*i[0];let f,y;return 0===r?(f=t[0],y=c*f+l):0===o?(f=i[0],y=a*f+u):0===s?(y=t[1],f=(y-l)/c):0===h?(y=i[1],f=(y-u)/a):(f=(l-u)/(a-c),y=a*f+u),[f,y]}var ot=function(){function t(){this.pos=new Z,this.dir=new Z,this.right=new Z,this.up=new Z,this.dist=0,this.widthScale=1,this.sharp=!1}var n=t.prototype;return n.lerpPathPoints=function(t,n,i){this.pos.lerpVectors(t.pos,n.pos,i),this.dir.lerpVectors(t.dir,n.dir,i),this.up.lerpVectors(t.up,n.up,i),this.right.lerpVectors(t.right,n.right,i),this.dist=(n.dist-t.dist)*i+t.dist,this.widthScale=(n.widthScale-t.widthScale)*i+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}(),ht=function(){function t(t,n,i,e,r,s,o,h,a,c,u,l,f,y,x,p){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,i,e,r,s,o,h,a,c,u,l,f,y,x,p)}var n=t.prototype;return n.set=function(t,n,i,e,r,s,o,h,a,c,u,l,f,y,x,p){var d=this.elements;return d[0]=t,d[4]=n,d[8]=i,d[12]=e,d[1]=r,d[5]=s,d[9]=o,d[13]=h,d[2]=a,d[6]=c,d[10]=u,d[14]=l,d[3]=f,d[7]=y,d[11]=x,d[15]=p,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var i=Math.cos(n),e=Math.sin(n),r=1-i,s=t.x,o=t.y,h=t.z,a=r*s,c=r*o;return this.set(a*s+i,a*o-e*h,a*h+e*o,0,a*o+e*h,c*o+i,c*h-e*s,0,a*h-e*o,c*h+e*s,r*h*h+i,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,i=t.elements,e=0;e<16;e++)if(n[e]!==i[e])return!1;return!0},t}(),at=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 i=this.getUtoTmapping(t);return this.getPoint(i,n)},n.getPoints=function(t){void 0===t&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/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,i=[],e=this.getPoint(0),r=0;i.push(0);for(var s=1;s<=t;s++)r+=(n=this.getPoint(s/t)).distanceTo(e),i.push(r),e=n;return this.cacheArcLengths=i,i},n.getUtoTmapping=function(t,n){var i,e=this.getLengths(),r=0,s=e.length;i=n||t*e[s-1];for(var o,h=0,a=s-1;h<=a;)if((o=e[r=Math.floor(h+(a-h)/2)]-i)<0)h=r+1;else{if(!(o>0)){a=r;break}a=r-1}if(e[r=a]===i)return r/(s-1);var c=e[r];return(r+(i-c)/(e[r+1]-c))/(s-1)},t}();function ct(t,n,i,e){return function(t,n){var i=1-t;return i*i*n}(t,n)+function(t,n){return 2*(1-t)*t*n}(t,i)+function(t,n){return t*t*n}(t,e)}var ut=function(t){var n,i;function e(n,i,e){var r;return void 0===n&&(n=new Z),void 0===i&&(i=new Z),void 0===e&&(e=new Z),(r=t.call(this)||this).isQuadraticBezierCurve3=!0,r.type="QuadraticBezierCurve3",r.v0=n,r.v1=i,r.v2=e,r}return i=t,(n=e).prototype=Object.create(i.prototype),n.prototype.constructor=n,F(n,i),e.prototype.getPoint=function(t,n){void 0===n&&(n=new Z);var i=n,e=this.v0,r=this.v1,s=this.v2;return i.set(ct(t,e.x,r.x,s.x),ct(t,e.y,r.y,s.y),ct(t,e.z,r.z,s.z)),i},e}(at),lt=new Z,ft=new Z,yt=new Z,xt=new ht,pt=new ut;var dt=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,i,e,r){if(void 0===n&&(n=.1),void 0===i&&(i=10),void 0===e&&(e=null),void 0===r&&(r=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);r&&!t[0].equals(t[t.length-1])&&t.push((new Z).copy(t[0]));for(var s=0,o=t.length;s<o;s++)if(0===s)this._start(t[s],t[s+1],e);else if(s===o-1)if(r){this._corner(t[s],t[1],n,i,e);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,i,e)},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 ot),this.array[t]},n._start=function(t,n,i){this.count=0;var e=this._getByIndex(this.count);if(e.pos.copy(t),e.dir.subVectors(n,t),i)e.up.copy(i);else{var r=Number.MAX_VALUE,s=Math.abs(e.dir.x),o=Math.abs(e.dir.y),h=Math.abs(e.dir.z);s<r&&(r=s,e.up.set(1,0,0)),o<r&&(r=o,e.up.set(0,1,0)),h<r&&e.up.set(0,0,1)}e.right.crossVectors(e.dir,e.up).normalize(),e.up.crossVectors(e.right,e.dir).normalize(),e.dist=0,e.widthScale=1,e.sharp=!1,e.dir.normalize(),this.count++},n._end=function(t){var n=this.array[this.count-1],i=this._getByIndex(this.count);i.pos.copy(t),i.dir.subVectors(t,n.pos);var e=i.dir.length();i.dir.normalize(),i.up.copy(n.up);var r=lt.crossVectors(n.dir,i.dir);if(r.length()>Number.EPSILON){r.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(i.dir),-1),1));i.up.applyMatrix4(xt.makeRotationAxis(r,s))}i.right.crossVectors(i.dir,i.up).normalize(),i.dist=n.dist+e,i.widthScale=1,i.sharp=!1,this.count++},n._corner=function(t,n,i,e,r){if(i>0&&e>0){for(var s=function(t,n,i,e,r,s){var o=lt.subVectors(n,t),h=ft.subVectors(i,n),a=o.length(),c=h.length();o.normalize(),h.normalize();var u=Math.min(.999999*(r?a/2:a),e);s.v0.copy(n).sub(o.multiplyScalar(u)),s.v1.copy(n);var l=Math.min(c/2*.999999,e);return s.v2.copy(n).add(h.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,i,this.count-1==0,pt),o=s.getPoints(e),h=0;h<e;h++)this._sharpCorner(o[h],o[h+1],r,0===h?1:0);o[e].equals(n)||this._sharpCorner(o[e],n,r,2)}else this._sharpCorner(t,n,r,0,!0)},n._sharpCorner=function(t,n,i,e,r){void 0===e&&(e=0),void 0===r&&(r=!1);var s=this.array[this.count-1],o=this._getByIndex(this.count),h=lt.subVectors(t,s.pos),a=ft.subVectors(n,t),c=h.length();if(h.normalize(),a.normalize(),o.pos.copy(t),1===e?o.dir.copy(h):2===e?o.dir.copy(a):(o.dir.addVectors(h,a),o.dir.normalize()),i)1===o.dir.dot(i)?o.right.crossVectors(a,i).normalize():o.right.crossVectors(o.dir,i).normalize(),o.up.crossVectors(o.right,o.dir).normalize();else{o.up.copy(s.up);var u=yt.crossVectors(s.dir,o.dir);if(u.length()>Number.EPSILON){u.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(o.dir),-1),1));o.up.applyMatrix4(xt.makeRotationAxis(u,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+c;var f=h.dot(a);o.widthScale=Math.min(1/Math.sqrt((1+f)/2),1.415)||1,o.sharp=Math.abs(f-1)>.05&&r,this.count++},t}();const gt=new Z(0,0,1),vt=new Z,_t=new Z,zt=new Z,mt=new Z,wt=new Z,Mt=new Z;const bt=new Z(0,0,1),At=new Z;const Pt=new Z(0,0,1),St=new Z;function Ct(t,n){const[i,e]=t,[r,s]=n,o=s-e,h=r-i;return Math.atan2(o,h)}const kt=new Z(0,0,0);t.cylinder=function(t,n){const i=Object.assign({},{radius:1,height:2,radialSegments:6},n),e=Math.round(Math.max(4,i.radialSegments));let{radius:r,height:s}=i;const o=360/e/360*Math.PI*2,h=e+1,a=new Float32Array(3*h*2),[c,u]=t;let l=0,f=0;const y=3*h,x=2*h,p=[],d=[];let g=p.length-1;for(let t=-1;t<e;t++){const n=o*t,i=Math.cos(n)*r+c,e=Math.sin(n)*r+u;a[l]=i,a[l+1]=e,a[l+2]=0,a[l+y]=i,a[l+1+y]=e,a[l+2+y]=s;let h=0,v=0;h=.5+i/r/2,v=.5+e/r/2,d[f]=h,d[f+1]=v,d[f+x]=h,d[f+1+x]=v,l+=3,f+=2,t>1&&(p[++g]=0,p[++g]=t-1,p[++g]=t)}l-=3,a[l]=a[0],a[l+1]=a[1],a[l+2]=a[2];const v=a.length;a[v-3]=a[0],a[v-2]=a[1],a[v-1]=s;const _=p.length;g=p.length-1;for(let t=0;t<_;t++){const n=p[t];p[++g]=n+h}const z=new Float32Array(2*(3*h*2-6));let m=-1;l=2*h,f=0,g=p.length-1;let w=d.length-1;for(let t=0,n=a.length/2;t<n-3;t+=3){const n=a[t],i=a[t+1],e=a[t+3],o=a[t+4];z[++m]=n,z[++m]=i,z[++m]=s,z[++m]=e,z[++m]=o,z[++m]=s,z[++m]=n,z[++m]=i,z[++m]=0,z[++m]=e,z[++m]=o,z[++m]=0;const c=l+2,u=l+3,y=l,x=l+1;p[++g]=y,p[++g]=c,p[++g]=x,p[++g]=c,p[++g]=u,p[++g]=x,l+=4;const v=f/h,_=(f+1)/h;d[++w]=v,d[++w]=s/r/2,d[++w]=_,d[++w]=s/r/2,d[++w]=v,d[++w]=0,d[++w]=_,d[++w]=0,f++}const M=new Float32Array(a.length+z.length);M.set(a,0),M.set(z,a.length);const b=Q(p,M);return{points:a,indices:new Uint32Array(p),position:M,normal:b,uv:new Float32Array(d)}},t.expandLine=tt,t.expandPaths=function(t,n){const i=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n),e=t.map((t=>{const n=D(t),e=new dt;e.set(n,i.cornerRadius,i.cornerSplit,gt);const r=function(t,n){const i=n.lineWidth||.1,e=1,r=i/2,s=i,o=t.distance(),h=e*o;let a=0;const c=[],u=[],l=[],f=[];let y=0;if(0===o)return{position:c,normal:u,uv:l,indices:f,count:a};const x=r/s;let p,d=c.length-1,g=u.length-1,v=l.length-1,_=f.length-1;function z(t){const n=0===c.length,i=t.sharp&&!n,e=t.dist/s,o=t.dir,h=t.up,p=t.right;if(vt.copy(p).multiplyScalar(r*t.widthScale),_t.copy(p).multiplyScalar(-r*t.widthScale),vt.add(t.pos),_t.add(t.pos),i){zt.fromArray(c,c.length-6).sub(_t),mt.fromArray(c,c.length-3).sub(vt);const t=zt.length()-mt.length();let n,i;t>0?(n=zt,i=_t):(n=mt,i=vt),wt.copy(n).setLength(Math.abs(t)).add(i);let r=Mt.copy(i).sub(wt).normalize().dot(o)*Mt.copy(i).sub(wt).length()*2;Mt.copy(o).setLength(r).add(wt),t>0?(c[++d]=wt.x,c[++d]=wt.y,c[++d]=wt.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=Mt.x,c[++d]=Mt.y,c[++d]=Mt.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,y+=6,f[++_]=y-6,f[++_]=y-8,f[++_]=y-7,f[++_]=y-6,f[++_]=y-7,f[++_]=y-5,f[++_]=y-4,f[++_]=y-6,f[++_]=y-5,f[++_]=y-2,f[++_]=y-4,f[++_]=y-1,a+=12):(c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=wt.x,c[++d]=wt.y,c[++d]=wt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=Mt.x,c[++d]=Mt.y,c[++d]=Mt.z,y+=6,f[++_]=y-6,f[++_]=y-8,f[++_]=y-7,f[++_]=y-6,f[++_]=y-7,f[++_]=y-5,f[++_]=y-6,f[++_]=y-5,f[++_]=y-3,f[++_]=y-2,f[++_]=y-3,f[++_]=y-1,a+=12);for(let t=0;t<6;t++)u[++g]=h.x,u[++g]=h.y,u[++g]=h.z;l[++v]=e-x,l[++v]=0,l[++v]=e-x,l[++v]=1,l[++v]=e,l[++v]=0,l[++v]=e,l[++v]=1,l[++v]=e+x,l[++v]=0,l[++v]=e+x,l[++v]=1}else c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,u[++g]=h.x,u[++g]=h.y,u[++g]=h.z,u[++g]=h.x,u[++g]=h.y,u[++g]=h.z,l[++v]=e,l[++v]=0,l[++v]=e,l[++v]=1,y+=2,n||(f[++_]=y-2,f[++_]=y-4,f[++_]=y-3,f[++_]=y-2,f[++_]=y-3,f[++_]=y-1,a+=6)}if(h>0)for(let n=0;n<t.count;n++){const i=t.array[n];if(i.dist>h){const e=t.array[n-1];p=new ot;const r=(h-e.dist)/(i.dist-e.dist);p.lerpPathPoints(e,i,r),z(p);break}z(i)}else p=t.array[0];return{position:c,normal:u,uv:l,indices:f,count:a}}(e,i);return{position:new Float32Array(r.position),indices:new Uint32Array(r.indices),uv:new Float32Array(r.uv),normal:new Float32Array(r.normal),line:t,count:r.count}})),r=W(e);return r.lines=t,r},t.expandTubes=function(t,n){const i=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n),e=t.map((t=>{const n=D(t),e=new dt;e.set(n,0,i.cornerSplit,bt);const r=function(t,n){const i=Math.max(n.radius||1,1e-8),e=void 0!==n.progress?n.progress:1,r=Math.max(3,n.radialSegments||8),s=n.startRad||0,o=2*i*Math.PI,h=t.distance(),a=e*h;if(0===a)return null;let c=0;const u=[],l=[],f=[],y=[];let x=0,p=-1,d=-1,g=-1,v=-1;function _(t,n,i){const e=0===u.length,r=t.dist/o;for(let e=0;e<=i;e++){let o=e;o===i&&(o=0),At.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();const h=n*t.widthScale;u[++p]=t.pos.x+At.x*h,u[++p]=t.pos.y+At.y*h,u[++p]=t.pos.z+At.z*h,l[++d]=At.x,l[++d]=At.y,l[++d]=At.z,f[++g]=r,f[++g]=e/i,x++}if(!e){const t=x-2*(i+1),n=x-(i+1);for(let e=0;e<i;e++)y[++v]=n+e,y[++v]=t+e,y[++v]=t+e+1,y[++v]=n+e,y[++v]=t+e+1,y[++v]=n+e+1,c+=6}}if(a>0)for(let n=0;n<t.count;n++){const e=t.array[n];if(e.dist>a){const s=t.array[n-1],o=new ot,h=(a-s.dist)/(e.dist-s.dist);o.lerpPathPoints(s,e,h),_(o,i,r);break}_(e,i,r)}return{points:u,normal:l,uv:f,indices:y,count:c}}(e,i);return r.line=t,r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.indices),r.uv=new Float32Array(r.uv),r.normal=new Float32Array(r.normal),r})),r=W(e);return r.lines=t,r},t.extrudePolygons=function(t,n){const i=Object.assign({},{depth:2,top:!0},n),e=t.map((t=>{E(t,!0);const n=function(t,n){const i=I(t),e=t.length,r=[],s=new Float32Array(2*i),o=[],h=[],a=3*i,c=2*i,u=n.depth;let l=0,f=0,y=0;for(let n=0;n<e;n++){const i=t[n];n>0&&r.push(l/2);let e=0;const x=i.length;for(;e<x;){const t=i[e],n=t[0],r=t[1],x=t[2]||0;s[l++]=n,s[l++]=r,o[f]=n,o[f+1]=r,o[f+2]=u+x,o[a+f]=n,o[a+f+1]=r,o[a+f+2]=x,h[y]=n,h[y+1]=r,h[c+y]=n,h[c+y+1]=r,f+=3,y+=2,e++}}return{flatVertices:s,holes:r,points:o,count:i,uv:h}}(t,i);n.polygon=t;return function(t,n,i){const e=[],{count:r}=t,s=i.top;for(let t=0,i=n.length;t<i;t+=3){const o=n[t],h=n[t+1],a=n[t+2];s&&(e[t]=o,e[t+1]=h,e[t+2]=a);let c=i+t;const u=r+o,l=r+h,f=r+a;s||(c=t),e[c]=u,e[c+1]=l,e[c+2]=f}t.indices=e}(n,C(n.flatVertices,n.holes,2),i),function(t,n){const{points:i,indices:e,polygon:r,uv:s}=t,o=n.depth;let h=i.length-1,a=e.length-1;for(let t=0,n=r.length;t<n;t++){const n=r[t];let c=0;const u=n.length;for(;c<u;){const t=n[c];let r=n[c+1];c===u-1&&(r=n[0]);const l=i.length/3,f=t[0],y=t[1],x=t[2]||0,p=r[0],d=r[1],g=r[2]||0;i[++h]=f,i[++h]=y,i[++h]=x+o,i[++h]=p,i[++h]=d,i[++h]=g+o,i[++h]=f,i[++h]=y,i[++h]=x,i[++h]=p,i[++h]=d,i[++h]=g;const v=l+2,_=l+3,z=l,m=l+1;e[++a]=v,e[++a]=z,e[++a]=_,e[++a]=z,e[++a]=m,e[++a]=_,Y(s,i,v,_,z,m),c++}}}(n,i),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=Q(n.indices,n.position),n})),r=W(e);return r.polygons=t,r},t.extrudePolygonsOnPath=function(t,n){const i=Object.assign({},{openEnd:!1,openEndUV:!0,polygonRotation:0},n),{extrudePath:e,openEnd:r}=i;if(!e||!Array.isArray(e)||e.length<2)return console.error("extrudePath is error:",e),null;const s=j(t),[o,h,a,c]=s,u=[(o+a)/2,(h+c)/2];i.center=u,i.bbox=s;const l=D(e),f=new dt;f.set(l,0,i.cornerSplit,Pt);const y=t.map((t=>{E(t,!1);const n=function(t,n,i){const e=function(t,n){const{center:i,polygonRotation:e}=n,[r,s]=i,o=[];return t.forEach(((t,n)=>{const h=[];let a,c=0;for(let n=0,o=t.length;n<o;n++){const o=t[n],u=o[0],l=o[1],f=u-r,y=l-s;let x=0;if(n>0){const t=a[0]-u,n=a[1]-l;x=Math.sqrt(t*t+n*n)+c,c=x}h[n]={distance:x,radius:Math.sqrt(f*f+y*y),angle:-Ct(i,o)+e},a=o}o[n]={ring:h,ringLen:c}})),o}(n,i),r=[],s=[],o=[],h=[];let a=0,c=-1,u=-1,l=-1,f=-1;const y=[],x=[];function p(t,n,i,e,p){const d=t.dist/i,g=n.length;for(let h=0;h<g;h++){const f=n[h];if(!f)continue;const v=h===g-1,_=f.angle,z=f.radius,m=f.distance;St.copy(t.up).applyAxisAngle(t.dir,_).normalize();const w=kt.copy(t.up);w.applyAxisAngle(t.dir,_),w.x*=z,w.y*=z,w.z*=z;const M=t.pos.x+w.x,b=t.pos.y+w.y,A=t.pos.z+w.z;if(r[++c]=M,r[++c]=b,r[++c]=A,s[++u]=St.x,s[++u]=St.y,s[++u]=St.z,o[++l]=d,o[++l]=m/i,a++,e&&!v){let t=y.length-1;y[++t]=M,y[++t]=b,y[++t]=A}if(p&&!v){let t=x.length-1;x[++t]=M,x[++t]=b,x[++t]=A}}if(!e){const t=a-2*g,n=a-g;for(let i=0;i<g-1;i++)h[++f]=n+i,h[++f]=t+i,h[++f]=t+i+1,h[++f]=n+i,h[++f]=t+i+1,h[++f]=n+i+1}}const d=e[0].ringLen;return e.forEach((n=>{for(let i=0;i<t.count;i++){const e=t.array[i],{ring:r,ringLen:s}=n;p(e,r,s,0===i,i===t.count-1)}})),{points:r,normal:s,uv:o,indices:h,startPoints:y,endPoints:x,polygonLen:d}}(f,t,i);return r||function(t,n,i){const{openEndUV:e}=i;for(let t=0,i=n.length;t<i;t++){const i=n[t];U(i)&&i.splice(i.length-1,1)}const r=I(n),s=[],o=[];let h=-1;for(let t=0,i=n.length;t<i;t++){const i=n[t];t>0&&o.push(s.length/2);for(let t=0,n=i.length;t<n;t++){const n=i[t];s[++h]=n[0],s[++h]=n[1]}}const a=C(s,o,2),{points:c,normal:u,uv:l,indices:f,startPoints:y,endPoints:x,polygonLen:p}=t;h=0;let d=0;const g=[],v=[],_=[],z=[];for(let t=0;t<r;t++){const n=3*t,i=y[n],r=y[n+1],s=y[n+2];g[h]=i,g[h+1]=r,g[h+2]=s,e?(v[d]=r/p,v[d+1]=s/p):(v[d]=0,v[d+1]=0);const o=x[n],a=x[n+1],c=x[n+2];_[h]=o,_[h+1]=a,_[h+2]=c,e?(z[d]=a/p,z[d+1]=c/p):(z[d]=0,z[d+1]=0),h+=3,d+=2}const m=c.length/3,w=[];for(let t=0,n=a.length;t<n;t++)w[t]=a[t]+m,w[t+n]=a[t]+m+r;const M=Q(a,g),b=Q(a,_);L(c,g),L(c,_),L(l,v),L(l,z),L(u,M),L(u,b),L(f,w)}(n,t,i),n.polygon=t,n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=new Float32Array(n.normal),n})),x=W(y);return x.polygons=t,x},t.extrudePolylines=function(t,n){const i=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},n);G(i);const e=t.map((t=>{const n=tt(t,i);return n.line=t,H(n,i),J(n,i),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=Q(n.indices,n.position),n})),r=W(e);return r.lines=t,r},t.extrudeSlopes=function(t,n){const i=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},n);G(i);const{depth:e,side:r,sideDepth:s}=i,o=t.map((t=>{const n=tt(t,i);n.line=t;const{leftPoints:o,rightPoints:h}=n,a={line:t};let c;for(let n=0,i=t.length;n<i;n++)t[n][2]=t[n][2]||0;return"left"===r?(a.leftPoints=o,a.rightPoints=t,c=[s,e]):(a.leftPoints=t,a.rightPoints=h,c=[e,s]),a.depths=c,H(a,i),J(a,i),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.indices),a.uv=new Float32Array(a.uv),a.normal=Q(a.indices,a.position),a})),h=W(o);return h.lines=t,h},t.isClockwise=O,t.leftOnLine=et,t.merge=W,t.plane=function(t,n,i,e){const r=t/(i=Math.max(1,i)),s=n/(e=Math.max(1,e)),o=-t/2,h=n/2,a=-n/2,c=(i+1)*(e+1),u=new Float32Array(3*c),l=new Float32Array(2*c),f=new Float32Array(3*c),y=new Uint32Array(10*c);let x=0,p=0,d=0;for(let c=0;c<=e;c++)for(let g=0;g<=i;g++){const v=o+r*g,_=h-s*c;u[x]=v,u[x+1]=_,u[x+2]=0,f[x]=0,f[x+1]=0,f[x+2]=1;const z=(v-o)/t,m=(_-a)/n;if(l[p]=z,l[p+1]=m,x+=3,p+=2,g<i&&c<e){const t=c*(i+1)+g,n=t+1,e=(i+1)*(c+1)+g,r=e+1;y[d]=t,y[d+1]=e,y[d+2]=n,y[d+3]=e,y[d+4]=r,y[d+5]=n,d+=6}}const g=new Uint32Array(d);for(let t=0,n=g.length;t<n;t++)g[t]=y[t];return{position:u,uv:l,normal:f,indices:g}},t.polygons=function(t,n={}){const i=Object.assign({},n),e=t.map((t=>{E(t,!0);const n=function(t,n={}){const i=[],e=[];let r=-1,s=-1,o=-1;const h=[],a=[];for(let n=0,c=t.length;n<c;n++){const c=t[n];n>0&&e.push(i.length/2);for(let t=0,n=c.length;t<n;t++){const n=c[t];i[++r]=n[0],i[++r]=n[1],h[++s]=n[0],h[++s]=n[1],h[++s]=n[2]||0,a[++o]=n[0],a[++o]=n[1]}}const c=C(i,e,2);return{normal:Q(c,h),uv:a,points:h,indices:c}}(t,i);return n.polygon=t,n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=new Float32Array(n.normal),n})),r=W(e);return r.polygons=t,r},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 i(t,n,i){i=i||2;var r,o,h,a,c,f,y,p=n&&n.length,d=p?n[0]*i:t.length,g=e(t,0,d,i,!0),v=[];if(!g||g.next===g.prev)return v;if(p&&(g=function(t,n,i,r){var s,o,h,a=[];for(s=0,o=n.length;s<o;s++)(h=e(t,n[s]*r,s<o-1?n[s+1]*r:t.length,r,!1))===h.next&&(h.steiner=!0),a.push(x(h));for(a.sort(u),s=0;s<a.length;s++)i=l(a[s],i);return i}(t,n,g,i)),t.length>80*i){r=h=t[0],o=a=t[1];for(var _=i;_<d;_+=i)(c=t[_])<r&&(r=c),(f=t[_+1])<o&&(o=f),c>h&&(h=c),f>a&&(a=f);y=0!==(y=Math.max(h-r,a-o))?32767/y:0}return s(g,v,i,r,o,y,0),v}function e(t,n,i,e,r){var s,o;if(r===S(t,n,i,e)>0)for(s=n;s<i;s+=e)o=b(s,t[s],t[s+1],o);else for(s=i-e;s>=n;s-=e)o=b(s,t[s],t[s+1],o);return o&&v(o,o.next)&&(A(o),o=o.next),o}function r(t,n){if(!t)return t;n||(n=t);var i,e=t;do{if(i=!1,e.steiner||!v(e,e.next)&&0!==g(e.prev,e,e.next))e=e.next;else{if(A(e),(e=n=e.prev)===e.next)break;i=!0}}while(i||e!==n);return n}function s(t,n,i,e,u,l,f){if(t){!f&&l&&function(t,n,i,e){var r=t;do{0===r.z&&(r.z=y(r.x,r.y,n,i,e)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var n,i,e,r,s,o,h,a,c=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,e=i,h=0,n=0;n<c&&(h++,e=e.nextZ);n++);for(a=c;h>0||a>0&&e;)0!==h&&(0===a||!e||i.z<=e.z)?(r=i,i=i.nextZ,h--):(r=e,e=e.nextZ,a--),s?s.nextZ=r:t=r,r.prevZ=s,s=r;i=e}s.nextZ=null,c*=2}while(o>1)}(r)}(t,e,u,l);for(var x,p,d=t;t.prev!==t.next;)if(x=t.prev,p=t.next,l?h(t,e,u,l):o(t))n.push(x.i/i|0),n.push(t.i/i|0),n.push(p.i/i|0),A(t),t=p.next,d=p.next;else if((t=p)===d){f?1===f?s(t=a(r(t),n,i),n,i,e,u,l,2):2===f&&c(t,n,i,e,u,l):s(r(t),n,i,e,u,l,1);break}}}function o(t){var n=t.prev,i=t,e=t.next;if(g(n,i,e)>=0)return!1;for(var r=n.x,s=i.x,o=e.x,h=n.y,a=i.y,c=e.y,u=r<s?r<o?r:o:s<o?s:o,l=h<a?h<c?h:c:a<c?a:c,f=r>s?r>o?r:o:s>o?s:o,y=h>a?h>c?h:c:a>c?a:c,x=e.next;x!==n;){if(x.x>=u&&x.x<=f&&x.y>=l&&x.y<=y&&p(r,h,s,a,o,c,x.x,x.y)&&g(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function h(t,n,i,e){var r=t.prev,s=t,o=t.next;if(g(r,s,o)>=0)return!1;for(var h=r.x,a=s.x,c=o.x,u=r.y,l=s.y,f=o.y,x=h<a?h<c?h:c:a<c?a:c,d=u<l?u<f?u:f:l<f?l:f,v=h>a?h>c?h:c:a>c?a:c,_=u>l?u>f?u:f:l>f?l:f,z=y(x,d,n,i,e),m=y(v,_,n,i,e),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=x&&w.x<=v&&w.y>=d&&w.y<=_&&w!==r&&w!==o&&p(h,u,a,l,c,f,w.x,w.y)&&g(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=x&&M.x<=v&&M.y>=d&&M.y<=_&&M!==r&&M!==o&&p(h,u,a,l,c,f,M.x,M.y)&&g(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=x&&w.x<=v&&w.y>=d&&w.y<=_&&w!==r&&w!==o&&p(h,u,a,l,c,f,w.x,w.y)&&g(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=x&&M.x<=v&&M.y>=d&&M.y<=_&&M!==r&&M!==o&&p(h,u,a,l,c,f,M.x,M.y)&&g(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function a(t,n,i){var e=t;do{var s=e.prev,o=e.next.next;!v(s,o)&&_(s,e,e.next,o)&&w(s,o)&&w(o,s)&&(n.push(s.i/i|0),n.push(e.i/i|0),n.push(o.i/i|0),A(e),A(e.next),e=t=o),e=e.next}while(e!==t);return r(e)}function c(t,n,i,e,o,h){var a=t;do{for(var c=a.next.next;c!==a.prev;){if(a.i!==c.i&&d(a,c)){var u=M(a,c);return a=r(a,a.next),u=r(u,u.next),s(a,n,i,e,o,h,0),void s(u,n,i,e,o,h,0)}c=c.next}a=a.next}while(a!==t)}function u(t,n){return t.x-n.x}function l(t,n){var i=function(t,n){var i,e=n,r=t.x,s=t.y,o=-1/0;do{if(s<=e.y&&s>=e.next.y&&e.next.y!==e.y){var h=e.x+(s-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(h<=r&&h>o&&(o=h,i=e.x<e.next.x?e:e.next,h===r))return i}e=e.next}while(e!==n);if(!i)return null;var a,c=i,u=i.x,l=i.y,y=1/0;e=i;do{r>=e.x&&e.x>=u&&r!==e.x&&p(s<l?r:o,s,u,l,s<l?o:r,s,e.x,e.y)&&(a=Math.abs(s-e.y)/(r-e.x),w(e,t)&&(a<y||a===y&&(e.x>i.x||e.x===i.x&&f(i,e)))&&(i=e,y=a)),e=e.next}while(e!==c);return i}(t,n);if(!i)return n;var e=M(i,t);return r(e,e.next),r(i,i.next)}function f(t,n){return g(t.prev,t,n.prev)<0&&g(n.next,t,t.next)<0}function y(t,n,i,e,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-e)*r|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function x(t){var n=t,i=t;do{(n.x<i.x||n.x===i.x&&n.y<i.y)&&(i=n),n=n.next}while(n!==t);return i}function p(t,n,i,e,r,s,o,h){return(r-o)*(n-h)>=(t-o)*(s-h)&&(t-o)*(e-h)>=(i-o)*(n-h)&&(i-o)*(s-h)>=(r-o)*(e-h)}function d(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var i=t;do{if(i.i!==t.i&&i.next.i!==t.i&&i.i!==n.i&&i.next.i!==n.i&&_(i,i.next,t,n))return!0;i=i.next}while(i!==t);return!1}(t,n)&&(w(t,n)&&w(n,t)&&function(t,n){var i=t,e=!1,r=(t.x+n.x)/2,s=(t.y+n.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&r<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(e=!e),i=i.next}while(i!==t);return e}(t,n)&&(g(t.prev,t,n.prev)||g(t,n.prev,n))||v(t,n)&&g(t.prev,t,t.next)>0&&g(n.prev,n,n.next)>0)}function g(t,n,i){return(n.y-t.y)*(i.x-n.x)-(n.x-t.x)*(i.y-n.y)}function v(t,n){return t.x===n.x&&t.y===n.y}function _(t,n,i,e){var r=m(g(t,n,i)),s=m(g(t,n,e)),o=m(g(i,e,t)),h=m(g(i,e,n));return r!==s&&o!==h||(!(0!==r||!z(t,i,n))||(!(0!==s||!z(t,e,n))||(!(0!==o||!z(i,t,e))||!(0!==h||!z(i,n,e)))))}function z(t,n,i){return n.x<=Math.max(t.x,i.x)&&n.x>=Math.min(t.x,i.x)&&n.y<=Math.max(t.y,i.y)&&n.y>=Math.min(t.y,i.y)}function m(t){return t>0?1:t<0?-1:0}function w(t,n){return g(t.prev,t,t.next)<0?g(t,n,t.next)>=0&&g(t,t.prev,n)>=0:g(t,n,t.prev)<0||g(t,t.next,n)<0}function M(t,n){var i=new P(t.i,t.x,t.y),e=new P(n.i,n.x,n.y),r=t.next,s=n.prev;return t.next=n,n.prev=t,i.next=r,r.prev=i,e.next=i,i.prev=e,s.next=e,e.prev=s,e}function b(t,n,i,e){var r=new P(t,n,i);return e?(r.next=e.next,r.prev=e,e.next.prev=r,e.next=r):(r.prev=r,r.next=r),r}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 P(t,n,i){this.i=t,this.x=n,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(t,n,i,e){for(var r=0,s=n,o=i-e;s<i;s+=e)r+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return r}n.exports=i,n.exports.default=i,i.deviation=function(t,n,i,e){var r=n&&n.length,s=r?n[0]*i:t.length,o=Math.abs(S(t,0,s,i));if(r)for(var h=0,a=n.length;h<a;h++){var c=n[h]*i,u=h<a-1?n[h+1]*i:t.length;o-=Math.abs(S(t,c,u,i))}var l=0;for(h=0;h<e.length;h+=3){var f=e[h]*i,y=e[h+1]*i,x=e[h+2]*i;l+=Math.abs((t[f]-t[x])*(t[y+1]-t[f+1])-(t[f]-t[y])*(t[x+1]-t[f+1]))}return 0===o&&0===l?0:Math.abs((l-o)/o)},i.flatten=function(t){for(var n=t[0][0].length,i={vertices:[],holes:[],dimensions:n},e=0,r=0;r<t.length;r++){for(var s=0;s<t[r].length;s++)for(var o=0;o<n;o++)i.vertices.push(t[r][s][o]);r>0&&(e+=t[r-1].length,i.holes.push(e))}return i};var C=n.exports;function k(t,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(t,e.key,e)}}function F(t,n){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},F(t,n)}var V=new(function(){function t(t,n,i,e){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===e&&(e=1),this.isQuaternion=!0,this._x=t,this._y=n,this._z=i,this._w=e}t.slerpFlat=function(t,n,i,e,r,s,o){var h=i[e+0],a=i[e+1],c=i[e+2],u=i[e+3],l=r[s+0],f=r[s+1],y=r[s+2],x=r[s+3];if(0===o)return t[n+0]=h,t[n+1]=a,t[n+2]=c,void(t[n+3]=u);if(1===o)return t[n+0]=l,t[n+1]=f,t[n+2]=y,void(t[n+3]=x);if(u!==x||h!==l||a!==f||c!==y){var p=1-o,d=h*l+a*f+c*y+u*x,g=d>=0?1:-1,v=1-d*d;if(v>Number.EPSILON){var _=Math.sqrt(v),z=Math.atan2(_,d*g);p=Math.sin(p*z)/_,o=Math.sin(o*z)/_}var m=o*g;if(h=h*p+l*m,a=a*p+f*m,c=c*p+y*m,u=u*p+x*m,p===1-o){var w=1/Math.sqrt(h*h+a*a+c*c+u*u);h*=w,a*=w,c*=w,u*=w}}t[n]=h,t[n+1]=a,t[n+2]=c,t[n+3]=u},t.multiplyQuaternionsFlat=function(t,n,i,e,r,s){var o=i[e],h=i[e+1],a=i[e+2],c=i[e+3],u=r[s],l=r[s+1],f=r[s+2],y=r[s+3];return t[n]=o*y+c*u+h*f-a*l,t[n+1]=h*y+c*l+a*u-o*f,t[n+2]=a*y+c*f+o*l-h*u,t[n+3]=c*y-o*u-h*l-a*f,t};var n,i,e,r=t.prototype;return r.set=function(t,n,i,e){return this._x=t,this._y=n,this._z=i,this._w=e,this._onChangeCallback(),this},r.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)},r.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},r.setFromEuler=function(t,n){void 0===n&&(n=!0);var i=t._x,e=t._y,r=t._z,s=t._order,o=Math.cos,h=Math.sin,a=o(i/2),c=o(e/2),u=o(r/2),l=h(i/2),f=h(e/2),y=h(r/2);switch(s){case"XYZ":this._x=l*c*u+a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u-l*f*y;break;case"YXZ":this._x=l*c*u+a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u+l*f*y;break;case"ZXY":this._x=l*c*u-a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u-l*f*y;break;case"ZYX":this._x=l*c*u-a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u+l*f*y;break;case"YZX":this._x=l*c*u+a*f*y,this._y=a*f*u+l*c*y,this._z=a*c*y-l*f*u,this._w=a*c*u-l*f*y;break;case"XZY":this._x=l*c*u-a*f*y,this._y=a*f*u-l*c*y,this._z=a*c*y+l*f*u,this._w=a*c*u+l*f*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===n&&this._onChangeCallback(),this},r.setFromAxisAngle=function(t,n){var i=n/2,e=Math.sin(i);return this._x=t.x*e,this._y=t.y*e,this._z=t.z*e,this._w=Math.cos(i),this._onChangeCallback(),this},r.setFromRotationMatrix=function(t){var n=t.elements,i=n[0],e=n[4],r=n[8],s=n[1],o=n[5],h=n[9],a=n[2],c=n[6],u=n[10],l=i+o+u;if(l>0){var f=.5/Math.sqrt(l+1);this._w=.25/f,this._x=(c-h)*f,this._y=(r-a)*f,this._z=(s-e)*f}else if(i>o&&i>u){var y=2*Math.sqrt(1+i-o-u);this._w=(c-h)/y,this._x=.25*y,this._y=(e+s)/y,this._z=(r+a)/y}else if(o>u){var x=2*Math.sqrt(1+o-i-u);this._w=(r-a)/x,this._x=(e+s)/x,this._y=.25*x,this._z=(h+c)/x}else{var p=2*Math.sqrt(1+u-i-o);this._w=(s-e)/p,this._x=(r+a)/p,this._y=(h+c)/p,this._z=.25*p}return this._onChangeCallback(),this},r.setFromUnitVectors=function(t,n){var i=t.dot(n)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*n.z-t.z*n.y,this._y=t.z*n.x-t.x*n.z,this._z=t.x*n.y-t.y*n.x,this._w=i),this.normalize()},r.rotateTowards=function(t,n){var i=this.angleTo(t);if(0===i)return this;var e=Math.min(1,n/i);return this.slerp(t,e),this},r.identity=function(){return this.set(0,0,0,1)},r.invert=function(){return this.conjugate()},r.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},r.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},r.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},r.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},r.normalize=function(){var t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this},r.multiply=function(t){return this.multiplyQuaternions(this,t)},r.premultiply=function(t){return this.multiplyQuaternions(t,this)},r.multiplyQuaternions=function(t,n){var i=t._x,e=t._y,r=t._z,s=t._w,o=n._x,h=n._y,a=n._z,c=n._w;return this._x=i*c+s*o+e*a-r*h,this._y=e*c+s*h+r*o-i*a,this._z=r*c+s*a+i*h-e*o,this._w=s*c-i*o-e*h-r*a,this._onChangeCallback(),this},r.slerp=function(t,n){if(0===n)return this;if(1===n)return this.copy(t);var i=this._x,e=this._y,r=this._z,s=this._w,o=s*t._w+i*t._x+e*t._y+r*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=s,this._x=i,this._y=e,this._z=r,this;var h=1-o*o;if(h<=Number.EPSILON){var a=1-n;return this._w=a*s+n*this._w,this._x=a*i+n*this._x,this._y=a*e+n*this._y,this._z=a*r+n*this._z,this.normalize(),this}var c=Math.sqrt(h),u=Math.atan2(c,o),l=Math.sin((1-n)*u)/c,f=Math.sin(n*u)/c;return this._w=s*l+this._w*f,this._x=i*l+this._x*f,this._y=e*l+this._y*f,this._z=r*l+this._z*f,this._onChangeCallback(),this},r.slerpQuaternions=function(t,n,i){return this.copy(t).slerp(n,i)},r.random=function(){var t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),e=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(e*Math.sin(t),e*Math.cos(t),r*Math.sin(n),r*Math.cos(n))},r.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},r.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._w=t[n+3],this._onChangeCallback(),this},r.toArray=function(t,n){return void 0===t&&(t=[]),void 0===n&&(n=0),t[n]=this._x,t[n+1]=this._y,t[n+2]=this._z,t[n+3]=this._w,t},r.fromBufferAttribute=function(t,n){return this._x=t.getX(n),this._y=t.getY(n),this._z=t.getZ(n),this._w=t.getW(n),this._onChangeCallback(),this},r.toJSON=function(){return this.toArray()},r._onChange=function(t){return this._onChangeCallback=t,this},r._onChangeCallback=function(){},n=t,(i=[{key:"x",get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()}},{key:"y",get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()}},{key:"z",get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()}},{key:"w",get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()}}])&&k(n.prototype,i),e&&k(n,e),Object.defineProperty(n,"prototype",{writable:!1}),t}()),Z=function(){function t(t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=t,this.y=n,this.z=i}var n=t.prototype;return n.set=function(t,n,i){return void 0===i&&(i=this.z),this.x=t,this.y=n,this.z=i,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.applyAxisAngle=function(t,n){return this.applyQuaternion(V.setFromAxisAngle(t,n))},n.applyMatrix4=function(t){var n=this.x,i=this.y,e=this.z,r=t.elements,s=1/(r[3]*n+r[7]*i+r[11]*e+r[15]);return this.x=(r[0]*n+r[4]*i+r[8]*e+r[12])*s,this.y=(r[1]*n+r[5]*i+r[9]*e+r[13])*s,this.z=(r[2]*n+r[6]*i+r[10]*e+r[14])*s,this},n.applyQuaternion=function(t){var n=this.x,i=this.y,e=this.z,r=t.x,s=t.y,o=t.z,h=t.w,a=h*n+s*e-o*i,c=h*i+o*n-r*e,u=h*e+r*i-s*n,l=-r*n-s*i-o*e;return this.x=a*h+l*-r+c*-o-u*-s,this.y=c*h+l*-s+u*-r-a*-o,this.z=u*h+l*-o+a*-s-c*-r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(n,i)))},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,i){return this.x=t.x+(n.x-t.x)*i,this.y=t.y+(n.y-t.y)*i,this.z=t.z+(n.z-t.z)*i,this},n.cross=function(t){return this.crossVectors(this,t)},n.crossVectors=function(t,n){var i=t.x,e=t.y,r=t.z,s=n.x,o=n.y,h=n.z;return this.x=e*h-r*o,this.y=r*s-i*h,this.z=i*o-e*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}();function L(t,n){let i=t.length-1;for(let e=0,r=n.length;e<r;e++)t[++i]=n[e]}function O(t){let n,i,e=0,r=1;const s=t.length;for(;r<s;)n=i||t[0],i=t[r],e+=(i[0]-n[0])*(i[1]+n[1]),r++;return e>0}function q(t){U(t)||t.push(t[0])}function U(t){const n=t.length,[i,e]=t[0],[r,s]=t[n-1];return i===r&&e===s}function I(t){let n=0,i=0;const e=t.length;for(;i<e;)n+=t[i].length,i++;return n}function j(t,n){n=n||[1/0,1/0,-1/0,-1/0];for(let i=0,e=t.length;i<e;i++){const e=t[i];if(Array.isArray(e[0][0]))j(e,n);else for(let t=0,i=e.length;t<i;t++){const i=e[t],[r,s]=i;n[0]=Math.min(n[0],r),n[1]=Math.min(n[1],s),n[2]=Math.max(n[2],r),n[3]=Math.max(n[3],s)}}return n}function E(t,n){for(let i=0,e=t.length;i<e;i++){const e=t[i];q(e),0===i?O(e)||(t[i]=e.reverse()):O(e)&&(t[i]=e.reverse()),n&&U(e)&&e.splice(e.length-1,1)}}function N(t,n,i){return t[0]=n[0]-i[0],t[1]=n[1]-i[1],t[2]=n[2]-i[2],t}function R(t,n){const i=n[0],e=n[1],r=n[2],s=Math.sqrt(i*i+e*e+r*r)||1;return t[0]=i/s,t[1]=e/s,t[2]=r/s,t}function T(t,n,i){const e=n[0],r=n[1],s=n[2],o=i[0],h=i[1],a=i[2];return t[0]=r*a-s*h,t[1]=s*o-e*a,t[2]=e*h-r*o,t}function Q(t,n){function i(t,n,i,e){t[0]=n,t[1]=i,t[2]=e}const e=[],r=[],s=[],o=[],h=[],a=[],c=t.length,u=new Float32Array(n.length);let l=0;for(;l<c;){const c=3*t[l],f=3*t[l+1],y=3*t[l+2];i(e,n[c],n[c+1],n[c+2]),i(r,n[f],n[f+1],n[f+2]),i(s,n[y],n[y+1],n[y+2]),N(h,s,r),N(o,e,r),T(a,h,o);for(let t=0;t<3;t++)u[c+t]+=a[t],u[f+t]+=a[t],u[y+t]+=a[t];l+=3}let f=0;const y=u.length;for(;f<y;)i(a,u[f],u[f+1],u[f+2]),R(a,a),u[f]=a[0]||0,u[f+1]=a[1]||0,u[f+2]=a[2]||0,f+=3;return u}function W(t){if(1===t.length){return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t}}let n=0,i=0;for(let e=0,r=t.length;e<r;e++){const{position:r,indices:s}=t[e];n+=r.length,i+=s.length}const e={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(i),results:t};let r=0,s=0,o=0,h=0;for(let n=0,i=t.length;n<i;n++){const{position:i,indices:a,normal:c,uv:u}=t[n];e.position.set(i,r),e.normal.set(c,r),e.uv.set(u,h);let l=0;const f=a.length;for(;l<f;){const t=a[l]+s;e.indices[o]=t,o++,l++}h+=u.length,r+=i.length,s+=i.length/3}return e}function X(t){return 180*t/Math.PI}function B(t){return t/180*Math.PI}function Y(t,n,i,e,r,s){const o=3*i,h=3*e,a=3*r,c=3*s,u=n[o],l=n[o+1],f=n[o+2],y=n[h],x=n[h+1],p=n[h+2],d=n[a],g=n[a+1],v=n[a+2],_=n[c],z=n[c+1],m=n[c+2];let w=t.length-1;Math.abs(l-x)<Math.abs(u-y)?(t[++w]=u,t[++w]=1-f,t[++w]=y,t[++w]=1-p,t[++w]=d,t[++w]=1-v,t[++w]=_,t[++w]=1-m):(t[++w]=l,t[++w]=1-f,t[++w]=x,t[++w]=1-p,t[++w]=g,t[++w]=1-v,t[++w]=z,t[++w]=1-m)}function D(t){const n=[];for(let i=0,e=t.length;i<e;i++){const e=t[i],[r,s,o]=e,h=new Z(r,s,o||0);n[i]=h}return n}function G(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function H(t,n){const i=n.bottomStickGround,e=n.depth,r=t.depths;let s=e,o=e;r&&(s=r[0],o=r[1]);const{leftPoints:h,rightPoints:a}=t,c=t.line,u=n.pathUV;let l=c;if(h.length>l.length&&(l=h),u){!function(t){let n=0;for(let i=0,e=t.length;i<e;i++){const e=t[i],r=t[i+1];if(0===i&&(e.distance=0),e&&r){const[t,i,s]=e,[o,h,a]=r,c=t-o,u=i-h,l=(s||0)-(a||0);n+=Math.sqrt(c*c+u*u+l*l),r.distance=n}}}(l);for(let t=0,n=l.length;t<n;t++)h[t].distance=a[t].distance=l[t].distance}let f=0,y=h.length;const x=[],p=[],d=[];for(;f<y;){const t=3*f,[n,e,r]=h[f];x[t]=n,x[t+1]=e,x[t+2]=s+r;const[c,p,g]=a[f],v=3*y+t;x[v]=c,x[v+1]=p,x[v+2]=o+g;const _=2*y*3+t;x[_]=n,x[_+1]=e,x[_+2]=r,i&&(x[_+2]=0);const z=2*y*3+3*y+t;if(x[z]=c,x[z+1]=p,x[z+2]=g,i&&(x[z+2]=0),u){let t=l[f].distance;const n=2*f;d[n]=t,d[n+1]=1;const i=2*y+n;d[i]=t,d[i+1]=0;const e=2*y*2+n;d[e]=t,d[e+1]=1;const r=2*y*2+2*y+n;d[r]=t,d[r+1]=0}f++}if(!u){f=0,y=x.length;let t=d.length-1;for(;f<y;){const n=x[f],i=x[f+1];d[++t]=n,d[++t]=i,f+=3}}f=0,y=h.length;let g=p.length-1;for(;f<y-1;){const t=f,n=f+1,i=t+y,e=n+y;p[++g]=t,p[++g]=i,p[++g]=n,p[++g]=i,p[++g]=e,p[++g]=n;const r=f+2*y,s=r+1,o=r+y,h=s+y;p[++g]=r,p[++g]=o,p[++g]=s,p[++g]=o,p[++g]=h,p[++g]=s,f++}if(t.indices=p,t.points=x,t.uv=d,r)for(y=h.length,f=0;f<y;)h[f].depth=s,a[f].depth=o,f++}function J(t,n){const{points:i,indices:e,leftPoints:r,rightPoints:s,uv:o}=t,h=n.depth,a=n.bottomStickGround,c=[r,s],u=t.depths,l=n.pathUV,f=n.lineWidth;let y=i.length-1,x=e.length-1,p=o.length-1;function d(t,n){const r=i.length/3,s=u?t.depth:h,c=u?n.depth:h;i[++y]=t[0],i[++y]=t[1],i[++y]=s+t[2],i[++y]=n[0],i[++y]=n[1],i[++y]=c+n[2],i[++y]=t[0],i[++y]=t[1],i[++y]=a?0:t[2],i[++y]=n[0],i[++y]=n[1],i[++y]=a?0:n[2];const d=r+2,g=r+3,v=r,_=r+1;e[++x]=d,e[++x]=v,e[++x]=g,e[++x]=v,e[++x]=_,e[++x]=g,l?(o[++p]=t.distance,o[++p]=s/f,o[++p]=n.distance,o[++p]=c/f,o[++p]=t.distance,o[++p]=0,o[++p]=n.distance,o[++p]=0):Y(o,i,d,g,v,_)}for(let t=0,n=c.length;t<n;t++){let n=c[t];t>0&&(n=n.map((t=>t)),n=n.reverse());let i=0;const e=n.length-1;for(;i<e;){d(n[i],n[i+1]),i++}}const g=r.length,v=[s[0],r[0],r[g-1],s[g-1]];for(let t=0;t<v.length;t+=2){d(v[t],v[t+1])}}const K={x:0,y:0},$={x:0,y:0};function tt(t,n){let i=(n=Object.assign({},{lineWidth:1,cutCorner:!1},n)).lineWidth/2;n.isSlope&&(i*=2);const{cutCorner:e}=n,r=[],s=[],o=[],h=t.length,a=()=>{const t=s.length;if(t){s.push(s[t-1]),o.push(o[t-1]);const n=r.length;r.push(r[n-2],r[n-1])}},c=(t,n)=>t[0]===n[0]&&t[1]===n[1];let u,l,f=0;for(;f<h;){let n,y=t[f],x=t[f+1];const p=y;if(f===h-1){if(y=t[h-2],x=t[h-1],c(y,x))for(let n=t.indexOf(y);n>=0;n--){const i=t[n];if(!c(i,p)){y=i;break}}}else if(c(y,x))for(let n=t.indexOf(x);n<h;n++){const i=t[n];if(!c(i,p)){x=i;break}}if(c(y,x)){a(),f++;continue}let d=x[1]-y[1],g=x[0]-y[0],v=0;const _=X(Math.atan2(d,g));if(0===f||f===h-1)v=_,v-=90;else{if(n=t[f-1],c(n,x)||c(n,y))for(let i=t.indexOf(x);i>=0;i--){const e=t[i];if(!c(e,x)&&!c(e,y)){n=e;break}}if(c(n,x)||c(n,y)||c(y,x)){a(),f++;continue}const i=y[1]-n[1],e=y[0]-n[0],r=X(Math.atan2(i,e));if(Math.abs(r-_)-180<=1e-4)v=_,v-=90;else{K.x=n[0]-y[0],K.y=n[1]-y[1],$.x=x[0]-y[0],$.y=x[1]-y[1],(0===K.x&&0===K.y||0===$.x&&0===$.y)&&console.error("has repeat vertex,the index:",f);v=_-nt(K,$)/2}}const z=B(v),m=p,w=[Math.cos(z)+m[0],Math.sin(z)+m[1]],[M,b]=rt(y,x,i);let A=st(M[0],M[1],m,w),P=st(b[0],b[1],m,w);if(!A||!P){const t=r.length,n=r[t-2],i=r[t-1];if(!n||!i){f++;continue}A=[n[0],n[1]],P=[i[0],i[1]]}A[2]=p[2]||0,P[2]=p[2]||0,r.push(A,P);let S=!1;if(e){const t=2*i;(it(p,A)>t||it(p,P)>t)&&(S=!0)}if(S&&n&&u&&l){let t=A;it(A,n)<it(P,n)&&(t=P);const e=t[1]-p[1],r=t[0]-p[0],h=Math.atan2(e,r)/Math.PI*180,a=B(h),c=Math.cos(a)*i+p[0],f=Math.sin(a)*i+p[1],d=[c,f],g=B(h+90),v=[Math.cos(g)+c,Math.sin(g)+f];let _=u,z=M,m=s,w=o;et(t,y,x)||(_=l,z=b,m=o,w=s);let S=st(_[0],_[1],d,v),C=st(z[0],z[1],d,v);S[2]=p[2]||0,C[2]=p[2]||0;const k=t===A?P:A;m.push(S,C),w.push(k,[...k])}else et(A,y,x)?(s.push(A),o.push(P)):(s.push(P),o.push(A));u=M,l=b,f++}return{offsetPoints:r,leftPoints:s,rightPoints:o,line:t}}const nt=({x:t,y:n},{x:i,y:e})=>{const r=t*i+n*e,s=t*e-n*i;return Math.atan2(s,r)/Math.PI*180};function it(t,n){const i=n[0]-t[0],e=n[1]-t[1];return Math.sqrt(i*i+e*e)}function et(t,n,i){const[e,r]=n,[s,o]=i,[h,a]=t;return(r-o)*h+(s-e)*a+e*o-s*r>0}function rt(t,n,i){const e=n[1]-t[1],r=n[0]-t[0];if(0===e&&0===r)return null;const s=Math.atan2(e,r),o=s+Math.PI/2;let h=Math.cos(o)*i,a=Math.sin(o)*i;const c=[t[0]+h,t[1]+a],u=[n[0]+h,n[1]+a],l=s-Math.PI/2;h=Math.cos(l)*i,a=Math.sin(l)*i;return[[c,u],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function st(t,n,i,e){const r=n[0]-t[0],s=n[1]-t[1],o=e[0]-i[0],h=e[1]-i[1];if(0===r&&0===o)return null;if(0===s&&0===h)return null;const a=s/r,c=h/o,u=t[1]-a*t[0],l=i[1]-c*i[0];let f,y;return 0===r?(f=t[0],y=c*f+l):0===o?(f=i[0],y=a*f+u):0===s?(y=t[1],f=(y-l)/c):0===h?(y=i[1],f=(y-u)/a):(f=(l-u)/(a-c),y=a*f+u),[f,y]}var ot=function(){function t(){this.pos=new Z,this.dir=new Z,this.right=new Z,this.up=new Z,this.dist=0,this.widthScale=1,this.sharp=!1}var n=t.prototype;return n.lerpPathPoints=function(t,n,i){this.pos.lerpVectors(t.pos,n.pos,i),this.dir.lerpVectors(t.dir,n.dir,i),this.up.lerpVectors(t.up,n.up,i),this.right.lerpVectors(t.right,n.right,i),this.dist=(n.dist-t.dist)*i+t.dist,this.widthScale=(n.widthScale-t.widthScale)*i+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}(),ht=function(){function t(t,n,i,e,r,s,o,h,a,c,u,l,f,y,x,p){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,i,e,r,s,o,h,a,c,u,l,f,y,x,p)}var n=t.prototype;return n.set=function(t,n,i,e,r,s,o,h,a,c,u,l,f,y,x,p){var d=this.elements;return d[0]=t,d[4]=n,d[8]=i,d[12]=e,d[1]=r,d[5]=s,d[9]=o,d[13]=h,d[2]=a,d[6]=c,d[10]=u,d[14]=l,d[3]=f,d[7]=y,d[11]=x,d[15]=p,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var i=Math.cos(n),e=Math.sin(n),r=1-i,s=t.x,o=t.y,h=t.z,a=r*s,c=r*o;return this.set(a*s+i,a*o-e*h,a*h+e*o,0,a*o+e*h,c*o+i,c*h-e*s,0,a*h-e*o,c*h+e*s,r*h*h+i,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,i=t.elements,e=0;e<16;e++)if(n[e]!==i[e])return!1;return!0},t}(),at=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 i=this.getUtoTmapping(t);return this.getPoint(i,n)},n.getPoints=function(t){void 0===t&&(t=5);for(var n=[],i=0;i<=t;i++)n.push(this.getPoint(i/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,i=[],e=this.getPoint(0),r=0;i.push(0);for(var s=1;s<=t;s++)r+=(n=this.getPoint(s/t)).distanceTo(e),i.push(r),e=n;return this.cacheArcLengths=i,i},n.getUtoTmapping=function(t,n){var i,e=this.getLengths(),r=0,s=e.length;i=n||t*e[s-1];for(var o,h=0,a=s-1;h<=a;)if((o=e[r=Math.floor(h+(a-h)/2)]-i)<0)h=r+1;else{if(!(o>0)){a=r;break}a=r-1}if(e[r=a]===i)return r/(s-1);var c=e[r];return(r+(i-c)/(e[r+1]-c))/(s-1)},t}();function ct(t,n,i,e){return function(t,n){var i=1-t;return i*i*n}(t,n)+function(t,n){return 2*(1-t)*t*n}(t,i)+function(t,n){return t*t*n}(t,e)}var ut=function(t){var n,i;function e(n,i,e){var r;return void 0===n&&(n=new Z),void 0===i&&(i=new Z),void 0===e&&(e=new Z),(r=t.call(this)||this).isQuadraticBezierCurve3=!0,r.type="QuadraticBezierCurve3",r.v0=n,r.v1=i,r.v2=e,r}return i=t,(n=e).prototype=Object.create(i.prototype),n.prototype.constructor=n,F(n,i),e.prototype.getPoint=function(t,n){void 0===n&&(n=new Z);var i=n,e=this.v0,r=this.v1,s=this.v2;return i.set(ct(t,e.x,r.x,s.x),ct(t,e.y,r.y,s.y),ct(t,e.z,r.z,s.z)),i},e}(at),lt=new Z,ft=new Z,yt=new Z,xt=new ht,pt=new ut;var dt=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,i,e,r){if(void 0===n&&(n=.1),void 0===i&&(i=10),void 0===e&&(e=null),void 0===r&&(r=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);r&&!t[0].equals(t[t.length-1])&&t.push((new Z).copy(t[0]));for(var s=0,o=t.length;s<o;s++)if(0===s)this._start(t[s],t[s+1],e);else if(s===o-1)if(r){this._corner(t[s],t[1],n,i,e);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,i,e)},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 ot),this.array[t]},n._start=function(t,n,i){this.count=0;var e=this._getByIndex(this.count);if(e.pos.copy(t),e.dir.subVectors(n,t),i)e.up.copy(i);else{var r=Number.MAX_VALUE,s=Math.abs(e.dir.x),o=Math.abs(e.dir.y),h=Math.abs(e.dir.z);s<r&&(r=s,e.up.set(1,0,0)),o<r&&(r=o,e.up.set(0,1,0)),h<r&&e.up.set(0,0,1)}e.right.crossVectors(e.dir,e.up).normalize(),e.up.crossVectors(e.right,e.dir).normalize(),e.dist=0,e.widthScale=1,e.sharp=!1,e.dir.normalize(),this.count++},n._end=function(t){var n=this.array[this.count-1],i=this._getByIndex(this.count);i.pos.copy(t),i.dir.subVectors(t,n.pos);var e=i.dir.length();i.dir.normalize(),i.up.copy(n.up);var r=lt.crossVectors(n.dir,i.dir);if(r.length()>Number.EPSILON){r.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(i.dir),-1),1));i.up.applyMatrix4(xt.makeRotationAxis(r,s))}i.right.crossVectors(i.dir,i.up).normalize(),i.dist=n.dist+e,i.widthScale=1,i.sharp=!1,this.count++},n._corner=function(t,n,i,e,r){if(i>0&&e>0){for(var s=function(t,n,i,e,r,s){var o=lt.subVectors(n,t),h=ft.subVectors(i,n),a=o.length(),c=h.length();o.normalize(),h.normalize();var u=Math.min(.999999*(r?a/2:a),e);s.v0.copy(n).sub(o.multiplyScalar(u)),s.v1.copy(n);var l=Math.min(c/2*.999999,e);return s.v2.copy(n).add(h.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,i,this.count-1==0,pt),o=s.getPoints(e),h=0;h<e;h++)this._sharpCorner(o[h],o[h+1],r,0===h?1:0);o[e].equals(n)||this._sharpCorner(o[e],n,r,2)}else this._sharpCorner(t,n,r,0,!0)},n._sharpCorner=function(t,n,i,e,r){void 0===e&&(e=0),void 0===r&&(r=!1);var s=this.array[this.count-1],o=this._getByIndex(this.count),h=lt.subVectors(t,s.pos),a=ft.subVectors(n,t),c=h.length();if(h.normalize(),a.normalize(),o.pos.copy(t),1===e?o.dir.copy(h):2===e?o.dir.copy(a):(o.dir.addVectors(h,a),o.dir.normalize()),i)1===o.dir.dot(i)?o.right.crossVectors(a,i).normalize():o.right.crossVectors(o.dir,i).normalize(),o.up.crossVectors(o.right,o.dir).normalize();else{o.up.copy(s.up);var u=yt.crossVectors(s.dir,o.dir);if(u.length()>Number.EPSILON){u.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(o.dir),-1),1));o.up.applyMatrix4(xt.makeRotationAxis(u,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+c;var f=h.dot(a);o.widthScale=Math.min(1/Math.sqrt((1+f)/2),1.415)||1,o.sharp=Math.abs(f-1)>.05&&r,this.count++},t}();const gt=new Z(0,0,1),vt=new Z,_t=new Z,zt=new Z,mt=new Z,wt=new Z,Mt=new Z;const bt=new Z(0,0,1),At=new Z;const Pt=new Z(0,0,1),St=new Z;function Ct(t,n){const[i,e]=t,[r,s]=n,o=s-e,h=r-i;return Math.atan2(o,h)}const kt=new Z(0,0,0);t.cylinder=function(t,n){const i=Object.assign({},{radius:1,height:2,radialSegments:6},n),e=Math.round(Math.max(4,i.radialSegments));let{radius:r,height:s}=i;const o=360/e/360*Math.PI*2,h=e+1,a=new Float32Array(3*h*2),[c,u]=t;let l=0,f=0;const y=3*h,x=2*h,p=[],d=[];let g=p.length-1;for(let t=-1;t<e;t++){const n=o*t,i=Math.cos(n)*r+c,e=Math.sin(n)*r+u;a[l]=i,a[l+1]=e,a[l+2]=0,a[l+y]=i,a[l+1+y]=e,a[l+2+y]=s;let h=0,v=0;h=.5+i/r/2,v=.5+e/r/2,d[f]=h,d[f+1]=v,d[f+x]=h,d[f+1+x]=v,l+=3,f+=2,t>1&&(p[++g]=0,p[++g]=t-1,p[++g]=t)}l-=3,a[l]=a[0],a[l+1]=a[1],a[l+2]=a[2];const v=a.length;a[v-3]=a[0],a[v-2]=a[1],a[v-1]=s;const _=p.length;g=p.length-1;for(let t=0;t<_;t++){const n=p[t];p[++g]=n+h}const z=new Float32Array(2*(3*h*2-6));let m=-1;l=2*h,f=0,g=p.length-1;let w=d.length-1;for(let t=0,n=a.length/2;t<n-3;t+=3){const n=a[t],i=a[t+1],e=a[t+3],o=a[t+4];z[++m]=n,z[++m]=i,z[++m]=s,z[++m]=e,z[++m]=o,z[++m]=s,z[++m]=n,z[++m]=i,z[++m]=0,z[++m]=e,z[++m]=o,z[++m]=0;const c=l+2,u=l+3,y=l,x=l+1;p[++g]=y,p[++g]=c,p[++g]=x,p[++g]=c,p[++g]=u,p[++g]=x,l+=4;const v=f/h,_=(f+1)/h;d[++w]=v,d[++w]=s/r/2,d[++w]=_,d[++w]=s/r/2,d[++w]=v,d[++w]=0,d[++w]=_,d[++w]=0,f++}const M=new Float32Array(a.length+z.length);M.set(a,0),M.set(z,a.length);const b=Q(p,M);return{points:a,indices:new Uint32Array(p),position:M,normal:b,uv:new Float32Array(d)}},t.expandLine=tt,t.expandPaths=function(t,n){const i=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n),e=t.map((t=>{const n=D(t),e=new dt;e.set(n,i.cornerRadius,i.cornerSplit,gt);const r=function(t,n){const i=n.lineWidth||.1,e=1,r=i/2,s=i,o=t.distance(),h=e*o;let a=0;const c=[],u=[],l=[],f=[];let y=0;if(0===o)return{position:c,normal:u,uv:l,indices:f,count:a};const x=r/s;let p,d=c.length-1,g=u.length-1,v=l.length-1,_=f.length-1;function z(t){const n=0===c.length,i=t.sharp&&!n,e=t.dist/s,o=t.dir,h=t.up,p=t.right;if(vt.copy(p).multiplyScalar(r*t.widthScale),_t.copy(p).multiplyScalar(-r*t.widthScale),vt.add(t.pos),_t.add(t.pos),i){zt.fromArray(c,c.length-6).sub(_t),mt.fromArray(c,c.length-3).sub(vt);const t=zt.length()-mt.length();let n,i;t>0?(n=zt,i=_t):(n=mt,i=vt),wt.copy(n).setLength(Math.abs(t)).add(i);let r=Mt.copy(i).sub(wt).normalize().dot(o)*Mt.copy(i).sub(wt).length()*2;Mt.copy(o).setLength(r).add(wt),t>0?(c[++d]=wt.x,c[++d]=wt.y,c[++d]=wt.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=Mt.x,c[++d]=Mt.y,c[++d]=Mt.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,y+=6,f[++_]=y-6,f[++_]=y-8,f[++_]=y-7,f[++_]=y-6,f[++_]=y-7,f[++_]=y-5,f[++_]=y-4,f[++_]=y-6,f[++_]=y-5,f[++_]=y-2,f[++_]=y-4,f[++_]=y-1,a+=12):(c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=wt.x,c[++d]=wt.y,c[++d]=wt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=Mt.x,c[++d]=Mt.y,c[++d]=Mt.z,y+=6,f[++_]=y-6,f[++_]=y-8,f[++_]=y-7,f[++_]=y-6,f[++_]=y-7,f[++_]=y-5,f[++_]=y-6,f[++_]=y-5,f[++_]=y-3,f[++_]=y-2,f[++_]=y-3,f[++_]=y-1,a+=12);for(let t=0;t<6;t++)u[++g]=h.x,u[++g]=h.y,u[++g]=h.z;l[++v]=e-x,l[++v]=0,l[++v]=e-x,l[++v]=1,l[++v]=e,l[++v]=0,l[++v]=e,l[++v]=1,l[++v]=e+x,l[++v]=0,l[++v]=e+x,l[++v]=1}else c[++d]=_t.x,c[++d]=_t.y,c[++d]=_t.z,c[++d]=vt.x,c[++d]=vt.y,c[++d]=vt.z,u[++g]=h.x,u[++g]=h.y,u[++g]=h.z,u[++g]=h.x,u[++g]=h.y,u[++g]=h.z,l[++v]=e,l[++v]=0,l[++v]=e,l[++v]=1,y+=2,n||(f[++_]=y-2,f[++_]=y-4,f[++_]=y-3,f[++_]=y-2,f[++_]=y-3,f[++_]=y-1,a+=6)}if(h>0)for(let n=0;n<t.count;n++){const i=t.array[n];if(i.dist>h){const e=t.array[n-1];p=new ot;const r=(h-e.dist)/(i.dist-e.dist);p.lerpPathPoints(e,i,r),z(p);break}z(i)}else p=t.array[0];return{position:c,normal:u,uv:l,indices:f,count:a}}(e,i);return{position:new Float32Array(r.position),indices:new Uint32Array(r.indices),uv:new Float32Array(r.uv),normal:new Float32Array(r.normal),line:t,count:r.count}})),r=W(e);return r.lines=t,r},t.expandTubes=function(t,n){const i=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n),e=t.map((t=>{const n=D(t),e=new dt;e.set(n,0,i.cornerSplit,bt);const r=function(t,n){const i=Math.max(n.radius||1,1e-8),e=void 0!==n.progress?n.progress:1,r=Math.max(3,n.radialSegments||8),s=n.startRad||0,o=2*i*Math.PI,h=t.distance(),a=e*h;if(0===a)return null;let c=0;const u=[],l=[],f=[],y=[];let x=0,p=-1,d=-1,g=-1,v=-1;function _(t,n,i){const e=0===u.length,r=t.dist/o;for(let e=0;e<=i;e++){let o=e;o===i&&(o=0),At.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();const h=n*t.widthScale;u[++p]=t.pos.x+At.x*h,u[++p]=t.pos.y+At.y*h,u[++p]=t.pos.z+At.z*h,l[++d]=At.x,l[++d]=At.y,l[++d]=At.z,f[++g]=r,f[++g]=e/i,x++}if(!e){const t=x-2*(i+1),n=x-(i+1);for(let e=0;e<i;e++)y[++v]=n+e,y[++v]=t+e,y[++v]=t+e+1,y[++v]=n+e,y[++v]=t+e+1,y[++v]=n+e+1,c+=6}}if(a>0)for(let n=0;n<t.count;n++){const e=t.array[n];if(e.dist>a){const s=t.array[n-1],o=new ot,h=(a-s.dist)/(e.dist-s.dist);o.lerpPathPoints(s,e,h),_(o,i,r);break}_(e,i,r)}return{points:u,normal:l,uv:f,indices:y,count:c}}(e,i);return r.line=t,r.position=new Float32Array(r.points),r.indices=new Uint32Array(r.indices),r.uv=new Float32Array(r.uv),r.normal=new Float32Array(r.normal),r})),r=W(e);return r.lines=t,r},t.extrudePolygons=function(t,n){const i=Object.assign({},{depth:2,top:!0},n),e=t.map((t=>{E(t,!0);const n=function(t,n){const i=I(t),e=t.length,r=[],s=new Float32Array(2*i),o=[],h=[],a=3*i,c=2*i,u=n.depth;let l=0,f=0,y=0;for(let n=0;n<e;n++){const i=t[n];n>0&&r.push(l/2);let e=0;const x=i.length;for(;e<x;){const t=i[e],n=t[0],r=t[1],x=t[2]||0;s[l++]=n,s[l++]=r,o[f]=n,o[f+1]=r,o[f+2]=u+x,o[a+f]=n,o[a+f+1]=r,o[a+f+2]=x,h[y]=n,h[y+1]=r,h[c+y]=n,h[c+y+1]=r,f+=3,y+=2,e++}}return{flatVertices:s,holes:r,points:o,count:i,uv:h}}(t,i);n.polygon=t;return function(t,n,i){const e=[],{count:r}=t,s=i.top;for(let t=0,i=n.length;t<i;t+=3){const o=n[t],h=n[t+1],a=n[t+2];s&&(e[t]=o,e[t+1]=h,e[t+2]=a);let c=i+t;const u=r+o,l=r+h,f=r+a;s||(c=t),e[c]=u,e[c+1]=l,e[c+2]=f}t.indices=e}(n,C(n.flatVertices,n.holes,2),i),function(t,n){const{points:i,indices:e,polygon:r,uv:s}=t,o=n.depth;let h=i.length-1,a=e.length-1;for(let t=0,n=r.length;t<n;t++){const n=r[t];let c=0;const u=n.length;for(;c<u;){const t=n[c];let r=n[c+1];c===u-1&&(r=n[0]);const l=i.length/3,f=t[0],y=t[1],x=t[2]||0,p=r[0],d=r[1],g=r[2]||0;i[++h]=f,i[++h]=y,i[++h]=x+o,i[++h]=p,i[++h]=d,i[++h]=g+o,i[++h]=f,i[++h]=y,i[++h]=x,i[++h]=p,i[++h]=d,i[++h]=g;const v=l+2,_=l+3,z=l,m=l+1;e[++a]=v,e[++a]=z,e[++a]=_,e[++a]=z,e[++a]=m,e[++a]=_,Y(s,i,v,_,z,m),c++}}}(n,i),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=Q(n.indices,n.position),n})),r=W(e);return r.polygons=t,r},t.extrudePolygonsOnPath=function(t,n){const i=Object.assign({},{openEnd:!1,openEndUV:!0,polygonRotation:0},n),{extrudePath:e,openEnd:r}=i;if(!e||!Array.isArray(e)||e.length<2)return console.error("extrudePath is error:",e),null;const s=j(t),[o,h,a,c]=s,u=[(o+a)/2,(h+c)/2];i.center=u,i.bbox=s;const l=D(e),f=new dt;f.set(l,0,i.cornerSplit,Pt);const y=t.map((t=>{E(t,!1);const n=function(t,n,i){const e=function(t,n){const{center:i,polygonRotation:e}=n,[r,s]=i,o=[];return t.forEach(((t,n)=>{const h=[];let a,c=0;for(let n=0,o=t.length;n<o;n++){const o=t[n],u=o[0],l=o[1],f=u-r,y=l-s;let x=0;if(n>0){const t=a[0]-u,n=a[1]-l;x=Math.sqrt(t*t+n*n)+c,c=x}h[n]={distance:x,radius:Math.sqrt(f*f+y*y),angle:-Ct(i,o)+e},a=o}o[n]={ring:h,ringLen:c}})),o}(n,i),r=[],s=[],o=[],h=[];let a=0,c=-1,u=-1,l=-1,f=-1;const y=[],x=[];function p(t,n,i,e,p){const d=t.dist/i,g=n.length;for(let h=0;h<g;h++){const f=n[h];if(!f)continue;const v=h===g-1,_=f.angle,z=f.radius,m=f.distance;St.copy(t.up).applyAxisAngle(t.dir,_).normalize();const w=kt.copy(t.up);w.applyAxisAngle(t.dir,_),w.x*=z,w.y*=z,w.z*=z;const M=t.pos.x+w.x,b=t.pos.y+w.y,A=t.pos.z+w.z;if(r[++c]=M,r[++c]=b,r[++c]=A,s[++u]=St.x,s[++u]=St.y,s[++u]=St.z,o[++l]=d,o[++l]=m/i,a++,e&&!v){let t=y.length-1;y[++t]=M,y[++t]=b,y[++t]=A}if(p&&!v){let t=x.length-1;x[++t]=M,x[++t]=b,x[++t]=A}}if(!e){const t=a-2*g,n=a-g;for(let i=0;i<g-1;i++)h[++f]=n+i,h[++f]=t+i,h[++f]=t+i+1,h[++f]=n+i,h[++f]=t+i+1,h[++f]=n+i+1}}const d=e[0].ringLen;return e.forEach((n=>{for(let i=0;i<t.count;i++){const e=t.array[i],{ring:r,ringLen:s}=n;p(e,r,s,0===i,i===t.count-1)}})),{points:r,normal:s,uv:o,indices:h,startPoints:y,endPoints:x,polygonLen:d}}(f,t,i);return r||function(t,n,i){const{openEndUV:e}=i;for(let t=0,i=n.length;t<i;t++){const i=n[t];U(i)&&i.splice(i.length-1,1)}const r=I(n),s=[],o=[];let h=-1;for(let t=0,i=n.length;t<i;t++){const i=n[t];t>0&&o.push(s.length/2);for(let t=0,n=i.length;t<n;t++){const n=i[t];s[++h]=n[0],s[++h]=n[1]}}const a=C(s,o,2),{points:c,normal:u,uv:l,indices:f,startPoints:y,endPoints:x,polygonLen:p}=t;h=0;let d=0;const g=[],v=[],_=[],z=[];for(let t=0;t<r;t++){const n=3*t,i=y[n],r=y[n+1],s=y[n+2];g[h]=i,g[h+1]=r,g[h+2]=s,e?(v[d]=r/p,v[d+1]=s/p):(v[d]=0,v[d+1]=0);const o=x[n],a=x[n+1],c=x[n+2];_[h]=o,_[h+1]=a,_[h+2]=c,e?(z[d]=a/p,z[d+1]=c/p):(z[d]=0,z[d+1]=0),h+=3,d+=2}const m=c.length/3,w=[];for(let t=0,n=a.length;t<n;t++)w[t]=a[t]+m,w[t+n]=a[t]+m+r;const M=Q(a,g),b=Q(a,_);L(c,g),L(c,_),L(l,v),L(l,z),L(u,M),L(u,b),L(f,w)}(n,t,i),n.polygon=t,n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=new Float32Array(n.normal),n})),x=W(y);return x.polygons=t,x},t.extrudePolylines=function(t,n){const i=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},n);G(i);const e=t.map((t=>{const n=tt(t,i);return n.line=t,H(n,i),J(n,i),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=Q(n.indices,n.position),n})),r=W(e);return r.lines=t,r},t.extrudeSlopes=function(t,n){const i=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},n);G(i);const{depth:e,side:r,sideDepth:s}=i,o=t.map((t=>{const n=tt(t,i);n.line=t;const{leftPoints:o,rightPoints:h}=n,a={line:t};let c;for(let n=0,i=t.length;n<i;n++)t[n][2]=t[n][2]||0;return"left"===r?(a.leftPoints=o,a.rightPoints=t,c=[s,e]):(a.leftPoints=t,a.rightPoints=h,c=[e,s]),a.depths=c,H(a,i),J(a,i),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.indices),a.uv=new Float32Array(a.uv),a.normal=Q(a.indices,a.position),a})),h=W(o);return h.lines=t,h},t.isClockwise=O,t.leftOnLine=et,t.merge=W,t.plane=function(t,n,i,e){const r=t/(i=Math.max(1,i)),s=n/(e=Math.max(1,e)),o=-t/2,h=n/2,a=-n/2,c=(i+1)*(e+1),u=new Float32Array(3*c),l=new Float32Array(2*c),f=new Float32Array(3*c),y=new Uint32Array(10*c);let x=0,p=0,d=0;for(let c=0;c<=e;c++)for(let g=0;g<=i;g++){const v=o+r*g,_=h-s*c;u[x]=v,u[x+1]=_,u[x+2]=0,f[x]=0,f[x+1]=0,f[x+2]=1;const z=(v-o)/t,m=(_-a)/n;if(l[p]=z,l[p+1]=m,x+=3,p+=2,g<i&&c<e){const t=c*(i+1)+g,n=t+1,e=(i+1)*(c+1)+g,r=e+1;y[d]=t,y[d+1]=e,y[d+2]=n,y[d+3]=e,y[d+4]=r,y[d+5]=n,d+=6}}const g=new Uint32Array(d);for(let t=0,n=g.length;t<n;t++)g[t]=y[t];return{position:u,uv:l,normal:f,indices:g}},t.polygons=function(t,n={}){const i=Object.assign({},n),e=t.map((t=>{E(t,!0);const n=function(t,n={}){const i=[],e=[];let r=-1,s=-1,o=-1;const h=[],a=[];for(let n=0,c=t.length;n<c;n++){const c=t[n];n>0&&e.push(i.length/2);for(let t=0,n=c.length;t<n;t++){const n=c[t];i[++r]=n[0],i[++r]=n[1],h[++s]=n[0],h[++s]=n[1],h[++s]=n[2]||0,a[++o]=n[0],a[++o]=n[1]}}const c=C(i,e,2);return{normal:Q(c,h),uv:a,points:h,indices:c}}(t,i);return n.polygon=t,n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=new Float32Array(n.normal),n})),r=W(e);return r.polygons=t,r},Object.defineProperty(t,"__esModule",{value:!0})}));
|
package/dist/poly-extrude.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.20.
|
2
|
+
* poly-extrude v0.20.1
|
3
3
|
*/
|
4
4
|
var earcut$2 = {exports: {}};
|
5
5
|
|
@@ -2554,15 +2554,25 @@ function expandLine(line, options) {
|
|
2554
2554
|
i++;
|
2555
2555
|
continue;
|
2556
2556
|
}
|
2557
|
-
|
2558
|
-
|
2559
|
-
|
2560
|
-
|
2561
|
-
if ((
|
2562
|
-
|
2557
|
+
const dy1 = p1[1] - p0[1], dx1 = p1[0] - p0[0];
|
2558
|
+
const rad1 = Math.atan2(dy1, dx1);
|
2559
|
+
const angle1 = radToDeg(rad1);
|
2560
|
+
// 平行,回头路
|
2561
|
+
if ((Math.abs(angle1 - angle) - 180) <= 0.0001) {
|
2562
|
+
rAngle = angle;
|
2563
|
+
rAngle -= 90;
|
2564
|
+
}
|
2565
|
+
else {
|
2566
|
+
TEMPV1.x = p0[0] - p1[0];
|
2567
|
+
TEMPV1.y = p0[1] - p1[1];
|
2568
|
+
TEMPV2.x = p2[0] - p1[0];
|
2569
|
+
TEMPV2.y = p2[1] - p1[1];
|
2570
|
+
if ((TEMPV1.x === 0 && TEMPV1.y === 0) || (TEMPV2.x === 0 && TEMPV2.y === 0)) {
|
2571
|
+
console.error('has repeat vertex,the index:', i);
|
2572
|
+
}
|
2573
|
+
const vAngle = getAngle$1(TEMPV1, TEMPV2);
|
2574
|
+
rAngle = angle - vAngle / 2;
|
2563
2575
|
}
|
2564
|
-
const vAngle = getAngle$1(TEMPV1, TEMPV2);
|
2565
|
-
rAngle = angle - vAngle / 2;
|
2566
2576
|
}
|
2567
2577
|
const rRad = degToRad(rAngle);
|
2568
2578
|
const p3 = currentp;
|