globe.gl 2.34.4 → 2.34.5

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.5 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
@@ -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);
@@ -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);