react-native-cesium 1.2.17 → 1.2.19

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.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/android/CMakeLists.txt +1 -0
  3. package/android/build.gradle +1 -1
  4. package/android/gradle.properties +4 -4
  5. package/android/src/main/cpp/CesiumBridgeAndroid.cpp +5 -15
  6. package/android/src/main/cpp/CesiumBridgeAndroid.h +2 -0
  7. package/android/src/main/cpp/vulkan/VulkanBackend.cpp +40 -4
  8. package/cpp/engine/CameraIntegrator.cpp +82 -47
  9. package/cpp/engine/CameraIntegrator.hpp +27 -8
  10. package/cpp/engine/CesiumEngine.cpp +152 -304
  11. package/cpp/engine/CesiumEngine.hpp +38 -28
  12. package/cpp/engine/EngineTunables.hpp +6 -5
  13. package/cpp/engine/GltfToMesh.cpp +14 -5
  14. package/cpp/engine/ResourcePreparer.cpp +3 -3
  15. package/cpp/engine/ResourcePreparer.hpp +1 -1
  16. package/cpp/engine/TerrainFloor.hpp +70 -0
  17. package/cpp/engine/TerrainHeight.hpp +113 -0
  18. package/cpp/engine/test/CameraIntegratorTest.cpp +264 -0
  19. package/ios/CesiumBridge.mm +7 -27
  20. package/lib/typescript/src/specs/cesium-view.nitro.d.ts +7 -6
  21. package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -1
  22. package/nitrogen/generated/android/ReactNativeCesiumOnLoad.cpp +1 -1
  23. package/nitrogen/generated/android/c++/JCameraState.hpp +1 -1
  24. package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +1 -1
  25. package/nitrogen/generated/android/c++/JQuaternion.hpp +1 -1
  26. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +177 -131
  27. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.hpp +6 -1
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +1 -1
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +1 -1
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CameraState.kt +0 -2
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CesiumMetrics.kt +0 -2
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +2 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Quaternion.kt +1 -1
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewManager.kt +26 -10
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewStateUpdater.kt +2 -2
  36. package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +211 -161
  37. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +34 -335
  38. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +107 -77
  39. package/package.json +12 -12
  40. package/scripts/cesium/config.mjs +1 -1
  41. package/scripts/cesium/vcpkg-triplets/arm64-ios-simulator.cmake +3 -0
  42. package/scripts/cesium/vcpkg-triplets/arm64-ios.cmake +4 -0
  43. package/src/specs/cesium-view.nitro.ts +7 -6
@@ -7,325 +7,49 @@
7
7
 
8
8
  #include "HybridCesiumViewComponent.hpp"
9
9
 
10
- #include <string>
11
- #include <exception>
12
- #include <utility>
13
- #include <NitroModules/NitroDefines.hpp>
14
- #include <NitroModules/JSIConverter.hpp>
15
- #include <NitroModules/PropNameIDCache.hpp>
16
- #include <react/renderer/core/RawValue.h>
17
- #include <react/renderer/core/ShadowNode.h>
18
- #include <react/renderer/core/ComponentDescriptor.h>
19
- #include <react/renderer/components/view/ViewProps.h>
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/ReactProp.hpp>
20
12
 
