@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 ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "proseWrap": "always"
3
+ }
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
+ [![npm version](https://badge.fury.io/js/@macrostrat%2Fcesium-martini.svg)](https://badge.fury.io/js/@macrostrat%2Fcesium-martini)
6
+
5
7
  ![Himalayas](/img/himalayas.jpg)
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) to
11
- transform [Terrain-RGB elevation tiles](https://blog.mapbox.com/global-elevation-data-6689f1d0ba65) into
12
- [quantized mesh terrain](https://github.com/CesiumGS/quantized-mesh),
13
- for rendering in the [CesiumJS digital globe](https://cesium.com).
14
- The module provides a general technique applicable to all raster imagery
15
- (although the Terrain-RGB format is near-ideal for streaming elevation data).
16
- Fixes for performance and better control of rendering quality are in progress.
17
-
18
- This module was created to support our geologic map visualization work
19
- at [Macrostrat](https://macrostrat.org) and as a building block
20
- for future rich geoscience visualizations.
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 installed
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 package manager.
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/) directory and runnable from the root project.
51
- The main example is built with Vite and others are built with Webpack v5. As well as showing how to use this module,
52
- these examples contain configuration for bundling Cesium in each packaging system.
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 `.env` file.
55
- in the root of this repository, and then start the appropriate example:
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
- These can be to add functionality (e.g. optional normal-map generation) or for
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 mesh,
71
- which caches the computationally-intensive step of meshing height-field data
72
- into a triangle irregular network (TIN). Unfortunately, this
73
- [quantized mesh](https://github.com/CesiumGS/quantized-mesh) format is relatively
74
- new, narrowly supported and tailored to Cesium itself. Going forward, supporting
75
- a TIN format for elevation datasets requires maintenance of significant single-purpose
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 raster GIS
81
- formats for representing terrain. Rasters are the standard representation of elevation data across the
82
- geosciences, and many pipelines are available to create and modify raster images.
83
- Basically any elevation dataset can be easily rescaled to the Terrain-RGB
84
- format, but the jump from there to a "Quantized mesh" is more complicated.
85
-
86
- Recently, the [MARTINI](https://github.com/mapbox/martini) project by
87
- [Vladimir Agafonkin](https://agafonkin.com/) at Mapbox demonstrated an
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
- MARTINI meshes based on right-triangulated irregular networks (RTIN, _Evans et al., 1998_)
91
- and is far quicker than the traditional TIN generation techniques.
92
-
93
- A speedy meshing algorithm allows this data-preparation step to be handled
94
- in the browser after elevation tiles are loaded. Integrating this
95
- toolchain into the Cesium digital globe enables the usage of Mapbox global
96
- data and other raster terrain layers (e.g. planetary and bathymetric data!),
97
- without adding overhead of TIN processing and storage.
98
-
99
- ## Current limitations
100
-
101
- ### Lack of support for overzooming
102
-
103
- Cesium's implementations of the `TerrainProvider` interface are generally geared
104
- towards representing static terrain meshes. The RTIN algorithm used here can
105
- dynamically build meshes at a variety of error levels, and the input height
106
- field are data-dense and can represent extremely detailed meshes at a given zoom level. Currently,
107
- meshes are generated at levels of detail that undersample the available structure
108
- in a terrain tile — levels of detail are calibrated to what Cesium needs to
109
- render visually pleasing output at a given zoom level.
110
-
111
- A smarter and more parsimonious solution would use much lower zoom levels
112
- for terrain than imagery, using the full resolution of the dataset in
113
- mesh construction. Done correctly, this could lead to an extremely
114
- data-efficient and adaptive terrain render, but this seems to run somewhat
115
- counter to how Cesium internally manages levels of detail. Ideally, someone familiar with the inner workings
116
- of Cesium would provide some guidance here.
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
- - [ ] TypeScript types are discarded on compilation rather than checked properly.
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
- ## TODO
151
+ ## Changelog
136
152
 
137
- - Make compatible with Mapbox's new `terrain-dem` tileset if possible
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
- Pull requests for any and all of these priorities are appreciated!
155
+ - Remove `.idea` files from bundle
143
156
 
144
- ## Changelog
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 [*Stuart Attenborrow*](https://github.com/stuarta0) to allow loading of non-Mapbox terrain tiles
149
- - Created Vite and Webpack examples of using the module with Mapzen Terrarium tiles
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 importing from [my fork](https://github.com/davenquinn/martini)
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 bundlers like [**Vite**](https://vitejs.dev). *Contributed by [@fc](https://github.com/fc).*
158
- - Change latitude-based scaling factor for tile error to improve fidelity at high latitudes.
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 overall design.
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 low-resolution tiles
179
- - Four (!) pull requests from [@stuarta0](https://github.com/stuarta0) to improve loading of non-Mapbox tilesets
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 through many terrain levels.
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
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ["@babel/preset-env", "@babel/preset-typescript"],
3
+ };