poly-extrude 0.11.0 → 0.13.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.11.0
2
+ * poly-extrude v0.13.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 e,h,a,o,u,x,f,v=n&&n.length,p=v?n[0]*i:t.length,d=r(t,0,p,i,!0),_=[];if(!d||d.next===d.prev)return _;if(v&&(d=function(t,n,i,e){var s,h,a,o=[];for(s=0,h=n.length;s<h;s++)(a=r(t,n[s]*e,s<h-1?n[s+1]*e:t.length,e,!1))===a.next&&(a.steiner=!0),o.push(y(a));for(o.sort(c),s=0;s<o.length;s++)i=l(o[s],i);return i}(t,n,d,i)),t.length>80*i){e=a=t[0],h=o=t[1];for(var g=i;g<p;g+=i)(u=t[g])<e&&(e=u),(x=t[g+1])<h&&(h=x),u>a&&(a=u),x>o&&(o=x);f=0!==(f=Math.max(a-e,o-h))?32767/f:0}return s(d,_,i,e,h,f,0),_}function r(t,n,i,r,e){var s,h;if(e===S(t,n,i,r)>0)for(s=n;s<i;s+=r)h=b(s,t[s],t[s+1],h);else for(s=i-r;s>=n;s-=r)h=b(s,t[s],t[s+1],h);return h&&_(h,h.next)&&(P(h),h=h.next),h}function e(t,n){if(!t)return t;n||(n=t);var i,r=t;do{if(i=!1,r.steiner||!_(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(P(r),(r=n=r.prev)===r.next)break;i=!0}}while(i||r!==n);return n}function s(t,n,i,r,c,l,x){if(t){!x&&l&&function(t,n,i,r){var e=t;do{0===e.z&&(e.z=f(e.x,e.y,n,i,r)),e.prevZ=e.prev,e.nextZ=e.next,e=e.next}while(e!==t);e.prevZ.nextZ=null,e.prevZ=null,function(t){var n,i,r,e,s,h,a,o,u=1;do{for(i=t,t=null,s=null,h=0;i;){for(h++,r=i,a=0,n=0;n<u&&(a++,r=r.nextZ);n++);for(o=u;a>0||o>0&&r;)0!==a&&(0===o||!r||i.z<=r.z)?(e=i,i=i.nextZ,a--):(e=r,r=r.nextZ,o--),s?s.nextZ=e:t=e,e.prevZ=s,s=e;i=r}s.nextZ=null,u*=2}while(h>1)}(e)}(t,r,c,l);for(var y,v,p=t;t.prev!==t.next;)if(y=t.prev,v=t.next,l?a(t,r,c,l):h(t))n.push(y.i/i|0),n.push(t.i/i|0),n.push(v.i/i|0),P(t),t=v.next,p=v.next;else if((t=v)===p){x?1===x?s(t=o(e(t),n,i),n,i,r,c,l,2):2===x&&u(t,n,i,r,c,l):s(e(t),n,i,r,c,l,1);break}}}function h(t){var n=t.prev,i=t,r=t.next;if(d(n,i,r)>=0)return!1;for(var e=n.x,s=i.x,h=r.x,a=n.y,o=i.y,u=r.y,c=e<s?e<h?e:h:s<h?s:h,l=a<o?a<u?a:u:o<u?o:u,x=e>s?e>h?e:h:s>h?s:h,f=a>o?a>u?a:u:o>u?o:u,y=r.next;y!==n;){if(y.x>=c&&y.x<=x&&y.y>=l&&y.y<=f&&v(e,a,s,o,h,u,y.x,y.y)&&d(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function a(t,n,i,r){var e=t.prev,s=t,h=t.next;if(d(e,s,h)>=0)return!1;for(var a=e.x,o=s.x,u=h.x,c=e.y,l=s.y,x=h.y,y=a<o?a<u?a:u:o<u?o:u,p=c<l?c<x?c:x:l<x?l:x,_=a>o?a>u?a:u:o>u?o:u,g=c>l?c>x?c:x:l>x?l:x,z=f(y,p,n,i,r),m=f(_,g,n,i,r),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=y&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&v(a,c,o,l,u,x,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=y&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&v(a,c,o,l,u,x,M.x,M.y)&&d(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=y&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&v(a,c,o,l,u,x,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=y&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&v(a,c,o,l,u,x,M.x,M.y)&&d(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function o(t,n,i){var r=t;do{var s=r.prev,h=r.next.next;!_(s,h)&&g(s,r,r.next,h)&&w(s,h)&&w(h,s)&&(n.push(s.i/i|0),n.push(r.i/i|0),n.push(h.i/i|0),P(r),P(r.next),r=t=h),r=r.next}while(r!==t);return e(r)}function u(t,n,i,r,h,a){var o=t;do{for(var u=o.next.next;u!==o.prev;){if(o.i!==u.i&&p(o,u)){var c=M(o,u);return o=e(o,o.next),c=e(c,c.next),s(o,n,i,r,h,a,0),void s(c,n,i,r,h,a,0)}u=u.next}o=o.next}while(o!==t)}function c(t,n){return t.x-n.x}function l(t,n){var i=function(t,n){var i,r=n,e=t.x,s=t.y,h=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=e&&a>h&&(h=a,i=r.x<r.next.x?r:r.next,a===e))return i}r=r.next}while(r!==n);if(!i)return null;var o,u=i,c=i.x,l=i.y,f=1/0;r=i;do{e>=r.x&&r.x>=c&&e!==r.x&&v(s<l?e:h,s,c,l,s<l?h:e,s,r.x,r.y)&&(o=Math.abs(s-r.y)/(e-r.x),w(r,t)&&(o<f||o===f&&(r.x>i.x||r.x===i.x&&x(i,r)))&&(i=r,f=o)),r=r.next}while(r!==u);return i}(t,n);if(!i)return n;var r=M(i,t);return e(r,r.next),e(i,i.next)}function x(t,n){return d(t.prev,t,n.prev)<0&&d(n.next,t,t.next)<0}function f(t,n,i,r,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*e|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*e|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function y(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 v(t,n,i,r,e,s,h,a){return(e-h)*(n-a)>=(t-h)*(s-a)&&(t-h)*(r-a)>=(i-h)*(n-a)&&(i-h)*(s-a)>=(e-h)*(r-a)}function p(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,r=!1,e=(t.x+n.x)/2,s=(t.y+n.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&e<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,n)&&(d(t.prev,t,n.prev)||d(t,n.prev,n))||_(t,n)&&d(t.prev,t,t.next)>0&&d(n.prev,n,n.next)>0)}function d(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,r){var e=m(d(t,n,i)),s=m(d(t,n,r)),h=m(d(i,r,t)),a=m(d(i,r,n));return e!==s&&h!==a||(!(0!==e||!z(t,i,n))||(!(0!==s||!z(t,r,n))||(!(0!==h||!z(i,t,r))||!(0!==a||!z(i,n,r)))))}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 d(t.prev,t,t.next)<0?d(t,n,t.next)>=0&&d(t,t.prev,n)>=0:d(t,n,t.prev)<0||d(t,t.next,n)<0}function M(t,n){var i=new A(t.i,t.x,t.y),r=new A(n.i,n.x,n.y),e=t.next,s=n.prev;return t.next=n,n.prev=t,i.next=e,e.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function b(t,n,i,r){var e=new A(t,n,i);return r?(e.next=r.next,e.prev=r,r.next.prev=e,r.next=e):(e.prev=e,e.next=e),e}function P(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,n,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,r){for(var e=0,s=n,h=i-r;s<i;s+=r)e+=(t[h]-t[s])*(t[s+1]+t[h+1]),h=s;return e}n.exports=i,n.exports.default=i,i.deviation=function(t,n,i,r){var e=n&&n.length,s=e?n[0]*i:t.length,h=Math.abs(S(t,0,s,i));if(e)for(var a=0,o=n.length;a<o;a++){var u=n[a]*i,c=a<o-1?n[a+1]*i:t.length;h-=Math.abs(S(t,u,c,i))}var l=0;for(a=0;a<r.length;a+=3){var x=r[a]*i,f=r[a+1]*i,y=r[a+2]*i;l+=Math.abs((t[x]-t[y])*(t[f+1]-t[x+1])-(t[x]-t[f])*(t[y+1]-t[x+1]))}return 0===h&&0===l?0:Math.abs((l-h)/h)},i.flatten=function(t){for(var n=t[0][0].length,i={vertices:[],holes:[],dimensions:n},r=0,e=0;e<t.length;e++){for(var s=0;s<t[e].length;s++)for(var h=0;h<n;h++)i.vertices.push(t[e][s][h]);e>0&&(r+=t[e-1].length,i.holes.push(r))}return i};var C=n.exports;function k(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function Z(t,n){return Z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Z(t,n)}var V=new(function(){function t(t,n,i,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=1),this.isQuaternion=!0,this._x=t,this._y=n,this._z=i,this._w=r}t.slerpFlat=function(t,n,i,r,e,s,h){var a=i[r+0],o=i[r+1],u=i[r+2],c=i[r+3],l=e[s+0],x=e[s+1],f=e[s+2],y=e[s+3];if(0===h)return t[n+0]=a,t[n+1]=o,t[n+2]=u,void(t[n+3]=c);if(1===h)return t[n+0]=l,t[n+1]=x,t[n+2]=f,void(t[n+3]=y);if(c!==y||a!==l||o!==x||u!==f){var v=1-h,p=a*l+o*x+u*f+c*y,d=p>=0?1:-1,_=1-p*p;if(_>Number.EPSILON){var g=Math.sqrt(_),z=Math.atan2(g,p*d);v=Math.sin(v*z)/g,h=Math.sin(h*z)/g}var m=h*d;if(a=a*v+l*m,o=o*v+x*m,u=u*v+f*m,c=c*v+y*m,v===1-h){var w=1/Math.sqrt(a*a+o*o+u*u+c*c);a*=w,o*=w,u*=w,c*=w}}t[n]=a,t[n+1]=o,t[n+2]=u,t[n+3]=c},t.multiplyQuaternionsFlat=function(t,n,i,r,e,s){var h=i[r],a=i[r+1],o=i[r+2],u=i[r+3],c=e[s],l=e[s+1],x=e[s+2],f=e[s+3];return t[n]=h*f+u*c+a*x-o*l,t[n+1]=a*f+u*l+o*c-h*x,t[n+2]=o*f+u*x+h*l-a*c,t[n+3]=u*f-h*c-a*l-o*x,t};var n,i,r,e=t.prototype;return e.set=function(t,n,i,r){return this._x=t,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this},e.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)},e.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},e.setFromEuler=function(t,n){void 0===n&&(n=!0);var i=t._x,r=t._y,e=t._z,s=t._order,h=Math.cos,a=Math.sin,o=h(i/2),u=h(r/2),c=h(e/2),l=a(i/2),x=a(r/2),f=a(e/2);switch(s){case"XYZ":this._x=l*u*c+o*x*f,this._y=o*x*c-l*u*f,this._z=o*u*f+l*x*c,this._w=o*u*c-l*x*f;break;case"YXZ":this._x=l*u*c+o*x*f,this._y=o*x*c-l*u*f,this._z=o*u*f-l*x*c,this._w=o*u*c+l*x*f;break;case"ZXY":this._x=l*u*c-o*x*f,this._y=o*x*c+l*u*f,this._z=o*u*f+l*x*c,this._w=o*u*c-l*x*f;break;case"ZYX":this._x=l*u*c-o*x*f,this._y=o*x*c+l*u*f,this._z=o*u*f-l*x*c,this._w=o*u*c+l*x*f;break;case"YZX":this._x=l*u*c+o*x*f,this._y=o*x*c+l*u*f,this._z=o*u*f-l*x*c,this._w=o*u*c-l*x*f;break;case"XZY":this._x=l*u*c-o*x*f,this._y=o*x*c-l*u*f,this._z=o*u*f+l*x*c,this._w=o*u*c+l*x*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===n&&this._onChangeCallback(),this},e.setFromAxisAngle=function(t,n){var i=n/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this},e.setFromRotationMatrix=function(t){var n=t.elements,i=n[0],r=n[4],e=n[8],s=n[1],h=n[5],a=n[9],o=n[2],u=n[6],c=n[10],l=i+h+c;if(l>0){var x=.5/Math.sqrt(l+1);this._w=.25/x,this._x=(u-a)*x,this._y=(e-o)*x,this._z=(s-r)*x}else if(i>h&&i>c){var f=2*Math.sqrt(1+i-h-c);this._w=(u-a)/f,this._x=.25*f,this._y=(r+s)/f,this._z=(e+o)/f}else if(h>c){var y=2*Math.sqrt(1+h-i-c);this._w=(e-o)/y,this._x=(r+s)/y,this._y=.25*y,this._z=(a+u)/y}else{var v=2*Math.sqrt(1+c-i-h);this._w=(s-r)/v,this._x=(e+o)/v,this._y=(a+u)/v,this._z=.25*v}return this._onChangeCallback(),this},e.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()},e.rotateTowards=function(t,n){var i=this.angleTo(t);if(0===i)return this;var r=Math.min(1,n/i);return this.slerp(t,r),this},e.identity=function(){return this.set(0,0,0,1)},e.invert=function(){return this.conjugate()},e.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},e.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},e.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},e.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.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},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,n){var i=t._x,r=t._y,e=t._z,s=t._w,h=n._x,a=n._y,o=n._z,u=n._w;return this._x=i*u+s*h+r*o-e*a,this._y=r*u+s*a+e*h-i*o,this._z=e*u+s*o+i*a-r*h,this._w=s*u-i*h-r*a-e*o,this._onChangeCallback(),this},e.slerp=function(t,n){if(0===n)return this;if(1===n)return this.copy(t);var i=this._x,r=this._y,e=this._z,s=this._w,h=s*t._w+i*t._x+r*t._y+e*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=s,this._x=i,this._y=r,this._z=e,this;var a=1-h*h;if(a<=Number.EPSILON){var o=1-n;return this._w=o*s+n*this._w,this._x=o*i+n*this._x,this._y=o*r+n*this._y,this._z=o*e+n*this._z,this.normalize(),this}var u=Math.sqrt(a),c=Math.atan2(u,h),l=Math.sin((1-n)*c)/u,x=Math.sin(n*c)/u;return this._w=s*l+this._w*x,this._x=i*l+this._x*x,this._y=r*l+this._y*x,this._z=e*l+this._z*x,this._onChangeCallback(),this},e.slerpQuaternions=function(t,n,i){return this.copy(t).slerp(n,i)},e.random=function(){var t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),e=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),e*Math.sin(n),e*Math.cos(n))},e.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},e.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},e.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},e.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},e.toJSON=function(){return this.toArray()},e._onChange=function(t){return this._onChangeCallback=t,this},e._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),r&&k(n,r),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(V.setFromAxisAngle(t,n))},n.applyMatrix4=function(t){var n=this.x,i=this.y,r=this.z,e=t.elements,s=1/(e[3]*n+e[7]*i+e[11]*r+e[15]);return this.x=(e[0]*n+e[4]*i+e[8]*r+e[12])*s,this.y=(e[1]*n+e[5]*i+e[9]*r+e[13])*s,this.z=(e[2]*n+e[6]*i+e[10]*r+e[14])*s,this},n.applyQuaternion=function(t){var n=this.x,i=this.y,r=this.z,e=t.x,s=t.y,h=t.z,a=t.w,o=a*n+s*r-h*i,u=a*i+h*n-e*r,c=a*r+e*i-s*n,l=-e*n-s*i-h*r;return this.x=o*a+l*-e+u*-h-c*-s,this.y=u*a+l*-s+c*-e-o*-h,this.z=c*a+l*-h+o*-s-u*-e,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,r=t.y,e=t.z,s=n.x,h=n.y,a=n.z;return this.x=r*a-e*h,this.y=e*s-i*a,this.z=i*h-r*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){for(var n,i,r=0,e=1,s=t.length;e<s;)n=i||t[0],r+=((i=t[e])[0]-n[0])*(i[1]+n[1]),e++;return r>0}function q(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){var i=n[0],r=n[1],e=n[2],s=Math.sqrt(i*i+r*r+e*e)||1;return t[0]=i/s,t[1]=r/s,t[2]=e/s,t}function I(t,n){function i(t,n,i,r){t[0]=n,t[1]=i,t[2]=r}for(var r,e,s,h,a,o,u,c,l,x=[],f=[],y=[],v=[],p=[],d=[],_=t.length,g=new Float32Array(n.length),z=0;z<_;){var m=3*t[z],w=3*t[z+1],M=3*t[z+2];i(x,n[m],n[m+1],n[m+2]),i(f,n[w],n[w+1],n[w+2]),i(y,n[M],n[M+1],n[M+2]),q(p,y,f),q(v,x,f),r=d,s=v,h=void 0,a=void 0,o=void 0,u=void 0,c=void 0,l=void 0,h=(e=p)[0],a=e[1],o=e[2],u=s[0],c=s[1],l=s[2],r[0]=a*l-o*c,r[1]=o*u-h*l,r[2]=h*c-a*u;for(var b=0;b<3;b++)g[m+b]+=d[b],g[w+b]+=d[b],g[M+b]+=d[b];z+=3}for(var P=0,A=g.length;P<A;)i(d,g[P],g[P+1],g[P+2]),O(d,d),g[P]=d[0]||0,g[P+1]=d[1]||0,g[P+2]=d[2]||0,P+=3;return g}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};for(var n=0,i=0,r=0,e=t.length;r<e;r++){var s=t[r],h=s.position,a=s.indices;n+=h.length,i+=a.length}for(var o={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(i),results:t},u=0,c=0,l=0,x=0,f=0,y=t.length;f<y;f++){var v=t[f],p=v.position,d=v.indices,_=v.normal,g=v.uv;o.position.set(p,u),o.normal.set(_,u),o.uv.set(g,x);for(var z=0,m=d.length;z<m;){var w=d[z]+c;o.indices[l]=w,l++,z++}x+=g.length,u+=p.length,c+=p.length/3}return o}function U(t){return 180*t/Math.PI}function E(t){return t/180*Math.PI}function N(t,n,i,r,e,s){var h=3*i,a=3*r,o=3*e,u=3*s,c=n[h],l=n[h+1],x=n[h+2],f=n[a],y=n[a+1],v=n[a+2],p=n[o],d=n[o+1],_=n[o+2],g=n[u],z=n[u+1],m=n[u+2],w=t.length-1;Math.abs(l-y)<Math.abs(c-f)?(t[++w]=c,t[++w]=1-x,t[++w]=f,t[++w]=1-v,t[++w]=p,t[++w]=1-_,t[++w]=g,t[++w]=1-m):(t[++w]=l,t[++w]=1-x,t[++w]=y,t[++w]=1-v,t[++w]=d,t[++w]=1-_,t[++w]=z,t[++w]=1-m)}function T(t){for(var n=[],i=0,r=t.length;i<r;i++){var e=t[i],s=e[0],h=e[1],a=e[2],o=new F(s,h,a||0);n[i]=o}return n}function Q(t){R(t)||t.push(t[0])}function R(t){var n=t.length,i=t[0],r=i[0],e=i[1],s=t[n-1],h=s[0],a=s[1];return r===h&&e===a}function W(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function X(t,n){var i=n.bottomStickGround,r=n.depth,e=t.depths,s=r,h=r;e&&(s=e[0],h=e[1]);for(var a=[],o=[],u=[],c=t.leftPoints,l=t.rightPoints,x=0,f=c.length;x<f;){var y=3*x,v=c[x],p=v[0],d=v[1],_=v[2];a[y]=p,a[y+1]=d,a[y+2]=s+_;var g=l[x],z=g[0],m=g[1],w=g[2],M=3*f+y;a[M]=z,a[M+1]=m,a[M+2]=h+w;var b=2*f*3+y;a[b]=p,a[b+1]=d,a[b+2]=_,i&&(a[b+2]=0);var P=2*f*3+3*f+y;a[P]=z,a[P+1]=m,a[P+2]=w,i&&(a[P+2]=0),x++}x=0,f=a.length;for(var A=u.length-1;x<f;){var S=a[x],C=a[x+1];u[++A]=S,u[++A]=C,x+=3}x=0,f=c.length;for(var k=o.length-1;x<f-1;){var Z=x,V=x+1,F=Z+f,L=V+f;o[++k]=Z,o[++k]=F,o[++k]=V,o[++k]=F,o[++k]=L,o[++k]=V;var q=x+2*f,O=q+1,I=q+f,j=O+f;o[++k]=q,o[++k]=I,o[++k]=O,o[++k]=I,o[++k]=j,o[++k]=O,x++}if(t.indices=o,t.points=a,t.uv=u,e)for(f=c.length,x=0;x<f;)c[x].depth=s,l[x].depth=h,x++}function B(t,n){var i=t.points,r=t.indices,e=t.leftPoints,s=t.rightPoints,h=t.uv,a=n.depth,o=n.bottomStickGround,u=[e,s],c=t.depths,l=i.length-1,x=r.length-1;function f(t,n){var e=i.length/3;i[++l]=t[0],i[++l]=t[1],i[++l]=(c?t.depth:a)+t[2],i[++l]=n[0],i[++l]=n[1],i[++l]=(c?n.depth:a)+n[2],i[++l]=t[0],i[++l]=t[1],i[++l]=o?0:t[2],i[++l]=n[0],i[++l]=n[1],i[++l]=o?0:n[2];var s=e+2,u=e+3,f=e,y=e+1;r[++x]=s,r[++x]=f,r[++x]=u,r[++x]=f,r[++x]=y,r[++x]=u,N(h,i,s,u,f,y)}for(var y=0,v=u.length;y<v;y++){var p=u[y];y>0&&(p=(p=p.map((function(t){return t}))).reverse());for(var d=0,_=p.length-1;d<_;){f(p[d],p[d+1]),d++}}for(var g=e.length,z=[s[0],e[0],e[g-1],s[g-1]],m=0;m<z.length;m+=2){f(z[m],z[m+1])}}var Y={x:0,y:0},D={x:0,y:0};function G(t,n){for(var i=n.lineWidth/2,r=[],e=[],s=[],h=t.length,a=0;a<h;){var o=t[a],u=t[a+1],c=t[a];a===h-1&&(o=t[h-2],u=t[h-1]);var l=u[1]-o[1],x=u[0]-o[0],f=0,y=U(Math.atan(l/x));if(0===a||a===h-1)f=y,f-=90;else{var v=t[a-1];Y.x=v[0]-o[0],Y.y=v[1]-o[1],D.x=u[0]-o[0],D.y=u[1]-o[1],f=y-H(Y,D)/2}var p=E(f),d=c,_=[Math.cos(p)+d[0],Math.sin(p)+d[1]],g=K(o,u,i),z=g[0],m=g[1],w=$(z[0],z[1],d,_),M=$(m[0],m[1],d,_);if(!w||!M){var b=r.length,P=r[b-2],A=r[b-1];if(!P||!A)continue;w=[P[0],P[1]],M=[A[0],A[1]]}w[2]=c[2]||0,M[2]=c[2]||0,r.push(w,M),J(w,o,u)?(e.push(w),s.push(M)):(e.push(M),s.push(w)),a++}return{offsetPoints:r,leftPoints:e,rightPoints:s}}var H=function(t,n){var i=t.x,r=t.y,e=n.x,s=n.y,h=i*e+r*s,a=i*s-r*e;return(Math.atan2(a,h)/Math.PI*180+360)%360};function J(t,n,i){var r=n[0],e=n[1],s=i[0],h=i[1];return(e-h)*t[0]+(s-r)*t[1]+r*h-s*e>0}function K(t,n,i){var r=n[1]-t[1],e=n[0]-t[0],s=Math.atan2(r,e),h=s+Math.PI/2,a=Math.cos(h)*i,o=Math.sin(h)*i,u=[t[0]+a,t[1]+o],c=[n[0]+a,n[1]+o],l=s-Math.PI/2;return a=Math.cos(l)*i,o=Math.sin(l)*i,[[u,c],[[t[0]+a,t[1]+o],[n[0]+a,n[1]+o]]]}function $(t,n,i,r){var e=n[0]-t[0],s=n[1]-t[1],h=r[0]-i[0],a=r[1]-i[1];if(0===e&&0===h)return null;if(0===s&&0===a)return null;var o,u,c=s/e,l=a/h,x=t[1]-c*t[0],f=i[1]-l*i[0];return 0===e?u=l*(o=t[0])+f:0===h?u=c*(o=i[0])+x:0===s?o=((u=t[1])-f)/l:0===a?o=((u=i[1])-x)/c:u=c*(o=(f-x)/(c-l))+x,[o,u]}var tt=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}(),nt=function(){function t(t,n,i,r,e,s,h,a,o,u,c,l,x,f,y,v){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,r,e,s,h,a,o,u,c,l,x,f,y,v)}var n=t.prototype;return n.set=function(t,n,i,r,e,s,h,a,o,u,c,l,x,f,y,v){var p=this.elements;return p[0]=t,p[4]=n,p[8]=i,p[12]=r,p[1]=e,p[5]=s,p[9]=h,p[13]=a,p[2]=o,p[6]=u,p[10]=c,p[14]=l,p[3]=x,p[7]=f,p[11]=y,p[15]=v,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var i=Math.cos(n),r=Math.sin(n),e=1-i,s=t.x,h=t.y,a=t.z,o=e*s,u=e*h;return this.set(o*s+i,o*h-r*a,o*a+r*h,0,o*h+r*a,u*h+i,u*a-r*s,0,o*a-r*h,u*a+r*s,e*a*a+i,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,i=t.elements,r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0},t}();function it(t,n,i,r){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,r)}var rt=function(t){var n,i;function r(n,i,r){var e;return void 0===n&&(n=new F),void 0===i&&(i=new F),void 0===r&&(r=new F),(e=t.call(this)||this).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=n,e.v1=i,e.v2=r,e}return i=t,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,Z(n,i),r.prototype.getPoint=function(t,n){void 0===n&&(n=new F);var i=n,r=this.v0,e=this.v1,s=this.v2;return i.set(it(t,r.x,e.x,s.x),it(t,r.y,e.y,s.y),it(t,r.z,e.z,s.z)),i},r}(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=[],r=this.getPoint(0),e=0;i.push(0);for(var s=1;s<=t;s++)e+=(n=this.getPoint(s/t)).distanceTo(r),i.push(e),r=n;return this.cacheArcLengths=i,i},n.getUtoTmapping=function(t,n){var i,r=this.getLengths(),e=0,s=r.length;i=n||t*r[s-1];for(var h,a=0,o=s-1;a<=o;)if((h=r[e=Math.floor(a+(o-a)/2)]-i)<0)a=e+1;else{if(!(h>0)){o=e;break}o=e-1}if(r[e=o]===i)return e/(s-1);var u=r[e];return(e+(i-u)/(r[e+1]-u))/(s-1)},t}()),et=new F,st=new F,ht=new F,at=new nt,ot=new rt;var ut=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,i,r,e){if(void 0===n&&(n=.1),void 0===i&&(i=10),void 0===r&&(r=null),void 0===e&&(e=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);e&&!t[0].equals(t[t.length-1])&&t.push((new F).copy(t[0]));for(var s=0,h=t.length;s<h;s++)if(0===s)this._start(t[s],t[s+1],r);else if(s===h-1)if(e){this._corner(t[s],t[1],n,i,r);var a=this.array[0].dist;this.array[0].copy(this.array[this.count-1]),this.array[0].dist=a}else this._end(t[s]);else this._corner(t[s],t[s+1],n,i,r)},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 tt),this.array[t]},n._start=function(t,n,i){this.count=0;var r=this._getByIndex(this.count);if(r.pos.copy(t),r.dir.subVectors(n,t),i)r.up.copy(i);else{var e=Number.MAX_VALUE,s=Math.abs(r.dir.x),h=Math.abs(r.dir.y),a=Math.abs(r.dir.z);s<e&&(e=s,r.up.set(1,0,0)),h<e&&(e=h,r.up.set(0,1,0)),a<e&&r.up.set(0,0,1)}r.right.crossVectors(r.dir,r.up).normalize(),r.up.crossVectors(r.right,r.dir).normalize(),r.dist=0,r.widthScale=1,r.sharp=!1,r.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 r=i.dir.length();i.dir.normalize(),i.up.copy(n.up);var e=et.crossVectors(n.dir,i.dir);if(e.length()>Number.EPSILON){e.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(i.dir),-1),1));i.up.applyMatrix4(at.makeRotationAxis(e,s))}i.right.crossVectors(i.dir,i.up).normalize(),i.dist=n.dist+r,i.widthScale=1,i.sharp=!1,this.count++},n._corner=function(t,n,i,r,e){if(i>0&&r>0){for(var s=function(t,n,i,r,e,s){var h=et.subVectors(n,t),a=st.subVectors(i,n),o=h.length(),u=a.length();h.normalize(),a.normalize();var c=Math.min(.999999*(e?o/2:o),r);s.v0.copy(n).sub(h.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/2*.999999,r);return s.v2.copy(n).add(a.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,i,this.count-1==0,ot),h=s.getPoints(r),a=0;a<r;a++)this._sharpCorner(h[a],h[a+1],e,0===a?1:0);h[r].equals(n)||this._sharpCorner(h[r],n,e,2)}else this._sharpCorner(t,n,e,0,!0)},n._sharpCorner=function(t,n,i,r,e){void 0===r&&(r=0),void 0===e&&(e=!1);var s=this.array[this.count-1],h=this._getByIndex(this.count),a=et.subVectors(t,s.pos),o=st.subVectors(n,t),u=a.length();if(a.normalize(),o.normalize(),h.pos.copy(t),1===r?h.dir.copy(a):2===r?h.dir.copy(o):(h.dir.addVectors(a,o),h.dir.normalize()),i)1===h.dir.dot(i)?h.right.crossVectors(o,i).normalize():h.right.crossVectors(h.dir,i).normalize(),h.up.crossVectors(h.right,h.dir).normalize();else{h.up.copy(s.up);var c=ht.crossVectors(s.dir,h.dir);if(c.length()>Number.EPSILON){c.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(h.dir),-1),1));h.up.applyMatrix4(at.makeRotationAxis(c,l))}h.right.crossVectors(h.dir,h.up).normalize()}h.dist=s.dist+u;var x=a.dot(o);h.widthScale=Math.min(1/Math.sqrt((1+x)/2),1.415)||1,h.sharp=Math.abs(x-1)>.05&&e,this.count++},t}(),ct=new F(0,0,1),lt=new F,xt=new F,ft=new F,yt=new F,vt=new F,pt=new F;var dt=new F(0,0,1),_t=new F;t.cylinder=function(t,n){void 0===n&&(n={}),n=Object.assign({},{radius:1,height:2,radialSegments:6},n);for(var i=Math.round(Math.max(4,n.radialSegments)),r=n,e=r.radius,s=r.height,h=360/i/360*Math.PI*2,a=i+1,o=new Float32Array(3*a*2),u=t[0],c=t[1],l=0,x=0,f=3*a,y=2*a,v=[],p=[],d=v.length-1,_=-1;_<i;_++){var g=h*_,z=Math.cos(g)*e+u,m=Math.sin(g)*e+c;o[l]=z,o[l+1]=m,o[l+2]=0,o[l+f]=z,o[l+1+f]=m,o[l+2+f]=s;var w,M;w=.5+z/e/2,M=.5+m/e/2,p[x]=w,p[x+1]=M,p[x+y]=w,p[x+1+y]=M,l+=3,x+=2,_>1&&(v[++d]=0,v[++d]=_-1,v[++d]=_)}o[l-=3]=o[0],o[l+1]=o[1],o[l+2]=o[2];var b=o.length;o[b-3]=o[0],o[b-2]=o[1],o[b-1]=s;var P=v.length;d=v.length-1;for(var A=0;A<P;A++){var S=v[A];v[++d]=S+a}var C=new Float32Array(2*(3*a*2-6)),k=-1;l=2*a,x=0,d=v.length-1;for(var Z=p.length-1,V=0,F=o.length/2;V<F-3;V+=3){var L=o[V],q=o[V+1],O=o[V+3],j=o[V+4];C[++k]=L,C[++k]=q,C[++k]=s,C[++k]=O,C[++k]=j,C[++k]=s,C[++k]=L,C[++k]=q,C[++k]=0,C[++k]=O,C[++k]=j,C[++k]=0;var U=l+2,E=l+3,N=l,T=l+1;v[++d]=N,v[++d]=U,v[++d]=T,v[++d]=U,v[++d]=E,v[++d]=T,l+=4;var Q=x/a,R=(x+1)/a;p[++Z]=Q,p[++Z]=s/e/2,p[++Z]=R,p[++Z]=s/e/2,p[++Z]=Q,p[++Z]=0,p[++Z]=R,p[++Z]=0,x++}var W=new Float32Array(o.length+C.length);W.set(o,0),W.set(C,o.length);var X=I(v,W);return{points:o,indices:new Uint32Array(v),position:W,normal:X,uv:new Float32Array(p)}},t.expandLine=G,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);var i=t.map((function(t){var i=T(t),r=new ut;r.set(i,n.cornerRadius,n.cornerSplit,ct);var e=function(t,n){var i=n.lineWidth||.1,r=1,e=i/2,s=i,h=t.distance(),a=r*h;if(0===h)return null;var o,u=e/s,c=0,l=[],x=[],f=[],y=[],v=0,p=l.length-1,d=x.length-1,_=f.length-1,g=y.length-1;function z(t){var n=0===l.length,i=t.sharp&&!n,r=t.dist/s,h=t.dir,a=t.up,o=t.right;if(lt.copy(o).multiplyScalar(e*t.widthScale),xt.copy(o).multiplyScalar(-e*t.widthScale),lt.add(t.pos),xt.add(t.pos),i){ft.fromArray(l,l.length-6).sub(xt),yt.fromArray(l,l.length-3).sub(lt);var z,m,w=ft.length()-yt.length();w>0?(z=ft,m=xt):(z=yt,m=lt),vt.copy(z).setLength(Math.abs(w)).add(m);var M=pt.copy(m).sub(vt).normalize().dot(h)*pt.copy(m).sub(vt).length()*2;pt.copy(h).setLength(M).add(vt),w>0?(l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=pt.x,l[++p]=pt.y,l[++p]=pt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,v+=6,y[++g]=v-6,y[++g]=v-8,y[++g]=v-7,y[++g]=v-6,y[++g]=v-7,y[++g]=v-5,y[++g]=v-4,y[++g]=v-6,y[++g]=v-5,y[++g]=v-2,y[++g]=v-4,y[++g]=v-1,c+=12):(l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=pt.x,l[++p]=pt.y,l[++p]=pt.z,v+=6,y[++g]=v-6,y[++g]=v-8,y[++g]=v-7,y[++g]=v-6,y[++g]=v-7,y[++g]=v-5,y[++g]=v-6,y[++g]=v-5,y[++g]=v-3,y[++g]=v-2,y[++g]=v-3,y[++g]=v-1,c+=12);for(var b=0;b<6;b++)x[++d]=a.x,x[++d]=a.y,x[++d]=a.z;f[++_]=r-u,f[++_]=0,f[++_]=r-u,f[++_]=1,f[++_]=r,f[++_]=0,f[++_]=r,f[++_]=1,f[++_]=r+u,f[++_]=0,f[++_]=r+u,f[++_]=1}else l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,x[++d]=a.x,x[++d]=a.y,x[++d]=a.z,x[++d]=a.x,x[++d]=a.y,x[++d]=a.z,f[++_]=r,f[++_]=0,f[++_]=r,f[++_]=1,v+=2,n||(y[++g]=v-2,y[++g]=v-4,y[++g]=v-3,y[++g]=v-2,y[++g]=v-3,y[++g]=v-1,c+=6)}if(a>0)for(var m=0;m<t.count;m++){var w=t.array[m];if(w.dist>a){var M=t.array[m-1];o=new tt;var b=(a-M.dist)/(w.dist-M.dist);o.lerpPathPoints(M,w,b),z(o);break}z(w)}else o=t.array[0];return{position:l,normal:x,uv:f,indices:y,count:c}}(r,n);return e.line=t,e.position=new Float32Array(e.position),e.indices=new Uint32Array(e.indices),e.uv=new Float32Array(e.uv),e.normal=new Float32Array(e.normal),e})),r=j(i);return r.lines=t,r},t.expandTubes=function(t,n){n=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n);var i=t.map((function(t){var i=T(t),r=new ut;r.set(i,n.cornerRadius,n.cornerSplit,dt);var e=function(t,n){var i=Math.max(n.radius||1,1e-8),r=void 0!==n.progress?n.progress:1,e=Math.max(3,n.radialSegments||8),s=n.startRad||0,h=2*i*Math.PI,a=t.distance(),o=r*a;if(0===o)return null;var u=0,c=[],l=[],x=[],f=[],y=0,v=-1,p=-1,d=-1,_=-1;function g(t,n,i){for(var r=0===c.length,e=t.dist/h,a=0;a<=i;a++){var o=a;o===i&&(o=0),_t.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();var g=n*t.widthScale;c[++v]=t.pos.x+_t.x*g,c[++v]=t.pos.y+_t.y*g,c[++v]=t.pos.z+_t.z*g,l[++p]=_t.x,l[++p]=_t.y,l[++p]=_t.z,x[++d]=e,x[++d]=a/i,y++}if(!r)for(var z=y-2*(i+1),m=y-(i+1),w=0;w<i;w++)f[++_]=m+w,f[++_]=z+w,f[++_]=z+w+1,f[++_]=m+w,f[++_]=z+w+1,f[++_]=m+w+1,u+=6}if(o>0)for(var z=0;z<t.count;z++){var m=t.array[z];if(m.dist>o){var w=t.array[z-1],M=new tt,b=(o-w.dist)/(m.dist-w.dist);M.lerpPathPoints(w,m,b),g(M,i,e);break}g(m,i,e)}return{points:c,normal:l,uv:x,indices:f,count:u}}(r,n);return e.line=t,e.position=new Float32Array(e.points),e.indices=new Uint32Array(e.indices),e.uv=new Float32Array(e.uv),e.normal=new Float32Array(e.normal),e})),r=j(i);return r.lines=t,r},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);var i=t.map((function(t){for(var i=0,r=t.length;i<r;i++){var e=t[i];Q(e),0===i?L(e)||(t[i]=e.reverse()):L(e)&&(t[i]=e.reverse()),R(e)&&e.splice(e.length-1,1)}var s=function(t,n){for(var i=function(t){var n=0,i=0,r=t.length;for(;i<r;)n+=t[i].length,i++;return n}(t),r=t.length,e=[],s=new Float32Array(2*i),h=[],a=[],o=3*i,u=2*i,c=n.depth,l=0,x=0,f=0,y=0;y<r;y++){var v=t[y];y>0&&e.push(l/2);for(var p=0,d=v.length;p<d;){var _=v[p],g=_[0],z=_[1],m=_[2]||0;s[l++]=g,s[l++]=z,h[x]=g,h[x+1]=z,h[x+2]=c+m,h[o+x]=g,h[o+x+1]=z,h[o+x+2]=m,a[f]=g,a[f+1]=z,a[u+f]=g,a[u+f+1]=z,x+=3,f+=2,p++}}return{flatVertices:s,holes:e,points:h,count:i,uv:a}}(t,n);return s.polygon=t,function(t,n){for(var i=[],r=t.count,e=0,s=n.length;e<s;e+=3){var h=n[e],a=n[e+1],o=n[e+2];i[e]=h,i[e+1]=a,i[e+2]=o;var u=s+e,c=r+h,l=r+a,x=r+o;i[u]=c,i[u+1]=l,i[u+2]=x}t.indices=i}(s,C(s.flatVertices,s.holes,2)),function(t,n){for(var i=t.points,r=t.indices,e=t.polygon,s=t.uv,h=n.depth,a=i.length-1,o=r.length-1,u=0,c=e.length;u<c;u++)for(var l=e[u],x=0,f=l.length;x<f;){var y=l[x],v=l[x+1];x===f-1&&(v=l[0]);var p=i.length/3,d=y[0],_=y[1],g=y[2]||0,z=v[0],m=v[1],w=v[2]||0;i[++a]=d,i[++a]=_,i[++a]=g+h,i[++a]=z,i[++a]=m,i[++a]=w+h,i[++a]=d,i[++a]=_,i[++a]=g,i[++a]=z,i[++a]=m,i[++a]=w;var M=p+2,b=p+3,P=p,A=p+1;r[++o]=M,r[++o]=P,r[++o]=b,r[++o]=P,r[++o]=A,r[++o]=b,N(s,i,M,b,P,A),x++}}(s,n),s.position=new Float32Array(s.points),s.indices=new Uint32Array(s.indices),s.uv=new Float32Array(s.uv),s.normal=I(s.indices,s.position),s})),r=j(i);return r.polygons=t,r},t.extrudePolylines=function(t,n){W(n=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1},n));var i=t.map((function(t){var i=G(t,n);return i.line=t,X(i,n),B(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=I(i.indices,i.position),i})),r=j(i);return r.lines=t,r},t.extrudeSlopes=function(t,n){W(n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1},n));var i=n,r=i.depth,e=i.side,s=i.sideDepth,h=t.map((function(t){var i=G(t,n);i.line=t;for(var h,a=i.leftPoints,o=i.rightPoints,u={line:t},c=0,l=t.length;c<l;c++)t[c][2]=t[c][2]||0;return"left"===e?(u.leftPoints=a,u.rightPoints=t,h=[s,r]):(u.leftPoints=t,u.rightPoints=o,h=[r,s]),u.depths=h,X(u,n),B(u,n),u.position=new Float32Array(u.points),u.indices=new Uint32Array(u.indices),u.uv=new Float32Array(u.uv),u.normal=I(u.indices,u.position),u})),a=j(h);return a.lines=t,a},t.leftOnLine=J,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 e,h,a,o,u,v,f,x=n&&n.length,p=x?n[0]*i:t.length,d=r(t,0,p,i,!0),_=[];if(!d||d.next===d.prev)return _;if(x&&(d=function(t,n,i,e){var s,h,a,o=[];for(s=0,h=n.length;s<h;s++)(a=r(t,n[s]*e,s<h-1?n[s+1]*e:t.length,e,!1))===a.next&&(a.steiner=!0),o.push(y(a));for(o.sort(c),s=0;s<o.length;s++)i=l(o[s],i);return i}(t,n,d,i)),t.length>80*i){e=a=t[0],h=o=t[1];for(var g=i;g<p;g+=i)(u=t[g])<e&&(e=u),(v=t[g+1])<h&&(h=v),u>a&&(a=u),v>o&&(o=v);f=0!==(f=Math.max(a-e,o-h))?32767/f:0}return s(d,_,i,e,h,f,0),_}function r(t,n,i,r,e){var s,h;if(e===S(t,n,i,r)>0)for(s=n;s<i;s+=r)h=b(s,t[s],t[s+1],h);else for(s=i-r;s>=n;s-=r)h=b(s,t[s],t[s+1],h);return h&&_(h,h.next)&&(A(h),h=h.next),h}function e(t,n){if(!t)return t;n||(n=t);var i,r=t;do{if(i=!1,r.steiner||!_(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(A(r),(r=n=r.prev)===r.next)break;i=!0}}while(i||r!==n);return n}function s(t,n,i,r,c,l,v){if(t){!v&&l&&function(t,n,i,r){var e=t;do{0===e.z&&(e.z=f(e.x,e.y,n,i,r)),e.prevZ=e.prev,e.nextZ=e.next,e=e.next}while(e!==t);e.prevZ.nextZ=null,e.prevZ=null,function(t){var n,i,r,e,s,h,a,o,u=1;do{for(i=t,t=null,s=null,h=0;i;){for(h++,r=i,a=0,n=0;n<u&&(a++,r=r.nextZ);n++);for(o=u;a>0||o>0&&r;)0!==a&&(0===o||!r||i.z<=r.z)?(e=i,i=i.nextZ,a--):(e=r,r=r.nextZ,o--),s?s.nextZ=e:t=e,e.prevZ=s,s=e;i=r}s.nextZ=null,u*=2}while(h>1)}(e)}(t,r,c,l);for(var y,x,p=t;t.prev!==t.next;)if(y=t.prev,x=t.next,l?a(t,r,c,l):h(t))n.push(y.i/i|0),n.push(t.i/i|0),n.push(x.i/i|0),A(t),t=x.next,p=x.next;else if((t=x)===p){v?1===v?s(t=o(e(t),n,i),n,i,r,c,l,2):2===v&&u(t,n,i,r,c,l):s(e(t),n,i,r,c,l,1);break}}}function h(t){var n=t.prev,i=t,r=t.next;if(d(n,i,r)>=0)return!1;for(var e=n.x,s=i.x,h=r.x,a=n.y,o=i.y,u=r.y,c=e<s?e<h?e:h:s<h?s:h,l=a<o?a<u?a:u:o<u?o:u,v=e>s?e>h?e:h:s>h?s:h,f=a>o?a>u?a:u:o>u?o:u,y=r.next;y!==n;){if(y.x>=c&&y.x<=v&&y.y>=l&&y.y<=f&&x(e,a,s,o,h,u,y.x,y.y)&&d(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function a(t,n,i,r){var e=t.prev,s=t,h=t.next;if(d(e,s,h)>=0)return!1;for(var a=e.x,o=s.x,u=h.x,c=e.y,l=s.y,v=h.y,y=a<o?a<u?a:u:o<u?o:u,p=c<l?c<v?c:v:l<v?l:v,_=a>o?a>u?a:u:o>u?o:u,g=c>l?c>v?c:v:l>v?l:v,z=f(y,p,n,i,r),m=f(_,g,n,i,r),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=y&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&x(a,c,o,l,u,v,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;if(w=w.prevZ,M.x>=y&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&x(a,c,o,l,u,v,M.x,M.y)&&d(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;w&&w.z>=z;){if(w.x>=y&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&x(a,c,o,l,u,v,w.x,w.y)&&d(w.prev,w,w.next)>=0)return!1;w=w.prevZ}for(;M&&M.z<=m;){if(M.x>=y&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&x(a,c,o,l,u,v,M.x,M.y)&&d(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function o(t,n,i){var r=t;do{var s=r.prev,h=r.next.next;!_(s,h)&&g(s,r,r.next,h)&&w(s,h)&&w(h,s)&&(n.push(s.i/i|0),n.push(r.i/i|0),n.push(h.i/i|0),A(r),A(r.next),r=t=h),r=r.next}while(r!==t);return e(r)}function u(t,n,i,r,h,a){var o=t;do{for(var u=o.next.next;u!==o.prev;){if(o.i!==u.i&&p(o,u)){var c=M(o,u);return o=e(o,o.next),c=e(c,c.next),s(o,n,i,r,h,a,0),void s(c,n,i,r,h,a,0)}u=u.next}o=o.next}while(o!==t)}function c(t,n){return t.x-n.x}function l(t,n){var i=function(t,n){var i,r=n,e=t.x,s=t.y,h=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=e&&a>h&&(h=a,i=r.x<r.next.x?r:r.next,a===e))return i}r=r.next}while(r!==n);if(!i)return null;var o,u=i,c=i.x,l=i.y,f=1/0;r=i;do{e>=r.x&&r.x>=c&&e!==r.x&&x(s<l?e:h,s,c,l,s<l?h:e,s,r.x,r.y)&&(o=Math.abs(s-r.y)/(e-r.x),w(r,t)&&(o<f||o===f&&(r.x>i.x||r.x===i.x&&v(i,r)))&&(i=r,f=o)),r=r.next}while(r!==u);return i}(t,n);if(!i)return n;var r=M(i,t);return e(r,r.next),e(i,i.next)}function v(t,n){return d(t.prev,t,n.prev)<0&&d(n.next,t,t.next)<0}function f(t,n,i,r,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*e|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*e|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function y(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 x(t,n,i,r,e,s,h,a){return(e-h)*(n-a)>=(t-h)*(s-a)&&(t-h)*(r-a)>=(i-h)*(n-a)&&(i-h)*(s-a)>=(e-h)*(r-a)}function p(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,r=!1,e=(t.x+n.x)/2,s=(t.y+n.y)/2;do{i.y>s!=i.next.y>s&&i.next.y!==i.y&&e<(i.next.x-i.x)*(s-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==t);return r}(t,n)&&(d(t.prev,t,n.prev)||d(t,n.prev,n))||_(t,n)&&d(t.prev,t,t.next)>0&&d(n.prev,n,n.next)>0)}function d(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,r){var e=m(d(t,n,i)),s=m(d(t,n,r)),h=m(d(i,r,t)),a=m(d(i,r,n));return e!==s&&h!==a||(!(0!==e||!z(t,i,n))||(!(0!==s||!z(t,r,n))||(!(0!==h||!z(i,t,r))||!(0!==a||!z(i,n,r)))))}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 d(t.prev,t,t.next)<0?d(t,n,t.next)>=0&&d(t,t.prev,n)>=0:d(t,n,t.prev)<0||d(t,t.next,n)<0}function M(t,n){var i=new P(t.i,t.x,t.y),r=new P(n.i,n.x,n.y),e=t.next,s=n.prev;return t.next=n,n.prev=t,i.next=e,e.prev=i,r.next=i,i.prev=r,s.next=r,r.prev=s,r}function b(t,n,i,r){var e=new P(t,n,i);return r?(e.next=r.next,e.prev=r,r.next.prev=e,r.next=e):(e.prev=e,e.next=e),e}function A(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function 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,r){for(var e=0,s=n,h=i-r;s<i;s+=r)e+=(t[h]-t[s])*(t[s+1]+t[h+1]),h=s;return e}n.exports=i,n.exports.default=i,i.deviation=function(t,n,i,r){var e=n&&n.length,s=e?n[0]*i:t.length,h=Math.abs(S(t,0,s,i));if(e)for(var a=0,o=n.length;a<o;a++){var u=n[a]*i,c=a<o-1?n[a+1]*i:t.length;h-=Math.abs(S(t,u,c,i))}var l=0;for(a=0;a<r.length;a+=3){var v=r[a]*i,f=r[a+1]*i,y=r[a+2]*i;l+=Math.abs((t[v]-t[y])*(t[f+1]-t[v+1])-(t[v]-t[f])*(t[y+1]-t[v+1]))}return 0===h&&0===l?0:Math.abs((l-h)/h)},i.flatten=function(t){for(var n=t[0][0].length,i={vertices:[],holes:[],dimensions:n},r=0,e=0;e<t.length;e++){for(var s=0;s<t[e].length;s++)for(var h=0;h<n;h++)i.vertices.push(t[e][s][h]);e>0&&(r+=t[e-1].length,i.holes.push(r))}return i};var C=n.exports;function k(t,n){for(var i=0;i<n.length;i++){var r=n[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}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,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=0),void 0===r&&(r=1),this.isQuaternion=!0,this._x=t,this._y=n,this._z=i,this._w=r}t.slerpFlat=function(t,n,i,r,e,s,h){var a=i[r+0],o=i[r+1],u=i[r+2],c=i[r+3],l=e[s+0],v=e[s+1],f=e[s+2],y=e[s+3];if(0===h)return t[n+0]=a,t[n+1]=o,t[n+2]=u,void(t[n+3]=c);if(1===h)return t[n+0]=l,t[n+1]=v,t[n+2]=f,void(t[n+3]=y);if(c!==y||a!==l||o!==v||u!==f){var x=1-h,p=a*l+o*v+u*f+c*y,d=p>=0?1:-1,_=1-p*p;if(_>Number.EPSILON){var g=Math.sqrt(_),z=Math.atan2(g,p*d);x=Math.sin(x*z)/g,h=Math.sin(h*z)/g}var m=h*d;if(a=a*x+l*m,o=o*x+v*m,u=u*x+f*m,c=c*x+y*m,x===1-h){var w=1/Math.sqrt(a*a+o*o+u*u+c*c);a*=w,o*=w,u*=w,c*=w}}t[n]=a,t[n+1]=o,t[n+2]=u,t[n+3]=c},t.multiplyQuaternionsFlat=function(t,n,i,r,e,s){var h=i[r],a=i[r+1],o=i[r+2],u=i[r+3],c=e[s],l=e[s+1],v=e[s+2],f=e[s+3];return t[n]=h*f+u*c+a*v-o*l,t[n+1]=a*f+u*l+o*c-h*v,t[n+2]=o*f+u*v+h*l-a*c,t[n+3]=u*f-h*c-a*l-o*v,t};var n,i,r,e=t.prototype;return e.set=function(t,n,i,r){return this._x=t,this._y=n,this._z=i,this._w=r,this._onChangeCallback(),this},e.clone=function(){return new this.constructor(this._x,this._y,this._z,this._w)},e.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},e.setFromEuler=function(t,n){void 0===n&&(n=!0);var i=t._x,r=t._y,e=t._z,s=t._order,h=Math.cos,a=Math.sin,o=h(i/2),u=h(r/2),c=h(e/2),l=a(i/2),v=a(r/2),f=a(e/2);switch(s){case"XYZ":this._x=l*u*c+o*v*f,this._y=o*v*c-l*u*f,this._z=o*u*f+l*v*c,this._w=o*u*c-l*v*f;break;case"YXZ":this._x=l*u*c+o*v*f,this._y=o*v*c-l*u*f,this._z=o*u*f-l*v*c,this._w=o*u*c+l*v*f;break;case"ZXY":this._x=l*u*c-o*v*f,this._y=o*v*c+l*u*f,this._z=o*u*f+l*v*c,this._w=o*u*c-l*v*f;break;case"ZYX":this._x=l*u*c-o*v*f,this._y=o*v*c+l*u*f,this._z=o*u*f-l*v*c,this._w=o*u*c+l*v*f;break;case"YZX":this._x=l*u*c+o*v*f,this._y=o*v*c+l*u*f,this._z=o*u*f-l*v*c,this._w=o*u*c-l*v*f;break;case"XZY":this._x=l*u*c-o*v*f,this._y=o*v*c-l*u*f,this._z=o*u*f+l*v*c,this._w=o*u*c+l*v*f;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+s)}return!0===n&&this._onChangeCallback(),this},e.setFromAxisAngle=function(t,n){var i=n/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this},e.setFromRotationMatrix=function(t){var n=t.elements,i=n[0],r=n[4],e=n[8],s=n[1],h=n[5],a=n[9],o=n[2],u=n[6],c=n[10],l=i+h+c;if(l>0){var v=.5/Math.sqrt(l+1);this._w=.25/v,this._x=(u-a)*v,this._y=(e-o)*v,this._z=(s-r)*v}else if(i>h&&i>c){var f=2*Math.sqrt(1+i-h-c);this._w=(u-a)/f,this._x=.25*f,this._y=(r+s)/f,this._z=(e+o)/f}else if(h>c){var y=2*Math.sqrt(1+h-i-c);this._w=(e-o)/y,this._x=(r+s)/y,this._y=.25*y,this._z=(a+u)/y}else{var x=2*Math.sqrt(1+c-i-h);this._w=(s-r)/x,this._x=(e+o)/x,this._y=(a+u)/x,this._z=.25*x}return this._onChangeCallback(),this},e.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()},e.rotateTowards=function(t,n){var i=this.angleTo(t);if(0===i)return this;var r=Math.min(1,n/i);return this.slerp(t,r),this},e.identity=function(){return this.set(0,0,0,1)},e.invert=function(){return this.conjugate()},e.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},e.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},e.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},e.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},e.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},e.multiply=function(t){return this.multiplyQuaternions(this,t)},e.premultiply=function(t){return this.multiplyQuaternions(t,this)},e.multiplyQuaternions=function(t,n){var i=t._x,r=t._y,e=t._z,s=t._w,h=n._x,a=n._y,o=n._z,u=n._w;return this._x=i*u+s*h+r*o-e*a,this._y=r*u+s*a+e*h-i*o,this._z=e*u+s*o+i*a-r*h,this._w=s*u-i*h-r*a-e*o,this._onChangeCallback(),this},e.slerp=function(t,n){if(0===n)return this;if(1===n)return this.copy(t);var i=this._x,r=this._y,e=this._z,s=this._w,h=s*t._w+i*t._x+r*t._y+e*t._z;if(h<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,h=-h):this.copy(t),h>=1)return this._w=s,this._x=i,this._y=r,this._z=e,this;var a=1-h*h;if(a<=Number.EPSILON){var o=1-n;return this._w=o*s+n*this._w,this._x=o*i+n*this._x,this._y=o*r+n*this._y,this._z=o*e+n*this._z,this.normalize(),this}var u=Math.sqrt(a),c=Math.atan2(u,h),l=Math.sin((1-n)*c)/u,v=Math.sin(n*c)/u;return this._w=s*l+this._w*v,this._x=i*l+this._x*v,this._y=r*l+this._y*v,this._z=e*l+this._z*v,this._onChangeCallback(),this},e.slerpQuaternions=function(t,n,i){return this.copy(t).slerp(n,i)},e.random=function(){var t=2*Math.PI*Math.random(),n=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),e=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),e*Math.sin(n),e*Math.cos(n))},e.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},e.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},e.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},e.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},e.toJSON=function(){return this.toArray()},e._onChange=function(t){return this._onChangeCallback=t,this},e._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),r&&k(n,r),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,r=this.z,e=t.elements,s=1/(e[3]*n+e[7]*i+e[11]*r+e[15]);return this.x=(e[0]*n+e[4]*i+e[8]*r+e[12])*s,this.y=(e[1]*n+e[5]*i+e[9]*r+e[13])*s,this.z=(e[2]*n+e[6]*i+e[10]*r+e[14])*s,this},n.applyQuaternion=function(t){var n=this.x,i=this.y,r=this.z,e=t.x,s=t.y,h=t.z,a=t.w,o=a*n+s*r-h*i,u=a*i+h*n-e*r,c=a*r+e*i-s*n,l=-e*n-s*i-h*r;return this.x=o*a+l*-e+u*-h-c*-s,this.y=u*a+l*-s+c*-e-o*-h,this.z=c*a+l*-h+o*-s-u*-e,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,r=t.y,e=t.z,s=n.x,h=n.y,a=n.z;return this.x=r*a-e*h,this.y=e*s-i*a,this.z=i*h-r*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){for(var n,i,r=0,e=1,s=t.length;e<s;)n=i||t[0],r+=((i=t[e])[0]-n[0])*(i[1]+n[1]),e++;return r>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){var i=n[0],r=n[1],e=n[2],s=Math.sqrt(i*i+r*r+e*e)||1;return t[0]=i/s,t[1]=r/s,t[2]=e/s,t}function I(t,n){function i(t,n,i,r){t[0]=n,t[1]=i,t[2]=r}for(var r,e,s,h,a,o,u,c,l,v=[],f=[],y=[],x=[],p=[],d=[],_=t.length,g=new Float32Array(n.length),z=0;z<_;){var m=3*t[z],w=3*t[z+1],M=3*t[z+2];i(v,n[m],n[m+1],n[m+2]),i(f,n[w],n[w+1],n[w+2]),i(y,n[M],n[M+1],n[M+2]),L(p,y,f),L(x,v,f),r=d,s=x,h=void 0,a=void 0,o=void 0,u=void 0,c=void 0,l=void 0,h=(e=p)[0],a=e[1],o=e[2],u=s[0],c=s[1],l=s[2],r[0]=a*l-o*c,r[1]=o*u-h*l,r[2]=h*c-a*u;for(var b=0;b<3;b++)g[m+b]+=d[b],g[w+b]+=d[b],g[M+b]+=d[b];z+=3}for(var A=0,P=g.length;A<P;)i(d,g[A],g[A+1],g[A+2]),O(d,d),g[A]=d[0]||0,g[A+1]=d[1]||0,g[A+2]=d[2]||0,A+=3;return g}function U(t){if(1===t.length)return{position:t[0].position,normal:t[0].normal,uv:t[0].uv,indices:t[0].indices,results:t};for(var n=0,i=0,r=0,e=t.length;r<e;r++){var s=t[r],h=s.position,a=s.indices;n+=h.length,i+=a.length}for(var o={position:new Float32Array(n),normal:new Float32Array(n),uv:new Float32Array(n/3*2),indices:new Uint32Array(i),results:t},u=0,c=0,l=0,v=0,f=0,y=t.length;f<y;f++){var x=t[f],p=x.position,d=x.indices,_=x.normal,g=x.uv;o.position.set(p,u),o.normal.set(_,u),o.uv.set(g,v);for(var z=0,m=d.length;z<m;){var w=d[z]+c;o.indices[l]=w,l++,z++}v+=g.length,u+=p.length,c+=p.length/3}return o}function j(t){return 180*t/Math.PI}function E(t){return t/180*Math.PI}function N(t,n,i,r,e,s){var h=3*i,a=3*r,o=3*e,u=3*s,c=n[h],l=n[h+1],v=n[h+2],f=n[a],y=n[a+1],x=n[a+2],p=n[o],d=n[o+1],_=n[o+2],g=n[u],z=n[u+1],m=n[u+2],w=t.length-1;Math.abs(l-y)<Math.abs(c-f)?(t[++w]=c,t[++w]=1-v,t[++w]=f,t[++w]=1-x,t[++w]=p,t[++w]=1-_,t[++w]=g,t[++w]=1-m):(t[++w]=l,t[++w]=1-v,t[++w]=y,t[++w]=1-x,t[++w]=d,t[++w]=1-_,t[++w]=z,t[++w]=1-m)}function T(t){for(var n=[],i=0,r=t.length;i<r;i++){var e=t[i],s=e[0],h=e[1],a=e[2],o=new F(s,h,a||0);n[i]=o}return n}function Q(t){R(t)||t.push(t[0])}function R(t){var n=t.length,i=t[0],r=i[0],e=i[1],s=t[n-1],h=s[0],a=s[1];return r===h&&e===a}function W(t){t.lineWidth=Math.max(0,t.lineWidth),t.depth=Math.max(0,t.depth),t.sideDepth=Math.max(0,t.sideDepth)}function X(t,n){var i=n.bottomStickGround,r=n.depth,e=t.depths,s=r,h=r;e&&(s=e[0],h=e[1]);var a=t.leftPoints,o=t.rightPoints,u=t.line,c=n.pathUV;if(c){!function(t){for(var n=0,i=0,r=t.length;i<r;i++){var e=t[i],s=t[i+1];if(0===i&&(e.distance=0),e&&s){var h=e[0],a=e[1],o=e[2],u=h-s[0],c=a-s[1],l=(o||0)-(s[2]||0);n+=Math.sqrt(u*u+c*c+l*l),s.distance=n}}}(u);for(var l=0,v=u.length;l<v;l++)a[l].distance=o[l].distance=u[l].distance}for(var f=0,y=a.length,x=[],p=[],d=[];f<y;){var _=3*f,g=a[f],z=g[0],m=g[1],w=g[2];x[_]=z,x[_+1]=m,x[_+2]=s+w;var M=o[f],b=M[0],A=M[1],P=M[2],S=3*y+_;x[S]=b,x[S+1]=A,x[S+2]=h+P;var C=2*y*3+_;x[C]=z,x[C+1]=m,x[C+2]=w,i&&(x[C+2]=0);var k=2*y*3+3*y+_;if(x[k]=b,x[k+1]=A,x[k+2]=P,i&&(x[k+2]=0),c){var V=u[f].distance,Z=2*f;d[Z]=V,d[Z+1]=1;var F=2*y+Z;d[F]=V,d[F+1]=0;var q=2*y*2+Z;d[q]=V,d[q+1]=1;var L=2*y*2+2*y+Z;d[L]=V,d[L+1]=0}f++}if(!c){f=0,y=x.length;for(var O=d.length-1;f<y;){var I=x[f],U=x[f+1];d[++O]=I,d[++O]=U,f+=3}}f=0,y=a.length;for(var j=p.length-1;f<y-1;){var E=f,N=f+1,T=E+y,Q=N+y;p[++j]=E,p[++j]=T,p[++j]=N,p[++j]=T,p[++j]=Q,p[++j]=N;var R=f+2*y,W=R+1,X=R+y,B=W+y;p[++j]=R,p[++j]=X,p[++j]=W,p[++j]=X,p[++j]=B,p[++j]=W,f++}if(t.indices=p,t.points=x,t.uv=d,e)for(y=a.length,f=0;f<y;)a[f].depth=s,o[f].depth=h,f++}function B(t,n){var i=t.points,r=t.indices,e=t.leftPoints,s=t.rightPoints,h=t.uv,a=n.depth,o=n.bottomStickGround,u=[e,s],c=t.depths,l=n.pathUV,v=n.lineWidth,f=i.length-1,y=r.length-1,x=h.length-1;function p(t,n){var e=i.length/3,s=c?t.depth:a,u=c?n.depth:a;i[++f]=t[0],i[++f]=t[1],i[++f]=s+t[2],i[++f]=n[0],i[++f]=n[1],i[++f]=u+n[2],i[++f]=t[0],i[++f]=t[1],i[++f]=o?0:t[2],i[++f]=n[0],i[++f]=n[1],i[++f]=o?0:n[2];var p=e+2,d=e+3,_=e,g=e+1;r[++y]=p,r[++y]=_,r[++y]=d,r[++y]=_,r[++y]=g,r[++y]=d,l?(h[++x]=t.distance,h[++x]=s/v,h[++x]=n.distance,h[++x]=u/v,h[++x]=t.distance,h[++x]=0,h[++x]=n.distance,h[++x]=0):N(h,i,p,d,_,g)}for(var d=0,_=u.length;d<_;d++){var g=u[d];d>0&&(g=(g=g.map((function(t){return t}))).reverse());for(var z=0,m=g.length-1;z<m;){p(g[z],g[z+1]),z++}}for(var w=e.length,M=[s[0],e[0],e[w-1],s[w-1]],b=0;b<M.length;b+=2){p(M[b],M[b+1])}}var Y={x:0,y:0},D={x:0,y:0};function G(t,n){var i=n.lineWidth/2;n.isSlope&&(i*=2);for(var r=[],e=[],s=[],h=t.length,a=0;a<h;){var o=t[a],u=t[a+1],c=t[a];a===h-1&&(o=t[h-2],u=t[h-1]);var l=u[1]-o[1],v=u[0]-o[0],f=0,y=j(Math.atan(l/v));if(0===a||a===h-1)f=y,f-=90;else{var x=t[a-1];Y.x=x[0]-o[0],Y.y=x[1]-o[1],D.x=u[0]-o[0],D.y=u[1]-o[1],f=y-H(Y,D)/2}var p=E(f),d=c,_=[Math.cos(p)+d[0],Math.sin(p)+d[1]],g=K(o,u,i),z=g[0],m=g[1],w=$(z[0],z[1],d,_),M=$(m[0],m[1],d,_);if(!w||!M){var b=r.length,A=r[b-2],P=r[b-1];if(!A||!P)continue;w=[A[0],A[1]],M=[P[0],P[1]]}w[2]=c[2]||0,M[2]=c[2]||0,r.push(w,M),J(w,o,u)?(e.push(w),s.push(M)):(e.push(M),s.push(w)),a++}return{offsetPoints:r,leftPoints:e,rightPoints:s,line:t}}var H=function(t,n){var i=t.x,r=t.y,e=n.x,s=n.y,h=i*e+r*s,a=i*s-r*e;return(Math.atan2(a,h)/Math.PI*180+360)%360};function J(t,n,i){var r=n[0],e=n[1],s=i[0],h=i[1];return(e-h)*t[0]+(s-r)*t[1]+r*h-s*e>0}function K(t,n,i){var r=n[1]-t[1],e=n[0]-t[0],s=Math.atan2(r,e),h=s+Math.PI/2,a=Math.cos(h)*i,o=Math.sin(h)*i,u=[t[0]+a,t[1]+o],c=[n[0]+a,n[1]+o],l=s-Math.PI/2;return a=Math.cos(l)*i,o=Math.sin(l)*i,[[u,c],[[t[0]+a,t[1]+o],[n[0]+a,n[1]+o]]]}function $(t,n,i,r){var e=n[0]-t[0],s=n[1]-t[1],h=r[0]-i[0],a=r[1]-i[1];if(0===e&&0===h)return null;if(0===s&&0===a)return null;var o,u,c=s/e,l=a/h,v=t[1]-c*t[0],f=i[1]-l*i[0];return 0===e?u=l*(o=t[0])+f:0===h?u=c*(o=i[0])+v:0===s?o=((u=t[1])-f)/l:0===a?o=((u=i[1])-v)/c:u=c*(o=(f-v)/(c-l))+v,[o,u]}var tt=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}(),nt=function(){function t(t,n,i,r,e,s,h,a,o,u,c,l,v,f,y,x){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,r,e,s,h,a,o,u,c,l,v,f,y,x)}var n=t.prototype;return n.set=function(t,n,i,r,e,s,h,a,o,u,c,l,v,f,y,x){var p=this.elements;return p[0]=t,p[4]=n,p[8]=i,p[12]=r,p[1]=e,p[5]=s,p[9]=h,p[13]=a,p[2]=o,p[6]=u,p[10]=c,p[14]=l,p[3]=v,p[7]=f,p[11]=y,p[15]=x,this},n.multiply=function(t){return this.multiplyMatrices(this,t)},n.makeRotationAxis=function(t,n){var i=Math.cos(n),r=Math.sin(n),e=1-i,s=t.x,h=t.y,a=t.z,o=e*s,u=e*h;return this.set(o*s+i,o*h-r*a,o*a+r*h,0,o*h+r*a,u*h+i,u*a-r*s,0,o*a-r*h,u*a+r*s,e*a*a+i,0,0,0,0,1),this},n.equals=function(t){for(var n=this.elements,i=t.elements,r=0;r<16;r++)if(n[r]!==i[r])return!1;return!0},t}();function it(t,n,i,r){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,r)}var rt=function(t){var n,i;function r(n,i,r){var e;return void 0===n&&(n=new F),void 0===i&&(i=new F),void 0===r&&(r=new F),(e=t.call(this)||this).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=n,e.v1=i,e.v2=r,e}return i=t,(n=r).prototype=Object.create(i.prototype),n.prototype.constructor=n,V(n,i),r.prototype.getPoint=function(t,n){void 0===n&&(n=new F);var i=n,r=this.v0,e=this.v1,s=this.v2;return i.set(it(t,r.x,e.x,s.x),it(t,r.y,e.y,s.y),it(t,r.z,e.z,s.z)),i},r}(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=[],r=this.getPoint(0),e=0;i.push(0);for(var s=1;s<=t;s++)e+=(n=this.getPoint(s/t)).distanceTo(r),i.push(e),r=n;return this.cacheArcLengths=i,i},n.getUtoTmapping=function(t,n){var i,r=this.getLengths(),e=0,s=r.length;i=n||t*r[s-1];for(var h,a=0,o=s-1;a<=o;)if((h=r[e=Math.floor(a+(o-a)/2)]-i)<0)a=e+1;else{if(!(h>0)){o=e;break}o=e-1}if(r[e=o]===i)return e/(s-1);var u=r[e];return(e+(i-u)/(r[e+1]-u))/(s-1)},t}()),et=new F,st=new F,ht=new F,at=new nt,ot=new rt;var ut=function(){function t(){this.array=[],this.count=0}var n=t.prototype;return n.set=function(t,n,i,r,e){if(void 0===n&&(n=.1),void 0===i&&(i=10),void 0===r&&(r=null),void 0===e&&(e=!1),(t=t.slice(0)).length<2)return console.warn("PathPointList: points length less than 2."),void(this.count=0);e&&!t[0].equals(t[t.length-1])&&t.push((new F).copy(t[0]));for(var s=0,h=t.length;s<h;s++)if(0===s)this._start(t[s],t[s+1],r);else if(s===h-1)if(e){this._corner(t[s],t[1],n,i,r);var a=this.array[0].dist;this.array[0].copy(this.array[this.count-1]),this.array[0].dist=a}else this._end(t[s]);else this._corner(t[s],t[s+1],n,i,r)},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 tt),this.array[t]},n._start=function(t,n,i){this.count=0;var r=this._getByIndex(this.count);if(r.pos.copy(t),r.dir.subVectors(n,t),i)r.up.copy(i);else{var e=Number.MAX_VALUE,s=Math.abs(r.dir.x),h=Math.abs(r.dir.y),a=Math.abs(r.dir.z);s<e&&(e=s,r.up.set(1,0,0)),h<e&&(e=h,r.up.set(0,1,0)),a<e&&r.up.set(0,0,1)}r.right.crossVectors(r.dir,r.up).normalize(),r.up.crossVectors(r.right,r.dir).normalize(),r.dist=0,r.widthScale=1,r.sharp=!1,r.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 r=i.dir.length();i.dir.normalize(),i.up.copy(n.up);var e=et.crossVectors(n.dir,i.dir);if(e.length()>Number.EPSILON){e.normalize();var s=Math.acos(Math.min(Math.max(n.dir.dot(i.dir),-1),1));i.up.applyMatrix4(at.makeRotationAxis(e,s))}i.right.crossVectors(i.dir,i.up).normalize(),i.dist=n.dist+r,i.widthScale=1,i.sharp=!1,this.count++},n._corner=function(t,n,i,r,e){if(i>0&&r>0){for(var s=function(t,n,i,r,e,s){var h=et.subVectors(n,t),a=st.subVectors(i,n),o=h.length(),u=a.length();h.normalize(),a.normalize();var c=Math.min(.999999*(e?o/2:o),r);s.v0.copy(n).sub(h.multiplyScalar(c)),s.v1.copy(n);var l=Math.min(u/2*.999999,r);return s.v2.copy(n).add(a.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,n,i,this.count-1==0,ot),h=s.getPoints(r),a=0;a<r;a++)this._sharpCorner(h[a],h[a+1],e,0===a?1:0);h[r].equals(n)||this._sharpCorner(h[r],n,e,2)}else this._sharpCorner(t,n,e,0,!0)},n._sharpCorner=function(t,n,i,r,e){void 0===r&&(r=0),void 0===e&&(e=!1);var s=this.array[this.count-1],h=this._getByIndex(this.count),a=et.subVectors(t,s.pos),o=st.subVectors(n,t),u=a.length();if(a.normalize(),o.normalize(),h.pos.copy(t),1===r?h.dir.copy(a):2===r?h.dir.copy(o):(h.dir.addVectors(a,o),h.dir.normalize()),i)1===h.dir.dot(i)?h.right.crossVectors(o,i).normalize():h.right.crossVectors(h.dir,i).normalize(),h.up.crossVectors(h.right,h.dir).normalize();else{h.up.copy(s.up);var c=ht.crossVectors(s.dir,h.dir);if(c.length()>Number.EPSILON){c.normalize();var l=Math.acos(Math.min(Math.max(s.dir.dot(h.dir),-1),1));h.up.applyMatrix4(at.makeRotationAxis(c,l))}h.right.crossVectors(h.dir,h.up).normalize()}h.dist=s.dist+u;var v=a.dot(o);h.widthScale=Math.min(1/Math.sqrt((1+v)/2),1.415)||1,h.sharp=Math.abs(v-1)>.05&&e,this.count++},t}(),ct=new F(0,0,1),lt=new F,vt=new F,ft=new F,yt=new F,xt=new F,pt=new F;var dt=new F(0,0,1),_t=new F;t.cylinder=function(t,n){void 0===n&&(n={}),n=Object.assign({},{radius:1,height:2,radialSegments:6},n);for(var i=Math.round(Math.max(4,n.radialSegments)),r=n,e=r.radius,s=r.height,h=360/i/360*Math.PI*2,a=i+1,o=new Float32Array(3*a*2),u=t[0],c=t[1],l=0,v=0,f=3*a,y=2*a,x=[],p=[],d=x.length-1,_=-1;_<i;_++){var g=h*_,z=Math.cos(g)*e+u,m=Math.sin(g)*e+c;o[l]=z,o[l+1]=m,o[l+2]=0,o[l+f]=z,o[l+1+f]=m,o[l+2+f]=s;var w,M;w=.5+z/e/2,M=.5+m/e/2,p[v]=w,p[v+1]=M,p[v+y]=w,p[v+1+y]=M,l+=3,v+=2,_>1&&(x[++d]=0,x[++d]=_-1,x[++d]=_)}o[l-=3]=o[0],o[l+1]=o[1],o[l+2]=o[2];var b=o.length;o[b-3]=o[0],o[b-2]=o[1],o[b-1]=s;var A=x.length;d=x.length-1;for(var P=0;P<A;P++){var S=x[P];x[++d]=S+a}var C=new Float32Array(2*(3*a*2-6)),k=-1;l=2*a,v=0,d=x.length-1;for(var V=p.length-1,Z=0,F=o.length/2;Z<F-3;Z+=3){var q=o[Z],L=o[Z+1],O=o[Z+3],U=o[Z+4];C[++k]=q,C[++k]=L,C[++k]=s,C[++k]=O,C[++k]=U,C[++k]=s,C[++k]=q,C[++k]=L,C[++k]=0,C[++k]=O,C[++k]=U,C[++k]=0;var j=l+2,E=l+3,N=l,T=l+1;x[++d]=N,x[++d]=j,x[++d]=T,x[++d]=j,x[++d]=E,x[++d]=T,l+=4;var Q=v/a,R=(v+1)/a;p[++V]=Q,p[++V]=s/e/2,p[++V]=R,p[++V]=s/e/2,p[++V]=Q,p[++V]=0,p[++V]=R,p[++V]=0,v++}var W=new Float32Array(o.length+C.length);W.set(o,0),W.set(C,o.length);var X=I(x,W);return{points:o,indices:new Uint32Array(x),position:W,normal:X,uv:new Float32Array(p)}},t.expandLine=G,t.expandPaths=function(t,n){n=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},n);var i=t.map((function(t){var i=T(t),r=new ut;r.set(i,n.cornerRadius,n.cornerSplit,ct);var e=function(t,n){var i=n.lineWidth||.1,r=1,e=i/2,s=i,h=t.distance(),a=r*h;if(0===h)return null;var o,u=e/s,c=0,l=[],v=[],f=[],y=[],x=0,p=l.length-1,d=v.length-1,_=f.length-1,g=y.length-1;function z(t){var n=0===l.length,i=t.sharp&&!n,r=t.dist/s,h=t.dir,a=t.up,o=t.right;if(lt.copy(o).multiplyScalar(e*t.widthScale),vt.copy(o).multiplyScalar(-e*t.widthScale),lt.add(t.pos),vt.add(t.pos),i){ft.fromArray(l,l.length-6).sub(vt),yt.fromArray(l,l.length-3).sub(lt);var z,m,w=ft.length()-yt.length();w>0?(z=ft,m=vt):(z=yt,m=lt),xt.copy(z).setLength(Math.abs(w)).add(m);var M=pt.copy(m).sub(xt).normalize().dot(h)*pt.copy(m).sub(xt).length()*2;pt.copy(h).setLength(M).add(xt),w>0?(l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=pt.x,l[++p]=pt.y,l[++p]=pt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,x+=6,y[++g]=x-6,y[++g]=x-8,y[++g]=x-7,y[++g]=x-6,y[++g]=x-7,y[++g]=x-5,y[++g]=x-4,y[++g]=x-6,y[++g]=x-5,y[++g]=x-2,y[++g]=x-4,y[++g]=x-1,c+=12):(l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=xt.x,l[++p]=xt.y,l[++p]=xt.z,l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=pt.x,l[++p]=pt.y,l[++p]=pt.z,x+=6,y[++g]=x-6,y[++g]=x-8,y[++g]=x-7,y[++g]=x-6,y[++g]=x-7,y[++g]=x-5,y[++g]=x-6,y[++g]=x-5,y[++g]=x-3,y[++g]=x-2,y[++g]=x-3,y[++g]=x-1,c+=12);for(var b=0;b<6;b++)v[++d]=a.x,v[++d]=a.y,v[++d]=a.z;f[++_]=r-u,f[++_]=0,f[++_]=r-u,f[++_]=1,f[++_]=r,f[++_]=0,f[++_]=r,f[++_]=1,f[++_]=r+u,f[++_]=0,f[++_]=r+u,f[++_]=1}else l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=lt.x,l[++p]=lt.y,l[++p]=lt.z,v[++d]=a.x,v[++d]=a.y,v[++d]=a.z,v[++d]=a.x,v[++d]=a.y,v[++d]=a.z,f[++_]=r,f[++_]=0,f[++_]=r,f[++_]=1,x+=2,n||(y[++g]=x-2,y[++g]=x-4,y[++g]=x-3,y[++g]=x-2,y[++g]=x-3,y[++g]=x-1,c+=6)}if(a>0)for(var m=0;m<t.count;m++){var w=t.array[m];if(w.dist>a){var M=t.array[m-1];o=new tt;var b=(a-M.dist)/(w.dist-M.dist);o.lerpPathPoints(M,w,b),z(o);break}z(w)}else o=t.array[0];return{position:l,normal:v,uv:f,indices:y,count:c}}(r,n);return e.line=t,e.position=new Float32Array(e.position),e.indices=new Uint32Array(e.indices),e.uv=new Float32Array(e.uv),e.normal=new Float32Array(e.normal),e})),r=U(i);return r.lines=t,r},t.expandTubes=function(t,n){n=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},n);var i=t.map((function(t){var i=T(t),r=new ut;r.set(i,n.cornerRadius,n.cornerSplit,dt);var e=function(t,n){var i=Math.max(n.radius||1,1e-8),r=void 0!==n.progress?n.progress:1,e=Math.max(3,n.radialSegments||8),s=n.startRad||0,h=2*i*Math.PI,a=t.distance(),o=r*a;if(0===o)return null;var u=0,c=[],l=[],v=[],f=[],y=0,x=-1,p=-1,d=-1,_=-1;function g(t,n,i){for(var r=0===c.length,e=t.dist/h,a=0;a<=i;a++){var o=a;o===i&&(o=0),_t.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/i).normalize();var g=n*t.widthScale;c[++x]=t.pos.x+_t.x*g,c[++x]=t.pos.y+_t.y*g,c[++x]=t.pos.z+_t.z*g,l[++p]=_t.x,l[++p]=_t.y,l[++p]=_t.z,v[++d]=e,v[++d]=a/i,y++}if(!r)for(var z=y-2*(i+1),m=y-(i+1),w=0;w<i;w++)f[++_]=m+w,f[++_]=z+w,f[++_]=z+w+1,f[++_]=m+w,f[++_]=z+w+1,f[++_]=m+w+1,u+=6}if(o>0)for(var z=0;z<t.count;z++){var m=t.array[z];if(m.dist>o){var w=t.array[z-1],M=new tt,b=(o-w.dist)/(m.dist-w.dist);M.lerpPathPoints(w,m,b),g(M,i,e);break}g(m,i,e)}return{points:c,normal:l,uv:v,indices:f,count:u}}(r,n);return e.line=t,e.position=new Float32Array(e.points),e.indices=new Uint32Array(e.indices),e.uv=new Float32Array(e.uv),e.normal=new Float32Array(e.normal),e})),r=U(i);return r.lines=t,r},t.extrudePolygons=function(t,n){n=Object.assign({},{depth:2},n);var i=t.map((function(t){for(var i=0,r=t.length;i<r;i++){var e=t[i];Q(e),0===i?q(e)||(t[i]=e.reverse()):q(e)&&(t[i]=e.reverse()),R(e)&&e.splice(e.length-1,1)}var s=function(t,n){for(var i=function(t){var n=0,i=0,r=t.length;for(;i<r;)n+=t[i].length,i++;return n}(t),r=t.length,e=[],s=new Float32Array(2*i),h=[],a=[],o=3*i,u=2*i,c=n.depth,l=0,v=0,f=0,y=0;y<r;y++){var x=t[y];y>0&&e.push(l/2);for(var p=0,d=x.length;p<d;){var _=x[p],g=_[0],z=_[1],m=_[2]||0;s[l++]=g,s[l++]=z,h[v]=g,h[v+1]=z,h[v+2]=c+m,h[o+v]=g,h[o+v+1]=z,h[o+v+2]=m,a[f]=g,a[f+1]=z,a[u+f]=g,a[u+f+1]=z,v+=3,f+=2,p++}}return{flatVertices:s,holes:e,points:h,count:i,uv:a}}(t,n);return s.polygon=t,function(t,n){for(var i=[],r=t.count,e=0,s=n.length;e<s;e+=3){var h=n[e],a=n[e+1],o=n[e+2];i[e]=h,i[e+1]=a,i[e+2]=o;var u=s+e,c=r+h,l=r+a,v=r+o;i[u]=c,i[u+1]=l,i[u+2]=v}t.indices=i}(s,C(s.flatVertices,s.holes,2)),function(t,n){for(var i=t.points,r=t.indices,e=t.polygon,s=t.uv,h=n.depth,a=i.length-1,o=r.length-1,u=0,c=e.length;u<c;u++)for(var l=e[u],v=0,f=l.length;v<f;){var y=l[v],x=l[v+1];v===f-1&&(x=l[0]);var p=i.length/3,d=y[0],_=y[1],g=y[2]||0,z=x[0],m=x[1],w=x[2]||0;i[++a]=d,i[++a]=_,i[++a]=g+h,i[++a]=z,i[++a]=m,i[++a]=w+h,i[++a]=d,i[++a]=_,i[++a]=g,i[++a]=z,i[++a]=m,i[++a]=w;var M=p+2,b=p+3,A=p,P=p+1;r[++o]=M,r[++o]=A,r[++o]=b,r[++o]=A,r[++o]=P,r[++o]=b,N(s,i,M,b,A,P),v++}}(s,n),s.position=new Float32Array(s.points),s.indices=new Uint32Array(s.indices),s.uv=new Float32Array(s.uv),s.normal=I(s.indices,s.position),s})),r=U(i);return r.polygons=t,r},t.extrudePolylines=function(t,n){W(n=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},n));var i=t.map((function(t){var i=G(t,n);return i.line=t,X(i,n),B(i,n),i.position=new Float32Array(i.points),i.indices=new Uint32Array(i.indices),i.uv=new Float32Array(i.uv),i.normal=I(i.indices,i.position),i})),r=U(i);return r.lines=t,r},t.extrudeSlopes=function(t,n){W(n=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},n));var i=n,r=i.depth,e=i.side,s=i.sideDepth,h=t.map((function(t){var i=G(t,n);i.line=t;for(var h,a=i.leftPoints,o=i.rightPoints,u={line:t},c=0,l=t.length;c<l;c++)t[c][2]=t[c][2]||0;return"left"===e?(u.leftPoints=a,u.rightPoints=t,h=[s,r]):(u.leftPoints=t,u.rightPoints=o,h=[r,s]),u.depths=h,X(u,n),B(u,n),u.position=new Float32Array(u.points),u.indices=new Uint32Array(u.indices),u.uv=new Float32Array(u.uv),u.normal=I(u.indices,u.position),u})),a=U(h);return a.lines=t,a},t.leftOnLine=J,t.plane=function(t,n,i,r){for(var e=t/(i=Math.max(1,i)),s=n/(r=Math.max(1,r)),h=-t/2,a=n/2,o=-n/2,u=(i+1)*(r+1),c=new Float32Array(3*u),l=new Float32Array(2*u),v=new Float32Array(3*u),f=new Uint32Array(10*u),y=0,x=0,p=0,d=0;d<=r;d++)for(var _=0;_<=i;_++){var g=h+e*_,z=a-s*d;c[y]=g,c[y+1]=z,c[y+2]=0,v[y]=0,v[y+1]=0,v[y+2]=1;var m=(g-h)/t,w=(z-o)/n;if(l[x]=m,l[x+1]=w,y+=3,x+=2,_<i&&d<r){var M=d*(i+1)+_,b=M+1,A=(i+1)*(d+1)+_,P=A+1;f[p]=M,f[p+1]=A,f[p+2]=b,f[p+3]=A,f[p+4]=P,f[p+5]=b,p+=6}}for(var S=new Uint32Array(p),C=0,k=S.length;C<k;C++)S[C]=f[C];return{position:c,uv:l,normal:v,indices:S}},Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.11.0
2
+ * poly-extrude v0.13.0
3
3
  */
