globe.gl 2.34.3 → 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.3 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) :
@@ -43,7 +43,7 @@
43
43
  function _arrayWithoutHoles$5(r) {
44
44
  if (Array.isArray(r)) return _arrayLikeToArray$7(r);
45
45
  }
46
- function _defineProperty$3(e, r, t) {
46
+ function _defineProperty$2(e, r, t) {
47
47
  return (r = _toPropertyKey$4(r)) in e ? Object.defineProperty(e, r, {
48
48
  value: t,
49
49
  enumerable: !0,
@@ -57,7 +57,7 @@
57
57
  function _nonIterableSpread$5() {
58
58
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
59
59
  }
60
- function ownKeys$2(e, r) {
60
+ function ownKeys$1(e, r) {
61
61
  var t = Object.keys(e);
62
62
  if (Object.getOwnPropertySymbols) {
63
63
  var o = Object.getOwnPropertySymbols(e);
@@ -67,29 +67,29 @@
67
67
  }
68
68
  return t;
69
69
  }
70
- function _objectSpread2$2(e) {
70
+ function _objectSpread2$1(e) {
71
71
  for (var r = 1; r < arguments.length; r++) {
72
72
  var t = null != arguments[r] ? arguments[r] : {};
73
- r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) {
74
- _defineProperty$3(e, r, t[r]);
75
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) {
73
+ r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) {
74
+ _defineProperty$2(e, r, t[r]);
75
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) {
76
76
  Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
77
77
  });
78
78
  }
79
79
  return e;
80
80
  }
81
- function _objectWithoutProperties$3(e, t) {
81
+ function _objectWithoutProperties$2(e, t) {
82
82
  if (null == e) return {};
83
83
  var o,
84
84
  r,
85
- i = _objectWithoutPropertiesLoose$3(e, t);
85
+ i = _objectWithoutPropertiesLoose$2(e, t);
86
86
  if (Object.getOwnPropertySymbols) {
87
87
  var s = Object.getOwnPropertySymbols(e);
88
88
  for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
89
89
  }
90
90
  return i;
91
91
  }
92
- function _objectWithoutPropertiesLoose$3(r, e) {
92
+ function _objectWithoutPropertiesLoose$2(r, e) {
93
93
  if (null == r) return {};
94
94
  var t = {};
95
95
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
@@ -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
 
@@ -29250,7 +29250,7 @@
29250
29250
 
29251
29251
  }
29252
29252
 
29253
- let _id$8 = 0;
29253
+ let _id$9 = 0;
29254
29254
 
29255
29255
  class WebGLShaderCache {
29256
29256
 
@@ -29364,7 +29364,7 @@
29364
29364
 
29365
29365
  constructor( code ) {
29366
29366
 
29367
- this.id = _id$8 ++;
29367
+ this.id = _id$9 ++;
29368
29368
 
29369
29369
  this.code = code;
29370
29370
  this.usedTimes = 0;
@@ -40947,10 +40947,10 @@ void main() {
40947
40947
  function _arrayWithHoles$6(r) {
40948
40948
  if (Array.isArray(r)) return r;
40949
40949
  }
40950
- function _classCallCheck$3(a, n) {
40950
+ function _classCallCheck$4(a, n) {
40951
40951
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
40952
40952
  }
40953
- function _createClass$3(e, r, t) {
40953
+ function _createClass$4(e, r, t) {
40954
40954
  return Object.defineProperty(e, "prototype", {
40955
40955
  writable: !1
40956
40956
  }), e;
@@ -40993,14 +40993,14 @@ void main() {
40993
40993
  }
40994
40994
  }
40995
40995
 
40996
- var Prop = /*#__PURE__*/_createClass$3(function Prop(name, _ref) {
40996
+ var Prop = /*#__PURE__*/_createClass$4(function Prop(name, _ref) {
40997
40997
  var _ref$default = _ref["default"],
40998
40998
  defaultVal = _ref$default === void 0 ? null : _ref$default,
40999
40999
  _ref$triggerUpdate = _ref.triggerUpdate,
41000
41000
  triggerUpdate = _ref$triggerUpdate === void 0 ? true : _ref$triggerUpdate,
41001
41001
  _ref$onChange = _ref.onChange,
41002
41002
  onChange = _ref$onChange === void 0 ? function (newVal, state) {} : _ref$onChange;
41003
- _classCallCheck$3(this, Prop);
41003
+ _classCallCheck$4(this, Prop);
41004
41004
  this.name = name;
41005
41005
  this.defaultVal = defaultVal;
41006
41006
  this.triggerUpdate = triggerUpdate;
@@ -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
@@ -45293,10 +45312,10 @@ void main() {
45293
45312
  function _callSuper$2(t, o, e) {
45294
45313
  return o = _getPrototypeOf$3(o), _possibleConstructorReturn$2(t, _isNativeReflectConstruct$3() ? Reflect.construct(o, [], _getPrototypeOf$3(t).constructor) : o.apply(t, e));
45295
45314
  }
45296
- function _classCallCheck$2(a, n) {
45315
+ function _classCallCheck$3(a, n) {
45297
45316
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
45298
45317
  }
45299
- function _createClass$2(e, r, t) {
45318
+ function _createClass$3(e, r, t) {
45300
45319
  return Object.defineProperty(e, "prototype", {
45301
45320
  writable: !1
45302
45321
  }), e;
@@ -45461,7 +45480,7 @@ void main() {
45461
45480
  var _this;
45462
45481
  var radius = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
45463
45482
  var resolution = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5;
45464
- _classCallCheck$2(this, GeoJsonGeometry);
45483
+ _classCallCheck$3(this, GeoJsonGeometry);
45465
45484
  _this = _callSuper$2(this, GeoJsonGeometry);
45466
45485
  _this.type = 'GeoJsonGeometry';
45467
45486
  _this.parameters = {
@@ -45623,7 +45642,7 @@ void main() {
45623
45642
  return _this;
45624
45643
  }
45625
45644
  _inherits$2(GeoJsonGeometry, _THREE$BufferGeometry);
45626
- return _createClass$2(GeoJsonGeometry);
45645
+ return _createClass$3(GeoJsonGeometry);
45627
45646
  }(THREE$k.BufferGeometry); //
45628
45647
  function concatGroup(main, extra) {
45629
45648
  var prevVertCnt = Math.round(main.vertices.length / 3);
@@ -48629,6 +48648,36 @@ void main() {
48629
48648
  function _arrayWithoutHoles$4(r) {
48630
48649
  if (Array.isArray(r)) return _arrayLikeToArray$4(r);
48631
48650
  }
48651
+ function _assertClassBrand$1(e, t, n) {
48652
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
48653
+ throw new TypeError("Private element is not present on this object");
48654
+ }
48655
+ function _checkPrivateRedeclaration$1(e, t) {
48656
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
48657
+ }
48658
+ function _classCallCheck$2(a, n) {
48659
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
48660
+ }
48661
+ function _classPrivateFieldGet2$1(s, a) {
48662
+ return s.get(_assertClassBrand$1(s, a));
48663
+ }
48664
+ function _classPrivateFieldInitSpec$1(e, t, a) {
48665
+ _checkPrivateRedeclaration$1(e, t), t.set(e, a);
48666
+ }
48667
+ function _classPrivateFieldSet2$1(s, a, r) {
48668
+ return s.set(_assertClassBrand$1(s, a), r), r;
48669
+ }
48670
+ function _defineProperties$1(e, r) {
48671
+ for (var t = 0; t < r.length; t++) {
48672
+ var o = r[t];
48673
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey$3(o.key), o);
48674
+ }
48675
+ }
48676
+ function _createClass$2(e, r, t) {
48677
+ return r && _defineProperties$1(e.prototype, r), Object.defineProperty(e, "prototype", {
48678
+ writable: !1
48679
+ }), e;
48680
+ }
48632
48681
  function _iterableToArray$4(r) {
48633
48682
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
48634
48683
  }
@@ -48662,26 +48711,6 @@ void main() {
48662
48711
  function _nonIterableSpread$4() {
48663
48712
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48664
48713
  }
48665
- function _objectWithoutProperties$2(e, t) {
48666
- if (null == e) return {};
48667
- var o,
48668
- r,
48669
- i = _objectWithoutPropertiesLoose$2(e, t);
48670
- if (Object.getOwnPropertySymbols) {
48671
- var s = Object.getOwnPropertySymbols(e);
48672
- for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
48673
- }
48674
- return i;
48675
- }
48676
- function _objectWithoutPropertiesLoose$2(r, e) {
48677
- if (null == r) return {};
48678
- var t = {};
48679
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
48680
- if (e.includes(n)) continue;
48681
- t[n] = r[n];
48682
- }
48683
- return t;
48684
- }
48685
48714
  function _slicedToArray$4(r, e) {
48686
48715
  return _arrayWithHoles$4(r) || _iterableToArrayLimit$4(r, e) || _unsupportedIterableToArray$4(r, e) || _nonIterableRest$4();
48687
48716
  }
@@ -48692,7 +48721,7 @@ void main() {
48692
48721
  if ("object" != typeof t || !t) return t;
48693
48722
  var e = t[Symbol.toPrimitive];
48694
48723
  if (void 0 !== e) {
48695
- var i = e.call(t, r );
48724
+ var i = e.call(t, r);
48696
48725
  if ("object" != typeof i) return i;
48697
48726
  throw new TypeError("@@toPrimitive must return a primitive value.");
48698
48727
  }
@@ -48710,367 +48739,103 @@ void main() {
48710
48739
  }
48711
48740
  }
48712
48741
 
48713
- var index = (function () {
48714
- var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
48715
- var keyAccessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
48716
- var multiItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
48717
- var flattenKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
48718
- var keys = (keyAccessors instanceof Array ? keyAccessors.length ? keyAccessors : [undefined] : [keyAccessors]).map(function (key) {
48719
- return {
48720
- keyAccessor: key,
48721
- isProp: !(key instanceof Function)
48722
- };
48723
- });
48724
- var indexedResult = list.reduce(function (res, item) {
48725
- var iterObj = res;
48726
- var itemVal = item;
48727
- keys.forEach(function (_ref, idx) {
48728
- var keyAccessor = _ref.keyAccessor,
48729
- isProp = _ref.isProp;
48730
- var key;
48731
- if (isProp) {
48732
- var _itemVal = itemVal,
48733
- propVal = _itemVal[keyAccessor],
48734
- rest = _objectWithoutProperties$2(_itemVal, [keyAccessor].map(_toPropertyKey$3));
48735
- key = propVal;
48736
- itemVal = rest;
48737
- } else {
48738
- key = keyAccessor(itemVal, idx);
48739
- }
48740
- if (idx + 1 < keys.length) {
48741
- if (!iterObj.hasOwnProperty(key)) {
48742
- iterObj[key] = {};
48743
- }
48744
- iterObj = iterObj[key];
48745
- } else {
48746
- // Leaf key
48747
- if (multiItem) {
48748
- if (!iterObj.hasOwnProperty(key)) {
48749
- iterObj[key] = [];
48750
- }
48751
- iterObj[key].push(itemVal);
48752
- } else {
48753
- iterObj[key] = itemVal;
48754
- }
48755
- }
48742
+ var _dataMap = /*#__PURE__*/new WeakMap();
48743
+ var _objMap = /*#__PURE__*/new WeakMap();
48744
+ var _id$8 = /*#__PURE__*/new WeakMap();
48745
+ var _createObj = /*#__PURE__*/new WeakMap();
48746
+ var _updateObj = /*#__PURE__*/new WeakMap();
48747
+ var _removeObj = /*#__PURE__*/new WeakMap();
48748
+ var DataBindMapper = /*#__PURE__*/function () {
48749
+ function DataBindMapper() {
48750
+ _classCallCheck$2(this, DataBindMapper);
48751
+ _classPrivateFieldInitSpec$1(this, _dataMap, new Map());
48752
+ _classPrivateFieldInitSpec$1(this, _objMap, new Map());
48753
+ _classPrivateFieldInitSpec$1(this, _id$8, function (d) {
48754
+ return d;
48756
48755
  });
48757
- return res;
48758
- }, {});
48759
- if (multiItem instanceof Function) {
48760
- // Reduce leaf multiple values
48761
- (function reduce(node) {
48762
- var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
48763
- if (level === keys.length) {
48764
- Object.keys(node).forEach(function (k) {
48765
- return node[k] = multiItem(node[k]);
48766
- });
48767
- } else {
48768
- Object.values(node).forEach(function (child) {
48769
- return reduce(child, level + 1);
48770
- });
48771
- }
48772
- })(indexedResult); // IIFE
48756
+ _classPrivateFieldInitSpec$1(this, _createObj, function () {
48757
+ return {};
48758
+ });
48759
+ _classPrivateFieldInitSpec$1(this, _updateObj, function () {});
48760
+ _classPrivateFieldInitSpec$1(this, _removeObj, function () {});
48773
48761
  }
48774
- var result = indexedResult;
48775
- if (flattenKeys) {
48776
- // flatten into array
48777
- result = [];
48778
- (function flatten(node) {
48779
- var accKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
48780
- if (accKeys.length === keys.length) {
48781
- result.push({
48782
- keys: accKeys,
48783
- vals: node
48784
- });
48785
- } else {
48786
- Object.entries(node).forEach(function (_ref2) {
48787
- var _ref3 = _slicedToArray$4(_ref2, 2),
48788
- key = _ref3[0],
48789
- val = _ref3[1];
48790
- return flatten(val, [].concat(_toConsumableArray$4(accKeys), [key]));
48791
- });
48792
- }
48793
- })(indexedResult); //IIFE
48794
-
48795
- if (keyAccessors instanceof Array && keyAccessors.length === 0 && result.length === 1) {
48796
- // clear keys if there's no key accessors (single result)
48797
- result[0].keys = [];
48762
+ return _createClass$2(DataBindMapper, [{
48763
+ key: "getObj",
48764
+ value: function getObj(d) {
48765
+ return _classPrivateFieldGet2$1(_dataMap, this).get(_classPrivateFieldGet2$1(_id$8, this).call(this, d));
48798
48766
  }
48799
- }
48800
- return result;
48801
- });
48802
-
48803
- function _iterableToArrayLimit$3(arr, i) {
48804
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
48805
- if (null != _i) {
48806
- var _s,
48807
- _e,
48808
- _x,
48809
- _r,
48810
- _arr = [],
48811
- _n = !0,
48812
- _d = !1;
48813
- try {
48814
- if (_x = (_i = _i.call(arr)).next, 0 === i) ; else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
48815
- } catch (err) {
48816
- _d = !0, _e = err;
48817
- } finally {
48818
- try {
48819
- if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return;
48820
- } finally {
48821
- if (_d) throw _e;
48822
- }
48767
+ }, {
48768
+ key: "getData",
48769
+ value: function getData(o) {
48770
+ return _classPrivateFieldGet2$1(_objMap, this).get(o);
48823
48771
  }
48824
- return _arr;
48825
- }
48826
- }
48827
- function ownKeys$1(object, enumerableOnly) {
48828
- var keys = Object.keys(object);
48829
- if (Object.getOwnPropertySymbols) {
48830
- var symbols = Object.getOwnPropertySymbols(object);
48831
- enumerableOnly && (symbols = symbols.filter(function (sym) {
48832
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
48833
- })), keys.push.apply(keys, symbols);
48834
- }
48835
- return keys;
48836
- }
48837
- function _objectSpread2$1(target) {
48838
- for (var i = 1; i < arguments.length; i++) {
48839
- var source = null != arguments[i] ? arguments[i] : {};
48840
- i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
48841
- _defineProperty$2(target, key, source[key]);
48842
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
48843
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
48844
- });
48845
- }
48846
- return target;
48847
- }
48848
- function _defineProperty$2(obj, key, value) {
48849
- key = _toPropertyKey$2(key);
48850
- if (key in obj) {
48851
- Object.defineProperty(obj, key, {
48852
- value: value,
48853
- enumerable: true,
48854
- configurable: true,
48855
- writable: true
48856
- });
48857
- } else {
48858
- obj[key] = value;
48859
- }
48860
- return obj;
48861
- }
48862
- function _objectWithoutPropertiesLoose$1(source, excluded) {
48863
- if (source == null) return {};
48864
- var target = {};
48865
- var sourceKeys = Object.keys(source);
48866
- var key, i;
48867
- for (i = 0; i < sourceKeys.length; i++) {
48868
- key = sourceKeys[i];
48869
- if (excluded.indexOf(key) >= 0) continue;
48870
- target[key] = source[key];
48871
- }
48872
- return target;
48873
- }
48874
- function _objectWithoutProperties$1(source, excluded) {
48875
- if (source == null) return {};
48876
- var target = _objectWithoutPropertiesLoose$1(source, excluded);
48877
- var key, i;
48878
- if (Object.getOwnPropertySymbols) {
48879
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
48880
- for (i = 0; i < sourceSymbolKeys.length; i++) {
48881
- key = sourceSymbolKeys[i];
48882
- if (excluded.indexOf(key) >= 0) continue;
48883
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
48884
- target[key] = source[key];
48772
+ }, {
48773
+ key: "entries",
48774
+ value: function entries() {
48775
+ return _toConsumableArray$4(_classPrivateFieldGet2$1(_objMap, this).entries()).map(function (_ref) {
48776
+ var _ref2 = _slicedToArray$4(_ref, 2),
48777
+ o = _ref2[0],
48778
+ d = _ref2[1];
48779
+ return [d, o];
48780
+ });
48885
48781
  }
48886
- }
48887
- return target;
48888
- }
48889
- function _slicedToArray$3(arr, i) {
48890
- return _arrayWithHoles$3(arr) || _iterableToArrayLimit$3(arr, i) || _unsupportedIterableToArray$3(arr, i) || _nonIterableRest$3();
48891
- }
48892
- function _toConsumableArray$3(arr) {
48893
- return _arrayWithoutHoles$3(arr) || _iterableToArray$3(arr) || _unsupportedIterableToArray$3(arr) || _nonIterableSpread$3();
48894
- }
48895
- function _arrayWithoutHoles$3(arr) {
48896
- if (Array.isArray(arr)) return _arrayLikeToArray$3(arr);
48897
- }
48898
- function _arrayWithHoles$3(arr) {
48899
- if (Array.isArray(arr)) return arr;
48900
- }
48901
- function _iterableToArray$3(iter) {
48902
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
48903
- }
48904
- function _unsupportedIterableToArray$3(o, minLen) {
48905
- if (!o) return;
48906
- if (typeof o === "string") return _arrayLikeToArray$3(o, minLen);
48907
- var n = Object.prototype.toString.call(o).slice(8, -1);
48908
- if (n === "Object" && o.constructor) n = o.constructor.name;
48909
- if (n === "Map" || n === "Set") return Array.from(o);
48910
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$3(o, minLen);
48911
- }
48912
- function _arrayLikeToArray$3(arr, len) {
48913
- if (len == null || len > arr.length) len = arr.length;
48914
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
48915
- return arr2;
48916
- }
48917
- function _nonIterableSpread$3() {
48918
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48919
- }
48920
- function _nonIterableRest$3() {
48921
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
48922
- }
48923
- function _toPrimitive$2(input, hint) {
48924
- if (typeof input !== "object" || input === null) return input;
48925
- var prim = input[Symbol.toPrimitive];
48926
- if (prim !== undefined) {
48927
- var res = prim.call(input, hint || "default");
48928
- if (typeof res !== "object") return res;
48929
- throw new TypeError("@@toPrimitive must return a primitive value.");
48930
- }
48931
- return (hint === "string" ? String : Number)(input);
48932
- }
48933
- function _toPropertyKey$2(arg) {
48934
- var key = _toPrimitive$2(arg, "string");
48935
- return typeof key === "symbol" ? key : String(key);
48936
- }
48937
-
48938
- var _excluded$2 = ["createObj", "updateObj", "exitObj", "objBindAttr", "dataBindAttr"];
48939
- function diffArrays(prev, next, idAccessor) {
48940
- var result = {
48941
- enter: [],
48942
- update: [],
48943
- exit: []
48944
- };
48945
- if (!idAccessor) {
48946
- // use object references for comparison
48947
- var prevSet = new Set(prev);
48948
- var nextSet = new Set(next);
48949
- new Set([].concat(_toConsumableArray$3(prevSet), _toConsumableArray$3(nextSet))).forEach(function (item) {
48950
- var type = !prevSet.has(item) ? 'enter' : !nextSet.has(item) ? 'exit' : 'update';
48951
- result[type].push(type === 'update' ? [item, item] : item);
48952
- });
48953
- } else {
48954
- // compare by id (duplicate keys are ignored)
48955
- var prevById = index(prev, idAccessor, false);
48956
- var nextById = index(next, idAccessor, false);
48957
- var byId = Object.assign({}, prevById, nextById);
48958
- Object.entries(byId).forEach(function (_ref) {
48959
- var _ref2 = _slicedToArray$3(_ref, 2),
48960
- id = _ref2[0],
48961
- item = _ref2[1];
48962
- var type = !prevById.hasOwnProperty(id) ? 'enter' : !nextById.hasOwnProperty(id) ? 'exit' : 'update';
48963
- result[type].push(type === 'update' ? [prevById[id], nextById[id]] : item);
48964
- });
48965
- }
48966
- return result;
48967
- }
48968
- function dataBindDiff(data, existingObjs, _ref3) {
48969
- var _ref3$objBindAttr = _ref3.objBindAttr,
48970
- objBindAttr = _ref3$objBindAttr === void 0 ? '__obj' : _ref3$objBindAttr,
48971
- _ref3$dataBindAttr = _ref3.dataBindAttr,
48972
- dataBindAttr = _ref3$dataBindAttr === void 0 ? '__data' : _ref3$dataBindAttr,
48973
- idAccessor = _ref3.idAccessor,
48974
- _ref3$purge = _ref3.purge,
48975
- purge = _ref3$purge === void 0 ? false : _ref3$purge;
48976
- var isObjValid = function isObjValid(obj) {
48977
- return obj.hasOwnProperty(dataBindAttr);
48978
- };
48979
- var removeObjs = existingObjs.filter(function (obj) {
48980
- return !isObjValid(obj);
48981
- });
48982
- var prevD = existingObjs.filter(isObjValid).map(function (obj) {
48983
- return obj[dataBindAttr];
48984
- });
48985
- var nextD = data;
48986
- var diff = purge ? {
48987
- enter: nextD,
48988
- exit: prevD,
48989
- update: []
48990
- } // don't diff data in purge mode
48991
- : diffArrays(prevD, nextD, idAccessor);
48992
- diff.update = diff.update.map(function (_ref4) {
48993
- var _ref5 = _slicedToArray$3(_ref4, 2),
48994
- prevD = _ref5[0],
48995
- nextD = _ref5[1];
48996
- if (prevD !== nextD) {
48997
- // transfer obj to new data point (if different)
48998
- nextD[objBindAttr] = prevD[objBindAttr];
48999
- nextD[objBindAttr][dataBindAttr] = nextD;
48782
+ }, {
48783
+ key: "id",
48784
+ value: function id(p) {
48785
+ _classPrivateFieldSet2$1(_id$8, this, index$1(p));
48786
+ return this;
49000
48787
  }
49001
- return nextD;
49002
- });
49003
- diff.exit = diff.exit.concat(removeObjs.map(function (obj) {
49004
- return _defineProperty$2({}, objBindAttr, obj);
49005
- }));
49006
- return diff;
49007
- }
49008
- function viewDigest(data, existingObjs,
49009
- // list
49010
- appendObj,
49011
- // item => {...} function
49012
- removeObj, // item => {...} function
49013
- _ref7) {
49014
- var _ref7$createObj = _ref7.createObj,
49015
- createObj = _ref7$createObj === void 0 ? function (d) {
49016
- return {};
49017
- } : _ref7$createObj,
49018
- _ref7$updateObj = _ref7.updateObj,
49019
- updateObj = _ref7$updateObj === void 0 ? function (obj, d) {} : _ref7$updateObj,
49020
- _ref7$exitObj = _ref7.exitObj,
49021
- exitObj = _ref7$exitObj === void 0 ? function (obj) {} : _ref7$exitObj,
49022
- _ref7$objBindAttr = _ref7.objBindAttr,
49023
- objBindAttr = _ref7$objBindAttr === void 0 ? '__obj' : _ref7$objBindAttr,
49024
- _ref7$dataBindAttr = _ref7.dataBindAttr,
49025
- dataBindAttr = _ref7$dataBindAttr === void 0 ? '__data' : _ref7$dataBindAttr,
49026
- dataDiffOptions = _objectWithoutProperties$1(_ref7, _excluded$2);
49027
- var _dataBindDiff = dataBindDiff(data, existingObjs, _objectSpread2$1({
49028
- objBindAttr: objBindAttr,
49029
- dataBindAttr: dataBindAttr
49030
- }, dataDiffOptions)),
49031
- enter = _dataBindDiff.enter,
49032
- update = _dataBindDiff.update,
49033
- exit = _dataBindDiff.exit;
49034
-
49035
- // Remove exiting points
49036
- exit.forEach(function (d) {
49037
- var obj = d[objBindAttr];
49038
- delete d[objBindAttr]; // unbind obj
49039
-
49040
- exitObj(obj);
49041
- removeObj(obj);
49042
- });
49043
- var newObjs = createObjs(enter);
49044
- var pointsData = [].concat(_toConsumableArray$3(enter), _toConsumableArray$3(update));
49045
- updateObjs(pointsData);
49046
-
49047
- // Add new points
49048
- newObjs.forEach(appendObj);
49049
-
49050
- //
49051
-
49052
- function createObjs(data) {
49053
- var newObjs = [];
49054
- data.forEach(function (d) {
49055
- var obj = createObj(d);
49056
- if (obj) {
49057
- obj[dataBindAttr] = d;
49058
- d[objBindAttr] = obj;
49059
- newObjs.push(obj);
49060
- }
49061
- });
49062
- return newObjs;
49063
- }
49064
- function updateObjs(data) {
49065
- data.forEach(function (d) {
49066
- var obj = d[objBindAttr];
49067
- if (obj) {
49068
- obj[dataBindAttr] = d;
49069
- updateObj(obj, d);
49070
- }
49071
- });
49072
- }
49073
- }
48788
+ }, {
48789
+ key: "onCreateObj",
48790
+ value: function onCreateObj(fn) {
48791
+ _classPrivateFieldSet2$1(_createObj, this, fn);
48792
+ return this;
48793
+ }
48794
+ }, {
48795
+ key: "onUpdateObj",
48796
+ value: function onUpdateObj(fn) {
48797
+ _classPrivateFieldSet2$1(_updateObj, this, fn);
48798
+ return this;
48799
+ }
48800
+ }, {
48801
+ key: "onRemoveObj",
48802
+ value: function onRemoveObj(fn) {
48803
+ _classPrivateFieldSet2$1(_removeObj, this, fn);
48804
+ return this;
48805
+ }
48806
+ }, {
48807
+ key: "digest",
48808
+ value: function digest(data) {
48809
+ var _this = this;
48810
+ data.filter(function (d) {
48811
+ return !_classPrivateFieldGet2$1(_dataMap, _this).has(_classPrivateFieldGet2$1(_id$8, _this).call(_this, d));
48812
+ }).forEach(function (d) {
48813
+ var obj = _classPrivateFieldGet2$1(_createObj, _this).call(_this, d);
48814
+ _classPrivateFieldGet2$1(_dataMap, _this).set(_classPrivateFieldGet2$1(_id$8, _this).call(_this, d), obj);
48815
+ _classPrivateFieldGet2$1(_objMap, _this).set(obj, d);
48816
+ });
48817
+ var dataIdsMap = new Map(data.map(function (d) {
48818
+ return [_classPrivateFieldGet2$1(_id$8, _this).call(_this, d), d];
48819
+ }));
48820
+ _classPrivateFieldGet2$1(_dataMap, this).forEach(function (o, dId) {
48821
+ if (!dataIdsMap.has(dId)) {
48822
+ _classPrivateFieldGet2$1(_removeObj, _this).call(_this, o, dId);
48823
+ _classPrivateFieldGet2$1(_dataMap, _this)["delete"](dId);
48824
+ _classPrivateFieldGet2$1(_objMap, _this)["delete"](o);
48825
+ } else {
48826
+ _classPrivateFieldGet2$1(_updateObj, _this).call(_this, o, dataIdsMap.get(dId));
48827
+ }
48828
+ });
48829
+ return this;
48830
+ }
48831
+ }, {
48832
+ key: "clear",
48833
+ value: function clear() {
48834
+ this.digest([]);
48835
+ return this;
48836
+ }
48837
+ }]);
48838
+ }();
49074
48839
 
49075
48840
  function getDefaultExportFromCjs (x) {
49076
48841
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
@@ -52018,16 +51783,16 @@ void main() {
52018
51783
  return data ? v(data) : v;
52019
51784
  }
52020
51785
 
52021
- function _arrayLikeToArray$2(r, a) {
51786
+ function _arrayLikeToArray$3(r, a) {
52022
51787
  (null == a || a > r.length) && (a = r.length);
52023
51788
  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
52024
51789
  return n;
52025
51790
  }
52026
- function _arrayWithHoles$2(r) {
51791
+ function _arrayWithHoles$3(r) {
52027
51792
  if (Array.isArray(r)) return r;
52028
51793
  }
52029
- function _arrayWithoutHoles$2(r) {
52030
- if (Array.isArray(r)) return _arrayLikeToArray$2(r);
51794
+ function _arrayWithoutHoles$3(r) {
51795
+ if (Array.isArray(r)) return _arrayLikeToArray$3(r);
52031
51796
  }
52032
51797
  function _assertThisInitialized$2(e) {
52033
51798
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -52069,10 +51834,10 @@ void main() {
52069
51834
  return !!t;
52070
51835
  })();
52071
51836
  }
52072
- function _iterableToArray$2(r) {
51837
+ function _iterableToArray$3(r) {
52073
51838
  if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
52074
51839
  }
52075
- function _iterableToArrayLimit$2(r, l) {
51840
+ function _iterableToArrayLimit$3(r, l) {
52076
51841
  var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
52077
51842
  if (null != t) {
52078
51843
  var e,
@@ -52096,10 +51861,10 @@ void main() {
52096
51861
  return a;
52097
51862
  }
52098
51863
  }
52099
- function _nonIterableRest$2() {
51864
+ function _nonIterableRest$3() {
52100
51865
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52101
51866
  }
52102
- function _nonIterableSpread$2() {
51867
+ function _nonIterableSpread$3() {
52103
51868
  throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52104
51869
  }
52105
51870
  function _possibleConstructorReturn$1(t, e) {
@@ -52112,17 +51877,17 @@ void main() {
52112
51877
  return t.__proto__ = e, t;
52113
51878
  }, _setPrototypeOf$2(t, e);
52114
51879
  }
52115
- function _slicedToArray$2(r, e) {
52116
- return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest$2();
51880
+ function _slicedToArray$3(r, e) {
51881
+ return _arrayWithHoles$3(r) || _iterableToArrayLimit$3(r, e) || _unsupportedIterableToArray$3(r, e) || _nonIterableRest$3();
52117
51882
  }
52118
- function _toConsumableArray$2(r) {
52119
- return _arrayWithoutHoles$2(r) || _iterableToArray$2(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread$2();
51883
+ function _toConsumableArray$3(r) {
51884
+ return _arrayWithoutHoles$3(r) || _iterableToArray$3(r) || _unsupportedIterableToArray$3(r) || _nonIterableSpread$3();
52120
51885
  }
52121
- function _unsupportedIterableToArray$2(r, a) {
51886
+ function _unsupportedIterableToArray$3(r, a) {
52122
51887
  if (r) {
52123
- if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
51888
+ if ("string" == typeof r) return _arrayLikeToArray$3(r, a);
52124
51889
  var t = {}.toString.call(r).slice(8, -1);
52125
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
51890
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0;
52126
51891
  }
52127
51892
  }
52128
51893
 
@@ -52133,17 +51898,17 @@ void main() {
52133
51898
  var contour = interpolateContourPoints(polygon, resolution);
52134
51899
  var edgePoints = merge(contour);
52135
51900
  var innerPoints = getInnerGeoPoints(polygon, resolution);
52136
- var points = [].concat(_toConsumableArray$2(edgePoints), _toConsumableArray$2(innerPoints));
51901
+ var points = [].concat(_toConsumableArray$3(edgePoints), _toConsumableArray$3(innerPoints));
52137
51902
  var boundariesGeojson = {
52138
51903
  type: 'Polygon',
52139
51904
  coordinates: polygon
52140
51905
  };
52141
51906
  var _geoBounds = geoBounds(boundariesGeojson),
52142
- _geoBounds2 = _slicedToArray$2(_geoBounds, 2),
52143
- _geoBounds2$ = _slicedToArray$2(_geoBounds2[0], 2),
51907
+ _geoBounds2 = _slicedToArray$3(_geoBounds, 2),
51908
+ _geoBounds2$ = _slicedToArray$3(_geoBounds2[0], 2),
52144
51909
  minLng = _geoBounds2$[0],
52145
51910
  minLat = _geoBounds2$[1],
52146
- _geoBounds2$2 = _slicedToArray$2(_geoBounds2[1], 2),
51911
+ _geoBounds2$2 = _slicedToArray$3(_geoBounds2[1], 2),
52147
51912
  maxLng = _geoBounds2$2[0],
52148
51913
  maxLat = _geoBounds2$2[1];
52149
51914
  var crossesPoleOrAntimeridian = minLng > maxLng // crosses antimeridian
@@ -52155,7 +51920,7 @@ void main() {
52155
51920
  // Use d3-geo-voronoi. Slowest, but most accurate for polygons that cross poles or anti-meridian
52156
51921
  var vt = geoVoronoi(points).triangles(); // geoDelaunay generates more triangles than needed
52157
51922
  var pntMap = new Map(points.map(function (_ref2, idx) {
52158
- var _ref3 = _slicedToArray$2(_ref2, 2),
51923
+ var _ref3 = _slicedToArray$3(_ref2, 2),
52159
51924
  lng = _ref3[0],
52160
51925
  lat = _ref3[1];
52161
51926
  return ["".concat(lng, "-").concat(lat), idx];
@@ -52166,7 +51931,7 @@ void main() {
52166
51931
 
52167
51932
  var inds = [];
52168
51933
  triangle.forEach(function (_ref4) {
52169
- var _ref5 = _slicedToArray$2(_ref4, 2),
51934
+ var _ref5 = _slicedToArray$3(_ref4, 2),
52170
51935
  lng = _ref5[0],
52171
51936
  lat = _ref5[1];
52172
51937
  var k = "".concat(lng, "-").concat(lat);
@@ -52213,7 +51978,7 @@ void main() {
52213
51978
  });
52214
51979
  if (!pointInside(triangleCentroid, boundariesGeojson, crossesPoleOrAntimeridian)) return 1; // continue
52215
51980
  }
52216
- (_indices2 = indices).push.apply(_indices2, _toConsumableArray$2(inds));
51981
+ (_indices2 = indices).push.apply(_indices2, _toConsumableArray$3(inds));
52217
51982
  };
52218
51983
  for (var i = 0, len = delaunay.triangles.length; i < len; i += 3) {
52219
51984
  if (_loop(i)) continue;
@@ -52228,7 +51993,7 @@ void main() {
52228
51993
  return d[1];
52229
51994
  }), [0, 1]);
52230
51995
  var uvs = points.map(function (_ref6) {
52231
- var _ref7 = _slicedToArray$2(_ref6, 2),
51996
+ var _ref7 = _slicedToArray$3(_ref6, 2),
52232
51997
  lng = _ref7[0],
52233
51998
  lat = _ref7[1];
52234
51999
  return [lngUvScale(lng), latUvScale(lat)];
@@ -52272,11 +52037,11 @@ void main() {
52272
52037
  coordinates: polygon
52273
52038
  };
52274
52039
  var _geoBounds3 = geoBounds(boundariesGeojson),
52275
- _geoBounds4 = _slicedToArray$2(_geoBounds3, 2),
52276
- _geoBounds4$ = _slicedToArray$2(_geoBounds4[0], 2),
52040
+ _geoBounds4 = _slicedToArray$3(_geoBounds3, 2),
52041
+ _geoBounds4$ = _slicedToArray$3(_geoBounds4[0], 2),
52277
52042
  minLng = _geoBounds4$[0],
52278
52043
  minLat = _geoBounds4$[1],
52279
- _geoBounds4$2 = _slicedToArray$2(_geoBounds4[1], 2),
52044
+ _geoBounds4$2 = _slicedToArray$3(_geoBounds4[1], 2),
52280
52045
  maxLng = _geoBounds4$2[0],
52281
52046
  maxLat = _geoBounds4$2[1];
52282
52047
 
@@ -52346,12 +52111,12 @@ void main() {
52346
52111
 
52347
52112
  // support both modes for backwards threejs compatibility
52348
52113
  var setAttributeFn = new THREE$j.BufferGeometry().setAttribute ? 'setAttribute' : 'addAttribute';
52349
- var ConicPolygonBufferGeometry = /*#__PURE__*/function (_THREE$BufferGeometry) {
52350
- function ConicPolygonBufferGeometry(polygonGeoJson, startHeight, endHeight, closedBottom, closedTop, includeSides, curvatureResolution) {
52114
+ var ConicPolygonGeometry = /*#__PURE__*/function (_THREE$BufferGeometry) {
52115
+ function ConicPolygonGeometry(polygonGeoJson, startHeight, endHeight, closedBottom, closedTop, includeSides, curvatureResolution) {
52351
52116
  var _this;
52352
- _classCallCheck$1(this, ConicPolygonBufferGeometry);
52353
- _this = _callSuper$1(this, ConicPolygonBufferGeometry);
52354
- _this.type = 'ConicPolygonBufferGeometry';
52117
+ _classCallCheck$1(this, ConicPolygonGeometry);
52118
+ _this = _callSuper$1(this, ConicPolygonGeometry);
52119
+ _this.type = 'ConicPolygonGeometry';
52355
52120
  _this.parameters = {
52356
52121
  polygonGeoJson: polygonGeoJson,
52357
52122
  startHeight: startHeight,
@@ -52409,7 +52174,7 @@ void main() {
52409
52174
  function generateVertices(polygon, altitude) {
52410
52175
  var coords3d = polygon.map(function (coords) {
52411
52176
  return coords.map(function (_ref) {
52412
- var _ref2 = _slicedToArray$2(_ref, 2),
52177
+ var _ref2 = _slicedToArray$3(_ref, 2),
52413
52178
  lng = _ref2[0],
52414
52179
  lat = _ref2[1];
52415
52180
  return polar2Cartesian$1(lat, lng, altitude);
@@ -52462,8 +52227,8 @@ void main() {
52462
52227
  }
52463
52228
  return _this;
52464
52229
  }
52465
- _inherits$1(ConicPolygonBufferGeometry, _THREE$BufferGeometry);
52466
- return _createClass$1(ConicPolygonBufferGeometry);
52230
+ _inherits$1(ConicPolygonGeometry, _THREE$BufferGeometry);
52231
+ return _createClass$1(ConicPolygonGeometry);
52467
52232
  }(THREE$j.BufferGeometry); //
52468
52233
  function polar2Cartesian$1(lat, lng) {
52469
52234
  var r = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
@@ -52477,6 +52242,188 @@ void main() {
52477
52242
  ];
52478
52243
  }
52479
52244
 
52245
+ function _arrayLikeToArray$2(r, a) {
52246
+ (null == a || a > r.length) && (a = r.length);
52247
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
52248
+ return n;
52249
+ }
52250
+ function _arrayWithHoles$2(r) {
52251
+ if (Array.isArray(r)) return r;
52252
+ }
52253
+ function _arrayWithoutHoles$2(r) {
52254
+ if (Array.isArray(r)) return _arrayLikeToArray$2(r);
52255
+ }
52256
+ function _iterableToArray$2(r) {
52257
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
52258
+ }
52259
+ function _iterableToArrayLimit$2(r, l) {
52260
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
52261
+ if (null != t) {
52262
+ var e,
52263
+ n,
52264
+ i,
52265
+ u,
52266
+ a = [],
52267
+ f = !0,
52268
+ o = !1;
52269
+ try {
52270
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
52271
+ } catch (r) {
52272
+ o = !0, n = r;
52273
+ } finally {
52274
+ try {
52275
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
52276
+ } finally {
52277
+ if (o) throw n;
52278
+ }
52279
+ }
52280
+ return a;
52281
+ }
52282
+ }
52283
+ function _nonIterableRest$2() {
52284
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52285
+ }
52286
+ function _nonIterableSpread$2() {
52287
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
52288
+ }
52289
+ function _objectWithoutProperties$1(e, t) {
52290
+ if (null == e) return {};
52291
+ var o,
52292
+ r,
52293
+ i = _objectWithoutPropertiesLoose$1(e, t);
52294
+ if (Object.getOwnPropertySymbols) {
52295
+ var s = Object.getOwnPropertySymbols(e);
52296
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
52297
+ }
52298
+ return i;
52299
+ }
52300
+ function _objectWithoutPropertiesLoose$1(r, e) {
52301
+ if (null == r) return {};
52302
+ var t = {};
52303
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
52304
+ if (e.includes(n)) continue;
52305
+ t[n] = r[n];
52306
+ }
52307
+ return t;
52308
+ }
52309
+ function _slicedToArray$2(r, e) {
52310
+ return _arrayWithHoles$2(r) || _iterableToArrayLimit$2(r, e) || _unsupportedIterableToArray$2(r, e) || _nonIterableRest$2();
52311
+ }
52312
+ function _toConsumableArray$2(r) {
52313
+ return _arrayWithoutHoles$2(r) || _iterableToArray$2(r) || _unsupportedIterableToArray$2(r) || _nonIterableSpread$2();
52314
+ }
52315
+ function _toPrimitive$2(t, r) {
52316
+ if ("object" != typeof t || !t) return t;
52317
+ var e = t[Symbol.toPrimitive];
52318
+ if (void 0 !== e) {
52319
+ var i = e.call(t, r );
52320
+ if ("object" != typeof i) return i;
52321
+ throw new TypeError("@@toPrimitive must return a primitive value.");
52322
+ }
52323
+ return (String )(t);
52324
+ }
52325
+ function _toPropertyKey$2(t) {
52326
+ var i = _toPrimitive$2(t, "string");
52327
+ return "symbol" == typeof i ? i : i + "";
52328
+ }
52329
+ function _unsupportedIterableToArray$2(r, a) {
52330
+ if (r) {
52331
+ if ("string" == typeof r) return _arrayLikeToArray$2(r, a);
52332
+ var t = {}.toString.call(r).slice(8, -1);
52333
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0;
52334
+ }
52335
+ }
52336
+
52337
+ var index = (function () {
52338
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
52339
+ var keyAccessors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
52340
+ var multiItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
52341
+ var flattenKeys = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
52342
+ var keys = (keyAccessors instanceof Array ? keyAccessors.length ? keyAccessors : [undefined] : [keyAccessors]).map(function (key) {
52343
+ return {
52344
+ keyAccessor: key,
52345
+ isProp: !(key instanceof Function)
52346
+ };
52347
+ });
52348
+ var indexedResult = list.reduce(function (res, item) {
52349
+ var iterObj = res;
52350
+ var itemVal = item;
52351
+ keys.forEach(function (_ref, idx) {
52352
+ var keyAccessor = _ref.keyAccessor,
52353
+ isProp = _ref.isProp;
52354
+ var key;
52355
+ if (isProp) {
52356
+ var _itemVal = itemVal,
52357
+ propVal = _itemVal[keyAccessor],
52358
+ rest = _objectWithoutProperties$1(_itemVal, [keyAccessor].map(_toPropertyKey$2));
52359
+ key = propVal;
52360
+ itemVal = rest;
52361
+ } else {
52362
+ key = keyAccessor(itemVal, idx);
52363
+ }
52364
+ if (idx + 1 < keys.length) {
52365
+ if (!iterObj.hasOwnProperty(key)) {
52366
+ iterObj[key] = {};
52367
+ }
52368
+ iterObj = iterObj[key];
52369
+ } else {
52370
+ // Leaf key
52371
+ if (multiItem) {
52372
+ if (!iterObj.hasOwnProperty(key)) {
52373
+ iterObj[key] = [];
52374
+ }
52375
+ iterObj[key].push(itemVal);
52376
+ } else {
52377
+ iterObj[key] = itemVal;
52378
+ }
52379
+ }
52380
+ });
52381
+ return res;
52382
+ }, {});
52383
+ if (multiItem instanceof Function) {
52384
+ // Reduce leaf multiple values
52385
+ (function reduce(node) {
52386
+ var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
52387
+ if (level === keys.length) {
52388
+ Object.keys(node).forEach(function (k) {
52389
+ return node[k] = multiItem(node[k]);
52390
+ });
52391
+ } else {
52392
+ Object.values(node).forEach(function (child) {
52393
+ return reduce(child, level + 1);
52394
+ });
52395
+ }
52396
+ })(indexedResult); // IIFE
52397
+ }
52398
+ var result = indexedResult;
52399
+ if (flattenKeys) {
52400
+ // flatten into array
52401
+ result = [];
52402
+ (function flatten(node) {
52403
+ var accKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
52404
+ if (accKeys.length === keys.length) {
52405
+ result.push({
52406
+ keys: accKeys,
52407
+ vals: node
52408
+ });
52409
+ } else {
52410
+ Object.entries(node).forEach(function (_ref2) {
52411
+ var _ref3 = _slicedToArray$2(_ref2, 2),
52412
+ key = _ref3[0],
52413
+ val = _ref3[1];
52414
+ return flatten(val, [].concat(_toConsumableArray$2(accKeys), [key]));
52415
+ });
52416
+ }
52417
+ })(indexedResult); //IIFE
52418
+
52419
+ if (keyAccessors instanceof Array && keyAccessors.length === 0 && result.length === 1) {
52420
+ // clear keys if there's no key accessors (single result)
52421
+ result[0].keys = [];
52422
+ }
52423
+ }
52424
+ return result;
52425
+ });
52426
+
52480
52427
  // @ts-nocheck
52481
52428
  var libh3 = function (libh3) {
52482
52429
  libh3 = libh3 || {};
@@ -69466,6 +69413,15 @@ void main() {
69466
69413
  writable: !0
69467
69414
  }) : e[r] = t, e;
69468
69415
  }
69416
+ function _get() {
69417
+ return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) {
69418
+ var p = _superPropBase(e, t);
69419
+ if (p) {
69420
+ var n = Object.getOwnPropertyDescriptor(p, t);
69421
+ return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value;
69422
+ }
69423
+ }, _get.apply(null, arguments);
69424
+ }
69469
69425
  function _getPrototypeOf$1(t) {
69470
69426
  return _getPrototypeOf$1 = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
69471
69427
  return t.__proto__ || Object.getPrototypeOf(t);
@@ -69581,6 +69537,16 @@ void main() {
69581
69537
  function _slicedToArray$1(r, e) {
69582
69538
  return _arrayWithHoles$1(r) || _iterableToArrayLimit$1(r, e) || _unsupportedIterableToArray$1(r, e) || _nonIterableRest$1();
69583
69539
  }
69540
+ function _superPropBase(t, o) {
69541
+ for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf$1(t)););
69542
+ return t;
69543
+ }
69544
+ function _superPropGet(t, o, e, r) {
69545
+ var p = _get(_getPrototypeOf$1(t.prototype ), o, e);
69546
+ return "function" == typeof p ? function (t) {
69547
+ return p.apply(e, t);
69548
+ } : p;
69549
+ }
69584
69550
  function _toConsumableArray$1(r) {
69585
69551
  return _arrayWithoutHoles$1(r) || _iterableToArray$1(r) || _unsupportedIterableToArray$1(r) || _nonIterableSpread$1();
69586
69552
  }
@@ -69709,22 +69675,16 @@ void main() {
69709
69675
  Mesh: Mesh,
69710
69676
  ShaderMaterial: ShaderMaterial
69711
69677
  };
69712
- var fragmentShader = "\nuniform vec3 color;\nuniform float coefficient;\nuniform float power;\nvarying vec3 vVertexNormal;\nvarying vec3 vVertexWorldPosition;\nvoid main() {\n vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;\n vec3 viewCameraToVertex\t= (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;\n viewCameraToVertex = normalize(viewCameraToVertex);\n float intensity\t= pow(\n coefficient + dot(vVertexNormal, viewCameraToVertex),\n power\n );\n gl_FragColor = vec4(color, intensity);\n}";
69713
- var vertexShader = "\nvarying vec3 vVertexWorldPosition;\nvarying vec3 vVertexNormal;\nvoid main() {\n vVertexNormal\t= normalize(normalMatrix * normal);\n vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n gl_Position\t= projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}\n";
69714
- var defaultOptions = {
69715
- backside: true,
69716
- coefficient: 0.5,
69717
- color: 'gold',
69718
- size: 2,
69719
- power: 1
69720
- };
69678
+ var vertexShader = "\nuniform float hollowRadius;\n\nvarying vec3 vVertexWorldPosition;\nvarying vec3 vVertexNormal;\nvarying float vCameraDistanceToObjCenter;\nvarying float vVertexAngularDistanceToHollowRadius;\n\nvoid main() { \n vVertexNormal\t= normalize(normalMatrix * normal);\n vVertexWorldPosition = (modelMatrix * vec4(position, 1.0)).xyz;\n \n vec4 objCenterViewPosition = modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0);\n vCameraDistanceToObjCenter = length(objCenterViewPosition);\n \n float edgeAngle = atan(hollowRadius / vCameraDistanceToObjCenter);\n float vertexAngle = acos(dot(normalize(modelViewMatrix * vec4(position, 1.0)), normalize(objCenterViewPosition)));\n vVertexAngularDistanceToHollowRadius = vertexAngle - edgeAngle;\n\n gl_Position\t= projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n}";
69679
+ var fragmentShader = "\nuniform vec3 color;\nuniform float coefficient;\nuniform float power;\nuniform float hollowRadius;\n\nvarying vec3 vVertexNormal;\nvarying vec3 vVertexWorldPosition;\nvarying float vCameraDistanceToObjCenter;\nvarying float vVertexAngularDistanceToHollowRadius;\n\nvoid main() {\n if (vCameraDistanceToObjCenter < hollowRadius) discard; // inside the hollowRadius\n if (vVertexAngularDistanceToHollowRadius < 0.0) discard; // frag position is within the hollow radius\n\n vec3 worldCameraToVertex = vVertexWorldPosition - cameraPosition;\n vec3 viewCameraToVertex\t= (viewMatrix * vec4(worldCameraToVertex, 0.0)).xyz;\n viewCameraToVertex = normalize(viewCameraToVertex);\n float intensity\t= pow(\n coefficient + dot(vVertexNormal, viewCameraToVertex),\n power\n );\n gl_FragColor = vec4(color, intensity);\n}";
69721
69680
 
69722
69681
  // Based off: http://stemkoski.blogspot.fr/2013/07/shaders-in-threejs-glow-and-halo.html
69723
- function createGlowMaterial(coefficient, color, power) {
69682
+ function createGlowMaterial(coefficient, color, power, hollowRadius) {
69724
69683
  return new THREE$h.ShaderMaterial({
69725
69684
  depthWrite: false,
69726
- fragmentShader: fragmentShader,
69727
69685
  transparent: true,
69686
+ vertexShader: vertexShader,
69687
+ fragmentShader: fragmentShader,
69728
69688
  uniforms: {
69729
69689
  coefficient: {
69730
69690
  value: coefficient
@@ -69734,13 +69694,14 @@ void main() {
69734
69694
  },
69735
69695
  power: {
69736
69696
  value: power
69697
+ },
69698
+ hollowRadius: {
69699
+ value: hollowRadius
69737
69700
  }
69738
- },
69739
- vertexShader: vertexShader
69701
+ }
69740
69702
  });
69741
69703
  }
69742
69704
  function createGlowGeometry(geometry, size) {
69743
- // expect BufferGeometry
69744
69705
  var glowGeometry = geometry.clone();
69745
69706
 
69746
69707
  // Resize vertex positions according to normals
@@ -69753,20 +69714,34 @@ void main() {
69753
69714
  glowGeometry.setAttribute('position', new THREE$h.BufferAttribute(position, 3));
69754
69715
  return glowGeometry;
69755
69716
  }
69756
- function createGlowMesh(geometry) {
69757
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultOptions;
69758
- var backside = options.backside,
69759
- coefficient = options.coefficient,
69760
- color = options.color,
69761
- size = options.size,
69762
- power = options.power;
69763
- var glowGeometry = createGlowGeometry(geometry, size);
69764
- var glowMaterial = createGlowMaterial(coefficient, color, power);
69765
- if (backside) {
69766
- glowMaterial.side = THREE$h.BackSide;
69717
+ var GlowMesh = /*#__PURE__*/function (_THREE$Mesh) {
69718
+ function GlowMesh(geometry) {
69719
+ var _this;
69720
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
69721
+ _ref$color = _ref.color,
69722
+ color = _ref$color === void 0 ? 'gold' : _ref$color,
69723
+ _ref$size = _ref.size,
69724
+ size = _ref$size === void 0 ? 2 : _ref$size,
69725
+ _ref$coefficient = _ref.coefficient,
69726
+ coefficient = _ref$coefficient === void 0 ? 0.5 : _ref$coefficient,
69727
+ _ref$power = _ref.power,
69728
+ power = _ref$power === void 0 ? 1 : _ref$power,
69729
+ _ref$hollowRadius = _ref.hollowRadius,
69730
+ hollowRadius = _ref$hollowRadius === void 0 ? 0 : _ref$hollowRadius,
69731
+ _ref$backside = _ref.backside,
69732
+ backside = _ref$backside === void 0 ? true : _ref$backside;
69733
+ _classCallCheck(this, GlowMesh);
69734
+ _this = _callSuper(this, GlowMesh);
69735
+ var glowGeometry = createGlowGeometry(geometry, size);
69736
+ var glowMaterial = createGlowMaterial(coefficient, color, power, hollowRadius);
69737
+ backside && (glowMaterial.side = THREE$h.BackSide);
69738
+ _this.geometry = glowGeometry;
69739
+ _this.material = glowMaterial;
69740
+ return _this;
69767
69741
  }
69768
- return new THREE$h.Mesh(glowGeometry, glowMaterial);
69769
- }
69742
+ _inherits(GlowMesh, _THREE$Mesh);
69743
+ return _createClass(GlowMesh);
69744
+ }(THREE$h.Mesh);
69770
69745
 
69771
69746
  var THREE$g = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
69772
69747
  : {
@@ -69900,13 +69875,12 @@ void main() {
69900
69875
  emptyObject(state.atmosphereObj);
69901
69876
  }
69902
69877
  if (state.atmosphereColor && state.atmosphereAltitude) {
69903
- var obj = state.atmosphereObj = createGlowMesh(state.globeObj.geometry, {
69904
- backside: true,
69878
+ var obj = state.atmosphereObj = new GlowMesh(state.globeObj.geometry, {
69905
69879
  color: state.atmosphereColor,
69906
69880
  size: GLOBE_RADIUS * state.atmosphereAltitude,
69907
- power: 3.5,
69908
- // dispersion
69909
- coefficient: 0.1
69881
+ hollowRadius: GLOBE_RADIUS,
69882
+ coefficient: 0.1,
69883
+ power: 3.5 // dispersion
69910
69884
  });
69911
69885
  obj.visible = !!state.showAtmosphere;
69912
69886
  obj.__globeObjType = 'atmosphere'; // Add object type
@@ -69984,28 +69958,69 @@ void main() {
69984
69958
  return res;
69985
69959
  }
69986
69960
 
69987
- function threeDigest(data, scene) {
69988
- var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
69989
- var _ref = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {},
69990
- _ref$removeDelay = _ref.removeDelay,
69991
- removeDelay = _ref$removeDelay === void 0 ? 0 : _ref$removeDelay;
69992
- return viewDigest(data, scene.children, function (obj) {
69993
- return scene.add(obj);
69994
- }, function (obj) {
69995
- var removeFn = function removeFn() {
69996
- scene.remove(obj);
69997
- emptyObject(obj);
69998
- obj && obj.hasOwnProperty('__data') && delete obj.__data.__currentTargetD;
69999
- };
70000
- removeDelay ? setTimeout(removeFn, removeDelay) : removeFn();
70001
- }, _objectSpread2({
70002
- objBindAttr: '__threeObj'
70003
- }, options));
70004
- }
69961
+ var _dataBindAttr = /*#__PURE__*/new WeakMap();
69962
+ var _objBindAttr = /*#__PURE__*/new WeakMap();
69963
+ var _removeDelay = /*#__PURE__*/new WeakMap();
69964
+ var ThreeDigest = /*#__PURE__*/function (_DataBindMapper) {
69965
+ function ThreeDigest(scene) {
69966
+ var _this;
69967
+ var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
69968
+ _ref$dataBindAttr = _ref.dataBindAttr,
69969
+ dataBindAttr = _ref$dataBindAttr === void 0 ? '__data' : _ref$dataBindAttr,
69970
+ _ref$objBindAttr = _ref.objBindAttr,
69971
+ objBindAttr = _ref$objBindAttr === void 0 ? '__threeObj' : _ref$objBindAttr,
69972
+ _ref$removeDelay = _ref.removeDelay,
69973
+ removeDelay = _ref$removeDelay === void 0 ? 0 : _ref$removeDelay;
69974
+ _classCallCheck(this, ThreeDigest);
69975
+ _this = _callSuper(this, ThreeDigest);
69976
+ _defineProperty$1(_this, "scene", void 0);
69977
+ _classPrivateFieldInitSpec(_this, _dataBindAttr, void 0);
69978
+ _classPrivateFieldInitSpec(_this, _objBindAttr, void 0);
69979
+ _classPrivateFieldInitSpec(_this, _removeDelay, void 0);
69980
+ _this.scene = scene;
69981
+ _classPrivateFieldSet2(_dataBindAttr, _this, dataBindAttr);
69982
+ _classPrivateFieldSet2(_objBindAttr, _this, objBindAttr);
69983
+ _classPrivateFieldSet2(_removeDelay, _this, removeDelay);
69984
+ _this.onRemoveObj(function () {});
69985
+ return _this;
69986
+ }
69987
+ _inherits(ThreeDigest, _DataBindMapper);
69988
+ return _createClass(ThreeDigest, [{
69989
+ key: "onCreateObj",
69990
+ value: function onCreateObj(fn) {
69991
+ var _this2 = this;
69992
+ _superPropGet(ThreeDigest, "onCreateObj", this)([function (d) {
69993
+ var obj = fn(d);
69994
+ d[_classPrivateFieldGet2(_objBindAttr, _this2)] = obj;
69995
+ obj[_classPrivateFieldGet2(_dataBindAttr, _this2)] = d;
69996
+ _this2.scene.add(obj);
69997
+ return obj;
69998
+ }]);
69999
+ return this;
70000
+ }
70001
+ }, {
70002
+ key: "onRemoveObj",
70003
+ value: function onRemoveObj(fn) {
70004
+ var _this3 = this;
70005
+ _superPropGet(ThreeDigest, "onRemoveObj", this)([function (obj, dId) {
70006
+ var d = _superPropGet(ThreeDigest, "getData", _this3)([obj]);
70007
+ fn(obj, dId);
70008
+ var removeFn = function removeFn() {
70009
+ _this3.scene.remove(obj);
70010
+ emptyObject(obj);
70011
+ delete d[_classPrivateFieldGet2(_objBindAttr, _this3)];
70012
+ };
70013
+ _classPrivateFieldGet2(_removeDelay, _this3) ? setTimeout(removeFn, _classPrivateFieldGet2(_removeDelay, _this3)) : removeFn();
70014
+ }]);
70015
+ return this;
70016
+ }
70017
+ }]);
70018
+ }(DataBindMapper);
70005
70019
 
70006
70020
  var THREE$e = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
70007
70021
  : {
70008
70022
  BufferGeometry: BufferGeometry,
70023
+ Color: Color$1,
70009
70024
  CylinderGeometry: CylinderGeometry,
70010
70025
  Matrix4: Matrix4,
70011
70026
  Mesh: Mesh,
@@ -70064,8 +70079,11 @@ void main() {
70064
70079
  // Main three object to manipulate
70065
70080
  state.scene = threeObj;
70066
70081
  state.tweenGroup = tweenGroup;
70082
+ state.dataMapper = new ThreeDigest(threeObj, {
70083
+ objBindAttr: '__threeObjPoint'
70084
+ });
70067
70085
  },
70068
- update: function update(state) {
70086
+ update: function update(state, changedProps) {
70069
70087
  // Data accessors
70070
70088
  var latAccessor = index$1(state.pointLat);
70071
70089
  var lngAccessor = index$1(state.pointLng);
@@ -70080,18 +70098,16 @@ void main() {
70080
70098
  var pxPerDeg = 2 * Math.PI * GLOBE_RADIUS / 360;
70081
70099
  var pointMaterials = {}; // indexed by color
70082
70100
 
70083
- var scene = state.pointsMerge ? new THREE$e.Object3D() : state.scene; // use fake scene if merging points
70101
+ if (!state.pointsMerge && changedProps.hasOwnProperty('pointsMerge')) {
70102
+ emptyObject(state.scene); // Empty trailing merged objects
70103
+ }
70104
+ state.dataMapper.scene = state.pointsMerge ? new THREE$e.Object3D() : state.scene; // use fake scene if merging points
70084
70105
 
70085
- threeDigest(state.pointsData, scene, {
70086
- createObj: createObj,
70087
- updateObj: updateObj
70088
- });
70106
+ state.dataMapper.onCreateObj(createObj).onUpdateObj(updateObj).digest(state.pointsData);
70089
70107
  if (state.pointsMerge) {
70090
70108
  // merge points into a single mesh
70091
70109
  var pointsGeometry = !state.pointsData.length ? new THREE$e.BufferGeometry() : (BufferGeometryUtils$2.mergeGeometries || BufferGeometryUtils$2.mergeBufferGeometries)(state.pointsData.map(function (d) {
70092
- var obj = d.__threeObj;
70093
- d.__threeObj = undefined; // unbind merged points
70094
-
70110
+ var obj = state.dataMapper.getObj(d);
70095
70111
  var geom = obj.geometry.clone();
70096
70112
 
70097
70113
  // apply mesh world transform to vertices
@@ -70111,6 +70127,7 @@ void main() {
70111
70127
  points.__globeObjType = 'points'; // Add object type
70112
70128
  points.__data = state.pointsData; // Attach obj data
70113
70129
 
70130
+ state.dataMapper.clear(); // Unbind merged points
70114
70131
  emptyObject(state.scene);
70115
70132
  state.scene.add(points);
70116
70133
  }
@@ -70250,6 +70267,7 @@ void main() {
70250
70267
  Line: Line,
70251
70268
  Mesh: Mesh,
70252
70269
  NormalBlending: NormalBlending,
70270
+ QuadraticBezierCurve3: QuadraticBezierCurve3,
70253
70271
  ShaderMaterial: ShaderMaterial,
70254
70272
  TubeGeometry: TubeGeometry,
70255
70273
  Vector3: Vector3
@@ -70329,25 +70347,46 @@ void main() {
70329
70347
  },
70330
70348
  _destructor: function _destructor(state) {
70331
70349
  var _state$ticker3;
70350
+ state.sharedMaterial.dispose();
70332
70351
  (_state$ticker3 = state.ticker) === null || _state$ticker3 === void 0 || _state$ticker3.dispose();
70333
70352
  }
70334
70353
  },
70335
- init: function init(threeObj, state, _ref) {
70354
+ stateInit: function stateInit(_ref) {
70336
70355
  var tweenGroup = _ref.tweenGroup;
70356
+ return {
70357
+ tweenGroup: tweenGroup,
70358
+ ticker: new FrameTicker$2(),
70359
+ sharedMaterial: new THREE$d.ShaderMaterial(_objectSpread2(_objectSpread2({}, dashedLineShaders()), {}, {
70360
+ transparent: true,
70361
+ blending: THREE$d.NormalBlending
70362
+ }))
70363
+ };
70364
+ },
70365
+ init: function init(threeObj, state) {
70337
70366
  // Clear the scene
70338
70367
  emptyObject(threeObj);
70339
70368
 
70340
70369
  // Main three object to manipulate
70341
70370
  state.scene = threeObj;
70342
- state.tweenGroup = tweenGroup;
70371
+ state.dataMapper = new ThreeDigest(threeObj, {
70372
+ objBindAttr: '__threeObjArc'
70373
+ }).onCreateObj(function () {
70374
+ var obj = new THREE$d.Group(); // populated in updateObj
70375
+
70376
+ obj.__globeObjType = 'arc'; // Add object type
70377
+ return obj;
70378
+ });
70343
70379
 
70344
70380
  // Kick-off dash animations
70345
- state.ticker = new FrameTicker$2();
70346
70381
  state.ticker.onTick.add(function (_, timeDelta) {
70347
- state.arcsData.filter(function (d) {
70348
- return d.__threeObj && d.__threeObj.children.length && d.__threeObj.children[0].material && d.__threeObj.children[0].__dashAnimateStep;
70349
- }).forEach(function (d) {
70350
- var obj = d.__threeObj.children[0];
70382
+ state.dataMapper.entries().map(function (_ref2) {
70383
+ var _ref3 = _slicedToArray$1(_ref2, 2),
70384
+ obj = _ref3[1];
70385
+ return obj;
70386
+ }).filter(function (o) {
70387
+ return o.children.length && o.children[0].material && o.children[0].__dashAnimateStep;
70388
+ }).forEach(function (o) {
70389
+ var obj = o.children[0];
70351
70390
  var step = obj.__dashAnimateStep * timeDelta;
70352
70391
  var curTranslate = obj.material.uniforms.dashTranslate.value % 1e9; // reset after 1B loops
70353
70392
  obj.material.uniforms.dashTranslate.value = curTranslate + step;
@@ -70368,118 +70407,106 @@ void main() {
70368
70407
  var dashGapAccessor = index$1(state.arcDashGap);
70369
70408
  var dashInitialGapAccessor = index$1(state.arcDashInitialGap);
70370
70409
  var dashAnimateTimeAccessor = index$1(state.arcDashAnimateTime);
70371
- var sharedMaterial = new THREE$d.ShaderMaterial(_objectSpread2(_objectSpread2({}, dashedLineShaders()), {}, {
70372
- transparent: true,
70373
- blending: THREE$d.NormalBlending
70374
- }));
70375
- threeDigest(state.arcsData, state.scene, {
70376
- createObj: function createObj() {
70377
- var obj = new THREE$d.Group(); // populated in updateObj
70410
+ state.dataMapper.onUpdateObj(function (group, arc) {
70411
+ var stroke = strokeAccessor(arc);
70412
+ var useTube = stroke !== null && stroke !== undefined;
70413
+ if (!group.children.length || useTube !== (group.children[0].type === 'Mesh')) {
70414
+ // create or swap object types
70415
+ emptyObject(group);
70416
+ var _obj = useTube ? new THREE$d.Mesh() : new THREE$d.Line(new THREE$d.BufferGeometry());
70417
+ _obj.material = state.sharedMaterial.clone(); // Separate material instance per object to have dedicated uniforms (but shared shaders)
70418
+
70419
+ group.add(_obj);
70420
+ }
70421
+ var obj = group.children[0];
70378
70422
 
70379
- obj.__globeObjType = 'arc'; // Add object type
70380
- return obj;
70381
- },
70382
- updateObj: function updateObj(group, arc) {
70383
- var stroke = strokeAccessor(arc);
70384
- var useTube = stroke !== null && stroke !== undefined;
70385
- if (!group.children.length || useTube !== (group.children[0].type === 'Mesh')) {
70386
- // create or swap object types
70387
- emptyObject(group);
70388
- var _obj = useTube ? new THREE$d.Mesh() : new THREE$d.Line(new THREE$d.BufferGeometry());
70389
- _obj.material = sharedMaterial.clone(); // Separate material instance per object to have dedicated uniforms (but shared shaders)
70390
-
70391
- group.add(_obj);
70423
+ // set dash uniforms
70424
+ Object.assign(obj.material.uniforms, {
70425
+ dashSize: {
70426
+ value: dashLengthAccessor(arc)
70427
+ },
70428
+ gapSize: {
70429
+ value: dashGapAccessor(arc)
70430
+ },
70431
+ dashOffset: {
70432
+ value: dashInitialGapAccessor(arc)
70392
70433
  }
70393
- var obj = group.children[0];
70394
-
70395
- // set dash uniforms
70396
- Object.assign(obj.material.uniforms, {
70397
- dashSize: {
70398
- value: dashLengthAccessor(arc)
70399
- },
70400
- gapSize: {
70401
- value: dashGapAccessor(arc)
70402
- },
70403
- dashOffset: {
70404
- value: dashInitialGapAccessor(arc)
70405
- }
70406
- });
70434
+ });
70407
70435
 
70408
- // set dash animation step
70409
- var dashAnimateTime = dashAnimateTimeAccessor(arc);
70410
- obj.__dashAnimateStep = dashAnimateTime > 0 ? 1000 / dashAnimateTime : 0; // per second
70436
+ // set dash animation step
70437
+ var dashAnimateTime = dashAnimateTimeAccessor(arc);
70438
+ obj.__dashAnimateStep = dashAnimateTime > 0 ? 1000 / dashAnimateTime : 0; // per second
70411
70439
 
70412
- // calculate vertex colors (to create gradient)
70413
- var vertexColorArray = calcColorVertexArray(colorAccessor(arc),
70414
- // single, array of colors or interpolator
70415
- state.arcCurveResolution,
70416
- // numSegments
70417
- useTube ? state.arcCircularResolution + 1 : 1 // num vertices per segment
70418
- );
70440
+ // calculate vertex colors (to create gradient)
70441
+ var vertexColorArray = calcColorVertexArray(colorAccessor(arc),
70442
+ // single, array of colors or interpolator
70443
+ state.arcCurveResolution,
70444
+ // numSegments
70445
+ useTube ? state.arcCircularResolution + 1 : 1 // num vertices per segment
70446
+ );
70419
70447
 
70420
- // calculate vertex relative distances (for dashed lines)
70421
- var vertexRelDistanceArray = calcVertexRelDistances(state.arcCurveResolution,
70422
- // numSegments
70423
- useTube ? state.arcCircularResolution + 1 : 1,
70424
- // num vertices per segment
70425
- true // run from end to start, to animate in the correct direction
70426
- );
70427
- obj.geometry.setAttribute('color', vertexColorArray);
70428
- obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
70429
- var applyUpdate = function applyUpdate(td) {
70430
- var _arc$__currentTargetD = arc.__currentTargetD = td,
70431
- stroke = _arc$__currentTargetD.stroke,
70432
- curveD = _objectWithoutProperties(_arc$__currentTargetD, _excluded$1);
70433
- var curve = calcCurve(curveD);
70434
- if (useTube) {
70435
- obj.geometry && obj.geometry.dispose();
70436
- obj.geometry = new THREE$d.TubeGeometry(curve, state.arcCurveResolution, stroke / 2, state.arcCircularResolution);
70437
- obj.geometry.setAttribute('color', vertexColorArray);
70438
- obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
70439
- } else {
70440
- obj.geometry.setFromPoints(curve.getPoints(state.arcCurveResolution));
70441
- }
70442
- };
70443
- var targetD = {
70444
- stroke: stroke,
70445
- alt: altitudeAccessor(arc),
70446
- altAutoScale: +altitudeAutoScaleAccessor(arc),
70447
- startLat: +startLatAccessor(arc),
70448
- startLng: +startLngAccessor(arc),
70449
- endLat: +endLatAccessor(arc),
70450
- endLng: +endLngAccessor(arc)
70451
- };
70452
- var currentTargetD = arc.__currentTargetD || Object.assign({}, targetD, {
70453
- altAutoScale: -1e-3
70454
- });
70455
- if (Object.keys(targetD).some(function (k) {
70456
- return currentTargetD[k] !== targetD[k];
70457
- })) {
70458
- if (!state.arcsTransitionDuration || state.arcsTransitionDuration < 0) {
70459
- // set final position
70460
- applyUpdate(targetD);
70461
- } else {
70462
- // animate
70463
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.arcsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
70464
- }
70448
+ // calculate vertex relative distances (for dashed lines)
70449
+ var vertexRelDistanceArray = calcVertexRelDistances(state.arcCurveResolution,
70450
+ // numSegments
70451
+ useTube ? state.arcCircularResolution + 1 : 1,
70452
+ // num vertices per segment
70453
+ true // run from end to start, to animate in the correct direction
70454
+ );
70455
+ obj.geometry.setAttribute('color', vertexColorArray);
70456
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
70457
+ var applyUpdate = function applyUpdate(td) {
70458
+ var _group$__currentTarge = group.__currentTargetD = td,
70459
+ stroke = _group$__currentTarge.stroke,
70460
+ curveD = _objectWithoutProperties(_group$__currentTarge, _excluded$1);
70461
+ var curve = calcCurve(curveD);
70462
+ if (useTube) {
70463
+ obj.geometry && obj.geometry.dispose();
70464
+ obj.geometry = new THREE$d.TubeGeometry(curve, state.arcCurveResolution, stroke / 2, state.arcCircularResolution);
70465
+ obj.geometry.setAttribute('color', vertexColorArray);
70466
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
70467
+ } else {
70468
+ obj.geometry.setFromPoints(curve.getPoints(state.arcCurveResolution));
70469
+ }
70470
+ };
70471
+ var targetD = {
70472
+ stroke: stroke,
70473
+ alt: altitudeAccessor(arc),
70474
+ altAutoScale: +altitudeAutoScaleAccessor(arc),
70475
+ startLat: +startLatAccessor(arc),
70476
+ startLng: +startLngAccessor(arc),
70477
+ endLat: +endLatAccessor(arc),
70478
+ endLng: +endLngAccessor(arc)
70479
+ };
70480
+ var currentTargetD = group.__currentTargetD || Object.assign({}, targetD, {
70481
+ altAutoScale: -1e-3
70482
+ });
70483
+ if (Object.keys(targetD).some(function (k) {
70484
+ return currentTargetD[k] !== targetD[k];
70485
+ })) {
70486
+ if (!state.arcsTransitionDuration || state.arcsTransitionDuration < 0) {
70487
+ // set final position
70488
+ applyUpdate(targetD);
70489
+ } else {
70490
+ // animate
70491
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.arcsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
70465
70492
  }
70466
70493
  }
70467
- });
70494
+ }).digest(state.arcsData);
70468
70495
 
70469
70496
  //
70470
70497
 
70471
- function calcCurve(_ref2) {
70472
- var alt = _ref2.alt,
70473
- altAutoScale = _ref2.altAutoScale,
70474
- startLat = _ref2.startLat,
70475
- startLng = _ref2.startLng,
70476
- endLat = _ref2.endLat,
70477
- endLng = _ref2.endLng;
70478
- var getVec = function getVec(_ref3) {
70479
- var _ref4 = _slicedToArray$1(_ref3, 3),
70480
- lng = _ref4[0],
70481
- lat = _ref4[1],
70482
- alt = _ref4[2];
70498
+ function calcCurve(_ref4) {
70499
+ var alt = _ref4.alt,
70500
+ altAutoScale = _ref4.altAutoScale,
70501
+ startLat = _ref4.startLat,
70502
+ startLng = _ref4.startLng,
70503
+ endLat = _ref4.endLat,
70504
+ endLng = _ref4.endLng;
70505
+ var getVec = function getVec(_ref5) {
70506
+ var _ref6 = _slicedToArray$1(_ref5, 3),
70507
+ lng = _ref6[0],
70508
+ lat = _ref6[1],
70509
+ alt = _ref6[2];
70483
70510
  var _polar2Cartesian = polar2Cartesian(lat, lng, alt),
70484
70511
  x = _polar2Cartesian.x,
70485
70512
  y = _polar2Cartesian.y,
@@ -70581,6 +70608,7 @@ void main() {
70581
70608
  var THREE$c = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
70582
70609
  : {
70583
70610
  BufferGeometry: BufferGeometry,
70611
+ Color: Color$1,
70584
70612
  DoubleSide: DoubleSide,
70585
70613
  Mesh: Mesh,
70586
70614
  MeshLambertMaterial: MeshLambertMaterial,
@@ -70651,8 +70679,11 @@ void main() {
70651
70679
  // Main three object to manipulate
70652
70680
  state.scene = threeObj;
70653
70681
  state.tweenGroup = tweenGroup;
70682
+ state.dataMapper = new ThreeDigest(threeObj, {
70683
+ objBindAttr: '__threeObjHexbin'
70684
+ });
70654
70685
  },
70655
- update: function update(state) {
70686
+ update: function update(state, changedProps) {
70656
70687
  // Accessors
70657
70688
  var latAccessor = index$1(state.hexBinPointLat);
70658
70689
  var lngAccessor = index$1(state.hexBinPointLng);
@@ -70680,20 +70711,18 @@ void main() {
70680
70711
  });
70681
70712
  var hexMaterials = {}; // indexed by color
70682
70713
 
70683
- var scene = state.hexBinMerge ? new THREE$c.Object3D() : state.scene; // use fake scene if merging hex points
70714
+ if (!state.hexBinMerge && changedProps.hasOwnProperty('hexBinMerge')) {
70715
+ emptyObject(state.scene); // Empty trailing merged objects
70716
+ }
70717
+ state.dataMapper.scene = state.hexBinMerge ? new THREE$c.Object3D() : state.scene; // use fake scene if merging hex points
70684
70718
 
70685
- threeDigest(hexBins, scene, {
70686
- createObj: createObj,
70687
- updateObj: updateObj,
70688
- idAccessor: function idAccessor(d) {
70689
- return d.h3Idx;
70690
- }
70691
- });
70719
+ state.dataMapper.id(function (d) {
70720
+ return d.h3Idx;
70721
+ }).onCreateObj(createObj).onUpdateObj(updateObj).digest(hexBins);
70692
70722
  if (state.hexBinMerge) {
70693
70723
  // merge points into a single mesh
70694
70724
  var hexPointsGeometry = !hexBins.length ? new THREE$c.BufferGeometry() : (BufferGeometryUtils$1.mergeGeometries || BufferGeometryUtils$1.mergeBufferGeometries)(hexBins.map(function (d) {
70695
- var obj = d.__threeObj;
70696
- d.__threeObj = undefined; // unbind merged points
70725
+ var obj = state.dataMapper.getObj(d);
70697
70726
 
70698
70727
  // use non-indexed geometry so that groups can be colored separately, otherwise different groups share vertices
70699
70728
  var geom = obj.geometry.toNonIndexed();
@@ -70712,15 +70741,20 @@ void main() {
70712
70741
  }), 4));
70713
70742
  return geom;
70714
70743
  }));
70715
- var hexPoints = new THREE$c.Mesh(hexPointsGeometry, applyShaderExtensionToMaterial(new THREE$c.MeshLambertMaterial({
70744
+ var hexMaterial = new THREE$c.MeshLambertMaterial({
70716
70745
  color: 0xffffff,
70717
70746
  transparent: true,
70718
70747
  vertexColors: true,
70719
70748
  side: THREE$c.DoubleSide
70720
- }), invisibleUndergroundShaderExtend));
70749
+ });
70750
+ hexMaterial.onBeforeCompile = function (shader) {
70751
+ hexMaterial.userData.shader = invisibleUndergroundShaderExtend(shader);
70752
+ };
70753
+ var hexPoints = new THREE$c.Mesh(hexPointsGeometry, hexMaterial);
70721
70754
  hexPoints.__globeObjType = 'hexBinPoints'; // Add object type
70722
70755
  hexPoints.__data = hexBins; // Attach obj data
70723
70756
 
70757
+ state.dataMapper.clear(); // Unbind merged points
70724
70758
  emptyObject(state.scene);
70725
70759
  state.scene.add(hexPoints);
70726
70760
  }
@@ -70766,7 +70800,7 @@ void main() {
70766
70800
  });
70767
70801
  var topCurvatureResolution = state.hexTopCurvatureResolution;
70768
70802
  obj.geometry && obj.geometry.dispose();
70769
- obj.geometry = new ConicPolygonBufferGeometry([geoJson], 0, GLOBE_RADIUS, false, true, true, topCurvatureResolution);
70803
+ obj.geometry = new ConicPolygonGeometry([geoJson], 0, GLOBE_RADIUS, false, true, true, topCurvatureResolution);
70770
70804
  var targetD = {
70771
70805
  alt: +altitudeAccessor(d)
70772
70806
  };
@@ -70974,6 +71008,16 @@ void main() {
70974
71008
  // Main three object to manipulate
70975
71009
  state.scene = threeObj;
70976
71010
  state.tweenGroup = tweenGroup;
71011
+ state.dataMapper = new ThreeDigest(threeObj, {
71012
+ objBindAttr: '__threeObjHeatmap'
71013
+ }).onCreateObj(function () {
71014
+ var obj = new THREE$b.Mesh(new THREE$b.SphereGeometry(GLOBE_RADIUS), applyShaderExtensionToMaterial(new THREE$b.MeshLambertMaterial({
71015
+ vertexColors: true,
71016
+ transparent: true
71017
+ }), setRadiusShaderExtend));
71018
+ obj.__globeObjType = 'heatmap'; // Add object type
71019
+ return obj;
71020
+ });
70977
71021
  },
70978
71022
  update: function update(state) {
70979
71023
  // Accessors
@@ -70986,133 +71030,123 @@ void main() {
70986
71030
  var saturationAccessor = index$1(state.heatmapColorSaturation);
70987
71031
  var baseAltitudeAccessor = index$1(state.heatmapBaseAltitude);
70988
71032
  var topAltitudeAccessor = index$1(state.heatmapTopAltitude);
70989
- threeDigest(state.heatmapsData, state.scene, {
70990
- createObj: function createObj() {
70991
- var obj = new THREE$b.Mesh(new THREE$b.SphereGeometry(GLOBE_RADIUS), applyShaderExtensionToMaterial(new THREE$b.MeshLambertMaterial({
70992
- vertexColors: true,
70993
- transparent: true
70994
- }), setRadiusShaderExtend));
70995
- obj.__globeObjType = 'heatmap'; // Add object type
70996
- return obj;
70997
- },
70998
- updateObj: function updateObj(obj, d) {
70999
- // Accessors
71000
- var bandwidth = bandwidthAccessor(d);
71001
- var colorFn = colorFnAccessor(d);
71002
- var saturation = saturationAccessor(d);
71003
- var baseAlt = baseAltitudeAccessor(d);
71004
- var topAlt = topAltitudeAccessor(d);
71005
- var pnts = pointsAccessor(d).map(function (pnt) {
71006
- var lat = latPntAccessor(pnt);
71007
- var lng = lngPntAccessor(pnt);
71008
- var _polar2Cartesian = polar2Cartesian(lat, lng),
71009
- x = _polar2Cartesian.x,
71010
- y = _polar2Cartesian.y,
71011
- z = _polar2Cartesian.z;
71012
- return {
71033
+ state.dataMapper.onUpdateObj(function (obj, d) {
71034
+ // Accessors
71035
+ var bandwidth = bandwidthAccessor(d);
71036
+ var colorFn = colorFnAccessor(d);
71037
+ var saturation = saturationAccessor(d);
71038
+ var baseAlt = baseAltitudeAccessor(d);
71039
+ var topAlt = topAltitudeAccessor(d);
71040
+ var pnts = pointsAccessor(d).map(function (pnt) {
71041
+ var lat = latPntAccessor(pnt);
71042
+ var lng = lngPntAccessor(pnt);
71043
+ var _polar2Cartesian = polar2Cartesian(lat, lng),
71044
+ x = _polar2Cartesian.x,
71045
+ y = _polar2Cartesian.y,
71046
+ z = _polar2Cartesian.z;
71047
+ return {
71048
+ x: x,
71049
+ y: y,
71050
+ z: z,
71051
+ lat: lat,
71052
+ lng: lng,
71053
+ weight: weightPntAccessor(pnt)
71054
+ };
71055
+ });
71056
+
71057
+ // Check resolution
71058
+ var resolution = Math.max(MIN_RESOLUTION, bandwidth / RES_BW_FACTOR);
71059
+ var equatorNumSegments = Math.ceil(360 / (resolution || -1));
71060
+ if (obj.geometry.parameters.widthSegments !== equatorNumSegments) {
71061
+ obj.geometry.dispose();
71062
+ obj.geometry = new THREE$b.SphereGeometry(GLOBE_RADIUS, equatorNumSegments, equatorNumSegments / 2);
71063
+ }
71064
+
71065
+ // Get vertex polar coordinates
71066
+ var vertexCoords = bufferAttr2Array(obj.geometry.getAttribute('position'));
71067
+ var vertexGeoCoords = vertexCoords.map(function (_ref2) {
71068
+ var _ref3 = _slicedToArray$1(_ref2, 3),
71069
+ x = _ref3[0],
71070
+ y = _ref3[1],
71071
+ z = _ref3[2];
71072
+ var _cartesian2Polar = cartesian2Polar({
71013
71073
  x: x,
71014
71074
  y: y,
71015
- z: z,
71016
- lat: lat,
71017
- lng: lng,
71018
- weight: weightPntAccessor(pnt)
71019
- };
71020
- });
71021
-
71022
- // Check resolution
71023
- var resolution = Math.max(MIN_RESOLUTION, bandwidth / RES_BW_FACTOR);
71024
- var equatorNumSegments = Math.ceil(360 / (resolution || -1));
71025
- if (obj.geometry.parameters.widthSegments !== equatorNumSegments) {
71026
- obj.geometry.dispose();
71027
- obj.geometry = new THREE$b.SphereGeometry(GLOBE_RADIUS, equatorNumSegments, equatorNumSegments / 2);
71028
- }
71075
+ z: z
71076
+ }),
71077
+ lng = _cartesian2Polar.lng,
71078
+ lat = _cartesian2Polar.lat;
71079
+ return [lng, lat];
71080
+ });
71029
71081
 
71030
- // Get vertex polar coordinates
71031
- var vertexCoords = bufferAttr2Array(obj.geometry.getAttribute('position'));
71032
- var vertexGeoCoords = vertexCoords.map(function (_ref2) {
71033
- var _ref3 = _slicedToArray$1(_ref2, 3),
71034
- x = _ref3[0],
71035
- y = _ref3[1],
71036
- z = _ref3[2];
71037
- var _cartesian2Polar = cartesian2Polar({
71038
- x: x,
71039
- y: y,
71040
- z: z
71041
- }),
71042
- lng = _cartesian2Polar.lng,
71043
- lat = _cartesian2Polar.lat;
71044
- return [lng, lat];
71082
+ // Compute KDE
71083
+ var pntsOctree = new PointsOctree(pnts, bandwidth * BW_RADIUS_INFLUENCE);
71084
+ var kdeVals = vertexGeoCoords.map(function (vxCoords, idx) {
71085
+ var _vertexCoords$idx = _slicedToArray$1(vertexCoords[idx], 3),
71086
+ x = _vertexCoords$idx[0],
71087
+ y = _vertexCoords$idx[1],
71088
+ z = _vertexCoords$idx[2];
71089
+ return getGeoKDE(vxCoords, pntsOctree.getNearPoints(x, y, z), {
71090
+ latAccessor: function latAccessor(d) {
71091
+ return d.lat;
71092
+ },
71093
+ lngAccessor: function lngAccessor(d) {
71094
+ return d.lng;
71095
+ },
71096
+ weightAccessor: function weightAccessor(d) {
71097
+ return d.weight;
71098
+ },
71099
+ bandwidth: bandwidth
71045
71100
  });
71101
+ });
71046
71102
 
71047
- // Compute KDE
71048
- var pntsOctree = new PointsOctree(pnts, bandwidth * BW_RADIUS_INFLUENCE);
71049
- var kdeVals = vertexGeoCoords.map(function (vxCoords, idx) {
71050
- var _vertexCoords$idx = _slicedToArray$1(vertexCoords[idx], 3),
71051
- x = _vertexCoords$idx[0],
71052
- y = _vertexCoords$idx[1],
71053
- z = _vertexCoords$idx[2];
71054
- return getGeoKDE(vxCoords, pntsOctree.getNearPoints(x, y, z), {
71055
- latAccessor: function latAccessor(d) {
71056
- return d.lat;
71057
- },
71058
- lngAccessor: function lngAccessor(d) {
71059
- return d.lng;
71060
- },
71061
- weightAccessor: function weightAccessor(d) {
71062
- return d.weight;
71063
- },
71064
- bandwidth: bandwidth
71065
- });
71066
- });
71103
+ // Animations
71104
+ var colors = _toConsumableArray$1(new Array(NUM_COLORS)).map(function (_, idx) {
71105
+ return color2ShaderArr(colorFn(idx / (NUM_COLORS - 1)));
71106
+ });
71107
+ var applyUpdate = function applyUpdate(td) {
71108
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
71109
+ kdeVals = _obj$__currentTargetD.kdeVals,
71110
+ topAlt = _obj$__currentTargetD.topAlt,
71111
+ saturation = _obj$__currentTargetD.saturation;
71112
+ var maxVal = max$2(kdeVals.map(Math.abs)) || 1e-15;
71113
+
71114
+ // Set vertex colors
71115
+ var colorScale = quantize([0, maxVal / saturation], colors);
71116
+ obj.geometry.setAttribute('color', array2BufferAttr(kdeVals.map(function (v) {
71117
+ return colorScale(Math.abs(v));
71118
+ }), 4));
71067
71119
 
71068
- // Animations
71069
- var colors = _toConsumableArray$1(new Array(NUM_COLORS)).map(function (_, idx) {
71070
- return color2ShaderArr(colorFn(idx / (NUM_COLORS - 1)));
71071
- });
71072
- var applyUpdate = function applyUpdate(td) {
71073
- var _obj$__currentTargetD = obj.__currentTargetD = td,
71074
- kdeVals = _obj$__currentTargetD.kdeVals,
71075
- topAlt = _obj$__currentTargetD.topAlt,
71076
- saturation = _obj$__currentTargetD.saturation;
71077
- var maxVal = max$2(kdeVals.map(Math.abs)) || 1e-15;
71078
-
71079
- // Set vertex colors
71080
- var colorScale = quantize([0, maxVal / saturation], colors);
71081
- obj.geometry.setAttribute('color', array2BufferAttr(kdeVals.map(function (v) {
71082
- return colorScale(Math.abs(v));
71083
- }), 4));
71084
-
71085
- // Set altitudes
71086
- var rScale = linear([0, maxVal], [GLOBE_RADIUS * (1 + baseAlt), GLOBE_RADIUS * (1 + (topAlt || baseAlt))]);
71087
- obj.geometry.setAttribute('r', array2BufferAttr(kdeVals.map(rScale)));
71088
- };
71089
- var targetD = {
71090
- kdeVals: kdeVals,
71091
- topAlt: topAlt,
71092
- saturation: saturation
71093
- };
71094
- var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71095
- kdeVals: kdeVals.map(function () {
71096
- return 0;
71097
- }),
71098
- topAlt: !topAlt ? topAlt : baseAlt,
71099
- saturation: 0.5
71100
- });
71101
- // do not interpolate between different length arrays
71102
- currentTargetD.kdeVals.length !== kdeVals.length && (currentTargetD.kdeVals = kdeVals.slice());
71103
- if (Object.keys(targetD).some(function (k) {
71104
- return currentTargetD[k] !== targetD[k];
71105
- })) {
71106
- if (!state.heatmapsTransitionDuration || state.heatmapsTransitionDuration < 0) {
71107
- // set final position
71108
- applyUpdate(targetD);
71109
- } else {
71110
- // animate
71111
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.heatmapsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71112
- }
71120
+ // Set altitudes
71121
+ var rScale = linear([0, maxVal], [GLOBE_RADIUS * (1 + baseAlt), GLOBE_RADIUS * (1 + (topAlt || baseAlt))]);
71122
+ obj.geometry.setAttribute('r', array2BufferAttr(kdeVals.map(rScale)));
71123
+ };
71124
+ var targetD = {
71125
+ kdeVals: kdeVals,
71126
+ topAlt: topAlt,
71127
+ saturation: saturation
71128
+ };
71129
+ var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71130
+ kdeVals: kdeVals.map(function () {
71131
+ return 0;
71132
+ }),
71133
+ topAlt: !topAlt ? topAlt : baseAlt,
71134
+ saturation: 0.5
71135
+ });
71136
+ // do not interpolate between different length arrays
71137
+ currentTargetD.kdeVals.length !== kdeVals.length && (currentTargetD.kdeVals = kdeVals.slice());
71138
+ if (Object.keys(targetD).some(function (k) {
71139
+ return currentTargetD[k] !== targetD[k];
71140
+ })) {
71141
+ if (!state.heatmapsTransitionDuration || state.heatmapsTransitionDuration < 0) {
71142
+ // set final position
71143
+ applyUpdate(targetD);
71144
+ } else {
71145
+ // animate
71146
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.heatmapsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71113
71147
  }
71114
71148
  }
71115
- });
71149
+ }).digest(state.heatmapsData);
71116
71150
  }
71117
71151
  });
71118
71152
 
@@ -71170,6 +71204,33 @@ void main() {
71170
71204
  // Main three object to manipulate
71171
71205
  state.scene = threeObj;
71172
71206
  state.tweenGroup = tweenGroup;
71207
+ state.dataMapper = new ThreeDigest(threeObj, {
71208
+ objBindAttr: '__threeObjPolygon'
71209
+ }).id(function (d) {
71210
+ return d.id;
71211
+ }).onCreateObj(function () {
71212
+ var obj = new THREE$a.Group();
71213
+ obj.__defaultSideMaterial = applyShaderExtensionToMaterial(new THREE$a.MeshBasicMaterial({
71214
+ side: THREE$a.DoubleSide,
71215
+ depthWrite: true
71216
+ }), invisibleUndergroundShaderExtend);
71217
+ obj.__defaultCapMaterial = new THREE$a.MeshBasicMaterial({
71218
+ side: THREE$a.DoubleSide,
71219
+ depthWrite: true
71220
+ });
71221
+
71222
+ // conic geometry
71223
+ obj.add(new THREE$a.Mesh(undefined, [obj.__defaultSideMaterial,
71224
+ // side material
71225
+ obj.__defaultCapMaterial // cap material
71226
+ ]));
71227
+
71228
+ // polygon stroke
71229
+ obj.add(new THREE$a.LineSegments(undefined, new THREE$a.LineBasicMaterial()));
71230
+ obj.__globeObjType = 'polygon'; // Add object type
71231
+
71232
+ return obj;
71233
+ });
71173
71234
  },
71174
71235
  update: function update(state) {
71175
71236
  // Data accessors
@@ -71212,117 +71273,89 @@ void main() {
71212
71273
  console.warn("Unsupported GeoJson geometry type: ".concat(geoJson.type, ". Skipping geometry..."));
71213
71274
  }
71214
71275
  });
71215
- threeDigest(singlePolygons, state.scene, {
71216
- idAccessor: function idAccessor(d) {
71217
- return d.id;
71218
- },
71219
- createObj: function createObj() {
71220
- var obj = new THREE$a.Group();
71221
- obj.__defaultSideMaterial = applyShaderExtensionToMaterial(new THREE$a.MeshBasicMaterial({
71222
- side: THREE$a.DoubleSide,
71223
- depthWrite: true
71224
- }), invisibleUndergroundShaderExtend);
71225
- obj.__defaultCapMaterial = new THREE$a.MeshBasicMaterial({
71226
- side: THREE$a.DoubleSide,
71227
- depthWrite: true
71228
- });
71229
-
71230
- // conic geometry
71231
- obj.add(new THREE$a.Mesh(undefined, [obj.__defaultSideMaterial,
71232
- // side material
71233
- obj.__defaultCapMaterial // cap material
71234
- ]));
71235
-
71236
- // polygon stroke
71237
- obj.add(new THREE$a.LineSegments(undefined, new THREE$a.LineBasicMaterial()));
71238
- obj.__globeObjType = 'polygon'; // Add object type
71239
-
71240
- return obj;
71241
- },
71242
- updateObj: function updateObj(obj, _ref2) {
71243
- var coords = _ref2.coords,
71244
- capColor = _ref2.capColor,
71245
- capMaterial = _ref2.capMaterial,
71246
- sideColor = _ref2.sideColor,
71247
- sideMaterial = _ref2.sideMaterial,
71248
- strokeColor = _ref2.strokeColor,
71249
- altitude = _ref2.altitude,
71250
- capCurvatureResolution = _ref2.capCurvatureResolution;
71251
- var _obj$children = _slicedToArray$1(obj.children, 2),
71252
- conicObj = _obj$children[0],
71253
- strokeObj = _obj$children[1];
71254
-
71255
- // hide stroke if no color set
71256
- var addStroke = !!strokeColor;
71257
- strokeObj.visible = addStroke;
71258
-
71259
- // regenerate geometries if needed
71260
- if (!objMatch(conicObj.geometry.parameters || {}, {
71261
- polygonGeoJson: coords,
71262
- curvatureResolution: capCurvatureResolution
71263
- })) {
71264
- conicObj.geometry && conicObj.geometry.dispose();
71265
- conicObj.geometry = new ConicPolygonBufferGeometry(coords, 0, GLOBE_RADIUS, false, true, true, capCurvatureResolution);
71266
- }
71267
- if (addStroke && (!strokeObj.geometry.parameters || strokeObj.geometry.parameters.geoJson.coordinates !== coords || strokeObj.geometry.parameters.resolution !== capCurvatureResolution)) {
71268
- strokeObj.geometry && strokeObj.geometry.dispose();
71269
- strokeObj.geometry = new GeoJsonGeometry({
71270
- type: 'Polygon',
71271
- coordinates: coords
71272
- }, GLOBE_RADIUS, capCurvatureResolution);
71273
- }
71276
+ state.dataMapper.onUpdateObj(function (obj, _ref2) {
71277
+ var coords = _ref2.coords,
71278
+ capColor = _ref2.capColor,
71279
+ capMaterial = _ref2.capMaterial,
71280
+ sideColor = _ref2.sideColor,
71281
+ sideMaterial = _ref2.sideMaterial,
71282
+ strokeColor = _ref2.strokeColor,
71283
+ altitude = _ref2.altitude,
71284
+ capCurvatureResolution = _ref2.capCurvatureResolution;
71285
+ var _obj$children = _slicedToArray$1(obj.children, 2),
71286
+ conicObj = _obj$children[0],
71287
+ strokeObj = _obj$children[1];
71288
+
71289
+ // hide stroke if no color set
71290
+ var addStroke = !!strokeColor;
71291
+ strokeObj.visible = addStroke;
71292
+
71293
+ // regenerate geometries if needed
71294
+ if (!objMatch(conicObj.geometry.parameters || {}, {
71295
+ polygonGeoJson: coords,
71296
+ curvatureResolution: capCurvatureResolution
71297
+ })) {
71298
+ conicObj.geometry && conicObj.geometry.dispose();
71299
+ conicObj.geometry = new ConicPolygonGeometry(coords, 0, GLOBE_RADIUS, false, true, true, capCurvatureResolution);
71300
+ }
71301
+ if (addStroke && (!strokeObj.geometry.parameters || strokeObj.geometry.parameters.geoJson.coordinates !== coords || strokeObj.geometry.parameters.resolution !== capCurvatureResolution)) {
71302
+ strokeObj.geometry && strokeObj.geometry.dispose();
71303
+ strokeObj.geometry = new GeoJsonGeometry({
71304
+ type: 'Polygon',
71305
+ coordinates: coords
71306
+ }, GLOBE_RADIUS, capCurvatureResolution);
71307
+ }
71274
71308
 
71275
- // replace side/cap materials if defined
71276
- conicObj.material[0] = sideMaterial || obj.__defaultSideMaterial;
71277
- conicObj.material[1] = capMaterial || obj.__defaultCapMaterial;
71309
+ // replace side/cap materials if defined
71310
+ conicObj.material[0] = sideMaterial || obj.__defaultSideMaterial;
71311
+ conicObj.material[1] = capMaterial || obj.__defaultCapMaterial;
71278
71312
 
71279
- // update default material colors
71280
- [!sideMaterial && sideColor, !capMaterial && capColor].forEach(function (color, materialIdx) {
71281
- if (!color) return; // skip custom materials
71313
+ // update default material colors
71314
+ [!sideMaterial && sideColor, !capMaterial && capColor].forEach(function (color, materialIdx) {
71315
+ if (!color) return; // skip custom materials
71282
71316
 
71283
- // conic object
71284
- var material = conicObj.material[materialIdx];
71285
- var opacity = colorAlpha(color);
71286
- material.color.set(colorStr2Hex(color));
71287
- material.transparent = opacity < 1;
71288
- material.opacity = opacity;
71289
- });
71290
- if (addStroke) {
71291
- // stroke object
71292
- var material = strokeObj.material;
71293
- var opacity = colorAlpha(strokeColor);
71294
- material.color.set(colorStr2Hex(strokeColor));
71295
- material.transparent = opacity < 1;
71296
- material.opacity = opacity;
71297
- }
71298
- var targetD = {
71299
- alt: altitude
71300
- };
71301
- var applyUpdate = function applyUpdate(td) {
71302
- var _obj$__currentTargetD = obj.__currentTargetD = td,
71303
- alt = _obj$__currentTargetD.alt;
71304
- conicObj.scale.x = conicObj.scale.y = conicObj.scale.z = 1 + alt;
71305
- addStroke && (strokeObj.scale.x = strokeObj.scale.y = strokeObj.scale.z = 1 + alt + 1e-4); // stroke slightly above the conic mesh
71306
- setExtendedMaterialUniforms(obj.__defaultSideMaterial, function (uniforms) {
71307
- return uniforms.surfaceRadius.value = GLOBE_RADIUS / (alt + 1);
71308
- }); // update side material scale uniform
71309
- };
71310
- var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71311
- alt: -1e-3
71312
- });
71313
- if (Object.keys(targetD).some(function (k) {
71314
- return currentTargetD[k] !== targetD[k];
71315
- })) {
71316
- if (!state.polygonsTransitionDuration || state.polygonsTransitionDuration < 0 || currentTargetD.alt === targetD.alt) {
71317
- // set final position
71318
- applyUpdate(targetD);
71319
- } else {
71320
- // animate
71321
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.polygonsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71322
- }
71317
+ // conic object
71318
+ var material = conicObj.material[materialIdx];
71319
+ var opacity = colorAlpha(color);
71320
+ material.color.set(colorStr2Hex(color));
71321
+ material.transparent = opacity < 1;
71322
+ material.opacity = opacity;
71323
+ });
71324
+ if (addStroke) {
71325
+ // stroke object
71326
+ var material = strokeObj.material;
71327
+ var opacity = colorAlpha(strokeColor);
71328
+ material.color.set(colorStr2Hex(strokeColor));
71329
+ material.transparent = opacity < 1;
71330
+ material.opacity = opacity;
71331
+ }
71332
+ var targetD = {
71333
+ alt: altitude
71334
+ };
71335
+ var applyUpdate = function applyUpdate(td) {
71336
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
71337
+ alt = _obj$__currentTargetD.alt;
71338
+ conicObj.scale.x = conicObj.scale.y = conicObj.scale.z = 1 + alt;
71339
+ addStroke && (strokeObj.scale.x = strokeObj.scale.y = strokeObj.scale.z = 1 + alt + 1e-4); // stroke slightly above the conic mesh
71340
+ setExtendedMaterialUniforms(obj.__defaultSideMaterial, function (uniforms) {
71341
+ return uniforms.surfaceRadius.value = GLOBE_RADIUS / (alt + 1);
71342
+ }); // update side material scale uniform
71343
+ };
71344
+ var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71345
+ alt: -1e-3
71346
+ });
71347
+ if (Object.keys(targetD).some(function (k) {
71348
+ return currentTargetD[k] !== targetD[k];
71349
+ })) {
71350
+ if (!state.polygonsTransitionDuration || state.polygonsTransitionDuration < 0 || currentTargetD.alt === targetD.alt) {
71351
+ // set final position
71352
+ applyUpdate(targetD);
71353
+ } else {
71354
+ // animate
71355
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.polygonsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71323
71356
  }
71324
71357
  }
71325
- });
71358
+ }).digest(singlePolygons);
71326
71359
  }
71327
71360
  });
71328
71361
  function objMatch(obj, attrs) {
@@ -71342,6 +71375,7 @@ void main() {
71342
71375
  var THREE$9 = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
71343
71376
  : {
71344
71377
  BufferGeometry: BufferGeometry,
71378
+ CircleGeometry: CircleGeometry,
71345
71379
  DoubleSide: DoubleSide,
71346
71380
  Mesh: Mesh,
71347
71381
  MeshLambertMaterial: MeshLambertMaterial,
@@ -71402,6 +71436,16 @@ void main() {
71402
71436
  // Main three object to manipulate
71403
71437
  state.scene = threeObj;
71404
71438
  state.tweenGroup = tweenGroup;
71439
+ state.dataMapper = new ThreeDigest(threeObj, {
71440
+ objBindAttr: '__threeObjHexPolygon'
71441
+ }).onCreateObj(function () {
71442
+ var obj = new THREE$9.Mesh(undefined, new THREE$9.MeshLambertMaterial({
71443
+ side: THREE$9.DoubleSide
71444
+ }));
71445
+ obj.__globeObjType = 'hexPolygon'; // Add object type
71446
+
71447
+ return obj;
71448
+ });
71405
71449
  },
71406
71450
  update: function update(state) {
71407
71451
  // Accessors
@@ -71413,132 +71457,122 @@ void main() {
71413
71457
  var useDotsAccessor = index$1(state.hexPolygonUseDots);
71414
71458
  var curvatureResolutionAccessor = index$1(state.hexPolygonCurvatureResolution);
71415
71459
  var dotResolutionAccessor = index$1(state.hexPolygonDotResolution);
71416
- threeDigest(state.hexPolygonsData, state.scene, {
71417
- createObj: function createObj(d) {
71418
- var obj = new THREE$9.Mesh(undefined, new THREE$9.MeshLambertMaterial({
71419
- side: THREE$9.DoubleSide
71420
- }));
71421
- obj.__globeObjType = 'hexPolygon'; // Add object type
71422
-
71423
- return obj;
71424
- },
71425
- updateObj: function updateObj(obj, d) {
71426
- var geoJson = geoJsonAccessor(d);
71427
- var h3Res = resolutionAccessor(d);
71428
- var alt = altitudeAccessor(d);
71429
- var margin = Math.max(0, Math.min(1, +marginAccessor(d)));
71430
- var useDots = useDotsAccessor(d);
71431
- var curvatureResolution = curvatureResolutionAccessor(d);
71432
- var dotResolution = dotResolutionAccessor(d);
71433
-
71434
- // update material
71435
- var color = colorAccessor(d);
71436
- var opacity = colorAlpha(color);
71437
- obj.material.color.set(colorStr2Hex(color));
71438
- obj.material.transparent = opacity < 1;
71439
- obj.material.opacity = opacity;
71440
- var targetD = {
71441
- alt: alt,
71442
- margin: margin,
71443
- curvatureResolution: curvatureResolution
71444
- };
71445
- var memD = {
71446
- geoJson: geoJson,
71447
- h3Res: h3Res
71448
- };
71449
- var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71450
- alt: -1e-3
71451
- });
71452
- var currentMemD = obj.__currentMemD || memD;
71453
- if (Object.keys(targetD).some(function (k) {
71454
- return currentTargetD[k] !== targetD[k];
71455
- }) || Object.keys(memD).some(function (k) {
71456
- return currentMemD[k] !== memD[k];
71457
- })) {
71458
- obj.__currentMemD = memD;
71459
- var h3Idxs = [];
71460
- if (geoJson.type === 'Polygon') {
71461
- polygonToCells(geoJson.coordinates, h3Res, true).forEach(function (idx) {
71460
+ state.dataMapper.onUpdateObj(function (obj, d) {
71461
+ var geoJson = geoJsonAccessor(d);
71462
+ var h3Res = resolutionAccessor(d);
71463
+ var alt = altitudeAccessor(d);
71464
+ var margin = Math.max(0, Math.min(1, +marginAccessor(d)));
71465
+ var useDots = useDotsAccessor(d);
71466
+ var curvatureResolution = curvatureResolutionAccessor(d);
71467
+ var dotResolution = dotResolutionAccessor(d);
71468
+
71469
+ // update material
71470
+ var color = colorAccessor(d);
71471
+ var opacity = colorAlpha(color);
71472
+ obj.material.color.set(colorStr2Hex(color));
71473
+ obj.material.transparent = opacity < 1;
71474
+ obj.material.opacity = opacity;
71475
+ var targetD = {
71476
+ alt: alt,
71477
+ margin: margin,
71478
+ curvatureResolution: curvatureResolution
71479
+ };
71480
+ var memD = {
71481
+ geoJson: geoJson,
71482
+ h3Res: h3Res
71483
+ };
71484
+ var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
71485
+ alt: -1e-3
71486
+ });
71487
+ var currentMemD = obj.__currentMemD || memD;
71488
+ if (Object.keys(targetD).some(function (k) {
71489
+ return currentTargetD[k] !== targetD[k];
71490
+ }) || Object.keys(memD).some(function (k) {
71491
+ return currentMemD[k] !== memD[k];
71492
+ })) {
71493
+ obj.__currentMemD = memD;
71494
+ var h3Idxs = [];
71495
+ if (geoJson.type === 'Polygon') {
71496
+ polygonToCells(geoJson.coordinates, h3Res, true).forEach(function (idx) {
71497
+ return h3Idxs.push(idx);
71498
+ });
71499
+ } else if (geoJson.type === 'MultiPolygon') {
71500
+ geoJson.coordinates.forEach(function (coords) {
71501
+ return polygonToCells(coords, h3Res, true).forEach(function (idx) {
71462
71502
  return h3Idxs.push(idx);
71463
71503
  });
71464
- } else if (geoJson.type === 'MultiPolygon') {
71465
- geoJson.coordinates.forEach(function (coords) {
71466
- return polygonToCells(coords, h3Res, true).forEach(function (idx) {
71467
- return h3Idxs.push(idx);
71468
- });
71469
- });
71470
- } else {
71471
- console.warn("Unsupported GeoJson geometry type: ".concat(geoJson.type, ". Skipping geometry..."));
71472
- }
71473
- var hexBins = h3Idxs.map(function (h3Idx) {
71474
- var hexCenter = cellToLatLng(h3Idx);
71475
- var hexGeoJson = cellToBoundary(h3Idx, true).reverse(); // correct polygon winding
71476
-
71477
- // stitch longitudes at the anti-meridian
71478
- var centerLng = hexCenter[1];
71479
- hexGeoJson.forEach(function (d) {
71480
- var edgeLng = d[0];
71481
- if (Math.abs(centerLng - edgeLng) > 170) {
71482
- // normalize large lng distances
71483
- d[0] += centerLng > edgeLng ? 360 : -360;
71484
- }
71485
- });
71486
- return {
71487
- h3Idx: h3Idx,
71488
- hexCenter: hexCenter,
71489
- hexGeoJson: hexGeoJson
71490
- };
71491
71504
  });
71492
- var applyUpdate = function applyUpdate(td) {
71493
- var _obj$__currentTargetD = obj.__currentTargetD = td,
71494
- alt = _obj$__currentTargetD.alt,
71495
- margin = _obj$__currentTargetD.margin,
71496
- curvatureResolution = _obj$__currentTargetD.curvatureResolution;
71497
- obj.geometry && obj.geometry.dispose();
71498
- obj.geometry = !hexBins.length ? new THREE$9.BufferGeometry() : (BufferGeometryUtils.mergeGeometries || BufferGeometryUtils.mergeBufferGeometries)(hexBins.map(function (h) {
71499
- var _h$hexCenter = _slicedToArray$1(h.hexCenter, 2),
71500
- clat = _h$hexCenter[0],
71501
- clng = _h$hexCenter[1];
71502
- if (useDots) {
71503
- var centerPos = polar2Cartesian(clat, clng, alt);
71504
- var edgePos = polar2Cartesian(h.hexGeoJson[0][1], h.hexGeoJson[0][0], alt);
71505
- var r = 0.85 * (1 - margin) * new THREE$9.Vector3(centerPos.x, centerPos.y, centerPos.z).distanceTo(new THREE$9.Vector3(edgePos.x, edgePos.y, edgePos.z));
71506
- var geometry = new CircleGeometry(r, dotResolution);
71507
- geometry.rotateX(deg2Rad$1(-clat));
71508
- geometry.rotateY(deg2Rad$1(clng));
71509
- geometry.translate(centerPos.x, centerPos.y, centerPos.z);
71510
- return geometry;
71511
- } else {
71512
- var relNum = function relNum(st, end, rat) {
71513
- return st - (st - end) * rat;
71514
- };
71515
-
71516
- // compute new geojson with relative margin
71517
- var _geoJson = margin === 0 ? h.hexGeoJson : h.hexGeoJson.map(function (_ref2) {
71518
- var _ref3 = _slicedToArray$1(_ref2, 2),
71519
- elng = _ref3[0],
71520
- elat = _ref3[1];
71521
- return [[elng, clng], [elat, clat]].map(function (_ref4) {
71522
- var _ref5 = _slicedToArray$1(_ref4, 2),
71523
- st = _ref5[0],
71524
- end = _ref5[1];
71525
- return relNum(st, end, margin);
71526
- });
71527
- });
71528
- return new ConicPolygonBufferGeometry([_geoJson], GLOBE_RADIUS, GLOBE_RADIUS * (1 + alt), false, true, false, curvatureResolution);
71529
- }
71530
- }));
71505
+ } else {
71506
+ console.warn("Unsupported GeoJson geometry type: ".concat(geoJson.type, ". Skipping geometry..."));
71507
+ }
71508
+ var hexBins = h3Idxs.map(function (h3Idx) {
71509
+ var hexCenter = cellToLatLng(h3Idx);
71510
+ var hexGeoJson = cellToBoundary(h3Idx, true).reverse(); // correct polygon winding
71511
+
71512
+ // stitch longitudes at the anti-meridian
71513
+ var centerLng = hexCenter[1];
71514
+ hexGeoJson.forEach(function (d) {
71515
+ var edgeLng = d[0];
71516
+ if (Math.abs(centerLng - edgeLng) > 170) {
71517
+ // normalize large lng distances
71518
+ d[0] += centerLng > edgeLng ? 360 : -360;
71519
+ }
71520
+ });
71521
+ return {
71522
+ h3Idx: h3Idx,
71523
+ hexCenter: hexCenter,
71524
+ hexGeoJson: hexGeoJson
71531
71525
  };
71532
- if (!state.hexPolygonsTransitionDuration || state.hexPolygonsTransitionDuration < 0) {
71533
- // set final position
71534
- applyUpdate(targetD);
71535
- } else {
71536
- // animate
71537
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.hexPolygonsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71538
- }
71526
+ });
71527
+ var applyUpdate = function applyUpdate(td) {
71528
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
71529
+ alt = _obj$__currentTargetD.alt,
71530
+ margin = _obj$__currentTargetD.margin,
71531
+ curvatureResolution = _obj$__currentTargetD.curvatureResolution;
71532
+ obj.geometry && obj.geometry.dispose();
71533
+ obj.geometry = !hexBins.length ? new THREE$9.BufferGeometry() : (BufferGeometryUtils.mergeGeometries || BufferGeometryUtils.mergeBufferGeometries)(hexBins.map(function (h) {
71534
+ var _h$hexCenter = _slicedToArray$1(h.hexCenter, 2),
71535
+ clat = _h$hexCenter[0],
71536
+ clng = _h$hexCenter[1];
71537
+ if (useDots) {
71538
+ var centerPos = polar2Cartesian(clat, clng, alt);
71539
+ var edgePos = polar2Cartesian(h.hexGeoJson[0][1], h.hexGeoJson[0][0], alt);
71540
+ var r = 0.85 * (1 - margin) * new THREE$9.Vector3(centerPos.x, centerPos.y, centerPos.z).distanceTo(new THREE$9.Vector3(edgePos.x, edgePos.y, edgePos.z));
71541
+ var geometry = new CircleGeometry(r, dotResolution);
71542
+ geometry.rotateX(deg2Rad$1(-clat));
71543
+ geometry.rotateY(deg2Rad$1(clng));
71544
+ geometry.translate(centerPos.x, centerPos.y, centerPos.z);
71545
+ return geometry;
71546
+ } else {
71547
+ var relNum = function relNum(st, end, rat) {
71548
+ return st - (st - end) * rat;
71549
+ };
71550
+
71551
+ // compute new geojson with relative margin
71552
+ var _geoJson = margin === 0 ? h.hexGeoJson : h.hexGeoJson.map(function (_ref2) {
71553
+ var _ref3 = _slicedToArray$1(_ref2, 2),
71554
+ elng = _ref3[0],
71555
+ elat = _ref3[1];
71556
+ return [[elng, clng], [elat, clat]].map(function (_ref4) {
71557
+ var _ref5 = _slicedToArray$1(_ref4, 2),
71558
+ st = _ref5[0],
71559
+ end = _ref5[1];
71560
+ return relNum(st, end, margin);
71561
+ });
71562
+ });
71563
+ return new ConicPolygonGeometry([_geoJson], GLOBE_RADIUS, GLOBE_RADIUS * (1 + alt), false, true, false, curvatureResolution);
71564
+ }
71565
+ }));
71566
+ };
71567
+ if (!state.hexPolygonsTransitionDuration || state.hexPolygonsTransitionDuration < 0) {
71568
+ // set final position
71569
+ applyUpdate(targetD);
71570
+ } else {
71571
+ // animate
71572
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.hexPolygonsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71539
71573
  }
71540
71574
  }
71541
- });
71575
+ }).digest(state.hexPolygonsData);
71542
71576
  }
71543
71577
  });
71544
71578
 
@@ -71657,22 +71691,42 @@ void main() {
71657
71691
  (_state$ticker3 = state.ticker) === null || _state$ticker3 === void 0 || _state$ticker3.dispose();
71658
71692
  }
71659
71693
  },
71660
- init: function init(threeObj, state, _ref) {
71694
+ stateInit: function stateInit(_ref) {
71661
71695
  var tweenGroup = _ref.tweenGroup;
71696
+ return {
71697
+ tweenGroup: tweenGroup,
71698
+ ticker: new FrameTicker$1(),
71699
+ sharedMaterial: new THREE$7.ShaderMaterial(_objectSpread2(_objectSpread2({}, dashedLineShaders()), {}, {
71700
+ transparent: true,
71701
+ blending: THREE$7.NormalBlending
71702
+ }))
71703
+ };
71704
+ },
71705
+ init: function init(threeObj, state) {
71662
71706
  // Clear the scene
71663
71707
  emptyObject(threeObj);
71664
71708
 
71665
71709
  // Main three object to manipulate
71666
71710
  state.scene = threeObj;
71667
- state.tweenGroup = tweenGroup;
71711
+ state.dataMapper = new ThreeDigest(threeObj, {
71712
+ objBindAttr: '__threeObjPath'
71713
+ }).onCreateObj(function () {
71714
+ var obj = new THREE$7.Group(); // populated in updateObj
71715
+
71716
+ obj.__globeObjType = 'path'; // Add object type
71717
+ return obj;
71718
+ });
71668
71719
 
71669
71720
  // Kick-off dash animations
71670
- state.ticker = new FrameTicker$1();
71671
71721
  state.ticker.onTick.add(function (_, timeDelta) {
71672
- state.pathsData.filter(function (d) {
71673
- return d.__threeObj && d.__threeObj.children.length && d.__threeObj.children[0].material && d.__threeObj.children[0].__dashAnimateStep;
71674
- }).forEach(function (d) {
71675
- var obj = d.__threeObj.children[0];
71722
+ state.dataMapper.entries().map(function (_ref2) {
71723
+ var _ref3 = _slicedToArray$1(_ref2, 2),
71724
+ obj = _ref3[1];
71725
+ return obj;
71726
+ }).filter(function (o) {
71727
+ return o.children.length && o.children[0].material && o.children[0].__dashAnimateStep;
71728
+ }).forEach(function (o) {
71729
+ var obj = o.children[0];
71676
71730
  var step = obj.__dashAnimateStep * timeDelta;
71677
71731
  if (obj.type === 'Line') {
71678
71732
  var curTranslate = obj.material.uniforms.dashTranslate.value % 1e9; // reset after 1B loops
@@ -71699,154 +71753,142 @@ void main() {
71699
71753
  var dashGapAccessor = index$1(state.pathDashGap);
71700
71754
  var dashInitialGapAccessor = index$1(state.pathDashInitialGap);
71701
71755
  var dashAnimateTimeAccessor = index$1(state.pathDashAnimateTime);
71702
- var sharedShaderMaterial = new THREE$7.ShaderMaterial(_objectSpread2(_objectSpread2({}, dashedLineShaders()), {}, {
71703
- transparent: true,
71704
- blending: THREE$7.NormalBlending
71705
- }));
71706
- threeDigest(state.pathsData, state.scene, {
71707
- createObj: function createObj() {
71708
- var obj = new THREE$7.Group(); // populated in updateObj
71756
+ state.dataMapper.onUpdateObj(function (group, path) {
71757
+ var stroke = strokeAccessor(path);
71758
+ var useFatLine = stroke !== null && stroke !== undefined;
71759
+ if (!group.children.length || useFatLine === (group.children[0].type === 'Line')) {
71760
+ // create or swap object types
71761
+ emptyObject(group);
71762
+ var _obj = useFatLine ? new Line2(new LineGeometry(), new LineMaterial()) : new THREE$7.Line(new THREE$7.BufferGeometry(), state.sharedMaterial.clone() // Separate material instance per object to have dedicated uniforms (but shared shaders)
71763
+ );
71764
+ group.add(_obj);
71765
+ }
71766
+ var obj = group.children[0];
71767
+ var points = calcPath(pointsAccessor(path), pointLatAccessor, pointLngAccessor, pointAltAccessor, state.pathResolution);
71709
71768
 
71710
- obj.__globeObjType = 'path'; // Add object type
71711
- return obj;
71712
- },
71713
- updateObj: function updateObj(group, path) {
71714
- var stroke = strokeAccessor(path);
71715
- var useFatLine = stroke !== null && stroke !== undefined;
71716
- if (!group.children.length || useFatLine === (group.children[0].type === 'Line')) {
71717
- // create or swap object types
71718
- emptyObject(group);
71719
- var _obj = useFatLine ? new Line2(new LineGeometry(), new LineMaterial()) : new THREE$7.Line(new THREE$7.BufferGeometry(), sharedShaderMaterial.clone() // Separate material instance per object to have dedicated uniforms (but shared shaders)
71720
- );
71721
- group.add(_obj);
71722
- }
71723
- var obj = group.children[0];
71724
- var points = calcPath(pointsAccessor(path), pointLatAccessor, pointLngAccessor, pointAltAccessor, state.pathResolution);
71725
-
71726
- // set dash animation step
71727
- var dashAnimateTime = dashAnimateTimeAccessor(path);
71728
- obj.__dashAnimateStep = dashAnimateTime > 0 ? 1000 / dashAnimateTime : 0; // per second
71729
-
71730
- if (!useFatLine) {
71731
- // set dash uniforms
71732
- Object.assign(obj.material.uniforms, {
71733
- dashSize: {
71734
- value: dashLengthAccessor(path)
71735
- },
71736
- gapSize: {
71737
- value: dashGapAccessor(path)
71738
- },
71739
- dashOffset: {
71740
- value: dashInitialGapAccessor(path)
71741
- }
71742
- });
71769
+ // set dash animation step
71770
+ var dashAnimateTime = dashAnimateTimeAccessor(path);
71771
+ obj.__dashAnimateStep = dashAnimateTime > 0 ? 1000 / dashAnimateTime : 0; // per second
71743
71772
 
71744
- // calculate vertex colors (to create gradient)
71745
- var vertexColorArray = calcColorVertexArray(colorAccessor(path),
71746
- // single, array of colors or interpolator
71747
- points.length // numSegments
71748
- );
71749
-
71750
- // calculate vertex relative distances (for dashed lines)
71751
- var vertexRelDistanceArray = calcVertexRelDistances(points.length,
71752
- // numSegments
71753
- 1,
71754
- // num vertices per segment
71755
- true // run from end to start, to animate in the correct direction
71756
- );
71757
- obj.geometry.setAttribute('color', vertexColorArray);
71758
- obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
71759
- } else {
71760
- // fat lines
71761
- obj.material.resolution = state.rendererSize;
71762
- {
71763
- // set dash styling
71764
- var dashLength = dashLengthAccessor(path);
71765
- var dashGap = dashGapAccessor(path);
71766
- var dashInitialGap = dashInitialGapAccessor(path);
71767
- obj.material.dashed = dashGap > 0;
71768
-
71769
- // temp hack to activate line dashes
71770
- obj.material.dashed ? obj.material.defines.USE_DASH = "" : delete obj.material.defines.USE_DASH;
71771
- if (obj.material.dashed) {
71772
- obj.material.dashScale = 1 / calcLineDistance(points); // dash sizes relative to full line length
71773
-
71774
- obj.material.dashSize = dashLength;
71775
- obj.material.gapSize = dashGap;
71776
- obj.material.dashOffset = -dashInitialGap;
71777
- }
71778
- }
71779
- {
71780
- // set line colors
71781
- var colors = colorAccessor(path);
71782
- if (colors instanceof Array) {
71783
- // calculate vertex colors (to create gradient)
71784
- var _vertexColorArray = calcColorVertexArray(colorAccessor(path),
71785
- // single, array of colors or interpolator
71786
- points.length - 1,
71787
- // numSegments
71788
- 1,
71789
- // num vertices per segment
71790
- false);
71791
- obj.geometry.setColors(_vertexColorArray.array);
71792
- obj.material.vertexColors = true;
71793
- } else {
71794
- // single color
71795
- var color = colors;
71796
- var opacity = colorAlpha(color);
71797
- obj.material.color = new THREE$7.Color(colorStr2Hex(color));
71798
- obj.material.transparent = opacity < 1;
71799
- obj.material.opacity = opacity;
71800
- obj.material.vertexColors = false;
71801
- }
71773
+ if (!useFatLine) {
71774
+ // set dash uniforms
71775
+ Object.assign(obj.material.uniforms, {
71776
+ dashSize: {
71777
+ value: dashLengthAccessor(path)
71778
+ },
71779
+ gapSize: {
71780
+ value: dashGapAccessor(path)
71781
+ },
71782
+ dashOffset: {
71783
+ value: dashInitialGapAccessor(path)
71802
71784
  }
71803
- obj.material.needsUpdate = true;
71804
- }
71785
+ });
71805
71786
 
71806
- // animate from start to finish by default
71807
- var pointsInterpolator = interpolateVectors(path.__currentTargetD && path.__currentTargetD.points || [points[0]], points);
71808
- var applyUpdate = function applyUpdate(td) {
71809
- var _path$__currentTarget = path.__currentTargetD = td,
71810
- stroke = _path$__currentTarget.stroke,
71811
- interpolK = _path$__currentTarget.interpolK;
71812
- var kPoints = path.__currentTargetD.points = pointsInterpolator(interpolK);
71813
- if (useFatLine) {
71814
- var _ref2;
71815
- obj.geometry.setPositions((_ref2 = []).concat.apply(_ref2, _toConsumableArray$1(kPoints.map(function (_ref3) {
71816
- var x = _ref3.x,
71817
- y = _ref3.y,
71818
- z = _ref3.z;
71819
- return [x, y, z];
71820
- }))));
71821
- obj.material.linewidth = stroke;
71822
-
71823
- // necessary for dashed lines
71824
- obj.material.dashed && obj.computeLineDistances();
71825
- } else {
71826
- obj.geometry.setFromPoints(kPoints);
71827
- obj.geometry.computeBoundingSphere();
71787
+ // calculate vertex colors (to create gradient)
71788
+ var vertexColorArray = calcColorVertexArray(colorAccessor(path),
71789
+ // single, array of colors or interpolator
71790
+ points.length // numSegments
71791
+ );
71792
+
71793
+ // calculate vertex relative distances (for dashed lines)
71794
+ var vertexRelDistanceArray = calcVertexRelDistances(points.length,
71795
+ // numSegments
71796
+ 1,
71797
+ // num vertices per segment
71798
+ true // run from end to start, to animate in the correct direction
71799
+ );
71800
+ obj.geometry.setAttribute('color', vertexColorArray);
71801
+ obj.geometry.setAttribute('relDistance', vertexRelDistanceArray);
71802
+ } else {
71803
+ // fat lines
71804
+ obj.material.resolution = state.rendererSize;
71805
+ {
71806
+ // set dash styling
71807
+ var dashLength = dashLengthAccessor(path);
71808
+ var dashGap = dashGapAccessor(path);
71809
+ var dashInitialGap = dashInitialGapAccessor(path);
71810
+ obj.material.dashed = dashGap > 0;
71811
+
71812
+ // temp hack to activate line dashes
71813
+ obj.material.dashed ? obj.material.defines.USE_DASH = "" : delete obj.material.defines.USE_DASH;
71814
+ if (obj.material.dashed) {
71815
+ obj.material.dashScale = 1 / calcLineDistance(points); // dash sizes relative to full line length
71816
+
71817
+ obj.material.dashSize = dashLength;
71818
+ obj.material.gapSize = dashGap;
71819
+ obj.material.dashOffset = -dashInitialGap;
71828
71820
  }
71829
- };
71830
- var targetD = {
71831
- stroke: stroke,
71832
- interpolK: 1
71833
- };
71834
- var currentTargetD = Object.assign({}, path.__currentTargetD || targetD, {
71835
- interpolK: 0
71836
- });
71837
- if (Object.keys(targetD).some(function (k) {
71838
- return currentTargetD[k] !== targetD[k];
71839
- })) {
71840
- if (!state.pathTransitionDuration || state.pathTransitionDuration < 0) {
71841
- // set final position
71842
- applyUpdate(targetD);
71821
+ }
71822
+ {
71823
+ // set line colors
71824
+ var colors = colorAccessor(path);
71825
+ if (colors instanceof Array) {
71826
+ // calculate vertex colors (to create gradient)
71827
+ var _vertexColorArray = calcColorVertexArray(colorAccessor(path),
71828
+ // single, array of colors or interpolator
71829
+ points.length - 1,
71830
+ // numSegments
71831
+ 1,
71832
+ // num vertices per segment
71833
+ false);
71834
+ obj.geometry.setColors(_vertexColorArray.array);
71835
+ obj.material.vertexColors = true;
71843
71836
  } else {
71844
- // animate
71845
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.pathTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71837
+ // single color
71838
+ var color = colors;
71839
+ var opacity = colorAlpha(color);
71840
+ obj.material.color = new THREE$7.Color(colorStr2Hex(color));
71841
+ obj.material.transparent = opacity < 1;
71842
+ obj.material.opacity = opacity;
71843
+ obj.material.vertexColors = false;
71846
71844
  }
71847
71845
  }
71846
+ obj.material.needsUpdate = true;
71848
71847
  }
71849
- });
71848
+
71849
+ // animate from start to finish by default
71850
+ var pointsInterpolator = interpolateVectors(group.__currentTargetD && group.__currentTargetD.points || [points[0]], points);
71851
+ var applyUpdate = function applyUpdate(td) {
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);
71856
+ if (useFatLine) {
71857
+ var _ref4;
71858
+ obj.geometry.setPositions((_ref4 = []).concat.apply(_ref4, _toConsumableArray$1(kPoints.map(function (_ref5) {
71859
+ var x = _ref5.x,
71860
+ y = _ref5.y,
71861
+ z = _ref5.z;
71862
+ return [x, y, z];
71863
+ }))));
71864
+ obj.material.linewidth = stroke;
71865
+
71866
+ // necessary for dashed lines
71867
+ obj.material.dashed && obj.computeLineDistances();
71868
+ } else {
71869
+ obj.geometry.setFromPoints(kPoints);
71870
+ obj.geometry.computeBoundingSphere();
71871
+ }
71872
+ };
71873
+ var targetD = {
71874
+ stroke: stroke,
71875
+ interpolK: 1
71876
+ };
71877
+ var currentTargetD = Object.assign({}, group.__currentTargetD || targetD, {
71878
+ interpolK: 0
71879
+ });
71880
+ if (Object.keys(targetD).some(function (k) {
71881
+ return currentTargetD[k] !== targetD[k];
71882
+ })) {
71883
+ if (!state.pathTransitionDuration || state.pathTransitionDuration < 0) {
71884
+ // set final position
71885
+ applyUpdate(targetD);
71886
+ } else {
71887
+ // animate
71888
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.pathTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
71889
+ }
71890
+ }
71891
+ }).digest(state.pathsData);
71850
71892
 
71851
71893
  //
71852
71894
 
@@ -71891,11 +71933,11 @@ void main() {
71891
71933
  });
71892
71934
  return result;
71893
71935
  };
71894
- var getVec = function getVec(_ref4) {
71895
- var _ref5 = _slicedToArray$1(_ref4, 3),
71896
- lat = _ref5[0],
71897
- lng = _ref5[1],
71898
- alt = _ref5[2];
71936
+ var getVec = function getVec(_ref6) {
71937
+ var _ref7 = _slicedToArray$1(_ref6, 3),
71938
+ lat = _ref7[0],
71939
+ lng = _ref7[1],
71940
+ alt = _ref7[2];
71899
71941
  var _polar2Cartesian = polar2Cartesian(lat, lng, alt),
71900
71942
  x = _polar2Cartesian.x,
71901
71943
  y = _polar2Cartesian.y,
@@ -72020,6 +72062,14 @@ void main() {
72020
72062
  // Main three object to manipulate
72021
72063
  state.scene = threeObj;
72022
72064
  state.tweenGroup = tweenGroup;
72065
+ state.dataMapper = new ThreeDigest(threeObj, {
72066
+ objBindAttr: '__threeObjTile'
72067
+ }).onCreateObj(function () {
72068
+ var obj = new THREE$6.Mesh();
72069
+ obj.__globeObjType = 'tile'; // Add object type
72070
+
72071
+ return obj;
72072
+ });
72023
72073
  },
72024
72074
  update: function update(state) {
72025
72075
  // Data accessors
@@ -72031,60 +72081,52 @@ void main() {
72031
72081
  var useGlobeProjectionAccessor = index$1(state.tileUseGlobeProjection);
72032
72082
  var materialAccessor = index$1(state.tileMaterial);
72033
72083
  var curvatureResolutionAccessor = index$1(state.tileCurvatureResolution);
72034
- threeDigest(state.tilesData, state.scene, {
72035
- createObj: function createObj() {
72036
- var obj = new THREE$6.Mesh();
72037
- obj.__globeObjType = 'tile'; // Add object type
72038
-
72039
- return obj;
72040
- },
72041
- updateObj: function updateObj(obj, d) {
72042
- obj.material = materialAccessor(d); // set material
72084
+ state.dataMapper.onUpdateObj(function (obj, d) {
72085
+ obj.material = materialAccessor(d); // set material
72043
72086
 
72044
- var useGlobeProjection = useGlobeProjectionAccessor(d);
72045
- var curvatureResolution = curvatureResolutionAccessor(d);
72087
+ var useGlobeProjection = useGlobeProjectionAccessor(d);
72088
+ var curvatureResolution = curvatureResolutionAccessor(d);
72046
72089
 
72047
- // animations
72048
- var applyPosition = function applyPosition(td) {
72049
- var _obj$__currentTargetD = obj.__currentTargetD = td,
72050
- lat = _obj$__currentTargetD.lat,
72051
- lng = _obj$__currentTargetD.lng,
72052
- alt = _obj$__currentTargetD.alt,
72053
- width = _obj$__currentTargetD.width,
72054
- height = _obj$__currentTargetD.height;
72055
- var rotLng = deg2Rad(lng);
72056
- var rotLat = deg2Rad(-lat);
72057
- obj.geometry && obj.geometry.dispose();
72058
- obj.geometry = new THREE$6.SphereGeometry(GLOBE_RADIUS * (1 + alt), Math.ceil(width / (curvatureResolution || -1)), Math.ceil(height / (curvatureResolution || -1)), deg2Rad(90 - width / 2) + (useGlobeProjection ? rotLng : 0), deg2Rad(width), deg2Rad(90 - height / 2) + (useGlobeProjection ? rotLat : 0), deg2Rad(height));
72059
- if (!useGlobeProjection) {
72060
- // rotate obj instead. order matters, rotate longitudinally first.
72061
- obj.setRotationFromEuler(new THREE$6.Euler(rotLat, rotLng, 0, 'YXZ'));
72062
- }
72063
- };
72064
- var targetD = {
72065
- lat: +latAccessor(d),
72066
- lng: +lngAccessor(d),
72067
- alt: +altitudeAccessor(d),
72068
- width: +widthAccessor(d),
72069
- height: +heightAccessor(d)
72070
- };
72071
- var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
72072
- width: 0,
72073
- height: 0
72074
- });
72075
- if (Object.keys(targetD).some(function (k) {
72076
- return currentTargetD[k] !== targetD[k];
72077
- })) {
72078
- if (!state.tilesTransitionDuration || state.tilesTransitionDuration < 0) {
72079
- // set final position
72080
- applyPosition(targetD);
72081
- } else {
72082
- // animate
72083
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.tilesTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyPosition).start());
72084
- }
72090
+ // animations
72091
+ var applyPosition = function applyPosition(td) {
72092
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
72093
+ lat = _obj$__currentTargetD.lat,
72094
+ lng = _obj$__currentTargetD.lng,
72095
+ alt = _obj$__currentTargetD.alt,
72096
+ width = _obj$__currentTargetD.width,
72097
+ height = _obj$__currentTargetD.height;
72098
+ var rotLng = deg2Rad(lng);
72099
+ var rotLat = deg2Rad(-lat);
72100
+ obj.geometry && obj.geometry.dispose();
72101
+ obj.geometry = new THREE$6.SphereGeometry(GLOBE_RADIUS * (1 + alt), Math.ceil(width / (curvatureResolution || -1)), Math.ceil(height / (curvatureResolution || -1)), deg2Rad(90 - width / 2) + (useGlobeProjection ? rotLng : 0), deg2Rad(width), deg2Rad(90 - height / 2) + (useGlobeProjection ? rotLat : 0), deg2Rad(height));
72102
+ if (!useGlobeProjection) {
72103
+ // rotate obj instead. order matters, rotate longitudinally first.
72104
+ obj.setRotationFromEuler(new THREE$6.Euler(rotLat, rotLng, 0, 'YXZ'));
72105
+ }
72106
+ };
72107
+ var targetD = {
72108
+ lat: +latAccessor(d),
72109
+ lng: +lngAccessor(d),
72110
+ alt: +altitudeAccessor(d),
72111
+ width: +widthAccessor(d),
72112
+ height: +heightAccessor(d)
72113
+ };
72114
+ var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
72115
+ width: 0,
72116
+ height: 0
72117
+ });
72118
+ if (Object.keys(targetD).some(function (k) {
72119
+ return currentTargetD[k] !== targetD[k];
72120
+ })) {
72121
+ if (!state.tilesTransitionDuration || state.tilesTransitionDuration < 0) {
72122
+ // set final position
72123
+ applyPosition(targetD);
72124
+ } else {
72125
+ // animate
72126
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.tilesTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyPosition).start());
72085
72127
  }
72086
72128
  }
72087
- });
72129
+ }).digest(state.tilesData);
72088
72130
  }
72089
72131
  });
72090
72132
  var deg2Rad = function deg2Rad(deg) {
@@ -72177,6 +72219,26 @@ void main() {
72177
72219
  // Main three object to manipulate
72178
72220
  state.scene = threeObj;
72179
72221
  state.tweenGroup = tweenGroup;
72222
+ var circleGeometry = new THREE$5.CircleGeometry(1, 32);
72223
+ state.dataMapper = new ThreeDigest(threeObj, {
72224
+ objBindAttr: '__threeObjLabel'
72225
+ }).onCreateObj(function () {
72226
+ var material = new THREE$5.MeshLambertMaterial();
72227
+ material.side = DoubleSide;
72228
+ var obj = new THREE$5.Group(); // container
72229
+
72230
+ obj.add(new THREE$5.Mesh(circleGeometry, material)); // dot
72231
+ var textObj = new THREE$5.Mesh(undefined, material);
72232
+ obj.add(textObj); // text
72233
+
72234
+ // text invisible bounding box (raycaster trap)
72235
+ var bbObj = new THREE$5.Mesh();
72236
+ bbObj.visible = false;
72237
+ textObj.add(bbObj);
72238
+ obj.__globeObjType = 'label'; // Add object type
72239
+
72240
+ return obj;
72241
+ });
72180
72242
  },
72181
72243
  update: function update(state) {
72182
72244
  // Data accessors
@@ -72192,123 +72254,103 @@ void main() {
72192
72254
  var dotOrientationAccessor = index$1(state.labelDotOrientation);
72193
72255
  var orientations = new Set(['right', 'top', 'bottom']);
72194
72256
  var pxPerDeg = 2 * Math.PI * GLOBE_RADIUS / 360;
72195
- var circleGeometry = new THREE$5.CircleGeometry(1, 32);
72196
- threeDigest(state.labelsData, state.scene, {
72197
- createObj: function createObj() {
72198
- var material = new THREE$5.MeshLambertMaterial();
72199
- material.side = DoubleSide;
72200
- var obj = new THREE$5.Group(); // container
72201
-
72202
- obj.add(new THREE$5.Mesh(circleGeometry, material)); // dot
72203
- var textObj = new THREE$5.Mesh(undefined, material);
72204
- obj.add(textObj); // text
72205
-
72206
- // text invisible bounding box (raycaster trap)
72207
- var bbObj = new THREE$5.Mesh();
72208
- bbObj.visible = false;
72209
- textObj.add(bbObj);
72210
- obj.__globeObjType = 'label'; // Add object type
72211
-
72212
- return obj;
72213
- },
72214
- updateObj: function updateObj(obj, d) {
72215
- var _obj$children = _slicedToArray$1(obj.children, 2),
72216
- dotObj = _obj$children[0],
72217
- textObj = _obj$children[1];
72218
- var _textObj$children = _slicedToArray$1(textObj.children, 1),
72219
- bbObj = _textObj$children[0];
72220
-
72221
- // update color
72222
- var color = colorAccessor(d);
72223
- var opacity = colorAlpha(color);
72224
- textObj.material.color.set(colorStr2Hex(color));
72225
- textObj.material.transparent = opacity < 1;
72226
- textObj.material.opacity = opacity;
72227
-
72228
- // update dot
72229
- var includeDot = includeDotAccessor(d);
72230
- var dotOrient = dotOrientationAccessor(d);
72231
- !includeDot || !orientations.has(dotOrient) && (dotOrient = 'bottom');
72232
-
72233
- // size dot
72234
- var dotR = includeDot ? +dotRadiusAccessor(d) * pxPerDeg : 1e-12;
72235
- dotObj.scale.x = dotObj.scale.y = dotR;
72236
-
72237
- // create text geometry
72238
- var textHeight = +sizeAccessor(d) * pxPerDeg;
72239
- textObj.geometry && textObj.geometry.dispose();
72240
- textObj.geometry = new THREE$5.TextGeometry(textAccessor(d), {
72241
- font: state.font,
72242
- size: textHeight,
72243
- depth: 0,
72244
- height: 0,
72245
- curveSegments: state.labelResolution
72246
- });
72257
+ state.dataMapper.onUpdateObj(function (obj, d) {
72258
+ var _obj$children = _slicedToArray$1(obj.children, 2),
72259
+ dotObj = _obj$children[0],
72260
+ textObj = _obj$children[1];
72261
+ var _textObj$children = _slicedToArray$1(textObj.children, 1),
72262
+ bbObj = _textObj$children[0];
72263
+
72264
+ // update color
72265
+ var color = colorAccessor(d);
72266
+ var opacity = colorAlpha(color);
72267
+ textObj.material.color.set(colorStr2Hex(color));
72268
+ textObj.material.transparent = opacity < 1;
72269
+ textObj.material.opacity = opacity;
72270
+
72271
+ // update dot
72272
+ var includeDot = includeDotAccessor(d);
72273
+ var dotOrient = dotOrientationAccessor(d);
72274
+ !includeDot || !orientations.has(dotOrient) && (dotOrient = 'bottom');
72275
+
72276
+ // size dot
72277
+ var dotR = includeDot ? +dotRadiusAccessor(d) * pxPerDeg : 1e-12;
72278
+ dotObj.scale.x = dotObj.scale.y = dotR;
72279
+
72280
+ // create text geometry
72281
+ var textHeight = +sizeAccessor(d) * pxPerDeg;
72282
+ textObj.geometry && textObj.geometry.dispose();
72283
+ textObj.geometry = new THREE$5.TextGeometry(textAccessor(d), {
72284
+ font: state.font,
72285
+ size: textHeight,
72286
+ depth: 0,
72287
+ height: 0,
72288
+ curveSegments: state.labelResolution
72289
+ });
72247
72290
 
72248
- // update text convex hull/bounding box
72249
- bbObj.geometry && bbObj.geometry.dispose();
72250
- textObj.geometry.computeBoundingBox();
72251
- bbObj.geometry = _construct$1(THREE$5.BoxGeometry, _toConsumableArray$1(new THREE$5.Vector3().subVectors(textObj.geometry.boundingBox.max, textObj.geometry.boundingBox.min).toArray()));
72252
-
72253
- // center text (otherwise anchor is on bottom-left)
72254
- dotOrient !== 'right' && textObj.geometry.center();
72255
- if (includeDot) {
72256
- // translate text
72257
- var padding = dotR + textHeight / 2;
72258
- dotOrient === 'right' && (textObj.position.x = padding);
72259
- textObj.position.y = {
72260
- right: -textHeight / 2,
72261
- // center vertically
72262
- top: padding + textHeight / 2,
72263
- bottom: -padding - textHeight / 2
72264
- }[dotOrient];
72265
- }
72291
+ // update text convex hull/bounding box
72292
+ bbObj.geometry && bbObj.geometry.dispose();
72293
+ textObj.geometry.computeBoundingBox();
72294
+ bbObj.geometry = _construct$1(THREE$5.BoxGeometry, _toConsumableArray$1(new THREE$5.Vector3().subVectors(textObj.geometry.boundingBox.max, textObj.geometry.boundingBox.min).toArray()));
72295
+
72296
+ // center text (otherwise anchor is on bottom-left)
72297
+ dotOrient !== 'right' && textObj.geometry.center();
72298
+ if (includeDot) {
72299
+ // translate text
72300
+ var padding = dotR + textHeight / 2;
72301
+ dotOrient === 'right' && (textObj.position.x = padding);
72302
+ textObj.position.y = {
72303
+ right: -textHeight / 2,
72304
+ // center vertically
72305
+ top: padding + textHeight / 2,
72306
+ bottom: -padding - textHeight / 2
72307
+ }[dotOrient];
72308
+ }
72266
72309
 
72267
- // animations
72268
- var applyPosition = function applyPosition(td) {
72269
- var _obj$__currentTargetD = obj.__currentTargetD = td,
72270
- lat = _obj$__currentTargetD.lat,
72271
- lng = _obj$__currentTargetD.lng,
72272
- alt = _obj$__currentTargetD.alt,
72273
- rot = _obj$__currentTargetD.rot,
72274
- scale = _obj$__currentTargetD.scale;
72310
+ // animations
72311
+ var applyPosition = function applyPosition(td) {
72312
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
72313
+ lat = _obj$__currentTargetD.lat,
72314
+ lng = _obj$__currentTargetD.lng,
72315
+ alt = _obj$__currentTargetD.alt,
72316
+ rot = _obj$__currentTargetD.rot,
72317
+ scale = _obj$__currentTargetD.scale;
72275
72318
 
72276
- // position center
72277
- Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72319
+ // position center
72320
+ Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72278
72321
 
72279
- // rotate
72280
- obj.lookAt(state.scene.localToWorld(new THREE$5.Vector3(0, 0, 0))); // face globe (local) center
72281
- obj.rotateY(Math.PI); // face outwards
72322
+ // rotate
72323
+ obj.lookAt(state.scene.localToWorld(new THREE$5.Vector3(0, 0, 0))); // face globe (local) center
72324
+ obj.rotateY(Math.PI); // face outwards
72282
72325
 
72283
- // rotate clockwise relative to lat parallel
72284
- obj.rotateZ(-rot * Math.PI / 180);
72326
+ // rotate clockwise relative to lat parallel
72327
+ obj.rotateZ(-rot * Math.PI / 180);
72285
72328
 
72286
- // scale it
72287
- obj.scale.x = obj.scale.y = obj.scale.z = scale;
72288
- };
72289
- var targetD = {
72290
- lat: +latAccessor(d),
72291
- lng: +lngAccessor(d),
72292
- alt: +altitudeAccessor(d),
72293
- rot: +rotationAccessor(d),
72294
- scale: 1
72295
- };
72296
- var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
72297
- scale: 1e-12
72298
- });
72299
- if (Object.keys(targetD).some(function (k) {
72300
- return currentTargetD[k] !== targetD[k];
72301
- })) {
72302
- if (!state.labelsTransitionDuration || state.labelsTransitionDuration < 0) {
72303
- // set final position
72304
- applyPosition(targetD);
72305
- } else {
72306
- // animate
72307
- state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.labelsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyPosition).start());
72308
- }
72329
+ // scale it
72330
+ obj.scale.x = obj.scale.y = obj.scale.z = scale;
72331
+ };
72332
+ var targetD = {
72333
+ lat: +latAccessor(d),
72334
+ lng: +lngAccessor(d),
72335
+ alt: +altitudeAccessor(d),
72336
+ rot: +rotationAccessor(d),
72337
+ scale: 1
72338
+ };
72339
+ var currentTargetD = obj.__currentTargetD || Object.assign({}, targetD, {
72340
+ scale: 1e-12
72341
+ });
72342
+ if (Object.keys(targetD).some(function (k) {
72343
+ return currentTargetD[k] !== targetD[k];
72344
+ })) {
72345
+ if (!state.labelsTransitionDuration || state.labelsTransitionDuration < 0) {
72346
+ // set final position
72347
+ applyPosition(targetD);
72348
+ } else {
72349
+ // animate
72350
+ state.tweenGroup.add(new Tween(currentTargetD).to(targetD, state.labelsTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyPosition).start());
72309
72351
  }
72310
72352
  }
72311
- });
72353
+ }).digest(state.labelsData);
72312
72354
  }
72313
72355
  });
72314
72356
 
@@ -72416,6 +72458,14 @@ void main() {
72416
72458
  // Main three object to manipulate
72417
72459
  state.scene = threeObj;
72418
72460
  state.tweenGroup = tweenGroup;
72461
+ state.dataMapper = new ThreeDigest(threeObj, {
72462
+ objBindAttr: '__threeObjRing',
72463
+ removeDelay: 30000 // wait until all rings are gone
72464
+ }).onCreateObj(function () {
72465
+ var obj = new THREE$3.Group();
72466
+ obj.__globeObjType = 'ring'; // Add object type
72467
+ return obj;
72468
+ });
72419
72469
  state.ticker = new FrameTicker();
72420
72470
  state.ticker.onTick.add(function (time) {
72421
72471
  if (!state.ringsData.length) return;
@@ -72426,10 +72476,14 @@ void main() {
72426
72476
  var maxRadiusAccessor = index$1(state.ringMaxRadius);
72427
72477
  var propagationSpeedAccessor = index$1(state.ringPropagationSpeed);
72428
72478
  var repeatPeriodAccessor = index$1(state.ringRepeatPeriod);
72429
- state.ringsData.filter(function (d) {
72430
- return d.__threeObj;
72431
- }).forEach(function (d) {
72432
- var obj = d.__threeObj;
72479
+ state.dataMapper.entries().filter(function (_ref2) {
72480
+ var _ref3 = _slicedToArray$1(_ref2, 2),
72481
+ o = _ref3[1];
72482
+ return o;
72483
+ }).forEach(function (_ref4) {
72484
+ var _ref5 = _slicedToArray$1(_ref4, 2),
72485
+ d = _ref5[0],
72486
+ obj = _ref5[1];
72433
72487
  if ((obj.__nextRingTime || 0) <= time) {
72434
72488
  // time to add a new ring
72435
72489
  var periodSecs = repeatPeriodAccessor(d) / 1000;
@@ -72461,8 +72515,8 @@ void main() {
72461
72515
  var maxAngle = maxRadius * Math.PI / 180; // in radians
72462
72516
  var propagationSpeed = propagationSpeedAccessor(d);
72463
72517
  var isReverse = propagationSpeed <= 0;
72464
- var updateFn = function updateFn(_ref2) {
72465
- var t = _ref2.t;
72518
+ var updateFn = function updateFn(_ref6) {
72519
+ var t = _ref6.t;
72466
72520
  var ang = (isReverse ? 1 - t : t) * maxAngle;
72467
72521
  circleObj.scale.x = circleObj.scale.y = curveR * Math.sin(ang);
72468
72522
  circleObj.position.z = curveR * (1 - Math.cos(ang));
@@ -72501,25 +72555,15 @@ void main() {
72501
72555
  var altitudeAccessor = index$1(state.ringAltitude);
72502
72556
  var globeCenter = state.scene.localToWorld(new THREE$3.Vector3(0, 0, 0)); // translate from local to world coords
72503
72557
 
72504
- threeDigest(state.ringsData, state.scene, {
72505
- createObj: function createObj() {
72506
- var obj = new THREE$3.Group();
72507
- obj.__globeObjType = 'ring'; // Add object type
72508
- return obj;
72509
- },
72510
- updateObj: function updateObj(obj, d) {
72511
- var lat = latAccessor(d);
72512
- var lng = lngAccessor(d);
72513
- var alt = altitudeAccessor(d);
72558
+ state.dataMapper.onUpdateObj(function (obj, d) {
72559
+ var lat = latAccessor(d);
72560
+ var lng = lngAccessor(d);
72561
+ var alt = altitudeAccessor(d);
72514
72562
 
72515
- // position & orientate inwards
72516
- Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72517
- obj.lookAt(globeCenter);
72518
- }
72519
- }, {
72520
- removeDelay: 30000
72521
- } // wait until all rings are gone
72522
- );
72563
+ // position & orientate inwards
72564
+ Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72565
+ obj.lookAt(globeCenter);
72566
+ }).digest(state.ringsData);
72523
72567
  }
72524
72568
  });
72525
72569
 
@@ -72560,9 +72604,12 @@ void main() {
72560
72604
  },
72561
72605
  methods: {
72562
72606
  updateObjVisibility: function updateObjVisibility(state, obj) {
72607
+ if (!state.dataMapper) return;
72563
72608
  // default to all if no obj specified
72564
- var objs = obj ? [obj] : state.htmlElementsData.map(function (d) {
72565
- return d.__threeObj;
72609
+ var objs = obj ? [obj] : state.dataMapper.entries().map(function (_ref) {
72610
+ var _ref2 = _slicedToArray$1(_ref, 2),
72611
+ o = _ref2[1];
72612
+ return o;
72566
72613
  }).filter(function (d) {
72567
72614
  return d;
72568
72615
  });
@@ -72572,14 +72619,23 @@ void main() {
72572
72619
  });
72573
72620
  }
72574
72621
  },
72575
- init: function init(threeObj, state, _ref) {
72576
- var tweenGroup = _ref.tweenGroup;
72622
+ init: function init(threeObj, state, _ref3) {
72623
+ var tweenGroup = _ref3.tweenGroup;
72577
72624
  // Clear the scene
72578
72625
  emptyObject(threeObj);
72579
72626
 
72580
72627
  // Main three object to manipulate
72581
72628
  state.scene = threeObj;
72582
72629
  state.tweenGroup = tweenGroup;
72630
+ state.dataMapper = new ThreeDigest(threeObj, {
72631
+ objBindAttr: '__threeObjHtml'
72632
+ }).onCreateObj(function (d) {
72633
+ var elem = index$1(state.htmlElement)(d);
72634
+ var obj = new THREE$2.CSS2DObject(elem);
72635
+ obj.__globeObjType = 'html'; // Add object type
72636
+
72637
+ return obj;
72638
+ });
72583
72639
  },
72584
72640
  update: function update(state, changedProps) {
72585
72641
  var _this = this;
@@ -72587,45 +72643,37 @@ void main() {
72587
72643
  var latAccessor = index$1(state.htmlLat);
72588
72644
  var lngAccessor = index$1(state.htmlLng);
72589
72645
  var altitudeAccessor = index$1(state.htmlAltitude);
72590
- var elemAccessor = index$1(state.htmlElement);
72591
- threeDigest(state.htmlElementsData, state.scene, {
72592
- // objs need to be recreated if this prop has changed
72593
- purge: changedProps.hasOwnProperty('htmlElement'),
72594
- createObj: function createObj(d) {
72595
- var elem = elemAccessor(d);
72596
- var obj = new THREE$2.CSS2DObject(elem);
72597
- obj.__globeObjType = 'html'; // Add object type
72598
72646
 
72599
- return obj;
72600
- },
72601
- updateObj: function updateObj(obj, d) {
72602
- var applyUpdate = function applyUpdate(td) {
72603
- var _obj$__currentTargetD = obj.__currentTargetD = td,
72604
- alt = _obj$__currentTargetD.alt,
72605
- lat = _obj$__currentTargetD.lat,
72606
- lng = _obj$__currentTargetD.lng;
72607
- Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72608
- _this.updateObjVisibility(obj);
72609
- };
72610
- var targetD = {
72611
- lat: +latAccessor(d),
72612
- lng: +lngAccessor(d),
72613
- alt: +altitudeAccessor(d)
72614
- };
72615
- if (!state.htmlTransitionDuration || state.htmlTransitionDuration < 0 || !obj.__currentTargetD) {
72616
- // set final position
72617
- applyUpdate(targetD);
72618
- } else {
72619
- // animate
72620
- state.tweenGroup.add(new Tween(obj.__currentTargetD).to(targetD, state.htmlTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
72621
- }
72647
+ // objs need to be recreated if this prop has changed
72648
+ changedProps.hasOwnProperty('htmlElement') && state.dataMapper.clear();
72649
+ state.dataMapper.onUpdateObj(function (obj, d) {
72650
+ var applyUpdate = function applyUpdate(td) {
72651
+ var _obj$__currentTargetD = obj.__currentTargetD = td,
72652
+ alt = _obj$__currentTargetD.alt,
72653
+ lat = _obj$__currentTargetD.lat,
72654
+ lng = _obj$__currentTargetD.lng;
72655
+ Object.assign(obj.position, polar2Cartesian(lat, lng, alt));
72656
+ _this.updateObjVisibility(obj);
72657
+ };
72658
+ var targetD = {
72659
+ lat: +latAccessor(d),
72660
+ lng: +lngAccessor(d),
72661
+ alt: +altitudeAccessor(d)
72662
+ };
72663
+ if (!state.htmlTransitionDuration || state.htmlTransitionDuration < 0 || !obj.__currentTargetD) {
72664
+ // set final position
72665
+ applyUpdate(targetD);
72666
+ } else {
72667
+ // animate
72668
+ state.tweenGroup.add(new Tween(obj.__currentTargetD).to(targetD, state.htmlTransitionDuration).easing(Easing.Quadratic.InOut).onUpdate(applyUpdate).start());
72622
72669
  }
72623
- });
72670
+ }).digest(state.htmlElementsData);
72624
72671
  }
72625
72672
  });
72626
72673
 
72627
72674
  var THREE$1 = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
72628
72675
  : {
72676
+ Euler: Euler,
72629
72677
  Group: Group$1,
72630
72678
  Mesh: Mesh,
72631
72679
  MeshLambertMaterial: MeshLambertMaterial,
@@ -72669,6 +72717,20 @@ void main() {
72669
72717
 
72670
72718
  // Main three object to manipulate
72671
72719
  state.scene = threeObj;
72720
+ state.dataMapper = new ThreeDigest(threeObj, {
72721
+ objBindAttr: '__threeObjObject'
72722
+ }).onCreateObj(function (d) {
72723
+ var obj = index$1(state.objectThreeObject)(d);
72724
+ if (state.objectThreeObject === obj) {
72725
+ // clone object if it's a shared object among all points
72726
+ obj = obj.clone();
72727
+ }
72728
+ var g = new THREE$1.Group();
72729
+ g.add(obj);
72730
+ g.__globeObjType = 'object'; // Add object type
72731
+
72732
+ return g;
72733
+ });
72672
72734
  },
72673
72735
  update: function update(state, changedProps) {
72674
72736
  // Data accessors
@@ -72677,33 +72739,19 @@ void main() {
72677
72739
  var altitudeAccessor = index$1(state.objectAltitude);
72678
72740
  var parallelAccessor = index$1(state.objectFacesSurface);
72679
72741
  var rotationAccessor = index$1(state.objectRotation);
72680
- var threeObjAccessor = index$1(state.objectThreeObject);
72681
- threeDigest(state.objectsData, state.scene, {
72682
- // objs need to be recreated if this prop has changed
72683
- purge: changedProps.hasOwnProperty('objectThreeObject'),
72684
- createObj: function createObj(d) {
72685
- var obj = threeObjAccessor(d);
72686
- if (state.objectThreeObject === obj) {
72687
- // clone object if it's a shared object among all points
72688
- obj = obj.clone();
72689
- }
72690
- var g = new THREE$1.Group();
72691
- g.add(obj);
72692
- g.__globeObjType = 'object'; // Add object type
72693
72742
 
72694
- return g;
72695
- },
72696
- updateObj: function updateObj(objG, d) {
72697
- var lat = +latAccessor(d);
72698
- var lng = +lngAccessor(d);
72699
- var alt = +altitudeAccessor(d);
72700
- Object.assign(objG.position, polar2Cartesian(lat, lng, alt));
72701
- parallelAccessor(d) ? objG.setRotationFromEuler(new Euler(deg2Rad$1(-lat), deg2Rad$1(lng), 0, 'YXZ')) : objG.rotation.set(0, 0, 0);
72702
- var obj = objG.children[0];
72703
- var rot = rotationAccessor(d);
72704
- rot && obj.setRotationFromEuler(new Euler(deg2Rad$1(rot.x || 0), deg2Rad$1(rot.y || 0), deg2Rad$1(rot.z || 0)));
72705
- }
72706
- });
72743
+ // objs need to be recreated if this prop has changed
72744
+ changedProps.hasOwnProperty('objectThreeObject') && state.dataMapper.clear();
72745
+ state.dataMapper.onUpdateObj(function (objG, d) {
72746
+ var lat = +latAccessor(d);
72747
+ var lng = +lngAccessor(d);
72748
+ var alt = +altitudeAccessor(d);
72749
+ Object.assign(objG.position, polar2Cartesian(lat, lng, alt));
72750
+ parallelAccessor(d) ? objG.setRotationFromEuler(new Euler(deg2Rad$1(-lat), deg2Rad$1(lng), 0, 'YXZ')) : objG.rotation.set(0, 0, 0);
72751
+ var obj = objG.children[0];
72752
+ var rot = rotationAccessor(d);
72753
+ rot && obj.setRotationFromEuler(new Euler(deg2Rad$1(rot.x || 0), deg2Rad$1(rot.y || 0), deg2Rad$1(rot.z || 0)));
72754
+ }).digest(state.objectsData);
72707
72755
  }
72708
72756
  });
72709
72757
 
@@ -72725,32 +72773,32 @@ void main() {
72725
72773
 
72726
72774
  // Main three object to manipulate
72727
72775
  state.scene = threeObj;
72776
+ state.dataMapper = new ThreeDigest(threeObj, {
72777
+ objBindAttr: '__threeObjCustom'
72778
+ }).onCreateObj(function (d) {
72779
+ var obj = index$1(state.customThreeObject)(d, GLOBE_RADIUS);
72780
+ if (obj) {
72781
+ if (state.customThreeObject === obj) {
72782
+ // clone object if it's a shared object among all points
72783
+ obj = obj.clone();
72784
+ }
72785
+ obj.__globeObjType = 'custom'; // Add object type
72786
+ }
72787
+ return obj;
72788
+ });
72728
72789
  },
72729
72790
  update: function update(state, changedProps) {
72730
72791
  if (!state.customThreeObjectUpdate) {
72731
72792
  emptyObject(state.scene);
72732
72793
  } // Clear the existing objects to create all new, if there's no update method (brute-force)
72733
72794
 
72734
- var customObjectAccessor = index$1(state.customThreeObject);
72735
72795
  var customObjectUpdateAccessor = index$1(state.customThreeObjectUpdate);
72736
- threeDigest(state.customLayerData, state.scene, {
72737
- // objs need to be recreated if this prop has changed
72738
- purge: changedProps.hasOwnProperty('customThreeObject'),
72739
- createObj: function createObj(d) {
72740
- var obj = customObjectAccessor(d, GLOBE_RADIUS);
72741
- if (obj) {
72742
- if (state.customThreeObject === obj) {
72743
- // clone object if it's a shared object among all points
72744
- obj = obj.clone();
72745
- }
72746
- obj.__globeObjType = 'custom'; // Add object type
72747
- }
72748
- return obj;
72749
- },
72750
- updateObj: function updateObj(obj, d) {
72751
- return customObjectUpdateAccessor(obj, d, GLOBE_RADIUS);
72752
- }
72753
- });
72796
+
72797
+ // objs need to be recreated if this prop has changed
72798
+ changedProps.hasOwnProperty('customThreeObject') && state.dataMapper.clear();
72799
+ state.dataMapper.onUpdateObj(function (obj, d) {
72800
+ return customObjectUpdateAccessor(obj, d, GLOBE_RADIUS);
72801
+ }).digest(state.customLayerData);
72754
72802
  }
72755
72803
  });
72756
72804
 
@@ -115142,7 +115190,7 @@ var<${access}> ${name} : ${structName};`;
115142
115190
  }
115143
115191
 
115144
115192
  var _excluded = ["rendererConfig", "waitForGlobeReady"];
115145
- var THREE = _objectSpread2$2(_objectSpread2$2({}, window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
115193
+ var THREE = _objectSpread2$1(_objectSpread2$1({}, window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
115146
115194
  : {
115147
115195
  AmbientLight: AmbientLight,
115148
115196
  DirectionalLight: DirectionalLight,
@@ -115157,25 +115205,25 @@ var<${access}> ${name} : ${structName};`;
115157
115205
  // Expose config from ThreeGlobe
115158
115206
  var bindGlobe = linkKapsule('globe', threeGlobe);
115159
115207
  var linkedGlobeProps = Object.assign.apply(Object, _toConsumableArray$5(['globeImageUrl', 'bumpImageUrl', 'showGlobe', 'showGraticules', 'showAtmosphere', 'atmosphereColor', 'atmosphereAltitude', 'onGlobeReady', 'pointsData', 'pointLat', 'pointLng', 'pointColor', 'pointAltitude', 'pointRadius', 'pointResolution', 'pointsMerge', 'pointsTransitionDuration', 'arcsData', 'arcStartLat', 'arcStartLng', 'arcEndLat', 'arcEndLng', 'arcColor', 'arcAltitude', 'arcAltitudeAutoScale', 'arcStroke', 'arcCurveResolution', 'arcCircularResolution', 'arcDashLength', 'arcDashGap', 'arcDashInitialGap', 'arcDashAnimateTime', 'arcsTransitionDuration', 'polygonsData', 'polygonGeoJsonGeometry', 'polygonCapColor', 'polygonCapMaterial', 'polygonSideColor', 'polygonSideMaterial', 'polygonStrokeColor', 'polygonAltitude', 'polygonCapCurvatureResolution', 'polygonsTransitionDuration', 'pathsData', 'pathPoints', 'pathPointLat', 'pathPointLng', 'pathPointAlt', 'pathResolution', 'pathColor', 'pathStroke', 'pathDashLength', 'pathDashGap', 'pathDashInitialGap', 'pathDashAnimateTime', 'pathTransitionDuration', 'heatmapsData', 'heatmapPoints', 'heatmapPointLat', 'heatmapPointLng', 'heatmapPointWeight', 'heatmapBandwidth', 'heatmapColorFn', 'heatmapColorSaturation', 'heatmapBaseAltitude', 'heatmapTopAltitude', 'heatmapsTransitionDuration', 'hexBinPointsData', 'hexBinPointLat', 'hexBinPointLng', 'hexBinPointWeight', 'hexBinResolution', 'hexMargin', 'hexTopCurvatureResolution', 'hexTopColor', 'hexSideColor', 'hexAltitude', 'hexBinMerge', 'hexTransitionDuration', 'hexPolygonsData', 'hexPolygonGeoJsonGeometry', 'hexPolygonColor', 'hexPolygonAltitude', 'hexPolygonResolution', 'hexPolygonMargin', 'hexPolygonUseDots', 'hexPolygonCurvatureResolution', 'hexPolygonDotResolution', 'hexPolygonsTransitionDuration', 'tilesData', 'tileLat', 'tileLng', 'tileAltitude', 'tileWidth', 'tileHeight', 'tileUseGlobeProjection', 'tileMaterial', 'tileCurvatureResolution', 'tilesTransitionDuration', 'ringsData', 'ringLat', 'ringLng', 'ringAltitude', 'ringColor', 'ringResolution', 'ringMaxRadius', 'ringPropagationSpeed', 'ringRepeatPeriod', 'labelsData', 'labelLat', 'labelLng', 'labelAltitude', 'labelRotation', 'labelText', 'labelSize', 'labelTypeFace', 'labelColor', 'labelResolution', 'labelIncludeDot', 'labelDotRadius', 'labelDotOrientation', 'labelsTransitionDuration', 'htmlElementsData', 'htmlLat', 'htmlLng', 'htmlAltitude', 'htmlElement', 'htmlTransitionDuration', 'objectsData', 'objectLat', 'objectLng', 'objectAltitude', 'objectRotation', 'objectFacesSurface', 'objectThreeObject', 'customLayerData', 'customThreeObject', 'customThreeObjectUpdate'].map(function (p) {
115160
- return _defineProperty$3({}, p, bindGlobe.linkProp(p));
115208
+ return _defineProperty$2({}, p, bindGlobe.linkProp(p));
115161
115209
  })));
115162
115210
  var linkedGlobeMethods = Object.assign.apply(Object, _toConsumableArray$5(['globeMaterial', 'getGlobeRadius', 'getCoords', 'toGeoCoords'].map(function (p) {
115163
- return _defineProperty$3({}, p, bindGlobe.linkMethod(p));
115211
+ return _defineProperty$2({}, p, bindGlobe.linkMethod(p));
115164
115212
  })));
115165
115213
 
115166
115214
  // Expose config from renderObjs
115167
115215
  var bindRenderObjs = linkKapsule('renderObjs', threeRenderObjects);
115168
115216
  var linkedRenderObjsProps = Object.assign.apply(Object, _toConsumableArray$5(['width', 'height', 'backgroundColor', 'backgroundImageUrl', 'enablePointerInteraction'].map(function (p) {
115169
- return _defineProperty$3({}, p, bindRenderObjs.linkProp(p));
115217
+ return _defineProperty$2({}, p, bindRenderObjs.linkProp(p));
115170
115218
  })));
115171
115219
  var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray$5(['lights', 'postProcessingComposer'].map(function (p) {
115172
- return _defineProperty$3({}, p, bindRenderObjs.linkMethod(p));
115220
+ return _defineProperty$2({}, p, bindRenderObjs.linkMethod(p));
115173
115221
  })));
115174
115222
 
115175
115223
  //
115176
115224
 
115177
115225
  var globe = index$2({
115178
- props: _objectSpread2$2(_objectSpread2$2({
115226
+ props: _objectSpread2$1(_objectSpread2$1({
115179
115227
  onZoom: {
115180
115228
  triggerUpdate: false
115181
115229
  },
@@ -115340,7 +115388,7 @@ var<${access}> ${name} : ${structName};`;
115340
115388
  }
115341
115389
  }
115342
115390
  }, linkedGlobeProps), linkedRenderObjsProps),
115343
- methods: _objectSpread2$2(_objectSpread2$2({
115391
+ methods: _objectSpread2$1(_objectSpread2$1({
115344
115392
  pauseAnimation: function pauseAnimation(state) {
115345
115393
  var _state$globe;
115346
115394
  if (state.animationFrameRequestId !== null) {
@@ -115462,8 +115510,8 @@ var<${access}> ${name} : ${structName};`;
115462
115510
  var rendererConfig = _ref6.rendererConfig,
115463
115511
  _ref6$waitForGlobeRea = _ref6.waitForGlobeReady,
115464
115512
  waitForGlobeReady = _ref6$waitForGlobeRea === void 0 ? true : _ref6$waitForGlobeRea,
115465
- globeInitConfig = _objectWithoutProperties$3(_ref6, _excluded);
115466
- var globe = new threeGlobe(_objectSpread2$2({
115513
+ globeInitConfig = _objectWithoutProperties$2(_ref6, _excluded);
115514
+ var globe = new threeGlobe(_objectSpread2$1({
115467
115515
  waitForGlobeReady: waitForGlobeReady
115468
115516
  }, globeInitConfig));
115469
115517
  return {