poly-extrude 0.12.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.
- package/dist/poly-extrude.js +75 -1
- package/dist/poly-extrude.js.map +1 -1
- package/dist/poly-extrude.min.js +2 -2
- package/dist/poly-extrude.mjs +75 -2
- package/index.js +2 -1
- package/package.json +1 -1
- package/readme.md +28 -2
- package/src/plane.js +58 -0
package/dist/poly-extrude.min.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.13.0
|
3
3
|
*/
|
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})}));
|
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})}));
|
package/dist/poly-extrude.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* poly-extrude v0.
|
2
|
+
* poly-extrude v0.13.0
|
3
3
|
*/
|
4
4
|
var earcut$2 = {exports: {}};
|
5
5
|
|
@@ -4653,4 +4653,77 @@ function generateTubeVertexData(pathPointList, options) {
|
|
4653
4653
|
};
|
4654
4654
|
}
|
4655
4655
|
|
4656
|
-
|
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
|
-
|
6
|
+
import { plane } from './src/plane';
|
7
|
+
export { extrudePolygons, extrudePolylines, extrudeSlopes, expandLine, leftOnLine, cylinder, expandPaths, expandTubes, plane };
|
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -124,13 +124,14 @@ npm i poly-extrude
|
|
124
124
|
```
|
125
125
|
|
126
126
|

|
127
|
+
|
127
128
|
### `extrudePolylines(lines, options)`
|
128
129
|
|
129
130
|
* `lines`
|
130
131
|
* `options.depth`
|
131
132
|
* `options.lineWidth`
|
132
133
|
* `options.bottomStickGround` Is the bottom attached to the ground
|
133
|
-
* `options.
|
134
|
+
* `options.pathUV` generate Path UV
|
134
135
|
|
135
136
|
```js
|
136
137
|
const result = extrudePolylines(polylines, {
|
@@ -147,6 +148,7 @@ npm i poly-extrude
|
|
147
148
|
```
|
148
149
|
|
149
150
|

|
151
|
+
|
150
152
|
### `cylinder(center, options)`
|
151
153
|
|
152
154
|
* `center`
|
@@ -174,6 +176,7 @@ const {
|
|
174
176
|
```
|
175
177
|
|
176
178
|

|
179
|
+
|
177
180
|
### `expandPaths(lines, options)`
|
178
181
|
|
179
182
|
* `lines`
|
@@ -207,7 +210,7 @@ const {
|
|
207
210
|
* `options.side` Which side serves as the slope, 'left' or 'right'
|
208
211
|
* `options.sideDepth` slope depth
|
209
212
|
* `options.bottomStickGround` Is the bottom attached to the ground
|
210
|
-
* `options.
|
213
|
+
* `options.pathUV` generate Path UV
|
211
214
|
|
212
215
|
```js
|
213
216
|
const result = extrudeSlopes(polylines, {
|
@@ -230,6 +233,7 @@ const {
|
|
230
233
|
```
|
231
234
|
|
232
235
|

|
236
|
+
|
233
237
|
### `expandTubes(lines, options)`
|
234
238
|
|
235
239
|
* `lines`
|
@@ -253,3 +257,25 @@ const {
|
|
253
257
|
} = result;
|
254
258
|
//do something
|
255
259
|
```
|
260
|
+
|
261
|
+

|
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
|
+
}
|