21
13
  namespace margelo::nitro::reactnativecesium::views {
22
14
 
15
+ using namespace facebook;
16
+
23
17
  extern const char HybridCesiumViewComponentName[] = "CesiumView";
24
18
 
25
19
  HybridCesiumViewProps::HybridCesiumViewProps(const react::PropsParserContext& context,
26
20
  const HybridCesiumViewProps& sourceProps,
27
21
  const react::RawProps& rawProps):
28
22
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
- ionAccessToken([&]() -> CachedProp<std::string> {
30
- try {
31
- const react::RawValue* rawValue = rawProps.at("ionAccessToken", nullptr, nullptr);
32
- if (rawValue == nullptr) return sourceProps.ionAccessToken;
33
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
- return CachedProp<std::string>::fromRawValue(*runtime, value, sourceProps.ionAccessToken);
35
- } catch (const std::exception& exc) {
36
- throw std::runtime_error(std::string("CesiumView.ionAccessToken: ") + exc.what());
37
- }
38
- }()),
39
- ionAssetId([&]() -> CachedProp<double> {
40
- try {
41
- const react::RawValue* rawValue = rawProps.at("ionAssetId", nullptr, nullptr);
42
- if (rawValue == nullptr) return sourceProps.ionAssetId;
43
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.ionAssetId);
45
- } catch (const std::exception& exc) {
46
- throw std::runtime_error(std::string("CesiumView.ionAssetId: ") + exc.what());
47
- }
48
- }()),
49
- initialCamera([&]() -> CachedProp<CameraState> {
50
- try {
51
- const react::RawValue* rawValue = rawProps.at("initialCamera", nullptr, nullptr);
52
- if (rawValue == nullptr) return sourceProps.initialCamera;
53
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
- return CachedProp<CameraState>::fromRawValue(*runtime, value, sourceProps.initialCamera);
55
- } catch (const std::exception& exc) {
56
- throw std::runtime_error(std::string("CesiumView.initialCamera: ") + exc.what());
57
- }
58
- }()),
59
- pauseRendering([&]() -> CachedProp<bool> {
60
- try {
61
- const react::RawValue* rawValue = rawProps.at("pauseRendering", nullptr, nullptr);
62
- if (rawValue == nullptr) return sourceProps.pauseRendering;
63
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
- return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.pauseRendering);
65
- } catch (const std::exception& exc) {
66
- throw std::runtime_error(std::string("CesiumView.pauseRendering: ") + exc.what());
67
- }
68
- }()),
69
- maximumScreenSpaceError([&]() -> CachedProp<double> {
70
- try {
71
- const react::RawValue* rawValue = rawProps.at("maximumScreenSpaceError", nullptr, nullptr);
72
- if (rawValue == nullptr) return sourceProps.maximumScreenSpaceError;
73
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.maximumScreenSpaceError);
75
- } catch (const std::exception& exc) {
76
- throw std::runtime_error(std::string("CesiumView.maximumScreenSpaceError: ") + exc.what());
77
- }
78
- }()),
79
- maximumSimultaneousTileLoads([&]() -> CachedProp<double> {
80
- try {
81
- const react::RawValue* rawValue = rawProps.at("maximumSimultaneousTileLoads", nullptr, nullptr);
82
- if (rawValue == nullptr) return sourceProps.maximumSimultaneousTileLoads;
83
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.maximumSimultaneousTileLoads);
85
- } catch (const std::exception& exc) {
86
- throw std::runtime_error(std::string("CesiumView.maximumSimultaneousTileLoads: ") + exc.what());
87
- }
88
- }()),
89
- loadingDescendantLimit([&]() -> CachedProp<double> {
90
- try {
91
- const react::RawValue* rawValue = rawProps.at("loadingDescendantLimit", nullptr, nullptr);
92
- if (rawValue == nullptr) return sourceProps.loadingDescendantLimit;
93
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.loadingDescendantLimit);
95
- } catch (const std::exception& exc) {
96
- throw std::runtime_error(std::string("CesiumView.loadingDescendantLimit: ") + exc.what());
97
- }
98
- }()),
99
- msaaSampleCount([&]() -> CachedProp<double> {
100
- try {
101
- const react::RawValue* rawValue = rawProps.at("msaaSampleCount", nullptr, nullptr);
102
- if (rawValue == nullptr) return sourceProps.msaaSampleCount;
103
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.msaaSampleCount);
105
- } catch (const std::exception& exc) {
106
- throw std::runtime_error(std::string("CesiumView.msaaSampleCount: ") + exc.what());
107
- }
108
- }()),
109
- ionImageryAssetId([&]() -> CachedProp<double> {
110
- try {
111
- const react::RawValue* rawValue = rawProps.at("ionImageryAssetId", nullptr, nullptr);
112
- if (rawValue == nullptr) return sourceProps.ionImageryAssetId;
113
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.ionImageryAssetId);
115
- } catch (const std::exception& exc) {
116
- throw std::runtime_error(std::string("CesiumView.ionImageryAssetId: ") + exc.what());
117
- }
118
- }()),
119
- maximumCachedMiB([&]() -> CachedProp<std::optional<double>> {
120
- try {
121
- const react::RawValue* rawValue = rawProps.at("maximumCachedMiB", nullptr, nullptr);
122
- if (rawValue == nullptr) return sourceProps.maximumCachedMiB;
123
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maximumCachedMiB);
125
- } catch (const std::exception& exc) {
126
- throw std::runtime_error(std::string("CesiumView.maximumCachedMiB: ") + exc.what());
127
- }
128
- }()),
129
- preloadAncestors([&]() -> CachedProp<std::optional<bool>> {
130
- try {
131
- const react::RawValue* rawValue = rawProps.at("preloadAncestors", nullptr, nullptr);
132
- if (rawValue == nullptr) return sourceProps.preloadAncestors;
133
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.preloadAncestors);
135
- } catch (const std::exception& exc) {
136
- throw std::runtime_error(std::string("CesiumView.preloadAncestors: ") + exc.what());
137
- }
138
- }()),
139
- preloadSiblings([&]() -> CachedProp<std::optional<bool>> {
140
- try {
141
- const react::RawValue* rawValue = rawProps.at("preloadSiblings", nullptr, nullptr);
142
- if (rawValue == nullptr) return sourceProps.preloadSiblings;
143
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
144
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.preloadSiblings);
145
- } catch (const std::exception& exc) {
146
- throw std::runtime_error(std::string("CesiumView.preloadSiblings: ") + exc.what());
147
- }
148
- }()),
149
- forbidHoles([&]() -> CachedProp<std::optional<bool>> {
150
- try {
151
- const react::RawValue* rawValue = rawProps.at("forbidHoles", nullptr, nullptr);
152
- if (rawValue == nullptr) return sourceProps.forbidHoles;
153
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
154
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.forbidHoles);
155
- } catch (const std::exception& exc) {
156
- throw std::runtime_error(std::string("CesiumView.forbidHoles: ") + exc.what());
157
- }
158
- }()),
159
- enableWaterMask([&]() -> CachedProp<std::optional<bool>> {
160
- try {
161
- const react::RawValue* rawValue = rawProps.at("enableWaterMask", nullptr, nullptr);
162
- if (rawValue == nullptr) return sourceProps.enableWaterMask;
163
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
164
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enableWaterMask);
165
- } catch (const std::exception& exc) {
166
- throw std::runtime_error(std::string("CesiumView.enableWaterMask: ") + exc.what());
167
- }
168
- }()),
169
- enableFogCulling([&]() -> CachedProp<std::optional<bool>> {
170
- try {
171
- const react::RawValue* rawValue = rawProps.at("enableFogCulling", nullptr, nullptr);
172
- if (rawValue == nullptr) return sourceProps.enableFogCulling;
173
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
174
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enableFogCulling);
175
- } catch (const std::exception& exc) {
176
- throw std::runtime_error(std::string("CesiumView.enableFogCulling: ") + exc.what());
177
- }
178
- }()),
179
- enforceCulledScreenSpaceError([&]() -> CachedProp<std::optional<bool>> {
180
- try {
181
- const react::RawValue* rawValue = rawProps.at("enforceCulledScreenSpaceError", nullptr, nullptr);
182
- if (rawValue == nullptr) return sourceProps.enforceCulledScreenSpaceError;
183
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
184
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enforceCulledScreenSpaceError);
185
- } catch (const std::exception& exc) {
186
- throw std::runtime_error(std::string("CesiumView.enforceCulledScreenSpaceError: ") + exc.what());
187
- }
188
- }()),
189
- culledScreenSpaceError([&]() -> CachedProp<std::optional<double>> {
190
- try {
191
- const react::RawValue* rawValue = rawProps.at("culledScreenSpaceError", nullptr, nullptr);
192
- if (rawValue == nullptr) return sourceProps.culledScreenSpaceError;
193
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
194
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.culledScreenSpaceError);
195
- } catch (const std::exception& exc) {
196
- throw std::runtime_error(std::string("CesiumView.culledScreenSpaceError: ") + exc.what());
197
- }
198
- }()),
199
- enableLodTransitionPeriod([&]() -> CachedProp<std::optional<bool>> {
200
- try {
201
- const react::RawValue* rawValue = rawProps.at("enableLodTransitionPeriod", nullptr, nullptr);
202
- if (rawValue == nullptr) return sourceProps.enableLodTransitionPeriod;
203
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
204
- return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enableLodTransitionPeriod);
205
- } catch (const std::exception& exc) {
206
- throw std::runtime_error(std::string("CesiumView.enableLodTransitionPeriod: ") + exc.what());
207
- }
208
- }()),
209
- lodTransitionLength([&]() -> CachedProp<std::optional<double>> {
210
- try {
211
- const react::RawValue* rawValue = rawProps.at("lodTransitionLength", nullptr, nullptr);
212
- if (rawValue == nullptr) return sourceProps.lodTransitionLength;
213
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
214
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.lodTransitionLength);
215
- } catch (const std::exception& exc) {
216
- throw std::runtime_error(std::string("CesiumView.lodTransitionLength: ") + exc.what());
217
- }
218
- }()),
219
- sqliteCacheMaxRows([&]() -> CachedProp<std::optional<double>> {
220
- try {
221
- const react::RawValue* rawValue = rawProps.at("sqliteCacheMaxRows", nullptr, nullptr);
222
- if (rawValue == nullptr) return sourceProps.sqliteCacheMaxRows;
223
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
224
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.sqliteCacheMaxRows);
225
- } catch (const std::exception& exc) {
226
- throw std::runtime_error(std::string("CesiumView.sqliteCacheMaxRows: ") + exc.what());
227
- }
228
- }()),
229
- taskProcessorThreads([&]() -> CachedProp<std::optional<double>> {
230
- try {
231
- const react::RawValue* rawValue = rawProps.at("taskProcessorThreads", nullptr, nullptr);
232
- if (rawValue == nullptr) return sourceProps.taskProcessorThreads;
233
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
234
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.taskProcessorThreads);
235
- } catch (const std::exception& exc) {
236
- throw std::runtime_error(std::string("CesiumView.taskProcessorThreads: ") + exc.what());
237
- }
238
- }()),
239
- minAltitudeAboveTerrain([&]() -> CachedProp<std::optional<double>> {
240
- try {
241
- const react::RawValue* rawValue = rawProps.at("minAltitudeAboveTerrain", nullptr, nullptr);
242
- if (rawValue == nullptr) return sourceProps.minAltitudeAboveTerrain;
243
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
244
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.minAltitudeAboveTerrain);
245
- } catch (const std::exception& exc) {
246
- throw std::runtime_error(std::string("CesiumView.minAltitudeAboveTerrain: ") + exc.what());
247
- }
248
- }()),
249
- maxYawRateDegSec([&]() -> CachedProp<std::optional<double>> {
250
- try {
251
- const react::RawValue* rawValue = rawProps.at("maxYawRateDegSec", nullptr, nullptr);
252
- if (rawValue == nullptr) return sourceProps.maxYawRateDegSec;
253
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
254
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxYawRateDegSec);
255
- } catch (const std::exception& exc) {
256
- throw std::runtime_error(std::string("CesiumView.maxYawRateDegSec: ") + exc.what());
257
- }
258
- }()),
259
- maxPitchRateDegSec([&]() -> CachedProp<std::optional<double>> {
260
- try {
261
- const react::RawValue* rawValue = rawProps.at("maxPitchRateDegSec", nullptr, nullptr);
262
- if (rawValue == nullptr) return sourceProps.maxPitchRateDegSec;
263
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
264
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxPitchRateDegSec);
265
- } catch (const std::exception& exc) {
266
- throw std::runtime_error(std::string("CesiumView.maxPitchRateDegSec: ") + exc.what());
267
- }
268
- }()),
269
- maxRollRateDegSec([&]() -> CachedProp<std::optional<double>> {
270
- try {
271
- const react::RawValue* rawValue = rawProps.at("maxRollRateDegSec", nullptr, nullptr);
272
- if (rawValue == nullptr) return sourceProps.maxRollRateDegSec;
273
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
274
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxRollRateDegSec);
275
- } catch (const std::exception& exc) {
276
- throw std::runtime_error(std::string("CesiumView.maxRollRateDegSec: ") + exc.what());
277
- }
278
- }()),
279
- maxClimbRateMps([&]() -> CachedProp<std::optional<double>> {
280
- try {
281
- const react::RawValue* rawValue = rawProps.at("maxClimbRateMps", nullptr, nullptr);
282
- if (rawValue == nullptr) return sourceProps.maxClimbRateMps;
283
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
284
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxClimbRateMps);
285
- } catch (const std::exception& exc) {
286
- throw std::runtime_error(std::string("CesiumView.maxClimbRateMps: ") + exc.what());
287
- }
288
- }()),
289
- maxGroundSpeedMps([&]() -> CachedProp<std::optional<double>> {
290
- try {
291
- const react::RawValue* rawValue = rawProps.at("maxGroundSpeedMps", nullptr, nullptr);
292
- if (rawValue == nullptr) return sourceProps.maxGroundSpeedMps;
293
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
294
- return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxGroundSpeedMps);
295
- } catch (const std::exception& exc) {
296
- throw std::runtime_error(std::string("CesiumView.maxGroundSpeedMps: ") + exc.what());
297
- }
298
- }()),
299
- onMetrics([&]() -> CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>> {
300
- try {
301
- const react::RawValue* rawValue = rawProps.at("onMetrics", nullptr, nullptr);
302
- if (rawValue == nullptr) return sourceProps.onMetrics;
303
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
304
- return CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onMetrics);
305
- } catch (const std::exception& exc) {
306
- throw std::runtime_error(std::string("CesiumView.onMetrics: ") + exc.what());
307
- }
308
- }()),
309
- onActualCamera([&]() -> CachedProp<std::optional<std::function<void(const CameraState& /* camera */)>>> {
310
- try {
311
- const react::RawValue* rawValue = rawProps.at("onActualCamera", nullptr, nullptr);
312
- if (rawValue == nullptr) return sourceProps.onActualCamera;
313
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
314
- return CachedProp<std::optional<std::function<void(const CameraState& /* camera */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onActualCamera);
315
- } catch (const std::exception& exc) {
316
- throw std::runtime_error(std::string("CesiumView.onActualCamera: ") + exc.what());
317
- }
318
- }()),
319
- hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>> {
320
- try {
321
- const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
322
- if (rawValue == nullptr) return sourceProps.hybridRef;
323
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
324
- return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
325
- } catch (const std::exception& exc) {
326
- throw std::runtime_error(std::string("CesiumView.hybridRef: ") + exc.what());
327
- }
328
- }()) { }
23
+ ionAccessToken(nitro::ReactProp<std::string>::fromRawValue("CesiumView", "ionAccessToken", rawProps, sourceProps.ionAccessToken)),
24
+ ionAssetId(nitro::ReactProp<double>::fromRawValue("CesiumView", "ionAssetId", rawProps, sourceProps.ionAssetId)),
25
+ initialCamera(nitro::ReactProp<CameraState>::fromRawValue("CesiumView", "initialCamera", rawProps, sourceProps.initialCamera)),
26
+ pauseRendering(nitro::ReactProp<bool>::fromRawValue("CesiumView", "pauseRendering", rawProps, sourceProps.pauseRendering)),
27
+ maximumScreenSpaceError(nitro::ReactProp<double>::fromRawValue("CesiumView", "maximumScreenSpaceError", rawProps, sourceProps.maximumScreenSpaceError)),
28
+ maximumSimultaneousTileLoads(nitro::ReactProp<double>::fromRawValue("CesiumView", "maximumSimultaneousTileLoads", rawProps, sourceProps.maximumSimultaneousTileLoads)),
29
+ loadingDescendantLimit(nitro::ReactProp<double>::fromRawValue("CesiumView", "loadingDescendantLimit", rawProps, sourceProps.loadingDescendantLimit)),
30
+ msaaSampleCount(nitro::ReactProp<double>::fromRawValue("CesiumView", "msaaSampleCount", rawProps, sourceProps.msaaSampleCount)),
31
+ ionImageryAssetId(nitro::ReactProp<double>::fromRawValue("CesiumView", "ionImageryAssetId", rawProps, sourceProps.ionImageryAssetId)),
32
+ maximumCachedMiB(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maximumCachedMiB", rawProps, sourceProps.maximumCachedMiB)),
33
+ preloadAncestors(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "preloadAncestors", rawProps, sourceProps.preloadAncestors)),
34
+ preloadSiblings(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "preloadSiblings", rawProps, sourceProps.preloadSiblings)),
35
+ forbidHoles(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "forbidHoles", rawProps, sourceProps.forbidHoles)),
36
+ enableWaterMask(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "enableWaterMask", rawProps, sourceProps.enableWaterMask)),
37
+ enableFogCulling(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "enableFogCulling", rawProps, sourceProps.enableFogCulling)),
38
+ enforceCulledScreenSpaceError(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "enforceCulledScreenSpaceError", rawProps, sourceProps.enforceCulledScreenSpaceError)),
39
+ culledScreenSpaceError(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "culledScreenSpaceError", rawProps, sourceProps.culledScreenSpaceError)),
40
+ enableLodTransitionPeriod(nitro::ReactProp<std::optional<bool>>::fromRawValue("CesiumView", "enableLodTransitionPeriod", rawProps, sourceProps.enableLodTransitionPeriod)),
41
+ lodTransitionLength(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "lodTransitionLength", rawProps, sourceProps.lodTransitionLength)),
42
+ sqliteCacheMaxRows(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "sqliteCacheMaxRows", rawProps, sourceProps.sqliteCacheMaxRows)),
43
+ taskProcessorThreads(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "taskProcessorThreads", rawProps, sourceProps.taskProcessorThreads)),
44
+ minAltitudeAboveTerrain(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "minAltitudeAboveTerrain", rawProps, sourceProps.minAltitudeAboveTerrain)),
45
+ maxYawRateDegSec(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maxYawRateDegSec", rawProps, sourceProps.maxYawRateDegSec)),
46
+ maxPitchRateDegSec(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maxPitchRateDegSec", rawProps, sourceProps.maxPitchRateDegSec)),
47
+ maxRollRateDegSec(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maxRollRateDegSec", rawProps, sourceProps.maxRollRateDegSec)),
48
+ maxClimbRateMps(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maxClimbRateMps", rawProps, sourceProps.maxClimbRateMps)),
49
+ maxGroundSpeedMps(nitro::ReactProp<std::optional<double>>::fromRawValue("CesiumView", "maxGroundSpeedMps", rawProps, sourceProps.maxGroundSpeedMps)),
50
+ onMetrics(nitro::ReactProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>>::fromRawValue("CesiumView", "onMetrics", rawProps, sourceProps.onMetrics)),
51
+ onActualCamera(nitro::ReactProp<std::optional<std::function<void(const CameraState& /* camera */)>>>::fromRawValue("CesiumView", "onActualCamera", rawProps, sourceProps.onActualCamera)),
52
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>>::fromRawValue("CesiumView", "hybridRef", rawProps, sourceProps.hybridRef)) { }
329
53
 
330
54
  bool HybridCesiumViewProps::filterObjectKeys(const std::string& propName) {
331
55
  switch (hashString(propName)) {
@@ -363,29 +87,4 @@ namespace margelo::nitro::reactnativecesium::views {
363
87
  }
364
88
  }
365
89
 
366
- HybridCesiumViewComponentDescriptor::HybridCesiumViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
367
- : ConcreteComponentDescriptor(parameters,
368
- react::RawPropsParser(/* enableJsiParser */ true)) {}
369
-
370
- std::shared_ptr<const react::Props> HybridCesiumViewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
371
- const std::shared_ptr<const react::Props>& props,
372
- react::RawProps rawProps) const {
373
- // 1. Prepare raw props parser
374
- rawProps.parse(rawPropsParser_);
375
- // 2. Copy props with Nitro's cached copy constructor
376
- return HybridCesiumViewShadowNode::Props(context, /* & */ rawProps, props);
377
- }
378
-
379
- #ifdef ANDROID
380
- void HybridCesiumViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
381
- // This is called immediately after `ShadowNode` is created, cloned or in progress.
382
- // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
383
- auto& concreteShadowNode = static_cast<HybridCesiumViewShadowNode&>(shadowNode);
384
- const std::shared_ptr<const HybridCesiumViewProps>& constProps = concreteShadowNode.getConcreteSharedProps();
385
- const std::shared_ptr<HybridCesiumViewProps>& props = std::const_pointer_cast<HybridCesiumViewProps>(constProps);
386
- HybridCesiumViewState state{props};
387
- concreteShadowNode.setStateData(std::move(state));
388
- }
389
- #endif
390
-
391
90
  } // namespace margelo::nitro::reactnativecesium::views
@@ -7,14 +7,15 @@
7
7
 
8
8
  #pragma once
9
9
 
10
- #include <optional>
11
- #include <NitroModules/NitroDefines.hpp>
12
- #include <NitroModules/NitroHash.hpp>
13
- #include <NitroModules/CachedProp.hpp>
14
- #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
- #include <react/renderer/core/PropsParserContext.h>
10
+ #include <NitroModules/ReactProp.hpp>
11
+ #include <NitroModules/ViewComponentDescriptor.hpp>
12
+ #include <NitroModules/ViewPropsHolderState.hpp>
16
13
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
14
  #include <react/renderer/components/view/ViewProps.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/core/RawProps.h>
17
+
18
+ #include <string>
18
19
 
19
20
  #include <string>
20
21
  #include "CameraState.hpp"
@@ -44,36 +45,104 @@ namespace margelo::nitro::reactnativecesium::views {
44
45
  const react::RawProps& rawProps);
45
46
 
46
47
  public:
47
- CachedProp<std::string> ionAccessToken;
48
- CachedProp<double> ionAssetId;
49
- CachedProp<CameraState> initialCamera;
50
- CachedProp<bool> pauseRendering;
51
- CachedProp<double> maximumScreenSpaceError;
52
- CachedProp<double> maximumSimultaneousTileLoads;
53
- CachedProp<double> loadingDescendantLimit;
54
- CachedProp<double> msaaSampleCount;
55
- CachedProp<double> ionImageryAssetId;
56
- CachedProp<std::optional<double>> maximumCachedMiB;
57
- CachedProp<std::optional<bool>> preloadAncestors;
58
- CachedProp<std::optional<bool>> preloadSiblings;
59
- CachedProp<std::optional<bool>> forbidHoles;
60
- CachedProp<std::optional<bool>> enableWaterMask;
61
- CachedProp<std::optional<bool>> enableFogCulling;
62
- CachedProp<std::optional<bool>> enforceCulledScreenSpaceError;
63
- CachedProp<std::optional<double>> culledScreenSpaceError;
64
- CachedProp<std::optional<bool>> enableLodTransitionPeriod;
65
- CachedProp<std::optional<double>> lodTransitionLength;
66
- CachedProp<std::optional<double>> sqliteCacheMaxRows;
67
- CachedProp<std::optional<double>> taskProcessorThreads;
68
- CachedProp<std::optional<double>> minAltitudeAboveTerrain;
69
- CachedProp<std::optional<double>> maxYawRateDegSec;
70
- CachedProp<std::optional<double>> maxPitchRateDegSec;
71
- CachedProp<std::optional<double>> maxRollRateDegSec;
72
- CachedProp<std::optional<double>> maxClimbRateMps;
73
- CachedProp<std::optional<double>> maxGroundSpeedMps;
74
- CachedProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>> onMetrics;
75
- CachedProp<std::optional<std::function<void(const CameraState& /* camera */)>>> onActualCamera;
76
- CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>> hybridRef;
48
+ nitro::ReactProp<std::string> ionAccessToken;
49
+ nitro::ReactProp<double> ionAssetId;
50
+ nitro::ReactProp<CameraState> initialCamera;
51
+ nitro::ReactProp<bool> pauseRendering;
52
+ nitro::ReactProp<double> maximumScreenSpaceError;
53
+ nitro::ReactProp<double> maximumSimultaneousTileLoads;
54
+ nitro::ReactProp<double> loadingDescendantLimit;
55
+ nitro::ReactProp<double> msaaSampleCount;
56
+ nitro::ReactProp<double> ionImageryAssetId;
57
+ nitro::ReactProp<std::optional<double>> maximumCachedMiB;
58
+ nitro::ReactProp<std::optional<bool>> preloadAncestors;
59
+ nitro::ReactProp<std::optional<bool>> preloadSiblings;
60
+ nitro::ReactProp<std::optional<bool>> forbidHoles;
61
+ nitro::ReactProp<std::optional<bool>> enableWaterMask;
62
+ nitro::ReactProp<std::optional<bool>> enableFogCulling;
63
+ nitro::ReactProp<std::optional<bool>> enforceCulledScreenSpaceError;
64
+ nitro::ReactProp<std::optional<double>> culledScreenSpaceError;
65
+ nitro::ReactProp<std::optional<bool>> enableLodTransitionPeriod;
66
+ nitro::ReactProp<std::optional<double>> lodTransitionLength;
67
+ nitro::ReactProp<std::optional<double>> sqliteCacheMaxRows;
68
+ nitro::ReactProp<std::optional<double>> taskProcessorThreads;
69
+ nitro::ReactProp<std::optional<double>> minAltitudeAboveTerrain;
70
+ nitro::ReactProp<std::optional<double>> maxYawRateDegSec;
71
+ nitro::ReactProp<std::optional<double>> maxPitchRateDegSec;
72
+ nitro::ReactProp<std::optional<double>> maxRollRateDegSec;
73
+ nitro::ReactProp<std::optional<double>> maxClimbRateMps;
74
+ nitro::ReactProp<std::optional<double>> maxGroundSpeedMps;
75
+ nitro::ReactProp<std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>> onMetrics;
76
+ nitro::ReactProp<std::optional<std::function<void(const CameraState& /* camera */)>>> onActualCamera;
77
+ nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridCesiumViewSpec>& /* ref */)>>> hybridRef;
78
+
79
+ [[nodiscard]]
80
+ bool hasSameProps(const HybridCesiumViewProps& other) const noexcept {
81
+ return ionAccessToken.hasSameValue(other.ionAccessToken) &&
82
+ ionAssetId.hasSameValue(other.ionAssetId) &&
83
+ initialCamera.hasSameValue(other.initialCamera) &&
84
+ pauseRendering.hasSameValue(other.pauseRendering) &&
85
+ maximumScreenSpaceError.hasSameValue(other.maximumScreenSpaceError) &&
86
+ maximumSimultaneousTileLoads.hasSameValue(other.maximumSimultaneousTileLoads) &&
87
+ loadingDescendantLimit.hasSameValue(other.loadingDescendantLimit) &&
88
+ msaaSampleCount.hasSameValue(other.msaaSampleCount) &&
89
+ ionImageryAssetId.hasSameValue(other.ionImageryAssetId) &&
90
+ maximumCachedMiB.hasSameValue(other.maximumCachedMiB) &&
91
+ preloadAncestors.hasSameValue(other.preloadAncestors) &&
92
+ preloadSiblings.hasSameValue(other.preloadSiblings) &&
93
+ forbidHoles.hasSameValue(other.forbidHoles) &&
94
+ enableWaterMask.hasSameValue(other.enableWaterMask) &&
95
+ enableFogCulling.hasSameValue(other.enableFogCulling) &&
96
+ enforceCulledScreenSpaceError.hasSameValue(other.enforceCulledScreenSpaceError) &&
97
+ culledScreenSpaceError.hasSameValue(other.culledScreenSpaceError) &&
98
+ enableLodTransitionPeriod.hasSameValue(other.enableLodTransitionPeriod) &&
99
+ lodTransitionLength.hasSameValue(other.lodTransitionLength) &&
100
+ sqliteCacheMaxRows.hasSameValue(other.sqliteCacheMaxRows) &&
101
+ taskProcessorThreads.hasSameValue(other.taskProcessorThreads) &&
102
+ minAltitudeAboveTerrain.hasSameValue(other.minAltitudeAboveTerrain) &&
103
+ maxYawRateDegSec.hasSameValue(other.maxYawRateDegSec) &&
104
+ maxPitchRateDegSec.hasSameValue(other.maxPitchRateDegSec) &&
105
+ maxRollRateDegSec.hasSameValue(other.maxRollRateDegSec) &&
106
+ maxClimbRateMps.hasSameValue(other.maxClimbRateMps) &&
107
+ maxGroundSpeedMps.hasSameValue(other.maxGroundSpeedMps) &&
108
+ onMetrics.hasSameValue(other.onMetrics) &&
109
+ onActualCamera.hasSameValue(other.onActualCamera) &&
110
+ hybridRef.hasSameValue(other.hybridRef);
111
+ }
112
+
113
+ [[nodiscard]]
114
+ bool hasAnyProvidedProps() const noexcept {
115
+ return ionAccessToken.isProvided() ||
116
+ ionAssetId.isProvided() ||
117
+ initialCamera.isProvided() ||
118
+ pauseRendering.isProvided() ||
119
+ maximumScreenSpaceError.isProvided() ||
120
+ maximumSimultaneousTileLoads.isProvided() ||
121
+ loadingDescendantLimit.isProvided() ||
122
+ msaaSampleCount.isProvided() ||
123
+ ionImageryAssetId.isProvided() ||
124
+ maximumCachedMiB.isProvided() ||
125
+ preloadAncestors.isProvided() ||
126
+ preloadSiblings.isProvided() ||
127
+ forbidHoles.isProvided() ||
128
+ enableWaterMask.isProvided() ||
129
+ enableFogCulling.isProvided() ||
130
+ enforceCulledScreenSpaceError.isProvided() ||
131
+ culledScreenSpaceError.isProvided() ||
132
+ enableLodTransitionPeriod.isProvided() ||
133
+ lodTransitionLength.isProvided() ||
134
+ sqliteCacheMaxRows.isProvided() ||
135
+ taskProcessorThreads.isProvided() ||
136
+ minAltitudeAboveTerrain.isProvided() ||
137
+ maxYawRateDegSec.isProvided() ||
138
+ maxPitchRateDegSec.isProvided() ||
139
+ maxRollRateDegSec.isProvided() ||
140
+ maxClimbRateMps.isProvided() ||
141
+ maxGroundSpeedMps.isProvided() ||
142
+ onMetrics.isProvided() ||
143
+ onActualCamera.isProvided() ||
144
+ hybridRef.isProvided();
145
+ }
77
146
 
