globe.gl 2.25.1 → 2.26.0
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/README.md +36 -1
- package/dist/globe.gl.common.js +28 -18
- package/dist/globe.gl.d.ts +5 -1
- package/dist/globe.gl.js +1778 -1138
- package/dist/globe.gl.js.map +1 -1
- package/dist/globe.gl.min.js +4 -4
- package/dist/globe.gl.module.js +24 -14
- package/example/html-markers/index.html +42 -0
- package/example/html-markers/preview.png +0 -0
- package/example/satellites/index.html +9 -3
- package/package.json +8 -8
package/dist/globe.gl.module.js
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
494
|
-
waitForGlobeReady: waitForGlobeReady
|
|
495
|
-
}, globeInitConfig)),
|
|
500
|
+
globe: globe,
|
|
496
501
|
renderObjs: ThreeRenderObjects({
|
|
497
502
|
controlType: 'orbit',
|
|
498
503
|
rendererConfig: rendererConfig,
|
|
499
|
-
waitForLoadComplete: waitForGlobeReady
|
|
500
|
-
|
|
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
|
|
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 =
|
|
531
|
+
controls.minDistance = globeR * 1.01; // just above the surface
|
|
524
532
|
|
|
525
533
|
setTimeout(function () {
|
|
526
|
-
return controls.maxDistance =
|
|
527
|
-
}); // apply async
|
|
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
|
|
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
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
<script>
|
|
30
30
|
const EARTH_RADIUS_KM = 6371; // km
|
|
31
|
-
const SAT_SIZE =
|
|
31
|
+
const SAT_SIZE = 100; // km
|
|
32
32
|
const TIME_STEP = 3 * 1000; // per frame
|
|
33
33
|
|
|
34
34
|
const timeLogger = document.getElementById('time-log');
|
|
@@ -48,11 +48,17 @@
|
|
|
48
48
|
world.objectThreeObject(() => new THREE.Mesh(satGeometry, satMaterial));
|
|
49
49
|
|
|
50
50
|
fetch('../datasets/space-track-leo.txt').then(r => r.text()).then(rawData => {
|
|
51
|
-
const tleData = rawData.replace(/\r/g, '')
|
|
51
|
+
const tleData = rawData.replace(/\r/g, '')
|
|
52
|
+
.split(/\n(?=[^12])/)
|
|
53
|
+
.filter(d => d)
|
|
54
|
+
.map(tle => tle.split('\n'));
|
|
52
55
|
const satData = tleData.map(([name, ...tle]) => ({
|
|
53
56
|
satrec: satellite.twoline2satrec(...tle),
|
|
54
57
|
name: name.trim().replace(/^0 /, '')
|
|
55
|
-
}))
|
|
58
|
+
}))
|
|
59
|
+
// exclude those that can't be propagated
|
|
60
|
+
.filter(d => !!satellite.propagate(d.satrec, new Date()).position)
|
|
61
|
+
.slice(0, 2000);
|
|
56
62
|
|
|
57
63
|
// time ticker
|
|
58
64
|
let time = new Date();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "globe.gl",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.26.0",
|
|
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,7 +43,7 @@
|
|
|
43
43
|
"accessor-fn": "1",
|
|
44
44
|
"kapsule": "^1.13",
|
|
45
45
|
"three": ">=0.118 <1",
|
|
46
|
-
"three-globe": "^2.
|
|
46
|
+
"three-globe": "^2.24",
|
|
47
47
|
"three-render-objects": "^1.26"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
@@ -51,15 +51,15 @@
|
|
|
51
51
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
52
52
|
"@babel/plugin-proposal-object-rest-spread": "^7.17.3",
|
|
53
53
|
"@babel/preset-env": "^7.16.11",
|
|
54
|
-
"@rollup/plugin-babel": "^5.3.
|
|
55
|
-
"@rollup/plugin-commonjs": "^21.0.
|
|
54
|
+
"@rollup/plugin-babel": "^5.3.1",
|
|
55
|
+
"@rollup/plugin-commonjs": "^21.0.2",
|
|
56
56
|
"@rollup/plugin-node-resolve": "^13.1.3",
|
|
57
|
-
"postcss": "^8.4.
|
|
57
|
+
"postcss": "^8.4.7",
|
|
58
58
|
"rimraf": "^3.0.2",
|
|
59
|
-
"rollup": "^2.
|
|
60
|
-
"rollup-plugin-dts": "^4.
|
|
59
|
+
"rollup": "^2.69.1",
|
|
60
|
+
"rollup-plugin-dts": "^4.2.0",
|
|
61
61
|
"rollup-plugin-postcss": "^4.0.2",
|
|
62
62
|
"rollup-plugin-terser": "^7.0.2",
|
|
63
|
-
"typescript": "^4.
|
|
63
|
+
"typescript": "^4.6.2"
|
|
64
64
|
}
|
|
65
65
|
}
|