react-native-cesium 1.2.8 → 1.2.10
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/android/src/main/cpp/CesiumBridgeAndroid.cpp +24 -13
- package/android/src/main/cpp/CesiumBridgeAndroid.h +2 -1
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/CesiumBridgeJNI.kt +4 -3
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/HybridCesiumView.kt +12 -6
- package/cpp/engine/CesiumEngine.cpp +42 -9
- package/cpp/engine/CesiumEngine.hpp +9 -6
- package/cpp/engine/GlobeCamera.cpp +0 -1
- package/ios/CesiumBridge.h +6 -1
- package/ios/CesiumBridge.mm +21 -11
- package/ios/HybridCesiumView.swift +6 -6
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts +17 -7
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/specs/cesium-view.nitro.ts +23 -7
|
@@ -25,12 +25,22 @@ CesiumBridgeAndroid::~CesiumBridgeAndroid() {
|
|
|
25
25
|
|
|
26
26
|
void CesiumBridgeAndroid::init(JNIEnv* env, jobject surface, int width, int height,
|
|
27
27
|
const std::string& cacheDir,
|
|
28
|
-
const std::string& cacertPath
|
|
28
|
+
const std::string& cacertPath,
|
|
29
|
+
const std::string& ionAccessToken,
|
|
30
|
+
int64_t ionAssetId) {
|
|
29
31
|
config_.cacheDatabasePath = cacheDir.empty() ? "" : cacheDir + "/cesium_cache.db";
|
|
30
32
|
config_.tlsCaBundlePath = cacertPath;
|
|
31
33
|
viewportWidth_ = width;
|
|
32
34
|
viewportHeight_ = height;
|
|
33
35
|
|
|
36
|
+
// Seed the ion credentials before buildEngine so createTileset() can
|
|
37
|
+
// immediately start the async tileset.json HTTP round-trip, letting it
|
|
38
|
+
// overlap with Vulkan PSO compilation rather than run serially after it.
|
|
39
|
+
if (!ionAccessToken.empty()) {
|
|
40
|
+
config_.ionAccessToken = ionAccessToken;
|
|
41
|
+
config_.ionAssetId = ionAssetId;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
// ANativeWindow_fromSurface() acquires one strong reference on the
|
|
35
45
|
// returned window; we own it now and must call ANativeWindow_release() in
|
|
36
46
|
// shutdown() (or before re-acquiring) to avoid leaking it on every view
|
|
@@ -302,17 +312,15 @@ void CesiumBridgeAndroid::renderFrame(double nowSeconds) {
|
|
|
302
312
|
|
|
303
313
|
// ── Terrain floor clamp ───────────────────────────────────────────────
|
|
304
314
|
const float minAbove = engine_->getConfig().minAltitudeAboveTerrain;
|
|
305
|
-
if (minAbove > 0.0f) {
|
|
306
|
-
const double
|
|
315
|
+
if (minAbove > 0.0f && engine_->terrainFloorKnown()) {
|
|
316
|
+
const double geoidN =
|
|
307
317
|
reactnativecesium::mslToEllipsoidMeters(actual.latitude, actual.longitude, 0.0);
|
|
308
|
-
const double
|
|
309
|
-
|
|
310
|
-
const double
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
integrator_->clampActualAltitude(clampedMsl);
|
|
315
|
-
actual.altitude = clampedMsl;
|
|
318
|
+
const double floorMsl =
|
|
319
|
+
static_cast<double>(engine_->terrainFloorEllipsoidMeters()) - geoidN;
|
|
320
|
+
const double minMsl = floorMsl + static_cast<double>(minAbove);
|
|
321
|
+
if (actual.altitude < minMsl) {
|
|
322
|
+
integrator_->clampActualAltitude(minMsl);
|
|
323
|
+
actual.altitude = minMsl;
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
326
|
|
|
@@ -408,12 +416,15 @@ Java_com_margelo_nitro_reactnativecesium_CesiumBridgeJNI_nativeCreate(JNIEnv*, j
|
|
|
408
416
|
JNIEXPORT void JNICALL
|
|
409
417
|
Java_com_margelo_nitro_reactnativecesium_CesiumBridgeJNI_nativeInit(
|
|
410
418
|
JNIEnv* env, jobject, jlong ptr, jobject surface, jint w, jint h,
|
|
411
|
-
jstring cacheDir, jstring cacertPath) {
|
|
419
|
+
jstring cacheDir, jstring cacertPath, jstring ionAccessToken, jlong ionAssetId) {
|
|
412
420
|
const char* cacheDirC = env->GetStringUTFChars(cacheDir, nullptr);
|
|
413
421
|
const char* cacertC = env->GetStringUTFChars(cacertPath, nullptr);
|
|
414
|
-
|
|
422
|
+
const char* tokenC = env->GetStringUTFChars(ionAccessToken, nullptr);
|
|
423
|
+
getBridge(ptr)->init(env, surface, w, h, cacheDirC, cacertC,
|
|
424
|
+
tokenC ? tokenC : "", static_cast<int64_t>(ionAssetId));
|
|
415
425
|
env->ReleaseStringUTFChars(cacheDir, cacheDirC);
|
|
416
426
|
env->ReleaseStringUTFChars(cacertPath, cacertC);
|
|
427
|
+
env->ReleaseStringUTFChars(ionAccessToken, tokenC);
|
|
417
428
|
}
|
|
418
429
|
|
|
419
430
|
JNIEXPORT void JNICALL
|
|
@@ -36,7 +36,8 @@ struct CesiumBridgeAndroid {
|
|
|
36
36
|
CesiumBridgeAndroid& operator=(CesiumBridgeAndroid&&) = delete;
|
|
37
37
|
|
|
38
38
|
void init(JNIEnv* env, jobject surface, int width, int height,
|
|
39
|
-
const std::string& cacheDir, const std::string& cacertPath
|
|
39
|
+
const std::string& cacheDir, const std::string& cacertPath,
|
|
40
|
+
const std::string& ionAccessToken, int64_t ionAssetId);
|
|
40
41
|
void shutdown();
|
|
41
42
|
|
|
42
43
|
void resize(int width, int height);
|
|
@@ -9,8 +9,9 @@ import android.view.Surface
|
|
|
9
9
|
class CesiumBridgeJNI {
|
|
10
10
|
private var nativePtr: Long = nativeCreate()
|
|
11
11
|
|
|
12
|
-
fun init(surface: Surface, width: Int, height: Int, cacheDir: String, cacertPath: String
|
|
13
|
-
|
|
12
|
+
fun init(surface: Surface, width: Int, height: Int, cacheDir: String, cacertPath: String,
|
|
13
|
+
ionAccessToken: String = "", ionAssetId: Long = 1L) {
|
|
14
|
+
nativeInit(nativePtr, surface, width, height, cacheDir, cacertPath, ionAccessToken, ionAssetId)
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
fun shutdown() = nativeShutdown(nativePtr)
|
|
@@ -98,7 +99,7 @@ class CesiumBridgeJNI {
|
|
|
98
99
|
fun setMinAltitudeAboveTerrain(v: Float) = nativeSetMinAltitudeAboveTerrain(nativePtr, v)
|
|
99
100
|
|
|
100
101
|
private external fun nativeCreate(): Long
|
|
101
|
-
private external fun nativeInit(ptr: Long, surface: Surface, w: Int, h: Int, cacheDir: String, cacertPath: String)
|
|
102
|
+
private external fun nativeInit(ptr: Long, surface: Surface, w: Int, h: Int, cacheDir: String, cacertPath: String, ionAccessToken: String, ionAssetId: Long)
|
|
102
103
|
private external fun nativeShutdown(ptr: Long)
|
|
103
104
|
private external fun nativeDestroy(ptr: Long)
|
|
104
105
|
private external fun nativeResize(ptr: Long, w: Int, h: Int)
|
|
@@ -286,7 +286,12 @@ class HybridCesiumView(private val appContext: Context) : HybridCesiumViewSpec()
|
|
|
286
286
|
val cacertPath = extractCacert()
|
|
287
287
|
rh.post {
|
|
288
288
|
val b = CesiumBridgeJNI()
|
|
289
|
-
|
|
289
|
+
// sqliteCacheMaxRows and taskProcessorThreads are consumed once inside
|
|
290
|
+
// CesiumEngine::initialize() (SqliteCache + TaskProcessor sizing).
|
|
291
|
+
// They must be seeded into config_ before init() calls buildEngine().
|
|
292
|
+
sqliteCacheMaxRows?.let { b.setSqliteCacheMaxRows(it.toInt()) }
|
|
293
|
+
taskProcessorThreads?.let { b.setTaskProcessorThreads(it.toInt()) }
|
|
294
|
+
b.init(surface, w, h, cacheDir, cacertPath, ionAccessToken, ionAssetId.toLong())
|
|
290
295
|
bridge = b
|
|
291
296
|
syncBridgePropsOnRenderThread(b)
|
|
292
297
|
|
|
@@ -313,12 +318,13 @@ class HybridCesiumView(private val appContext: Context) : HybridCesiumViewSpec()
|
|
|
313
318
|
b.setViewCorrection(q.w, q.x, q.y, q.z); pendingViewCorrection = null
|
|
314
319
|
}
|
|
315
320
|
|
|
321
|
+
// Ion credentials were seeded at init() time for parallel tileset
|
|
322
|
+
// fetch; call updateIonAccessToken here only as a hot-reload safety
|
|
323
|
+
// net in case the token changed between bridge teardown and rebuild.
|
|
316
324
|
if (ionAccessToken.isNotEmpty()) {
|
|
317
325
|
b.updateIonAccessToken(ionAccessToken, ionAssetId.toLong())
|
|
318
326
|
}
|
|
319
|
-
|
|
320
|
-
b.updateImageryAssetId(ionImageryAssetId.toLong())
|
|
321
|
-
}
|
|
327
|
+
b.updateImageryAssetId(ionImageryAssetId.toLong())
|
|
322
328
|
b.setMsaa(msaaSampleCount.toInt())
|
|
323
329
|
|
|
324
330
|
pushRateCaps()
|
|
@@ -510,8 +516,8 @@ class HybridCesiumView(private val appContext: Context) : HybridCesiumViewSpec()
|
|
|
510
516
|
culledScreenSpaceError?.let { b.setCulledScreenSpaceError(it) }
|
|
511
517
|
enableLodTransitionPeriod?.let { b.setEnableLodTransitionPeriod(it) }
|
|
512
518
|
lodTransitionLength?.let { b.setLodTransitionLength(it) }
|
|
513
|
-
sqliteCacheMaxRows
|
|
514
|
-
|
|
519
|
+
// sqliteCacheMaxRows and taskProcessorThreads are applied before init() in
|
|
520
|
+
// surfaceCreated; calling them here (after buildEngine) has no effect.
|
|
515
521
|
minAltitudeAboveTerrain?.let { b.setMinAltitudeAboveTerrain(it.toFloat()) }
|
|
516
522
|
}
|
|
517
523
|
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
#include <Cesium3DTilesSelection/TilesetExternals.h>
|
|
14
14
|
#include <Cesium3DTilesSelection/TilesetOptions.h>
|
|
15
15
|
#include <CesiumGeospatial/BoundingRegion.h>
|
|
16
|
+
#include <CesiumGeospatial/Ellipsoid.h>
|
|
16
17
|
#include <CesiumGeospatial/GlobeRectangle.h>
|
|
18
|
+
#include <CesiumGeospatial/GlobeTransforms.h>
|
|
17
19
|
#include <CesiumAsync/CachingAssetAccessor.h>
|
|
18
20
|
#include <CesiumAsync/SqliteCache.h>
|
|
19
21
|
#include <CesiumCurl/CurlAssetAccessor.h>
|
|
@@ -607,7 +609,8 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
607
609
|
const double camLatRad = glm::radians(camParams.latitude);
|
|
608
610
|
const double camLonRad = glm::radians(camParams.longitude);
|
|
609
611
|
float bestTerrainFloor = terrainFloorEllipsoidM_; // carry previous value if no tile matches
|
|
610
|
-
double
|
|
612
|
+
double bestHorizDistSq = std::numeric_limits<double>::max();
|
|
613
|
+
bool floorScanFound = false;
|
|
611
614
|
|
|
612
615
|
// ── floor-scan cache lookup ─────────────────────────────────────────
|
|
613
616
|
// Skip the per-vertex scan when the camera has moved less than ~10 cm in
|
|
@@ -630,6 +633,18 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
630
633
|
// semantics aligned).
|
|
631
634
|
const bool runFloorScan = trackTerrainFloor && !floorScanFromCache;
|
|
632
635
|
|
|
636
|
+
// ENU basis at the camera — horizontal distance to each terrain vertex.
|
|
637
|
+
glm::dvec3 floorEast(1.0, 0.0, 0.0);
|
|
638
|
+
glm::dvec3 floorNorth(0.0, 1.0, 0.0);
|
|
639
|
+
if (runFloorScan) {
|
|
640
|
+
const auto& ellipsoid = CesiumGeospatial::Ellipsoid::WGS84;
|
|
641
|
+
const glm::dmat4 enuToEcef =
|
|
642
|
+
CesiumGeospatial::GlobeTransforms::eastNorthUpToFixedFrame(
|
|
643
|
+
cameraPos, ellipsoid);
|
|
644
|
+
floorEast = glm::normalize(glm::dvec3(enuToEcef[0]));
|
|
645
|
+
floorNorth = glm::normalize(glm::dvec3(enuToEcef[1]));
|
|
646
|
+
}
|
|
647
|
+
|
|
633
648
|
// ── fast path ────────────────────────────────────────────────────────
|
|
634
649
|
// The visible primitive list has been identical for kMaxFramesInFlight
|
|
635
650
|
// frames in a row, so every backend slot is guaranteed to hold a copy of
|
|
@@ -660,10 +675,18 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
660
675
|
for (size_t vi = 0; vi < vc; ++vi) {
|
|
661
676
|
const glm::dvec3 vECEF =
|
|
662
677
|
glm::dvec3(prim.localPositions[vi]) + prim.rtcCenter;
|
|
663
|
-
const
|
|
664
|
-
|
|
665
|
-
|
|
678
|
+
const glm::dvec3 delta = vECEF - cameraPos;
|
|
679
|
+
const double de = glm::dot(delta, floorEast);
|
|
680
|
+
const double dn = glm::dot(delta, floorNorth);
|
|
681
|
+
const double horizSq = de * de + dn * dn;
|
|
682
|
+
if (horizSq < bestHorizDistSq) {
|
|
683
|
+
bestHorizDistSq = horizSq;
|
|
666
684
|
bestTerrainFloor = prim.altitudes[vi];
|
|
685
|
+
floorScanFound = true;
|
|
686
|
+
} else if (horizSq <= bestHorizDistSq * (1.0 + 1e-9) + 1e-4) {
|
|
687
|
+
bestTerrainFloor =
|
|
688
|
+
std::min(bestTerrainFloor, prim.altitudes[vi]);
|
|
689
|
+
floorScanFound = true;
|
|
667
690
|
}
|
|
668
691
|
}
|
|
669
692
|
}
|
|
@@ -703,8 +726,9 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
703
726
|
result.cameraLon = paramsFP.longitude;
|
|
704
727
|
result.cameraAlt = paramsFP.altitude;
|
|
705
728
|
|
|
706
|
-
if (trackTerrainFloor) {
|
|
729
|
+
if (trackTerrainFloor && (floorScanFound || floorScanFromCache)) {
|
|
707
730
|
terrainFloorEllipsoidM_ = bestTerrainFloor;
|
|
731
|
+
terrainFloorValid_ = true;
|
|
708
732
|
// P5: refresh the floor cache on a fresh scan; skip when we hit the
|
|
709
733
|
// cache (the stored value already reflects this signature).
|
|
710
734
|
if (runFloorScan && signature != 0ULL) {
|
|
@@ -763,10 +787,18 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
763
787
|
for (size_t vi = 0; vi < vertexCount; ++vi) {
|
|
764
788
|
const glm::dvec3 vECEF =
|
|
765
789
|
glm::dvec3(prim.localPositions[vi]) + prim.rtcCenter;
|
|
766
|
-
const
|
|
767
|
-
|
|
768
|
-
|
|
790
|
+
const glm::dvec3 delta = vECEF - cameraPos;
|
|
791
|
+
const double de = glm::dot(delta, floorEast);
|
|
792
|
+
const double dn = glm::dot(delta, floorNorth);
|
|
793
|
+
const double horizSq = de * de + dn * dn;
|
|
794
|
+
if (horizSq < bestHorizDistSq) {
|
|
795
|
+
bestHorizDistSq = horizSq;
|
|
769
796
|
bestTerrainFloor = prim.altitudes[vi];
|
|
797
|
+
floorScanFound = true;
|
|
798
|
+
} else if (horizSq <= bestHorizDistSq * (1.0 + 1e-9) + 1e-4) {
|
|
799
|
+
bestTerrainFloor =
|
|
800
|
+
std::min(bestTerrainFloor, prim.altitudes[vi]);
|
|
801
|
+
floorScanFound = true;
|
|
770
802
|
}
|
|
771
803
|
}
|
|
772
804
|
}
|
|
@@ -1018,8 +1050,9 @@ void CesiumEngine::updateFrame(double w, double h, FrameResult& result) {
|
|
|
1018
1050
|
result.cameraLon = params.longitude;
|
|
1019
1051
|
result.cameraAlt = params.altitude;
|
|
1020
1052
|
|
|
1021
|
-
if (trackTerrainFloor) {
|
|
1053
|
+
if (trackTerrainFloor && (floorScanFound || floorScanFromCache)) {
|
|
1022
1054
|
terrainFloorEllipsoidM_ = bestTerrainFloor;
|
|
1055
|
+
terrainFloorValid_ = true;
|
|
1023
1056
|
// refresh the floor cache on a fresh scan (slow path always runs a
|
|
1024
1057
|
// scan unless the cache short-circuit fired above). Only memoise when
|
|
1025
1058
|
// the geometry signature is stable enough to key on.
|
|
@@ -142,10 +142,11 @@ public:
|
|
|
142
142
|
|
|
143
143
|
const EngineConfig& getConfig() const { return config_; }
|
|
144
144
|
|
|
145
|
-
// Ellipsoid height (metres) of the terrain
|
|
146
|
-
//
|
|
147
|
-
// tile covering the camera position has been rendered.
|
|
145
|
+
// Ellipsoid height (metres) of the terrain surface under the camera nadir,
|
|
146
|
+
// sampled from loaded tile meshes. Meaningless until terrainFloorKnown().
|
|
148
147
|
float terrainFloorEllipsoidMeters() const { return terrainFloorEllipsoidM_; }
|
|
148
|
+
// True after at least one frame has sampled the floor from real terrain tiles.
|
|
149
|
+
bool terrainFloorKnown() const { return terrainFloorValid_; }
|
|
149
150
|
|
|
150
151
|
private:
|
|
151
152
|
void createTileset();
|
|
@@ -184,9 +185,10 @@ private:
|
|
|
184
185
|
GlobeCamera camera_;
|
|
185
186
|
TileLifecycleManager lifecycle_;
|
|
186
187
|
|
|
187
|
-
// Ellipsoid height of the terrain surface at the camera nadir
|
|
188
|
-
//
|
|
188
|
+
// Ellipsoid height of the terrain surface at the camera nadir (horizontal
|
|
189
|
+
// nearest-neighbour sample). Only written after a successful tile scan.
|
|
189
190
|
float terrainFloorEllipsoidM_ = 0.0f;
|
|
191
|
+
bool terrainFloorValid_ = false;
|
|
190
192
|
|
|
191
193
|
// Wall-clock timestamp of the previous updateFrame call. Used to compute
|
|
192
194
|
// deltaTime for Tileset::updateViewGroup, which drives LOD transition fading.
|
|
@@ -225,7 +227,8 @@ private:
|
|
|
225
227
|
// ── terrain-floor scan cache ──────────────────────────────────────
|
|
226
228
|
// The minAltitudeAboveTerrain clamp scans every vertex of every tile whose
|
|
227
229
|
// bounding region contains the camera lon/lat and picks the altitude of
|
|
228
|
-
// the vertex with the smallest
|
|
230
|
+
// the vertex with the smallest horizontal (ENU) distance to the camera
|
|
231
|
+
// nadir (tie-break: lower ellipsoid height). That's an O(NV)
|
|
229
232
|
// scan over the visible primitives — dominant CPU cost when the camera
|
|
230
233
|
// sits over a dense LOD chain. Result depends only on the camera lon/lat
|
|
231
234
|
// and the set of visible primitives, so we cache it keyed on
|
package/ios/CesiumBridge.h
CHANGED
|
@@ -12,12 +12,17 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
12
12
|
/// Pass `ionAccessToken` and `ionAssetId` here so the engine can start the
|
|
13
13
|
/// async tileset.json network round-trip immediately, before Metal pipeline
|
|
14
14
|
/// compilation begins — letting the two operations overlap in time.
|
|
15
|
+
/// `sqliteCacheMaxRows` and `taskProcessorThreads` must also be provided here
|
|
16
|
+
/// because they are consumed once when the SqliteCache / TaskProcessor are
|
|
17
|
+
/// constructed inside `buildEngine`; setting them after init has no effect.
|
|
15
18
|
- (instancetype)initWithMetalLayer:(CAMetalLayer *)layer
|
|
16
19
|
width:(int)width
|
|
17
20
|
height:(int)height
|
|
18
21
|
cacheDir:(NSString *)cacheDir
|
|
19
22
|
ionAccessToken:(NSString *)token
|
|
20
|
-
ionAssetId:(int64_t)assetId
|
|
23
|
+
ionAssetId:(int64_t)assetId
|
|
24
|
+
sqliteCacheMaxRows:(int32_t)sqliteRows
|
|
25
|
+
taskProcessorThreads:(int32_t)threads;
|
|
21
26
|
|
|
22
27
|
- (void)updateIonAccessToken:(NSString *)token assetId:(int64_t)assetId;
|
|
23
28
|
- (void)updateImageryAssetId:(int64_t)assetId;
|
package/ios/CesiumBridge.mm
CHANGED
|
@@ -56,7 +56,9 @@
|
|
|
56
56
|
height:(int)height
|
|
57
57
|
cacheDir:(NSString *)cacheDir
|
|
58
58
|
ionAccessToken:(NSString *)token
|
|
59
|
-
ionAssetId:(int64_t)assetId
|
|
59
|
+
ionAssetId:(int64_t)assetId
|
|
60
|
+
sqliteCacheMaxRows:(int32_t)sqliteRows
|
|
61
|
+
taskProcessorThreads:(int32_t)threads {
|
|
60
62
|
self = [super init];
|
|
61
63
|
if (self) {
|
|
62
64
|
_viewportWidth = width;
|
|
@@ -90,6 +92,16 @@
|
|
|
90
92
|
_config.ionAssetId = assetId;
|
|
91
93
|
}
|
|
92
94
|
|
|
95
|
+
// These two params are consumed once inside CesiumEngine::initialize()
|
|
96
|
+
// (SqliteCache constructor and TaskProcessor thread-pool sizing). Setting
|
|
97
|
+
// them after buildEngine() has no effect, so they must be seeded here.
|
|
98
|
+
if (sqliteRows > 0) {
|
|
99
|
+
_config.sqliteCacheMaxRows = std::max<int32_t>(64, sqliteRows);
|
|
100
|
+
}
|
|
101
|
+
if (threads >= 0) {
|
|
102
|
+
_config.taskProcessorThreads = threads;
|
|
103
|
+
}
|
|
104
|
+
|
|
93
105
|
_metalBackend = std::make_unique<reactnativecesium::MetalBackend>();
|
|
94
106
|
|
|
95
107
|
// Start the async tileset.json fetch before Metal PSO compilation so both
|
|
@@ -375,17 +387,15 @@
|
|
|
375
387
|
// Uses terrain floor from the previous frame (one-frame lag is
|
|
376
388
|
// imperceptible at 60 fps). Skipped when minAltitudeAboveTerrain == 0.
|
|
377
389
|
const float minAbove = _engine->getConfig().minAltitudeAboveTerrain;
|
|
378
|
-
if (minAbove > 0.0f) {
|
|
379
|
-
const double
|
|
390
|
+
if (minAbove > 0.0f && _engine->terrainFloorKnown()) {
|
|
391
|
+
const double geoidN =
|
|
380
392
|
reactnativecesium::mslToEllipsoidMeters(actual.latitude, actual.longitude, 0.0);
|
|
381
|
-
const double
|
|
382
|
-
|
|
383
|
-
const double
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
_integrator->clampActualAltitude(clampedMsl);
|
|
388
|
-
actual.altitude = clampedMsl;
|
|
393
|
+
const double floorMsl =
|
|
394
|
+
static_cast<double>(_engine->terrainFloorEllipsoidMeters()) - geoidN;
|
|
395
|
+
const double minMsl = floorMsl + static_cast<double>(minAbove);
|
|
396
|
+
if (actual.altitude < minMsl) {
|
|
397
|
+
_integrator->clampActualAltitude(minMsl);
|
|
398
|
+
actual.altitude = minMsl;
|
|
389
399
|
}
|
|
390
400
|
}
|
|
391
401
|
|
|
@@ -381,7 +381,9 @@ class HybridCesiumView: HybridCesiumViewSpec {
|
|
|
381
381
|
height: Int32(h),
|
|
382
382
|
cacheDir: cacheDir,
|
|
383
383
|
ionAccessToken: ionAccessToken,
|
|
384
|
-
ionAssetId: Int64(ionAssetId)
|
|
384
|
+
ionAssetId: Int64(ionAssetId),
|
|
385
|
+
sqliteCacheMaxRows: Int32(sqliteCacheMaxRows ?? 0),
|
|
386
|
+
taskProcessorThreads: Int32(taskProcessorThreads ?? 0)
|
|
385
387
|
)
|
|
386
388
|
|
|
387
389
|
syncBridgeOptionsFromProps()
|
|
@@ -416,9 +418,7 @@ class HybridCesiumView: HybridCesiumViewSpec {
|
|
|
416
418
|
if let f = pendingVfov { bridge?.setVerticalFovDeg(f); pendingVfov = nil }
|
|
417
419
|
if let q = pendingViewCorrection { bridge?.setViewCorrectionW(q.w, x: q.x, y: q.y, z: q.z); pendingViewCorrection = nil }
|
|
418
420
|
|
|
419
|
-
|
|
420
|
-
bridge?.updateImageryAssetId(Int64(ionImageryAssetId))
|
|
421
|
-
}
|
|
421
|
+
bridge?.updateImageryAssetId(Int64(ionImageryAssetId))
|
|
422
422
|
|
|
423
423
|
let sc = Int32(msaaSampleCount)
|
|
424
424
|
bridge?.setMsaaSampleCount(sc)
|
|
@@ -457,8 +457,8 @@ class HybridCesiumView: HybridCesiumViewSpec {
|
|
|
457
457
|
if let v = culledScreenSpaceError { bridge?.setCulledScreenSpaceError(v) }
|
|
458
458
|
if let v = enableLodTransitionPeriod { bridge?.setEnableLodTransitionPeriod(v) }
|
|
459
459
|
if let v = lodTransitionLength { bridge?.setLodTransitionLength(v) }
|
|
460
|
-
|
|
461
|
-
|
|
460
|
+
// sqliteCacheMaxRows and taskProcessorThreads are applied at construction
|
|
461
|
+
// time via the CesiumBridge initializer; calling them here has no effect.
|
|
462
462
|
if let v = minAltitudeAboveTerrain { bridge?.setMinAltitudeAboveTerrain(Float(v)) }
|
|
463
463
|
}
|
|
464
464
|
|
|
@@ -57,7 +57,7 @@ export interface CesiumViewProps extends HybridViewProps {
|
|
|
57
57
|
preloadAncestors?: boolean;
|
|
58
58
|
/** Pre-load sibling tiles around the visible set. Default true. */
|
|
59
59
|
preloadSiblings?: boolean;
|
|
60
|
-
/** Refuse to render holes in the terrain. Default
|
|
60
|
+
/** Refuse to render holes in the terrain. Default false (matching Cesium Native). Relax for fast pans. */
|
|
61
61
|
forbidHoles?: boolean;
|
|
62
62
|
/** Decode water-mask textures (coastline shading). Default true. */
|
|
63
63
|
enableWaterMask?: boolean;
|
|
@@ -71,15 +71,25 @@ export interface CesiumViewProps extends HybridViewProps {
|
|
|
71
71
|
enableLodTransitionPeriod?: boolean;
|
|
72
72
|
/** Length (s) of the LOD cross-fade. Default 1. */
|
|
73
73
|
lodTransitionLength?: number;
|
|
74
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* Sqlite asset cache row budget. Default 4096.
|
|
76
|
+
* Must be set on initial mount — changes after the first render are ignored
|
|
77
|
+
* because the cache is opened once at engine construction time.
|
|
78
|
+
*/
|
|
75
79
|
sqliteCacheMaxRows?: number;
|
|
76
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* Worker thread count. 0 = auto (hardware_concurrency-1, clamped 2..16).
|
|
82
|
+
* Must be set on initial mount — the thread pool is sized once at engine
|
|
83
|
+
* construction time and cannot be resized at runtime.
|
|
84
|
+
*/
|
|
77
85
|
taskProcessorThreads?: number;
|
|
78
86
|
/**
|
|
79
|
-
* Minimum
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* terrain
|
|
87
|
+
* Minimum clearance above the loaded terrain surface, in metres (added on top of the
|
|
88
|
+
* terrain MSL height at the camera position). Default 0 (no constraint).
|
|
89
|
+
* Set to e.g. 2 to prevent the camera from going underground.
|
|
90
|
+
* The clamp runs only after terrain tiles have been sampled; until then the demand
|
|
91
|
+
* altitude is used as-is. The demand altitude is not modified — only the rendered
|
|
92
|
+
* (actual) camera may be raised to meet this minimum.
|
|
83
93
|
*/
|
|
84
94
|
minAltitudeAboveTerrain?: number;
|
|
85
95
|
/** Maximum yaw rate (degrees per second). 0 = uncapped. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cesium-view.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/cesium-view.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EAClB,MAAM,4BAA4B,CAAA;AAEnC;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACj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AM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IAEpD;;;;OAIG;IACH,iBAAiB,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAAA;IAEtC,uEAAuE;IACvE,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAA;IAEjC;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;IAEnC;;;;;OAKG;IACH,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IAEvC;;;;OAIG;IACH,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IAEvC,8EAA8E;IAC9E,iBAAiB,IAAI,OAAO,CAAC,UAAU,CAAC,CAAA;CACzC;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-cesium",
|
|
3
|
-
"version": "1.2.
|
|
4
|
-
"description": "Experimental Cesium rendering for React Native via Nitro
|
|
3
|
+
"version": "1.2.10",
|
|
4
|
+
"description": "Experimental Cesium rendering for React Native via Nitro",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
7
7
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"node": ">=18"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"react-native-nitro-modules": "^0.35.
|
|
67
|
+
"react-native-nitro-modules": "^0.35.7"
|
|
68
68
|
},
|
|
69
69
|
"publishConfig": {
|
|
70
70
|
"access": "public",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@types/jest": "^29.5.14",
|
|
78
78
|
"@types/react": "19.2.14",
|
|
79
79
|
"conventional-changelog-conventionalcommits": "^9.3.1",
|
|
80
|
-
"nitrogen": "0.35.
|
|
80
|
+
"nitrogen": "0.35.7",
|
|
81
81
|
"react": "19.2.3",
|
|
82
82
|
"react-native": "0.85.3",
|
|
83
83
|
"react-native-builder-bob": "^0.41.0",
|
|
@@ -61,13 +61,17 @@ export interface CesiumViewProps extends HybridViewProps {
|
|
|
61
61
|
ionImageryAssetId: number
|
|
62
62
|
|
|
63
63
|
// ── Optional perf / quality knobs ────────────────────────────────────────
|
|
64
|
+
// Note: all optional props below use "set once" semantics. Once a value has
|
|
65
|
+
// been applied to the native engine, removing the prop (returning it to
|
|
66
|
+
// `undefined`) does NOT revert the engine to its built-in default — the last
|
|
67
|
+
// explicitly set value is retained. To reset, pass the desired default value.
|
|
64
68
|
/** RAM budget for live tileset, in mebibytes. Default 256. */
|
|
65
69
|
maximumCachedMiB?: number
|
|
66
70
|
/** Pre-load ancestor tiles around the visible set (smoother panning, more loads). Default true. */
|
|
67
71
|
preloadAncestors?: boolean
|
|
68
72
|
/** Pre-load sibling tiles around the visible set. Default true. */
|
|
69
73
|
preloadSiblings?: boolean
|
|
70
|
-
/** Refuse to render holes in the terrain. Default
|
|
74
|
+
/** Refuse to render holes in the terrain. Default false (matching Cesium Native). Relax for fast pans. */
|
|
71
75
|
forbidHoles?: boolean
|
|
72
76
|
/** Decode water-mask textures (coastline shading). Default true. */
|
|
73
77
|
enableWaterMask?: boolean
|
|
@@ -81,15 +85,25 @@ export interface CesiumViewProps extends HybridViewProps {
|
|
|
81
85
|
enableLodTransitionPeriod?: boolean
|
|
82
86
|
/** Length (s) of the LOD cross-fade. Default 1. */
|
|
83
87
|
lodTransitionLength?: number
|
|
84
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Sqlite asset cache row budget. Default 4096.
|
|
90
|
+
* Must be set on initial mount — changes after the first render are ignored
|
|
91
|
+
* because the cache is opened once at engine construction time.
|
|
92
|
+
*/
|
|
85
93
|
sqliteCacheMaxRows?: number
|
|
86
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Worker thread count. 0 = auto (hardware_concurrency-1, clamped 2..16).
|
|
96
|
+
* Must be set on initial mount — the thread pool is sized once at engine
|
|
97
|
+
* construction time and cannot be resized at runtime.
|
|
98
|
+
*/
|
|
87
99
|
taskProcessorThreads?: number
|
|
88
100
|
/**
|
|
89
|
-
* Minimum
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
* terrain
|
|
101
|
+
* Minimum clearance above the loaded terrain surface, in metres (added on top of the
|
|
102
|
+
* terrain MSL height at the camera position). Default 0 (no constraint).
|
|
103
|
+
* Set to e.g. 2 to prevent the camera from going underground.
|
|
104
|
+
* The clamp runs only after terrain tiles have been sampled; until then the demand
|
|
105
|
+
* altitude is used as-is. The demand altitude is not modified — only the rendered
|
|
106
|
+
* (actual) camera may be raised to meet this minimum.
|
|
93
107
|
*/
|
|
94
108
|
minAltitudeAboveTerrain?: number
|
|
95
109
|
|
|
@@ -98,6 +112,8 @@ export interface CesiumViewProps extends HybridViewProps {
|
|
|
98
112
|
// angular / linear speed on the integrator's per-DoF velocity. Useful when
|
|
99
113
|
// your sensor feed is noisy and you would rather drop the change than
|
|
100
114
|
// visually whip the camera.
|
|
115
|
+
// Note: same "set once" semantics as the knobs above — removing the prop
|
|
116
|
+
// keeps the last value rather than reverting to 0 (uncapped).
|
|
101
117
|
/** Maximum yaw rate (degrees per second). 0 = uncapped. */
|
|
102
118
|
maxYawRateDegSec?: number
|
|
103
119
|
/** Maximum pitch rate (degrees per second). 0 = uncapped. */
|