@dxos/react-ui-geo 0.8.4-staging.ac66bdf99f → 0.9.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/LICENSE +102 -5
- package/data/countries-10m.ts +12 -0
- package/data/countries-110m.ts +4 -10579
- package/data/countries-50m.ts +12 -0
- package/dist/lib/browser/chunk-SC2FBYFU.mjs +17 -0
- package/dist/lib/browser/chunk-SC2FBYFU.mjs.map +7 -0
- package/dist/lib/browser/countries-10m-CWWDOKH7.mjs +6 -0
- package/dist/lib/browser/countries-10m-CWWDOKH7.mjs.map +7 -0
- package/dist/lib/browser/countries-110m-72QBAA5E.mjs +6 -0
- package/dist/lib/browser/countries-110m-72QBAA5E.mjs.map +7 -0
- package/dist/lib/browser/countries-50m-H7SL7KVF.mjs +6 -0
- package/dist/lib/browser/countries-50m-H7SL7KVF.mjs.map +7 -0
- package/dist/lib/browser/data.mjs +1 -1
- package/dist/lib/browser/index.mjs +774 -223
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +19 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VZENBYLJ.mjs +19 -0
- package/dist/lib/node-esm/chunk-VZENBYLJ.mjs.map +7 -0
- package/dist/lib/node-esm/countries-10m-DJZV66KG.mjs +8 -0
- package/dist/lib/node-esm/countries-10m-DJZV66KG.mjs.map +7 -0
- package/dist/lib/node-esm/countries-110m-H3WY6K4Q.mjs +8 -0
- package/dist/lib/node-esm/countries-110m-H3WY6K4Q.mjs.map +7 -0
- package/dist/lib/node-esm/countries-50m-ZY7Z3IWD.mjs +8 -0
- package/dist/lib/node-esm/countries-50m-ZY7Z3IWD.mjs.map +7 -0
- package/dist/lib/node-esm/data.mjs +1 -1
- package/dist/lib/node-esm/index.mjs +774 -223
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +21 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/data/airports.d.ts +4 -4
- package/dist/types/data/airports.d.ts.map +1 -1
- package/dist/types/data/cities.d.ts.map +1 -1
- package/dist/types/data/countries-10m.d.ts +8 -0
- package/dist/types/data/countries-10m.d.ts.map +1 -0
- package/dist/types/data/countries-110m.d.ts +2 -30
- package/dist/types/data/countries-110m.d.ts.map +1 -1
- package/dist/types/data/countries-50m.d.ts +8 -0
- package/dist/types/data/countries-50m.d.ts.map +1 -0
- package/dist/types/data/countries-dots-3.d.ts.map +1 -1
- package/dist/types/data/countries-dots-4.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +18 -10
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +16 -8
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +49 -13
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +9 -5
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/data.d.ts +9 -1
- package/dist/types/src/data.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +37 -0
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrag.d.ts +22 -2
- package/dist/types/src/hooks/useDrag.d.ts.map +1 -1
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts +3 -2
- package/dist/types/src/hooks/useGlobeZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts +1 -1
- package/dist/types/src/hooks/useMapZoomHandler.d.ts.map +1 -1
- package/dist/types/src/hooks/useSimplifiedTopology.d.ts +32 -0
- package/dist/types/src/hooks/useSimplifiedTopology.d.ts.map +1 -0
- package/dist/types/src/hooks/useSpinner.d.ts +1 -1
- package/dist/types/src/hooks/useSpinner.d.ts.map +1 -1
- package/dist/types/src/hooks/useTopology.d.ts +26 -0
- package/dist/types/src/hooks/useTopology.d.ts.map +1 -0
- package/dist/types/src/hooks/useTour.d.ts +3 -2
- package/dist/types/src/hooks/useTour.d.ts.map +1 -1
- package/dist/types/src/hooks/useWheel.d.ts +24 -0
- package/dist/types/src/hooks/useWheel.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +0 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +4 -4
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util/animation.d.ts +16 -0
- package/dist/types/src/util/animation.d.ts.map +1 -0
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/index.d.ts +2 -0
- package/dist/types/src/util/index.d.ts.map +1 -1
- package/dist/types/src/util/inertia.d.ts.map +1 -1
- package/dist/types/src/util/path.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts +25 -1
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/dist/types/src/util/styles.d.ts +4 -0
- package/dist/types/src/util/styles.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -24
- package/src/components/Globe/Globe.stories.tsx +135 -58
- package/src/components/Globe/Globe.tsx +237 -120
- package/src/components/Map/Map.stories.tsx +58 -12
- package/src/components/Map/Map.tsx +293 -91
- package/src/components/Toolbar/Controls.tsx +1 -1
- package/src/data.ts +19 -2
- package/src/hooks/context.tsx +44 -0
- package/src/hooks/index.ts +3 -0
- package/src/hooks/useDrag.ts +33 -5
- package/src/hooks/useGlobeZoomHandler.ts +2 -1
- package/src/hooks/useSimplifiedTopology.ts +81 -0
- package/src/hooks/useSpinner.ts +1 -1
- package/src/hooks/useTopology.ts +95 -0
- package/src/hooks/useTour.ts +70 -81
- package/src/hooks/useWheel.ts +83 -0
- package/src/index.ts +0 -2
- package/src/util/animation.ts +35 -0
- package/src/util/index.ts +2 -0
- package/src/util/inertia.ts +87 -4
- package/src/util/render.ts +105 -16
- package/src/util/styles.ts +62 -0
- package/dist/lib/browser/chunk-GMWLKTLN.mjs +0 -9
- package/dist/lib/browser/chunk-GMWLKTLN.mjs.map +0 -7
- package/dist/lib/browser/countries-110m-ZM3ZIEFS.mjs +0 -37859
- package/dist/lib/browser/countries-110m-ZM3ZIEFS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JODBF4CC.mjs +0 -11
- package/dist/lib/node-esm/chunk-JODBF4CC.mjs.map +0 -7
- package/dist/lib/node-esm/countries-110m-3SFASWVD.mjs +0 -37861
- package/dist/lib/node-esm/countries-110m-3SFASWVD.mjs.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-geo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Geo components.",
|
|
5
5
|
"homepage": "https://github.com/dxos",
|
|
6
6
|
"bugs": "https://github.com/dxos/issues",
|
|
@@ -8,32 +8,34 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"sideEffects": true,
|
|
14
14
|
"type": "module",
|
|
15
|
+
"imports": {
|
|
16
|
+
"#translations": "./src/translations.ts"
|
|
17
|
+
},
|
|
15
18
|
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"source": "./src/index.ts",
|
|
21
|
+
"types": "./dist/types/src/index.d.ts",
|
|
22
|
+
"browser": "./dist/lib/browser/index.mjs",
|
|
23
|
+
"node": "./dist/lib/node-esm/index.mjs"
|
|
24
|
+
},
|
|
16
25
|
"./data": {
|
|
17
26
|
"source": "./src/data.ts",
|
|
18
27
|
"types": "./dist/types/src/data.d.ts",
|
|
19
28
|
"browser": "./dist/lib/browser/data.mjs",
|
|
20
29
|
"node": "./dist/lib/node-esm/data.mjs"
|
|
21
30
|
},
|
|
22
|
-
"
|
|
23
|
-
"source": "./src/
|
|
24
|
-
"types": "./dist/types/src/
|
|
25
|
-
"browser": "./dist/lib/browser/
|
|
26
|
-
"node": "./dist/lib/node-esm/
|
|
31
|
+
"./translations": {
|
|
32
|
+
"source": "./src/translations.ts",
|
|
33
|
+
"types": "./dist/types/src/translations.d.ts",
|
|
34
|
+
"browser": "./dist/lib/browser/translations.mjs",
|
|
35
|
+
"node": "./dist/lib/node-esm/translations.mjs"
|
|
27
36
|
}
|
|
28
37
|
},
|
|
29
38
|
"types": "dist/types/src/index.d.ts",
|
|
30
|
-
"typesVersions": {
|
|
31
|
-
"*": {
|
|
32
|
-
"data": [
|
|
33
|
-
"dist/types/src/data.d.ts"
|
|
34
|
-
]
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
39
|
"files": [
|
|
38
40
|
"data",
|
|
39
41
|
"dist",
|
|
@@ -53,11 +55,11 @@
|
|
|
53
55
|
"topojson-client": "^3.1.0",
|
|
54
56
|
"topojson-simplify": "^3.0.3",
|
|
55
57
|
"versor": "^0.2.0",
|
|
56
|
-
"@dxos/
|
|
57
|
-
"@dxos/
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/util": "0.
|
|
58
|
+
"@dxos/async": "0.9.0",
|
|
59
|
+
"@dxos/debug": "0.9.0",
|
|
60
|
+
"@dxos/node-std": "0.9.0",
|
|
61
|
+
"@dxos/log": "0.9.0",
|
|
62
|
+
"@dxos/util": "0.9.0"
|
|
61
63
|
},
|
|
62
64
|
"devDependencies": {
|
|
63
65
|
"@react-three/drei": "^10.7.7",
|
|
@@ -77,15 +79,15 @@
|
|
|
77
79
|
"react": "~19.2.3",
|
|
78
80
|
"react-dom": "~19.2.3",
|
|
79
81
|
"three": "^0.178.0",
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/ui-theme": "0.
|
|
82
|
+
"@dxos/react-ui": "0.9.0",
|
|
83
|
+
"@dxos/storybook-utils": "0.9.0",
|
|
84
|
+
"@dxos/ui-theme": "0.9.0"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"react": "~19.2.3",
|
|
86
88
|
"react-dom": "~19.2.3",
|
|
87
|
-
"@dxos/react-ui": "0.
|
|
88
|
-
"@dxos/ui-theme": "0.
|
|
89
|
+
"@dxos/react-ui": "0.9.0",
|
|
90
|
+
"@dxos/ui-theme": "0.9.0"
|
|
89
91
|
},
|
|
90
92
|
"publishConfig": {
|
|
91
93
|
"access": "public"
|
|
@@ -5,53 +5,54 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import { type FeatureCollection, type Geometry, type Position } from 'geojson';
|
|
7
7
|
import { Leva } from 'leva';
|
|
8
|
-
import React, { useMemo,
|
|
8
|
+
import React, { useMemo, useState } from 'react';
|
|
9
9
|
import { type Topology } from 'topojson-specification';
|
|
10
10
|
|
|
11
11
|
import { useAsyncState } from '@dxos/react-ui';
|
|
12
12
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { loadTopology } from '../../data';
|
|
15
|
+
import {
|
|
16
|
+
type GlobeController,
|
|
17
|
+
type Level,
|
|
18
|
+
type Vector,
|
|
19
|
+
useDrag,
|
|
20
|
+
useGlobeContext,
|
|
21
|
+
useGlobeZoomHandler,
|
|
22
|
+
useSpinner,
|
|
23
|
+
useTopology,
|
|
24
|
+
useTour,
|
|
25
|
+
useWheel,
|
|
26
|
+
} from '../../hooks';
|
|
15
27
|
import { type LatLngLiteral } from '../../types';
|
|
16
28
|
import { type StyleSet, closestPoint } from '../../util';
|
|
17
29
|
import { type ControlProps } from '../Toolbar';
|
|
18
|
-
import { Globe, type GlobeCanvasProps, type
|
|
19
|
-
|
|
20
|
-
// TODO(burdon): Load from JSON at runtime?
|
|
21
|
-
const useTopology = () => {
|
|
22
|
-
return useAsyncState(async () => (await import('../../../data/countries-110m.ts')).default);
|
|
23
|
-
};
|
|
30
|
+
import { Globe, type GlobeCanvasProps, type GlobeRootProps } from './Globe';
|
|
24
31
|
|
|
25
32
|
const defaultStyles: StyleSet = {
|
|
26
33
|
water: {
|
|
27
34
|
fillStyle: '#0a0a0a',
|
|
28
35
|
},
|
|
29
|
-
|
|
30
36
|
land: {
|
|
31
37
|
fillStyle: '#050505',
|
|
32
38
|
strokeStyle: 'darkgreen',
|
|
33
39
|
},
|
|
34
|
-
|
|
35
40
|
graticule: {
|
|
36
41
|
strokeStyle: '#111',
|
|
37
42
|
},
|
|
38
|
-
|
|
39
43
|
line: {
|
|
40
44
|
lineWidth: 1,
|
|
41
45
|
lineDash: [4, 16],
|
|
42
46
|
strokeStyle: 'yellow',
|
|
43
47
|
},
|
|
44
|
-
|
|
45
48
|
point: {
|
|
46
49
|
pointRadius: 2,
|
|
47
50
|
fillStyle: 'red',
|
|
48
51
|
},
|
|
49
|
-
|
|
50
52
|
cursor: {
|
|
51
53
|
fillStyle: 'orange',
|
|
52
54
|
pointRadius: 2,
|
|
53
55
|
},
|
|
54
|
-
|
|
55
56
|
arc: {
|
|
56
57
|
lineWidth: 2,
|
|
57
58
|
strokeStyle: 'yellow',
|
|
@@ -63,17 +64,14 @@ const dotStyles: StyleSet = {
|
|
|
63
64
|
fillStyle: '#444',
|
|
64
65
|
pointRadius: 2,
|
|
65
66
|
},
|
|
66
|
-
|
|
67
67
|
point: {
|
|
68
68
|
pointRadius: 2,
|
|
69
69
|
fillStyle: 'red',
|
|
70
70
|
},
|
|
71
|
-
|
|
72
71
|
cursor: {
|
|
73
72
|
fillStyle: 'orange',
|
|
74
73
|
pointRadius: 2,
|
|
75
74
|
},
|
|
76
|
-
|
|
77
75
|
arc: {
|
|
78
76
|
lineWidth: 2,
|
|
79
77
|
strokeStyle: 'yellow',
|
|
@@ -132,7 +130,10 @@ type DefaultStoryProps = Pick<GlobeRootProps, 'zoom' | 'translation' | 'rotation
|
|
|
132
130
|
drag?: boolean;
|
|
133
131
|
spin?: boolean;
|
|
134
132
|
tour?: boolean;
|
|
135
|
-
|
|
133
|
+
wheel?: boolean;
|
|
134
|
+
lockTilt?: boolean;
|
|
135
|
+
mode?: 'linear' | 'versor';
|
|
136
|
+
level?: Level;
|
|
136
137
|
};
|
|
137
138
|
|
|
138
139
|
const DefaultStory = ({
|
|
@@ -144,9 +145,12 @@ const DefaultStory = ({
|
|
|
144
145
|
drag = false,
|
|
145
146
|
spin = false,
|
|
146
147
|
tour = false,
|
|
147
|
-
|
|
148
|
+
wheel = false,
|
|
149
|
+
lockTilt = false,
|
|
150
|
+
mode,
|
|
151
|
+
level = '110m',
|
|
148
152
|
}: DefaultStoryProps) => {
|
|
149
|
-
const controller =
|
|
153
|
+
const [controller, setController] = useState<GlobeController | null>(null);
|
|
150
154
|
const [dots] = useAsyncState(async () => {
|
|
151
155
|
const points = (await import('../../../data/countries-dots-3.ts')).default;
|
|
152
156
|
return {
|
|
@@ -154,7 +158,7 @@ const DefaultStory = ({
|
|
|
154
158
|
objects: { dots: points },
|
|
155
159
|
} as any as Topology;
|
|
156
160
|
});
|
|
157
|
-
const [topology] =
|
|
161
|
+
const [topology] = useAsyncState(() => loadTopology(level), [level]);
|
|
158
162
|
const [airports] = useAsyncState(async () => (await import('../../../data/airports.ts')).default);
|
|
159
163
|
|
|
160
164
|
const features = useMemo(() => {
|
|
@@ -162,10 +166,11 @@ const DefaultStory = ({
|
|
|
162
166
|
}, [airports, routes, dots]);
|
|
163
167
|
|
|
164
168
|
// Control hooks.
|
|
165
|
-
const [startSpinner, stopSpinner] = useSpinner(controller
|
|
166
|
-
const [_running, setRunning] = useTour(controller
|
|
167
|
-
useDrag(controller
|
|
168
|
-
|
|
169
|
+
const [startSpinner, stopSpinner] = useSpinner(controller, { disabled: !spin });
|
|
170
|
+
const [_running, setRunning] = useTour(controller, features?.points, { disabled: !tour, styles });
|
|
171
|
+
useDrag(controller, {
|
|
172
|
+
lockTilt,
|
|
173
|
+
mode,
|
|
169
174
|
disabled: !drag,
|
|
170
175
|
onUpdate: (event) => {
|
|
171
176
|
switch (event.type) {
|
|
@@ -177,6 +182,13 @@ const DefaultStory = ({
|
|
|
177
182
|
}
|
|
178
183
|
},
|
|
179
184
|
});
|
|
185
|
+
useWheel(controller, {
|
|
186
|
+
disabled: !wheel,
|
|
187
|
+
onUpdate: () => {
|
|
188
|
+
stopSpinner();
|
|
189
|
+
setRunning(false);
|
|
190
|
+
},
|
|
191
|
+
});
|
|
180
192
|
|
|
181
193
|
// TODO(burdon): Factor out handlers.
|
|
182
194
|
const handleAction: ControlProps['onAction'] = (event) => {
|
|
@@ -191,31 +203,32 @@ const DefaultStory = ({
|
|
|
191
203
|
break;
|
|
192
204
|
}
|
|
193
205
|
case 'zoom-in': {
|
|
194
|
-
controller
|
|
206
|
+
controller?.setZoom((scale) => scale * 1.1);
|
|
195
207
|
break;
|
|
196
208
|
}
|
|
197
209
|
case 'zoom-out': {
|
|
198
|
-
controller
|
|
210
|
+
controller?.setZoom((scale) => scale * 0.9);
|
|
199
211
|
break;
|
|
200
212
|
}
|
|
201
213
|
}
|
|
202
214
|
};
|
|
203
215
|
|
|
204
216
|
return (
|
|
205
|
-
<Globe.Root zoom={zoomProp} translation={translation} rotation={rotation}>
|
|
206
|
-
<Globe.
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
217
|
+
<Globe.Root zoom={zoomProp} translation={translation} rotation={rotation} ref={setController}>
|
|
218
|
+
<Globe.Viewport>
|
|
219
|
+
<Globe.Canvas
|
|
220
|
+
topology={styles?.dots ? dots : topology}
|
|
221
|
+
projection={projection}
|
|
222
|
+
styles={styles}
|
|
223
|
+
features={tour ? { points: features?.points ?? [] } : features}
|
|
224
|
+
/>
|
|
225
|
+
<Globe.Zoom onAction={handleAction} />
|
|
226
|
+
<Globe.Action onAction={handleAction} />
|
|
227
|
+
<Globe.Debug />
|
|
228
|
+
<Globe.Panel position='topright' classNames='w-20 h-20'>
|
|
229
|
+
<Leva />
|
|
230
|
+
</Globe.Panel>
|
|
231
|
+
</Globe.Viewport>
|
|
219
232
|
</Globe.Root>
|
|
220
233
|
);
|
|
221
234
|
};
|
|
@@ -234,31 +247,78 @@ const meta = {
|
|
|
234
247
|
|
|
235
248
|
export default meta;
|
|
236
249
|
|
|
237
|
-
|
|
238
|
-
const [topology] =
|
|
250
|
+
const Earth = ({ level }: { level: Level }) => {
|
|
251
|
+
const [topology] = useAsyncState(() => loadTopology(level), [level]);
|
|
239
252
|
const [controller, setController] = useState<GlobeController | null>();
|
|
240
253
|
const handleAction = useGlobeZoomHandler(controller);
|
|
241
254
|
useDrag(controller);
|
|
255
|
+
useWheel(controller);
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<Globe.Root zoom={1.2} rotation={[0, 0, 0]} ref={setController}>
|
|
259
|
+
<Globe.Viewport>
|
|
260
|
+
<Globe.Canvas topology={topology} styles={defaultStyles} />
|
|
261
|
+
<Globe.Zoom onAction={handleAction} />
|
|
262
|
+
</Globe.Viewport>
|
|
263
|
+
</Globe.Root>
|
|
264
|
+
);
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const Topology110 = () => {
|
|
268
|
+
return <Earth level='110m' />;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
export const Topology50 = () => {
|
|
272
|
+
return <Earth level='50m' />;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
export const Topology10 = () => {
|
|
276
|
+
return <Earth level='10m' />;
|
|
277
|
+
};
|
|
242
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Discrete-resolution LOD: swaps resolution by zoom via `useTopology(zoom)`. Each resolution is a
|
|
281
|
+
* code-split chunk fetched on demand the first time its tier is entered (default tiers: 110m / 50m).
|
|
282
|
+
* Reads the live zoom from the globe context, so it must render inside `Globe.Root`.
|
|
283
|
+
*/
|
|
284
|
+
const DynamicCanvas = ({ controller }: { controller: GlobeController | null | undefined }) => {
|
|
285
|
+
const { zoom } = useGlobeContext();
|
|
286
|
+
const topology = useTopology(zoom);
|
|
287
|
+
const handleAction = useGlobeZoomHandler(controller);
|
|
288
|
+
useDrag(controller);
|
|
289
|
+
useWheel(controller);
|
|
243
290
|
return (
|
|
244
|
-
<Globe.
|
|
245
|
-
<Globe.Canvas
|
|
291
|
+
<Globe.Viewport>
|
|
292
|
+
<Globe.Canvas topology={topology} styles={defaultStyles} />
|
|
246
293
|
<Globe.Zoom onAction={handleAction} />
|
|
294
|
+
<Globe.Debug />
|
|
295
|
+
</Globe.Viewport>
|
|
296
|
+
);
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
export const Dynamic = () => {
|
|
300
|
+
const [controller, setController] = useState<GlobeController | null>();
|
|
301
|
+
return (
|
|
302
|
+
<Globe.Root zoom={1.2} rotation={[0, 0, 0]} ref={setController}>
|
|
303
|
+
<DynamicCanvas controller={controller} />
|
|
247
304
|
</Globe.Root>
|
|
248
305
|
);
|
|
249
306
|
};
|
|
250
307
|
|
|
251
|
-
export const
|
|
252
|
-
const
|
|
308
|
+
export const Earthrise = () => {
|
|
309
|
+
const topology = useTopology();
|
|
253
310
|
const [controller, setController] = useState<GlobeController | null>();
|
|
254
311
|
const handleAction = useGlobeZoomHandler(controller);
|
|
255
312
|
useDrag(controller);
|
|
313
|
+
useWheel(controller);
|
|
256
314
|
|
|
257
315
|
return (
|
|
258
316
|
<div className='absolute bottom-0 left-0 right-0 '>
|
|
259
|
-
<Globe.Root
|
|
260
|
-
<Globe.
|
|
261
|
-
|
|
317
|
+
<Globe.Root zoom={2.8} translation={{ x: 0, y: 400 }} ref={setController}>
|
|
318
|
+
<Globe.Viewport classNames='h-[400px]'>
|
|
319
|
+
<Globe.Canvas topology={topology} styles={defaultStyles} />
|
|
320
|
+
<Globe.Zoom onAction={handleAction} />
|
|
321
|
+
</Globe.Viewport>
|
|
262
322
|
</Globe.Root>
|
|
263
323
|
</div>
|
|
264
324
|
);
|
|
@@ -268,31 +328,31 @@ const monochrome: StyleSet = {
|
|
|
268
328
|
water: {
|
|
269
329
|
fillStyle: '#191919',
|
|
270
330
|
},
|
|
271
|
-
|
|
272
331
|
land: {
|
|
273
332
|
fillStyle: '#444',
|
|
274
333
|
strokeStyle: '#222',
|
|
275
334
|
},
|
|
276
|
-
|
|
277
335
|
border: {
|
|
278
336
|
strokeStyle: '#111',
|
|
279
337
|
},
|
|
280
|
-
|
|
281
338
|
graticule: {
|
|
282
339
|
strokeStyle: '#111',
|
|
283
340
|
},
|
|
284
341
|
};
|
|
285
342
|
|
|
286
343
|
export const Mercator = () => {
|
|
287
|
-
const
|
|
344
|
+
const topology = useTopology();
|
|
288
345
|
const [controller, setController] = useState<GlobeController | null>();
|
|
289
346
|
const handleAction = useGlobeZoomHandler(controller);
|
|
290
347
|
useDrag(controller);
|
|
348
|
+
useWheel(controller);
|
|
291
349
|
|
|
292
350
|
return (
|
|
293
|
-
<Globe.Root
|
|
294
|
-
<Globe.
|
|
295
|
-
|
|
351
|
+
<Globe.Root zoom={0.7} rotation={initialRotation} ref={setController}>
|
|
352
|
+
<Globe.Viewport>
|
|
353
|
+
<Globe.Canvas topology={topology} projection='mercator' styles={monochrome} />
|
|
354
|
+
<Globe.Zoom onAction={handleAction} />
|
|
355
|
+
</Globe.Viewport>
|
|
296
356
|
</Globe.Root>
|
|
297
357
|
);
|
|
298
358
|
};
|
|
@@ -302,6 +362,7 @@ type Story = StoryObj<typeof DefaultStory>;
|
|
|
302
362
|
export const Globe1: Story = {
|
|
303
363
|
args: {
|
|
304
364
|
drag: true,
|
|
365
|
+
wheel: true,
|
|
305
366
|
projection: 'mercator',
|
|
306
367
|
zoom: 0.8,
|
|
307
368
|
rotation: initialRotation,
|
|
@@ -312,6 +373,7 @@ export const Globe1: Story = {
|
|
|
312
373
|
export const Globe2: Story = {
|
|
313
374
|
args: {
|
|
314
375
|
drag: true,
|
|
376
|
+
wheel: true,
|
|
315
377
|
projection: 'transverse-mercator',
|
|
316
378
|
zoom: 0.8,
|
|
317
379
|
rotation: initialRotation,
|
|
@@ -322,6 +384,7 @@ export const Globe2: Story = {
|
|
|
322
384
|
export const Globe3: Story = {
|
|
323
385
|
args: {
|
|
324
386
|
drag: true,
|
|
387
|
+
wheel: true,
|
|
325
388
|
spin: true,
|
|
326
389
|
zoom: 1.5,
|
|
327
390
|
rotation: initialRotation,
|
|
@@ -332,6 +395,7 @@ export const Globe3: Story = {
|
|
|
332
395
|
export const Globe4: Story = {
|
|
333
396
|
args: {
|
|
334
397
|
drag: true,
|
|
398
|
+
wheel: true,
|
|
335
399
|
tour: true,
|
|
336
400
|
zoom: 2,
|
|
337
401
|
rotation: initialRotation,
|
|
@@ -342,6 +406,7 @@ export const Globe4: Story = {
|
|
|
342
406
|
export const Globe5: Story = {
|
|
343
407
|
args: {
|
|
344
408
|
drag: true,
|
|
409
|
+
wheel: true,
|
|
345
410
|
tour: true,
|
|
346
411
|
zoom: 0.9,
|
|
347
412
|
rotation: initialRotation,
|
|
@@ -352,7 +417,8 @@ export const Globe5: Story = {
|
|
|
352
417
|
export const Globe6: Story = {
|
|
353
418
|
args: {
|
|
354
419
|
drag: true,
|
|
355
|
-
|
|
420
|
+
wheel: true,
|
|
421
|
+
lockTilt: true,
|
|
356
422
|
tour: true,
|
|
357
423
|
zoom: 2,
|
|
358
424
|
translation: { x: 0, y: 600 },
|
|
@@ -360,3 +426,14 @@ export const Globe6: Story = {
|
|
|
360
426
|
styles: dotStyles,
|
|
361
427
|
},
|
|
362
428
|
};
|
|
429
|
+
|
|
430
|
+
export const VersorDrag: Story = {
|
|
431
|
+
args: {
|
|
432
|
+
drag: true,
|
|
433
|
+
wheel: true,
|
|
434
|
+
mode: 'versor',
|
|
435
|
+
zoom: 1.5,
|
|
436
|
+
rotation: initialRotation,
|
|
437
|
+
styles: defaultStyles,
|
|
438
|
+
},
|
|
439
|
+
};
|