globe.gl 2.34.4 → 2.34.6

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/globe.gl.js CHANGED
@@ -1,4 +1,4 @@
1
- // Version 2.34.4 globe.gl - https://github.com/vasturiano/globe.gl
1
+ // Version 2.34.6 globe.gl - https://github.com/vasturiano/globe.gl
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -17445,7 +17445,7 @@
17445
17445
 
17446
17446
  }
17447
17447
 
17448
- queue.sort( compareX$1 );
17448
+ queue.sort( compareX );
17449
17449
 
17450
17450
  // process holes from left to right
17451
17451
  for ( i = 0; i < queue.length; i ++ ) {
@@ -17458,7 +17458,7 @@
17458
17458
 
17459
17459
  }
17460
17460
 
17461
- function compareX$1( a, b ) {
17461
+ function compareX( a, b ) {
17462
17462
 
17463
17463
  return a.x - b.x;
17464
17464
 
@@ -42394,16 +42394,16 @@ void main() {
42394
42394
  // now make sure we don't have other points inside the potential ear
42395
42395
  const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
42396
42396
 
42397
- // triangle bbox; min & max are calculated like this for speed
42398
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
42399
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
42400
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
42401
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
42397
+ // triangle bbox
42398
+ const x0 = Math.min(ax, bx, cx),
42399
+ y0 = Math.min(ay, by, cy),
42400
+ x1 = Math.max(ax, bx, cx),
42401
+ y1 = Math.max(ay, by, cy);
42402
42402
 
42403
42403
  let p = c.next;
42404
42404
  while (p !== a) {
42405
42405
  if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 &&
42406
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) &&
42406
+ pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) &&
42407
42407
  area(p.prev, p, p.next) >= 0) return false;
42408
42408
  p = p.next;
42409
42409
  }
@@ -42420,11 +42420,11 @@ void main() {
42420
42420
 
42421
42421
  const ax = a.x, bx = b.x, cx = c.x, ay = a.y, by = b.y, cy = c.y;
42422
42422
 
42423
- // triangle bbox; min & max are calculated like this for speed
42424
- const x0 = ax < bx ? (ax < cx ? ax : cx) : (bx < cx ? bx : cx),
42425
- y0 = ay < by ? (ay < cy ? ay : cy) : (by < cy ? by : cy),
42426
- x1 = ax > bx ? (ax > cx ? ax : cx) : (bx > cx ? bx : cx),
42427
- y1 = ay > by ? (ay > cy ? ay : cy) : (by > cy ? by : cy);
42423
+ // triangle bbox
42424
+ const x0 = Math.min(ax, bx, cx),
42425
+ y0 = Math.min(ay, by, cy),
42426
+ x1 = Math.max(ax, bx, cx),
42427
+ y1 = Math.max(ay, by, cy);
42428
42428
 
42429
42429
  // z-order range for the current triangle bbox;
42430
42430
  const minZ = zOrder(x0, y0, minX, minY, invSize),
@@ -42436,25 +42436,25 @@ void main() {
42436
42436
  // look for points inside the triangle in both directions
42437
42437
  while (p && p.z >= minZ && n && n.z <= maxZ) {
42438
42438
  if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
42439
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
42439
+ pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
42440
42440
  p = p.prevZ;
42441
42441
 
42442
42442
  if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
42443
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
42443
+ pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
42444
42444
  n = n.nextZ;
42445
42445
  }
42446
42446
 
42447
42447
  // look for remaining points in decreasing z-order
42448
42448
  while (p && p.z >= minZ) {
42449
42449
  if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c &&
42450
- pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
42450
+ pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0) return false;
42451
42451
  p = p.prevZ;
42452
42452
  }
42453
42453
 
42454
42454
  // look for remaining points in increasing z-order
42455
42455
  while (n && n.z <= maxZ) {
42456
42456
  if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c &&
42457
- pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
42457
+ pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0) return false;
42458
42458
  n = n.nextZ;
42459
42459
  }
42460
42460
 