4
4
  var earcut$2 = {exports: {}};
5
5
 
@@ -1987,6 +1987,35 @@ function line2Vectors(line) {
1987
1987
 
1988
1988
  return points;
1989
1989
  }
1990
+ function calLineDistance(line) {
1991
+ var distance = 0;
1992
+
1993
+ for (var i = 0, len = line.length; i < len; i++) {
1994
+ var p1 = line[i],
1995
+ p2 = line[i + 1];
1996
+
1997
+ if (i === 0) {
1998
+ p1.distance = 0;
1999
+ }
2000
+
2001
+ if (p1 && p2) {
2002
+ var x1 = p1[0],
2003
+ y1 = p1[1],
2004
+ z1 = p1[2];
2005
+ var x2 = p2[0],
2006
+ y2 = p2[1],
2007
+ z2 = p2[2];
2008
+ var dx = x1 - x2,
2009
+ dy = y1 - y2,
2010
+ dz = (z1 || 0) - (z2 || 0);
2011
+ var dis = Math.sqrt(dx * dx + dy * dy + dz * dz);
2012
+ distance += dis;
2013
+ p2.distance = distance;
2014
+ }
2015
+ }
2016
+
2017
+ return distance;
2018
+ }
1990
2019
 
1991
2020
  function extrudePolygons(polygons, options) {
1992
2021
  options = Object.assign({}, {
@@ -2210,7 +2239,8 @@ function extrudePolylines(lines, options) {
2210
2239
  options = Object.assign({}, {
2211
2240
  depth: 2,
2212
2241
  lineWidth: 1,
2213
- bottomStickGround: false
2242
+ bottomStickGround: false,
2243
+ pathUV: false
2214
2244
  }, options);
2215
2245
  checkOptions(options);
2216
2246
  var results = lines.map(function (line) {
@@ -2234,7 +2264,9 @@ function extrudeSlopes(lines, options) {
2234
2264
  lineWidth: 1,
2235
2265
  side: 'left',
2236
2266
  sideDepth: 0,
2237
- bottomStickGround: false
2267
+ bottomStickGround: false,
2268
+ pathUV: false,
2269
+ isSlope: true
2238
2270
  }, options);
2239
2271
  checkOptions(options);
2240
2272
  var _options = options,
@@ -2291,13 +2323,24 @@ function generateTopAndBottom(result, options) {
2291
2323
  rz = depths[1];
2292
2324
  }
2293
2325
 
2294
- var points = [],
2295
- indices = [],
2296
- uv = [];
2297
2326
  var leftPoints = result.leftPoints,
2298
2327
  rightPoints = result.rightPoints;
2328
+ var line = result.line;
2329
+ var pathUV = options.pathUV;
2330
+
2331
+ if (pathUV) {
2332
+ calLineDistance(line);
2333
+
2334
+ for (var _i = 0, _len = line.length; _i < _len; _i++) {
2335
+ leftPoints[_i].distance = rightPoints[_i].distance = line[_i].distance;
2336
+ }
2337
+ }
2338
+
2299
2339
  var i = 0,
2300
2340
  len = leftPoints.length;
2341
+ var points = [],
2342
+ indices = [],
2343
+ uv = [];
2301
2344
 
2302
2345
  while (i < len) {
2303
2346
  // top left
@@ -2336,22 +2379,42 @@ function generateTopAndBottom(result, options) {
2336
2379
 
2337
2380
  if (bottomStickGround) {
2338
2381
  points[idx3 + 2] = 0;
2382
+ } // generate path uv
2383
+
2384
+
2385
+ if (pathUV) {
2386
+ var p = line[i];
2387
+ var uvx = p.distance;
2388
+ var uIndex0 = i * 2;
2389
+ uv[uIndex0] = uvx;
2390
+ uv[uIndex0 + 1] = 1;
2391
+ var uIndex1 = len * 2 + uIndex0;
2392
+ uv[uIndex1] = uvx;
2393
+ uv[uIndex1 + 1] = 0;
2394
+ var uIndex2 = len * 2 * 2 + uIndex0;
2395
+ uv[uIndex2] = uvx;
2396
+ uv[uIndex2 + 1] = 1;
2397
+ var uIndex3 = len * 2 * 2 + len * 2 + uIndex0;
2398
+ uv[uIndex3] = uvx;
2399
+ uv[uIndex3 + 1] = 0;
2339
2400
  }
2340
2401
 
2341
2402
  i++;
2342
2403
  }
2343
2404
 
2344
- i = 0;
2345
- len = points.length;
2346
- var uIndex = uv.length - 1;
2405
+ if (!pathUV) {
2406
+ i = 0;
2407
+ len = points.length;
2408
+ var uIndex = uv.length - 1;
2347
2409
 
2348
- while (i < len) {
2349
- var x = points[i],
2350
- y = points[i + 1];
2351
- uv[++uIndex] = x;
2352
- uv[++uIndex] = y; // uvs.push(x, y);
2410
+ while (i < len) {
2411
+ var x = points[i],
2412
+ y = points[i + 1];
2413
+ uv[++uIndex] = x;
2414
+ uv[++uIndex] = y; // uvs.push(x, y);
2353
2415
 
2354
- i += 3;
2416
+ i += 3;
2417
+ }
2355
2418
  }
2356
2419
 
2357
2420
  i = 0;
@@ -2417,19 +2480,24 @@ function generateSides(result, options) {
2417
2480
  var bottomStickGround = options.bottomStickGround;
2418
2481
  var rings = [leftPoints, rightPoints];
2419
2482
  var depthsEnable = result.depths;
2483
+ var pathUV = options.pathUV;
2484
+ var lineWidth = options.lineWidth;
2420
2485
  var pIndex = points.length - 1;
2421
2486
  var iIndex = indices.length - 1;
2487
+ var uIndex = uv.length - 1;
2422
2488
 
2423
2489
  function addOneSideIndex(v1, v2) {
2424
2490
  var idx = points.length / 3; // let pIndex = points.length - 1;
2425
- // top
2491
+
2492
+ var v1Depth = depthsEnable ? v1.depth : z;
2493
+ var v2Depth = depthsEnable ? v2.depth : z; // top
2426
2494
 
2427
2495
  points[++pIndex] = v1[0];
2428
2496
  points[++pIndex] = v1[1];
2429
- points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
2497
+ points[++pIndex] = v1Depth + v1[2];
2430
2498
  points[++pIndex] = v2[0];
2431
2499
  points[++pIndex] = v2[1];
2432
- points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
2500
+ points[++pIndex] = v2Depth + v2[2]; // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
2433
2501
  // bottom
2434
2502
 
2435
2503
  points[++pIndex] = v1[0];
@@ -2450,10 +2518,21 @@ function generateSides(result, options) {
2450
2518
  indices[++iIndex] = d;
2451
2519
  indices[++iIndex] = b; // index.push(a, c, b, c, d, b);
2452
2520
 
2453
- generateSideWallUV(uv, points, a, b, c, d);
2521
+ if (!pathUV) {
2522
+ generateSideWallUV(uv, points, a, b, c, d);
2523
+ } else {
2524
+ uv[++uIndex] = v1.distance;
2525
+ uv[++uIndex] = v1Depth / lineWidth;
2526
+ uv[++uIndex] = v2.distance;
2527
+ uv[++uIndex] = v2Depth / lineWidth;
2528
+ uv[++uIndex] = v1.distance;
2529
+ uv[++uIndex] = 0;
2530
+ uv[++uIndex] = v2.distance;
2531
+ uv[++uIndex] = 0;
2532
+ }
2454
2533
  }
2455
2534
 
2456
- for (var i = 0, _len = rings.length; i < _len; i++) {
2535
+ for (var i = 0, _len2 = rings.length; i < _len2; i++) {
2457
2536
  var ring = rings[i];
2458
2537
 
2459
2538
  if (i > 0) {
@@ -2477,9 +2556,9 @@ function generateSides(result, options) {
2477
2556
  var len = leftPoints.length;
2478
2557
  var vs = [rightPoints[0], leftPoints[0], leftPoints[len - 1], rightPoints[len - 1]];
2479
2558
 
2480
- for (var _i = 0; _i < vs.length; _i += 2) {
2481
- var _v = vs[_i],
2482
- _v2 = vs[_i + 1];
2559
+ for (var _i2 = 0; _i2 < vs.length; _i2 += 2) {
2560
+ var _v = vs[_i2],
2561
+ _v2 = vs[_i2 + 1];
2483
2562
  addOneSideIndex(_v, _v2);
2484
2563
  }
2485
2564
  }
@@ -2495,6 +2574,11 @@ var TEMPV1 = {
2495
2574
  function expandLine(line, options) {
2496
2575
  // let preAngle = 0;
2497
2576
  var radius = options.lineWidth / 2;
2577
+
2578
+ if (options.isSlope) {
2579
+ radius *= 2;
2580
+ }
2581
+
2498
2582
  var points = [],
2499
2583
  leftPoints = [],
2500
2584
  rightPoints = [];
@@ -2576,7 +2660,8 @@ function expandLine(line, options) {
2576
2660
  return {
2577
2661
  offsetPoints: points,
2578
2662
  leftPoints: leftPoints,
2579
- rightPoints: rightPoints
2663
+ rightPoints: rightPoints,
2664
+ line: line
2580
2665
  };
2581
2666
  } // eslint-disable-next-line no-unused-vars
2582
2667
 
@@ -4568,4 +4653,77 @@ function generateTubeVertexData(pathPointList, options) {
4568
4653
  };
4569
4654
  }
4570
4655
 
4571
- export { cylinder, expandLine, expandPaths, expandTubes, extrudePolygons, extrudePolylines, extrudeSlopes, leftOnLine };
4656
+ function plane(width, height, devideW, devideH) {
4657
+ devideW = Math.max(1, devideW);
4658
+ devideH = Math.max(1, devideH);
4659
+ var dx = width / devideW,
4660
+ dy = height / devideH;
4661
+ var minX = -width / 2,
4662
+ maxY = height / 2,
4663
+ minY = -height / 2;
4664
+ var len = (devideW + 1) * (devideH + 1);
4665
+ var position = new Float32Array(len * 3),
4666
+ uv = new Float32Array(len * 2),
4667
+ normal = new Float32Array(len * 3),
4668
+ indices = new Uint32Array(len * 10);
4669
+ var index = 0,
4670
+ uIndex = 0,
4671
+ iIndex = 0;
4672
+
4673
+ for (var j = 0; j <= devideH; j++) {
4674
+ for (var i = 0; i <= devideW; i++) {
4675
+ var x = minX + dx * i;
4676
+ var y = maxY - dy * j;
4677
+ position[index] = x;
4678
+ position[index + 1] = y;
4679
+ position[index + 2] = 0;
4680
+ normal[index] = 0;
4681
+ normal[index + 1] = 0;
4682
+ normal[index + 2] = 1; // position.push(x, y, 0);
4683
+ // normal.push(0, 0, 1);
4684
+
4685
+ var uvx = (x - minX) / width,
4686
+ uvy = (y - minY) / height; // uv.push(uvx, uvy);
4687
+
4688
+ uv[uIndex] = uvx;
4689
+ uv[uIndex + 1] = uvy;
4690
+ index += 3;
4691
+ uIndex += 2;
4692
+
4693
+ if (i < devideW && j < devideH) {
4694
+ var a = j * (devideW + 1) + i,
4695
+ b = a + 1,
4696
+ c = (devideW + 1) * (j + 1) + i,
4697
+ d = c + 1;
4698
+ indices[iIndex] = a;
4699
+ indices[iIndex + 1] = c;
4700
+ indices[iIndex + 2] = b;
4701
+ indices[iIndex + 3] = c;
4702
+ indices[iIndex + 4] = d;
4703
+ indices[iIndex + 5] = b;
4704
+ iIndex += 6; // indexs.push(a, c, b, c, d, b);
4705
+ }
4706
+ }
4707
+ }
4708
+
4709
+ var indexArray = new Uint32Array(iIndex);
4710
+
4711
+ for (var _i = 0, _len = indexArray.length; _i < _len; _i++) {
4712
+ indexArray[_i] = indices[_i];
4713
+ } // for (let j = 0; j < devideH; j++) {
4714
+ // for (let i = 0; i < devideW; i++) {
4715
+ // const a = j * (devideW + 1) + i, b = a + 1, c = (devideW + 1) * (j + 1) + i, d = c + 1;
4716
+ // indexs.push(a, c, b, c, d, b);
4717
+ // }
4718
+ // }
4719
+
4720
+
4721
+ return {
4722
+ position: position,
4723
+ uv: uv,
4724
+ normal: normal,
4725
+ indices: indexArray
4726
+ };
4727
+ }
4728
+
4729
+ export { cylinder, expandLine, expandPaths, expandTubes, extrudePolygons, extrudePolylines, extrudeSlopes, leftOnLine, plane };
package/index.js CHANGED
@@ -3,4 +3,5 @@ import { extrudePolylines, expandLine, leftOnLine, extrudeSlopes } from './src/p
3
3
  import { cylinder } from './src/cylinder';
4
4
  import { expandPaths } from './src/path';
5
5
  import { expandTubes } from './src/tube';
6
- export { extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes };
6
+ import { plane } from './src/plane';
7
+ export { extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes, plane };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "poly-extrude",
3
- "version": "0.11.0",
3
+ "version": "0.13.0",
4
4
  "description": "",
5
5
  "main": "dist/poly-extrude.js",
6
6
  "module": "dist/poly-extrude.mjs",
7
7
  "scripts": {
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "lint": "eslint src/**/*.js",
10
- "build": "npm run lint && cross-env NODE_ENV=dev rollup -c",
10
+ "build": "npm run lint && cross-env NODE_ENV=prd rollup -c",
11
11
  "dev": "npm run lint && cross-env NODE_ENV=dev rollup -c -w"
12
12
  },
13
13
  "repository": {
package/readme.md CHANGED
@@ -124,12 +124,14 @@ npm i poly-extrude
124
124
  ```
125
125
 
126
126
  ![](./img/extrudePolylines.png)
127
+
127
128
  ### `extrudePolylines(lines, options)`
128
129
 
129
130
  * `lines`
130
131
  * `options.depth`
131
132
  * `options.lineWidth`
132
- * `options.bottomStickGround` Is the bottom attached to the ground
133
+ * `options.bottomStickGround` Is the bottom attached to the ground
134
+ * `options.pathUV` generate Path UV
133
135
 
134
136
  ```js
135
137
  const result = extrudePolylines(polylines, {
@@ -146,6 +148,7 @@ npm i poly-extrude
146
148
  ```
147
149
 
148
150
  ![](./img/cylinder.png)
151
+
149
152
  ### `cylinder(center, options)`
150
153
 
151
154
  * `center`
@@ -173,6 +176,7 @@ const {
173
176
  ```
174
177
 
175
178
  ![](./img/expandPaths.png)
179
+
176
180
  ### `expandPaths(lines, options)`
177
181
 
178
182
  * `lines`
@@ -206,6 +210,7 @@ const {
206
210
  * `options.side` Which side serves as the slope, 'left' or 'right'
207
211
  * `options.sideDepth` slope depth
208
212
  * `options.bottomStickGround` Is the bottom attached to the ground
213
+ * `options.pathUV` generate Path UV
209
214
 
210
215
  ```js
211
216
  const result = extrudeSlopes(polylines, {
@@ -228,6 +233,7 @@ const {
228
233
  ```
229
234
 
230
235
  ![](./img/expandTubes.png)
236
+
231
237
  ### `expandTubes(lines, options)`
232
238
 
233
239
  * `lines`
@@ -251,3 +257,25 @@ const {
251
257
  } = result;
252
258
  //do something
253
259
  ```
260
+
261
+ ![](./img/plane.png)
262
+
263
+ ### `plane(width, height,devideW,devideH)`
264
+
265
+ * `width`
266
+ * `height`
267
+ * `devideW`
268
+ * `devideH`
269
+
270
+ ```js
271
+ const result = plane(100,100,10,10);
272
+ const {
273
+
274
+ positon,
275
+ normal,
276
+ uv,
277
+ indices
278
+
279
+ } = result;
280
+ //do something
281
+ ```
package/src/plane.js ADDED
@@ -0,0 +1,58 @@
1
+ export function plane(width, height, devideW, devideH) {
2
+ devideW = Math.max(1, devideW);
3
+ devideH = Math.max(1, devideH);
4
+ const dx = width / devideW, dy = height / devideH;
5
+ const minX = -width / 2, maxY = height / 2, minY = -height / 2;
6
+ const len = (devideW + 1) * (devideH + 1);
7
+ const position = new Float32Array(len * 3), uv = new Float32Array(len * 2), normal = new Float32Array(len * 3), indices = new Uint32Array(len * 10);
8
+ let index = 0, uIndex = 0, iIndex = 0;
9
+ for (let j = 0; j <= devideH; j++) {
10
+ for (let i = 0; i <= devideW; i++) {
11
+ const x = minX + dx * i;
12
+ const y = maxY - dy * j;
13
+ position[index] = x;
14
+ position[index + 1] = y;
15
+ position[index + 2] = 0;
16
+
17
+ normal[index] = 0;
18
+ normal[index + 1] = 0;
19
+ normal[index + 2] = 1;
20
+ // position.push(x, y, 0);
21
+ // normal.push(0, 0, 1);
22
+ const uvx = (x - minX) / width, uvy = (y - minY) / height;
23
+ // uv.push(uvx, uvy);
24
+ uv[uIndex] = uvx;
25
+ uv[uIndex + 1] = uvy;
26
+
27
+ index += 3;
28
+ uIndex += 2;
29
+ if (i < devideW && j < devideH) {
30
+ const a = j * (devideW + 1) + i, b = a + 1, c = (devideW + 1) * (j + 1) + i, d = c + 1;
31
+ indices[iIndex] = a;
32
+ indices[iIndex + 1] = c;
33
+ indices[iIndex + 2] = b;
34
+ indices[iIndex + 3] = c;
35
+ indices[iIndex + 4] = d;
36
+ indices[iIndex + 5] = b;
37
+ iIndex += 6;
38
+ // indexs.push(a, c, b, c, d, b);
39
+ }
40
+ }
41
+ }
42
+ const indexArray = new Uint32Array(iIndex);
43
+ for (let i = 0, len = indexArray.length; i < len; i++) {
44
+ indexArray[i] = indices[i];
45
+ }
46
+ // for (let j = 0; j < devideH; j++) {
47
+ // for (let i = 0; i < devideW; i++) {
48
+ // const a = j * (devideW + 1) + i, b = a + 1, c = (devideW + 1) * (j + 1) + i, d = c + 1;
49
+ // indexs.push(a, c, b, c, d, b);
50
+ // }
51
+ // }
52
+ return {
53
+ position,
54
+ uv,
55
+ normal,
56
+ indices: indexArray
57
+ };
58
+ }