poly-extrude 0.14.0 → 0.15.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.
@@ -1,4 +1,4 @@
1
1
  /*!
2
- * poly-extrude v0.14.0
2
+ * poly-extrude v0.15.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 i(t,n,i){i=i||2;var r,o,h,a,u,f,y,p=n&&n.length,d=p?n[0]*i:t.length,v=e(t,0,d,i,!0),_=[];if(!v||v.next===v.prev)return _;if(p&&(v=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(c),s=0;s<a.length;s++)i=l(a[s],i);return i}(t,n,v,i)),t.length>80*i){r=h=t[0],o=a=t[1];for(var g=i;g<d;g+=i)(u=t[g])<r&&(r=u),(f=t[g+1])<o&&(o=f),u>h&&(h=u),f>a&&(a=f);y=0!==(y=Math.max(h-r,a-o))?32767/y:0}return s(v,_,i,r,o,y,0),_}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&&_(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||!_(e,e.next)&&0!==v(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,c,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,u=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,e=i,h=0,n=0;n<u&&(h++,e=e.nextZ);n++);for(a=u;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,u*=2}while(o>1)}(r)}(t,e,c,l);for(var x,p,d=t;t.prev!==t.next;)if(x=t.prev,p=t.next,l?h(t,e,c,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,c,l,2):2===f&&u(t,n,i,e,c,l):s(r(t),n,i,e,c,l,1);break}}}function o(t){var n=t.prev,i=t,e=t.next;if(v(n,i,e)>=0)return!1;for(var r=n.x,s=i.x,o=e.x,h=n.y,a=i.y,u=e.y,c=r<s?r<o?r:o:s<o?s:o,l=h<a?h<u?h:u:a<u?a:u,f=r>s?r>o?r:o:s>o?s:o,y=h>a?h>u?h:u:a>u?a:u,x=e.next;x!==n;){if(x.x>=c&&x.x<=f&&x.y>=l&&x.y<=y&&p(r,h,s,a,o,u,x.x,x.y)&&v(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(v(r,s,o)>=0)return!1;for(var h=r.x,a=s.x,u=o.x,c=r.y,l=s.y,f=o.y,x=h<a?h<u?h:u:a<u?a:u,d=c<l?c<f?c:f:l<f?l:f,_=h>a?h>u?h:u:a>u?a:u,g=c>l?c>f?c:f:l>f?l:f,z=y(x,d,n,i,e),m=y(_,g,n,i,e),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=x&&w.x<=_&&w.y>=d&&w.y<=g&&w!==r&&w!==o&&p(h,c,a,l,u,f,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=x&&M.x<=_&&M.y>=d&&M.y<=g&&M!==r&&M!==o&&p(h,c,a,l,u,f,M.x,M.y)&&v(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=x&&w.x<=_&&w.y>=d&&w.y<=g&&w!==r&&w!==o&&p(h,c,a,l,u,f,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=x&&M.x<=_&&M.y>=d&&M.y<=g&&M!==r&&M!==o&&p(h,c,a,l,u,f,M.x,M.y)&&v(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;!_(s,o)&&g(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 u(t,n,i,e,o,h){var a=t;do{for(var u=a.next.next;u!==a.prev;){if(a.i!==u.i&&d(a,u)){var c=M(a,u);return a=r(a,a.next),c=r(c,c.next),s(a,n,i,e,o,h,0),void s(c,n,i,e,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 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,u=i,c=i.x,l=i.y,y=1/0;e=i;do{r>=e.x&&e.x>=c&&r!==e.x&&p(s<l?r:o,s,c,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!==u);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 v(t.prev,t,n.prev)<0&&v(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&&g(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)&&(v(t.prev,t,n.prev)||v(t,n.prev,n))||_(t,n)&&v(t.prev,t,t.next)>0&&v(n.prev,n,n.next)>0)}function v(t,n,i){return(n.y-t.y)*(i.x-n.x)-(n.x-t.x)*(i.y-n.y)}function _(t,n){return t.x===n.x&&t.y===n.y}function g(t,n,i,e){var r=m(v(t,n,i)),s=m(v(t,n,e)),o=m(v(i,e,t)),h=m(v(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 v(t.prev,t,t.next)<0?v(t,n,t.next)>=0&&v(t,t.prev,n)>=0:v(t,n,t.prev)<0||v(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 u=n[h]*i,c=h<a-1?n[h+1]*i:t.length;o-=Math.abs(S(t,u,c,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 V(t,n){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},V(t,n)}var Z=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],u=i[e+2],c=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]=u,void(t[n+3]=c);if(1===o)return t[n+0]=l,t[n+1]=f,t[n+2]=y,void(t[n+3]=x);if(c!==x||h!==l||a!==f||u!==y){var p=1-o,d=h*l+a*f+u*y+c*x,v=d>=0?1:-1,_=1-d*d;if(_>Number.EPSILON){var g=Math.sqrt(_),z=Math.atan2(g,d*v);p=Math.sin(p*z)/g,o=Math.sin(o*z)/g}var m=o*v;if(h=h*p+l*m,a=a*p+f*m,u=u*p+y*m,c=c*p+x*m,p===1-o){var w=1/Math.sqrt(h*h+a*a+u*u+c*c);h*=w,a*=w,u*=w,c*=w}}t[n]=h,t[n+1]=a,t[n+2]=u,t[n+3]=c},t.multiplyQuaternionsFlat=function(t,n,i,e,r,s){var o=i[e],h=i[e+1],a=i[e+2],u=i[e+3],c=r[s],l=r[s+1],f=r[s+2],y=r[s+3];return t[n]=o*y+u*c+h*f-a*l,t[n+1]=h*y+u*l+a*c-o*f,t[n+2]=a*y+u*f+o*l-h*c,t[n+3]=u*y-o*c-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),u=o(e/2),c=o(r/2),l=h(i/2),f=h(e/2),y=h(r/2);switch(s){case"XYZ":this._x=l*u*c+a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c-l*f*y;break;case"YXZ":this._x=l*u*c+a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c+l*f*y;break;case"ZXY":this._x=l*u*c-a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c-l*f*y;break;case"ZYX":this._x=l*u*c-a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c+l*f*y;break;case"YZX":this._x=l*u*c+a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c-l*f*y;break;case"XZY":this._x=l*u*c-a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c+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],u=n[6],c=n[10],l=i+o+c;if(l>0){var f=.5/Math.sqrt(l+1);this._w=.25/f,this._x=(u-h)*f,this._y=(r-a)*f,this._z=(s-e)*f}else if(i>o&&i>c){var y=2*Math.sqrt(1+i-o-c);this._w=(u-h)/y,this._x=.25*y,this._y=(e+s)/y,this._z=(r+a)/y}else if(o>c){var x=2*Math.sqrt(1+o-i-c);this._w=(r-a)/x,this._x=(e+s)/x,this._y=.25*x,this._z=(h+u)/x}else{var p=2*Math.sqrt(1+c-i-o);this._w=(s-e)/p,this._x=(r+a)/p,this._y=(h+u)/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,u=n._w;return this._x=i*u+s*o+e*a-r*h,this._y=e*u+s*h+r*o-i*a,this._z=r*u+s*a+i*h-e*o,this._w=s*u-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 u=Math.sqrt(h),c=Math.atan2(u,o),l=Math.sin((1-n)*c)/u,f=Math.sin(n*c)/u;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}()),F=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(Z.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,u=h*i+o*n-r*e,c=h*e+r*i-s*n,l=-r*n-s*i-o*e;return this.x=a*h+l*-r+u*-o-c*-s,this.y=u*h+l*-s+c*-r-a*-o,this.z=c*h+l*-o+a*-s-u*-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 q(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 L(t,n,i){return t[0]=n[0]-i[0],t[1]=n[1]-i[1],t[2]=n[2]-i[2],t}function O(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 I(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 U(t,n){function i(t,n,i,e){t[0]=n,t[1]=i,t[2]=e}const e=[],r=[],s=[],o=[],h=[],a=[],u=t.length,c=new Float32Array(n.length);let l=0;for(;l<u;){const u=3*t[l],f=3*t[l+1],y=3*t[l+2];i(e,n[u],n[u+1],n[u+2]),i(r,n[f],n[f+1],n[f+2]),i(s,n[y],n[y+1],n[y+2]),L(h,s,r),L(o,e,r),I(a,h,o);for(let t=0;t<3;t++)c[u+t]+=a[t],c[f+t]+=a[t],c[y+t]+=a[t];l+=3}let f=0;const y=c.length;for(;f<y;)i(a,c[f],c[f+1],c[f+2]),O(a,a),c[f]=a[0]||0,c[f+1]=a[1]||0,c[f+2]=a[2]||0,f+=3;return c}function j(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:u,uv:c}=t[n];e.position.set(i,r),e.normal.set(u,r),e.uv.set(c,h);let l=0;const f=a.length;for(;l<f;){const t=a[l]+s;e.indices[o]=t,o++,l++}h+=c.length,r+=i.length,s+=i.length/3}return e}function E(t){return 180*t/Math.PI}function N(t){return t/180*Math.PI}function T(t,n,i,e,r,s){const o=3*i,h=3*e,a=3*r,u=3*s,c=n[o],l=n[o+1],f=n[o+2],y=n[h],x=n[h+1],p=n[h+2],d=n[a],v=n[a+1],_=n[a+2],g=n[u],z=n[u+1],m=n[u+2];let w=t.length-1;Math.abs(l-x)<Math.abs(c-y)?(t[++w]=c,t[++w]=1-f,t[++w]=y,t[++w]=1-p,t[++w]=d,t[++w]=1-_,t[++w]=g,t[++w]=1-m):(t[++w]=l,t[++w]=1-f,t[++w]=x,t[++w]=1-p,t[++w]=v,t[++w]=1-_,t[++w]=z,t[++w]=1-m)}function Q(t){const n=[];for(let i=0,e=t.length;i<e;i++){const e=t[i],[r,s,o]=e,h=new F(r,s,o||0);n[i]=h}return n}function R(t){W(t)||t.push(t[0])}function W(t){const n=t.length,[i,e]=t[0],[r,s]=t[n-1];return i===r&&e===s}function X(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function B(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,u=t.line,c=n.pathUV;if(c){!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,u=t-o,c=i-h,l=(s||0)-(a||0);n+=Math.sqrt(u*u+c*c+l*l),r.distance=n}}}(u);for(let t=0,n=u.length;t<n;t++)h[t].distance=a[t].distance=u[t].distance}let l=0,f=h.length;const y=[],x=[],p=[];for(;l<f;){const t=3*l,[n,e,r]=h[l];y[t]=n,y[t+1]=e,y[t+2]=s+r;const[x,d,v]=a[l],_=3*f+t;y[_]=x,y[_+1]=d,y[_+2]=o+v;const g=2*f*3+t;y[g]=n,y[g+1]=e,y[g+2]=r,i&&(y[g+2]=0);const z=2*f*3+3*f+t;if(y[z]=x,y[z+1]=d,y[z+2]=v,i&&(y[z+2]=0),c){const t=u[l].distance,n=2*l;p[n]=t,p[n+1]=1;const i=2*f+n;p[i]=t,p[i+1]=0;const e=2*f*2+n;p[e]=t,p[e+1]=1;const r=2*f*2+2*f+n;p[r]=t,p[r+1]=0}l++}if(!c){l=0,f=y.length;let t=p.length-1;for(;l<f;){const n=y[l],i=y[l+1];p[++t]=n,p[++t]=i,l+=3}}l=0,f=h.length;let d=x.length-1;for(;l<f-1;){const t=l,n=l+1,i=t+f,e=n+f;x[++d]=t,x[++d]=i,x[++d]=n,x[++d]=i,x[++d]=e,x[++d]=n;const r=l+2*f,s=r+1,o=r+f,h=s+f;x[++d]=r,x[++d]=o,x[++d]=s,x[++d]=o,x[++d]=h,x[++d]=s,l++}if(t.indices=x,t.points=y,t.uv=p,r)for(f=h.length,l=0;l<f;)h[l].depth=s,a[l].depth=o,l++}function Y(t,n){const{points:i,indices:e,leftPoints:r,rightPoints:s,uv:o}=t,h=n.depth,a=n.bottomStickGround,u=[r,s],c=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=c?t.depth:h,u=c?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]=u+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,v=r+3,_=r,g=r+1;e[++x]=d,e[++x]=_,e[++x]=v,e[++x]=_,e[++x]=g,e[++x]=v,l?(o[++p]=t.distance,o[++p]=s/f,o[++p]=n.distance,o[++p]=u/f,o[++p]=t.distance,o[++p]=0,o[++p]=n.distance,o[++p]=0):T(o,i,d,v,_,g)}for(let t=0,n=u.length;t<n;t++){let n=u[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 v=r.length,_=[s[0],r[0],r[v-1],s[v-1]];for(let t=0;t<_.length;t+=2){d(_[t],_[t+1])}}const D={x:0,y:0},G={x:0,y:0};function H(t,n){let i=n.lineWidth/2;n.isSlope&&(i*=2);const e=[],r=[],s=[],o=t.length;let h=0;for(;h<o;){let n=t[h],a=t[h+1];const u=t[h];h===o-1&&(n=t[o-2],a=t[o-1]);const c=a[1]-n[1],l=a[0]-n[0];let f=0;const y=E(Math.atan(c/l));if(0===h||h===o-1)f=y,f-=90;else{const i=t[h-1];D.x=i[0]-n[0],D.y=i[1]-n[1],G.x=a[0]-n[0],G.y=a[1]-n[1];f=y-J(D,G)/2}const x=N(f),p=u,d=[Math.cos(x)+p[0],Math.sin(x)+p[1]],[v,_]=$(n,a,i);let g=tt(v[0],v[1],p,d),z=tt(_[0],_[1],p,d);if(!g||!z){const t=e.length,n=e[t-2],i=e[t-1];if(!n||!i)continue;g=[n[0],n[1]],z=[i[0],i[1]]}g[2]=u[2]||0,z[2]=u[2]||0,e.push(g,z),K(g,n,a)?(r.push(g),s.push(z)):(r.push(z),s.push(g)),h++}return{offsetPoints:e,leftPoints:r,rightPoints:s,line:t}}const J=({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+360)%360};function K(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 $(t,n,i){const e=n[1]-t[1],r=n[0]-t[0],s=Math.atan2(e,r),o=s+Math.PI/2;let h=Math.cos(o)*i,a=Math.sin(o)*i;const u=[t[0]+h,t[1]+a],c=[n[0]+h,n[1]+a],l=s-Math.PI/2;h=Math.cos(l)*i,a=Math.sin(l)*i;return[[u,c],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function tt(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,u=h/o,c=t[1]-a*t[0],l=i[1]-u*i[0];let f,y;return 0===r?(f=t[0],y=u*f+l):0===o?(f=i[0],y=a*f+c):0===s?(y=t[1],f=(y-l)/u):0===h?(y=i[1],f=(y-c)/a):(f=(l-c)/(a-u),y=a*f+c),[f,y]}var nt=function(){function t(){this.pos=new F,this.dir=new F,this.right=new F,this.up=new F,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}(),it=function(){function t(t,n,i,e,r,s,o,h,a,u,c,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,u,c,l,f,y,x,p)}var n=t.prototype;return n.set=function(t,n,i,e,r,s,o,h,a,u,c,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]=u,d[10]=c,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,u=r*o;return this.set(a*s+i,a*o-e*h,a*h+e*o,0,a*o+e*h,u*o+i,u*h-e*s,0,a*h-e*o,u*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}();function et(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 rt=function(t){var n,i;function e(n,i,e){var r;return void 0===n&&(n=new F),void 0===i&&(i=new F),void 0===e&&(e=new F),(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,V(n,i),e.prototype.getPoint=function(t,n){void 0===n&&(n=new F);var i=n,e=this.v0,r=this.v1,s=this.v2;return i.set(et(t,e.x,r.x,s.x),et(t,e.y,r.y,s.y),et(t,e.z,r.z,s.z)),i},e}(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 u=e[r];return(r+(i-u)/(e[r+1]-u))/(s-1)},t}()),st=new F,ot=new F,ht=new F,at=new it,ut=new rt;var ct=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 F).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 nt),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=st.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(at.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=st.subVectors(n,t),h=ot.subVectors(i,n),a=o.length(),u=h.length();o.normalize(),h.normalize();var c=Math.min(.999999*(r?a/2:a),e);s.v0.copy(n).sub(o.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/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,ut),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=st.subVectors(t,s.pos),a=ot.subVectors(n,t),u=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 c=ht.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(at.makeRotationAxis(c,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+u;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 lt=new F(0,0,1),ft=new F,yt=new F,xt=new F,pt=new F,dt=new F,vt=new F;const _t=new F(0,0,1),gt=new F;t.cylinder=function(t,n){n=Object.assign({},{radius:1,height:2,radialSegments:6},n);const i=Math.round(Math.max(4,n.radialSegments));let{radius:e,height:r}=n;const s=360/i/360*Math.PI*2,o=i+1,h=new Float32Array(3*o*2),[a,u]=t;let c=0,l=0;const f=3*o,y=2*o,x=[],p=[];let d=x.length-1;for(let t=-1;t<i;t++){const n=s*t,i=Math.cos(n)*e+a,o=Math.sin(n)*e+u;h[c]=i,h[c+1]=o,h[c+2]=0,h[c+f]=i,h[c+1+f]=o,h[c+2+f]=r;let v=0,_=0;v=.5+i/e/2,_=.5+o/e/2,p[l]=v,p[l+1]=_,p[l+y]=v,p[l+1+y]=_,c+=3,l+=2,t>1&&(x[++d]=0,x[++d]=t-1,x[++d]=t)}c-=3,h[c]=h[0],h[c+1]=h[1],h[c+2]=h[2];const v=h.length;h[v-3]=h[0],h[v-2]=h[1],h[v-1]=r;const _=x.length;d=x.length-1;for(let t=0;t<_;t++){const n=x[t];x[++d]=n+o}const g=new Float32Array(2*(3*o*2-6));let z=-1;c=2*o,l=0,d=x.length-1;let m=p.length-1;for(let t=0,n=h.length/2;t<n-3;t+=3){const n=h[t],i=h[t+1],s=h[t+3],a=h[t+4];g[++z]=n,g[++z]=i,g[++z]=r,g[++z]=s,g[++z]=a,g[++z]=r,g[++z]=n,g[++z]=i,g[++z]=0,g[++z]=s,g[++z]=a,g[++z]=0;const u=c+2,f=c+3,y=c,v=c+1;x[++d]=y,x[++d]=u,x[++d]=v,x[++d]=u,x[++d]=f,x[++d]=v,c+=4;const _=l/o,w=(l+1)/o;p[++m]=_,p[++m]=r/e/2,p[++m]=w,p[++m]=r/e/2,p[++m]=_,p[++m]=0,p[++m]=w,p[++m]=0,l++}const w=new Float32Array(h.length+g.length);w.set(h,0),w.set(g,h.length);const M=U(x,w);return{points:h,indices:new Uint32Array(x),position:w,normal:M,uv:new Float32Array(p)}},t.expandLine=H,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);const i=t.map((t=>{const i=Q(t),e=new ct;e.set(i,n.cornerRadius,n.cornerSplit,lt);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 u=[],c=[],l=[],f=[];let y=0;if(0===o)return{position:u,normal:c,uv:l,indices:f,count:a};const x=r/s;let p,d=u.length-1,v=c.length-1,_=l.length-1,g=f.length-1;function z(t){const n=0===u.length,i=t.sharp&&!n,e=t.dist/s,o=t.dir,h=t.up,p=t.right;if(ft.copy(p).multiplyScalar(r*t.widthScale),yt.copy(p).multiplyScalar(-r*t.widthScale),ft.add(t.pos),yt.add(t.pos),i){xt.fromArray(u,u.length-6).sub(yt),pt.fromArray(u,u.length-3).sub(ft);const t=xt.length()-pt.length();let n,i;t>0?(n=xt,i=yt):(n=pt,i=ft),dt.copy(n).setLength(Math.abs(t)).add(i);let r=vt.copy(i).sub(dt).normalize().dot(o)*vt.copy(i).sub(dt).length()*2;vt.copy(o).setLength(r).add(dt),t>0?(u[++d]=dt.x,u[++d]=dt.y,u[++d]=dt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=vt.x,u[++d]=vt.y,u[++d]=vt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,y+=6,f[++g]=y-6,f[++g]=y-8,f[++g]=y-7,f[++g]=y-6,f[++g]=y-7,f[++g]=y-5,f[++g]=y-4,f[++g]=y-6,f[++g]=y-5,f[++g]=y-2,f[++g]=y-4,f[++g]=y-1,a+=12):(u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=dt.x,u[++d]=dt.y,u[++d]=dt.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=vt.x,u[++d]=vt.y,u[++d]=vt.z,y+=6,f[++g]=y-6,f[++g]=y-8,f[++g]=y-7,f[++g]=y-6,f[++g]=y-7,f[++g]=y-5,f[++g]=y-6,f[++g]=y-5,f[++g]=y-3,f[++g]=y-2,f[++g]=y-3,f[++g]=y-1,a+=12);for(let t=0;t<6;t++)c[++v]=h.x,c[++v]=h.y,c[++v]=h.z;l[++_]=e-x,l[++_]=0,l[++_]=e-x,l[++_]=1,l[++_]=e,l[++_]=0,l[++_]=e,l[++_]=1,l[++_]=e+x,l[++_]=0,l[++_]=e+x,l[++_]=1}else u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,c[++v]=h.x,c[++v]=h.y,c[++v]=h.z,c[++v]=h.x,c[++v]=h.y,c[++v]=h.z,l[++_]=e,l[++_]=0,l[++_]=e,l[++_]=1,y+=2,n||(f[++g]=y-2,f[++g]=y-4,f[++g]=y-3,f[++g]=y-2,f[++g]=y-3,f[++g]=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 nt;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:u,normal:c,uv:l,indices:f,count:a}}(e,n);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}})),e=j(i);return e.lines=t,e},t.expandTubes=function(t,n){n=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n);const i=t.map((t=>{const i=Q(t),e=new ct;e.set(i,0,n.cornerSplit,_t);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 u=0;const c=[],l=[],f=[],y=[];let x=0,p=-1,d=-1,v=-1,_=-1;function g(t,n,i){const e=0===c.length,r=t.dist/o;for(let e=0;e<=i;e++){let o=e;o===i&&(o=0),gt.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();const h=n*t.widthScale;c[++p]=t.pos.x+gt.x*h,c[++p]=t.pos.y+gt.y*h,c[++p]=t.pos.z+gt.z*h,l[++d]=gt.x,l[++d]=gt.y,l[++d]=gt.z,f[++v]=r,f[++v]=e/i,x++}if(!e){const t=x-2*(i+1),n=x-(i+1);for(let e=0;e<i;e++)y[++_]=n+e,y[++_]=t+e,y[++_]=t+e+1,y[++_]=n+e,y[++_]=t+e+1,y[++_]=n+e+1,u+=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 nt,h=(a-s.dist)/(e.dist-s.dist);o.lerpPathPoints(s,e,h),g(o,i,r);break}g(e,i,r)}return{points:c,normal:l,uv:f,indices:y,count:u}}(e,n);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})),e=j(i);return e.lines=t,e},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);const i=t.map((t=>{for(let n=0,i=t.length;n<i;n++){const i=t[n];R(i),0===n?q(i)||(t[n]=i.reverse()):q(i)&&(t[n]=i.reverse()),W(i)&&i.splice(i.length-1,1)}const i=function(t,n){const i=function(t){let n=0,i=0;const e=t.length;for(;i<e;)n+=t[i].length,i++;return n}(t),e=t.length,r=[],s=new Float32Array(2*i),o=[],h=[],a=3*i,u=2*i,c=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]=c+x,o[a+f]=n,o[a+f+1]=r,o[a+f+2]=x,h[y]=n,h[y+1]=r,h[u+y]=n,h[u+y+1]=r,f+=3,y+=2,e++}}return{flatVertices:s,holes:r,points:o,count:i,uv:h}}(t,n);i.polygon=t;return function(t,n){const i=[],{count:e}=t;for(let t=0,r=n.length;t<r;t+=3){const s=n[t],o=n[t+1],h=n[t+2];i[t]=s,i[t+1]=o,i[t+2]=h;const a=r+t,u=e+s,c=e+o,l=e+h;i[a]=u,i[a+1]=c,i[a+2]=l}t.indices=i}(i,C(i.flatVertices,i.holes,2)),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 u=0;const c=n.length;for(;u<c;){const t=n[u];let r=n[u+1];u===c-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],v=r[2]||0;i[++h]=f,i[++h]=y,i[++h]=x+o,i[++h]=p,i[++h]=d,i[++h]=v+o,i[++h]=f,i[++h]=y,i[++h]=x,i[++h]=p,i[++h]=d,i[++h]=v;const _=l+2,g=l+3,z=l,m=l+1;e[++a]=_,e[++a]=z,e[++a]=g,e[++a]=z,e[++a]=m,e[++a]=g,T(s,i,_,g,z,m),u++}}}(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=U(i.indices,i.position),i})),e=j(i);return e.polygons=t,e},t.extrudePolylines=function(t,n){X(n=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},n));const i=t.map((t=>{const i=H(t,n);return i.line=t,B(i,n),Y(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=U(i.indices,i.position),i})),e=j(i);return e.lines=t,e},t.extrudeSlopes=function(t,n){X(n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},n));const{depth:i,side:e,sideDepth:r}=n,s=t.map((t=>{const s=H(t,n);s.line=t;const{leftPoints:o,rightPoints:h}=s,a={line:t};let u;for(let n=0,i=t.length;n<i;n++)t[n][2]=t[n][2]||0;return"left"===e?(a.leftPoints=o,a.rightPoints=t,u=[r,i]):(a.leftPoints=t,a.rightPoints=h,u=[i,r]),a.depths=u,B(a,n),Y(a,n),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.indices),a.uv=new Float32Array(a.uv),a.normal=U(a.indices,a.position),a})),o=j(s);return o.lines=t,o},t.leftOnLine=K,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,u=(i+1)*(e+1),c=new Float32Array(3*u),l=new Float32Array(2*u),f=new Float32Array(3*u),y=new Uint32Array(10*u);let x=0,p=0,d=0;for(let u=0;u<=e;u++)for(let v=0;v<=i;v++){const _=o+r*v,g=h-s*u;c[x]=_,c[x+1]=g,c[x+2]=0,f[x]=0,f[x+1]=0,f[x+2]=1;const z=(_-o)/t,m=(g-a)/n;if(l[p]=z,l[p+1]=m,x+=3,p+=2,v<i&&u<e){const t=u*(i+1)+v,n=t+1,e=(i+1)*(u+1)+v,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 v=new Uint32Array(d);for(let t=0,n=v.length;t<n;t++)v[t]=y[t];return{position:c,uv:l,normal:f,indices:v}},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,u,f,y,p=n&&n.length,d=p?n[0]*i:t.length,v=e(t,0,d,i,!0),_=[];if(!v||v.next===v.prev)return _;if(p&&(v=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(c),s=0;s<a.length;s++)i=l(a[s],i);return i}(t,n,v,i)),t.length>80*i){r=h=t[0],o=a=t[1];for(var g=i;g<d;g+=i)(u=t[g])<r&&(r=u),(f=t[g+1])<o&&(o=f),u>h&&(h=u),f>a&&(a=f);y=0!==(y=Math.max(h-r,a-o))?32767/y:0}return s(v,_,i,r,o,y,0),_}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&&_(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||!_(e,e.next)&&0!==v(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,c,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,u=1;do{for(i=t,t=null,s=null,o=0;i;){for(o++,e=i,h=0,n=0;n<u&&(h++,e=e.nextZ);n++);for(a=u;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,u*=2}while(o>1)}(r)}(t,e,c,l);for(var x,p,d=t;t.prev!==t.next;)if(x=t.prev,p=t.next,l?h(t,e,c,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,c,l,2):2===f&&u(t,n,i,e,c,l):s(r(t),n,i,e,c,l,1);break}}}function o(t){var n=t.prev,i=t,e=t.next;if(v(n,i,e)>=0)return!1;for(var r=n.x,s=i.x,o=e.x,h=n.y,a=i.y,u=e.y,c=r<s?r<o?r:o:s<o?s:o,l=h<a?h<u?h:u:a<u?a:u,f=r>s?r>o?r:o:s>o?s:o,y=h>a?h>u?h:u:a>u?a:u,x=e.next;x!==n;){if(x.x>=c&&x.x<=f&&x.y>=l&&x.y<=y&&p(r,h,s,a,o,u,x.x,x.y)&&v(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(v(r,s,o)>=0)return!1;for(var h=r.x,a=s.x,u=o.x,c=r.y,l=s.y,f=o.y,x=h<a?h<u?h:u:a<u?a:u,d=c<l?c<f?c:f:l<f?l:f,_=h>a?h>u?h:u:a>u?a:u,g=c>l?c>f?c:f:l>f?l:f,z=y(x,d,n,i,e),m=y(_,g,n,i,e),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=x&&w.x<=_&&w.y>=d&&w.y<=g&&w!==r&&w!==o&&p(h,c,a,l,u,f,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=x&&M.x<=_&&M.y>=d&&M.y<=g&&M!==r&&M!==o&&p(h,c,a,l,u,f,M.x,M.y)&&v(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=x&&w.x<=_&&w.y>=d&&w.y<=g&&w!==r&&w!==o&&p(h,c,a,l,u,f,w.x,w.y)&&v(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=x&&M.x<=_&&M.y>=d&&M.y<=g&&M!==r&&M!==o&&p(h,c,a,l,u,f,M.x,M.y)&&v(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;!_(s,o)&&g(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 u(t,n,i,e,o,h){var a=t;do{for(var u=a.next.next;u!==a.prev;){if(a.i!==u.i&&d(a,u)){var c=M(a,u);return a=r(a,a.next),c=r(c,c.next),s(a,n,i,e,o,h,0),void s(c,n,i,e,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 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,u=i,c=i.x,l=i.y,y=1/0;e=i;do{r>=e.x&&e.x>=c&&r!==e.x&&p(s<l?r:o,s,c,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!==u);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 v(t.prev,t,n.prev)<0&&v(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&&g(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)&&(v(t.prev,t,n.prev)||v(t,n.prev,n))||_(t,n)&&v(t.prev,t,t.next)>0&&v(n.prev,n,n.next)>0)}function v(t,n,i){return(n.y-t.y)*(i.x-n.x)-(n.x-t.x)*(i.y-n.y)}function _(t,n){return t.x===n.x&&t.y===n.y}function g(t,n,i,e){var r=m(v(t,n,i)),s=m(v(t,n,e)),o=m(v(i,e,t)),h=m(v(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 v(t.prev,t,t.next)<0?v(t,n,t.next)>=0&&v(t,t.prev,n)>=0:v(t,n,t.prev)<0||v(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 u=n[h]*i,c=h<a-1?n[h+1]*i:t.length;o-=Math.abs(S(t,u,c,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 V(t,n){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},V(t,n)}var Z=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],u=i[e+2],c=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]=u,void(t[n+3]=c);if(1===o)return t[n+0]=l,t[n+1]=f,t[n+2]=y,void(t[n+3]=x);if(c!==x||h!==l||a!==f||u!==y){var p=1-o,d=h*l+a*f+u*y+c*x,v=d>=0?1:-1,_=1-d*d;if(_>Number.EPSILON){var g=Math.sqrt(_),z=Math.atan2(g,d*v);p=Math.sin(p*z)/g,o=Math.sin(o*z)/g}var m=o*v;if(h=h*p+l*m,a=a*p+f*m,u=u*p+y*m,c=c*p+x*m,p===1-o){var w=1/Math.sqrt(h*h+a*a+u*u+c*c);h*=w,a*=w,u*=w,c*=w}}t[n]=h,t[n+1]=a,t[n+2]=u,t[n+3]=c},t.multiplyQuaternionsFlat=function(t,n,i,e,r,s){var o=i[e],h=i[e+1],a=i[e+2],u=i[e+3],c=r[s],l=r[s+1],f=r[s+2],y=r[s+3];return t[n]=o*y+u*c+h*f-a*l,t[n+1]=h*y+u*l+a*c-o*f,t[n+2]=a*y+u*f+o*l-h*c,t[n+3]=u*y-o*c-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),u=o(e/2),c=o(r/2),l=h(i/2),f=h(e/2),y=h(r/2);switch(s){case"XYZ":this._x=l*u*c+a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c-l*f*y;break;case"YXZ":this._x=l*u*c+a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c+l*f*y;break;case"ZXY":this._x=l*u*c-a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c-l*f*y;break;case"ZYX":this._x=l*u*c-a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c+l*f*y;break;case"YZX":this._x=l*u*c+a*f*y,this._y=a*f*c+l*u*y,this._z=a*u*y-l*f*c,this._w=a*u*c-l*f*y;break;case"XZY":this._x=l*u*c-a*f*y,this._y=a*f*c-l*u*y,this._z=a*u*y+l*f*c,this._w=a*u*c+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],u=n[6],c=n[10],l=i+o+c;if(l>0){var f=.5/Math.sqrt(l+1);this._w=.25/f,this._x=(u-h)*f,this._y=(r-a)*f,this._z=(s-e)*f}else if(i>o&&i>c){var y=2*Math.sqrt(1+i-o-c);this._w=(u-h)/y,this._x=.25*y,this._y=(e+s)/y,this._z=(r+a)/y}else if(o>c){var x=2*Math.sqrt(1+o-i-c);this._w=(r-a)/x,this._x=(e+s)/x,this._y=.25*x,this._z=(h+u)/x}else{var p=2*Math.sqrt(1+c-i-o);this._w=(s-e)/p,this._x=(r+a)/p,this._y=(h+u)/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,u=n._w;return this._x=i*u+s*o+e*a-r*h,this._y=e*u+s*h+r*o-i*a,this._z=r*u+s*a+i*h-e*o,this._w=s*u-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 u=Math.sqrt(h),c=Math.atan2(u,o),l=Math.sin((1-n)*c)/u,f=Math.sin(n*c)/u;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}()),F=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(Z.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,u=h*i+o*n-r*e,c=h*e+r*i-s*n,l=-r*n-s*i-o*e;return this.x=a*h+l*-r+u*-o-c*-s,this.y=u*h+l*-s+c*-r-a*-o,this.z=c*h+l*-o+a*-s-u*-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 q(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 L(t,n,i){return t[0]=n[0]-i[0],t[1]=n[1]-i[1],t[2]=n[2]-i[2],t}function O(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 I(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 U(t,n){function i(t,n,i,e){t[0]=n,t[1]=i,t[2]=e}const e=[],r=[],s=[],o=[],h=[],a=[],u=t.length,c=new Float32Array(n.length);let l=0;for(;l<u;){const u=3*t[l],f=3*t[l+1],y=3*t[l+2];i(e,n[u],n[u+1],n[u+2]),i(r,n[f],n[f+1],n[f+2]),i(s,n[y],n[y+1],n[y+2]),L(h,s,r),L(o,e,r),I(a,h,o);for(let t=0;t<3;t++)c[u+t]+=a[t],c[f+t]+=a[t],c[y+t]+=a[t];l+=3}let f=0;const y=c.length;for(;f<y;)i(a,c[f],c[f+1],c[f+2]),O(a,a),c[f]=a[0]||0,c[f+1]=a[1]||0,c[f+2]=a[2]||0,f+=3;return c}function j(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:u,uv:c}=t[n];e.position.set(i,r),e.normal.set(u,r),e.uv.set(c,h);let l=0;const f=a.length;for(;l<f;){const t=a[l]+s;e.indices[o]=t,o++,l++}h+=c.length,r+=i.length,s+=i.length/3}return e}function E(t){return 180*t/Math.PI}function N(t){return t/180*Math.PI}function T(t,n,i,e,r,s){const o=3*i,h=3*e,a=3*r,u=3*s,c=n[o],l=n[o+1],f=n[o+2],y=n[h],x=n[h+1],p=n[h+2],d=n[a],v=n[a+1],_=n[a+2],g=n[u],z=n[u+1],m=n[u+2];let w=t.length-1;Math.abs(l-x)<Math.abs(c-y)?(t[++w]=c,t[++w]=1-f,t[++w]=y,t[++w]=1-p,t[++w]=d,t[++w]=1-_,t[++w]=g,t[++w]=1-m):(t[++w]=l,t[++w]=1-f,t[++w]=x,t[++w]=1-p,t[++w]=v,t[++w]=1-_,t[++w]=z,t[++w]=1-m)}function Q(t){const n=[];for(let i=0,e=t.length;i<e;i++){const e=t[i],[r,s,o]=e,h=new F(r,s,o||0);n[i]=h}return n}function R(t){W(t)||t.push(t[0])}function W(t){const n=t.length,[i,e]=t[0],[r,s]=t[n-1];return i===r&&e===s}function X(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function B(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,u=t.line,c=n.pathUV;if(c){!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,u=t-o,c=i-h,l=(s||0)-(a||0);n+=Math.sqrt(u*u+c*c+l*l),r.distance=n}}}(u);for(let t=0,n=u.length;t<n;t++)h[t].distance=a[t].distance=u[t].distance}let l=0,f=h.length;const y=[],x=[],p=[];for(;l<f;){const t=3*l,[n,e,r]=h[l];y[t]=n,y[t+1]=e,y[t+2]=s+r;const[x,d,v]=a[l],_=3*f+t;y[_]=x,y[_+1]=d,y[_+2]=o+v;const g=2*f*3+t;y[g]=n,y[g+1]=e,y[g+2]=r,i&&(y[g+2]=0);const z=2*f*3+3*f+t;if(y[z]=x,y[z+1]=d,y[z+2]=v,i&&(y[z+2]=0),c){const t=u[l].distance,n=2*l;p[n]=t,p[n+1]=1;const i=2*f+n;p[i]=t,p[i+1]=0;const e=2*f*2+n;p[e]=t,p[e+1]=1;const r=2*f*2+2*f+n;p[r]=t,p[r+1]=0}l++}if(!c){l=0,f=y.length;let t=p.length-1;for(;l<f;){const n=y[l],i=y[l+1];p[++t]=n,p[++t]=i,l+=3}}l=0,f=h.length;let d=x.length-1;for(;l<f-1;){const t=l,n=l+1,i=t+f,e=n+f;x[++d]=t,x[++d]=i,x[++d]=n,x[++d]=i,x[++d]=e,x[++d]=n;const r=l+2*f,s=r+1,o=r+f,h=s+f;x[++d]=r,x[++d]=o,x[++d]=s,x[++d]=o,x[++d]=h,x[++d]=s,l++}if(t.indices=x,t.points=y,t.uv=p,r)for(f=h.length,l=0;l<f;)h[l].depth=s,a[l].depth=o,l++}function Y(t,n){const{points:i,indices:e,leftPoints:r,rightPoints:s,uv:o}=t,h=n.depth,a=n.bottomStickGround,u=[r,s],c=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=c?t.depth:h,u=c?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]=u+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,v=r+3,_=r,g=r+1;e[++x]=d,e[++x]=_,e[++x]=v,e[++x]=_,e[++x]=g,e[++x]=v,l?(o[++p]=t.distance,o[++p]=s/f,o[++p]=n.distance,o[++p]=u/f,o[++p]=t.distance,o[++p]=0,o[++p]=n.distance,o[++p]=0):T(o,i,d,v,_,g)}for(let t=0,n=u.length;t<n;t++){let n=u[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 v=r.length,_=[s[0],r[0],r[v-1],s[v-1]];for(let t=0;t<_.length;t+=2){d(_[t],_[t+1])}}const D={x:0,y:0},G={x:0,y:0};function H(t,n){let i=n.lineWidth/2;n.isSlope&&(i*=2);const e=[],r=[],s=[],o=t.length;let h=0;for(;h<o;){let n=t[h],a=t[h+1];const u=t[h];h===o-1&&(n=t[o-2],a=t[o-1]);const c=a[1]-n[1],l=a[0]-n[0];let f=0;const y=E(Math.atan(c/l));if(0===h||h===o-1)f=y,f-=90;else{const i=t[h-1];D.x=i[0]-n[0],D.y=i[1]-n[1],G.x=a[0]-n[0],G.y=a[1]-n[1];f=y-J(D,G)/2}const x=N(f),p=u,d=[Math.cos(x)+p[0],Math.sin(x)+p[1]],[v,_]=$(n,a,i);let g=tt(v[0],v[1],p,d),z=tt(_[0],_[1],p,d);if(!g||!z){const t=e.length,n=e[t-2],i=e[t-1];if(!n||!i)continue;g=[n[0],n[1]],z=[i[0],i[1]]}g[2]=u[2]||0,z[2]=u[2]||0,e.push(g,z),K(g,n,a)?(r.push(g),s.push(z)):(r.push(z),s.push(g)),h++}return{offsetPoints:e,leftPoints:r,rightPoints:s,line:t}}const J=({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+360)%360};function K(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 $(t,n,i){const e=n[1]-t[1],r=n[0]-t[0],s=Math.atan2(e,r),o=s+Math.PI/2;let h=Math.cos(o)*i,a=Math.sin(o)*i;const u=[t[0]+h,t[1]+a],c=[n[0]+h,n[1]+a],l=s-Math.PI/2;h=Math.cos(l)*i,a=Math.sin(l)*i;return[[u,c],[[t[0]+h,t[1]+a],[n[0]+h,n[1]+a]]]}function tt(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,u=h/o,c=t[1]-a*t[0],l=i[1]-u*i[0];let f,y;return 0===r?(f=t[0],y=u*f+l):0===o?(f=i[0],y=a*f+c):0===s?(y=t[1],f=(y-l)/u):0===h?(y=i[1],f=(y-c)/a):(f=(l-c)/(a-u),y=a*f+c),[f,y]}var nt=function(){function t(){this.pos=new F,this.dir=new F,this.right=new F,this.up=new F,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}(),it=function(){function t(t,n,i,e,r,s,o,h,a,u,c,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,u,c,l,f,y,x,p)}var n=t.prototype;return n.set=function(t,n,i,e,r,s,o,h,a,u,c,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]=u,d[10]=c,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,u=r*o;return this.set(a*s+i,a*o-e*h,a*h+e*o,0,a*o+e*h,u*o+i,u*h-e*s,0,a*h-e*o,u*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}();function et(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 rt=function(t){var n,i;function e(n,i,e){var r;return void 0===n&&(n=new F),void 0===i&&(i=new F),void 0===e&&(e=new F),(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,V(n,i),e.prototype.getPoint=function(t,n){void 0===n&&(n=new F);var i=n,e=this.v0,r=this.v1,s=this.v2;return i.set(et(t,e.x,r.x,s.x),et(t,e.y,r.y,s.y),et(t,e.z,r.z,s.z)),i},e}(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 u=e[r];return(r+(i-u)/(e[r+1]-u))/(s-1)},t}()),st=new F,ot=new F,ht=new F,at=new it,ut=new rt;var ct=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 F).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 nt),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=st.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(at.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=st.subVectors(n,t),h=ot.subVectors(i,n),a=o.length(),u=h.length();o.normalize(),h.normalize();var c=Math.min(.999999*(r?a/2:a),e);s.v0.copy(n).sub(o.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/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,ut),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=st.subVectors(t,s.pos),a=ot.subVectors(n,t),u=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 c=ht.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(at.makeRotationAxis(c,l))}o.right.crossVectors(o.dir,o.up).normalize()}o.dist=s.dist+u;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 lt=new F(0,0,1),ft=new F,yt=new F,xt=new F,pt=new F,dt=new F,vt=new F;const _t=new F(0,0,1),gt=new F;t.cylinder=function(t,n){n=Object.assign({},{radius:1,height:2,radialSegments:6},n);const i=Math.round(Math.max(4,n.radialSegments));let{radius:e,height:r}=n;const s=360/i/360*Math.PI*2,o=i+1,h=new Float32Array(3*o*2),[a,u]=t;let c=0,l=0;const f=3*o,y=2*o,x=[],p=[];let d=x.length-1;for(let t=-1;t<i;t++){const n=s*t,i=Math.cos(n)*e+a,o=Math.sin(n)*e+u;h[c]=i,h[c+1]=o,h[c+2]=0,h[c+f]=i,h[c+1+f]=o,h[c+2+f]=r;let v=0,_=0;v=.5+i/e/2,_=.5+o/e/2,p[l]=v,p[l+1]=_,p[l+y]=v,p[l+1+y]=_,c+=3,l+=2,t>1&&(x[++d]=0,x[++d]=t-1,x[++d]=t)}c-=3,h[c]=h[0],h[c+1]=h[1],h[c+2]=h[2];const v=h.length;h[v-3]=h[0],h[v-2]=h[1],h[v-1]=r;const _=x.length;d=x.length-1;for(let t=0;t<_;t++){const n=x[t];x[++d]=n+o}const g=new Float32Array(2*(3*o*2-6));let z=-1;c=2*o,l=0,d=x.length-1;let m=p.length-1;for(let t=0,n=h.length/2;t<n-3;t+=3){const n=h[t],i=h[t+1],s=h[t+3],a=h[t+4];g[++z]=n,g[++z]=i,g[++z]=r,g[++z]=s,g[++z]=a,g[++z]=r,g[++z]=n,g[++z]=i,g[++z]=0,g[++z]=s,g[++z]=a,g[++z]=0;const u=c+2,f=c+3,y=c,v=c+1;x[++d]=y,x[++d]=u,x[++d]=v,x[++d]=u,x[++d]=f,x[++d]=v,c+=4;const _=l/o,w=(l+1)/o;p[++m]=_,p[++m]=r/e/2,p[++m]=w,p[++m]=r/e/2,p[++m]=_,p[++m]=0,p[++m]=w,p[++m]=0,l++}const w=new Float32Array(h.length+g.length);w.set(h,0),w.set(g,h.length);const M=U(x,w);return{points:h,indices:new Uint32Array(x),position:w,normal:M,uv:new Float32Array(p)}},t.expandLine=H,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);const i=t.map((t=>{const i=Q(t),e=new ct;e.set(i,n.cornerRadius,n.cornerSplit,lt);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 u=[],c=[],l=[],f=[];let y=0;if(0===o)return{position:u,normal:c,uv:l,indices:f,count:a};const x=r/s;let p,d=u.length-1,v=c.length-1,_=l.length-1,g=f.length-1;function z(t){const n=0===u.length,i=t.sharp&&!n,e=t.dist/s,o=t.dir,h=t.up,p=t.right;if(ft.copy(p).multiplyScalar(r*t.widthScale),yt.copy(p).multiplyScalar(-r*t.widthScale),ft.add(t.pos),yt.add(t.pos),i){xt.fromArray(u,u.length-6).sub(yt),pt.fromArray(u,u.length-3).sub(ft);const t=xt.length()-pt.length();let n,i;t>0?(n=xt,i=yt):(n=pt,i=ft),dt.copy(n).setLength(Math.abs(t)).add(i);let r=vt.copy(i).sub(dt).normalize().dot(o)*vt.copy(i).sub(dt).length()*2;vt.copy(o).setLength(r).add(dt),t>0?(u[++d]=dt.x,u[++d]=dt.y,u[++d]=dt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=vt.x,u[++d]=vt.y,u[++d]=vt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,y+=6,f[++g]=y-6,f[++g]=y-8,f[++g]=y-7,f[++g]=y-6,f[++g]=y-7,f[++g]=y-5,f[++g]=y-4,f[++g]=y-6,f[++g]=y-5,f[++g]=y-2,f[++g]=y-4,f[++g]=y-1,a+=12):(u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=dt.x,u[++d]=dt.y,u[++d]=dt.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=vt.x,u[++d]=vt.y,u[++d]=vt.z,y+=6,f[++g]=y-6,f[++g]=y-8,f[++g]=y-7,f[++g]=y-6,f[++g]=y-7,f[++g]=y-5,f[++g]=y-6,f[++g]=y-5,f[++g]=y-3,f[++g]=y-2,f[++g]=y-3,f[++g]=y-1,a+=12);for(let t=0;t<6;t++)c[++v]=h.x,c[++v]=h.y,c[++v]=h.z;l[++_]=e-x,l[++_]=0,l[++_]=e-x,l[++_]=1,l[++_]=e,l[++_]=0,l[++_]=e,l[++_]=1,l[++_]=e+x,l[++_]=0,l[++_]=e+x,l[++_]=1}else u[++d]=yt.x,u[++d]=yt.y,u[++d]=yt.z,u[++d]=ft.x,u[++d]=ft.y,u[++d]=ft.z,c[++v]=h.x,c[++v]=h.y,c[++v]=h.z,c[++v]=h.x,c[++v]=h.y,c[++v]=h.z,l[++_]=e,l[++_]=0,l[++_]=e,l[++_]=1,y+=2,n||(f[++g]=y-2,f[++g]=y-4,f[++g]=y-3,f[++g]=y-2,f[++g]=y-3,f[++g]=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 nt;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:u,normal:c,uv:l,indices:f,count:a}}(e,n);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}})),e=j(i);return e.lines=t,e},t.expandTubes=function(t,n){n=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n);const i=t.map((t=>{const i=Q(t),e=new ct;e.set(i,0,n.cornerSplit,_t);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 u=0;const c=[],l=[],f=[],y=[];let x=0,p=-1,d=-1,v=-1,_=-1;function g(t,n,i){const e=0===c.length,r=t.dist/o;for(let e=0;e<=i;e++){let o=e;o===i&&(o=0),gt.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();const h=n*t.widthScale;c[++p]=t.pos.x+gt.x*h,c[++p]=t.pos.y+gt.y*h,c[++p]=t.pos.z+gt.z*h,l[++d]=gt.x,l[++d]=gt.y,l[++d]=gt.z,f[++v]=r,f[++v]=e/i,x++}if(!e){const t=x-2*(i+1),n=x-(i+1);for(let e=0;e<i;e++)y[++_]=n+e,y[++_]=t+e,y[++_]=t+e+1,y[++_]=n+e,y[++_]=t+e+1,y[++_]=n+e+1,u+=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 nt,h=(a-s.dist)/(e.dist-s.dist);o.lerpPathPoints(s,e,h),g(o,i,r);break}g(e,i,r)}return{points:c,normal:l,uv:f,indices:y,count:u}}(e,n);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})),e=j(i);return e.lines=t,e},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);const i=t.map((t=>{for(let n=0,i=t.length;n<i;n++){const i=t[n];R(i),0===n?q(i)||(t[n]=i.reverse()):q(i)&&(t[n]=i.reverse()),W(i)&&i.splice(i.length-1,1)}const i=function(t,n){const i=function(t){let n=0,i=0;const e=t.length;for(;i<e;)n+=t[i].length,i++;return n}(t),e=t.length,r=[],s=new Float32Array(2*i),o=[],h=[],a=3*i,u=2*i,c=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]=c+x,o[a+f]=n,o[a+f+1]=r,o[a+f+2]=x,h[y]=n,h[y+1]=r,h[u+y]=n,h[u+y+1]=r,f+=3,y+=2,e++}}return{flatVertices:s,holes:r,points:o,count:i,uv:h}}(t,n);i.polygon=t;return function(t,n){const i=[],{count:e}=t;for(let t=0,r=n.length;t<r;t+=3){const s=n[t],o=n[t+1],h=n[t+2];i[t]=s,i[t+1]=o,i[t+2]=h;const a=r+t,u=e+s,c=e+o,l=e+h;i[a]=u,i[a+1]=c,i[a+2]=l}t.indices=i}(i,C(i.flatVertices,i.holes,2)),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 u=0;const c=n.length;for(;u<c;){const t=n[u];let r=n[u+1];u===c-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],v=r[2]||0;i[++h]=f,i[++h]=y,i[++h]=x+o,i[++h]=p,i[++h]=d,i[++h]=v+o,i[++h]=f,i[++h]=y,i[++h]=x,i[++h]=p,i[++h]=d,i[++h]=v;const _=l+2,g=l+3,z=l,m=l+1;e[++a]=_,e[++a]=z,e[++a]=g,e[++a]=z,e[++a]=m,e[++a]=g,T(s,i,_,g,z,m),u++}}}(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=U(i.indices,i.position),i})),e=j(i);return e.polygons=t,e},t.extrudePolylines=function(t,n){X(n=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},n));const i=t.map((t=>{const i=H(t,n);return i.line=t,B(i,n),Y(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=U(i.indices,i.position),i})),e=j(i);return e.lines=t,e},t.extrudeSlopes=function(t,n){X(n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},n));const{depth:i,side:e,sideDepth:r}=n,s=t.map((t=>{const s=H(t,n);s.line=t;const{leftPoints:o,rightPoints:h}=s,a={line:t};let u;for(let n=0,i=t.length;n<i;n++)t[n][2]=t[n][2]||0;return"left"===e?(a.leftPoints=o,a.rightPoints=t,u=[r,i]):(a.leftPoints=t,a.rightPoints=h,u=[i,r]),a.depths=u,B(a,n),Y(a,n),a.position=new Float32Array(a.points),a.indices=new Uint32Array(a.indices),a.uv=new Float32Array(a.uv),a.normal=U(a.indices,a.position),a})),o=j(s);return o.lines=t,o},t.isClockwise=q,t.leftOnLine=K,t.merge=j,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,u=(i+1)*(e+1),c=new Float32Array(3*u),l=new Float32Array(2*u),f=new Float32Array(3*u),y=new Uint32Array(10*u);let x=0,p=0,d=0;for(let u=0;u<=e;u++)for(let v=0;v<=i;v++){const _=o+r*v,g=h-s*u;c[x]=_,c[x+1]=g,c[x+2]=0,f[x]=0,f[x+1]=0,f[x+2]=1;const z=(_-o)/t,m=(g-a)/n;if(l[p]=z,l[p+1]=m,x+=3,p+=2,v<i&&u<e){const t=u*(i+1)+v,n=t+1,e=(i+1)*(u+1)+v,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 v=new Uint32Array(d);for(let t=0,n=v.length;t<n;t++)v[t]=y[t];return{position:c,uv:l,normal:f,indices:v}},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.14.0
2
+ * poly-extrude v0.15.0
3
3
  */
4
4
  var earcut$2 = {exports: {}};
5
5
 
@@ -4430,5 +4430,5 @@ function plane(width, height, devideW, devideH) {
4430
4430
  };
4431
4431
  }
4432
4432
 
4433
- export { cylinder, expandLine, expandPaths, expandTubes, extrudePolygons, extrudePolylines, extrudeSlopes, leftOnLine, plane };
4433
+ export { cylinder, expandLine, expandPaths, expandTubes, extrudePolygons, extrudePolylines, extrudeSlopes, isClockwise, leftOnLine, merge, plane };
4434
4434
  //# sourceMappingURL=poly-extrude.mjs.map