poly-extrude 0.11.0 → 0.12.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.12.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,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).polyextrude=t.polyextrude||{})}(this,(function(t){"use strict";var i={exports:{}};function n(t,i,n){n=n||2;var e,h,a,o,u,v,f,y=i&&i.length,p=y?i[0]*n:t.length,d=r(t,0,p,n,!0),_=[];if(!d||d.next===d.prev)return _;if(y&&(d=function(t,i,n,e){var s,h,a,o=[];for(s=0,h=i.length;s<h;s++)(a=r(t,i[s]*e,s<h-1?i[s+1]*e:t.length,e,!1))===a.next&&(a.steiner=!0),o.push(x(a));for(o.sort(c),s=0;s<o.length;s++)n=l(o[s],n);return n}(t,i,d,n)),t.length>80*n){e=a=t[0],h=o=t[1];for(var g=n;g<p;g+=n)(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,_,n,e,h,f,0),_}function r(t,i,n,r,e){var s,h;if(e===S(t,i,n,r)>0)for(s=i;s<n;s+=r)h=b(s,t[s],t[s+1],h);else for(s=n-r;s>=i;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,i){if(!t)return t;i||(i=t);var n,r=t;do{if(n=!1,r.steiner||!_(r,r.next)&&0!==d(r.prev,r,r.next))r=r.next;else{if(P(r),(r=i=r.prev)===r.next)break;n=!0}}while(n||r!==i);return i}function s(t,i,n,r,c,l,v){if(t){!v&&l&&function(t,i,n,r){var e=t;do{0===e.z&&(e.z=f(e.x,e.y,i,n,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 i,n,r,e,s,h,a,o,u=1;do{for(n=t,t=null,s=null,h=0;n;){for(h++,r=n,a=0,i=0;i<u&&(a++,r=r.nextZ);i++);for(o=u;a>0||o>0&&r;)0!==a&&(0===o||!r||n.z<=r.z)?(e=n,n=n.nextZ,a--):(e=r,r=r.nextZ,o--),s?s.nextZ=e:t=e,e.prevZ=s,s=e;n=r}s.nextZ=null,u*=2}while(h>1)}(e)}(t,r,c,l);for(var x,y,p=t;t.prev!==t.next;)if(x=t.prev,y=t.next,l?a(t,r,c,l):h(t))i.push(x.i/n|0),i.push(t.i/n|0),i.push(y.i/n|0),P(t),t=y.next,p=y.next;else if((t=y)===p){v?1===v?s(t=o(e(t),i,n),i,n,r,c,l,2):2===v&&u(t,i,n,r,c,l):s(e(t),i,n,r,c,l,1);break}}}function h(t){var i=t.prev,n=t,r=t.next;if(d(i,n,r)>=0)return!1;for(var e=i.x,s=n.x,h=r.x,a=i.y,o=n.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,x=r.next;x!==i;){if(x.x>=c&&x.x<=v&&x.y>=l&&x.y<=f&&y(e,a,s,o,h,u,x.x,x.y)&&d(x.prev,x,x.next)>=0)return!1;x=x.next}return!0}function a(t,i,n,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,x=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(x,p,i,n,r),m=f(_,g,i,n,r),w=t.prevZ,M=t.nextZ;w&&w.z>=z&&M&&M.z<=m;){if(w.x>=x&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&y(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>=x&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&y(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>=x&&w.x<=_&&w.y>=p&&w.y<=g&&w!==e&&w!==h&&y(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>=x&&M.x<=_&&M.y>=p&&M.y<=g&&M!==e&&M!==h&&y(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,i,n){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)&&(i.push(s.i/n|0),i.push(r.i/n|0),i.push(h.i/n|0),P(r),P(r.next),r=t=h),r=r.next}while(r!==t);return e(r)}function u(t,i,n,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,i,n,r,h,a,0),void s(c,i,n,r,h,a,0)}u=u.next}o=o.next}while(o!==t)}function c(t,i){return t.x-i.x}function l(t,i){var n=function(t,i){var n,r=i,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,n=r.x<r.next.x?r:r.next,a===e))return n}r=r.next}while(r!==i);if(!n)return null;var o,u=n,c=n.x,l=n.y,f=1/0;r=n;do{e>=r.x&&r.x>=c&&e!==r.x&&y(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>n.x||r.x===n.x&&v(n,r)))&&(n=r,f=o)),r=r.next}while(r!==u);return n}(t,i);if(!n)return i;var r=M(n,t);return e(r,r.next),e(n,n.next)}function v(t,i){return d(t.prev,t,i.prev)<0&&d(i.next,t,t.next)<0}function f(t,i,n,r,e){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-n)*e|0)|t<<8))|t<<4))|t<<2))|t<<1))|(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*e|0)|i<<8))|i<<4))|i<<2))|i<<1))<<1}function x(t){var i=t,n=t;do{(i.x<n.x||i.x===n.x&&i.y<n.y)&&(n=i),i=i.next}while(i!==t);return n}function y(t,i,n,r,e,s,h,a){return(e-h)*(i-a)>=(t-h)*(s-a)&&(t-h)*(r-a)>=(n-h)*(i-a)&&(n-h)*(s-a)>=(e-h)*(r-a)}function p(t,i){return t.next.i!==i.i&&t.prev.i!==i.i&&!function(t,i){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==i.i&&n.next.i!==i.i&&g(n,n.next,t,i))return!0;n=n.next}while(n!==t);return!1}(t,i)&&(w(t,i)&&w(i,t)&&function(t,i){var n=t,r=!1,e=(t.x+i.x)/2,s=(t.y+i.y)/2;do{n.y>s!=n.next.y>s&&n.next.y!==n.y&&e<(n.next.x-n.x)*(s-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,i)&&(d(t.prev,t,i.prev)||d(t,i.prev,i))||_(t,i)&&d(t.prev,t,t.next)>0&&d(i.prev,i,i.next)>0)}function d(t,i,n){return(i.y-t.y)*(n.x-i.x)-(i.x-t.x)*(n.y-i.y)}function _(t,i){return t.x===i.x&&t.y===i.y}function g(t,i,n,r){var e=m(d(t,i,n)),s=m(d(t,i,r)),h=m(d(n,r,t)),a=m(d(n,r,i));return e!==s&&h!==a||(!(0!==e||!z(t,n,i))||(!(0!==s||!z(t,r,i))||(!(0!==h||!z(n,t,r))||!(0!==a||!z(n,i,r)))))}function z(t,i,n){return i.x<=Math.max(t.x,n.x)&&i.x>=Math.min(t.x,n.x)&&i.y<=Math.max(t.y,n.y)&&i.y>=Math.min(t.y,n.y)}function m(t){return t>0?1:t<0?-1:0}function w(t,i){return d(t.prev,t,t.next)<0?d(t,i,t.next)>=0&&d(t,t.prev,i)>=0:d(t,i,t.prev)<0||d(t,t.next,i)<0}function M(t,i){var n=new A(t.i,t.x,t.y),r=new A(i.i,i.x,i.y),e=t.next,s=i.prev;return t.next=i,i.prev=t,n.next=e,e.prev=n,r.next=n,n.prev=r,s.next=r,r.prev=s,r}function b(t,i,n,r){var e=new A(t,i,n);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,i,n){this.i=t,this.x=i,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function S(t,i,n,r){for(var e=0,s=i,h=n-r;s<n;s+=r)e+=(t[h]-t[s])*(t[s+1]+t[h+1]),h=s;return e}i.exports=n,i.exports.default=n,n.deviation=function(t,i,n,r){var e=i&&i.length,s=e?i[0]*n:t.length,h=Math.abs(S(t,0,s,n));if(e)for(var a=0,o=i.length;a<o;a++){var u=i[a]*n,c=a<o-1?i[a+1]*n:t.length;h-=Math.abs(S(t,u,c,n))}var l=0;for(a=0;a<r.length;a+=3){var v=r[a]*n,f=r[a+1]*n,x=r[a+2]*n;l+=Math.abs((t[v]-t[x])*(t[f+1]-t[v+1])-(t[v]-t[f])*(t[x+1]-t[v+1]))}return 0===h&&0===l?0:Math.abs((l-h)/h)},n.flatten=function(t){for(var i=t[0][0].length,n={vertices:[],holes:[],dimensions:i},r=0,e=0;e<t.length;e++){for(var s=0;s<t[e].length;s++)for(var h=0;h<i;h++)n.vertices.push(t[e][s][h]);e>0&&(r+=t[e-1].length,n.holes.push(r))}return n};var C=i.exports;function k(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function V(t,i){return V=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,i){return t.__proto__=i,t},V(t,i)}var Z=new(function(){function t(t,i,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),this.isQuaternion=!0,this._x=t,this._y=i,this._z=n,this._w=r}t.slerpFlat=function(t,i,n,r,e,s,h){var a=n[r+0],o=n[r+1],u=n[r+2],c=n[r+3],l=e[s+0],v=e[s+1],f=e[s+2],x=e[s+3];if(0===h)return t[i+0]=a,t[i+1]=o,t[i+2]=u,void(t[i+3]=c);if(1===h)return t[i+0]=l,t[i+1]=v,t[i+2]=f,void(t[i+3]=x);if(c!==x||a!==l||o!==v||u!==f){var y=1-h,p=a*l+o*v+u*f+c*x,d=p>=0?1:-1,_=1-p*p;if(_>Number.EPSILON){var g=Math.sqrt(_),z=Math.atan2(g,p*d);y=Math.sin(y*z)/g,h=Math.sin(h*z)/g}var m=h*d;if(a=a*y+l*m,o=o*y+v*m,u=u*y+f*m,c=c*y+x*m,y===1-h){var w=1/Math.sqrt(a*a+o*o+u*u+c*c);a*=w,o*=w,u*=w,c*=w}}t[i]=a,t[i+1]=o,t[i+2]=u,t[i+3]=c},t.multiplyQuaternionsFlat=function(t,i,n,r,e,s){var h=n[r],a=n[r+1],o=n[r+2],u=n[r+3],c=e[s],l=e[s+1],v=e[s+2],f=e[s+3];return t[i]=h*f+u*c+a*v-o*l,t[i+1]=a*f+u*l+o*c-h*v,t[i+2]=o*f+u*v+h*l-a*c,t[i+3]=u*f-h*c-a*l-o*v,t};var i,n,r,e=t.prototype;return e.set=function(t,i,n,r){return this._x=t,this._y=i,this._z=n,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,i){void 0===i&&(i=!0);var n=t._x,r=t._y,e=t._z,s=t._order,h=Math.cos,a=Math.sin,o=h(n/2),u=h(r/2),c=h(e/2),l=a(n/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===i&&this._onChangeCallback(),this},e.setFromAxisAngle=function(t,i){var n=i/2,r=Math.sin(n);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(n),this._onChangeCallback(),this},e.setFromRotationMatrix=function(t){var i=t.elements,n=i[0],r=i[4],e=i[8],s=i[1],h=i[5],a=i[9],o=i[2],u=i[6],c=i[10],l=n+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(n>h&&n>c){var f=2*Math.sqrt(1+n-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 x=2*Math.sqrt(1+h-n-c);this._w=(e-o)/x,this._x=(r+s)/x,this._y=.25*x,this._z=(a+u)/x}else{var y=2*Math.sqrt(1+c-n-h);this._w=(s-r)/y,this._x=(e+o)/y,this._y=(a+u)/y,this._z=.25*y}return this._onChangeCallback(),this},e.setFromUnitVectors=function(t,i){var n=t.dot(i)+1;return n<Number.EPSILON?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*i.z-t.z*i.y,this._y=t.z*i.x-t.x*i.z,this._z=t.x*i.y-t.y*i.x,this._w=n),this.normalize()},e.rotateTowards=function(t,i){var n=this.angleTo(t);if(0===n)return this;var r=Math.min(1,i/n);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,i){var n=t._x,r=t._y,e=t._z,s=t._w,h=i._x,a=i._y,o=i._z,u=i._w;return this._x=n*u+s*h+r*o-e*a,this._y=r*u+s*a+e*h-n*o,this._z=e*u+s*o+n*a-r*h,this._w=s*u-n*h-r*a-e*o,this._onChangeCallback(),this},e.slerp=function(t,i){if(0===i)return this;if(1===i)return this.copy(t);var n=this._x,r=this._y,e=this._z,s=this._w,h=s*t._w+n*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=n,this._y=r,this._z=e,this;var a=1-h*h;if(a<=Number.EPSILON){var o=1-i;return this._w=o*s+i*this._w,this._x=o*n+i*this._x,this._y=o*r+i*this._y,this._z=o*e+i*this._z,this.normalize(),this}var u=Math.sqrt(a),c=Math.atan2(u,h),l=Math.sin((1-i)*c)/u,v=Math.sin(i*c)/u;return this._w=s*l+this._w*v,this._x=n*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,i,n){return this.copy(t).slerp(i,n)},e.random=function(){var t=2*Math.PI*Math.random(),i=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),e=Math.sqrt(n);return this.set(r*Math.sin(t),r*Math.cos(t),e*Math.sin(i),e*Math.cos(i))},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,i){return void 0===i&&(i=0),this._x=t[i],this._y=t[i+1],this._z=t[i+2],this._w=t[i+3],this._onChangeCallback(),this},e.toArray=function(t,i){return void 0===t&&(t=[]),void 0===i&&(i=0),t[i]=this._x,t[i+1]=this._y,t[i+2]=this._z,t[i+3]=this._w,t},e.fromBufferAttribute=function(t,i){return this._x=t.getX(i),this._y=t.getY(i),this._z=t.getZ(i),this._w=t.getW(i),this._onChangeCallback(),this},e.toJSON=function(){return this.toArray()},e._onChange=function(t){return this._onChangeCallback=t,this},e._onChangeCallback=function(){},i=t,(n=[{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(i.prototype,n),r&&k(i,r),Object.defineProperty(i,"prototype",{writable:!1}),t}()),F=function(){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=i,this.z=n}var i=t.prototype;return i.set=function(t,i,n){return void 0===n&&(n=this.z),this.x=t,this.y=i,this.z=n,this},i.clone=function(){return new this.constructor(this.x,this.y,this.z)},i.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},i.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},i.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},i.addVectors=function(t,i){return this.x=t.x+i.x,this.y=t.y+i.y,this.z=t.z+i.z,this},i.addScaledVector=function(t,i){return this.x+=t.x*i,this.y+=t.y*i,this.z+=t.z*i,this},i.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},i.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},i.subVectors=function(t,i){return this.x=t.x-i.x,this.y=t.y-i.y,this.z=t.z-i.z,this},i.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},i.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},i.multiplyVectors=function(t,i){return this.x=t.x*i.x,this.y=t.y*i.y,this.z=t.z*i.z,this},i.applyAxisAngle=function(t,i){return this.applyQuaternion(Z.setFromAxisAngle(t,i))},i.applyMatrix4=function(t){var i=this.x,n=this.y,r=this.z,e=t.elements,s=1/(e[3]*i+e[7]*n+e[11]*r+e[15]);return this.x=(e[0]*i+e[4]*n+e[8]*r+e[12])*s,this.y=(e[1]*i+e[5]*n+e[9]*r+e[13])*s,this.z=(e[2]*i+e[6]*n+e[10]*r+e[14])*s,this},i.applyQuaternion=function(t){var i=this.x,n=this.y,r=this.z,e=t.x,s=t.y,h=t.z,a=t.w,o=a*i+s*r-h*n,u=a*n+h*i-e*r,c=a*r+e*n-s*i,l=-e*i-s*n-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},i.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},i.divideScalar=function(t){return this.multiplyScalar(1/t)},i.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},i.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},i.clamp=function(t,i){return this.x=Math.max(t.x,Math.min(i.x,this.x)),this.y=Math.max(t.y,Math.min(i.y,this.y)),this.z=Math.max(t.z,Math.min(i.z,this.z)),this},i.clampScalar=function(t,i){return this.x=Math.max(t,Math.min(i,this.x)),this.y=Math.max(t,Math.min(i,this.y)),this.z=Math.max(t,Math.min(i,this.z)),this},i.clampLength=function(t,i){var n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(i,n)))},i.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},i.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.normalize=function(){return this.divideScalar(this.length()||1)},i.setLength=function(t){return this.normalize().multiplyScalar(t)},i.lerp=function(t,i){return this.x+=(t.x-this.x)*i,this.y+=(t.y-this.y)*i,this.z+=(t.z-this.z)*i,this},i.lerpVectors=function(t,i,n){return this.x=t.x+(i.x-t.x)*n,this.y=t.y+(i.y-t.y)*n,this.z=t.z+(i.z-t.z)*n,this},i.cross=function(t){return this.crossVectors(this,t)},i.crossVectors=function(t,i){var n=t.x,r=t.y,e=t.z,s=i.x,h=i.y,a=i.z;return this.x=r*a-e*h,this.y=e*s-n*a,this.z=n*h-r*s,this},i.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},i.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},i.fromArray=function(t,i){return void 0===i&&(i=0),this.x=t[i],this.y=t[i+1],this.z=t[i+2],this},i.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},t}();function q(t){for(var i,n,r=0,e=1,s=t.length;e<s;)i=n||t[0],r+=((n=t[e])[0]-i[0])*(n[1]+i[1]),e++;return r>0}function L(t,i,n){return t[0]=i[0]-n[0],t[1]=i[1]-n[1],t[2]=i[2]-n[2],t}function O(t,i){var n=i[0],r=i[1],e=i[2],s=Math.sqrt(n*n+r*r+e*e)||1;return t[0]=n/s,t[1]=r/s,t[2]=e/s,t}function I(t,i){function n(t,i,n,r){t[0]=i,t[1]=n,t[2]=r}for(var r,e,s,h,a,o,u,c,l,v=[],f=[],x=[],y=[],p=[],d=[],_=t.length,g=new Float32Array(i.length),z=0;z<_;){var m=3*t[z],w=3*t[z+1],M=3*t[z+2];n(v,i[m],i[m+1],i[m+2]),n(f,i[w],i[w+1],i[w+2]),n(x,i[M],i[M+1],i[M+2]),L(p,x,f),L(y,v,f),r=d,s=y,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;)n(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 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 i=0,n=0,r=0,e=t.length;r<e;r++){var s=t[r],h=s.position,a=s.indices;i+=h.length,n+=a.length}for(var o={position:new Float32Array(i),normal:new Float32Array(i),uv:new Float32Array(i/3*2),indices:new Uint32Array(n),results:t},u=0,c=0,l=0,v=0,f=0,x=t.length;f<x;f++){var y=t[f],p=y.position,d=y.indices,_=y.normal,g=y.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,i,n,r,e,s){var h=3*n,a=3*r,o=3*e,u=3*s,c=i[h],l=i[h+1],v=i[h+2],f=i[a],x=i[a+1],y=i[a+2],p=i[o],d=i[o+1],_=i[o+2],g=i[u],z=i[u+1],m=i[u+2],w=t.length-1;Math.abs(l-x)<Math.abs(c-f)?(t[++w]=c,t[++w]=1-v,t[++w]=f,t[++w]=1-y,t[++w]=p,t[++w]=1-_,t[++w]=g,t[++w]=1-m):(t[++w]=l,t[++w]=1-v,t[++w]=x,t[++w]=1-y,t[++w]=d,t[++w]=1-_,t[++w]=z,t[++w]=1-m)}function T(t){for(var i=[],n=0,r=t.length;n<r;n++){var e=t[n],s=e[0],h=e[1],a=e[2],o=new F(s,h,a||0);i[n]=o}return i}function Q(t){R(t)||t.push(t[0])}function R(t){var i=t.length,n=t[0],r=n[0],e=n[1],s=t[i-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,i){var n=i.bottomStickGround,r=i.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=i.pathUV;if(c){!function(t){for(var i=0,n=0,r=t.length;n<r;n++){var e=t[n],s=t[n+1];if(0===n&&(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);i+=Math.sqrt(u*u+c*c+l*l),s.distance=i}}}(u);for(var l=0,v=u.length;l<v;l++)a[l].distance=o[l].distance=u[l].distance}for(var f=0,x=a.length,y=[],p=[],d=[];f<x;){var _=3*f,g=a[f],z=g[0],m=g[1],w=g[2];y[_]=z,y[_+1]=m,y[_+2]=s+w;var M=o[f],b=M[0],P=M[1],A=M[2],S=3*x+_;y[S]=b,y[S+1]=P,y[S+2]=h+A;var C=2*x*3+_;y[C]=z,y[C+1]=m,y[C+2]=w,n&&(y[C+2]=0);var k=2*x*3+3*x+_;if(y[k]=b,y[k+1]=P,y[k+2]=A,n&&(y[k+2]=0),c){var V=u[f].distance,Z=2*f;d[Z]=V,d[Z+1]=1;var F=2*x+Z;d[F]=V,d[F+1]=0;var q=2*x*2+Z;d[q]=V,d[q+1]=1;var L=2*x*2+2*x+Z;d[L]=V,d[L+1]=0}f++}if(!c){f=0,x=y.length;for(var O=d.length-1;f<x;){var I=y[f],U=y[f+1];d[++O]=I,d[++O]=U,f+=3}}f=0,x=a.length;for(var j=p.length-1;f<x-1;){var E=f,N=f+1,T=E+x,Q=N+x;p[++j]=E,p[++j]=T,p[++j]=N,p[++j]=T,p[++j]=Q,p[++j]=N;var R=f+2*x,W=R+1,X=R+x,B=W+x;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=y,t.uv=d,e)for(x=a.length,f=0;f<x;)a[f].depth=s,o[f].depth=h,f++}function B(t,i){var n=t.points,r=t.indices,e=t.leftPoints,s=t.rightPoints,h=t.uv,a=i.depth,o=i.bottomStickGround,u=[e,s],c=t.depths,l=i.pathUV,v=i.lineWidth,f=n.length-1,x=r.length-1,y=h.length-1;function p(t,i){var e=n.length/3,s=c?t.depth:a,u=c?i.depth:a;n[++f]=t[0],n[++f]=t[1],n[++f]=s+t[2],n[++f]=i[0],n[++f]=i[1],n[++f]=u+i[2],n[++f]=t[0],n[++f]=t[1],n[++f]=o?0:t[2],n[++f]=i[0],n[++f]=i[1],n[++f]=o?0:i[2];var p=e+2,d=e+3,_=e,g=e+1;r[++x]=p,r[++x]=_,r[++x]=d,r[++x]=_,r[++x]=g,r[++x]=d,l?(h[++y]=t.distance,h[++y]=s/v,h[++y]=i.distance,h[++y]=u/v,h[++y]=t.distance,h[++y]=0,h[++y]=i.distance,h[++y]=0):N(h,n,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,i){var n=i.lineWidth/2;i.isSlope&&(n*=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,x=j(Math.atan(l/v));if(0===a||a===h-1)f=x,f-=90;else{var y=t[a-1];Y.x=y[0]-o[0],Y.y=y[1]-o[1],D.x=u[0]-o[0],D.y=u[1]-o[1],f=x-H(Y,D)/2}var p=E(f),d=c,_=[Math.cos(p)+d[0],Math.sin(p)+d[1]],g=K(o,u,n),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,line:t}}var H=function(t,i){var n=t.x,r=t.y,e=i.x,s=i.y,h=n*e+r*s,a=n*s-r*e;return(Math.atan2(a,h)/Math.PI*180+360)%360};function J(t,i,n){var r=i[0],e=i[1],s=n[0],h=n[1];return(e-h)*t[0]+(s-r)*t[1]+r*h-s*e>0}function K(t,i,n){var r=i[1]-t[1],e=i[0]-t[0],s=Math.atan2(r,e),h=s+Math.PI/2,a=Math.cos(h)*n,o=Math.sin(h)*n,u=[t[0]+a,t[1]+o],c=[i[0]+a,i[1]+o],l=s-Math.PI/2;return a=Math.cos(l)*n,o=Math.sin(l)*n,[[u,c],[[t[0]+a,t[1]+o],[i[0]+a,i[1]+o]]]}function $(t,i,n,r){var e=i[0]-t[0],s=i[1]-t[1],h=r[0]-n[0],a=r[1]-n[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=n[1]-l*n[0];return 0===e?u=l*(o=t[0])+f:0===h?u=c*(o=n[0])+v:0===s?o=((u=t[1])-f)/l:0===a?o=((u=n[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 i=t.prototype;return i.lerpPathPoints=function(t,i,n){this.pos.lerpVectors(t.pos,i.pos,n),this.dir.lerpVectors(t.dir,i.dir,n),this.up.lerpVectors(t.up,i.up,n),this.right.lerpVectors(t.right,i.right,n),this.dist=(i.dist-t.dist)*n+t.dist,this.widthScale=(i.widthScale-t.widthScale)*n+t.widthScale},i.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,i,n,r,e,s,h,a,o,u,c,l,v,f,x,y){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,i,n,r,e,s,h,a,o,u,c,l,v,f,x,y)}var i=t.prototype;return i.set=function(t,i,n,r,e,s,h,a,o,u,c,l,v,f,x,y){var p=this.elements;return p[0]=t,p[4]=i,p[8]=n,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]=x,p[15]=y,this},i.multiply=function(t){return this.multiplyMatrices(this,t)},i.makeRotationAxis=function(t,i){var n=Math.cos(i),r=Math.sin(i),e=1-n,s=t.x,h=t.y,a=t.z,o=e*s,u=e*h;return this.set(o*s+n,o*h-r*a,o*a+r*h,0,o*h+r*a,u*h+n,u*a-r*s,0,o*a-r*h,u*a+r*s,e*a*a+n,0,0,0,0,1),this},i.equals=function(t){for(var i=this.elements,n=t.elements,r=0;r<16;r++)if(i[r]!==n[r])return!1;return!0},t}();function nt(t,i,n,r){return function(t,i){var n=1-t;return n*n*i}(t,i)+function(t,i){return 2*(1-t)*t*i}(t,n)+function(t,i){return t*t*i}(t,r)}var rt=function(t){var i,n;function r(i,n,r){var e;return void 0===i&&(i=new F),void 0===n&&(n=new F),void 0===r&&(r=new F),(e=t.call(this)||this).isQuadraticBezierCurve3=!0,e.type="QuadraticBezierCurve3",e.v0=i,e.v1=n,e.v2=r,e}return n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,V(i,n),r.prototype.getPoint=function(t,i){void 0===i&&(i=new F);var n=i,r=this.v0,e=this.v1,s=this.v2;return n.set(nt(t,r.x,e.x,s.x),nt(t,r.y,e.y,s.y),nt(t,r.z,e.z,s.z)),n},r}(function(){function t(){this.type="Curve",this.arcLengthDivisions=200}var i=t.prototype;return i.getPoint=function(){return console.warn("THREE.Curve: .getPoint() not implemented."),null},i.getPointAt=function(t,i){var n=this.getUtoTmapping(t);return this.getPoint(n,i)},i.getPoints=function(t){void 0===t&&(t=5);for(var i=[],n=0;n<=t;n++)i.push(this.getPoint(n/t));return i},i.getLength=function(){var t=this.getLengths();return t[t.length-1]},i.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 i,n=[],r=this.getPoint(0),e=0;n.push(0);for(var s=1;s<=t;s++)e+=(i=this.getPoint(s/t)).distanceTo(r),n.push(e),r=i;return this.cacheArcLengths=n,n},i.getUtoTmapping=function(t,i){var n,r=this.getLengths(),e=0,s=r.length;n=i||t*r[s-1];for(var h,a=0,o=s-1;a<=o;)if((h=r[e=Math.floor(a+(o-a)/2)]-n)<0)a=e+1;else{if(!(h>0)){o=e;break}o=e-1}if(r[e=o]===n)return e/(s-1);var u=r[e];return(e+(n-u)/(r[e+1]-u))/(s-1)},t}()),et=new F,st=new F,ht=new F,at=new it,ot=new rt;var ut=function(){function t(){this.array=[],this.count=0}var i=t.prototype;return i.set=function(t,i,n,r,e){if(void 0===i&&(i=.1),void 0===n&&(n=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],i,n,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],i,n,r)},i.distance=function(){return this.count>0?this.array[this.count-1].dist:0},i._getByIndex=function(t){return this.array[t]||(this.array[t]=new tt),this.array[t]},i._start=function(t,i,n){this.count=0;var r=this._getByIndex(this.count);if(r.pos.copy(t),r.dir.subVectors(i,t),n)r.up.copy(n);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++},i._end=function(t){var i=this.array[this.count-1],n=this._getByIndex(this.count);n.pos.copy(t),n.dir.subVectors(t,i.pos);var r=n.dir.length();n.dir.normalize(),n.up.copy(i.up);var e=et.crossVectors(i.dir,n.dir);if(e.length()>Number.EPSILON){e.normalize();var s=Math.acos(Math.min(Math.max(i.dir.dot(n.dir),-1),1));n.up.applyMatrix4(at.makeRotationAxis(e,s))}n.right.crossVectors(n.dir,n.up).normalize(),n.dist=i.dist+r,n.widthScale=1,n.sharp=!1,this.count++},i._corner=function(t,i,n,r,e){if(n>0&&r>0){for(var s=function(t,i,n,r,e,s){var h=et.subVectors(i,t),a=st.subVectors(n,i),o=h.length(),u=a.length();h.normalize(),a.normalize();var c=Math.min(.999999*(e?o/2:o),r);s.v0.copy(i).sub(h.multiplyScalar(c)),s.v1.copy(i);var l=Math.min(u/2*.999999,r);return s.v2.copy(i).add(a.multiplyScalar(l)),s}(this.array[this.count-1].pos,t,i,n,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(i)||this._sharpCorner(h[r],i,e,2)}else this._sharpCorner(t,i,e,0,!0)},i._sharpCorner=function(t,i,n,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(i,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()),n)1===h.dir.dot(n)?h.right.crossVectors(o,n).normalize():h.right.crossVectors(h.dir,n).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,xt=new F,yt=new F,pt=new F;var dt=new F(0,0,1),_t=new F;t.cylinder=function(t,i){void 0===i&&(i={}),i=Object.assign({},{radius:1,height:2,radialSegments:6},i);for(var n=Math.round(Math.max(4,i.radialSegments)),r=i,e=r.radius,s=r.height,h=360/n/360*Math.PI*2,a=n+1,o=new Float32Array(3*a*2),u=t[0],c=t[1],l=0,v=0,f=3*a,x=2*a,y=[],p=[],d=y.length-1,_=-1;_<n;_++){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+x]=w,p[v+1+x]=M,l+=3,v+=2,_>1&&(y[++d]=0,y[++d]=_-1,y[++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=y.length;d=y.length-1;for(var A=0;A<P;A++){var S=y[A];y[++d]=S+a}var C=new Float32Array(2*(3*a*2-6)),k=-1;l=2*a,v=0,d=y.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;y[++d]=N,y[++d]=j,y[++d]=T,y[++d]=j,y[++d]=E,y[++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(y,W);return{points:o,indices:new Uint32Array(y),position:W,normal:X,uv:new Float32Array(p)}},t.expandLine=G,t.expandPaths=function(t,i){i=Object.assign({},{lineWidth:1,cornerRadius:0,cornerSplit:10},i);var n=t.map((function(t){var n=T(t),r=new ut;r.set(n,i.cornerRadius,i.cornerSplit,ct);var e=function(t,i){var n=i.lineWidth||.1,r=1,e=n/2,s=n,h=t.distance(),a=r*h;if(0===h)return null;var o,u=e/s,c=0,l=[],v=[],f=[],x=[],y=0,p=l.length-1,d=v.length-1,_=f.length-1,g=x.length-1;function z(t){var i=0===l.length,n=t.sharp&&!i,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),n){ft.fromArray(l,l.length-6).sub(vt),xt.fromArray(l,l.length-3).sub(lt);var z,m,w=ft.length()-xt.length();w>0?(z=ft,m=vt):(z=xt,m=lt),yt.copy(z).setLength(Math.abs(w)).add(m);var M=pt.copy(m).sub(yt).normalize().dot(h)*pt.copy(m).sub(yt).length()*2;pt.copy(h).setLength(M).add(yt),w>0?(l[++p]=yt.x,l[++p]=yt.y,l[++p]=yt.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,y+=6,x[++g]=y-6,x[++g]=y-8,x[++g]=y-7,x[++g]=y-6,x[++g]=y-7,x[++g]=y-5,x[++g]=y-4,x[++g]=y-6,x[++g]=y-5,x[++g]=y-2,x[++g]=y-4,x[++g]=y-1,c+=12):(l[++p]=vt.x,l[++p]=vt.y,l[++p]=vt.z,l[++p]=yt.x,l[++p]=yt.y,l[++p]=yt.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,y+=6,x[++g]=y-6,x[++g]=y-8,x[++g]=y-7,x[++g]=y-6,x[++g]=y-7,x[++g]=y-5,x[++g]=y-6,x[++g]=y-5,x[++g]=y-3,x[++g]=y-2,x[++g]=y-3,x[++g]=y-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,y+=2,i||(x[++g]=y-2,x[++g]=y-4,x[++g]=y-3,x[++g]=y-2,x[++g]=y-3,x[++g]=y-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:x,count:c}}(r,i);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(n);return r.lines=t,r},t.expandTubes=function(t,i){i=Object.assign({},{radius:1,cornerSplit:0,radialSegments:8,startRad:-Math.PI/4},i);var n=t.map((function(t){var n=T(t),r=new ut;r.set(n,i.cornerRadius,i.cornerSplit,dt);var e=function(t,i){var n=Math.max(i.radius||1,1e-8),r=void 0!==i.progress?i.progress:1,e=Math.max(3,i.radialSegments||8),s=i.startRad||0,h=2*n*Math.PI,a=t.distance(),o=r*a;if(0===o)return null;var u=0,c=[],l=[],v=[],f=[],x=0,y=-1,p=-1,d=-1,_=-1;function g(t,i,n){for(var r=0===c.length,e=t.dist/h,a=0;a<=n;a++){var o=a;o===n&&(o=0),_t.copy(t.up).applyAxisAngle(t.dir,s+2*Math.PI*o/n).normalize();var g=i*t.widthScale;c[++y]=t.pos.x+_t.x*g,c[++y]=t.pos.y+_t.y*g,c[++y]=t.pos.z+_t.z*g,l[++p]=_t.x,l[++p]=_t.y,l[++p]=_t.z,v[++d]=e,v[++d]=a/n,x++}if(!r)for(var z=x-2*(n+1),m=x-(n+1),w=0;w<n;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,n,e);break}g(m,n,e)}return{points:c,normal:l,uv:v,indices:f,count:u}}(r,i);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(n);return r.lines=t,r},t.extrudePolygons=function(t,i){i=Object.assign({},{depth:2},i);var n=t.map((function(t){for(var n=0,r=t.length;n<r;n++){var e=t[n];Q(e),0===n?q(e)||(t[n]=e.reverse()):q(e)&&(t[n]=e.reverse()),R(e)&&e.splice(e.length-1,1)}var s=function(t,i){for(var n=function(t){var i=0,n=0,r=t.length;for(;n<r;)i+=t[n].length,n++;return i}(t),r=t.length,e=[],s=new Float32Array(2*n),h=[],a=[],o=3*n,u=2*n,c=i.depth,l=0,v=0,f=0,x=0;x<r;x++){var y=t[x];x>0&&e.push(l/2);for(var p=0,d=y.length;p<d;){var _=y[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:n,uv:a}}(t,i);return s.polygon=t,function(t,i){for(var n=[],r=t.count,e=0,s=i.length;e<s;e+=3){var h=i[e],a=i[e+1],o=i[e+2];n[e]=h,n[e+1]=a,n[e+2]=o;var u=s+e,c=r+h,l=r+a,v=r+o;n[u]=c,n[u+1]=l,n[u+2]=v}t.indices=n}(s,C(s.flatVertices,s.holes,2)),function(t,i){for(var n=t.points,r=t.indices,e=t.polygon,s=t.uv,h=i.depth,a=n.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 x=l[v],y=l[v+1];v===f-1&&(y=l[0]);var p=n.length/3,d=x[0],_=x[1],g=x[2]||0,z=y[0],m=y[1],w=y[2]||0;n[++a]=d,n[++a]=_,n[++a]=g+h,n[++a]=z,n[++a]=m,n[++a]=w+h,n[++a]=d,n[++a]=_,n[++a]=g,n[++a]=z,n[++a]=m,n[++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,n,M,b,P,A),v++}}(s,i),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(n);return r.polygons=t,r},t.extrudePolylines=function(t,i){W(i=Object.assign({},{depth:2,lineWidth:1,bottomStickGround:!1,pathUV:!1},i));var n=t.map((function(t){var n=G(t,i);return n.line=t,X(n,i),B(n,i),n.position=new Float32Array(n.points),n.indices=new Uint32Array(n.indices),n.uv=new Float32Array(n.uv),n.normal=I(n.indices,n.position),n})),r=U(n);return r.lines=t,r},t.extrudeSlopes=function(t,i){W(i=Object.assign({},{depth:2,lineWidth:1,side:"left",sideDepth:0,bottomStickGround:!1,pathUV:!1,isSlope:!0},i));var n=i,r=n.depth,e=n.side,s=n.sideDepth,h=t.map((function(t){var n=G(t,i);n.line=t;for(var h,a=n.leftPoints,o=n.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,i),B(u,i),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,Object.defineProperty(t,"__esModule",{value:!0})}));
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * poly-extrude v0.11.0
2
+ * poly-extrude v0.12.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
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "poly-extrude",
3
- "version": "0.11.0",
3
+ "version": "0.12.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
@@ -129,7 +129,8 @@ npm i poly-extrude
129
129
  * `lines`
130
130
  * `options.depth`
131
131
  * `options.lineWidth`
132
- * `options.bottomStickGround` Is the bottom attached to the ground
132
+ * `options.bottomStickGround` Is the bottom attached to the ground
133
+ * `options.pathuV` generate Path UV
133
134
 
134
135
  ```js
135
136
  const result = extrudePolylines(polylines, {
@@ -206,6 +207,7 @@ const {
206
207
  * `options.side` Which side serves as the slope, 'left' or 'right'
207
208
  * `options.sideDepth` slope depth
208
209
  * `options.bottomStickGround` Is the bottom attached to the ground
210
+ * `options.pathuV` generate Path UV
209
211
 
210
212
  ```js
211
213
  const result = extrudeSlopes(polylines, {
package/src/polyline.js CHANGED
@@ -1,4 +1,4 @@
1
- import { degToRad, generateNormal, generateSideWallUV, merge, radToDeg } from './util';
1
+ import { calLineDistance, degToRad, generateNormal, generateSideWallUV, merge, radToDeg } from './util';
2
2
 
3
3
  function checkOptions(options) {
4
4
  options.lineWidth = Math.max(0, options.lineWidth);
@@ -7,7 +7,7 @@ function checkOptions(options) {
7
7
  }
8
8
 
9
9
  export function extrudePolylines(lines, options) {
10
- options = Object.assign({}, { depth: 2, lineWidth: 1, bottomStickGround: false }, options);
10
+ options = Object.assign({}, { depth: 2, lineWidth: 1, bottomStickGround: false, pathUV: false }, options);
11
11
  checkOptions(options);
12
12
  const results = lines.map(line => {
13
13
  const result = expandLine(line, options);
@@ -26,7 +26,7 @@ export function extrudePolylines(lines, options) {
26
26
  }
27
27
 
28
28
  export function extrudeSlopes(lines, options) {
29
- options = Object.assign({}, { depth: 2, lineWidth: 1, side: 'left', sideDepth: 0, bottomStickGround: false }, options);
29
+ options = Object.assign({}, { depth: 2, lineWidth: 1, side: 'left', sideDepth: 0, bottomStickGround: false, pathUV: false, isSlope: true }, options);
30
30
  checkOptions(options);
31
31
  const { depth, side, sideDepth } = options;
32
32
  const results = lines.map(line => {
@@ -70,9 +70,17 @@ function generateTopAndBottom(result, options) {
70
70
  lz = depths[0];
71
71
  rz = depths[1];
72
72
  }
73
- const points = [], indices = [], uv = [];
74
73
  const { leftPoints, rightPoints } = result;
74
+ const line = result.line;
75
+ const pathUV = options.pathUV;
76
+ if (pathUV) {
77
+ calLineDistance(line);
78
+ for (let i = 0, len = line.length; i < len; i++) {
79
+ leftPoints[i].distance = rightPoints[i].distance = line[i].distance;
80
+ }
81
+ }
75
82
  let i = 0, len = leftPoints.length;
83
+ const points = [], indices = [], uv = [];
76
84
  while (i < len) {
77
85
  // top left
78
86
  const idx0 = i * 3;
@@ -106,18 +114,43 @@ function generateTopAndBottom(result, options) {
106
114
  points[idx3 + 2] = 0;
107
115
  }
108
116
 
117
+ // generate path uv
118
+ if (pathUV) {
119
+ const p = line[i];
120
+ const uvx = p.distance;
121
+
122
+ const uIndex0 = i * 2;
123
+ uv[uIndex0] = uvx;
124
+ uv[uIndex0 + 1] = 1;
125
+
126
+ const uIndex1 = len * 2 + uIndex0;
127
+ uv[uIndex1] = uvx;
128
+ uv[uIndex1 + 1] = 0;
129
+
130
+ const uIndex2 = (len * 2) * 2 + uIndex0;
131
+ uv[uIndex2] = uvx;
132
+ uv[uIndex2 + 1] = 1;
133
+
134
+ const uIndex3 = (len * 2) * 2 + len * 2 + uIndex0;
135
+ uv[uIndex3] = uvx;
136
+ uv[uIndex3 + 1] = 0;
137
+
138
+ }
109
139
  i++;
110
140
  }
111
- i = 0;
112
- len = points.length;
113
- let uIndex = uv.length - 1;
114
- while (i < len) {
115
- const x = points[i], y = points[i + 1];
116
- uv[++uIndex] = x;
117
- uv[++uIndex] = y;
118
- // uvs.push(x, y);
119
- i += 3;
141
+ if (!pathUV) {
142
+ i = 0;
143
+ len = points.length;
144
+ let uIndex = uv.length - 1;
145
+ while (i < len) {
146
+ const x = points[i], y = points[i + 1];
147
+ uv[++uIndex] = x;
148
+ uv[++uIndex] = y;
149
+ // uvs.push(x, y);
150
+ i += 3;
151
+ }
120
152
  }
153
+
121
154
  i = 0;
122
155
  len = leftPoints.length;
123
156
  let iIndex = indices.length - 1;
@@ -168,21 +201,28 @@ function generateSides(result, options) {
168
201
  const bottomStickGround = options.bottomStickGround;
169
202
  const rings = [leftPoints, rightPoints];
170
203
  const depthsEnable = result.depths;
204
+ const pathUV = options.pathUV;
205
+ const lineWidth = options.lineWidth;
171
206
 
172
207
  let pIndex = points.length - 1;
173
208
  let iIndex = indices.length - 1;
209
+ let uIndex = uv.length - 1;
210
+
174
211
  function addOneSideIndex(v1, v2) {
175
212
  const idx = points.length / 3;
176
213
  // let pIndex = points.length - 1;
177
214
 
215
+ const v1Depth = (depthsEnable ? v1.depth : z);
216
+ const v2Depth = (depthsEnable ? v2.depth : z);
217
+
178
218
  // top
179
219
  points[++pIndex] = v1[0];
180
220
  points[++pIndex] = v1[1];
181
- points[++pIndex] = (depthsEnable ? v1.depth : z) + v1[2];
221
+ points[++pIndex] = v1Depth + v1[2];
182
222
 
183
223
  points[++pIndex] = v2[0];
184
224
  points[++pIndex] = v2[1];
185
- points[++pIndex] = (depthsEnable ? v2.depth : z) + v2[2];
225
+ points[++pIndex] = v2Depth + v2[2];
186
226
 
187
227
  // points.push(v1[0], v1[1], (depthsEnable ? v1.depth : z) + v1[2], v2[0], v2[1], (depthsEnable ? v2.depth : z) + v2[2]);
188
228
 
@@ -206,7 +246,21 @@ function generateSides(result, options) {
206
246
  indices[++iIndex] = d;
207
247
  indices[++iIndex] = b;
208
248
  // index.push(a, c, b, c, d, b);
209
- generateSideWallUV(uv, points, a, b, c, d);
249
+ if (!pathUV) {
250
+ generateSideWallUV(uv, points, a, b, c, d);
251
+ } else {
252
+ uv[++uIndex] = v1.distance;
253
+ uv[++uIndex] = v1Depth / lineWidth;
254
+
255
+ uv[++uIndex] = v2.distance;
256
+ uv[++uIndex] = v2Depth / lineWidth;
257
+
258
+ uv[++uIndex] = v1.distance;
259
+ uv[++uIndex] = 0;
260
+
261
+ uv[++uIndex] = v2.distance;
262
+ uv[++uIndex] = 0;
263
+ }
210
264
  }
211
265
 
212
266
  for (let i = 0, len = rings.length; i < len; i++) {
@@ -238,7 +292,10 @@ const TEMPV1 = { x: 0, y: 0 }, TEMPV2 = { x: 0, y: 0 };
238
292
 
239
293
  export function expandLine(line, options) {
240
294
  // let preAngle = 0;
241
- const radius = options.lineWidth / 2;
295
+ let radius = options.lineWidth / 2;
296
+ if (options.isSlope) {
297
+ radius *= 2;
298
+ }
242
299
  const points = [], leftPoints = [], rightPoints = [];
243
300
  const len = line.length;
244
301
  let i = 0;
@@ -302,7 +359,7 @@ export function expandLine(line, options) {
302
359
  i++;
303
360
  }
304
361
 
305
- return { offsetPoints: points, leftPoints, rightPoints };
362
+ return { offsetPoints: points, leftPoints, rightPoints, line };
306
363
  }
307
364
 
308
365
  // eslint-disable-next-line no-unused-vars
package/src/util.js CHANGED
@@ -221,3 +221,22 @@ export function line2Vectors(line) {
221
221
  }
222
222
  return points;
223
223
  }
224
+
225
+ export function calLineDistance(line) {
226
+ let distance = 0;
227
+ for (let i = 0, len = line.length; i < len; i++) {
228
+ const p1 = line[i], p2 = line[i + 1];
229
+ if (i === 0) {
230
+ p1.distance = 0;
231
+ }
232
+ if (p1 && p2) {
233
+ const [x1, y1, z1] = p1;
234
+ const [x2, y2, z2] = p2;
235
+ const dx = x1 - x2, dy = y1 - y2, dz = (z1 || 0) - (z2 || 0);
236
+ const dis = Math.sqrt(dx * dx + dy * dy + dz * dz);
237
+ distance += dis;
238
+ p2.distance = distance;
239
+ }
240
+ }
241
+ return distance;
242
+ }