@anov/gis-skills-cli 0.0.0-stage → 0.3.3
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/CHANGELOG.md +637 -0
- package/INSTALL.md +481 -0
- package/LICENSE +15 -0
- package/README.md +148 -2
- package/RELEASING.md +162 -0
- package/bin/anov-gis-skills.mjs +470 -0
- package/lib/mcp-config.mjs +273 -0
- package/package.json +43 -4
- package/skills/anovgis-analysis/SKILL.md +585 -0
- package/skills/anovgis-effects/SKILL.md +260 -0
- package/skills/anovgis-imagery-terrain/SKILL.md +505 -0
- package/skills/anovgis-layers/SKILL.md +627 -0
- package/skills/anovgis-materials/SKILL.md +635 -0
- package/skills/anovgis-models-3dtiles/SKILL.md +448 -0
- package/skills/anovgis-pitfalls/SKILL.md +561 -0
- package/skills/anovgis-popup-widget/SKILL.md +474 -0
- package/skills/anovgis-primitives/SKILL.md +482 -0
- package/skills/anovgis-vector-graphics/SKILL.md +602 -0
- package/skills/anovgis-viewer/SKILL.md +618 -0
- package/skills/using-anovgis/DEMO-MAP.md +64 -0
- package/skills/using-anovgis/DEMO-SKILL-MAP.md +248 -0
- package/skills/using-anovgis/DOMAINS.md +183 -0
- package/skills/using-anovgis/REFERENCE.md +114 -0
- package/skills/using-anovgis/SKILL.md +392 -0
- package/skills/using-anovgis/templates/README.md +154 -0
- package/skills/using-anovgis/templates/combo1-vue3-vite.md +295 -0
- package/skills/using-anovgis/templates/combo2-vue2-cli.md +119 -0
- package/skills/using-anovgis/templates/combo3-html-cdn.md +107 -0
- package/skills/using-anovgis/templates/combo4-vanilla-webpack.md +91 -0
- package/skills/using-anovgis/templates/wizard-profiles.md +105 -0
- package/vendor/cesiumjs-skills/LICENSE +201 -0
- package/vendor/cesiumjs-skills/NOTICE +18 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-3d-tiles/SKILL.md +465 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-camera/SKILL.md +500 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-core-utilities/SKILL.md +403 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/REFERENCE.md +397 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/SKILL.md +351 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/01-diffuse-tint.js +38 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/02-texture-swap.js +42 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/03-feature-id-tileset.js +29 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/04-translucent-override.js +37 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/05-vertex-displacement.js +49 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/06-metadata-ramp.js +34 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/07-voxel-shader.js +27 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/README.md +19 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-custom-shader/examples/_sandcastle-template.html +9 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-entities/SKILL.md +389 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-imagery/SKILL.md +471 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-interaction/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-materials-shaders/SKILL.md +292 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-models-particles/SKILL.md +423 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-primitives/SKILL.md +537 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-spatial-math/SKILL.md +358 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-terrain-environment/SKILL.md +401 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-time-properties/SKILL.md +353 -0
- package/vendor/cesiumjs-skills/skills/cesiumjs-viewer-setup/SKILL.md +434 -0
- package/vendor/cesiumjs-skills/skills/using-cesiumjs-skills/SKILL.md +35 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: cesiumjs-terrain-environment
|
|
3
|
+
description: "CesiumJS terrain, globe, and environment - TerrainProvider, Globe, sampleTerrain, atmosphere, sky, fog, lighting, shadows, panoramas. Use when configuring terrain providers, querying terrain heights, customizing atmosphere or sky rendering, adding panoramas, or adjusting scene lighting and shadows."
|
|
4
|
+
---
|
|
5
|
+
# CesiumJS Terrain, Globe & Environment
|
|
6
|
+
|
|
7
|
+
Version baseline: CesiumJS v1.142 | ES module imports (`import { ... } from "cesium";`)
|
|
8
|
+
|
|
9
|
+
## Terrain Providers
|
|
10
|
+
|
|
11
|
+
Terrain is served through `TerrainProvider` implementations. Use async factory methods
|
|
12
|
+
(`fromIonAssetId`, `fromUrl`), not the constructor directly.
|
|
13
|
+
|
|
14
|
+
### Cesium Ion World Terrain
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { Viewer, Terrain } from "cesium";
|
|
18
|
+
|
|
19
|
+
const viewer = new Viewer("cesiumContainer", {
|
|
20
|
+
terrain: Terrain.fromWorldTerrain({
|
|
21
|
+
requestVertexNormals: true, // smoother lighting
|
|
22
|
+
requestWaterMask: true, // ocean water effect
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### CesiumTerrainProvider from Ion Asset / URL
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { CesiumTerrainProvider } from "cesium";
|
|
31
|
+
|
|
32
|
+
// By Ion asset ID (e.g. 3956 = Arctic DEM)
|
|
33
|
+
const tp = await CesiumTerrainProvider.fromIonAssetId(3956, {
|
|
34
|
+
requestVertexNormals: true,
|
|
35
|
+
});
|
|
36
|
+
viewer.scene.globe.terrainProvider = tp;
|
|
37
|
+
|
|
38
|
+
// By URL (self-hosted terrain server)
|
|
39
|
+
const tp2 = await CesiumTerrainProvider.fromUrl(
|
|
40
|
+
"https://my-server.example.com/terrain",
|
|
41
|
+
{ requestVertexNormals: true },
|
|
42
|
+
);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### EllipsoidTerrainProvider (Flat Globe)
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
import { EllipsoidTerrainProvider } from "cesium";
|
|
49
|
+
// Flat ellipsoid -- no terrain data, useful for 2D/Columbus or testing
|
|
50
|
+
viewer.scene.globe.terrainProvider = new EllipsoidTerrainProvider();
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### CustomHeightmapTerrainProvider (Procedural)
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
import { CustomHeightmapTerrainProvider } from "cesium";
|
|
57
|
+
|
|
58
|
+
viewer.scene.globe.terrainProvider = new CustomHeightmapTerrainProvider({
|
|
59
|
+
width: 32,
|
|
60
|
+
height: 32,
|
|
61
|
+
callback: function (x, y, level) {
|
|
62
|
+
const buf = new Float32Array(32 * 32);
|
|
63
|
+
for (let r = 0; r < 32; r++) {
|
|
64
|
+
for (let c = 0; c < 32; c++) {
|
|
65
|
+
buf[r * 32 + c] = Math.sin((x + c / 32) * 6.28) * 5000;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return buf;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Sampling Terrain Heights
|
|
74
|
+
|
|
75
|
+
Both functions mutate the input `Cartographic[]` in place (setting `.height`) and
|
|
76
|
+
return a promise resolving to the same array.
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
import { sampleTerrain, sampleTerrainMostDetailed, Cartographic } from "cesium";
|
|
80
|
+
|
|
81
|
+
const positions = [
|
|
82
|
+
Cartographic.fromDegrees(86.925145, 27.988257), // Mt Everest
|
|
83
|
+
Cartographic.fromDegrees(87.0, 28.0),
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
// Fixed LOD level -- fast, approximate
|
|
87
|
+
await sampleTerrain(viewer.scene.globe.terrainProvider, 11, positions);
|
|
88
|
+
|
|
89
|
+
// Max available LOD -- slower, most precise
|
|
90
|
+
// Requires provider.availability (e.g. CesiumTerrainProvider)
|
|
91
|
+
await sampleTerrainMostDetailed(viewer.scene.globe.terrainProvider, positions);
|
|
92
|
+
// positions[0].height is now populated
|
|
93
|
+
|
|
94
|
+
// Pass true as 3rd arg to reject on tile failure instead of undefined heights
|
|
95
|
+
await sampleTerrainMostDetailed(provider, positions, true);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Globe Configuration
|
|
99
|
+
|
|
100
|
+
Access via `viewer.scene.globe`. Controls terrain rendering, imagery layers,
|
|
101
|
+
atmosphere, and surface visual properties.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
const globe = viewer.scene.globe;
|
|
105
|
+
|
|
106
|
+
globe.show = true;
|
|
107
|
+
globe.maximumScreenSpaceError = 2; // terrain LOD quality (higher = less detail)
|
|
108
|
+
globe.tileCacheSize = 100; // tiles kept in memory
|
|
109
|
+
|
|
110
|
+
// Lighting
|
|
111
|
+
globe.enableLighting = true;
|
|
112
|
+
globe.dynamicAtmosphereLighting = true;
|
|
113
|
+
globe.dynamicAtmosphereLightingFromSun = false; // true = always sun direction
|
|
114
|
+
globe.lambertDiffuseMultiplier = 0.9;
|
|
115
|
+
|
|
116
|
+
// Atmosphere
|
|
117
|
+
globe.showGroundAtmosphere = true; // horizon glow (default true for WGS84)
|
|
118
|
+
globe.atmosphereHueShift = 0.0;
|
|
119
|
+
globe.atmosphereSaturationShift = 0.0;
|
|
120
|
+
globe.atmosphereBrightnessShift = 0.0;
|
|
121
|
+
|
|
122
|
+
// Surface behavior
|
|
123
|
+
globe.depthTestAgainstTerrain = false; // true = z-test entities vs terrain
|
|
124
|
+
globe.showWaterEffect = true; // animated ocean (needs water mask)
|
|
125
|
+
globe.shadows = Cesium.ShadowMode.RECEIVE_ONLY;
|
|
126
|
+
globe.baseColor = Cesium.Color.BLUE; // color when no imagery loaded
|
|
127
|
+
globe.backFaceCulling = true;
|
|
128
|
+
globe.showSkirts = true;
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Globe.pick and Globe.getHeight
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
// Raycast to globe surface
|
|
135
|
+
const ray = viewer.camera.getPickRay(windowPosition);
|
|
136
|
+
const hit = viewer.scene.globe.pick(ray, viewer.scene);
|
|
137
|
+
|
|
138
|
+
// Synchronous height from cached tiles (may return undefined)
|
|
139
|
+
const h = viewer.scene.globe.getHeight(Cesium.Cartographic.fromDegrees(-105, 40));
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Terrain Exaggeration
|
|
143
|
+
|
|
144
|
+
```js
|
|
145
|
+
// Set on Scene, not Globe
|
|
146
|
+
viewer.scene.verticalExaggeration = 2.0;
|
|
147
|
+
viewer.scene.verticalExaggerationRelativeHeight = 0.0; // relative to sea level
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Globe Translucency
|
|
151
|
+
|
|
152
|
+
Makes the globe see-through for underground/subsurface visualization.
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
const globe = viewer.scene.globe;
|
|
156
|
+
globe.translucency.enabled = true;
|
|
157
|
+
globe.translucency.frontFaceAlpha = 0.5;
|
|
158
|
+
globe.translucency.backFaceAlpha = 1.0;
|
|
159
|
+
|
|
160
|
+
// Distance-based alpha
|
|
161
|
+
globe.translucency.frontFaceAlphaByDistance = new Cesium.NearFarScalar(
|
|
162
|
+
1.5e2, 0.5, // near: 150m, alpha 0.5
|
|
163
|
+
8.0e6, 1.0, // far: 8000km, alpha 1.0
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
// Limit to geographic region
|
|
167
|
+
globe.translucency.rectangle = Cesium.Rectangle.fromDegrees(-120, 30, -80, 50);
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Elevation Band Material
|
|
171
|
+
|
|
172
|
+
Color the globe surface by elevation.
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
import { createElevationBandMaterial, Color } from "cesium";
|
|
176
|
+
|
|
177
|
+
viewer.scene.globe.material = createElevationBandMaterial({
|
|
178
|
+
scene: viewer.scene,
|
|
179
|
+
layers: [{
|
|
180
|
+
entries: [
|
|
181
|
+
{ height: 0, color: new Color(0.0, 0.0, 0.5, 1.0) },
|
|
182
|
+
{ height: 500, color: new Color(0.0, 0.8, 0.0, 1.0) },
|
|
183
|
+
{ height: 2000, color: new Color(0.6, 0.3, 0.1, 1.0) },
|
|
184
|
+
{ height: 5000, color: Color.WHITE },
|
|
185
|
+
],
|
|
186
|
+
}],
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## SkyAtmosphere
|
|
191
|
+
|
|
192
|
+
Atmospheric haze ring around the globe limb. 3D mode only.
|
|
193
|
+
|
|
194
|
+
```js
|
|
195
|
+
const sky = viewer.scene.skyAtmosphere;
|
|
196
|
+
sky.show = true;
|
|
197
|
+
sky.perFragmentAtmosphere = false; // true = higher quality, slight perf cost
|
|
198
|
+
sky.atmosphereLightIntensity = 50.0;
|
|
199
|
+
sky.hueShift = 0.0; // 0..1
|
|
200
|
+
sky.saturationShift = 0.0; // -1..1
|
|
201
|
+
sky.brightnessShift = 0.0; // -1..1
|
|
202
|
+
// Scattering coefficients (advanced tuning)
|
|
203
|
+
sky.atmosphereRayleighCoefficient = new Cesium.Cartesian3(5.5e-6, 13.0e-6, 28.4e-6);
|
|
204
|
+
sky.atmosphereMieCoefficient = new Cesium.Cartesian3(21e-6, 21e-6, 21e-6);
|
|
205
|
+
sky.atmosphereMieAnisotropy = 0.9;
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## SkyBox
|
|
209
|
+
|
|
210
|
+
Star field cube map behind the globe. 3D mode only.
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
import { SkyBox } from "cesium";
|
|
214
|
+
|
|
215
|
+
viewer.scene.skyBox = SkyBox.createEarthSkyBox(); // default stars
|
|
216
|
+
|
|
217
|
+
viewer.scene.skyBox = new SkyBox({
|
|
218
|
+
sources: {
|
|
219
|
+
positiveX: "skybox_px.png", negativeX: "skybox_nx.png",
|
|
220
|
+
positiveY: "skybox_py.png", negativeY: "skybox_ny.png",
|
|
221
|
+
positiveZ: "skybox_pz.png", negativeZ: "skybox_nz.png",
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Fog
|
|
227
|
+
|
|
228
|
+
Blends distant terrain toward atmosphere color and culls far tiles. 3D mode only.
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
const fog = viewer.scene.fog;
|
|
232
|
+
fog.enabled = true;
|
|
233
|
+
fog.renderable = true; // false = cull tiles but skip visual fog
|
|
234
|
+
fog.density = 0.0006; // higher = thicker fog, more culling
|
|
235
|
+
fog.visualDensityScalar = 0.15; // visual-only multiplier
|
|
236
|
+
fog.maxHeight = 800000.0; // fog disabled above this altitude (m)
|
|
237
|
+
fog.heightFalloff = 0.59; // exponential falloff (must be >0)
|
|
238
|
+
fog.screenSpaceErrorFactor = 2.0;
|
|
239
|
+
fog.minimumBrightness = 0.03; // prevents completely black fog
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Sun and Moon
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
viewer.scene.sun = new Cesium.Sun();
|
|
246
|
+
viewer.scene.sun.show = true;
|
|
247
|
+
viewer.scene.moon.show = true; // follows real lunar ephemeris
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
## Lighting
|
|
251
|
+
|
|
252
|
+
`scene.light` controls the scene light source. Default is `SunLight` (follows clock).
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
import { SunLight, DirectionalLight, Cartesian3, Color } from "cesium";
|
|
256
|
+
|
|
257
|
+
// SunLight -- follows the Sun position based on scene clock
|
|
258
|
+
viewer.scene.light = new SunLight({ color: Color.WHITE, intensity: 2.0 });
|
|
259
|
+
|
|
260
|
+
// DirectionalLight -- fixed direction for studio-style lighting
|
|
261
|
+
viewer.scene.light = new DirectionalLight({
|
|
262
|
+
direction: new Cartesian3(0.2, -0.5, -0.8), // must be non-zero
|
|
263
|
+
color: Color.WHITE,
|
|
264
|
+
intensity: 1.5,
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
viewer.scene.globe.enableLighting = true; // required for light to affect terrain
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
`DynamicAtmosphereLightingType` enum (NONE, SCENE_LIGHT, SUNLIGHT) is configured
|
|
271
|
+
via `globe.enableLighting`, `globe.dynamicAtmosphereLighting`, and
|
|
272
|
+
`globe.dynamicAtmosphereLightingFromSun` flags.
|
|
273
|
+
|
|
274
|
+
## Shadows
|
|
275
|
+
|
|
276
|
+
Cascaded shadow maps from the scene light source.
|
|
277
|
+
|
|
278
|
+
```js
|
|
279
|
+
viewer.shadows = true;
|
|
280
|
+
const sm = viewer.shadowMap;
|
|
281
|
+
sm.maximumDistance = 5000.0; // cascade range (meters)
|
|
282
|
+
sm.softShadows = true; // PCF for softer edges
|
|
283
|
+
sm.darkness = 0.3; // 0 = invisible, 1 = black
|
|
284
|
+
sm.fadingEnabled = true; // fade near horizon
|
|
285
|
+
|
|
286
|
+
viewer.scene.globe.shadows = Cesium.ShadowMode.RECEIVE_ONLY; // default
|
|
287
|
+
// ShadowMode: DISABLED, ENABLED, CAST_ONLY, RECEIVE_ONLY
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Panoramas (v1.139+)
|
|
291
|
+
|
|
292
|
+
360-degree imagery at a scene location. Two formats: equirectangular and cube map.
|
|
293
|
+
|
|
294
|
+
### EquirectangularPanorama
|
|
295
|
+
|
|
296
|
+
```js
|
|
297
|
+
import {
|
|
298
|
+
EquirectangularPanorama, Cartesian3,
|
|
299
|
+
HeadingPitchRoll, Transforms, Math as CesiumMath,
|
|
300
|
+
} from "cesium";
|
|
301
|
+
|
|
302
|
+
const position = Cartesian3.fromDegrees(-75.17, 39.95, 100.0);
|
|
303
|
+
const hpr = new HeadingPitchRoll(CesiumMath.toRadians(45), 0, 0);
|
|
304
|
+
const transform = Transforms.headingPitchRollToFixedFrame(position, hpr);
|
|
305
|
+
|
|
306
|
+
viewer.scene.primitives.add(new EquirectangularPanorama({
|
|
307
|
+
transform,
|
|
308
|
+
image: "path/to/equirectangular-360.jpg",
|
|
309
|
+
radius: 100000.0,
|
|
310
|
+
}));
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### CubeMapPanorama
|
|
314
|
+
|
|
315
|
+
```js
|
|
316
|
+
import { CubeMapPanorama, Cartesian3, Transforms, Matrix3, Matrix4 } from "cesium";
|
|
317
|
+
|
|
318
|
+
const pos = Cartesian3.fromDegrees(-122.42, 37.77, 10.0);
|
|
319
|
+
const northDown = Transforms.localFrameToFixedFrameGenerator("north", "down");
|
|
320
|
+
const xform = Matrix4.getMatrix3(northDown(pos), new Matrix3());
|
|
321
|
+
|
|
322
|
+
viewer.scene.primitives.add(new CubeMapPanorama({
|
|
323
|
+
sources: {
|
|
324
|
+
positiveX: "px.jpg", negativeX: "nx.jpg",
|
|
325
|
+
positiveY: "py.jpg", negativeY: "ny.jpg",
|
|
326
|
+
positiveZ: "pz.jpg", negativeZ: "nz.jpg",
|
|
327
|
+
},
|
|
328
|
+
transform: xform,
|
|
329
|
+
}));
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### GoogleStreetViewCubeMapPanoramaProvider
|
|
333
|
+
|
|
334
|
+
```js
|
|
335
|
+
import { GoogleStreetViewCubeMapPanoramaProvider, Cartographic } from "cesium";
|
|
336
|
+
|
|
337
|
+
const provider = new GoogleStreetViewCubeMapPanoramaProvider({
|
|
338
|
+
key: "YOUR_GOOGLE_STREETVIEW_API_KEY",
|
|
339
|
+
});
|
|
340
|
+
const pano = await provider.loadPanorama({
|
|
341
|
+
cartographic: Cartographic.fromDegrees(-122.42, 37.77, 0),
|
|
342
|
+
});
|
|
343
|
+
viewer.scene.primitives.add(pano);
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
## Terrain Provider Events
|
|
347
|
+
|
|
348
|
+
```js
|
|
349
|
+
viewer.scene.globe.terrainProviderChanged.addEventListener((newProvider) => {
|
|
350
|
+
console.log("Terrain changed:", newProvider.constructor.name);
|
|
351
|
+
});
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
## Performance Tips
|
|
355
|
+
|
|
356
|
+
1. **Increase `maximumScreenSpaceError`** from `2` to `4`+ on mobile -- single biggest
|
|
357
|
+
terrain perf knob.
|
|
358
|
+
2. **Keep fog enabled** (default) -- culls distant tiles, reducing draw calls.
|
|
359
|
+
3. **Avoid per-frame `verticalExaggeration` changes** -- forces terrain tile reloads.
|
|
360
|
+
4. **Set `requestVertexNormals: true` only when lighting is enabled** -- doubles tile size.
|
|
361
|
+
5. **Skip `requestWaterMask`** (default false) when `showWaterEffect` is off.
|
|
362
|
+
6. **Prefer `sampleTerrain` over `sampleTerrainMostDetailed`** when approximate heights
|
|
363
|
+
suffice -- resolves faster with fewer tile requests.
|
|
364
|
+
7. **Batch terrain sampling** -- pass all positions in one array to share tile loads.
|
|
365
|
+
8. **Tune `tileCacheSize`** -- increase for zoom-heavy workflows, decrease for memory.
|
|
366
|
+
9. **Disable `showGroundAtmosphere`** on non-Earth ellipsoids to avoid artifacts.
|
|
367
|
+
10. **Keep `depthTestAgainstTerrain = false`** (default) to avoid z-fighting with
|
|
368
|
+
labels and billboards near the surface.
|
|
369
|
+
|
|
370
|
+
## Quick Reference
|
|
371
|
+
|
|
372
|
+
| Class / Function | Purpose |
|
|
373
|
+
|---|---|
|
|
374
|
+
| `CesiumTerrainProvider.fromIonAssetId(id, opts)` | Ion terrain asset |
|
|
375
|
+
| `CesiumTerrainProvider.fromUrl(url, opts)` | Self-hosted terrain |
|
|
376
|
+
| `EllipsoidTerrainProvider` | Flat ellipsoid (no terrain) |
|
|
377
|
+
| `CustomHeightmapTerrainProvider` | Procedural/callback terrain |
|
|
378
|
+
| `ArcGISTiledElevationTerrainProvider` | ArcGIS elevation service |
|
|
379
|
+
| `sampleTerrain(provider, level, positions)` | Heights at fixed LOD |
|
|
380
|
+
| `sampleTerrainMostDetailed(provider, positions)` | Heights at max LOD |
|
|
381
|
+
| `Globe` | Surface rendering, terrain, atmosphere |
|
|
382
|
+
| `GlobeTranslucency` | See-through globe for underground views |
|
|
383
|
+
| `createElevationBandMaterial` | Color surface by elevation |
|
|
384
|
+
| `SkyAtmosphere` | Atmospheric limb glow |
|
|
385
|
+
| `SkyBox` / `SkyBox.createEarthSkyBox()` | Star field cube map |
|
|
386
|
+
| `Fog` | Distance fog and terrain culling |
|
|
387
|
+
| `Sun` / `Moon` | Celestial body rendering |
|
|
388
|
+
| `SunLight` | Light following the Sun |
|
|
389
|
+
| `DirectionalLight` | Fixed-direction light |
|
|
390
|
+
| `ShadowMap` | Cascaded shadow maps |
|
|
391
|
+
| `EquirectangularPanorama` | 360-degree panorama |
|
|
392
|
+
| `CubeMapPanorama` | Cube map panorama |
|
|
393
|
+
| `GoogleStreetViewCubeMapPanoramaProvider` | Google Street View panoramas |
|
|
394
|
+
| `DynamicAtmosphereLightingType` | Enum: NONE, SCENE_LIGHT, SUNLIGHT |
|
|
395
|
+
| `ShadowMode` | Enum: DISABLED, ENABLED, CAST_ONLY, RECEIVE_ONLY |
|
|
396
|
+
|
|
397
|
+
## See Also
|
|
398
|
+
|
|
399
|
+
- **cesiumjs-viewer-setup** -- Viewer initialization, Ion token, Scene configuration
|
|
400
|
+
- **cesiumjs-imagery** -- Imagery providers and layer management
|
|
401
|
+
- **cesiumjs-spatial-math** -- Cartesian3, Cartographic, Transforms, coordinate math
|