78
147
  private:
79
148
  static bool filterObjectKeys(const std::string& propName);
@@ -82,32 +151,7 @@ namespace margelo::nitro::reactnativecesium::views {
82
151
  /**
83
152
  * State for the "CesiumView" View.
84
153
  */
85
- class HybridCesiumViewState final {
86
- public:
87
- HybridCesiumViewState() = default;
88
- explicit HybridCesiumViewState(const std::shared_ptr<HybridCesiumViewProps>& props):
89
- _props(props) {}
90
-
91
- public:
92
- [[nodiscard]]
93
- const std::shared_ptr<HybridCesiumViewProps>& getProps() const {
94
- return _props;
95
- }
96
-
97
- public:
98
- #ifdef ANDROID
99
- HybridCesiumViewState(const HybridCesiumViewState& /* previousState */, folly::dynamic /* data */) {}
100
- folly::dynamic getDynamic() const {
101
- throw std::runtime_error("HybridCesiumViewState does not support folly!");
102
- }
103
- react::MapBuffer getMapBuffer() const {
104
- throw std::runtime_error("HybridCesiumViewState does not support MapBuffer!");
105
- };
106
- #endif
107
-
108
- private:
109
- std::shared_ptr<HybridCesiumViewProps> _props;
110
- };
154
+ using HybridCesiumViewState = nitro::ViewPropsHolderState<HybridCesiumViewProps>;
111
155
 
112
156
  /**
113
157
  * The Shadow Node for the "CesiumView" View.
@@ -120,21 +164,7 @@ namespace margelo::nitro::reactnativecesium::views {
120
164
  /**
121
165
  * The Component Descriptor for the "CesiumView" View.
122
166
  */
123
- class HybridCesiumViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridCesiumViewShadowNode> {
124
- public:
125
- explicit HybridCesiumViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
126
-
127
- public:
128
- /**
129
- * A faster path for cloning props - reuses the caching logic from `HybridCesiumViewProps`.
130
- */
131
- std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
132
- const std::shared_ptr<const react::Props>& props,
133
- react::RawProps rawProps) const override;
134
- #ifdef ANDROID
135
- void adopt(react::ShadowNode& shadowNode) const override;
136
- #endif
137
- };
167
+ using HybridCesiumViewComponentDescriptor = nitro::ViewComponentDescriptor<HybridCesiumViewShadowNode>;
138
168
 
139
169
  /* The actual view for "CesiumView" needs to be implemented in platform-specific code. */
140
170