three-conic-polygon-geometry
Advanced tools
Comparing version 1.3.2 to 1.3.3
@@ -11,3 +11,4 @@ import { Geometry, BufferGeometry } from 'three'; | ||
closedTop: boolean, | ||
includeSides: boolean | ||
includeSides: boolean, | ||
curvatureResolution: number | ||
}; | ||
@@ -22,3 +23,4 @@ | ||
closedTop?: boolean, | ||
includeSides?: boolean | ||
includeSides?: boolean, | ||
curvatureResolution?: number | ||
); | ||
@@ -36,3 +38,4 @@ | ||
closedTop?: boolean, | ||
includeSides?: boolean | ||
includeSides?: boolean, | ||
curvatureResolution?: number | ||
); | ||
@@ -39,0 +42,0 @@ |
@@ -1,2 +0,2 @@ | ||
// Version 1.3.2 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
// Version 1.3.3 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],n):n((t=t||self).THREE=t.THREE||{},t.THREE)}(this,(function(t,n){"use strict";function e(t,n){return function(t){if(Array.isArray(t))return t}(t)||function(t,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(t)))return;var e=[],r=!0,i=!1,o=void 0;try{for(var u,s=t[Symbol.iterator]();!(r=(u=s.next()).done)&&(e.push(u.value),!n||e.length!==n);r=!0);}catch(t){i=!0,o=t}finally{try{r||null==s.return||s.return()}finally{if(i)throw o}}return e}(t,n)||i(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t))return Array.from(t)}(t)||i(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t,n){if(t){if("string"==typeof t)return o(t,n);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,n):void 0}}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}const u=Math.pow(2,-52),s=new Uint32Array(512);class a{static from(t,n=p,e=d){const r=t.length,i=new Float64Array(2*r);for(let o=0;o<r;o++){const r=t[o];i[2*o]=n(r),i[2*o+1]=e(r)}return new a(i)}constructor(t){const n=t.length>>1;if(n>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const e=Math.max(2*n-5,0);this._triangles=new Uint32Array(3*e),this._halfedges=new Int32Array(3*e),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize).fill(-1),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:e,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let s=1/0,a=1/0,l=-1/0,c=-1/0;for(let n=0;n<o;n++){const e=t[2*n],r=t[2*n+1];e<s&&(s=e),r<a&&(a=r),e>l&&(l=e),r>c&&(c=r),this._ids[n]=n}const v=(s+l)/2,p=(a+c)/2;let d,g,m,_=1/0;for(let n=0;n<o;n++){const e=f(v,p,t[2*n],t[2*n+1]);e<_&&(d=n,_=e)}const w=t[2*d],M=t[2*d+1];_=1/0;for(let n=0;n<o;n++){if(n===d)continue;const e=f(w,M,t[2*n],t[2*n+1]);e<_&&e>0&&(g=n,_=e)}let b=t[2*g],S=t[2*g+1],A=1/0;for(let n=0;n<o;n++){if(n===d||n===g)continue;const e=y(w,M,b,S,t[2*n],t[2*n+1]);e<A&&(m=n,A=e)}let Z=t[2*m],P=t[2*m+1];if(A===1/0){for(let n=0;n<o;n++)this._dists[n]=t[2*n]-t[0]||t[2*n+1]-t[1];x(this._ids,this._dists,0,o-1);const n=new Uint32Array(o);let e=0;for(let t=0,r=-1/0;t<o;t++){const i=this._ids[t];this._dists[i]>r&&(n[e++]=i,r=this._dists[i])}return this.hull=n.subarray(0,e),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(h(w,M,b,S,Z,P)){const t=g,n=b,e=S;g=m,b=Z,S=P,m=t,Z=n,P=e}const E=function(t,n,e,r,i,o){const u=e-t,s=r-n,a=i-t,f=o-n,l=u*u+s*s,h=a*a+f*f,c=.5/(u*f-s*a);return{x:t+(f*l-s*h)*c,y:n+(u*h-a*l)*c}}(w,M,b,S,Z,P);this._cx=E.x,this._cy=E.y;for(let n=0;n<o;n++)this._dists[n]=f(t[2*n],t[2*n+1],E.x,E.y);x(this._ids,this._dists,0,o-1),this._hullStart=d;let z=3;e[d]=n[m]=g,e[g]=n[d]=m,e[m]=n[g]=d,r[d]=0,r[g]=1,r[m]=2,i.fill(-1),i[this._hashKey(w,M)]=d,i[this._hashKey(b,S)]=g,i[this._hashKey(Z,P)]=m,this.trianglesLen=0,this._addTriangle(d,g,m,-1,-1,-1);for(let o,s,a=0;a<this._ids.length;a++){const f=this._ids[a],l=t[2*f],c=t[2*f+1];if(a>0&&Math.abs(l-o)<=u&&Math.abs(c-s)<=u)continue;if(o=l,s=c,f===d||f===g||f===m)continue;let y=0;for(let t=0,n=this._hashKey(l,c);t<this._hashSize&&(y=i[(n+t)%this._hashSize],-1===y||y===e[y]);t++);y=n[y];let x,v=y;for(;x=e[v],!h(l,c,t[2*v],t[2*v+1],t[2*x],t[2*x+1]);)if(v=x,v===y){v=-1;break}if(-1===v)continue;let p=this._addTriangle(v,f,e[v],-1,-1,r[v]);r[f]=this._legalize(p+2),r[v]=p,z++;let _=e[v];for(;x=e[_],h(l,c,t[2*_],t[2*_+1],t[2*x],t[2*x+1]);)p=this._addTriangle(_,f,x,r[f],-1,r[_]),r[f]=this._legalize(p+2),e[_]=_,z--,_=x;if(v===y)for(;x=n[v],h(l,c,t[2*x],t[2*x+1],t[2*v],t[2*v+1]);)p=this._addTriangle(x,f,v,-1,r[v],r[x]),this._legalize(p+2),r[x]=p,e[v]=v,z--,v=x;this._hullStart=n[f]=v,e[v]=n[_]=f,e[f]=_,i[this._hashKey(l,c)]=f,i[this._hashKey(t[2*v],t[2*v+1])]=v}this.hull=new Uint32Array(z);for(let t=0,n=this._hullStart;t<z;t++)this.hull[t]=n,n=e[n];this.triangles=this._triangles.subarray(0,this.trianglesLen),this.halfedges=this._halfedges.subarray(0,this.trianglesLen)}_hashKey(t,n){return Math.floor(function(t,n){const e=t/(Math.abs(t)+Math.abs(n));return(n>0?3-e:1+e)/4}(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:e,coords:r}=this;let i=0,o=0;for(;;){const u=e[t],a=t-t%3;if(o=a+(t+2)%3,-1===u){if(0===i)break;t=s[--i];continue}const f=u-u%3,l=a+(t+1)%3,h=f+(u+2)%3,y=n[o],x=n[t],v=n[l],p=n[h];if(c(r[2*y],r[2*y+1],r[2*x],r[2*x+1],r[2*v],r[2*v+1],r[2*p],r[2*p+1])){n[t]=p,n[u]=y;const r=e[h];if(-1===r){let n=this._hullStart;do{if(this._hullTri[n]===h){this._hullTri[n]=t;break}n=this._hullPrev[n]}while(n!==this._hullStart)}this._link(t,r),this._link(u,e[o]),this._link(o,h);const a=f+(u+1)%3;i<s.length&&(s[i++]=a)}else{if(0===i)break;t=s[--i]}}return o}_link(t,n){this._halfedges[t]=n,-1!==n&&(this._halfedges[n]=t)}_addTriangle(t,n,e,r,i,o){const u=this.trianglesLen;return this._triangles[u]=t,this._triangles[u+1]=n,this._triangles[u+2]=e,this._link(u,r),this._link(u+1,i),this._link(u+2,o),this.trianglesLen+=3,u}}function f(t,n,e,r){const i=t-e,o=n-r;return i*i+o*o}function l(t,n,e,r,i,o){const u=(r-n)*(i-t),s=(e-t)*(o-n);return Math.abs(u-s)>=33306690738754716e-32*Math.abs(u+s)?u-s:0}function h(t,n,e,r,i,o){return(l(i,o,t,n,e,r)||l(t,n,e,r,i,o)||l(e,r,i,o,t,n))<0}function c(t,n,e,r,i,o,u,s){const a=t-u,f=n-s,l=e-u,h=r-s,c=i-u,y=o-s,x=l*l+h*h,v=c*c+y*y;return a*(h*v-x*y)-f*(l*v-x*c)+(a*a+f*f)*(l*y-h*c)<0}function y(t,n,e,r,i,o){const u=e-t,s=r-n,a=i-t,f=o-n,l=u*u+s*s,h=a*a+f*f,c=.5/(u*f-s*a),y=(f*l-s*h)*c,x=(u*h-a*l)*c;return y*y+x*x}function x(t,n,e,r){if(r-e<=20)for(let i=e+1;i<=r;i++){const r=t[i],o=n[r];let u=i-1;for(;u>=e&&n[t[u]]>o;)t[u+1]=t[u--];t[u+1]=r}else{let i=e+1,o=r;v(t,e+r>>1,i),n[t[e]]>n[t[r]]&&v(t,e,r),n[t[i]]>n[t[r]]&&v(t,i,r),n[t[e]]>n[t[i]]&&v(t,e,i);const u=t[i],s=n[u];for(;;){do{i++}while(n[t[i]]<s);do{o--}while(n[t[o]]>s);if(o<i)break;v(t,i,o)}t[e+1]=t[o],t[o]=u,r-i+1>=o-e?(x(t,n,i,r),x(t,n,e,o-1)):(x(t,n,e,o-1),x(t,n,i,r))}}function v(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function p(t){return t[0]}function d(t){return t[1]}var g=_,m=_;function _(t,n,e){e=e||2;var r,i,o,u,s,a,f,l=n&&n.length,h=l?n[0]*e:t.length,c=w(t,0,h,e,!0),y=[];if(!c||c.next===c.prev)return y;if(l&&(c=function(t,n,e,r){var i,o,u,s,a,f=[];for(i=0,o=n.length;i<o;i++)u=n[i]*r,s=i<o-1?n[i+1]*r:t.length,(a=w(t,u,s,r,!1))===a.next&&(a.steiner=!0),f.push(k(a));for(f.sort(E),i=0;i<f.length;i++)z(f[i],e),e=M(e,e.next);return e}(t,n,c,e)),t.length>80*e){r=o=t[0],i=u=t[1];for(var x=e;x<h;x+=e)(s=t[x])<r&&(r=s),(a=t[x+1])<i&&(i=a),s>o&&(o=s),a>u&&(u=a);f=0!==(f=Math.max(o-r,u-i))?1/f:0}return b(c,y,e,r,i,f),y}function w(t,n,e,r,i){var o,u;if(i===q(t,n,e,r)>0)for(o=n;o<e;o+=r)u=K(o,t[o],t[o+1],u);else for(o=e-r;o>=n;o-=r)u=K(o,t[o],t[o+1],u);return u&&H(u,u.next)&&(R(u),u=u.next),u}function M(t,n){if(!t)return t;n||(n=t);var e,r=t;do{if(e=!1,r.steiner||!H(r,r.next)&&0!==O(r.prev,r,r.next))r=r.next;else{if(R(r),(r=n=r.prev)===r.next)break;e=!0}}while(e||r!==n);return n}function b(t,n,e,r,i,o,u){if(t){!u&&o&&function(t,n,e,r){var i=t;do{null===i.z&&(i.z=T(i.x,i.y,n,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var n,e,r,i,o,u,s,a,f=1;do{for(e=t,t=null,o=null,u=0;e;){for(u++,r=e,s=0,n=0;n<f&&(s++,r=r.nextZ);n++);for(a=f;s>0||a>0&&r;)0!==s&&(0===a||!r||e.z<=r.z)?(i=e,e=e.nextZ,s--):(i=r,r=r.nextZ,a--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;e=r}o.nextZ=null,f*=2}while(u>1)}(i)}(t,r,i,o);for(var s,a,f=t;t.prev!==t.next;)if(s=t.prev,a=t.next,o?A(t,r,i,o):S(t))n.push(s.i/e),n.push(t.i/e),n.push(a.i/e),R(t),t=a.next,f=a.next;else if((t=a)===f){u?1===u?b(t=Z(M(t),n,e),n,e,r,i,o,2):2===u&&P(t,n,e,r,i,o):b(M(t),n,e,r,i,o,1);break}}}function S(t){var n=t.prev,e=t,r=t.next;if(O(n,e,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(B(n.x,n.y,e.x,e.y,r.x,r.y,i.x,i.y)&&O(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function A(t,n,e,r){var i=t.prev,o=t,u=t.next;if(O(i,o,u)>=0)return!1;for(var s=i.x<o.x?i.x<u.x?i.x:u.x:o.x<u.x?o.x:u.x,a=i.y<o.y?i.y<u.y?i.y:u.y:o.y<u.y?o.y:u.y,f=i.x>o.x?i.x>u.x?i.x:u.x:o.x>u.x?o.x:u.x,l=i.y>o.y?i.y>u.y?i.y:u.y:o.y>u.y?o.y:u.y,h=T(s,a,n,e,r),c=T(f,l,n,e,r),y=t.prevZ,x=t.nextZ;y&&y.z>=h&&x&&x.z<=c;){if(y!==t.prev&&y!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,y.x,y.y)&&O(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,x!==t.prev&&x!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,x.x,x.y)&&O(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;y&&y.z>=h;){if(y!==t.prev&&y!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,y.x,y.y)&&O(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;x&&x.z<=c;){if(x!==t.prev&&x!==t.next&&B(i.x,i.y,o.x,o.y,u.x,u.y,x.x,x.y)&&O(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Z(t,n,e){var r=t;do{var i=r.prev,o=r.next.next;!H(i,o)&&U(i,r,r.next,o)&&L(i,o)&&L(o,i)&&(n.push(i.i/e),n.push(r.i/e),n.push(o.i/e),R(r),R(r.next),r=t=o),r=r.next}while(r!==t);return M(r)}function P(t,n,e,r,i,o){var u=t;do{for(var s=u.next.next;s!==u.prev;){if(u.i!==s.i&&I(u,s)){var a=C(u,s);return u=M(u,u.next),a=M(a,a.next),b(u,n,e,r,i,o),void b(a,n,e,r,i,o)}s=s.next}u=u.next}while(u!==t)}function E(t,n){return t.x-n.x}function z(t,n){if(n=function(t,n){var e,r=n,i=t.x,o=t.y,u=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>u){if(u=s,s===i){if(o===r.y)return r;if(o===r.next.y)return r.next}e=r.x<r.next.x?r:r.next}}r=r.next}while(r!==n);if(!e)return null;if(i===u)return e;var a,f=e,l=e.x,h=e.y,c=1/0;r=e;do{i>=r.x&&r.x>=l&&i!==r.x&&B(o<h?i:u,o,l,h,o<h?u:i,o,r.x,r.y)&&(a=Math.abs(o-r.y)/(i-r.x),L(r,t)&&(a<c||a===c&&(r.x>e.x||r.x===e.x&&G(e,r)))&&(e=r,c=a)),r=r.next}while(r!==f);return e}(t,n)){var e=C(n,t);M(n,n.next),M(e,e.next)}}function G(t,n){return O(t.prev,t,n.prev)<0&&O(n.next,t,t.next)<0}function T(t,n,e,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-e)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-r)*i)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function k(t){var n=t,e=t;do{(n.x<e.x||n.x===e.x&&n.y<e.y)&&(e=n),n=n.next}while(n!==t);return e}function B(t,n,e,r,i,o,u,s){return(i-u)*(n-s)-(t-u)*(o-s)>=0&&(t-u)*(r-s)-(e-u)*(n-s)>=0&&(e-u)*(o-s)-(i-u)*(r-s)>=0}function I(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&U(e,e.next,t,n))return!0;e=e.next}while(e!==t);return!1}(t,n)&&(L(t,n)&&L(n,t)&&function(t,n){var e=t,r=!1,i=(t.x+n.x)/2,o=(t.y+n.y)/2;do{e.y>o!=e.next.y>o&&e.next.y!==e.y&&i<(e.next.x-e.x)*(o-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next}while(e!==t);return r}(t,n)&&(O(t.prev,t,n.prev)||O(t,n.prev,n))||H(t,n)&&O(t.prev,t,t.next)>0&&O(n.prev,n,n.next)>0)}function O(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function H(t,n){return t.x===n.x&&t.y===n.y}function U(t,n,e,r){var i=F(O(t,n,e)),o=F(O(t,n,r)),u=F(O(e,r,t)),s=F(O(e,r,n));return i!==o&&u!==s||(!(0!==i||!j(t,e,n))||(!(0!==o||!j(t,r,n))||(!(0!==u||!j(e,t,r))||!(0!==s||!j(e,n,r)))))}function j(t,n,e){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}function F(t){return t>0?1:t<0?-1:0}function L(t,n){return O(t.prev,t,t.next)<0?O(t,n,t.next)>=0&&O(t,t.prev,n)>=0:O(t,n,t.prev)<0||O(t,t.next,n)<0}function C(t,n){var e=new N(t.i,t.x,t.y),r=new N(n.i,n.x,n.y),i=t.next,o=n.prev;return t.next=n,n.prev=t,e.next=i,i.prev=e,r.next=e,e.prev=r,o.next=r,r.prev=o,r}function K(t,n,e,r){var i=new N(t,n,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function R(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 N(t,n,e){this.i=t,this.x=n,this.y=e,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function q(t,n,e,r){for(var i=0,o=n,u=e-r;o<e;o+=r)i+=(t[u]-t[o])*(t[o+1]+t[u+1]),u=o;return i}function J(){return new V}function V(){this.reset()}_.deviation=function(t,n,e,r){var i=n&&n.length,o=i?n[0]*e:t.length,u=Math.abs(q(t,0,o,e));if(i)for(var s=0,a=n.length;s<a;s++){var f=n[s]*e,l=s<a-1?n[s+1]*e:t.length;u-=Math.abs(q(t,f,l,e))}var h=0;for(s=0;s<r.length;s+=3){var c=r[s]*e,y=r[s+1]*e,x=r[s+2]*e;h+=Math.abs((t[c]-t[x])*(t[y+1]-t[c+1])-(t[c]-t[y])*(t[x+1]-t[c+1]))}return 0===u&&0===h?0:Math.abs((h-u)/u)},_.flatten=function(t){for(var n=t[0][0].length,e={vertices:[],holes:[],dimensions:n},r=0,i=0;i<t.length;i++){for(var o=0;o<t[i].length;o++)for(var u=0;u<n;u++)e.vertices.push(t[i][o][u]);i>0&&(r+=t[i-1].length,e.holes.push(r))}return e},g.default=m,V.prototype={constructor:V,reset:function(){this.s=this.t=0},add:function(t){D($,t,this.t),D(this,$.s,this.s),this.s?this.t+=$.t:this.s=$.t},valueOf:function(){return this.s}};var $=new V;function D(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}var Q=Math.PI,W=Q/2,X=Q/4,Y=2*Q,tt=180/Q,nt=Q/180,et=Math.abs,rt=Math.atan2,it=Math.cos,ot=Math.sin,ut=Math.sign||function(t){return t>0?1:t<0?-1:0},st=Math.sqrt;function at(t){return t>1?W:t<-1?-W:Math.asin(t)}function ft(t){return(t=ot(t/2))*t}function lt(){}function ht(t,n){t&&yt.hasOwnProperty(t.type)&&yt[t.type](t,n)}var ct={Feature:function(t,n){ht(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)ht(e[r].geometry,n)}},yt={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){xt(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)xt(e[r],n,0)},Polygon:function(t,n){vt(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)vt(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)ht(e[r],n)}};function xt(t,n,e){var r,i=-1,o=t.length-e;for(n.lineStart();++i<o;)r=t[i],n.point(r[0],r[1],r[2]);n.lineEnd()}function vt(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)xt(t[e],n,1);n.polygonEnd()}function pt(t){var n=t[0],e=t[1],r=it(e);return[r*it(n),r*ot(n),ot(e)]}function dt(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function gt(t){var n=st(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var mt=J();function _t(t){return et(t[0])<=Q?t[0]:ut(t[0])*((et(t[0])+Q)%Y-Q)}var wt,Mt,bt,St=J(),At={sphere:lt,point:lt,lineStart:function(){At.point=Pt,At.lineEnd=Zt},lineEnd:lt,polygonStart:lt,polygonEnd:lt};function Zt(){At.point=At.lineEnd=lt}function Pt(t,n){wt=t*=nt,Mt=ot(n*=nt),bt=it(n),At.point=Et}function Et(t,n){t*=nt;var e=ot(n*=nt),r=it(n),i=et(t-wt),o=it(i),u=r*ot(i),s=bt*e-Mt*r*o,a=Mt*e+bt*r*o;St.add(rt(st(u*u+s*s),a)),wt=t,Mt=e,bt=r}function zt(t){return St.reset(),function(t,n){t&&ct.hasOwnProperty(t.type)?ct[t.type](t,n):ht(t,n)}(t,At),+St}var Gt=[null,null],Tt={type:"LineString",coordinates:Gt};function kt(t,n){return Gt[0]=t,Gt[1]=n,zt(Tt)}var Bt={Feature:function(t,n){return Ot(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r<i;)if(Ot(e[r].geometry,n))return!0;return!1}},It={Sphere:function(){return!0},Point:function(t,n){return Ht(t.coordinates,n)},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Ht(e[r],n))return!0;return!1},LineString:function(t,n){return Ut(t.coordinates,n)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(Ut(e[r],n))return!0;return!1},Polygon:function(t,n){return jt(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;++r<i;)if(jt(e[r],n))return!0;return!1},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;++r<i;)if(Ot(e[r],n))return!0;return!1}};function Ot(t,n){return!(!t||!It.hasOwnProperty(t.type))&&It[t.type](t,n)}function Ht(t,n){return 0===kt(t,n)}function Ut(t,n){for(var e,r,i,o=0,u=t.length;o<u;o++){if(0===(r=kt(t[o],n)))return!0;if(o>0&&(i=kt(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))<1e-12*i)return!0;e=r}return!1}function jt(t,n){return!!function(t,n){var e=_t(n),r=n[1],i=ot(r),o=[ot(e),-it(e),0],u=0,s=0;mt.reset(),1===i?r=W+1e-6:-1===i&&(r=-W-1e-6);for(var a=0,f=t.length;a<f;++a)if(h=(l=t[a]).length)for(var l,h,c=l[h-1],y=_t(c),x=c[1]/2+X,v=ot(x),p=it(x),d=0;d<h;++d,y=m,v=w,p=M,c=g){var g=l[d],m=_t(g),_=g[1]/2+X,w=ot(_),M=it(_),b=m-y,S=b>=0?1:-1,A=S*b,Z=A>Q,P=v*w;if(mt.add(rt(P*S*ot(A),p*M+P*it(A))),u+=Z?b+S*Y:b,Z^y>=e^m>=e){var E=dt(pt(c),pt(g));gt(E);var z=dt(o,E);gt(z);var G=(Z^b>=0?-1:1)*at(z[2]);(r>G||r===G&&(E[0]||E[1]))&&(s+=Z^b>=0?1:-1)}}return(u<-1e-6||u<1e-6&&mt<-1e-6)^1&s}(t.map(Ft),Lt(n))}function Ft(t){return(t=t.map(Lt)).pop(),t}function Lt(t){return[t[0]*nt,t[1]*nt]}function Ct(t,n){return(t&&Bt.hasOwnProperty(t.type)?Bt[t.type]:Ot)(t,n)}function Kt(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r<n&&(r=n)));else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(void 0===e?o>=o&&(e=r=o):(e>o&&(e=o),r<o&&(r=o)))}return[e,r]}function Rt(t){return Array.from(function*(t){for(const n of t)yield*n}(t))}var Nt=window.THREE?window.THREE:{BufferGeometry:n.BufferGeometry,Float32BufferAttribute:n.Float32BufferAttribute,Geometry:n.Geometry},qt=(new Nt.BufferGeometry).setAttribute?"setAttribute":"addAttribute";function Jt(t,n,e,r,i,o,u){Nt.Geometry.call(this),this.type="ConicPolygonGeometry",this.parameters={polygonGeoJson:t,startHeight:n,endHeight:e,closedBottom:r,closedTop:i,includeSides:o,curvatureResolution:u},this.fromBufferGeometry(new Vt(t,n,e,r,i,o)),this.mergeVertices()}function Vt(t,n,i,o,u,s,f){var l=this;Nt.BufferGeometry.call(this),this.type="ConicPolygonBufferGeometry",this.parameters={polygonGeoJson:t,startHeight:n,endHeight:i,closedBottom:o,closedTop:u,includeSides:s,curvatureResolution:f},n=n||0,i=i||1,o=void 0===o||o,u=void 0===u||u,s=void 0===s||s;var h=function(t,n){return t.map((function(t){var e,r=[];return t.forEach((function(t){if(e){var i=180*kt(t,e)/Math.PI;if(i>n)for(var o=(f=t,l=(a=e)[0]*nt,h=a[1]*nt,c=f[0]*nt,y=f[1]*nt,x=it(h),v=ot(h),p=it(y),d=ot(y),g=x*it(l),m=x*ot(l),_=p*it(c),w=p*ot(c),M=2*at(st(ft(y-h)+x*p*ft(c-l))),b=ot(M),(S=M?function(t){var n=ot(t*=M)/b,e=ot(M-t)/b,r=e*g+n*_,i=e*m+n*w,o=e*v+n*d;return[rt(i,r)*tt,rt(o,st(r*r+i*i))*tt]}:function(){return[l*tt,h*tt]}).distance=M,S),u=1/Math.ceil(i/n),s=u;s<1;)r.push(o(s)),s+=u}var a,f,l,h,c,y,x,v,p,d,g,m,_,w,M,b,S;r.push(e=t)})),r}))}(t,f=f||10),c=(u||o)&&function(){var n=Rt(h),i=function(t,n){var r=e(Kt(t[0],(function(t){return t[0]})),2),i=r[0],o=r[1],u=e(Kt(t[0],(function(t){return t[1]})),2),s=u[0],a=u[1];if(Math.min(o-i,a-s)<n)return[];var f,l=s+(a-s)%n/2,h=[],c={type:"Polygon",coordinates:t},y=i+(o-i)%n/2;for(;y<o;){for(f=l;f<a;){var x=[y,f];Ct(c,x)&&h.push(x),f+=n}y+=n}return h}(t,f),o=[].concat(r(n),r(i)),u=[];if(i.length)!function(){for(var i=a.from(o),s=1.1*Math.hypot(f,f),l={type:"Polygon",coordinates:t},h=function(t,a){var f,h=[0,1,2].map((function(n){return i.triangles[t+n]})),c=h.map((function(t){return o[t]}));if(Math.max.apply(Math,r([[0,1],[1,2],[2,0]].map((function(t){var n=e(t,2),i=n[0],o=n[1];return Math.hypot.apply(Math,r([0,1].map((function(t){return c[o][t]-c[i][t]}))))}))))>s)return"continue";if(h.some((function(t){return t<n.length}))){var y=[0,1].map((function(t){return function(t,n){let e=0,r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++e,r+=n);else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e}(c,(function(n){return n[t]}))}));if(!Ct(l,y))return"continue"}(f=u).push.apply(f,r(h))},c=0,y=i.triangles.length;c<y;c+=3)h(c)}();else{var s=g.flatten(h),l=s.vertices,c=s.holes;u=g(l,void 0===c?[]:c,2)}return{points:o,indices:u}}(),y=[],x=[],v=0,p=function(t){var n=Math.round(y.length/3),e=x.length;y=y.concat(t.vertices),x=x.concat(n?t.indices.map((function(t){return t+n})):t.indices),l.addGroup(e,x.length-e,v++)};function d(t,n){var r=t.map((function(t){return t.map((function(t){var r=e(t,2),i=r[0];return function(t,n){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-t)*Math.PI/180,i=(90-n)*Math.PI/180;return[e*Math.sin(r)*Math.cos(i),e*Math.cos(r),e*Math.sin(r)*Math.sin(i)]}(r[1],i,n)}))}));return g.flatten(r)}function m(t){return{indices:c.indices,vertices:d([c.points],t).vertices}}s&&p(function(){for(var t=d(h,n),e=t.vertices,r=t.holes,o=d(h,i).vertices,u=Rt([o,e]),s=Math.round(o.length/3),a=new Set(r),f=0,l=[],c=0;c<s;c++){var y=c+1;if(y===s)y=f;else if(a.has(y)){var x=y;y=f,f=x}l.push(c,c+s,y+s),l.push(y+s,y,c)}return{indices:l,vertices:u}}()),o&&p(m(n)),u&&p(m(i)),this.setIndex(x),this[qt]("position",new Nt.Float32BufferAttribute(y,3)),this.computeFaceNormals(),this.computeVertexNormals()}Jt.prototype=Object.create(Nt.Geometry.prototype),Jt.prototype.constructor=Jt,Vt.prototype=Object.create(Nt.BufferGeometry.prototype),Vt.prototype.constructor=Vt,t.ConicPolygonBufferGeometry=Vt,t.ConicPolygonGeometry=Jt,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "three-conic-polygon-geometry", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "ThreeJS geometry for drawing polygons on a sphere", | ||
@@ -5,0 +5,0 @@ "unpkg": "dist/three-conic-polygon-geometry.min.js", |
@@ -11,3 +11,4 @@ import { Geometry, BufferGeometry } from 'three'; | ||
closedTop: boolean, | ||
includeSides: boolean | ||
includeSides: boolean, | ||
curvatureResolution: number | ||
}; | ||
@@ -22,3 +23,4 @@ | ||
closedTop?: boolean, | ||
includeSides?: boolean | ||
includeSides?: boolean, | ||
curvatureResolution?: number | ||
); | ||
@@ -36,3 +38,4 @@ | ||
closedTop?: boolean, | ||
includeSides?: boolean | ||
includeSides?: boolean, | ||
curvatureResolution?: number | ||
); | ||
@@ -39,0 +42,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
865251
2786