react-globe.gl 2.20.2 → 2.21.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 CHANGED
@@ -3,7 +3,7 @@ react-globe.gl
3
3
 
4
4
  [![NPM package][npm-img]][npm-url]
5
5
  [![Build Size][build-size-img]][build-size-url]
6
- [![Dependencies][dependencies-img]][dependencies-url]
6
+ [![NPM Downloads][npm-downloads-img]][npm-downloads-url]
7
7
 
8
8
  React bindings for the [globe.gl](https://github.com/vasturiano/globe.gl) UI component.
9
9
 
@@ -40,25 +40,26 @@ Check out the examples:
40
40
  * [World Volcanoes](https://vasturiano.github.io/react-globe.gl/example/volcanoes/) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/volcanoes/index.html))
41
41
  * [US outbound international airline routes](https://vasturiano.github.io/react-globe.gl/example/airline-routes/us-international-outbound.html) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/airline-routes/us-international-outbound.html))
42
42
  * [Earth Shield](https://vasturiano.github.io/react-globe.gl/example/earth-shield/) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/earth-shield/index.html))
43
+ * [Satellites](https://vasturiano.github.io/react-globe.gl/example/satellites/index.html) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/satellites/index.html))
43
44
  * [Submarine Cables](https://vasturiano.github.io/react-globe.gl/example/submarine-cables/index.html) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/submarine-cables/index.html))
44
45
  * [Moon Landing Sites](https://vasturiano.github.io/react-globe.gl/example/moon-landing-sites/index.html) ([source](https://github.com/vasturiano/react-globe.gl/blob/master/example/moon-landing-sites/index.html))
45
46
 
46
47
 
47
48
  ## Quick start
48
49
 
49
- ```
50
+ ```js
50
51
  import Globe from 'react-globe.gl';
51
52
  ```
52
53
 
53
54
  or using a script tag
54
55
 
55
- ```
56
+ ```html
56
57
  <script src="//unpkg.com/react-globe.gl"></script>
57
58
  ```
58
59
 
59
60
  then
60
61
 
61
- ```
62
+ ```jsx
62
63
  ReactDOM.render(
63
64
  <Globe
64
65
  pointsData={myData}
@@ -310,6 +311,24 @@ ReactDOM.render(
310
311
  | <b>onLabelRightClick</b> | <i>func</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 })`. |
311
312
  | <b>onLabelHover</b> | <i>func</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)`. |
312
313
 
314
+ ### Objects Layer
315
+
316
+ <p align="center">
317
+ <a href="//vasturiano.github.io/react-globe.gl/example/satellites/"><img width="70%" src="https://vasturiano.github.io/react-globe.gl/example/satellites/preview.png"></a>
318
+ </p>
319
+
320
+ | Prop | Type | Default | Description |
321
+ | --- | :--: | :--: | --- |
322
+ | <b>objectsData</b> | <i>array</i> | `[]` | Getter/setter for the list of custom 3D objects to represent in the objects layer. Each object is rendered according to the `objectThreeObject` method. |
323
+ | <b>objectLabel</b> | <i>string</i> or <i>func</i> | `name` | Object accessor function or attribute for its own tooltip label. Supports plain text or HTML content. |
324
+ | <b>objectLat</b> | <i>number</i>, <i>string</i> or <i>func</i> | `lat` | Object accessor function, attribute or a numeric constant for the latitude coordinate of the object's position. |
325
+ | <b>objectLng</b> | <i>number</i>, <i>string</i> or <i>func</i> | `lng` | Object accessor function, attribute or a numeric constant for the longitude coordinate of the object's position. |
326
+ | <b>objectAltitude</b> | <i>number</i>, <i>string</i> or <i>func</i> | 0.01 | Object accessor function, attribute or a numeric constant for the altitude coordinate of the object's position, in terms of globe radius units. |
327
+ | <b>objectThreeObject</b> | <i>Object3d</i>, <i>string</i> or <i>func</i> | *A yellow sphere* | Object accessor function or attribute for defining a custom 3d object to render as part of the objects map layer. Should return an instance of [ThreeJS Object3d](https://threejs.org/docs/index.html#api/core/Object3D). |
328
+ | <b>onObjectClick</b> | <i>func</i> | *-* | Callback function for object (left-button) clicks. The object itself, the event and the clicked coordinates are included as arguments: `onObjectClick(obj, event, { lat, lng, altitude })`. |
329
+ | <b>onObjectRightClick</b> | <i>func</i> | *-* | Callback function for object right-clicks. The object itself, the event and the clicked coordinates are included as arguments: `onObjectRightClick(obj, event, { lat, lng, altitude })`. |
330
+ | <b>onObjectHover</b> | <i>func</i> | *-* | Callback function for object mouse over events. The object itself (or `null` if there's no object under the mouse line of sight) is included as the first argument, and the previous object (or `null`) as second argument: `onObjectHover(obj, prevObj)`. |
331
+
313
332
  ### Custom Layer
314
333
 
315
334
  <p align="center">
@@ -320,8 +339,8 @@ ReactDOM.render(
320
339
  | --- | :--: | :--: | --- |
321
340
  | <b>customLayerData</b> | <i>array</i> | `[]` | List of items to represent in the custom map layer. Each item is rendered according to the `customThreeObject` method. |
322
341
  | <b>customLayerLabel</b> | <i>string</i> or <i>func</i> | `name` | Object accessor function or attribute for label (shown as tooltip). Supports plain text or HTML content. |
323
- | <b>customThreeObject</b> | <i>Object3d</i>, <i>string</i> or <i>func</i>| *-* |Object accessor function or attribute for generating a custom 3d object to render as part of the custom map layer. Should return an instance of [ThreeJS Object3d](https://threejs.org/docs/index.html#api/core/Object3D). The callback method's signature includes the object's data as well as the globe radius: `customThreeObject((objData, globeRadius) => { ... })`. |
324
- | <b>customThreeObjectUpdate</b> | <i>string</i> or <i>func</i>| *-* |Object accessor function or attribute for updating an existing custom 3d object with new data. This can be used for performance improvement on data updates as the objects don't need to be removed and recreated at each update. The callback method's signature includes the object to be update, its new data and the globe radius: `customThreeObjectUpdate((obj, objData, globeRadius) => { ... })`. |
342
+ | <b>customThreeObject</b> | <i>Object3d</i>, <i>string</i> or <i>func</i>| *-* |Object accessor function or attribute for generating a custom 3d object to render as part of the custom map layer. Should return an instance of [ThreeJS Object3d](https://threejs.org/docs/index.html#api/core/Object3D). |
343
+ | <b>customThreeObjectUpdate</b> | <i>string</i> or <i>func</i>| *-* |Object accessor function or attribute for updating an existing custom 3d object with new data. This can be used for performance improvement on data updates as the objects don't need to be removed and recreated at each update. The callback method's signature includes the object to be update and its new data: `customThreeObjectUpdate((obj, objData) => { ... })`. |
325
344
  | <b>onCustomLayerClick</b> | <i>func</i>| *-* | Callback function for custom object (left-button) clicks. The custom object, the event object and the clicked coordinates are included as arguments: `onCustomLayerClick(obj, event, { lat, lng, altitude })`. |
326
345
  | <b>onCustomLayerRightClick</b> | <i>func</i>| *-* | Callback function for custom object right-clicks. The custom object, the event object and the clicked coordinates are included as arguments: `onCustomLayerRightClick(obj, event, { lat, lng, altitude })`. |
327
346
  | <b>onCustomLayerHover</b> | <i>func</i>| *-* | Callback function for custom object mouse over events. The custom object (or `null` if there's no object under the mouse line of sight) is included as the first argument, and the previous custom object (or `null`) as second argument: `onCustomLayerHover(obj, prevObj)`. |
@@ -351,6 +370,7 @@ ReactDOM.render(
351
370
 
352
371
  | Method | Arguments | Description |
353
372
  | --- | :--: | --- |
373
+ | <b>getGlobeRadius</b> | *-* | Returns the cartesian distance of a globe radius in absolute spatial units. |
354
374
  | <b>getCoords</b> | <i>lat</i>, <i>lng</i> [,<i>altitude</i>=`0`] | Utility method to translate spherical coordinates to cartesian. Given a pair of latitude/longitude coordinates and optionally altitude (in terms of globe radius units), returns the equivalent `{x, y, z}` cartesian spatial coordinates. |
355
375
  | <b>getScreenCoords</b> | <i>lat</i>, <i>lng</i> [,<i>altitude</i>=`0`] | Utility method to translate spherical coordinates to the viewport domain. Given a pair of latitude/longitude coordinates and optionally altitude (in terms of globe radius units), returns the current equivalent `{x, y}` in viewport coordinates. |
356
376
  | <b>toGeoCoords</b> | { <i>x</i>, <i>y</i>, <i>z</i> } | Utility method to translate cartesian coordinates to the geographic domain. Given a set of 3D cartesian coordinates `{x, y, z}`, returns the equivalent `{lat, lng, altitude}` spherical coordinates. Altitude is defined in terms of globe radius units. |
@@ -360,9 +380,9 @@ ReactDOM.render(
360
380
 
361
381
  [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=L398E7PKP47E8&currency_code=USD&source=url) If this project has helped you and you'd like to contribute back, you can always [buy me a ☕](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=L398E7PKP47E8&currency_code=USD&source=url)!
362
382
 
363
- [npm-img]: https://img.shields.io/npm/v/react-globe.gl.svg
383
+ [npm-img]: https://img.shields.io/npm/v/react-globe.gl
364
384
  [npm-url]: https://npmjs.org/package/react-globe.gl
365
- [build-size-img]: https://img.shields.io/bundlephobia/minzip/react-globe.gl.svg
385
+ [build-size-img]: https://img.shields.io/bundlephobia/minzip/react-globe.gl
366
386
  [build-size-url]: https://bundlephobia.com/result?p=react-globe.gl
367
- [dependencies-img]: https://img.shields.io/david/vasturiano/react-globe.gl.svg
368
- [dependencies-url]: https://david-dm.org/vasturiano/react-globe.gl
387
+ [npm-downloads-img]: https://img.shields.io/npm/dt/react-globe.gl
388
+ [npm-downloads-url]: https://www.npmtrends.com/react-globe.gl
@@ -159,6 +159,15 @@ var GlobePropTypes = {
159
159
  onLabelClick: PropTypes__default["default"].func,
160
160
  onLabelRightClick: PropTypes__default["default"].func,
161
161
  onLabelHover: PropTypes__default["default"].func,
162
+ objectsData: PropTypes__default["default"].arrayOf(PropTypes__default["default"].object),
163
+ objectLat: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].string, PropTypes__default["default"].func]),
164
+ objectLng: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].string, PropTypes__default["default"].func]),
165
+ objectAltitude: PropTypes__default["default"].oneOfType([PropTypes__default["default"].number, PropTypes__default["default"].string, PropTypes__default["default"].func]),
166
+ objectThreeObject: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].func]),
167
+ objectLabel: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
168
+ onObjectClick: PropTypes__default["default"].func,
169
+ onObjectRightClick: PropTypes__default["default"].func,
170
+ onObjectHover: PropTypes__default["default"].func,
162
171
  customLayerData: PropTypes__default["default"].arrayOf(PropTypes__default["default"].object),
163
172
  customThreeObject: PropTypes__default["default"].oneOfType([PropTypes__default["default"].object, PropTypes__default["default"].string, PropTypes__default["default"].func]),
164
173
  customThreeObjectUpdate: PropTypes__default["default"].oneOfType([PropTypes__default["default"].string, PropTypes__default["default"].func]),
@@ -174,7 +183,7 @@ var GlobePropTypes = {
174
183
 
175
184
  var Globe = fromKapsule__default["default"](GlobeKapsule__default["default"], {
176
185
  methodNames: [// bind methods
177
- 'pauseAnimation', 'resumeAnimation', 'pointOfView', 'scene', 'camera', 'renderer', 'postProcessingComposer', 'controls', 'getCoords', 'getScreenCoords', 'toGeoCoords', 'toGlobeCoords'],
186
+ 'pauseAnimation', 'resumeAnimation', 'pointOfView', 'scene', 'camera', 'renderer', 'postProcessingComposer', 'controls', 'getGlobeRadius', 'getCoords', 'getScreenCoords', 'toGeoCoords', 'toGlobeCoords'],
178
187
  initPropNames: ['animateIn', 'waitForGlobeReady', 'rendererConfig']
179
188
  });
180
189
  Globe.displayName = 'Globe';
@@ -56,8 +56,8 @@ interface GlobeProps extends ConfigOptions {
56
56
  atmosphereAltitude?: number;
57
57
  globeMaterial?: Material;
58
58
  onGlobeReady?: () => void;
59
- onGlobeClick?: (coords: { lat, lng }, event: MouseEvent) => void;
60
- onGlobeRightClick?: (coords: { lat, lng }, event: MouseEvent) => void;
59
+ onGlobeClick?: (coords: { lat: number, lng: number }, event: MouseEvent) => void;
60
+ onGlobeRightClick?: (coords: { lat: number, lng: number }, event: MouseEvent) => void;
61
61
 
62
62
  // Points layer
63
63
  pointsData?: object[];
@@ -70,8 +70,8 @@ interface GlobeProps extends ConfigOptions {
70
70
  pointsMerge?: boolean;
71
71
  pointsTransitionDuration?: number;
72
72
  pointLabel?: ObjAccessor<string>;
73
- onPointClick?: (point: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
74
- onPointRightClick?: (point: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
73
+ onPointClick?: (point: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
74
+ onPointRightClick?: (point: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
75
75
  onPointHover?: (point: object | null, prevPoint: object | null) => void;
76
76
 
77
77
  // Arcs layer
@@ -92,8 +92,8 @@ interface GlobeProps extends ConfigOptions {
92
92
  arcDashAnimateTime?: ObjAccessor<number>;
93
93
  arcsTransitionDuration?: number;
94
94
  arcLabel?: ObjAccessor<string>;
95
- onArcClick?: (arc: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
96
- onArcRightClick?: (arc: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
95
+ onArcClick?: (arc: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
96
+ onArcRightClick?: (arc: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
97
97
  onArcHover?: (arc: object | null, prevArc: object | null) => void;
98
98
 
99
99
  // Polygons layer
@@ -108,8 +108,8 @@ interface GlobeProps extends ConfigOptions {
108
108
  polygonCapCurvatureResolution?: ObjAccessor<number>;
109
109
  polygonsTransitionDuration?: number;
110
110
  polygonLabel?: ObjAccessor<string>;
111
- onPolygonClick?: (polygon: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
112
- onPolygonRightClick?: (polygon: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
111
+ onPolygonClick?: (polygon: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
112
+ onPolygonRightClick?: (polygon: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
113
113
  onPolygonHover?: (polygon: object | null, prevPolygon: object | null) => void;
114
114
 
115
115
  // Paths layer
@@ -127,8 +127,8 @@ interface GlobeProps extends ConfigOptions {
127
127
  pathDashAnimateTime?: ObjAccessor<number>;
128
128
  pathTransitionDuration?: number;
129
129
  pathLabel?: ObjAccessor<string>;
130
- onPathClick?: (path: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
131
- onPathRightClick?: (path: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
130
+ onPathClick?: (path: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
131
+ onPathRightClick?: (path: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
132
132
  onPathHover?: (path: object | null, prevPath: object | null) => void;
133
133
 
134
134
  // Hex Bin layer
@@ -145,8 +145,8 @@ interface GlobeProps extends ConfigOptions {
145
145
  hexBinMerge?: boolean;
146
146
  hexTransitionDuration?: number;
147
147
  hexLabel?: HexBinAccessor<string>;
148
- onHexClick?: (hex: HexBin, event: MouseEvent, coords: { lat, lng, altitude }) => void;
149
- onHexRightClick?: (hex: HexBin, event: MouseEvent, coords: { lat, lng, altitude }) => void;
148
+ onHexClick?: (hex: HexBin, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
149
+ onHexRightClick?: (hex: HexBin, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
150
150
  onHexHover?: (hex: HexBin | null, prevHex: HexBin | null) => void;
151
151
 
152
152
  // Hexed Polygons layer
@@ -159,8 +159,8 @@ interface GlobeProps extends ConfigOptions {
159
159
  hexPolygonCurvatureResolution?: ObjAccessor<number>;
160
160
  hexPolygonsTransitionDuration?: number;
161
161
  hexPolygonLabel?: ObjAccessor<string>;
162
- onHexPolygonClick?: (polygon: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
163
- onHexPolygonRightClick?: (polygon: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
162
+ onHexPolygonClick?: (polygon: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
163
+ onHexPolygonRightClick?: (polygon: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
164
164
  onHexPolygonHover?: (polygon: object | null, prevPolygon: object | null) => void;
165
165
 
166
166
  // Tiles layer
@@ -175,8 +175,8 @@ interface GlobeProps extends ConfigOptions {
175
175
  tileCurvatureResolution?: ObjAccessor<number>;
176
176
  tilesTransitionDuration?: number;
177
177
  tileLabel?: ObjAccessor<string>;
178
- onTileClick?: (tile: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
179
- onTileRightClick?: (tile: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
178
+ onTileClick?: (tile: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
179
+ onTileRightClick?: (tile: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
180
180
  onTileHover?: (tile: object | null, prevTile: object | null) => void;
181
181
 
182
182
  // Rings Layer
@@ -206,17 +206,28 @@ interface GlobeProps extends ConfigOptions {
206
206
  labelDotOrientation?: ObjAccessor<LabelOrientation>;
207
207
  labelsTransitionDuration?: number;
208
208
  labelLabel?: ObjAccessor<string>;
209
- onLabelClick?: (label: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
210
- onLabelRightClick?: (label: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
209
+ onLabelClick?: (label: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
210
+ onLabelRightClick?: (label: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
211
211
  onLabelHover?: (label: object | null, prevLabel: object | null) => void;
212
212
 
213
+ // Objects layer
214
+ objectsData?: object[];
215
+ objectLat?: ObjAccessor<number>;
216
+ objectLng?: ObjAccessor<number>;
217
+ objectAltitude?: ObjAccessor<number>;
218
+ objectThreeObject?: Object3D | string | ((d: object) => Object3D);
219
+ objectLabel?: ObjAccessor<string>;
220
+ onObjectClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
221
+ onObjectRightClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
222
+ onObjectHover?: (obj: object | null, prevObj: object | null) => void;
223
+
213
224
  // Custom layer
214
225
  customLayerData?: object[];
215
- customThreeObject?: Object3D | string | ((d: object, globeRadius: number) => Object3D);
216
- customThreeObjectUpdate?: string | ((obj: Object3D, objData: object, globeRadius: number) => void);
226
+ customThreeObject?: Object3D | string | ((d: object) => Object3D);
227
+ customThreeObjectUpdate?: string | ((obj: Object3D, objData: object) => void);
217
228
  customLayerLabel?: ObjAccessor<string>;
218
- onCustomLayerClick?: (obj: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
219
- onCustomLayerRightClick?: (obj: object, event: MouseEvent, coords: { lat, lng, altitude }) => void;
229
+ onCustomLayerClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
230
+ onCustomLayerRightClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
220
231
  onCustomLayerHover?: (obj: object | null, prevObj: object | null) => void;
221
232
 
222
233
  // Render control
@@ -239,6 +250,7 @@ interface GlobeMethods {
239
250
  controls(): object;
240
251
 
241
252
  // Utilities
253
+ getGlobeRadius(): number;
242
254
  getCoords(lat: number, lng: number, altitude?: number): CartesianCoords;
243
255
  getScreenCoords(lat: number, lng: number, altitude?: number): ScreenCoords;
244
256
  toGeoCoords(coords: CartesianCoords): GeoCoords;