gralobe 1.0.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 +255 -0
- package/dist/gralobe.js +5945 -0
- package/dist/gralobe.js.map +1 -0
- package/dist/gralobe.umd.cjs +1009 -0
- package/dist/gralobe.umd.cjs.map +1 -0
- package/dist/index.d.ts +325 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# Gralobe
|
|
2
|
+
|
|
3
|
+
Interactive 3D globe visualization with world statistics, smooth flat map ↔ globe transitions, and country labels.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Smooth morphing animation between flat (Mercator) map and 3D globe
|
|
8
|
+
- Built-in world statistics (Life Expectancy, GDP, CO2 Emissions, etc.)
|
|
9
|
+
- Country labels with multiple display styles
|
|
10
|
+
- NASA Blue Marble and other texture presets
|
|
11
|
+
- Visual effects (clouds, atmosphere, grid lines, etc.)
|
|
12
|
+
- Screenshot and video/GIF recording
|
|
13
|
+
- Height extrusion based on data values
|
|
14
|
+
- Fully typed TypeScript API
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install gralobe three
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { GlobeViz } from 'gralobe';
|
|
26
|
+
|
|
27
|
+
// Create a globe with default settings
|
|
28
|
+
const globe = new GlobeViz('#container');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The default configuration displays:
|
|
32
|
+
- NASA Blue Marble satellite texture
|
|
33
|
+
- All country labels
|
|
34
|
+
- Life Expectancy statistic
|
|
35
|
+
- Globe view (morphed to sphere)
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { GlobeViz } from 'gralobe';
|
|
41
|
+
|
|
42
|
+
const globe = new GlobeViz('#container', {
|
|
43
|
+
// Earth texture: 'satellite' | 'natural' | 'dark' | 'light' | 'night' | 'topographic'
|
|
44
|
+
texture: 'satellite',
|
|
45
|
+
|
|
46
|
+
// Label style: 'none' | 'minimal' | 'major' | 'all'
|
|
47
|
+
labels: 'all',
|
|
48
|
+
|
|
49
|
+
// Initial statistic to display (built-in ID or custom StatisticData)
|
|
50
|
+
statistic: 'lifeExpectancy',
|
|
51
|
+
|
|
52
|
+
// Initial view: 'globe' or 'flat'
|
|
53
|
+
initialView: 'globe',
|
|
54
|
+
|
|
55
|
+
// Enable auto-rotation
|
|
56
|
+
autoRotate: false,
|
|
57
|
+
|
|
58
|
+
// Show control panel (lil-gui)
|
|
59
|
+
showControls: true,
|
|
60
|
+
|
|
61
|
+
// Show legend
|
|
62
|
+
showLegend: true,
|
|
63
|
+
|
|
64
|
+
// Enable 3D height extrusion based on data values
|
|
65
|
+
extrudeHeight: false,
|
|
66
|
+
|
|
67
|
+
// Visual effects
|
|
68
|
+
effects: {
|
|
69
|
+
atmosphereIntensity: 0.5,
|
|
70
|
+
clouds: true,
|
|
71
|
+
cloudSpeed: 1.0,
|
|
72
|
+
cloudOpacity: 0.6,
|
|
73
|
+
gridLines: false,
|
|
74
|
+
starTwinkle: true,
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
// Callbacks
|
|
78
|
+
onCountryClick: (id, name, value) => {
|
|
79
|
+
console.log(`Clicked: ${name} (${id}) = ${value}`);
|
|
80
|
+
},
|
|
81
|
+
onViewChange: (view, morph) => {
|
|
82
|
+
console.log(`View: ${view}, Morph: ${morph}`);
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## API
|
|
88
|
+
|
|
89
|
+
### View Control
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Animate to globe view
|
|
93
|
+
globe.toGlobe();
|
|
94
|
+
|
|
95
|
+
// Animate to flat map view
|
|
96
|
+
globe.toFlat();
|
|
97
|
+
|
|
98
|
+
// Set morph value directly (0 = flat, 1 = globe)
|
|
99
|
+
globe.setMorph(0.5);
|
|
100
|
+
|
|
101
|
+
// Get current morph value
|
|
102
|
+
const morph = globe.getMorph();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Statistics
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
// Change to a built-in statistic
|
|
109
|
+
globe.setStatistic('gdpPerCapita');
|
|
110
|
+
|
|
111
|
+
// Available built-in statistics:
|
|
112
|
+
// - lifeExpectancy
|
|
113
|
+
// - humanDevIndex
|
|
114
|
+
// - gdpPerCapita
|
|
115
|
+
// - co2Emissions
|
|
116
|
+
// - renewableEnergy
|
|
117
|
+
// - internetUsers
|
|
118
|
+
// - urbanPopulation
|
|
119
|
+
// - healthExpenditure
|
|
120
|
+
// - forestArea
|
|
121
|
+
// - population
|
|
122
|
+
// - accessElectricity
|
|
123
|
+
// - educationExpenditure
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Labels
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
// Change label style
|
|
130
|
+
globe.setLabels('major'); // 'none' | 'minimal' | 'major' | 'all'
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Texture
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
// Change earth texture
|
|
137
|
+
await globe.setTexture('night');
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Effects
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
// Update visual effects
|
|
144
|
+
globe.setEffects({
|
|
145
|
+
clouds: true,
|
|
146
|
+
cloudSpeed: 1.5,
|
|
147
|
+
atmosphereIntensity: 0.8,
|
|
148
|
+
gridLines: true,
|
|
149
|
+
});
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Export
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
// Take a screenshot
|
|
156
|
+
globe.screenshot({ filename: 'globe.png' });
|
|
157
|
+
|
|
158
|
+
// Record a GIF
|
|
159
|
+
await globe.recordGif({ duration: 5, fps: 30 });
|
|
160
|
+
|
|
161
|
+
// Record a video
|
|
162
|
+
await globe.recordVideo({ duration: 10 });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Other
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// Enable/disable auto-rotation
|
|
169
|
+
globe.setAutoRotate(true);
|
|
170
|
+
|
|
171
|
+
// Resize
|
|
172
|
+
globe.resize(800, 600);
|
|
173
|
+
|
|
174
|
+
// Clean up
|
|
175
|
+
globe.destroy();
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Built-in Statistics
|
|
179
|
+
|
|
180
|
+
| ID | Name | Unit |
|
|
181
|
+
|----|------|------|
|
|
182
|
+
| `lifeExpectancy` | Life Expectancy | years |
|
|
183
|
+
| `humanDevIndex` | Human Development Index | - |
|
|
184
|
+
| `gdpPerCapita` | GDP per Capita (PPP) | $ |
|
|
185
|
+
| `co2Emissions` | CO2 Emissions | t/capita |
|
|
186
|
+
| `renewableEnergy` | Renewable Energy | % |
|
|
187
|
+
| `internetUsers` | Internet Penetration | % |
|
|
188
|
+
| `urbanPopulation` | Urbanization | % |
|
|
189
|
+
| `healthExpenditure` | Health Spending | % GDP |
|
|
190
|
+
| `forestArea` | Forest Coverage | % |
|
|
191
|
+
| `population` | Population | millions |
|
|
192
|
+
| `accessElectricity` | Electricity Access | % |
|
|
193
|
+
| `educationExpenditure` | Education Spending | % GDP |
|
|
194
|
+
|
|
195
|
+
## Custom Statistics
|
|
196
|
+
|
|
197
|
+
You can provide your own statistics data:
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import type { StatisticData } from 'gralobe';
|
|
201
|
+
|
|
202
|
+
const customStat: StatisticData = {
|
|
203
|
+
definition: {
|
|
204
|
+
id: 'myStatistic',
|
|
205
|
+
name: 'My Custom Statistic',
|
|
206
|
+
unit: '%',
|
|
207
|
+
description: 'Description of my statistic',
|
|
208
|
+
colorScale: ['#feedde', '#fdbe85', '#d94701'],
|
|
209
|
+
domain: [0, 100],
|
|
210
|
+
format: (v) => `${v.toFixed(1)}%`,
|
|
211
|
+
},
|
|
212
|
+
values: {
|
|
213
|
+
'840': 75.5, // USA (ISO numeric code)
|
|
214
|
+
'156': 42.3, // China
|
|
215
|
+
// ... more countries
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
globe.setStatistic(customStat);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## TypeScript Types
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import type {
|
|
226
|
+
GlobeVizConfig,
|
|
227
|
+
GlobeVizAPI,
|
|
228
|
+
StatisticDefinition,
|
|
229
|
+
StatisticData,
|
|
230
|
+
CountryData,
|
|
231
|
+
TexturePreset,
|
|
232
|
+
LabelStyle,
|
|
233
|
+
EffectsConfig,
|
|
234
|
+
ExportOptions,
|
|
235
|
+
} from 'gralobe';
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Browser Support
|
|
239
|
+
|
|
240
|
+
Gralobe requires WebGL support. It works in all modern browsers:
|
|
241
|
+
|
|
242
|
+
- Chrome 80+
|
|
243
|
+
- Firefox 75+
|
|
244
|
+
- Safari 14+
|
|
245
|
+
- Edge 80+
|
|
246
|
+
|
|
247
|
+
## Dependencies
|
|
248
|
+
|
|
249
|
+
- [three.js](https://threejs.org/) - 3D rendering
|
|
250
|
+
- [gsap](https://greensock.com/gsap/) - Animations
|
|
251
|
+
- [lil-gui](https://github.com/georgealways/lil-gui) - Control panel
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT
|