globe.gl 2.26.12 → 2.27.1

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,731 +0,0 @@
1
- 'use strict';
2
-
3
- var three = require('three');
4
- var CSS2DRenderer_js = require('three/examples/jsm/renderers/CSS2DRenderer.js');
5
- var ThreeGlobe = require('three-globe');
6
- var ThreeRenderObjects = require('three-render-objects');
7
- var accessorFn = require('accessor-fn');
8
- var Kapsule = require('kapsule');
9
- var TWEEN = require('@tweenjs/tween.js');
10
-
11
- function styleInject(css, ref) {
12
- if (ref === void 0) ref = {};
13
- var insertAt = ref.insertAt;
14
- if (!css || typeof document === 'undefined') {
15
- return;
16
- }
17
- var head = document.head || document.getElementsByTagName('head')[0];
18
- var style = document.createElement('style');
19
- style.type = 'text/css';
20
- if (insertAt === 'top') {
21
- if (head.firstChild) {
22
- head.insertBefore(style, head.firstChild);
23
- } else {
24
- head.appendChild(style);
25
- }
26
- } else {
27
- head.appendChild(style);
28
- }
29
- if (style.styleSheet) {
30
- style.styleSheet.cssText = css;
31
- } else {
32
- style.appendChild(document.createTextNode(css));
33
- }
34
- }
35
-
36
- var css_248z = ".scene-container .clickable {\n cursor: pointer;\n}";
37
- styleInject(css_248z);
38
-
39
- function ownKeys(object, enumerableOnly) {
40
- var keys = Object.keys(object);
41
- if (Object.getOwnPropertySymbols) {
42
- var symbols = Object.getOwnPropertySymbols(object);
43
- enumerableOnly && (symbols = symbols.filter(function (sym) {
44
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
45
- })), keys.push.apply(keys, symbols);
46
- }
47
- return keys;
48
- }
49
- function _objectSpread2(target) {
50
- for (var i = 1; i < arguments.length; i++) {
51
- var source = null != arguments[i] ? arguments[i] : {};
52
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
53
- _defineProperty(target, key, source[key]);
54
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
55
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
56
- });
57
- }
58
- return target;
59
- }
60
- function _defineProperty(obj, key, value) {
61
- key = _toPropertyKey(key);
62
- if (key in obj) {
63
- Object.defineProperty(obj, key, {
64
- value: value,
65
- enumerable: true,
66
- configurable: true,
67
- writable: true
68
- });
69
- } else {
70
- obj[key] = value;
71
- }
72
- return obj;
73
- }
74
- function _objectWithoutPropertiesLoose(source, excluded) {
75
- if (source == null) return {};
76
- var target = {};
77
- var sourceKeys = Object.keys(source);
78
- var key, i;
79
- for (i = 0; i < sourceKeys.length; i++) {
80
- key = sourceKeys[i];
81
- if (excluded.indexOf(key) >= 0) continue;
82
- target[key] = source[key];
83
- }
84
- return target;
85
- }
86
- function _objectWithoutProperties(source, excluded) {
87
- if (source == null) return {};
88
- var target = _objectWithoutPropertiesLoose(source, excluded);
89
- var key, i;
90
- if (Object.getOwnPropertySymbols) {
91
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
92
- for (i = 0; i < sourceSymbolKeys.length; i++) {
93
- key = sourceSymbolKeys[i];
94
- if (excluded.indexOf(key) >= 0) continue;
95
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
96
- target[key] = source[key];
97
- }
98
- }
99
- return target;
100
- }
101
- function _toConsumableArray(arr) {
102
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
103
- }
104
- function _arrayWithoutHoles(arr) {
105
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
106
- }
107
- function _iterableToArray(iter) {
108
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
109
- }
110
- function _unsupportedIterableToArray(o, minLen) {
111
- if (!o) return;
112
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
113
- var n = Object.prototype.toString.call(o).slice(8, -1);
114
- if (n === "Object" && o.constructor) n = o.constructor.name;
115
- if (n === "Map" || n === "Set") return Array.from(o);
116
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
117
- }
118
- function _arrayLikeToArray(arr, len) {
119
- if (len == null || len > arr.length) len = arr.length;
120
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
121
- return arr2;
122
- }
123
- function _nonIterableSpread() {
124
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
125
- }
126
- function _toPrimitive(input, hint) {
127
- if (typeof input !== "object" || input === null) return input;
128
- var prim = input[Symbol.toPrimitive];
129
- if (prim !== undefined) {
130
- var res = prim.call(input, hint || "default");
131
- if (typeof res !== "object") return res;
132
- throw new TypeError("@@toPrimitive must return a primitive value.");
133
- }
134
- return (hint === "string" ? String : Number)(input);
135
- }
136
- function _toPropertyKey(arg) {
137
- var key = _toPrimitive(arg, "string");
138
- return typeof key === "symbol" ? key : String(key);
139
- }
140
-
141
- function linkKapsule (kapsulePropName, kapsuleType) {
142
- var dummyK = new kapsuleType(); // To extract defaults
143
-
144
- return {
145
- linkProp: function linkProp(prop) {
146
- // link property config
147
- return {
148
- "default": dummyK[prop](),
149
- onChange: function onChange(v, state) {
150
- state[kapsulePropName][prop](v);
151
- },
152
- triggerUpdate: false
153
- };
154
- },
155
- linkMethod: function linkMethod(method) {
156
- // link method pass-through
157
- return function (state) {
158
- var kapsuleInstance = state[kapsulePropName];
159
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
160
- args[_key - 1] = arguments[_key];
161
- }
162
- var returnVal = kapsuleInstance[method].apply(kapsuleInstance, args);
163
- return returnVal === kapsuleInstance ? this // chain based on the parent object, not the inner kapsule
164
- : returnVal;
165
- };
166
- }
167
- };
168
- }
169
-
170
- var _excluded = ["rendererConfig", "waitForGlobeReady"];
171
- var THREE = _objectSpread2(_objectSpread2({}, window.THREE ? window.THREE // Prefer consumption from global THREE, if exists
172
- : {
173
- AmbientLight: three.AmbientLight,
174
- DirectionalLight: three.DirectionalLight,
175
- Vector2: three.Vector2
176
- }), {}, {
177
- CSS2DRenderer: CSS2DRenderer_js.CSS2DRenderer
178
- });
179
-
180
- //
181
-
182
- // Expose config from ThreeGlobe
183
- var bindGlobe = linkKapsule('globe', ThreeGlobe);
184
- 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) {
185
- return _defineProperty({}, p, bindGlobe.linkProp(p));
186
- })));
187
- var linkedGlobeMethods = Object.assign.apply(Object, _toConsumableArray(['getGlobeRadius', 'getCoords', 'toGeoCoords'].map(function (p) {
188
- return _defineProperty({}, p, bindGlobe.linkMethod(p));
189
- })));
190
-
191
- // Expose config from renderObjs
192
- var bindRenderObjs = linkKapsule('renderObjs', ThreeRenderObjects);
193
- var linkedRenderObjsProps = Object.assign.apply(Object, _toConsumableArray(['width', 'height', 'backgroundColor', 'backgroundImageUrl', 'enablePointerInteraction'].map(function (p) {
194
- return _defineProperty({}, p, bindRenderObjs.linkProp(p));
195
- })));
196
- var linkedRenderObjsMethods = Object.assign.apply(Object, _toConsumableArray(['postProcessingComposer'].map(function (p) {
197
- return _defineProperty({}, p, bindRenderObjs.linkMethod(p));
198
- })));
199
-
200
- //
201
-
202
- var globe = Kapsule({
203
- props: _objectSpread2(_objectSpread2({
204
- onZoom: {
205
- triggerUpdate: false
206
- },
207
- onGlobeClick: {
208
- triggerUpdate: false
209
- },
210
- onGlobeRightClick: {
211
- triggerUpdate: false
212
- },
213
- pointLabel: {
214
- "default": 'name',
215
- triggerUpdate: false
216
- },
217
- onPointClick: {
218
- triggerUpdate: false
219
- },
220
- onPointRightClick: {
221
- triggerUpdate: false
222
- },
223
- onPointHover: {
224
- triggerUpdate: false
225
- },
226
- arcLabel: {
227
- "default": 'name',
228
- triggerUpdate: false
229
- },
230
- onArcClick: {
231
- triggerUpdate: false
232
- },
233
- onArcRightClick: {
234
- triggerUpdate: false
235
- },
236
- onArcHover: {
237
- triggerUpdate: false
238
- },
239
- polygonLabel: {
240
- "default": 'name',
241
- triggerUpdate: false
242
- },
243
- onPolygonClick: {
244
- triggerUpdate: false
245
- },
246
- onPolygonRightClick: {
247
- triggerUpdate: false
248
- },
249
- onPolygonHover: {
250
- triggerUpdate: false
251
- },
252
- pathLabel: {
253
- "default": 'name',
254
- triggerUpdate: false
255
- },
256
- onPathClick: {
257
- triggerUpdate: false
258
- },
259
- onPathRightClick: {
260
- triggerUpdate: false
261
- },
262
- onPathHover: {
263
- triggerUpdate: false
264
- },
265
- hexLabel: {
266
- triggerUpdate: false
267
- },
268
- onHexClick: {
269
- triggerUpdate: false
270
- },
271
- onHexRightClick: {
272
- triggerUpdate: false
273
- },
274
- onHexHover: {
275
- triggerUpdate: false
276
- },
277
- hexPolygonLabel: {
278
- triggerUpdate: false
279
- },
280
- onHexPolygonClick: {
281
- triggerUpdate: false
282
- },
283
- onHexPolygonRightClick: {
284
- triggerUpdate: false
285
- },
286
- onHexPolygonHover: {
287
- triggerUpdate: false
288
- },
289
- tileLabel: {
290
- "default": 'name',
291
- triggerUpdate: false
292
- },
293
- onTileClick: {
294
- triggerUpdate: false
295
- },
296
- onTileRightClick: {
297
- triggerUpdate: false
298
- },
299
- onTileHover: {
300
- triggerUpdate: false
301
- },
302
- labelLabel: {
303
- triggerUpdate: false
304
- },
305
- onLabelClick: {
306
- triggerUpdate: false
307
- },
308
- onLabelRightClick: {
309
- triggerUpdate: false
310
- },
311
- onLabelHover: {
312
- triggerUpdate: false
313
- },
314
- objectLabel: {
315
- "default": 'name',
316
- triggerUpdate: false
317
- },
318
- onObjectClick: {
319
- triggerUpdate: false
320
- },
321
- onObjectRightClick: {
322
- triggerUpdate: false
323
- },
324
- onObjectHover: {
325
- triggerUpdate: false
326
- },
327
- customLayerLabel: {
328
- "default": 'name',
329
- triggerUpdate: false
330
- },
331
- onCustomLayerClick: {
332
- triggerUpdate: false
333
- },
334
- onCustomLayerRightClick: {
335
- triggerUpdate: false
336
- },
337
- onCustomLayerHover: {
338
- triggerUpdate: false
339
- },
340
- pointerEventsFilter: {
341
- "default": function _default() {
342
- return true;
343
- },
344
- triggerUpdate: false,
345
- onChange: function onChange(filterFn, state) {
346
- return state.renderObjs.hoverFilter(function (obj) {
347
- return filterFn(obj, obj.__data);
348
- });
349
- }
350
- },
351
- lineHoverPrecision: {
352
- "default": 0.2,
353
- triggerUpdate: false,
354
- onChange: function onChange(val, state) {
355
- return state.renderObjs.lineHoverPrecision(val);
356
- }
357
- }
358
- }, linkedGlobeProps), linkedRenderObjsProps),
359
- methods: _objectSpread2(_objectSpread2({
360
- pauseAnimation: function pauseAnimation(state) {
361
- if (state.animationFrameRequestId !== null) {
362
- cancelAnimationFrame(state.animationFrameRequestId);
363
- state.animationFrameRequestId = null;
364
- }
365
- return this;
366
- },
367
- resumeAnimation: function resumeAnimation(state) {
368
- if (state.animationFrameRequestId === null) {
369
- this._animationCycle();
370
- }
371
- return this;
372
- },
373
- _animationCycle: function _animationCycle(state) {
374
- // Frame cycle
375
- state.renderObjs.tick();
376
- state.animationFrameRequestId = requestAnimationFrame(this._animationCycle);
377
- },
378
- pointOfView: function pointOfView(state) {
379
- var geoCoords = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
380
- var transitionDuration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
381
- var curGeoCoords = getGeoCoords();
382
-
383
- // Getter
384
- if (geoCoords.lat === undefined && geoCoords.lng === undefined && geoCoords.altitude === undefined) {
385
- return curGeoCoords;
386
- } else {
387
- // Setter
388
- var finalGeoCoords = Object.assign({}, curGeoCoords, geoCoords);
389
- ['lat', 'lng', 'altitude'].forEach(function (p) {
390
- return finalGeoCoords[p] = +finalGeoCoords[p];
391
- }); // coerce coords to number
392
-
393
- if (!transitionDuration) {
394
- // no animation
395
- setCameraPos(finalGeoCoords);
396
- } else {
397
- // Avoid rotating more than 180deg longitude
398
- while (curGeoCoords.lng - finalGeoCoords.lng > 180) curGeoCoords.lng -= 360;
399
- while (curGeoCoords.lng - finalGeoCoords.lng < -180) curGeoCoords.lng += 360;
400
- new TWEEN.Tween(curGeoCoords).to(finalGeoCoords, transitionDuration).easing(TWEEN.Easing.Cubic.InOut).onUpdate(setCameraPos).start();
401
- }
402
- return this;
403
- }
404
-
405
- //
406
-
407
- function getGeoCoords() {
408
- return state.globe.toGeoCoords(state.renderObjs.cameraPosition());
409
- }
410
- function setCameraPos(_ref5) {
411
- var lat = _ref5.lat,
412
- lng = _ref5.lng,
413
- altitude = _ref5.altitude;
414
- state.renderObjs.cameraPosition(state.globe.getCoords(lat, lng, altitude));
415
- }
416
- },
417
- getScreenCoords: function getScreenCoords(state) {
418
- var _state$globe;
419
- for (var _len = arguments.length, geoCoords = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
420
- geoCoords[_key - 1] = arguments[_key];
421
- }
422
- var cartesianCoords = (_state$globe = state.globe).getCoords.apply(_state$globe, geoCoords);
423
- return state.renderObjs.getScreenCoords(cartesianCoords.x, cartesianCoords.y, cartesianCoords.z);
424
- },
425
- toGlobeCoords: function toGlobeCoords(state, x, y) {
426
- var globeIntersects = state.renderObjs.intersectingObjects(x, y).find(function (d) {
427
- return d.object.__globeObjType === 'globe';
428
- });
429
- if (!globeIntersects) return null; // coords outside globe
430
-
431
- var _state$globe$toGeoCoo = state.globe.toGeoCoords(globeIntersects.point),
432
- lat = _state$globe$toGeoCoo.lat,
433
- lng = _state$globe$toGeoCoo.lng;
434
- return {
435
- lat: lat,
436
- lng: lng
437
- };
438
- },
439
- scene: function scene(state) {
440
- return state.renderObjs.scene();
441
- },
442
- // Expose scene
443
- camera: function camera(state) {
444
- return state.renderObjs.camera();
445
- },
446
- // Expose camera
447
- renderer: function renderer(state) {
448
- return state.renderObjs.renderer();
449
- },
450
- // Expose renderer
451
- controls: function controls(state) {
452
- return state.renderObjs.controls();
453
- },
454
- // Expose controls
455
- _destructor: function _destructor() {
456
- this.pauseAnimation();
457
- this.pointsData([]);
458
- this.arcsData([]);
459
- this.polygonsData([]);
460
- this.pathsData([]);
461
- this.hexBinPointsData([]);
462
- this.hexPolygonsData([]);
463
- this.tilesData([]);
464
- this.labelsData([]);
465
- this.htmlElementsData([]);
466
- this.objectsData([]);
467
- this.customLayerData([]);
468
- }
469
- }, linkedGlobeMethods), linkedRenderObjsMethods),
470
- stateInit: function stateInit(_ref6) {
471
- var rendererConfig = _ref6.rendererConfig,
472
- _ref6$waitForGlobeRea = _ref6.waitForGlobeReady,
473
- waitForGlobeReady = _ref6$waitForGlobeRea === void 0 ? true : _ref6$waitForGlobeRea,
474
- globeInitConfig = _objectWithoutProperties(_ref6, _excluded);
475
- var globe = new ThreeGlobe(_objectSpread2({
476
- waitForGlobeReady: waitForGlobeReady
477
- }, globeInitConfig));
478
- return {
479
- globe: globe,
480
- renderObjs: ThreeRenderObjects({
481
- controlType: 'orbit',
482
- rendererConfig: rendererConfig,
483
- waitForLoadComplete: waitForGlobeReady,
484
- extraRenderers: [new THREE.CSS2DRenderer()] // Used in HTML elements layer
485
- }).skyRadius(globe.getGlobeRadius() * 500).showNavInfo(false)
486
- };
487
- },
488
- init: function init(domNode, state) {
489
- var _this = this;
490
- // Wipe DOM
491
- domNode.innerHTML = '';
492
-
493
- // Add relative container
494
- domNode.appendChild(state.container = document.createElement('div'));
495
- state.container.style.position = 'relative';
496
-
497
- // Add renderObjs
498
- var roDomNode = document.createElement('div');
499
- state.container.appendChild(roDomNode);
500
- state.renderObjs(roDomNode);
501
-
502
- // inject renderer size on three-globe
503
- state.globe.rendererSize(state.renderObjs.renderer().getSize(new THREE.Vector2()));
504
-
505
- // set initial distance
506
- this.pointOfView({
507
- altitude: 2.5
508
- });
509
-
510
- // calibrate orbit controls
511
- var globeR = state.globe.getGlobeRadius();
512
- var controls = state.renderObjs.controls();
513
- controls.minDistance = globeR * 1.01; // just above the surface
514
- controls.maxDistance = globeR * 100;
515
- controls.enablePan = false;
516
- controls.enableDamping = true;
517
- controls.dampingFactor = 0.1;
518
- controls.rotateSpeed = 0.3;
519
- controls.zoomSpeed = 0.3;
520
- controls.addEventListener('change', function () {
521
- // adjust controls speed based on altitude
522
- var pov = _this.pointOfView();
523
- controls.rotateSpeed = pov.altitude * 0.2; // Math.pow(pov.altitude + 1, 2) * 0.025;
524
- controls.zoomSpeed = (pov.altitude + 1) * 0.1; // Math.sqrt(pov.altitude) * 0.2;
525
-
526
- // Update three-globe pov when camera moves, for proper hiding of elements
527
- state.globe.setPointOfView(state.renderObjs.camera().position);
528
- state.onZoom && state.onZoom(pov);
529
- });
530
-
531
- // config renderObjs
532
- var getGlobeObj = function getGlobeObj(object) {
533
- var obj = object;
534
- // recurse up object chain until finding the globe object
535
- while (obj && !obj.hasOwnProperty('__globeObjType')) {
536
- obj = obj.parent;
537
- }
538
- return obj;
539
- };
540
- var dataAccessors = {
541
- point: function point(d) {
542
- return d;
543
- },
544
- arc: function arc(d) {
545
- return d;
546
- },
547
- polygon: function polygon(d) {
548
- return d.data;
549
- },
550
- path: function path(d) {
551
- return d;
552
- },
553
- hexbin: function hexbin(d) {
554
- return d;
555
- },
556
- hexPolygon: function hexPolygon(d) {
557
- return d;
558
- },
559
- tile: function tile(d) {
560
- return d;
561
- },
562
- label: function label(d) {
563
- return d;
564
- },
565
- object: function object(d) {
566
- return d;
567
- },
568
- custom: function custom(d) {
569
- return d;
570
- }
571
- };
572
- state.renderObjs.objects([
573
- // Populate scene
574
- new THREE.AmbientLight(0xbbbbbb), new THREE.DirectionalLight(0xffffff, 0.6), state.globe]).hoverOrderComparator(function (a, b) {
575
- var aObj = getGlobeObj(a);
576
- var bObj = getGlobeObj(b);
577
-
578
- // de-prioritize background / non-globe objects
579
- var isBackground = function isBackground(o) {
580
- return !o;
581
- }; // || o.__globeObjType === 'globe' || o.__globeObjType === 'atmosphere';
582
- return isBackground(aObj) - isBackground(bObj);
583
- }).tooltipContent(function (obj) {
584
- var objAccessors = {
585
- point: state.pointLabel,
586
- arc: state.arcLabel,
587
- polygon: state.polygonLabel,
588
- path: state.pathLabel,
589
- hexbin: state.hexLabel,
590
- hexPolygon: state.hexPolygonLabel,
591
- tile: state.tileLabel,
592
- label: state.labelLabel,
593
- object: state.objectLabel,
594
- custom: state.customLayerLabel
595
- };
596
- var globeObj = getGlobeObj(obj);
597
- var objType = globeObj && globeObj.__globeObjType;
598
- return globeObj && objType && objAccessors.hasOwnProperty(objType) && dataAccessors.hasOwnProperty(objType) ? accessorFn(objAccessors[objType])(dataAccessors[objType](globeObj.__data)) || '' : '';
599
- }).onHover(function (obj) {
600
- // Update tooltip and trigger onHover events
601
- var hoverObjFns = {
602
- point: state.onPointHover,
603
- arc: state.onArcHover,
604
- polygon: state.onPolygonHover,
605
- path: state.onPathHover,
606
- hexbin: state.onHexHover,
607
- hexPolygon: state.onHexPolygonHover,
608
- tile: state.onTileHover,
609
- label: state.onLabelHover,
610
- object: state.onObjectHover,
611
- custom: state.onCustomLayerHover
612
- };
613
- var clickObjFns = {
614
- globe: state.onGlobeClick,
615
- point: state.onPointClick,
616
- arc: state.onArcClick,
617
- polygon: state.onPolygonClick,
618
- path: state.onPathClick,
619
- hexbin: state.onHexClick,
620
- hexPolygon: state.onHexPolygonClick,
621
- tile: state.onTileClick,
622
- label: state.onLabelClick,
623
- object: state.onObjectClick,
624
- custom: state.onCustomLayerClick
625
- };
626
- var hoverObj = getGlobeObj(obj);
627
-
628
- // ignore non-recognised obj types
629
- hoverObj && !hoverObjFns.hasOwnProperty(hoverObj.__globeObjType) && (hoverObj = null);
630
- if (hoverObj !== state.hoverObj) {
631
- var prevObjType = state.hoverObj ? state.hoverObj.__globeObjType : null;
632
- var prevObjData = state.hoverObj ? dataAccessors[prevObjType](state.hoverObj.__data) : null;
633
- var objType = hoverObj ? hoverObj.__globeObjType : null;
634
- var objData = hoverObj ? dataAccessors[objType](hoverObj.__data) : null;
635
- if (prevObjType && prevObjType !== objType) {
636
- // Hover out
637
- hoverObjFns[prevObjType] && hoverObjFns[prevObjType](null, prevObjData);
638
- }
639
- if (objType) {
640
- // Hover in
641
- hoverObjFns[objType] && hoverObjFns[objType](objData, prevObjType === objType ? prevObjData : null);
642
- }
643
-
644
- // set pointer if hovered object is clickable
645
- state.renderObjs.renderer().domElement.classList[objType && clickObjFns[objType] ? 'add' : 'remove']('clickable');
646
- state.hoverObj = hoverObj;
647
- }
648
- }).onClick(function (obj, ev, point) {
649
- if (!obj) return; // ignore background clicks
650
-
651
- // Handle click events on objects
652
- var objFns = {
653
- globe: state.onGlobeClick,
654
- point: state.onPointClick,
655
- arc: state.onArcClick,
656
- polygon: state.onPolygonClick,
657
- path: state.onPathClick,
658
- hexbin: state.onHexClick,
659
- hexPolygon: state.onHexPolygonClick,
660
- tile: state.onTileClick,
661
- label: state.onLabelClick,
662
- object: state.onObjectClick,
663
- custom: state.onCustomLayerClick
664
- };
665
- var globeObj = getGlobeObj(obj);
666
- var objType = globeObj.__globeObjType;
667
- if (globeObj && objFns.hasOwnProperty(objType) && objFns[objType]) {
668
- var args = [ev];
669
-
670
- // include click coords
671
- if (objType === 'globe') {
672
- var _this$toGeoCoords = _this.toGeoCoords(point),
673
- lat = _this$toGeoCoords.lat,
674
- lng = _this$toGeoCoords.lng;
675
- args.unshift({
676
- lat: lat,
677
- lng: lng
678
- });
679
- } else {
680
- args.push(_this.toGeoCoords(point));
681
- }
682
- dataAccessors.hasOwnProperty(objType) && args.unshift(dataAccessors[objType](globeObj.__data));
683
- objFns[objType].apply(objFns, args);
684
- }
685
- }).onRightClick(function (obj, ev, point) {
686
- if (!obj) return; // ignore background clicks
687
-
688
- // Handle right-click events
689
- var objFns = {
690
- globe: state.onGlobeRightClick,
691
- point: state.onPointRightClick,
692
- arc: state.onArcRightClick,
693
- polygon: state.onPolygonRightClick,
694
- path: state.onPathRightClick,
695
- hexbin: state.onHexRightClick,
696
- hexPolygon: state.onHexPolygonRightClick,
697
- tile: state.onTileRightClick,
698
- label: state.onLabelRightClick,
699
- object: state.onObjectRightClick,
700
- custom: state.onCustomLayerRightClick
701
- };
702
- var globeObj = getGlobeObj(obj);
703
- var objType = globeObj.__globeObjType;
704
- if (globeObj && objFns.hasOwnProperty(objType) && objFns[objType]) {
705
- var args = [ev];
706
-
707
- // include click coords
708
- if (objType === 'globe') {
709
- var _this$toGeoCoords2 = _this.toGeoCoords(point),
710
- lat = _this$toGeoCoords2.lat,
711
- lng = _this$toGeoCoords2.lng;
712
- args.unshift({
713
- lat: lat,
714
- lng: lng
715
- });
716
- } else {
717
- args.push(_this.toGeoCoords(point));
718
- }
719
- dataAccessors.hasOwnProperty(objType) && args.unshift(dataAccessors[objType](globeObj.__data));
720
- objFns[objType].apply(objFns, args);
721
- }
722
- });
723
-
724
- //
725
-
726
- // Kick-off renderer
727
- this._animationCycle();
728
- }
729
- });
730
-
731
- module.exports = globe;