@@ -42522,7 +42522,7 @@ void main() {
42522
42522
  queue.push(getLeftmost(list));
42523
42523
  }
42524
42524
 
42525
- queue.sort(compareX);
42525
+ queue.sort(compareXYSlope);
42526
42526
 
42527
42527
  // process holes from left to right
42528
42528
  for (let i = 0; i < queue.length; i++) {
@@ -42532,8 +42532,19 @@ void main() {
42532
42532
  return outerNode;
42533
42533
  }
42534
42534
 
42535
- function compareX(a, b) {
42536
- return a.x - b.x;
42535
+ function compareXYSlope(a, b) {
42536
+ let result = a.x - b.x;
42537
+ // when the left-most point of 2 holes meet at a vertex, sort the holes counterclockwise so that when we find
42538
+ // the bridge to the outer shell is always the point that they meet at.
42539
+ if (result === 0) {
42540
+ result = a.y - b.y;
42541
+ if (result === 0) {
42542
+ const aSlope = (a.next.y - a.y) / (a.next.x - a.x);
42543
+ const bSlope = (b.next.y - b.y) / (b.next.x - b.x);
42544
+ result = aSlope - bSlope;
42545
+ }
42546
+ }
42547
+ return result;
42537
42548
  }
42538
42549
 
42539
42550
  // find a bridge between vertices that connects hole with an outer ring and and link it
@@ -42560,8 +42571,11 @@ void main() {
42560
42571
 
42561
42572
  // find a segment intersected by a ray from the hole's leftmost point to the left;
42562
42573
  // segment's endpoint with lesser x will be potential connection point
42574
+ // unless they intersect at a vertex, then choose the vertex
42575
+ if (equals$1(hole, p)) return p;
42563
42576
  do {
42564
- if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
42577
+ if (equals$1(hole, p.next)) return p.next;
42578
+ else if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
42565
42579
  const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
42566
42580
  if (x <= hx && x > qx) {
42567
42581
  qx = x;
@@ -42717,6 +42731,11 @@ void main() {
42717
42731
  (bx - px) * (cy - py) >= (cx - px) * (by - py);
42718
42732
  }
42719
42733
 
42734
+ // check if a point lies within a convex triangle but false if its equal to the first point of the triangle
42735
+ function pointInTriangleExceptFirst(ax, ay, bx, by, cx, cy, px, py) {
42736
+ return !(ax === px && ay === py) && pointInTriangle(ax, ay, bx, by, cx, cy, px, py);
42737
+ }
42738
+
42720
42739
  // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
42721
42740
  function isValidDiagonal(a, b) {
42722
42741
  return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
@@ -48655,7 +48674,7 @@ void main() {
48655
48674
  }
48656
48675
  }
48657
48676
  function _createClass$2(e, r, t) {
48658
- return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", {
48677
+ return _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", {
48659
48678
  writable: !1
48660
48679
  }), e;
48661
48680
  }
@@ -48798,10 +48817,7 @@ void main() {
48798
48817
  var dataIdsMap = new Map(data.map(function (d) {
48799
48818
  return [_classPrivateFieldGet2$1(_id$8, _this).call(_this, d), d];
48800
48819
  }));
48801
- _classPrivateFieldGet2$1(_dataMap, this).entries().forEach(function (_ref3) {
48802
- var _ref4 = _slicedToArray$4(_ref3, 2),
48803
- dId = _ref4[0],
48804
- o = _ref4[1];
48820
+ _classPrivateFieldGet2$1(_dataMap, this).forEach(function (o, dId) {
48805
48821
  if (!dataIdsMap.has(dId)) {
48806
48822
  _classPrivateFieldGet2$1(_removeObj, _this).call(_this, o, dId);
48807
48823
  _classPrivateFieldGet2$1(_dataMap, _this)["delete"](dId);
@@ -50437,7 +50453,7 @@ void main() {
50437
50453
 
50438
50454
  if (v1 === 0 && v2 === 0) {
50439
50455
  if ((u2 <= 0 && u1 >= 0) || (u1 <= 0 && u2 >= 0)) { return 0 }
50440
- } else if ((v2 >= 0 && v1 < 0) || (v2 < 0 && v1 >= 0)) {
50456
+ } else if ((v2 >= 0 && v1 <= 0) || (v2 <= 0 && v1 >= 0)) {
50441
50457
  f = orient2d(u1, u2, v1, v2, 0, 0);
50442
50458
  if (f === 0) { return 0 }
50443
50459
  if ((f > 0 && v2 > 0 && v1 <= 0) || (f < 0 && v2 <= 0 && v1 > 0)) { k++; }
@@ -51764,7 +51780,7 @@ void main() {
51764
51780
  };
51765
51781
  };
51766
51782
 
51767
- return data ? v(data) : v;
51783
+ return v(data) ;
51768
51784
  }
51769
51785
 
51770
51786
  function _arrayLikeToArray$3(r, a) {
@@ -69993,7 +70009,6 @@ void main() {
69993
70009
  _this3.scene.remove(obj);
69994
70010
  emptyObject(obj);
69995
70011
  delete d[_classPrivateFieldGet2(_objBindAttr, _this3)];
69996
- delete d.__currentTargetD;
69997
70012
  };
69998
70013
  _classPrivateFieldGet2(_removeDelay, _this3) ? setTimeout(removeFn, _classPrivateFieldGet2(_removeDelay, _this3)) : removeFn();
69999
70014
  }]);
@@ -70440,9 +70455,9 @@ void main() {
70440
70455
  obj.geometry.setAttribute('color', vertexColorArray);
70441
70456
  obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
70442
70457
  var applyUpdate = function applyUpdate(td) {
70443
- var _arc$__currentTargetD = arc.__currentTargetD = td,
70444
- stroke = _arc$__currentTargetD.stroke,
70445
- curveD = _objectWithoutProperties(_arc$__currentTargetD, _excluded$1);
70458
+ var _group$__currentTarge = group.__currentTargetD = td,
70459
+ stroke = _group$__currentTarge.stroke,
70460
+ curveD = _objectWithoutProperties(_group$__currentTarge, _excluded$1);
70446
70461
  var curve = calcCurve(curveD);
70447
70462
  if (useTube) {
70448
70463
  obj.geometry && obj.geometry.dispose();
@@ -70462,7 +70477,7 @@ void main() {
70462
70477
  endLat: +endLatAccessor(arc),
70463
70478
  endLng: +endLngAccessor(arc)
70464
70479
  };
70465
- var currentTargetD = arc.__currentTargetD || Object.assign({}, targetD, {
70480
+ var currentTargetD = group.__currentTargetD || Object.assign({}, targetD, {
70466
70481
  altAutoScale: -1e-3
70467
70482
  });
70468
70483
  if (Object.keys(targetD).some(function (k) {
@@ -71832,12 +71847,12 @@ void main() {
71832
71847
  }
71833
71848
 
71834
71849
  // animate from start to finish by default
71835
- var pointsInterpolator = interpolateVectors(path.__currentTargetD && path.__currentTargetD.points || [points[0]], points);
71850
+ var pointsInterpolator = interpolateVectors(group.__currentTargetD && group.__currentTargetD.points || [points[0]], points);
71836
71851
  var applyUpdate = function applyUpdate(td) {
71837
- var _path$__currentTarget = path.__currentTargetD = td,
71838
- stroke = _path$__currentTarget.stroke,
71839
- interpolK = _path$__currentTarget.interpolK;
71840
- var kPoints = path.__currentTargetD.points = pointsInterpolator(interpolK);
71852
+ var _group$__currentTarge = group.__currentTargetD = td,
71853
+ stroke = _group$__currentTarge.stroke,
71854
+ interpolK = _group$__currentTarge.interpolK;
71855
+ var kPoints = group.__currentTargetD.points = pointsInterpolator(interpolK);
71841
71856
  if (useFatLine) {
71842
71857
  var _ref4;
71843
71858
  obj.geometry.setPositions((_ref4 = []).concat.apply(_ref4, _toConsumableArray$1(kPoints.map(function (_ref5) {
@@ -71859,7 +71874,7 @@ void main() {
71859
71874
  stroke: stroke,
71860
71875
  interpolK: 1
71861
71876
  };
71862
- var currentTargetD = Object.assign({}, path.__currentTargetD || targetD, {
71877
+ var currentTargetD = Object.assign({}, group.__currentTargetD || targetD, {
71863
71878
  interpolK: 0
71864
71879
  });
71865
71880
  if (Object.keys(targetD).some(function (k) {
@@ -72538,7 +72553,8 @@ void main() {
72538
72553
  var latAccessor = index$1(state.ringLat);
72539
72554
  var lngAccessor = index$1(state.ringLng);
72540
72555
  var altitudeAccessor = index$1(state.ringAltitude);
72541
- var globeCenter = new THREE$3.Vector3(0, 0, 0);
72556
+ var globeCenter = state.scene.localToWorld(new THREE$3.Vector3(0, 0, 0)); // translate from local to world coords
72557
+
72542
72558
  state.dataMapper.onUpdateObj(function (obj, d) {
72543
72559
  var lat = latAccessor(d);
72544
72560
  var lng = lngAccessor(d);
@@ -72788,6 +72804,7 @@ void main() {
72788
72804
 
72789
72805
  var THREE$i = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
72790
72806
  : {
72807
+ Camera: Camera,
72791
72808
  Group: Group$1,
72792
72809
  Vector2: Vector2,
72793
72810
  Vector3: Vector3
@@ -72887,10 +72904,13 @@ void main() {
72887
72904
  }
72888
72905
  return cartesian2Polar.apply(void 0, args);
72889
72906
  },
72890
- setPointOfView: function setPointOfView(state, globalPov, globePos) {
72907
+ setPointOfView: function setPointOfView(state, camera) {
72891
72908
  var isBehindGlobe = undefined;
72892
- if (globalPov) {
72909
+ if (state.scene && camera) {
72910
+ var globalPov = camera instanceof THREE$i.Camera ? camera.position : camera; // for backwards compatibility
72893
72911
  var globeRadius = getGlobeRadius();
72912
+ var globePos = new THREE$i.Vector3();
72913
+ state.scene.getWorldPosition(globePos);
72894
72914
  var pov = globePos ? globalPov.clone().sub(globePos) : globalPov; // convert to local vector
72895
72915
 
72896
72916
  var povDist, povEdgeDist, povEdgeAngle;
@@ -73039,29 +73059,29 @@ void main() {
73039
73059
  function fromKapsule (kapsule) {
73040
73060
  var baseClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Object;
73041
73061
  var initKapsuleWithSelf = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
73042
- var FromKapsule = /*#__PURE__*/function (_baseClass) {
73043
- function FromKapsule() {
73062
+ var Globe = /*#__PURE__*/function (_baseClass) {
73063
+ function Globe() {
73044
73064
  var _this;
73045
- _classCallCheck(this, FromKapsule);
73065
+ _classCallCheck(this, Globe);
73046
73066
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
73047
73067
  args[_key] = arguments[_key];
73048
73068
  }
73049
- _this = _callSuper(this, FromKapsule, [].concat(args));
73069
+ _this = _callSuper(this, Globe, [].concat(args));
73050
73070
  _this.__kapsuleInstance = _construct$1(kapsule, [].concat(_toConsumableArray$1(initKapsuleWithSelf ? [_this] : []), args));
73051
73071
  return _this;
73052
73072
  }
73053
- _inherits(FromKapsule, _baseClass);
73054
- return _createClass(FromKapsule);
73073
+ _inherits(Globe, _baseClass);
73074
+ return _createClass(Globe);
73055
73075
  }(baseClass); // attach kapsule props/methods to class prototype
73056
73076
  Object.keys(kapsule()).forEach(function (m) {
73057
- return FromKapsule.prototype[m] = function () {
73077
+ return Globe.prototype[m] = function () {
73058
73078
  var _this$__kapsuleInstan;
73059
73079
  var returnVal = (_this$__kapsuleInstan = this.__kapsuleInstance)[m].apply(_this$__kapsuleInstan, arguments);
73060
73080
  return returnVal === this.__kapsuleInstance ? this // chain based on this class, not the kapsule obj
73061
73081
  : returnVal;
73062
73082
  };
73063
73083
  });
73064
- return FromKapsule;
73084
+ return Globe;
73065
73085
  }
73066
73086
 
73067
73087
  var three$1 = window.THREE ? window.THREE : {
@@ -113828,9 +113848,7 @@ var<${access}> ${name} : ${structName};`;
113828
113848
  * }
113829
113849
  */
113830
113850
  function hsl(value, saturation, lightness) {
113831
- if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number') {
113832
- return hslToHex(value, saturation, lightness);
113833
- } else if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
113851
+ if (typeof value === 'object' && saturation === undefined && lightness === undefined) {
113834
113852
  return hslToHex(value.hue, value.saturation, value.lightness);
113835
113853
  }
113836
113854
  throw new PolishedError(1);
@@ -113863,9 +113881,7 @@ var<${access}> ${name} : ${structName};`;
113863
113881
  * }
113864
113882
  */
113865
113883
  function hsla(value, saturation, lightness, alpha) {
113866
- if (typeof value === 'number' && typeof saturation === 'number' && typeof lightness === 'number' && typeof alpha === 'number') {
113867
- return alpha >= 1 ? hslToHex(value, saturation, lightness) : "rgba(" + hslToRgb(value, saturation, lightness) + "," + alpha + ")";
113868
- } else if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
113884
+ if (typeof value === 'object' && saturation === undefined && lightness === undefined && alpha === undefined) {
113869
113885
  return value.alpha >= 1 ? hslToHex(value.hue, value.saturation, value.lightness) : "rgba(" + hslToRgb(value.hue, value.saturation, value.lightness) + "," + value.alpha + ")";
113870
113886
  }
113871
113887
  throw new PolishedError(2);
@@ -113938,12 +113954,7 @@ var<${access}> ${name} : ${structName};`;
113938
113954
  * }
113939
113955
  */
113940
113956
  function rgba(firstValue, secondValue, thirdValue, fourthValue) {
113941
- if (typeof firstValue === 'string' && typeof secondValue === 'number') {
113942
- var rgbValue = parseToRgb(firstValue);
113943
- return "rgba(" + rgbValue.red + "," + rgbValue.green + "," + rgbValue.blue + "," + secondValue + ")";
113944
- } else if (typeof firstValue === 'number' && typeof secondValue === 'number' && typeof thirdValue === 'number' && typeof fourthValue === 'number') {
113945
- return fourthValue >= 1 ? rgb(firstValue, secondValue, thirdValue) : "rgba(" + firstValue + "," + secondValue + "," + thirdValue + "," + fourthValue + ")";
113946
- } else if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
113957
+ if (typeof firstValue === 'object' && secondValue === undefined && thirdValue === undefined && fourthValue === undefined) {
113947
113958
  return firstValue.alpha >= 1 ? rgb(firstValue.red, firstValue.green, firstValue.blue) : "rgba(" + firstValue.red + "," + firstValue.green + "," + firstValue.blue + "," + firstValue.alpha + ")";
113948
113959
  }
113949
113960
  throw new PolishedError(7);
@@ -115549,7 +115560,7 @@ var<${access}> ${name} : ${structName};`;
115549
115560
  controls.zoomSpeed = (pov.altitude + 1) * 0.1; // Math.sqrt(pov.altitude) * 0.2;
115550
115561
 
115551
115562
  // Update three-globe pov when camera moves, for proper hiding of elements
115552
- state.globe.setPointOfView(state.renderObjs.camera().position);
115563
+ state.globe.setPointOfView(state.renderObjs.camera());
115553
115564
  state.onZoom && state.onZoom(pov);
115554
115565
  });
115555
115566