@macrostrat/cesium-martini 1.4.0 → 1.5.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.
- package/.prettierrc +3 -0
- package/README.md +112 -86
- package/babel.config.js +3 -0
- package/dist/index.cjs +657 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +651 -139
- package/dist/index.js.map +1 -1
- package/package.json +18 -12
- package/rollup.config.js +4 -1
- package/tsconfig.json +3 -6
- package/.babelrc +0 -3
- package/.npmrc +0 -1
- package/typings/worker-loader.d.ts +0 -10
- package/webpack.config.js +0 -75
package/.prettierrc
ADDED
package/README.md
CHANGED
|
@@ -2,28 +2,30 @@
|
|
|
2
2
|
|
|
3
3
|
**On-the-fly meshing of raster elevation tiles for the CesiumJS virtual globe**
|
|
4
4
|
|
|
5
|
+
[](https://badge.fury.io/js/@macrostrat%2Fcesium-martini)
|
|
6
|
+
|
|
5
7
|

|
|
6
8
|
|
|
7
9
|
This package contains a Cesium
|
|
8
10
|
[TerrainProvider](https://cesium.com/docs/cesiumjs-ref-doc/TerrainProvider.html)
|
|
9
11
|
that uses right-triangular irregular networks (RTIN) pioneered by
|
|
10
|
-
[Mapbox's Martini](https://observablehq.com/@mourner/martin-real-time-rtin-terrain-mesh)
|
|
11
|
-
transform
|
|
12
|
-
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
for future rich
|
|
21
|
-
|
|
12
|
+
[Mapbox's Martini](https://observablehq.com/@mourner/martin-real-time-rtin-terrain-mesh)
|
|
13
|
+
to transform
|
|
14
|
+
[Terrain-RGB elevation tiles](https://blog.mapbox.com/global-elevation-data-6689f1d0ba65)
|
|
15
|
+
into [quantized mesh terrain](https://github.com/CesiumGS/quantized-mesh), for
|
|
16
|
+
rendering in the [CesiumJS digital globe](https://cesium.com). The module
|
|
17
|
+
provides a general technique applicable to all raster imagery (although the
|
|
18
|
+
Terrain-RGB format is near-ideal for streaming elevation data). Fixes for
|
|
19
|
+
performance and better control of rendering quality are in progress.
|
|
20
|
+
|
|
21
|
+
This module was created to support our geologic map visualization work at
|
|
22
|
+
[Macrostrat](https://macrostrat.org) and as a building block for future rich
|
|
23
|
+
geoscience visualizations.
|
|
22
24
|
|
|
23
25
|
## Installation
|
|
24
26
|
|
|
25
|
-
This package is listed on NPM as `@macrostrat/cesium-martini`. It can be
|
|
26
|
-
using the command
|
|
27
|
+
This package is listed on NPM as `@macrostrat/cesium-martini`. It can be
|
|
28
|
+
installed using the command
|
|
27
29
|
|
|
28
30
|
```
|
|
29
31
|
npm install --save @macrostrat/cesium-martini
|
|
@@ -33,8 +35,8 @@ npm install --save @macrostrat/cesium-martini
|
|
|
33
35
|
|
|
34
36
|
## Development
|
|
35
37
|
|
|
36
|
-
As of version `1.3.x`, `cesium-martini` development is tested with the Yarn
|
|
37
|
-
Your mileage with `npm` may vary.
|
|
38
|
+
As of version `1.3.x`, `cesium-martini` development is tested with the Yarn
|
|
39
|
+
package manager. Your mileage with `npm` may vary.
|
|
38
40
|
|
|
39
41
|
### Quick start
|
|
40
42
|
|
|
@@ -47,12 +49,15 @@ After cloning this repository, you can build the module (using Rollup) with
|
|
|
47
49
|
|
|
48
50
|
### Example applications
|
|
49
51
|
|
|
50
|
-
Several example applications are available in the [`examples/`](examples/)
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
Several example applications are available in the [`examples/`](examples/)
|
|
53
|
+
directory and runnable from the root project. The main example is built with
|
|
54
|
+
Vite and others are built with Webpack v5. As well as showing how to use this
|
|
55
|
+
module, these examples contain configuration for bundling Cesium in each
|
|
56
|
+
packaging system.
|
|
53
57
|
|
|
54
|
-
To run an example application, add `MAPBOX_API_TOKEN=<your-mapbox-token>` to a
|
|
55
|
-
in the root of this repository, and then start the appropriate
|
|
58
|
+
To run an example application, add `MAPBOX_API_TOKEN=<your-mapbox-token>` to a
|
|
59
|
+
`.env` file. in the root of this repository, and then start the appropriate
|
|
60
|
+
example:
|
|
56
61
|
|
|
57
62
|
- `yarn run example` (Vite)
|
|
58
63
|
- `yarn run example:mapzen` (Vite + Mapzen)
|
|
@@ -60,66 +65,77 @@ in the root of this repository, and then start the appropriate example:
|
|
|
60
65
|
- `yarn run example:webpack-mapzen` (Webpack + Mapzen)
|
|
61
66
|
- `yarn run example:webpack-react` (Webpack + React)
|
|
62
67
|
|
|
63
|
-
Contributions in the form of bug reports and pull requests are welcome.
|
|
64
|
-
|
|
68
|
+
Contributions in the form of bug reports and pull requests are welcome. These
|
|
69
|
+
can be to add functionality (e.g. optional normal-map generation) or for
|
|
65
70
|
performance. See list of [known limitations](#current-known-limitations) below.
|
|
66
71
|
|
|
67
72
|
## Motivation
|
|
68
73
|
|
|
69
74
|
The Cesium digital globe is a powerful platform for visualization of geospatial
|
|
70
|
-
data in 3D. Cesium maintains a global elevation dataset as a prebuilt terrain
|
|
71
|
-
which caches the computationally-intensive step of meshing height-field
|
|
72
|
-
into a triangle irregular network (TIN). Unfortunately, this
|
|
73
|
-
[quantized mesh](https://github.com/CesiumGS/quantized-mesh) format is
|
|
74
|
-
new, narrowly supported and tailored to Cesium itself.
|
|
75
|
-
|
|
76
|
-
processing pipelines and storage resources.
|
|
75
|
+
data in 3D. Cesium maintains a global elevation dataset as a prebuilt terrain
|
|
76
|
+
mesh, which caches the computationally-intensive step of meshing height-field
|
|
77
|
+
data into a triangle irregular network (TIN). Unfortunately, this
|
|
78
|
+
[quantized mesh](https://github.com/CesiumGS/quantized-mesh) format is
|
|
79
|
+
relatively new, narrowly supported and tailored to Cesium itself. Supporting a
|
|
80
|
+
TIN format for elevation datasets requires maintenance of significant
|
|
81
|
+
single-purpose processing pipelines and storage resources.
|
|
82
|
+
|
|
83
|
+
### Fast raster meshing
|
|
77
84
|
|
|
78
85
|
Mapbox maintains a multiscale global elevation dataset in their clever
|
|
79
86
|
[terrain-RGB](https://blog.mapbox.com/global-elevation-data-6689f1d0ba65)
|
|
80
|
-
format, which bridges web standard file formats (PNG images) with traditional
|
|
81
|
-
formats for representing terrain. Rasters are the standard
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
format, but the jump from there to a
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
[Vladimir Agafonkin](https://agafonkin.com/) at Mapbox
|
|
87
|
+
format, which bridges web standard file formats (PNG images) with traditional
|
|
88
|
+
raster GIS formats for representing terrain. Rasters are the standard
|
|
89
|
+
representation of elevation data across the geosciences, and many pipelines are
|
|
90
|
+
available to create and modify raster images. Basically any elevation dataset
|
|
91
|
+
can be easily rescaled to the Terrain-RGB format, but the jump from there to a
|
|
92
|
+
"Quantized mesh" is more complicated.
|
|
93
|
+
|
|
94
|
+
More recently, [Vladimir Agafonkin](https://agafonkin.com/) at Mapbox
|
|
95
|
+
demonstrated an
|
|
88
96
|
[elegant algorithmic approach](https://observablehq.com/@mourner/martin-real-time-rtin-terrain-mesh)
|
|
89
|
-
that sidesteps this issue.
|
|
90
|
-
|
|
91
|
-
and is far quicker than the traditional TIN generation
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
meshes are generated at levels of detail that undersample the
|
|
108
|
-
in a terrain tile
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
97
|
+
that sidesteps this issue. His [MARTINI](https://github.com/mapbox/martini)
|
|
98
|
+
project constructs meshes based on right-triangulated irregular networks (RTIN,
|
|
99
|
+
_Evans et al., 1998_) and is far quicker than the traditional TIN generation
|
|
100
|
+
techniques.
|
|
101
|
+
|
|
102
|
+
A speedy meshing algorithm allows this data-preparation step to be handled in
|
|
103
|
+
the browser after elevation tiles are loaded. Integrating this toolchain into
|
|
104
|
+
the Cesium digital globe enables the usage of Mapbox global data and other
|
|
105
|
+
raster terrain layers (e.g. planetary and bathymetric data!), without adding
|
|
106
|
+
overhead of TIN processing and storage.
|
|
107
|
+
|
|
108
|
+
### Progressive mesh enhancement (added in version `1.5.0`)
|
|
109
|
+
|
|
110
|
+
Cesium `TerrainProvider`s are generally designed to represent static terrain
|
|
111
|
+
meshes. The RTIN algorithm used here can dynamically build meshes at a variety
|
|
112
|
+
of error levels, and the input height fields can represent extremely detailed
|
|
113
|
+
meshes at a given zoom level.
|
|
114
|
+
|
|
115
|
+
By default, meshes are generated at levels of detail that undersample the
|
|
116
|
+
available structure in a terrain tile, calibrated to what Cesium needs to render
|
|
117
|
+
visually pleasing output at a given zoom level. To more fully exploit the
|
|
118
|
+
available data, we can generate meshes at progressively higher resolution from
|
|
119
|
+
the same input data. This allows some zoom levels to be skipped, greatly
|
|
120
|
+
increasing efficiency.
|
|
121
|
+
|
|
122
|
+
This "overzooming" can be enabled using the `skipZoomLevels` configuration. For
|
|
123
|
+
instance, the below function will refuse to load tiles except in
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
function skipZoomLevels(z) {
|
|
127
|
+
return z % 3 != 0;
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The configuration also takes a single number and array.
|
|
117
132
|
|
|
118
133
|
### Outstanding bugs and issues
|
|
119
134
|
|
|
120
135
|
- [x] High-resolution `@2x` tiles are notionally supported but not well-tested.
|
|
121
136
|
- [ ] There is no formal testing framework to catch regressions.
|
|
122
|
-
- [
|
|
137
|
+
- [x] TypeScript types are discarded on compilation rather than checked
|
|
138
|
+
properly.
|
|
123
139
|
|
|
124
140
|
## Prior art and relevant examples
|
|
125
141
|
|
|
@@ -132,35 +148,45 @@ of Cesium would provide some guidance here.
|
|
|
132
148
|
- [Cesium globe materials example](https://sandcastle.cesium.com/?src=Globe%20Materials.html)
|
|
133
149
|
- [Cesium sky/atmosphere example](https://sandcastle.cesium.com/?src=Sky%20Atmosphere.html)
|
|
134
150
|
|
|
135
|
-
##
|
|
151
|
+
## Changelog
|
|
136
152
|
|
|
137
|
-
|
|
138
|
-
- Better masking of unavailable tiles
|
|
139
|
-
- Bathymetry option
|
|
140
|
-
- Tie to hillshade generator so the same tiles are loaded
|
|
153
|
+
### `[1.5.1]`: February 2025
|
|
141
154
|
|
|
142
|
-
|
|
155
|
+
- Remove `.idea` files from bundle
|
|
143
156
|
|
|
144
|
-
|
|
157
|
+
### `[1.5.0]`: February 2025
|
|
158
|
+
|
|
159
|
+
- Allow overzooming of tiles when zoom levels are skipped
|
|
160
|
+
- Improve and deduplicate examples
|
|
161
|
+
- Fix typescript types
|
|
162
|
+
- Improve some internal organization of code
|
|
145
163
|
|
|
146
164
|
### `[1.4.0]`: February 2025
|
|
147
165
|
|
|
148
|
-
- Merge [**PR #10**](https://github.com/davenquinn/cesium-martini/pull/10) from
|
|
149
|
-
|
|
166
|
+
- Merge [**PR #10**](https://github.com/davenquinn/cesium-martini/pull/10) from
|
|
167
|
+
[_Stuart Attenborrow_](https://github.com/stuarta0) to allow loading of
|
|
168
|
+
non-Mapbox terrain tiles
|
|
169
|
+
- Created Vite and Webpack examples of using the module with Mapzen Terrarium
|
|
170
|
+
tiles
|
|
150
171
|
- Migrated Vite examples to Vite 5
|
|
151
172
|
- Upgraded `axios` dependency
|
|
152
|
-
- Remove submodule dependency for `@mapbox/martini` in favor of directly
|
|
173
|
+
- Remove submodule dependency for `@mapbox/martini` in favor of directly
|
|
174
|
+
importing from [my fork](https://github.com/davenquinn/martini)
|
|
153
175
|
- Upgrade `yarn` to `4.6.0`
|
|
154
176
|
|
|
155
177
|
### `[1.3.0]`: September 2023
|
|
156
178
|
|
|
157
|
-
- Add compilation to ESModules, which allows the package to be used with modern
|
|
158
|
-
|
|
179
|
+
- Add compilation to ESModules, which allows the package to be used with modern
|
|
180
|
+
bundlers like [**Vite**](https://vitejs.dev). _Contributed by
|
|
181
|
+
[@fc](https://github.com/fc)._
|
|
182
|
+
- Change latitude-based scaling factor for tile error to improve fidelity at
|
|
183
|
+
high latitudes.
|
|
159
184
|
- Remove `regenerator-runtime` from web-worker code, targeting modern platforms.
|
|
160
185
|
|
|
161
186
|
#### Development environment
|
|
162
187
|
|
|
163
|
-
We reorganized the development environment and examples for a more modern
|
|
188
|
+
We reorganized the development environment and examples for a more modern
|
|
189
|
+
overall design.
|
|
164
190
|
|
|
165
191
|
- Switched to `yarn` from `npm` as the default package manager
|
|
166
192
|
- Enabled Yarn Plug'n'Play for faster development
|
|
@@ -169,15 +195,15 @@ We reorganized the development environment and examples for a more modern overal
|
|
|
169
195
|
- Moved all examples to the `examples/` directory as Yarn workspaces, enabling
|
|
170
196
|
separation of dependencies
|
|
171
197
|
|
|
172
|
-
|
|
173
198
|
### `[1.2.0]`: November 2021
|
|
174
199
|
|
|
175
200
|
- Globe caps! (disable using the `fillPoles` option).
|
|
176
201
|
- Some fixes for efficiency
|
|
177
202
|
- Fixed small errors in tile occlusion code
|
|
178
|
-
- Added a `minZoom` configuration option to prevent excessive loading of
|
|
179
|
-
-
|
|
180
|
-
|
|
203
|
+
- Added a `minZoom` configuration option to prevent excessive loading of
|
|
204
|
+
low-resolution tiles
|
|
205
|
+
- Four (!) pull requests from [@stuarta0](https://github.com/stuarta0) to
|
|
206
|
+
improve loading of non-Mapbox tilesets
|
|
181
207
|
|
|
182
208
|
### `[1.1.3]`: June 2021
|
|
183
209
|
|
|
@@ -186,8 +212,8 @@ We reorganized the development environment and examples for a more modern overal
|
|
|
186
212
|
### `[1.1.2]`: May 2021
|
|
187
213
|
|
|
188
214
|
- Fixed a bug with loading high-resolution tiles
|
|
189
|
-
- Added a `skipOddLevels` option that significantly reduces the load of zooming
|
|
190
|
-
This is enabled by default.
|
|
215
|
+
- Added a `skipOddLevels` option that significantly reduces the load of zooming
|
|
216
|
+
through many terrain levels. This is enabled by default.
|
|
191
217
|
- Greatly increase skirt height
|
|
192
218
|
|
|
193
219
|
### `[1.1.0]`: May 2021
|
package/babel.config.js
ADDED