globe.gl 2.25.3 → 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 +34 -1
- package/dist/globe.gl.common.js +28 -18
- package/dist/globe.gl.d.ts +5 -1
- package/dist/globe.gl.js +574 -213
- 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/package.json +5 -5
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ And check out the [React bindings](https://github.com/vasturiano/react-globe.gl)
|
|
|
33
33
|
* [Hollow Globe](https://vasturiano.github.io/globe.gl/example/hollow-globe/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/hollow-globe/index.html))
|
|
34
34
|
* [Path Lines](https://vasturiano.github.io/globe.gl/example/random-paths/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/random-paths/index.html))
|
|
35
35
|
* [Map Labels](https://vasturiano.github.io/globe.gl/example/world-cities/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/world-cities/index.html))
|
|
36
|
+
* [HTML Markers](https://vasturiano.github.io/globe.gl/example/html-markers/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/html-markers/index.html))
|
|
36
37
|
* [Hexed Country Polygons](https://vasturiano.github.io/globe.gl/example/hexed-polygons/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/hexed-polygons/index.html))
|
|
37
38
|
* [Tiles](https://vasturiano.github.io/globe.gl/example/tiles/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/tiles/index.html))
|
|
38
39
|
* [Ripple Rings](https://vasturiano.github.io/globe.gl/example/random-rings/) ([source](https://github.com/vasturiano/globe.gl/blob/master/example/random-rings/index.html))
|
|
@@ -73,6 +74,23 @@ myGlobe(myDOMElement)
|
|
|
73
74
|
|
|
74
75
|
## API reference
|
|
75
76
|
|
|
77
|
+
* [Initialisation](#initialisation)
|
|
78
|
+
* [Container Layout](#container-layout)
|
|
79
|
+
* [Globe Layer](#globe-layer)
|
|
80
|
+
* [Points Layer](#points-layer)
|
|
81
|
+
* [Arcs Layer](#arcs-layer)
|
|
82
|
+
* [Polygons Layer](#polygons-layer)
|
|
83
|
+
* [Paths Layer](#paths-layer)
|
|
84
|
+
* [Hex Bin Layer](#hex-bin-layer)
|
|
85
|
+
* [Hexed Polygons Layer](#hexed-polygons-layer)
|
|
86
|
+
* [Tiles Layer](#tiles-layer)
|
|
87
|
+
* [Rings Layer](#rings-layer)
|
|
88
|
+
* [HTML Elements Layer](#html-elements-layer)
|
|
89
|
+
* [3D Objects Layer](#3d-objects-layer)
|
|
90
|
+
* [Custom Layer](#custom-layer)
|
|
91
|
+
* [Render Control](#render-control)
|
|
92
|
+
* [Utility](#utility)
|
|
93
|
+
|
|
76
94
|
### Initialisation
|
|
77
95
|
|
|
78
96
|
```js
|
|
@@ -324,7 +342,22 @@ Globe({ configOptions })(<domElement>)
|
|
|
324
342
|
| <b>onLabelRightClick</b>(<i>fn</i>) | Callback function for label right-clicks. The label object, the event object and the clicked coordinates are included as arguments: `onLabelRightClick(label, event, { lat, lng, altitude })`. | - |
|
|
325
343
|
| <b>onLabelHover</b>(<i>fn</i>) | Callback function for label mouse over events. The label object (or `null` if there's no label under the mouse line of sight) is included as the first argument, and the previous label object (or `null`) as second argument: `onLabelHover(label, prevlabel)`. | - |
|
|
326
344
|
|
|
327
|
-
###
|
|
345
|
+
### HTML Elements Layer
|
|
346
|
+
|
|
347
|
+
<p align="center">
|
|
348
|
+
<a href="//vasturiano.github.io/globe.gl/example/html-markers/"><img width="70%" src="https://vasturiano.github.io/globe.gl/example/html-markers/preview.png"></a>
|
|
349
|
+
</p>
|
|
350
|
+
|
|
351
|
+
| Method | Description | Default |
|
|
352
|
+
| --- | --- | :--: |
|
|
353
|
+
| <b>htmlElementsData</b>([<i>array</i>]) | Getter/setter for the list of objects to represent in the HTML elements map layer. Each HTML element is rendered using [ThreeJS CSS2DRenderer](https://threejs.org/docs/#examples/en/renderers/CSS2DRenderer). | `[]` |
|
|
354
|
+
| <b>htmlLat</b>([<i>num</i>, <i>str</i> or <i>fn</i>]) | HTML element accessor function, attribute or a numeric constant for the latitude coordinate of the element's central position. | `lat` |
|
|
355
|
+
| <b>htmlLng</b>([<i>num</i>, <i>str</i> or <i>fn</i>]) | HTML element accessor function, attribute or a numeric constant for the longitude coordinate of the element's central position. | `lng` |
|
|
356
|
+
| <b>htmlAltitude</b>([<i>num</i>, <i>str</i> or <i>fn</i>]) | HTML element accessor function, attribute or a numeric constant for the altitude coordinate of the element's position, in terms of globe radius units. | 0 |
|
|
357
|
+
| <b>htmlElement</b>([<i>str</i> or <i>fn</i>]) | Accessor function or attribute to retrieve the DOM element to use. Should return an instance of [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement). | `null` |
|
|
358
|
+
| <b>htmlTransitionDuration</b>([<i>num</i>]) | Getter/setter for duration (ms) of the transition to animate HTML elements position changes. A value of `0` will move the elements immediately to their final position. | 1000 |
|
|
359
|
+
|
|
360
|
+
### 3D Objects Layer
|
|
328
361
|
|
|
329
362
|
<p align="center">
|
|
330
363
|
<a href="//vasturiano.github.io/globe.gl/example/satellites/"><img width="70%" src="https://vasturiano.github.io/globe.gl/example/satellites/preview.png"></a>
|
package/dist/globe.gl.common.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var three
|
|
3
|
+
var three = require('three');
|
|
4
|
+
var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
|
|
4
5
|
var ThreeGlobe = require('three-globe');
|
|
5
6
|
var ThreeRenderObjects = require('three-render-objects');
|
|
6
7
|
var accessorFn = require('accessor-fn');
|
|
@@ -189,16 +190,19 @@ function linkKapsule (kapsulePropName, kapsuleType) {
|
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
var _excluded = ["rendererConfig", "waitForGlobeReady"];
|
|
192
|
-
|
|
193
|
+
|
|
194
|
+
var THREE = _objectSpread2(_objectSpread2({}, window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
|
|
193
195
|
: {
|
|
194
|
-
AmbientLight: three
|
|
195
|
-
DirectionalLight: three
|
|
196
|
-
Vector2: three
|
|
197
|
-
}
|
|
196
|
+
AmbientLight: three.AmbientLight,
|
|
197
|
+
DirectionalLight: three.DirectionalLight,
|
|
198
|
+
Vector2: three.Vector2
|
|
199
|
+
}), {}, {
|
|
200
|
+
CSS2DRenderer: CSS2DRenderer_js.CSS2DRenderer
|
|
201
|
+
});
|
|
198
202
|
// Expose config from ThreeGlobe
|
|
199
203
|
|
|
200
204
|
var bindGlobe = linkKapsule('globe', ThreeGlobe__default["default"]);
|
|
201
|
-
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) {
|
|
205
|
+
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) {
|
|
202
206
|
return _defineProperty({}, p, bindGlobe.linkProp(p));
|
|
203
207
|
})));
|
|
204
208
|
var linkedGlobeMethods = Object.assign.apply(Object, _toConsumableArray(['getGlobeRadius', 'getCoords', 'toGeoCoords'].map(function (p) {
|
|
@@ -213,7 +217,6 @@ var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray(['p
|
|
|
213
217
|
return _defineProperty({}, p, bindRenderObjs.linkMethod(p));
|
|
214
218
|
}))); //
|
|
215
219
|
|
|
216
|
-
var GLOBE_RADIUS = 100;
|
|
217
220
|
var globe = Kapsule__default["default"]({
|
|
218
221
|
props: _objectSpread2(_objectSpread2({
|
|
219
222
|
onZoom: {
|
|
@@ -489,6 +492,7 @@ var globe = Kapsule__default["default"]({
|
|
|
489
492
|
this.hexPolygonsData([]);
|
|
490
493
|
this.tilesData([]);
|
|
491
494
|
this.labelsData([]);
|
|
495
|
+
this.htmlElementsData([]);
|
|
492
496
|
this.objectsData([]);
|
|
493
497
|
this.customLayerData([]);
|
|
494
498
|
}
|
|
@@ -499,15 +503,18 @@ var globe = Kapsule__default["default"]({
|
|
|
499
503
|
waitForGlobeReady = _ref6$waitForGlobeRea === void 0 ? true : _ref6$waitForGlobeRea,
|
|
500
504
|
globeInitConfig = _objectWithoutProperties(_ref6, _excluded);
|
|
501
505
|
|
|
506
|
+
var globe = new ThreeGlobe__default["default"](_objectSpread2({
|
|
507
|
+
waitForGlobeReady: waitForGlobeReady
|
|
508
|
+
}, globeInitConfig));
|
|
502
509
|
return {
|
|
503
|
-
globe:
|
|
504
|
-
waitForGlobeReady: waitForGlobeReady
|
|
505
|
-
}, globeInitConfig)),
|
|
510
|
+
globe: globe,
|
|
506
511
|
renderObjs: ThreeRenderObjects__default["default"]({
|
|
507
512
|
controlType: 'orbit',
|
|
508
513
|
rendererConfig: rendererConfig,
|
|
509
|
-
waitForLoadComplete: waitForGlobeReady
|
|
510
|
-
|
|
514
|
+
waitForLoadComplete: waitForGlobeReady,
|
|
515
|
+
extraRenderers: [new THREE.CSS2DRenderer()] // Used in HTML elements layer
|
|
516
|
+
|
|
517
|
+
}).skyRadius(globe.getGlobeRadius() * 500).showNavInfo(false)
|
|
511
518
|
};
|
|
512
519
|
},
|
|
513
520
|
init: function init(domNode, state) {
|
|
@@ -523,18 +530,19 @@ var globe = Kapsule__default["default"]({
|
|
|
523
530
|
state.container.appendChild(roDomNode);
|
|
524
531
|
state.renderObjs(roDomNode); // inject renderer size on three-globe
|
|
525
532
|
|
|
526
|
-
state.globe.rendererSize(state.renderObjs.renderer().getSize(new
|
|
533
|
+
state.globe.rendererSize(state.renderObjs.renderer().getSize(new THREE.Vector2())); // set initial distance
|
|
527
534
|
|
|
528
535
|
this.pointOfView({
|
|
529
536
|
altitude: 2.5
|
|
530
537
|
}); // calibrate orbit controls
|
|
531
538
|
|
|
539
|
+
var globeR = state.globe.getGlobeRadius();
|
|
532
540
|
var controls = state.renderObjs.controls();
|
|
533
|
-
controls.minDistance =
|
|
541
|
+
controls.minDistance = globeR * 1.01; // just above the surface
|
|
534
542
|
|
|
535
543
|
setTimeout(function () {
|
|
536
|
-
return controls.maxDistance =
|
|
537
|
-
}); // apply async
|
|
544
|
+
return controls.maxDistance = globeR * 100;
|
|
545
|
+
}); // apply async after renderObjs sets maxDistance
|
|
538
546
|
|
|
539
547
|
controls.enablePan = false;
|
|
540
548
|
controls.enableDamping = true;
|
|
@@ -548,7 +556,9 @@ var globe = Kapsule__default["default"]({
|
|
|
548
556
|
controls.rotateSpeed = pov.altitude * 0.2; // Math.pow(pov.altitude + 1, 2) * 0.025;
|
|
549
557
|
|
|
550
558
|
controls.zoomSpeed = (pov.altitude + 1) * 0.1; // Math.sqrt(pov.altitude) * 0.2;
|
|
559
|
+
// Update three-globe pov when camera moves, for proper hiding of elements
|
|
551
560
|
|
|
561
|
+
state.globe.setPointOfView(state.renderObjs.camera().position);
|
|
552
562
|
state.onZoom && state.onZoom(pov);
|
|
553
563
|
}); // config renderObjs
|
|
554
564
|
|
|
@@ -595,7 +605,7 @@ var globe = Kapsule__default["default"]({
|
|
|
595
605
|
}
|
|
596
606
|
};
|
|
597
607
|
state.renderObjs.objects([// Populate scene
|
|
598
|
-
new
|
|
608
|
+
new THREE.AmbientLight(0xbbbbbb), new THREE.DirectionalLight(0xffffff, 0.6), state.globe]).hoverOrderComparator(function (a, b) {
|
|
599
609
|
var aObj = getGlobeObj(a);
|
|
600
610
|
var bObj = getGlobeObj(b); // de-prioritize background / non-globe objects
|
|
601
611
|
|
package/dist/globe.gl.d.ts
CHANGED
|
@@ -23,7 +23,11 @@ interface GeoCoords {
|
|
|
23
23
|
|
|
24
24
|
type PointerEventsFilterFn = (object: Object3D, data?: object) => boolean;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
// don't surface these internal props from inner ThreeGlobe
|
|
27
|
+
type ExcludedInnerProps = 'setPointOfView';
|
|
28
|
+
|
|
29
|
+
interface GlobeGenericInstance<ChainableInstance>
|
|
30
|
+
extends Omit<ThreeGlobeGeneric<ChainableInstance>, ExcludedInnerProps> {
|
|
27
31
|
(element: HTMLElement): ChainableInstance;
|
|
28
32
|
resetProps(): ChainableInstance;
|
|
29
33
|
_destructor(): void;
|