react-native-cesium 1.2.18 → 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.
- package/README.md +1 -1
- package/android/CMakeLists.txt +1 -0
- package/android/build.gradle +1 -1
- package/android/gradle.properties +4 -4
- package/android/src/main/cpp/CesiumBridgeAndroid.cpp +5 -15
- package/android/src/main/cpp/CesiumBridgeAndroid.h +2 -0
- package/cpp/engine/CameraIntegrator.cpp +82 -47
- package/cpp/engine/CameraIntegrator.hpp +27 -8
- package/cpp/engine/CesiumEngine.cpp +152 -304
- package/cpp/engine/CesiumEngine.hpp +38 -28
- package/cpp/engine/EngineTunables.hpp +6 -5
- package/cpp/engine/GltfToMesh.cpp +14 -5
- package/cpp/engine/ResourcePreparer.cpp +3 -3
- package/cpp/engine/ResourcePreparer.hpp +1 -1
- package/cpp/engine/TerrainFloor.hpp +70 -0
- package/cpp/engine/TerrainHeight.hpp +113 -0
- package/cpp/engine/test/CameraIntegratorTest.cpp +264 -0
- package/ios/CesiumBridge.mm +7 -27
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts +7 -6
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/ReactNativeCesiumOnLoad.cpp +1 -1
- package/nitrogen/generated/android/c++/JCameraState.hpp +1 -1
- package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +1 -1
- package/nitrogen/generated/android/c++/JQuaternion.hpp +1 -1
- package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +177 -131
- package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.hpp +6 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CameraState.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CesiumMetrics.kt +0 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Quaternion.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewManager.kt +26 -10
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewStateUpdater.kt +2 -2
- package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +211 -161
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +34 -335
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +107 -77
- package/package.json +12 -12
- package/scripts/cesium/config.mjs +1 -1
- package/scripts/cesium/vcpkg-triplets/arm64-ios-simulator.cmake +3 -0
- package/scripts/cesium/vcpkg-triplets/arm64-ios.cmake +4 -0
- package/src/specs/cesium-view.nitro.ts +7 -6
|
@@ -17,7 +17,7 @@ namespace margelo::nitro::reactnativecesium {
|
|
|
17
17
|
using namespace facebook;
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* The C++ JNI bridge between the C++ struct "Quaternion" and the
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "Quaternion" and the Kotlin data class "Quaternion".
|
|
21
21
|
*/
|
|
22
22
|
struct JQuaternion final: public jni::JavaClass<JQuaternion> {
|
|
23
23
|
public:
|
|
@@ -15,153 +15,199 @@ namespace margelo::nitro::reactnativecesium::views {
|
|
|
15
15
|
using namespace facebook;
|
|
16
16
|
using ConcreteStateData = react::ConcreteState<HybridCesiumViewState>;
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
std::shared_ptr<const HybridCesiumViewProps> JHybridCesiumViewStateUpdater::getPropsFromStateWrapper(
|
|
19
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper) {
|
|
20
|
+
if (stateWrapper.get() == nullptr) {
|
|
21
|
+
return nullptr;
|
|
22
|
+
}
|
|
23
23
|
// Get concrete StateWrapperImpl from passed StateWrapper interface object
|
|
24
|
-
jobject rawStateWrapper =
|
|
25
|
-
if (!
|
|
26
|
-
|
|
24
|
+
jobject rawStateWrapper = stateWrapper.get();
|
|
25
|
+
if (!stateWrapper->isInstanceOf(react::StateWrapperImpl::javaClassStatic())) [[unlikely]] {
|
|
26
|
+
throw std::runtime_error("StateWrapper is not a StateWrapperImpl");
|
|
27
|
+
}
|
|
28
|
+
auto stateWrapperImpl = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
+
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)
|
|
30
|
+
};
|
|
31
|
+
std::shared_ptr<const react::State> state = stateWrapperImpl->cthis()->getState();
|
|
32
|
+
if (state == nullptr) {
|
|
33
|
+
return nullptr;
|
|
27
34
|
}
|
|
28
|
-
auto stateWrapper = jni::alias_ref<react::StateWrapperImpl::javaobject>{
|
|
29
|
-
static_cast<react::StateWrapperImpl::javaobject>(rawStateWrapper)};
|
|
30
|
-
std::shared_ptr<const react::State> state = stateWrapper->cthis()->getState();
|
|
31
35
|
auto concreteState = std::static_pointer_cast<const ConcreteStateData>(state);
|
|
32
36
|
const HybridCesiumViewState& data = concreteState->getData();
|
|
33
|
-
const std::shared_ptr<HybridCesiumViewProps>& props = data.getProps();
|
|
37
|
+
const std::shared_ptr<const HybridCesiumViewProps>& props = data.getProps();
|
|
34
38
|
if (props == nullptr) [[unlikely]] {
|
|
35
|
-
// Props aren't set yet!
|
|
36
39
|
throw std::runtime_error("HybridCesiumViewState's data doesn't contain any props!");
|
|
37
40
|
}
|
|
41
|
+
return props;
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (props->initialCamera.isDirty) {
|
|
49
|
-
hybridView->setInitialCamera(props->initialCamera.value);
|
|
50
|
-
props->initialCamera.isDirty = false;
|
|
51
|
-
}
|
|
52
|
-
if (props->pauseRendering.isDirty) {
|
|
53
|
-
hybridView->setPauseRendering(props->pauseRendering.value);
|
|
54
|
-
props->pauseRendering.isDirty = false;
|
|
55
|
-
}
|
|
56
|
-
if (props->maximumScreenSpaceError.isDirty) {
|
|
57
|
-
hybridView->setMaximumScreenSpaceError(props->maximumScreenSpaceError.value);
|
|
58
|
-
props->maximumScreenSpaceError.isDirty = false;
|
|
59
|
-
}
|
|
60
|
-
if (props->maximumSimultaneousTileLoads.isDirty) {
|
|
61
|
-
hybridView->setMaximumSimultaneousTileLoads(props->maximumSimultaneousTileLoads.value);
|
|
62
|
-
props->maximumSimultaneousTileLoads.isDirty = false;
|
|
63
|
-
}
|
|
64
|
-
if (props->loadingDescendantLimit.isDirty) {
|
|
65
|
-
hybridView->setLoadingDescendantLimit(props->loadingDescendantLimit.value);
|
|
66
|
-
props->loadingDescendantLimit.isDirty = false;
|
|
67
|
-
}
|
|
68
|
-
if (props->msaaSampleCount.isDirty) {
|
|
69
|
-
hybridView->setMsaaSampleCount(props->msaaSampleCount.value);
|
|
70
|
-
props->msaaSampleCount.isDirty = false;
|
|
71
|
-
}
|
|
72
|
-
if (props->ionImageryAssetId.isDirty) {
|
|
73
|
-
hybridView->setIonImageryAssetId(props->ionImageryAssetId.value);
|
|
74
|
-
props->ionImageryAssetId.isDirty = false;
|
|
75
|
-
}
|
|
76
|
-
if (props->maximumCachedMiB.isDirty) {
|
|
77
|
-
hybridView->setMaximumCachedMiB(props->maximumCachedMiB.value);
|
|
78
|
-
props->maximumCachedMiB.isDirty = false;
|
|
79
|
-
}
|
|
80
|
-
if (props->preloadAncestors.isDirty) {
|
|
81
|
-
hybridView->setPreloadAncestors(props->preloadAncestors.value);
|
|
82
|
-
props->preloadAncestors.isDirty = false;
|
|
83
|
-
}
|
|
84
|
-
if (props->preloadSiblings.isDirty) {
|
|
85
|
-
hybridView->setPreloadSiblings(props->preloadSiblings.value);
|
|
86
|
-
props->preloadSiblings.isDirty = false;
|
|
87
|
-
}
|
|
88
|
-
if (props->forbidHoles.isDirty) {
|
|
89
|
-
hybridView->setForbidHoles(props->forbidHoles.value);
|
|
90
|
-
props->forbidHoles.isDirty = false;
|
|
91
|
-
}
|
|
92
|
-
if (props->enableWaterMask.isDirty) {
|
|
93
|
-
hybridView->setEnableWaterMask(props->enableWaterMask.value);
|
|
94
|
-
props->enableWaterMask.isDirty = false;
|
|
95
|
-
}
|
|
96
|
-
if (props->enableFogCulling.isDirty) {
|
|
97
|
-
hybridView->setEnableFogCulling(props->enableFogCulling.value);
|
|
98
|
-
props->enableFogCulling.isDirty = false;
|
|
99
|
-
}
|
|
100
|
-
if (props->enforceCulledScreenSpaceError.isDirty) {
|
|
101
|
-
hybridView->setEnforceCulledScreenSpaceError(props->enforceCulledScreenSpaceError.value);
|
|
102
|
-
props->enforceCulledScreenSpaceError.isDirty = false;
|
|
103
|
-
}
|
|
104
|
-
if (props->culledScreenSpaceError.isDirty) {
|
|
105
|
-
hybridView->setCulledScreenSpaceError(props->culledScreenSpaceError.value);
|
|
106
|
-
props->culledScreenSpaceError.isDirty = false;
|
|
107
|
-
}
|
|
108
|
-
if (props->enableLodTransitionPeriod.isDirty) {
|
|
109
|
-
hybridView->setEnableLodTransitionPeriod(props->enableLodTransitionPeriod.value);
|
|
110
|
-
props->enableLodTransitionPeriod.isDirty = false;
|
|
111
|
-
}
|
|
112
|
-
if (props->lodTransitionLength.isDirty) {
|
|
113
|
-
hybridView->setLodTransitionLength(props->lodTransitionLength.value);
|
|
114
|
-
props->lodTransitionLength.isDirty = false;
|
|
115
|
-
}
|
|
116
|
-
if (props->sqliteCacheMaxRows.isDirty) {
|
|
117
|
-
hybridView->setSqliteCacheMaxRows(props->sqliteCacheMaxRows.value);
|
|
118
|
-
props->sqliteCacheMaxRows.isDirty = false;
|
|
119
|
-
}
|
|
120
|
-
if (props->taskProcessorThreads.isDirty) {
|
|
121
|
-
hybridView->setTaskProcessorThreads(props->taskProcessorThreads.value);
|
|
122
|
-
props->taskProcessorThreads.isDirty = false;
|
|
123
|
-
}
|
|
124
|
-
if (props->minAltitudeAboveTerrain.isDirty) {
|
|
125
|
-
hybridView->setMinAltitudeAboveTerrain(props->minAltitudeAboveTerrain.value);
|
|
126
|
-
props->minAltitudeAboveTerrain.isDirty = false;
|
|
127
|
-
}
|
|
128
|
-
if (props->maxYawRateDegSec.isDirty) {
|
|
129
|
-
hybridView->setMaxYawRateDegSec(props->maxYawRateDegSec.value);
|
|
130
|
-
props->maxYawRateDegSec.isDirty = false;
|
|
131
|
-
}
|
|
132
|
-
if (props->maxPitchRateDegSec.isDirty) {
|
|
133
|
-
hybridView->setMaxPitchRateDegSec(props->maxPitchRateDegSec.value);
|
|
134
|
-
props->maxPitchRateDegSec.isDirty = false;
|
|
135
|
-
}
|
|
136
|
-
if (props->maxRollRateDegSec.isDirty) {
|
|
137
|
-
hybridView->setMaxRollRateDegSec(props->maxRollRateDegSec.value);
|
|
138
|
-
props->maxRollRateDegSec.isDirty = false;
|
|
139
|
-
}
|
|
140
|
-
if (props->maxClimbRateMps.isDirty) {
|
|
141
|
-
hybridView->setMaxClimbRateMps(props->maxClimbRateMps.value);
|
|
142
|
-
props->maxClimbRateMps.isDirty = false;
|
|
143
|
-
}
|
|
144
|
-
if (props->maxGroundSpeedMps.isDirty) {
|
|
145
|
-
hybridView->setMaxGroundSpeedMps(props->maxGroundSpeedMps.value);
|
|
146
|
-
props->maxGroundSpeedMps.isDirty = false;
|
|
147
|
-
}
|
|
148
|
-
if (props->onMetrics.isDirty) {
|
|
149
|
-
hybridView->setOnMetrics(props->onMetrics.value);
|
|
150
|
-
props->onMetrics.isDirty = false;
|
|
44
|
+
void JHybridCesiumViewStateUpdater::updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
45
|
+
jni::alias_ref<JHybridCesiumViewSpec::JavaPart> javaView,
|
|
46
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
47
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState) {
|
|
48
|
+
std::shared_ptr<JHybridCesiumViewSpec> hybridView = javaView->getJHybridCesiumViewSpec();
|
|
49
|
+
std::shared_ptr<const HybridCesiumViewProps> newProps = getPropsFromStateWrapper(newState);
|
|
50
|
+
std::shared_ptr<const HybridCesiumViewProps> oldProps = getPropsFromStateWrapper(oldState);
|
|
51
|
+
if (newProps == nullptr) [[unlikely]] {
|
|
52
|
+
throw std::runtime_error("Current StateWrapper doesn't contain any props!");
|
|
151
53
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
54
|
+
|
|
55
|
+
// Update only props that differ from the previous State snapshot.
|
|
56
|
+
if (oldProps == nullptr
|
|
57
|
+
? newProps->ionAccessToken.isProvided()
|
|
58
|
+
: !newProps->ionAccessToken.hasSameValue(oldProps->ionAccessToken)) {
|
|
59
|
+
hybridView->setIonAccessToken(newProps->ionAccessToken.get());
|
|
60
|
+
}
|
|
61
|
+
if (oldProps == nullptr
|
|
62
|
+
? newProps->ionAssetId.isProvided()
|
|
63
|
+
: !newProps->ionAssetId.hasSameValue(oldProps->ionAssetId)) {
|
|
64
|
+
hybridView->setIonAssetId(newProps->ionAssetId.get());
|
|
65
|
+
}
|
|
66
|
+
if (oldProps == nullptr
|
|
67
|
+
? newProps->initialCamera.isProvided()
|
|
68
|
+
: !newProps->initialCamera.hasSameValue(oldProps->initialCamera)) {
|
|
69
|
+
hybridView->setInitialCamera(newProps->initialCamera.get());
|
|
70
|
+
}
|
|
71
|
+
if (oldProps == nullptr
|
|
72
|
+
? newProps->pauseRendering.isProvided()
|
|
73
|
+
: !newProps->pauseRendering.hasSameValue(oldProps->pauseRendering)) {
|
|
74
|
+
hybridView->setPauseRendering(newProps->pauseRendering.get());
|
|
75
|
+
}
|
|
76
|
+
if (oldProps == nullptr
|
|
77
|
+
? newProps->maximumScreenSpaceError.isProvided()
|
|
78
|
+
: !newProps->maximumScreenSpaceError.hasSameValue(oldProps->maximumScreenSpaceError)) {
|
|
79
|
+
hybridView->setMaximumScreenSpaceError(newProps->maximumScreenSpaceError.get());
|
|
80
|
+
}
|
|
81
|
+
if (oldProps == nullptr
|
|
82
|
+
? newProps->maximumSimultaneousTileLoads.isProvided()
|
|
83
|
+
: !newProps->maximumSimultaneousTileLoads.hasSameValue(oldProps->maximumSimultaneousTileLoads)) {
|
|
84
|
+
hybridView->setMaximumSimultaneousTileLoads(newProps->maximumSimultaneousTileLoads.get());
|
|
85
|
+
}
|
|
86
|
+
if (oldProps == nullptr
|
|
87
|
+
? newProps->loadingDescendantLimit.isProvided()
|
|
88
|
+
: !newProps->loadingDescendantLimit.hasSameValue(oldProps->loadingDescendantLimit)) {
|
|
89
|
+
hybridView->setLoadingDescendantLimit(newProps->loadingDescendantLimit.get());
|
|
90
|
+
}
|
|
91
|
+
if (oldProps == nullptr
|
|
92
|
+
? newProps->msaaSampleCount.isProvided()
|
|
93
|
+
: !newProps->msaaSampleCount.hasSameValue(oldProps->msaaSampleCount)) {
|
|
94
|
+
hybridView->setMsaaSampleCount(newProps->msaaSampleCount.get());
|
|
95
|
+
}
|
|
96
|
+
if (oldProps == nullptr
|
|
97
|
+
? newProps->ionImageryAssetId.isProvided()
|
|
98
|
+
: !newProps->ionImageryAssetId.hasSameValue(oldProps->ionImageryAssetId)) {
|
|
99
|
+
hybridView->setIonImageryAssetId(newProps->ionImageryAssetId.get());
|
|
100
|
+
}
|
|
101
|
+
if (oldProps == nullptr
|
|
102
|
+
? newProps->maximumCachedMiB.isProvided()
|
|
103
|
+
: !newProps->maximumCachedMiB.hasSameValue(oldProps->maximumCachedMiB)) {
|
|
104
|
+
hybridView->setMaximumCachedMiB(newProps->maximumCachedMiB.get());
|
|
105
|
+
}
|
|
106
|
+
if (oldProps == nullptr
|
|
107
|
+
? newProps->preloadAncestors.isProvided()
|
|
108
|
+
: !newProps->preloadAncestors.hasSameValue(oldProps->preloadAncestors)) {
|
|
109
|
+
hybridView->setPreloadAncestors(newProps->preloadAncestors.get());
|
|
110
|
+
}
|
|
111
|
+
if (oldProps == nullptr
|
|
112
|
+
? newProps->preloadSiblings.isProvided()
|
|
113
|
+
: !newProps->preloadSiblings.hasSameValue(oldProps->preloadSiblings)) {
|
|
114
|
+
hybridView->setPreloadSiblings(newProps->preloadSiblings.get());
|
|
115
|
+
}
|
|
116
|
+
if (oldProps == nullptr
|
|
117
|
+
? newProps->forbidHoles.isProvided()
|
|
118
|
+
: !newProps->forbidHoles.hasSameValue(oldProps->forbidHoles)) {
|
|
119
|
+
hybridView->setForbidHoles(newProps->forbidHoles.get());
|
|
120
|
+
}
|
|
121
|
+
if (oldProps == nullptr
|
|
122
|
+
? newProps->enableWaterMask.isProvided()
|
|
123
|
+
: !newProps->enableWaterMask.hasSameValue(oldProps->enableWaterMask)) {
|
|
124
|
+
hybridView->setEnableWaterMask(newProps->enableWaterMask.get());
|
|
125
|
+
}
|
|
126
|
+
if (oldProps == nullptr
|
|
127
|
+
? newProps->enableFogCulling.isProvided()
|
|
128
|
+
: !newProps->enableFogCulling.hasSameValue(oldProps->enableFogCulling)) {
|
|
129
|
+
hybridView->setEnableFogCulling(newProps->enableFogCulling.get());
|
|
130
|
+
}
|
|
131
|
+
if (oldProps == nullptr
|
|
132
|
+
? newProps->enforceCulledScreenSpaceError.isProvided()
|
|
133
|
+
: !newProps->enforceCulledScreenSpaceError.hasSameValue(oldProps->enforceCulledScreenSpaceError)) {
|
|
134
|
+
hybridView->setEnforceCulledScreenSpaceError(newProps->enforceCulledScreenSpaceError.get());
|
|
135
|
+
}
|
|
136
|
+
if (oldProps == nullptr
|
|
137
|
+
? newProps->culledScreenSpaceError.isProvided()
|
|
138
|
+
: !newProps->culledScreenSpaceError.hasSameValue(oldProps->culledScreenSpaceError)) {
|
|
139
|
+
hybridView->setCulledScreenSpaceError(newProps->culledScreenSpaceError.get());
|
|
140
|
+
}
|
|
141
|
+
if (oldProps == nullptr
|
|
142
|
+
? newProps->enableLodTransitionPeriod.isProvided()
|
|
143
|
+
: !newProps->enableLodTransitionPeriod.hasSameValue(oldProps->enableLodTransitionPeriod)) {
|
|
144
|
+
hybridView->setEnableLodTransitionPeriod(newProps->enableLodTransitionPeriod.get());
|
|
145
|
+
}
|
|
146
|
+
if (oldProps == nullptr
|
|
147
|
+
? newProps->lodTransitionLength.isProvided()
|
|
148
|
+
: !newProps->lodTransitionLength.hasSameValue(oldProps->lodTransitionLength)) {
|
|
149
|
+
hybridView->setLodTransitionLength(newProps->lodTransitionLength.get());
|
|
150
|
+
}
|
|
151
|
+
if (oldProps == nullptr
|
|
152
|
+
? newProps->sqliteCacheMaxRows.isProvided()
|
|
153
|
+
: !newProps->sqliteCacheMaxRows.hasSameValue(oldProps->sqliteCacheMaxRows)) {
|
|
154
|
+
hybridView->setSqliteCacheMaxRows(newProps->sqliteCacheMaxRows.get());
|
|
155
|
+
}
|
|
156
|
+
if (oldProps == nullptr
|
|
157
|
+
? newProps->taskProcessorThreads.isProvided()
|
|
158
|
+
: !newProps->taskProcessorThreads.hasSameValue(oldProps->taskProcessorThreads)) {
|
|
159
|
+
hybridView->setTaskProcessorThreads(newProps->taskProcessorThreads.get());
|
|
160
|
+
}
|
|
161
|
+
if (oldProps == nullptr
|
|
162
|
+
? newProps->minAltitudeAboveTerrain.isProvided()
|
|
163
|
+
: !newProps->minAltitudeAboveTerrain.hasSameValue(oldProps->minAltitudeAboveTerrain)) {
|
|
164
|
+
hybridView->setMinAltitudeAboveTerrain(newProps->minAltitudeAboveTerrain.get());
|
|
165
|
+
}
|
|
166
|
+
if (oldProps == nullptr
|
|
167
|
+
? newProps->maxYawRateDegSec.isProvided()
|
|
168
|
+
: !newProps->maxYawRateDegSec.hasSameValue(oldProps->maxYawRateDegSec)) {
|
|
169
|
+
hybridView->setMaxYawRateDegSec(newProps->maxYawRateDegSec.get());
|
|
170
|
+
}
|
|
171
|
+
if (oldProps == nullptr
|
|
172
|
+
? newProps->maxPitchRateDegSec.isProvided()
|
|
173
|
+
: !newProps->maxPitchRateDegSec.hasSameValue(oldProps->maxPitchRateDegSec)) {
|
|
174
|
+
hybridView->setMaxPitchRateDegSec(newProps->maxPitchRateDegSec.get());
|
|
175
|
+
}
|
|
176
|
+
if (oldProps == nullptr
|
|
177
|
+
? newProps->maxRollRateDegSec.isProvided()
|
|
178
|
+
: !newProps->maxRollRateDegSec.hasSameValue(oldProps->maxRollRateDegSec)) {
|
|
179
|
+
hybridView->setMaxRollRateDegSec(newProps->maxRollRateDegSec.get());
|
|
180
|
+
}
|
|
181
|
+
if (oldProps == nullptr
|
|
182
|
+
? newProps->maxClimbRateMps.isProvided()
|
|
183
|
+
: !newProps->maxClimbRateMps.hasSameValue(oldProps->maxClimbRateMps)) {
|
|
184
|
+
hybridView->setMaxClimbRateMps(newProps->maxClimbRateMps.get());
|
|
185
|
+
}
|
|
186
|
+
if (oldProps == nullptr
|
|
187
|
+
? newProps->maxGroundSpeedMps.isProvided()
|
|
188
|
+
: !newProps->maxGroundSpeedMps.hasSameValue(oldProps->maxGroundSpeedMps)) {
|
|
189
|
+
hybridView->setMaxGroundSpeedMps(newProps->maxGroundSpeedMps.get());
|
|
190
|
+
}
|
|
191
|
+
if (oldProps == nullptr
|
|
192
|
+
? newProps->onMetrics.isProvided()
|
|
193
|
+
: !newProps->onMetrics.hasSameValue(oldProps->onMetrics)) {
|
|
194
|
+
hybridView->setOnMetrics(newProps->onMetrics.get());
|
|
195
|
+
}
|
|
196
|
+
if (oldProps == nullptr
|
|
197
|
+
? newProps->onActualCamera.isProvided()
|
|
198
|
+
: !newProps->onActualCamera.hasSameValue(oldProps->onActualCamera)) {
|
|
199
|
+
hybridView->setOnActualCamera(newProps->onActualCamera.get());
|
|
155
200
|
}
|
|
156
201
|
|
|
157
202
|
// Update hybridRef if it changed
|
|
158
|
-
if (
|
|
203
|
+
if (oldProps == nullptr
|
|
204
|
+
? newProps->hybridRef.isProvided()
|
|
205
|
+
: !newProps->hybridRef.hasSameValue(oldProps->hybridRef)) {
|
|
159
206
|
// hybridRef changed - call it with new this
|
|
160
|
-
const auto& maybeFunc =
|
|
207
|
+
const auto& maybeFunc = newProps->hybridRef.get();
|
|
161
208
|
if (maybeFunc.has_value()) {
|
|
162
209
|
maybeFunc.value()(hybridView);
|
|
163
210
|
}
|
|
164
|
-
props->hybridRef.isDirty = false;
|
|
165
211
|
}
|
|
166
212
|
}
|
|
167
213
|
|
|
@@ -31,7 +31,12 @@ public:
|
|
|
31
31
|
public:
|
|
32
32
|
static void updateViewProps(jni::alias_ref<jni::JClass> /* class */,
|
|
33
33
|
jni::alias_ref<JHybridCesiumViewSpec::JavaPart> view,
|
|
34
|
-
jni::alias_ref<JStateWrapper::javaobject>
|
|
34
|
+
jni::alias_ref<JStateWrapper::javaobject> newState,
|
|
35
|
+
jni::alias_ref<JStateWrapper::javaobject> oldState);
|
|
36
|
+
|
|
37
|
+
private:
|
|
38
|
+
static std::shared_ptr<const HybridCesiumViewProps> getPropsFromStateWrapper(
|
|
39
|
+
jni::alias_ref<JStateWrapper::javaobject> stateWrapper);
|
|
35
40
|
|
|
36
41
|
public:
|
|
37
42
|
static void registerNatives() {
|
|
@@ -10,7 +10,6 @@ package com.margelo.nitro.reactnativecesium
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import dalvik.annotation.optimization.FastNative
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -59,7 +58,6 @@ class Func_void_CameraState_cxx: Func_void_CameraState {
|
|
|
59
58
|
override fun invoke(camera: CameraState): Unit
|
|
60
59
|
= invoke_cxx(camera)
|
|
61
60
|
|
|
62
|
-
@FastNative
|
|
63
61
|
private external fun invoke_cxx(camera: CameraState): Unit
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -10,7 +10,6 @@ package com.margelo.nitro.reactnativecesium
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
-
import dalvik.annotation.optimization.FastNative
|
|
14
13
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
@@ -59,7 +58,6 @@ class Func_void_CesiumMetrics_cxx: Func_void_CesiumMetrics {
|
|
|
59
58
|
override fun invoke(metrics: CesiumMetrics): Unit
|
|
60
59
|
= invoke_cxx(metrics)
|
|
61
60
|
|
|
62
|
-
@FastNative
|
|
63
61
|
private external fun invoke_cxx(metrics: CesiumMetrics): Unit
|
|
64
62
|
}
|
|
65
63
|
|
|
@@ -10,6 +10,7 @@ package com.margelo.nitro.reactnativecesium
|
|
|
10
10
|
import androidx.annotation.Keep
|
|
11
11
|
import com.facebook.jni.HybridData
|
|
12
12
|
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
13
14
|
import com.margelo.nitro.core.Promise
|
|
14
15
|
import com.margelo.nitro.core.HybridObject
|
|
15
16
|
import com.margelo.nitro.views.HybridView
|
|
@@ -268,6 +269,7 @@ abstract class HybridCesiumViewSpec: HybridView() {
|
|
|
268
269
|
@Keep
|
|
269
270
|
protected open class CxxPart(javaPart: HybridCesiumViewSpec): HybridObject.CxxPart(javaPart) {
|
|
270
271
|
// C++ JHybridCesiumViewSpec::CxxPart::initHybrid(...)
|
|
272
|
+
@FastNative
|
|
271
273
|
external override fun initHybrid(): HybridData
|
|
272
274
|
}
|
|
273
275
|
override fun createCxxPart(): CxxPart {
|
|
@@ -20,6 +20,14 @@ import com.margelo.nitro.reactnativecesium.*
|
|
|
20
20
|
* Represents the React Native `ViewManager` for the "CesiumView" Nitro HybridView.
|
|
21
21
|
*/
|
|
22
22
|
public class HybridCesiumViewManager: SimpleViewManager<View>() {
|
|
23
|
+
/**
|
|
24
|
+
* Represents the View and its last state snapshot (mutable)
|
|
25
|
+
*/
|
|
26
|
+
private class HybridViewHolder(
|
|
27
|
+
val hybridView: HybridCesiumView,
|
|
28
|
+
var lastState: StateWrapper? = null,
|
|
29
|
+
)
|
|
30
|
+
|
|
23
31
|
init {
|
|
24
32
|
if (RecyclableView::class.java.isAssignableFrom(HybridCesiumView::class.java)) {
|
|
25
33
|
// Enable view recycling
|
|
@@ -34,33 +42,41 @@ public class HybridCesiumViewManager: SimpleViewManager<View>() {
|
|
|
34
42
|
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
35
43
|
val hybridView = HybridCesiumView(reactContext)
|
|
36
44
|
val view = hybridView.view
|
|
37
|
-
view.setTag(associated_hybrid_view_tag, hybridView)
|
|
45
|
+
view.setTag(associated_hybrid_view_tag, HybridViewHolder(hybridView))
|
|
38
46
|
return view
|
|
39
47
|
}
|
|
40
48
|
|
|
41
49
|
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
42
|
-
val
|
|
50
|
+
val holder = getHybridViewHolder(view)
|
|
43
51
|
?: throw Error("Couldn't find view $view in local views table!")
|
|
52
|
+
val hybridView = holder.hybridView
|
|
53
|
+
val oldState = holder.lastState
|
|
54
|
+
val newState = stateWrapper
|
|
44
55
|
|
|
45
56
|
// 1. Update each prop individually
|
|
46
57
|
hybridView.beforeUpdate()
|
|
47
|
-
HybridCesiumViewStateUpdater.updateViewProps(hybridView,
|
|
58
|
+
HybridCesiumViewStateUpdater.updateViewProps(hybridView, newState, oldState)
|
|
48
59
|
hybridView.afterUpdate()
|
|
60
|
+
holder.lastState = newState
|
|
49
61
|
|
|
50
62
|
// 2. Continue in base View props
|
|
51
|
-
return super.updateState(view, props,
|
|
63
|
+
return super.updateState(view, props, newState)
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
override fun onDropViewInstance(view: View) {
|
|
55
|
-
val
|
|
56
|
-
|
|
67
|
+
val holder = getHybridViewHolder(view)
|
|
68
|
+
holder?.lastState = null
|
|
69
|
+
holder?.hybridView?.onDropView()
|
|
57
70
|
return super.onDropViewInstance(view)
|
|
58
71
|
}
|
|
59
72
|
|
|
60
73
|
protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? {
|
|
61
|
-
super.prepareToRecycleView(reactContext, view)
|
|
62
|
-
|
|
74
|
+
val preparedView = super.prepareToRecycleView(reactContext, view)
|
|
75
|
+
?: return null
|
|
76
|
+
val holder = getHybridViewHolder(preparedView)
|
|
63
77
|
?: return null
|
|
78
|
+
val hybridView = holder.hybridView
|
|
79
|
+
holder.lastState = null
|
|
64
80
|
|
|
65
81
|
@Suppress("USELESS_IS_CHECK")
|
|
66
82
|
if (hybridView is RecyclableView) {
|
|
@@ -74,7 +90,7 @@ public class HybridCesiumViewManager: SimpleViewManager<View>() {
|
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
92
|
|
|
77
|
-
private fun
|
|
78
|
-
return view.getTag(associated_hybrid_view_tag) as?
|
|
93
|
+
private fun getHybridViewHolder(view: View): HybridViewHolder? {
|
|
94
|
+
return view.getTag(associated_hybrid_view_tag) as? HybridViewHolder
|
|
79
95
|
}
|
|
80
96
|
}
|
|
@@ -14,10 +14,10 @@ internal class HybridCesiumViewStateUpdater {
|
|
|
14
14
|
companion object {
|
|
15
15
|
/**
|
|
16
16
|
* Updates the props for [view] through C++.
|
|
17
|
-
* The [
|
|
17
|
+
* The [newState] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
18
|
*/
|
|
19
19
|
@Suppress("KotlinJniMissingFunction")
|
|
20
20
|
@JvmStatic
|
|
21
|
-
external fun updateViewProps(view: HybridCesiumViewSpec,
|
|
21
|
+
external fun updateViewProps(view: HybridCesiumViewSpec, newState: StateWrapper, oldState: StateWrapper?)
|
|
22
22
|
}
|
|
23
23
|
}
|