react-native-cesium 1.0.6 → 1.2.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 +64 -11
- package/ReactNativeCesium.podspec +1 -1
- package/android/CMakeLists.txt +5 -3
- package/android/src/main/cpp/CesiumBridgeAndroid.cpp +197 -227
- package/android/src/main/cpp/CesiumBridgeAndroid.h +48 -49
- package/android/src/main/cpp/cpp-adapter.cpp +2 -2
- package/android/src/main/cpp/vulkan/VulkanBackend.cpp +1010 -569
- package/android/src/main/cpp/vulkan/VulkanBackend.h +121 -12
- package/android/src/main/cpp/vulkan/shaders/sky.frag +20 -10
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/CesiumBridgeJNI.kt +28 -0
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/HybridCesiumView.kt +295 -58
- package/cpp/engine/CameraSmoother.cpp +99 -0
- package/cpp/engine/CameraSmoother.hpp +29 -0
- package/cpp/engine/CameraTargetState.cpp +49 -0
- package/cpp/engine/CameraTargetState.hpp +121 -0
- package/cpp/engine/CesiumEngine.cpp +206 -60
- package/cpp/engine/CesiumEngine.hpp +77 -10
- package/cpp/engine/EngineTunables.hpp +79 -0
- package/cpp/engine/GeoidConverter.cpp +36 -0
- package/cpp/engine/GeoidConverter.hpp +10 -0
- package/cpp/engine/GlobeCamera.cpp +7 -2
- package/cpp/engine/MetricsAggregator.cpp +71 -0
- package/cpp/engine/MetricsAggregator.hpp +54 -0
- package/cpp/engine/TileLifecycleManager.cpp +0 -12
- package/cpp/engine/TileLifecycleManager.hpp +0 -3
- package/cpp/third_party/egm96/EGM96.c +289 -0
- package/cpp/third_party/egm96/EGM96.h +45 -0
- package/cpp/third_party/egm96/EGM96_data.h +65372 -0
- package/ios/CesiumBridge.h +24 -5
- package/ios/CesiumBridge.mm +149 -271
- package/ios/HybridCesiumView.swift +197 -40
- package/ios/metal/MetalBackend.mm +72 -23
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts +26 -0
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +5 -1
- package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.cpp +109 -1
- package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.hpp +24 -0
- package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +48 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +32 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Quaternion.kt +19 -0
- package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.hpp +30 -0
- package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.hpp +85 -1
- package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +60 -0
- package/nitrogen/generated/ios/swift/CesiumMetrics.swift +7 -2
- package/nitrogen/generated/ios/swift/HybridCesiumViewSpec.swift +12 -0
- package/nitrogen/generated/ios/swift/HybridCesiumViewSpec_cxx.swift +288 -0
- package/nitrogen/generated/shared/c++/CesiumMetrics.hpp +5 -1
- package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.cpp +24 -0
- package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.hpp +25 -1
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +132 -0
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +13 -1
- package/nitrogen/generated/shared/json/CesiumViewConfig.json +12 -0
- package/package.json +4 -4
- package/scripts/cesium/clone.mjs +1 -1
- package/src/specs/cesium-view.nitro.ts +29 -0
- package/cpp/engine/DeletionQueue.cpp +0 -28
- package/cpp/engine/DeletionQueue.hpp +0 -28
package/README.md
CHANGED
|
@@ -242,8 +242,14 @@ export function GlobeScreen() {
|
|
|
242
242
|
maximumScreenSpaceError={16}
|
|
243
243
|
maximumSimultaneousTileLoads={8}
|
|
244
244
|
loadingDescendantLimit={20}
|
|
245
|
-
msaaSampleCount={
|
|
245
|
+
msaaSampleCount={4}
|
|
246
246
|
ionImageryAssetId={2}
|
|
247
|
+
// Optional perf / quality knobs (see "Optional performance / quality knobs" below).
|
|
248
|
+
// Omit to use the built-in defaults; values shown here are typical for a high-end phone.
|
|
249
|
+
maximumCachedMiB={384}
|
|
250
|
+
preloadAncestors
|
|
251
|
+
forbidHoles
|
|
252
|
+
enableLodTransitionPeriod
|
|
247
253
|
onMetrics={callback((metrics: CesiumMetrics) => {
|
|
248
254
|
console.log('Cesium FPS:', metrics.fps)
|
|
249
255
|
})}
|
|
@@ -279,7 +285,7 @@ When you pass a callback ref to `CesiumView`, wrap it with `callback(...)` from
|
|
|
279
285
|
| `maximumScreenSpaceError` | `number` | `32` | Quality/performance trade-off for tile refinement. Lower values are sharper (more work); higher values are faster/blurrier. |
|
|
280
286
|
| `maximumSimultaneousTileLoads` | `number` | `12` | Max concurrent tile fetch/decode operations. Raising `8 -> 16` can improve fast camera moves on good networks but may increase memory/bandwidth spikes. |
|
|
281
287
|
| `loadingDescendantLimit` | `number` | `20` | Caps descendant tile fan-out during traversal. Lower values like `10` smooth bursts on low-end devices; higher values like `40` can fill detail faster. |
|
|
282
|
-
| `msaaSampleCount` | `number` | `1` | Anti-aliasing sample count.
|
|
288
|
+
| `msaaSampleCount` | `number` | `1` | Anti-aliasing sample count. Both backends support `1`, `2`, `4`, or `8`; the value is clamped to the largest sample count the physical device can frame-buffer (Metal: `device.supportsTextureSampleCount`, Vulkan: `framebufferColorSampleCounts & framebufferDepthSampleCounts`). On tiled mobile GPUs the multisample colour buffer is allocated `LAZILY_ALLOCATED` where supported, so MSAA's memory cost is largely on-chip. |
|
|
283
289
|
| `ionImageryAssetId` | `number` | `1` | Imagery layer to drape over terrain/tiles. Use a satellite imagery asset for a photoreal look, or switch to a streets/map layer for legibility. See your Cesium Ion Asset IDs. |
|
|
284
290
|
|
|
285
291
|
**Consumer-optional props (TypeScript)**
|
|
@@ -288,6 +294,35 @@ When you pass a callback ref to `CesiumView`, wrap it with `callback(...)` from
|
|
|
288
294
|
| --- | --- | --- | --- |
|
|
289
295
|
| `onMetrics` | `(metrics: CesiumMetrics) => void` | `undefined` | Receives throttled runtime stats and credits text. |
|
|
290
296
|
|
|
297
|
+
**Optional performance / quality knobs**
|
|
298
|
+
|
|
299
|
+
These props are all optional. Leave them unset to use the built-in defaults; set them to override per-screen for fine-grained control. They are runtime-mutable: changing them at any time after the view has mounted re-applies to the live tileset (no engine rebuild) except where noted.
|
|
300
|
+
|
|
301
|
+
| Prop | Type | Default | Description |
|
|
302
|
+
| --- | --- | --- | --- |
|
|
303
|
+
| `maximumCachedMiB` | `number` | `256` | RAM budget (mebibytes) for decoded geometry / textures held by the live tileset. Lower values (e.g. `128`) reduce peak memory on entry-level devices; higher values (`512+`) keep more tiles resident across long pans. |
|
|
304
|
+
| `preloadAncestors` | `boolean` | `true` | Pre-load ancestor tiles around the visible set. Smoother panning at higher load pressure. |
|
|
305
|
+
| `preloadSiblings` | `boolean` | `true` | Pre-load sibling tiles around the visible set. Same trade-off as `preloadAncestors`. |
|
|
306
|
+
| `forbidHoles` | `boolean` | `true` | When `true`, Cesium keeps coarser ancestor tiles visible until all children load. Setting to `false` during fast pans reduces upload pressure at the cost of brief visible "holes". |
|
|
307
|
+
| `enableWaterMask` | `boolean` | `true` | Decode the per-tile water-mask texture used for coastline shading and the ocean-vs-land hypsometric branch. Disable to save bandwidth on memory-constrained devices. |
|
|
308
|
+
| `enableFogCulling` | `boolean` | `false` | When `true`, tiles fully inside the atmospheric fog volume are culled before refinement. |
|
|
309
|
+
| `enforceCulledScreenSpaceError` | `boolean` | `true` | When `enableFogCulling` is `true`, allow fogged tiles to refine to a coarser SSE — saves work on tiles that will never be visually scrutinised. |
|
|
310
|
+
| `culledScreenSpaceError` | `number` | `64` | The relaxed SSE applied to fogged tiles when `enforceCulledScreenSpaceError` is `true`. |
|
|
311
|
+
| `enableLodTransitionPeriod` | `boolean` | `false` | Cross-fade between LODs as tiles refine instead of hard-popping. Smoother visually; very small per-frame cost. |
|
|
312
|
+
| `lodTransitionLength` | `number` | `1.0` | Length in seconds of the LOD cross-fade when `enableLodTransitionPeriod` is `true`. |
|
|
313
|
+
| `sqliteCacheMaxRows` | `number` | `4096` | Maximum number of cached HTTP responses Cesium keeps in `cesium_cache.db` between sessions. Tablets can comfortably go to `16384`. **Re-applied only on the next view init** — runtime changes take effect after the next mount. |
|
|
314
|
+
| `taskProcessorThreads` | `number` | `0` (auto) | Worker pool size for tile parsing / texture decode. `0` (default) auto-sizes to `clamp(2, std::thread::hardware_concurrency() - 1, 8)`. Override for benchmarking or to throttle background CPU on shared-render apps. **Re-applied only on the next view init.** |
|
|
315
|
+
|
|
316
|
+
#### Suggested presets
|
|
317
|
+
|
|
318
|
+
The defaults are tuned for current-generation phones (e.g. iPhone 13/Pixel 6 and newer). Useful starting points for other classes of device:
|
|
319
|
+
|
|
320
|
+
| Profile | `maximumScreenSpaceError` | `maximumSimultaneousTileLoads` | `maximumCachedMiB` | `forbidHoles` | `enableLodTransitionPeriod` |
|
|
321
|
+
| --- | --- | --- | --- | --- | --- |
|
|
322
|
+
| **High-end / tablet** | `16` | `16` | `512` | `true` | `true` |
|
|
323
|
+
| **Default / phone** | `32` | `12` | `256` | `true` | `false` |
|
|
324
|
+
| **Battery-saver / low-end** | `48` | `6` | `128` | `false` | `false` |
|
|
325
|
+
|
|
291
326
|
### `CameraState`
|
|
292
327
|
|
|
293
328
|
```ts
|
|
@@ -302,15 +337,15 @@ type CameraState = {
|
|
|
302
337
|
}
|
|
303
338
|
```
|
|
304
339
|
|
|
305
|
-
| Field | Type | Valid range / format
|
|
306
|
-
| --- | ---
|
|
307
|
-
| `latitude` | `number` | `-90..90`
|
|
308
|
-
| `longitude` | `number` | `-180..180`
|
|
309
|
-
| `altitude` | `number` | Meters above
|
|
310
|
-
| `heading` | `number` | Degrees
|
|
311
|
-
| `pitch` | `number` | Degrees
|
|
312
|
-
| `roll` | `number` | Degrees
|
|
313
|
-
| `verticalFovDeg` | `number` | `20..100` (clamped)
|
|
340
|
+
| Field | Type | Valid range / format | Description |
|
|
341
|
+
| --- | --- |------------------------------|-------------------------------------------------------------------------------------------------------|
|
|
342
|
+
| `latitude` | `number` | `-90..90` | Camera latitude in degrees. |
|
|
343
|
+
| `longitude` | `number` | `-180..180` | Camera longitude in degrees. |
|
|
344
|
+
| `altitude` | `number` | Meters above sea level (MSL) | Camera height in meters. |
|
|
345
|
+
| `heading` | `number` | Degrees | Compass direction the camera faces. Example: `0` faces north, `90` faces east. |
|
|
346
|
+
| `pitch` | `number` | Degrees | Tilt angle. Negative values look downward toward terrain; positive values tilt up toward horizon/sky. |
|
|
347
|
+
| `roll` | `number` | Degrees | Bank/rotation around forward axis. Positive right bank, negative left bank. |
|
|
348
|
+
| `verticalFovDeg` | `number` | `20..100` (clamped) | Vertical field of view in degrees; see **Field of view** (next section). |
|
|
314
349
|
|
|
315
350
|
### Field of view: vertical vs horizontal, full vs half, and Cesium alignment
|
|
316
351
|
|
|
@@ -362,6 +397,22 @@ Avoid assuming **main-thread-only** vs **JS-thread-only** labels beyond the abov
|
|
|
362
397
|
- You may **mix** the two: calling `setCamera` updates position and HPR but leaves the last view-correction target unchanged, so a calibration quaternion set earlier continues to apply until you change it with `setCameraQuaternion`.
|
|
363
398
|
- Prefer **`setCameraQuaternion`** on frames where you need to drive both the globe camera and the correction together so the native target stays consistent.
|
|
364
399
|
|
|
400
|
+
#### Smoothing of incoming camera updates
|
|
401
|
+
|
|
402
|
+
Every value you pass to `setCamera` / `setCameraQuaternion` is treated as a **demand** target — what you would *like* the camera to be — rather than a per-frame command. The native render thread runs an exponential filter every frame that converges the displayed camera onto your demand target, which means a coarse 1 Hz position feed (e.g. external GPS) does **not** teleport the view once a second. Instead it eases between samples.
|
|
403
|
+
|
|
404
|
+
| DoF | Smoothing |
|
|
405
|
+
| --- | --- |
|
|
406
|
+
| `latitude` / `longitude` | **Adaptive** exponential filter. Time constant `τ = clamp(α · ewmaInterval, τmin, τmax)` where `ewmaInterval` tracks the cadence of your `setCamera` calls. ~60 Hz gestures collapse `τ` to the floor (≤1 frame of trail, indistinguishable from the previous "snap" behaviour); ~1 Hz GPS feeds expand `τ` so each sample is ~95 % converged before the next arrives. Cross-planet jumps (Δ > ~0.5°) bypass the smoother and snap, so a deliberate teleport stays instant. Antimeridian crossings always rotate the short way. |
|
|
407
|
+
| `altitude` | Exponential, fixed `τ ≈ 40 ms`. |
|
|
408
|
+
| `heading` / `pitch` / `roll` | Exponential on the shortest-arc angular delta, fixed `τ ≈ 20–33 ms`. |
|
|
409
|
+
| `viewCorrection` (quaternion) | SLERP-based exponential, fixed `τ ≈ 20 ms`, hemisphere-corrected so it always takes the short rotation. |
|
|
410
|
+
| `verticalFovDeg` | Applied directly (not smoothed). |
|
|
411
|
+
|
|
412
|
+
You don't have to do anything special to take advantage of this — the smoother already runs, it's the same code path whether your driver is a Reanimated worklet at 60 Hz, a `setInterval` push at 10 Hz, or a 1 Hz GPS subscription. Just call `setCamera` whenever you have a new value.
|
|
413
|
+
|
|
414
|
+
If the smoothing ever feels off for your data source, the relevant constants live in [`cpp/engine/EngineTunables.hpp`](cpp/engine/EngineTunables.hpp) (`kSmoothPositionAlpha`, `kSmoothPositionTauMin`, `kSmoothPositionTauMax`, `kPosSnapThroughDeg`, `kEwmaIntervalAlpha`, plus the per-DoF `kSmooth*` rates).
|
|
415
|
+
|
|
365
416
|
### `CesiumMetrics`
|
|
366
417
|
|
|
367
418
|
| Field | Type | Description |
|
|
@@ -371,6 +422,7 @@ Avoid assuming **main-thread-only** vs **JS-thread-only** labels beyond the abov
|
|
|
371
422
|
| `tilesLoading` | `number` | Number of tiles still loading. If this stays high for long periods, reduce load pressure (`maximumSimultaneousTileLoads`) or check network. |
|
|
372
423
|
| `tilesVisited` | `number` | Number of tiles visited during traversal/culling. |
|
|
373
424
|
| `ionTokenConfigured` | `boolean` | Whether a non-empty Ion token is configured natively. `false` is a quick signal to check `ionAccessToken`. |
|
|
425
|
+
| `tlsConfigured` | `boolean` | Whether libcurl resolved a CA bundle for HTTPS. `false` means TLS to `api.cesium.com` may fail; on iOS verify `cacert.pem` is in the main bundle, on Android that the asset is bundled (the package ships one for you). |
|
|
374
426
|
| `tilesetReady` | `boolean` | Whether the primary tileset is initialized and ready. |
|
|
375
427
|
| `creditsPlainText` | `string` | Plain-text attribution/credits from Cesium data sources. Display this in your app footer to satisfy attribution requirements. |
|
|
376
428
|
|
|
@@ -393,6 +445,7 @@ The example project currently links this library locally via `link:..`.
|
|
|
393
445
|
|
|
394
446
|
- Native rendering is built on [Cesium Native](https://github.com/CesiumGS/cesium-native)
|
|
395
447
|
- Cesium Native is licensed under Apache 2.0; see [`NOTICE`](./NOTICE)
|
|
448
|
+
- EGM96 altitude offset calculations using [EGM96](https://github.com/emericg/EGM96)
|
|
396
449
|
- React Native integration is built with [Nitro Modules](https://github.com/mrousavy/nitro)
|
|
397
450
|
|
|
398
451
|
|
package/android/CMakeLists.txt
CHANGED
|
@@ -69,11 +69,13 @@ add_library(${PACKAGE_NAME} SHARED
|
|
|
69
69
|
../cpp/engine/ResourcePreparer.cpp
|
|
70
70
|
../cpp/engine/GltfToMesh.cpp
|
|
71
71
|
../cpp/engine/GlobeCamera.cpp
|
|
72
|
-
../cpp/engine/
|
|
72
|
+
../cpp/engine/GeoidConverter.cpp
|
|
73
73
|
../cpp/engine/TileLifecycleManager.cpp
|
|
74
|
-
|
|
74
|
+
../cpp/engine/CameraSmoother.cpp
|
|
75
|
+
../cpp/engine/CameraTargetState.cpp
|
|
76
|
+
../cpp/engine/MetricsAggregator.cpp
|
|
77
|
+
../cpp/third_party/egm96/EGM96.c
|
|
75
78
|
src/main/cpp/vulkan/VulkanBackend.cpp
|
|
76
|
-
# JNI bridge
|
|
77
79
|
src/main/cpp/CesiumBridgeAndroid.cpp
|
|
78
80
|
)
|
|
79
81
|
|