globe.gl 2.25.3 → 2.26.2

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.
@@ -1,4 +1,5 @@
1
1
  import { AmbientLight, DirectionalLight, Vector2 } from 'three';
2
+ import { CSS2DRenderer } from 'three/examples/jsm/renderers/CSS2DRenderer.js';
2
3
  import ThreeGlobe from 'three-globe';
3
4
  import ThreeRenderObjects from 'three-render-objects';
4
5
  import accessorFn from 'accessor-fn';
@@ -179,16 +180,19 @@ function linkKapsule (kapsulePropName, kapsuleType) {
179
180
  }
180
181
 
181
182
  var _excluded = ["rendererConfig", "waitForGlobeReady"];
182
- var three = window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
183
+
184
+ var THREE = _objectSpread2(_objectSpread2({}, window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
183
185
  : {
184
186
  AmbientLight: AmbientLight,
185
187
  DirectionalLight: DirectionalLight,
186
188
  Vector2: Vector2
187
- };
189
+ }), {}, {
190
+ CSS2DRenderer: CSS2DRenderer
191
+ });
188
192
  // Expose config from ThreeGlobe
189
193
 
190
194
  var bindGlobe = linkKapsule('globe', ThreeGlobe);
191
- var linkedGlobeProps = Object.assign.apply(Object, _toConsumableArray(['globeImageUrl', 'bumpImageUrl', 'showGlobe', 'showGraticules', 'showAtmosphere', 'atmosphereColor', 'atmosphereAltitude', 'globeMaterial', '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', 'hexBinPointsData', 'hexBinPointLat', 'hexBinPointLng', 'hexBinPointWeight', 'hexBinResolution', 'hexMargin', 'hexTopCurvatureResolution', 'hexTopColor', 'hexSideColor', 'hexAltitude', 'hexBinMerge', 'hexTransitionDuration', 'hexPolygonsData', 'hexPolygonGeoJsonGeometry', 'hexPolygonColor', 'hexPolygonAltitude', 'hexPolygonResolution', 'hexPolygonMargin', 'hexPolygonCurvatureResolution', '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', 'objectsData', 'objectLat', 'objectLng', 'objectAltitude', 'objectThreeObject', 'customLayerData', 'customThreeObject', 'customThreeObjectUpdate'].map(function (p) {
195
+ var linkedGlobeProps = Object.assign.apply(Object, _toConsumableArray(['globeImageUrl', 'bumpImageUrl', 'showGlobe', 'showGraticules', 'showAtmosphere', 'atmosphereColor', 'atmosphereAltitude', 'globeMaterial', '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', 'hexBinPointsData', 'hexBinPointLat', 'hexBinPointLng', 'hexBinPointWeight', 'hexBinResolution', 'hexMargin', 'hexTopCurvatureResolution', 'hexTopColor', 'hexSideColor', 'hexAltitude', 'hexBinMerge', 'hexTransitionDuration', 'hexPolygonsData', 'hexPolygonGeoJsonGeometry', 'hexPolygonColor', 'hexPolygonAltitude', 'hexPolygonResolution', 'hexPolygonMargin', 'hexPolygonCurvatureResolution', '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', 'objectThreeObject', 'customLayerData', 'customThreeObject', 'customThreeObjectUpdate'].map(function (p) {
192
196
  return _defineProperty({}, p, bindGlobe.linkProp(p));
193
197
  })));
194
198
  var linkedGlobeMethods = Object.assign.apply(Object, _toConsumableArray(['getGlobeRadius', 'getCoords', 'toGeoCoords'].map(function (p) {
@@ -203,7 +207,6 @@ var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray(['p
203
207
  return _defineProperty({}, p, bindRenderObjs.linkMethod(p));
204
208
  }))); //
205
209
 
206
- var GLOBE_RADIUS = 100;
207
210
  var globe = Kapsule({
208
211
  props: _objectSpread2(_objectSpread2({
209
212
  onZoom: {
@@ -479,6 +482,7 @@ var globe = Kapsule({
479
482
  this.hexPolygonsData([]);
480
483
  this.tilesData([]);
481
484
  this.labelsData([]);
485
+ this.htmlElementsData([]);
482
486
  this.objectsData([]);
483
487
  this.customLayerData([]);
484
488
  }
@@ -489,15 +493,18 @@ var globe = Kapsule({
489
493
  waitForGlobeReady = _ref6$waitForGlobeRea === void 0 ? true : _ref6$waitForGlobeRea,
490
494
  globeInitConfig = _objectWithoutProperties(_ref6, _excluded);
491
495
 
496
+ var globe = new ThreeGlobe(_objectSpread2({
497
+ waitForGlobeReady: waitForGlobeReady
498
+ }, globeInitConfig));
492
499
  return {
493
- globe: new ThreeGlobe(_objectSpread2({
494
- waitForGlobeReady: waitForGlobeReady
495
- }, globeInitConfig)),
500
+ globe: globe,
496
501
  renderObjs: ThreeRenderObjects({
497
502
  controlType: 'orbit',
498
503
  rendererConfig: rendererConfig,
499
- waitForLoadComplete: waitForGlobeReady
500
- }).skyRadius(GLOBE_RADIUS * 500).showNavInfo(false)
504
+ waitForLoadComplete: waitForGlobeReady,
505
+ extraRenderers: [new THREE.CSS2DRenderer()] // Used in HTML elements layer
506
+
507
+ }).skyRadius(globe.getGlobeRadius() * 500).showNavInfo(false)
501
508
  };
502
509
  },
503
510
  init: function init(domNode, state) {
@@ -513,18 +520,19 @@ var globe = Kapsule({
513
520
  state.container.appendChild(roDomNode);
514
521
  state.renderObjs(roDomNode); // inject renderer size on three-globe
515
522
 
516
- state.globe.rendererSize(state.renderObjs.renderer().getSize(new three.Vector2())); // set initial distance
523
+ state.globe.rendererSize(state.renderObjs.renderer().getSize(new THREE.Vector2())); // set initial distance
517
524
 
518
525
  this.pointOfView({
519
526
  altitude: 2.5
520
527
  }); // calibrate orbit controls
521
528
 
529
+ var globeR = state.globe.getGlobeRadius();
522
530
  var controls = state.renderObjs.controls();
523
- controls.minDistance = GLOBE_RADIUS * 1.01; // just above the surface
531
+ controls.minDistance = globeR * 1.01; // just above the surface
524
532
 
525
533
  setTimeout(function () {
526
- return controls.maxDistance = GLOBE_RADIUS * 100;
527
- }); // apply async after renderObjs sets maxDistance
534
+ return controls.maxDistance = globeR * 100;
535
+ }); // apply async after renderObjs sets maxDistance
528
536
 
529
537
  controls.enablePan = false;
530
538
  controls.enableDamping = true;
@@ -538,7 +546,9 @@ var globe = Kapsule({
538
546
  controls.rotateSpeed = pov.altitude * 0.2; // Math.pow(pov.altitude + 1, 2) * 0.025;
539
547
 
540
548
  controls.zoomSpeed = (pov.altitude + 1) * 0.1; // Math.sqrt(pov.altitude) * 0.2;
549
+ // Update three-globe pov when camera moves, for proper hiding of elements
541
550
 
551
+ state.globe.setPointOfView(state.renderObjs.camera().position);
542
552
  state.onZoom && state.onZoom(pov);
543
553
  }); // config renderObjs
544
554
 
@@ -585,7 +595,7 @@ var globe = Kapsule({
585
595
  }
586
596
  };
587
597
  state.renderObjs.objects([// Populate scene
588
- new three.AmbientLight(0xbbbbbb), new three.DirectionalLight(0xffffff, 0.6), state.globe]).hoverOrderComparator(function (a, b) {
598
+ new THREE.AmbientLight(0xbbbbbb), new THREE.DirectionalLight(0xffffff, 0.6), state.globe]).hoverOrderComparator(function (a, b) {
589
599
  var aObj = getGlobeObj(a);
590
600
  var bObj = getGlobeObj(b); // de-prioritize background / non-globe objects
591
601
 
@@ -0,0 +1,42 @@
1
+ <head>
2
+ <style> body { margin: 0; } </style>
3
+
4
+ <script src="//unpkg.com/globe.gl"></script>
5
+ <!-- <script src="../../dist/globe.gl.js"></script>-->
6
+ </head>
7
+
8
+ <body>
9
+ <div id="globeViz"></div>
10
+
11
+ <script>
12
+ const markerSvg = `<svg viewBox="-4 0 36 36">
13
+ <path fill="currentColor" d="M14,0 C21.732,0 28,5.641 28,12.6 C28,23.963 14,36 14,36 C14,36 0,24.064 0,12.6 C0,5.641 6.268,0 14,0 Z"></path>
14
+ <circle fill="black" cx="14" cy="14" r="7"></circle>
15
+ </svg>`;
16
+
17
+ // Gen random data
18
+ const N = 30;
19
+ const gData = [...Array(N).keys()].map(() => ({
20
+ lat: (Math.random() - 0.5) * 180,
21
+ lng: (Math.random() - 0.5) * 360,
22
+ size: 7 + Math.random() * 30,
23
+ color: ['red', 'white', 'blue', 'green'][Math.round(Math.random() * 3)]
24
+ }));
25
+
26
+ Globe()
27
+ .globeImageUrl('//unpkg.com/three-globe/example/img/earth-dark.jpg')
28
+ .htmlElementsData(gData)
29
+ .htmlElement(d => {
30
+ const el = document.createElement('div');
31
+ el.innerHTML = markerSvg;
32
+ el.style.color = d.color;
33
+ el.style.width = `${d.size}px`;
34
+
35
+ el.style['pointer-events'] = 'auto';
36
+ el.style.cursor = 'pointer';
37
+ el.onclick = () => console.info(d);
38
+ return el;
39
+ })
40
+ (document.getElementById('globeViz'));
41
+ </script>
42
+ </body>
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "globe.gl",
3
- "version": "2.25.3",
3
+ "version": "2.26.2",
4
4
  "description": "UI component for Globe Data Visualization using ThreeJS/WebGL",
5
5
  "unpkg": "dist/globe.gl.min.js",
6
6
  "jsdelivr": "dist/globe.gl.min.js",
@@ -43,23 +43,23 @@
43
43
  "accessor-fn": "1",
44
44
  "kapsule": "^1.13",
45
45
  "three": ">=0.118 <1",
46
- "three-globe": "^2.23",
46
+ "three-globe": "^2.24",
47
47
  "three-render-objects": "^1.26"
48
48
  },
49
49
  "devDependencies": {
50
- "@babel/core": "^7.17.5",
51
- "@babel/plugin-proposal-class-properties": "^7.16.7",
52
- "@babel/plugin-proposal-object-rest-spread": "^7.17.3",
53
- "@babel/preset-env": "^7.16.11",
50
+ "@babel/core": "^7.18.2",
51
+ "@babel/plugin-proposal-class-properties": "^7.17.12",
52
+ "@babel/plugin-proposal-object-rest-spread": "^7.18.0",
53
+ "@babel/preset-env": "^7.18.2",
54
54
  "@rollup/plugin-babel": "^5.3.1",
55
- "@rollup/plugin-commonjs": "^21.0.2",
56
- "@rollup/plugin-node-resolve": "^13.1.3",
57
- "postcss": "^8.4.7",
55
+ "@rollup/plugin-commonjs": "^22.0.0",
56
+ "@rollup/plugin-node-resolve": "^13.3.0",
57
+ "postcss": "^8.4.14",
58
58
  "rimraf": "^3.0.2",
59
- "rollup": "^2.68.0",
60
- "rollup-plugin-dts": "^4.1.0",
59
+ "rollup": "^2.75.0",
60
+ "rollup-plugin-dts": "^4.2.2",
61
61
  "rollup-plugin-postcss": "^4.0.2",
62
62
  "rollup-plugin-terser": "^7.0.2",
63
- "typescript": "^4.5.5"
63
+ "typescript": "^4.7.2"
64
64
  }
65
65
  }