three-conic-polygon-geometry
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -11,15 +11,11 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
@@ -32,10 +28,7 @@ | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -66,8 +59,25 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
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 _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -152,4 +162,7 @@ | ||
this.setIndex(indices); | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // auto-calculate normals | ||
this.computeFaceNormals(); | ||
this.computeVertexNormals(); // | ||
function generateVertices(altitude) { | ||
@@ -156,0 +169,0 @@ var coords3d = polygonGeoJson.map(function (coords) { |
@@ -1,2 +0,2 @@ | ||
// Version 1.2.0 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
// Version 1.2.1 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
(function (global, factory) { | ||
@@ -9,15 +9,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('three')) : | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
@@ -30,10 +26,7 @@ | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -64,12 +57,29 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
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 _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
var earcut_1 = earcut; | ||
var default_1 = earcut; | ||
var _default = earcut; | ||
@@ -750,3 +760,3 @@ function earcut(data, holeIndices, dim) { | ||
}; | ||
earcut_1.default = default_1; | ||
earcut_1.default = _default; | ||
@@ -830,4 +840,7 @@ var THREE = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists | ||
this.setIndex(indices); | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // auto-calculate normals | ||
this.computeFaceNormals(); | ||
this.computeVertexNormals(); // | ||
function generateVertices(altitude) { | ||
@@ -834,0 +847,0 @@ var coords3d = polygonGeoJson.map(function (coords) { |
@@ -1,2 +0,2 @@ | ||
// Version 1.2.0 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],t):t((e=e||self).THREE=e.THREE||{},e.THREE)}(this,(function(e,t){"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e))&&"[object Arguments]"!==Object.prototype.toString.call(e))return;var n=[],r=!0,i=!1,o=void 0;try{for(var x,u=e[Symbol.iterator]();!(r=(x=u.next()).done)&&(n.push(x.value),!t||n.length!==t);r=!0);}catch(e){i=!0,o=e}finally{try{r||null==u.return||u.return()}finally{if(i)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function r(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var i=x,o=x;function x(e,t,n){n=n||2;var r,i,o,x,y,v,l,p=t&&t.length,s=p?t[0]*n:e.length,d=u(e,0,s,n,!0),m=[];if(!d||d.next===d.prev)return m;if(p&&(d=function(e,t,n,r){var i,o,x,a,y,v=[];for(i=0,o=t.length;i<o;i++)x=t[i]*r,a=i<o-1?t[i+1]*r:e.length,(y=u(e,x,a,r,!1))===y.next&&(y.steiner=!0),v.push(g(y));for(v.sort(c),i=0;i<v.length;i++)h(v[i],n),n=f(n,n.next);return n}(e,t,d,n)),e.length>80*n){r=o=e[0],i=x=e[1];for(var b=n;b<s;b+=n)(y=e[b])<r&&(r=y),(v=e[b+1])<i&&(i=v),y>o&&(o=y),v>x&&(x=v);l=0!==(l=Math.max(o-r,x-i))?1/l:0}return a(d,m,n,r,i,l),m}function u(e,t,n,r,i){var o,x;if(i===T(e,t,n,r)>0)for(o=t;o<n;o+=r)x=j(o,e[o],e[o+1],x);else for(o=n-r;o>=t;o-=r)x=j(o,e[o],e[o+1],x);return x&&Z(x,x.next)&&(z(x),x=x.next),x}function f(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Z(r,r.next)&&0!==w(r.prev,r,r.next))r=r.next;else{if(z(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function a(e,t,n,r,i,o,x){if(e){!x&&o&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=d(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,x,u,f,a=1;do{for(n=e,e=null,o=null,x=0;n;){for(x++,r=n,u=0,t=0;t<a&&(u++,r=r.nextZ);t++);for(f=a;u>0||f>0&&r;)0!==u&&(0===f||!r||n.z<=r.z)?(i=n,n=n.nextZ,u--):(i=r,r=r.nextZ,f--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,a*=2}while(x>1)}(i)}(e,r,i,o);for(var u,c,h=e;e.prev!==e.next;)if(u=e.prev,c=e.next,o?v(e,r,i,o):y(e))t.push(u.i/n),t.push(e.i/n),t.push(c.i/n),z(e),e=c.next,h=c.next;else if((e=c)===h){x?1===x?a(e=l(f(e),t,n),t,n,r,i,o,2):2===x&&p(e,t,n,r,i,o):a(f(e),t,n,r,i,o,1);break}}}function y(e){var t=e.prev,n=e,r=e.next;if(w(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(m(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&w(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function v(e,t,n,r){var i=e.prev,o=e,x=e.next;if(w(i,o,x)>=0)return!1;for(var u=i.x<o.x?i.x<x.x?i.x:x.x:o.x<x.x?o.x:x.x,f=i.y<o.y?i.y<x.y?i.y:x.y:o.y<x.y?o.y:x.y,a=i.x>o.x?i.x>x.x?i.x:x.x:o.x>x.x?o.x:x.x,y=i.y>o.y?i.y>x.y?i.y:x.y:o.y>x.y?o.y:x.y,v=d(u,f,t,n,r),l=d(a,y,t,n,r),p=e.prevZ,c=e.nextZ;p&&p.z>=v&&c&&c.z<=l;){if(p!==e.prev&&p!==e.next&&m(i.x,i.y,o.x,o.y,x.x,x.y,p.x,p.y)&&w(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,c!==e.prev&&c!==e.next&&m(i.x,i.y,o.x,o.y,x.x,x.y,c.x,c.y)&&w(c.prev,c,c.next)>=0)return!1;c=c.nextZ}for(;p&&p.z>=v;){if(p!==e.prev&&p!==e.next&&m(i.x,i.y,o.x,o.y,x.x,x.y,p.x,p.y)&&w(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;c&&c.z<=l;){if(c!==e.prev&&c!==e.next&&m(i.x,i.y,o.x,o.y,x.x,x.y,c.x,c.y)&&w(c.prev,c,c.next)>=0)return!1;c=c.nextZ}return!0}function l(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Z(i,o)&&G(i,r,r.next,o)&&B(i,o)&&B(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),z(r),z(r.next),r=e=o),r=r.next}while(r!==e);return f(r)}function p(e,t,n,r,i,o){var x=e;do{for(var u=x.next.next;u!==x.prev;){if(x.i!==u.i&&b(x,u)){var y=E(x,u);return x=f(x,x.next),y=f(y,y.next),a(x,t,n,r,i,o),void a(y,t,n,r,i,o)}u=u.next}x=x.next}while(x!==e)}function c(e,t){return e.x-t.x}function h(e,t){if(t=function(e,t){var n,r=t,i=e.x,o=e.y,x=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var u=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=i&&u>x){if(x=u,u===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===x)return n;var f,a=n,y=n.x,v=n.y,l=1/0;r=n;do{i>=r.x&&r.x>=y&&i!==r.x&&m(o<v?i:x,o,y,v,o<v?x:i,o,r.x,r.y)&&(f=Math.abs(o-r.y)/(i-r.x),B(r,e)&&(f<l||f===l&&(r.x>n.x||r.x===n.x&&s(n,r)))&&(n=r,l=f)),r=r.next}while(r!==a);return n}(e,t)){var n=E(t,e);f(t,t.next),f(n,n.next)}}function s(e,t){return w(e.prev,e,t.prev)<0&&w(t.next,e,e.next)<0}function d(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function g(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function m(e,t,n,r,i,o,x,u){return(i-x)*(t-u)-(e-x)*(o-u)>=0&&(e-x)*(r-u)-(n-x)*(t-u)>=0&&(n-x)*(o-u)-(i-x)*(r-u)>=0}function b(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&G(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(B(e,t)&&B(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(w(e.prev,e,t.prev)||w(e,t.prev,t))||Z(e,t)&&w(e.prev,e,e.next)>0&&w(t.prev,t,t.next)>0)}function w(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Z(e,t){return e.x===t.x&&e.y===t.y}function G(e,t,n,r){var i=A(w(e,t,n)),o=A(w(e,t,r)),x=A(w(n,r,e)),u=A(w(n,r,t));return i!==o&&x!==u||(!(0!==i||!M(e,n,t))||(!(0!==o||!M(e,r,t))||(!(0!==x||!M(n,e,r))||!(0!==u||!M(n,t,r)))))}function M(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function A(e){return e>0?1:e<0?-1:0}function B(e,t){return w(e.prev,e,e.next)<0?w(e,t,e.next)>=0&&w(e,e.prev,t)>=0:w(e,t,e.prev)<0||w(e,e.next,t)<0}function E(e,t){var n=new H(e.i,e.x,e.y),r=new H(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function j(e,t,n,r){var i=new H(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function z(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function H(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function T(e,t,n,r){for(var i=0,o=t,x=n-r;o<n;o+=r)i+=(e[x]-e[o])*(e[o+1]+e[x+1]),x=o;return i}x.deviation=function(e,t,n,r){var i=t&&t.length,o=i?t[0]*n:e.length,x=Math.abs(T(e,0,o,n));if(i)for(var u=0,f=t.length;u<f;u++){var a=t[u]*n,y=u<f-1?t[u+1]*n:e.length;x-=Math.abs(T(e,a,y,n))}var v=0;for(u=0;u<r.length;u+=3){var l=r[u]*n,p=r[u+1]*n,c=r[u+2]*n;v+=Math.abs((e[l]-e[c])*(e[p+1]-e[l+1])-(e[l]-e[p])*(e[c+1]-e[l+1]))}return 0===x&&0===v?0:Math.abs((v-x)/x)},x.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var x=0;x<t;x++)n.vertices.push(e[i][o][x]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n},i.default=o;var S=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Float32BufferAttribute:t.Float32BufferAttribute,Geometry:t.Geometry},O=(new S.BufferGeometry).setAttribute?"setAttribute":"addAttribute";function P(e,t,n,r,i,o){S.Geometry.call(this),this.type="ConicPolygonGeometry",this.parameters={polygonGeoJson:e,startHeight:t,endHeight:n,closedBottom:r,closedTop:i,includeSides:o},this.fromBufferGeometry(new I(e,t,n,r,i,o)),this.mergeVertices()}function I(e,t,o,x,u,f){S.BufferGeometry.call(this),this.type="ConicPolygonBufferGeometry",this.parameters={polygonGeoJson:e,startHeight:t,endHeight:o,closedBottom:x,closedTop:u,includeSides:f},o=o||1,x=void 0===x||x,u=void 0===u||u,f=void 0===f||f;var a=b(t=t||0),y=a.vertices,v=a.holes,l=b(o).vertices,p=Math.round(l.length/3),c=[].concat(r(l),r(y)),h=[],s=0;if(f){var d=h.length;h=h.concat(function(){for(var e=new Set(v),t=0,n=[],r=0;r<p;r++){var i=r+1;if(i===p)i=t;else if(e.has(i)){var o=i;i=t,t=o}n.push(r,r+p,i+p),n.push(i+p,i,r)}return n}()),this.addGroup(d,h.length-d,s++)}if(x){var g=h.length;h=h.concat(w(!1)),this.addGroup(g,h.length-g,s++)}if(u){var m=h.length;h=h.concat(w(!0)),this.addGroup(m,h.length-m,s++)}function b(t){var r=e.map((function(e){return e.map((function(e){var r=n(e,2),i=r[0];return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,i=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(i),n*Math.cos(r),n*Math.sin(r)*Math.sin(i)]}(r[1],i,t)}))}));return i.flatten(r)}function w(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=i(i.flatten(e).vertices,v,2);return!t&&(n=n.map((function(e){return e+p}))),n}this.setIndex(h),this[O]("position",new S.Float32BufferAttribute(c,3))}P.prototype=Object.create(S.Geometry.prototype),P.prototype.constructor=P,I.prototype=Object.create(S.BufferGeometry.prototype),I.prototype.constructor=I,e.ConicPolygonBufferGeometry=I,e.ConicPolygonGeometry=P,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
// Version 1.2.1 three-conic-polygon-geometry - https://github.com/vasturiano/three-conic-polygon-geometry | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("three")):"function"==typeof define&&define.amd?define(["exports","three"],t):t((e=e||self).THREE=e.THREE||{},e.THREE)}(this,(function(e,t){"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var n=[],r=!0,o=!1,i=void 0;try{for(var x,u=e[Symbol.iterator]();!(r=(x=u.next()).done)&&(n.push(x.value),!t||n.length!==t);r=!0);}catch(e){o=!0,i=e}finally{try{r||null==u.return||u.return()}finally{if(o)throw i}}return n}(e,t)||o(e,t)||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(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||o(e)||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 o(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var x=f,u=f;function f(e,t,n){n=n||2;var r,o,i,x,u,f,l,c=t&&t.length,p=c?t[0]*n:e.length,h=a(e,0,p,n,!0),m=[];if(!h||h.next===h.prev)return m;if(c&&(h=function(e,t,n,r){var o,i,x,u,f,v=[];for(o=0,i=t.length;o<i;o++)x=t[o]*r,u=o<i-1?t[o+1]*r:e.length,(f=a(e,x,u,r,!1))===f.next&&(f.steiner=!0),v.push(b(f));for(v.sort(s),o=0;o<v.length;o++)d(v[o],n),n=y(n,n.next);return n}(e,t,h,n)),e.length>80*n){r=i=e[0],o=x=e[1];for(var g=n;g<p;g+=n)(u=e[g])<r&&(r=u),(f=e[g+1])<o&&(o=f),u>i&&(i=u),f>x&&(x=f);l=0!==(l=Math.max(i-r,x-o))?1/l:0}return v(h,m,n,r,o,l),m}function a(e,t,n,r,o){var i,x;if(o===I(e,t,n,r)>0)for(i=t;i<n;i+=r)x=z(i,e[i],e[i+1],x);else for(i=n-r;i>=t;i-=r)x=z(i,e[i],e[i+1],x);return x&&G(x,x.next)&&(H(x),x=x.next),x}function y(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!G(r,r.next)&&0!==M(r.prev,r,r.next))r=r.next;else{if(H(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function v(e,t,n,r,o,i,x){if(e){!x&&i&&function(e,t,n,r){var o=e;do{null===o.z&&(o.z=g(o.x,o.y,t,n,r)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==e);o.prevZ.nextZ=null,o.prevZ=null,function(e){var t,n,r,o,i,x,u,f,a=1;do{for(n=e,e=null,i=null,x=0;n;){for(x++,r=n,u=0,t=0;t<a&&(u++,r=r.nextZ);t++);for(f=a;u>0||f>0&&r;)0!==u&&(0===f||!r||n.z<=r.z)?(o=n,n=n.nextZ,u--):(o=r,r=r.nextZ,f--),i?i.nextZ=o:e=o,o.prevZ=i,i=o;n=r}i.nextZ=null,a*=2}while(x>1)}(o)}(e,r,o,i);for(var u,f,a=e;e.prev!==e.next;)if(u=e.prev,f=e.next,i?c(e,r,o,i):l(e))t.push(u.i/n),t.push(e.i/n),t.push(f.i/n),H(e),e=f.next,a=f.next;else if((e=f)===a){x?1===x?v(e=p(y(e),t,n),t,n,r,o,i,2):2===x&&h(e,t,n,r,o,i):v(y(e),t,n,r,o,i,1);break}}}function l(e){var t=e.prev,n=e,r=e.next;if(M(t,n,r)>=0)return!1;for(var o=e.next.next;o!==e.prev;){if(w(t.x,t.y,n.x,n.y,r.x,r.y,o.x,o.y)&&M(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function c(e,t,n,r){var o=e.prev,i=e,x=e.next;if(M(o,i,x)>=0)return!1;for(var u=o.x<i.x?o.x<x.x?o.x:x.x:i.x<x.x?i.x:x.x,f=o.y<i.y?o.y<x.y?o.y:x.y:i.y<x.y?i.y:x.y,a=o.x>i.x?o.x>x.x?o.x:x.x:i.x>x.x?i.x:x.x,y=o.y>i.y?o.y>x.y?o.y:x.y:i.y>x.y?i.y:x.y,v=g(u,f,t,n,r),l=g(a,y,t,n,r),c=e.prevZ,p=e.nextZ;c&&c.z>=v&&p&&p.z<=l;){if(c!==e.prev&&c!==e.next&&w(o.x,o.y,i.x,i.y,x.x,x.y,c.x,c.y)&&M(c.prev,c,c.next)>=0)return!1;if(c=c.prevZ,p!==e.prev&&p!==e.next&&w(o.x,o.y,i.x,i.y,x.x,x.y,p.x,p.y)&&M(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;c&&c.z>=v;){if(c!==e.prev&&c!==e.next&&w(o.x,o.y,i.x,i.y,x.x,x.y,c.x,c.y)&&M(c.prev,c,c.next)>=0)return!1;c=c.prevZ}for(;p&&p.z<=l;){if(p!==e.prev&&p!==e.next&&w(o.x,o.y,i.x,i.y,x.x,x.y,p.x,p.y)&&M(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function p(e,t,n){var r=e;do{var o=r.prev,i=r.next.next;!G(o,i)&&A(o,r,r.next,i)&&S(o,i)&&S(i,o)&&(t.push(o.i/n),t.push(r.i/n),t.push(i.i/n),H(r),H(r.next),r=e=i),r=r.next}while(r!==e);return y(r)}function h(e,t,n,r,o,i){var x=e;do{for(var u=x.next.next;u!==x.prev;){if(x.i!==u.i&&Z(x,u)){var f=j(x,u);return x=y(x,x.next),f=y(f,f.next),v(x,t,n,r,o,i),void v(f,t,n,r,o,i)}u=u.next}x=x.next}while(x!==e)}function s(e,t){return e.x-t.x}function d(e,t){if(t=function(e,t){var n,r=t,o=e.x,i=e.y,x=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var u=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(u<=o&&u>x){if(x=u,u===o){if(i===r.y)return r;if(i===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(o===x)return n;var f,a=n,y=n.x,v=n.y,l=1/0;r=n;do{o>=r.x&&r.x>=y&&o!==r.x&&w(i<v?o:x,i,y,v,i<v?x:o,i,r.x,r.y)&&(f=Math.abs(i-r.y)/(o-r.x),S(r,e)&&(f<l||f===l&&(r.x>n.x||r.x===n.x&&m(n,r)))&&(n=r,l=f)),r=r.next}while(r!==a);return n}(e,t)){var n=j(t,e);y(t,t.next),y(n,n.next)}}function m(e,t){return M(e.prev,e,t.prev)<0&&M(t.next,e,e.next)<0}function g(e,t,n,r,o){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*o)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*o)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function b(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function w(e,t,n,r,o,i,x,u){return(o-x)*(t-u)-(e-x)*(i-u)>=0&&(e-x)*(r-u)-(n-x)*(t-u)>=0&&(n-x)*(i-u)-(o-x)*(r-u)>=0}function Z(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&A(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(S(e,t)&&S(t,e)&&function(e,t){var n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{n.y>i!=n.next.y>i&&n.next.y!==n.y&&o<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(M(e.prev,e,t.prev)||M(e,t.prev,t))||G(e,t)&&M(e.prev,e,e.next)>0&&M(t.prev,t,t.next)>0)}function M(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function G(e,t){return e.x===t.x&&e.y===t.y}function A(e,t,n,r){var o=E(M(e,t,n)),i=E(M(e,t,r)),x=E(M(n,r,e)),u=E(M(n,r,t));return o!==i&&x!==u||(!(0!==o||!B(e,n,t))||(!(0!==i||!B(e,r,t))||(!(0!==x||!B(n,e,r))||!(0!==u||!B(n,t,r)))))}function B(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function E(e){return e>0?1:e<0?-1:0}function S(e,t){return M(e.prev,e,e.next)<0?M(e,t,e.next)>=0&&M(e,e.prev,t)>=0:M(e,t,e.prev)<0||M(e,e.next,t)<0}function j(e,t){var n=new T(e.i,e.x,e.y),r=new T(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function z(e,t,n,r){var o=new T(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function H(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function T(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function I(e,t,n,r){for(var o=0,i=t,x=n-r;i<n;i+=r)o+=(e[x]-e[i])*(e[i+1]+e[x+1]),x=i;return o}f.deviation=function(e,t,n,r){var o=t&&t.length,i=o?t[0]*n:e.length,x=Math.abs(I(e,0,i,n));if(o)for(var u=0,f=t.length;u<f;u++){var a=t[u]*n,y=u<f-1?t[u+1]*n:e.length;x-=Math.abs(I(e,a,y,n))}var v=0;for(u=0;u<r.length;u+=3){var l=r[u]*n,c=r[u+1]*n,p=r[u+2]*n;v+=Math.abs((e[l]-e[p])*(e[c+1]-e[l+1])-(e[l]-e[c])*(e[p+1]-e[l+1]))}return 0===x&&0===v?0:Math.abs((v-x)/x)},f.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,o=0;o<e.length;o++){for(var i=0;i<e[o].length;i++)for(var x=0;x<t;x++)n.vertices.push(e[o][i][x]);o>0&&(r+=e[o-1].length,n.holes.push(r))}return n},x.default=u;var O=window.THREE?window.THREE:{BufferGeometry:t.BufferGeometry,Float32BufferAttribute:t.Float32BufferAttribute,Geometry:t.Geometry},P=(new O.BufferGeometry).setAttribute?"setAttribute":"addAttribute";function C(e,t,n,r,o,i){O.Geometry.call(this),this.type="ConicPolygonGeometry",this.parameters={polygonGeoJson:e,startHeight:t,endHeight:n,closedBottom:r,closedTop:o,includeSides:i},this.fromBufferGeometry(new R(e,t,n,r,o,i)),this.mergeVertices()}function R(e,t,o,i,u,f){O.BufferGeometry.call(this),this.type="ConicPolygonBufferGeometry",this.parameters={polygonGeoJson:e,startHeight:t,endHeight:o,closedBottom:i,closedTop:u,includeSides:f},o=o||1,i=void 0===i||i,u=void 0===u||u,f=void 0===f||f;var a=b(t=t||0),y=a.vertices,v=a.holes,l=b(o).vertices,c=Math.round(l.length/3),p=[].concat(r(l),r(y)),h=[],s=0;if(f){var d=h.length;h=h.concat(function(){for(var e=new Set(v),t=0,n=[],r=0;r<c;r++){var o=r+1;if(o===c)o=t;else if(e.has(o)){var i=o;o=t,t=i}n.push(r,r+c,o+c),n.push(o+c,o,r)}return n}()),this.addGroup(d,h.length-d,s++)}if(i){var m=h.length;h=h.concat(w(!1)),this.addGroup(m,h.length-m,s++)}if(u){var g=h.length;h=h.concat(w(!0)),this.addGroup(g,h.length-g,s++)}function b(t){var r=e.map((function(e){return e.map((function(e){var r=n(e,2),o=r[0];return function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,r=(90-e)*Math.PI/180,o=(90-t)*Math.PI/180;return[n*Math.sin(r)*Math.cos(o),n*Math.cos(r),n*Math.sin(r)*Math.sin(o)]}(r[1],o,t)}))}));return x.flatten(r)}function w(){var t=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],n=x(x.flatten(e).vertices,v,2);return!t&&(n=n.map((function(e){return e+c}))),n}this.setIndex(h),this[P]("position",new O.Float32BufferAttribute(p,3)),this.computeFaceNormals(),this.computeVertexNormals()}C.prototype=Object.create(O.Geometry.prototype),C.prototype.constructor=C,R.prototype=Object.create(O.BufferGeometry.prototype),R.prototype.constructor=R,e.ConicPolygonBufferGeometry=R,e.ConicPolygonGeometry=C,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -5,15 +5,11 @@ import { BufferGeometry, Float32BufferAttribute, Geometry } from 'three'; | ||
function _slicedToArray(arr, i) { | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); | ||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); | ||
} | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) { | ||
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
@@ -26,10 +22,7 @@ | ||
function _iterableToArray(iter) { | ||
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
function _iterableToArrayLimit(arr, i) { | ||
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { | ||
return; | ||
} | ||
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; | ||
var _arr = []; | ||
@@ -60,8 +53,25 @@ var _n = true; | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
return arr2; | ||
} | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance"); | ||
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 _nonIterableRest() { | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance"); | ||
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
@@ -146,4 +156,7 @@ | ||
this.setIndex(indices); | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // | ||
this[setAttributeFn]('position', new THREE.Float32BufferAttribute(vertices, 3)); // auto-calculate normals | ||
this.computeFaceNormals(); | ||
this.computeVertexNormals(); // | ||
function generateVertices(altitude) { | ||
@@ -150,0 +163,0 @@ var coords3d = polygonGeoJson.map(function (coords) { |
{ | ||
"name": "three-conic-polygon-geometry", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "ThreeJS geometry for drawing polygons on a sphere", | ||
@@ -48,13 +48,13 @@ "unpkg": "dist/three-conic-polygon-geometry.min.js", | ||
"devDependencies": { | ||
"@babel/core": "^7.8.7", | ||
"@babel/core": "^7.9.6", | ||
"@babel/plugin-proposal-class-properties": "^7.8.3", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.8.3", | ||
"@babel/preset-env": "^7.8.7", | ||
"@rollup/plugin-commonjs": "^11.0.2", | ||
"@rollup/plugin-node-resolve": "^7.1.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.9.6", | ||
"@babel/preset-env": "^7.9.6", | ||
"@rollup/plugin-commonjs": "^11.1.0", | ||
"@rollup/plugin-node-resolve": "^7.1.3", | ||
"@types/three": ">=0.72.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.0.6", | ||
"rollup": "^2.7.6", | ||
"rollup-plugin-babel": "^4.4.0", | ||
"rollup-plugin-dts": "^1.3.0", | ||
"rollup-plugin-dts": "^1.4.0", | ||
"rollup-plugin-terser": "^5.3.0", | ||
@@ -61,0 +61,0 @@ "typescript": "^3.8.3" |
@@ -94,2 +94,6 @@ import { | ||
// auto-calculate normals | ||
this.computeFaceNormals(); | ||
this.computeVertexNormals(); | ||
// | ||
@@ -96,0 +100,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
718066
1318