react-globe.gl 2.20.4 → 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 +22 -2
- package/dist/react-globe.gl.common.js +10 -1
- package/dist/react-globe.gl.d.ts +14 -2
- package/dist/react-globe.gl.js +255 -148
- package/dist/react-globe.gl.js.map +1 -1
- package/dist/react-globe.gl.min.js +4 -4
- package/dist/react-globe.gl.module.js +10 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -40,6 +40,7 @@ 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
|
|
|
@@ -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).
|
|
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
|
|
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. |
|
|
@@ -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';
|
package/dist/react-globe.gl.d.ts
CHANGED
|
@@ -210,10 +210,21 @@ interface GlobeProps extends ConfigOptions {
|
|
|
210
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
|
|
216
|
-
customThreeObjectUpdate?: string | ((obj: Object3D, objData: object
|
|
226
|
+
customThreeObject?: Object3D | string | ((d: object) => Object3D);
|
|
227
|
+
customThreeObjectUpdate?: string | ((obj: Object3D, objData: object) => void);
|
|
217
228
|
customLayerLabel?: ObjAccessor<string>;
|
|
218
229
|
onCustomLayerClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
|
|
219
230
|
onCustomLayerRightClick?: (obj: object, event: MouseEvent, coords: { lat: number, lng: number, altitude: number }) => void;
|
|
@@ -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;
|