react-native-cesium 1.0.1
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/LICENSE +21 -0
- package/NOTICE +12 -0
- package/README.md +308 -0
- package/ReactNativeCesium.podspec +54 -0
- package/android/CMakeLists.txt +146 -0
- package/android/build.gradle +178 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/assets/cacert.pem +3529 -0
- package/android/src/main/cpp/CesiumBridgeAndroid.cpp +487 -0
- package/android/src/main/cpp/CesiumBridgeAndroid.h +94 -0
- package/android/src/main/cpp/cpp-adapter.cpp +17 -0
- package/android/src/main/cpp/vulkan/VulkanBackend.cpp +1781 -0
- package/android/src/main/cpp/vulkan/VulkanBackend.h +190 -0
- package/android/src/main/cpp/vulkan/shaders/sky.frag +86 -0
- package/android/src/main/cpp/vulkan/shaders/sky.vert +9 -0
- package/android/src/main/cpp/vulkan/shaders/terrain.frag +144 -0
- package/android/src/main/cpp/vulkan/shaders/terrain.vert +25 -0
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/CesiumBridgeJNI.kt +84 -0
- package/android/src/main/java/com/margelo/nitro/reactnativecesium/HybridCesiumView.kt +225 -0
- package/android/src/main/java/com/reactnativecesium/ReactNativeCesiumPackage.kt +28 -0
- package/cpp/engine/CesiumEngine.cpp +413 -0
- package/cpp/engine/CesiumEngine.hpp +90 -0
- package/cpp/engine/DeletionQueue.cpp +28 -0
- package/cpp/engine/DeletionQueue.hpp +28 -0
- package/cpp/engine/GlobeCamera.cpp +181 -0
- package/cpp/engine/GlobeCamera.hpp +64 -0
- package/cpp/engine/GltfToMesh.cpp +154 -0
- package/cpp/engine/GltfToMesh.hpp +20 -0
- package/cpp/engine/ResourcePreparer.cpp +224 -0
- package/cpp/engine/ResourcePreparer.hpp +96 -0
- package/cpp/engine/TaskProcessor.cpp +61 -0
- package/cpp/engine/TaskProcessor.hpp +43 -0
- package/cpp/engine/TileLifecycleManager.cpp +30 -0
- package/cpp/engine/TileLifecycleManager.hpp +25 -0
- package/cpp/fmt/format.h +9 -0
- package/cpp/renderer/IGPUBackend.hpp +22 -0
- package/cpp/renderer/RenderTypes.hpp +112 -0
- package/cpp/renderer/ShaderTypes.hpp +29 -0
- package/example/README.md +43 -0
- package/example/react-native-cesium-example.jpg +0 -0
- package/ios/CesiumBridge.h +55 -0
- package/ios/CesiumBridge.mm +393 -0
- package/ios/HybridCesiumView.swift +299 -0
- package/ios/ReactNativeCesium-umbrella.h +16 -0
- package/ios/metal/MetalBackend.h +82 -0
- package/ios/metal/MetalBackend.mm +839 -0
- package/ios/react_native_cesium_ensure_native.rb +12 -0
- package/ios/react_native_cesium_post_install.rb +30 -0
- package/lib/commonjs/CesiumView.js +13 -0
- package/lib/commonjs/CesiumView.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/cesium-view.nitro.js +6 -0
- package/lib/commonjs/specs/cesium-view.nitro.js.map +1 -0
- package/lib/module/CesiumView.js +9 -0
- package/lib/module/CesiumView.js.map +1 -0
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/specs/cesium-view.nitro.js +4 -0
- package/lib/module/specs/cesium-view.nitro.js.map +1 -0
- package/lib/typescript/src/CesiumView.d.ts +5 -0
- package/lib/typescript/src/CesiumView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts +43 -0
- package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/ReactNativeCesium+autolinking.cmake +83 -0
- package/nitrogen/generated/android/ReactNativeCesium+autolinking.gradle +27 -0
- package/nitrogen/generated/android/ReactNativeCesiumOnLoad.cpp +58 -0
- package/nitrogen/generated/android/ReactNativeCesiumOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JCameraState.hpp +81 -0
- package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_CesiumMetrics.hpp +78 -0
- package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.cpp +178 -0
- package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.hpp +83 -0
- package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +92 -0
- package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CesiumMetrics.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +126 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/ReactNativeCesiumOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewManager.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/ReactNativeCesium+autolinking.rb +60 -0
- package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.cpp +57 -0
- package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.hpp +164 -0
- package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Umbrella.hpp +53 -0
- package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.mm +33 -0
- package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.hpp +157 -0
- package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +167 -0
- package/nitrogen/generated/ios/swift/CameraState.swift +59 -0
- package/nitrogen/generated/ios/swift/CesiumMetrics.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_CameraState.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CesiumMetrics.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCesiumViewSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridCesiumViewSpec_cxx.swift +306 -0
- package/nitrogen/generated/shared/c++/CameraState.hpp +107 -0
- package/nitrogen/generated/shared/c++/CesiumMetrics.hpp +107 -0
- package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.cpp +42 -0
- package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.hpp +90 -0
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +182 -0
- package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +122 -0
- package/nitrogen/generated/shared/json/CesiumViewConfig.json +19 -0
- package/package.json +140 -0
- package/react-native.config.js +16 -0
- package/scripts/cesium/build.mjs +901 -0
- package/scripts/cesium/clean.mjs +35 -0
- package/scripts/cesium/clone.mjs +32 -0
- package/scripts/cesium/ensure-native.mjs +116 -0
- package/scripts/cesium/vcpkg-ports/zstd/fix-emscripten-and-clang-cl.patch +31 -0
- package/scripts/cesium/vcpkg-ports/zstd/fix-windows-rc-compile.patch +13 -0
- package/scripts/cesium/vcpkg-ports/zstd/no-static-suffix.patch +13 -0
- package/scripts/cesium/vcpkg-ports/zstd/portfile.cmake +77 -0
- package/scripts/cesium/vcpkg-ports/zstd/usage +4 -0
- package/scripts/cesium/vcpkg-ports/zstd/vcpkg.json +23 -0
- package/scripts/cesium/vcpkg-triplets/arm64-ios-simulator.cmake +10 -0
- package/scripts/cesium/vcpkg-triplets/arm64-ios.cmake +14 -0
- package/src/CesiumView.tsx +13 -0
- package/src/index.ts +7 -0
- package/src/specs/cesium-view.nitro.ts +51 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCesiumViewSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridCesiumViewSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridCesiumViewSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace ReactNativeCesium { class HybridCesiumViewSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
// Forward declaration of `CameraState` to properly resolve imports.
|
|
16
|
+
namespace margelo::nitro::reactnativecesium { struct CameraState; }
|
|
17
|
+
// Forward declaration of `CesiumMetrics` to properly resolve imports.
|
|
18
|
+
namespace margelo::nitro::reactnativecesium { struct CesiumMetrics; }
|
|
19
|
+
|
|
20
|
+
#include <string>
|
|
21
|
+
#include "CameraState.hpp"
|
|
22
|
+
#include "CesiumMetrics.hpp"
|
|
23
|
+
#include <functional>
|
|
24
|
+
#include <optional>
|
|
25
|
+
#include <NitroModules/Promise.hpp>
|
|
26
|
+
|
|
27
|
+
#include "ReactNativeCesium-Swift-Cxx-Umbrella.hpp"
|
|
28
|
+
|
|
29
|
+
namespace margelo::nitro::reactnativecesium {
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The C++ part of HybridCesiumViewSpec_cxx.swift.
|
|
33
|
+
*
|
|
34
|
+
* HybridCesiumViewSpecSwift (C++) accesses HybridCesiumViewSpec_cxx (Swift), and might
|
|
35
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
36
|
+
*
|
|
37
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
38
|
+
* the future, HybridCesiumViewSpec_cxx can directly inherit from the C++ class HybridCesiumViewSpec
|
|
39
|
+
* to simplify the whole structure and memory management.
|
|
40
|
+
*/
|
|
41
|
+
class HybridCesiumViewSpecSwift: public virtual HybridCesiumViewSpec {
|
|
42
|
+
public:
|
|
43
|
+
// Constructor from a Swift instance
|
|
44
|
+
explicit HybridCesiumViewSpecSwift(const ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart):
|
|
45
|
+
HybridObject(HybridCesiumViewSpec::TAG),
|
|
46
|
+
_swiftPart(swiftPart) { }
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Get the Swift part
|
|
50
|
+
inline ReactNativeCesium::HybridCesiumViewSpec_cxx& getSwiftPart() noexcept {
|
|
51
|
+
return _swiftPart;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
56
|
+
return _swiftPart.getMemorySize();
|
|
57
|
+
}
|
|
58
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
59
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridCesiumViewSpecSwift>(other)) {
|
|
60
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
void dispose() noexcept override {
|
|
65
|
+
_swiftPart.dispose();
|
|
66
|
+
}
|
|
67
|
+
std::string toString() override {
|
|
68
|
+
return _swiftPart.toString();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public:
|
|
72
|
+
// Properties
|
|
73
|
+
inline std::string getIonAccessToken() noexcept override {
|
|
74
|
+
auto __result = _swiftPart.getIonAccessToken();
|
|
75
|
+
return __result;
|
|
76
|
+
}
|
|
77
|
+
inline void setIonAccessToken(const std::string& ionAccessToken) noexcept override {
|
|
78
|
+
_swiftPart.setIonAccessToken(ionAccessToken);
|
|
79
|
+
}
|
|
80
|
+
inline double getIonAssetId() noexcept override {
|
|
81
|
+
return _swiftPart.getIonAssetId();
|
|
82
|
+
}
|
|
83
|
+
inline void setIonAssetId(double ionAssetId) noexcept override {
|
|
84
|
+
_swiftPart.setIonAssetId(std::forward<decltype(ionAssetId)>(ionAssetId));
|
|
85
|
+
}
|
|
86
|
+
inline CameraState getInitialCamera() noexcept override {
|
|
87
|
+
return _swiftPart.getInitialCamera();
|
|
88
|
+
}
|
|
89
|
+
inline void setInitialCamera(const CameraState& initialCamera) noexcept override {
|
|
90
|
+
_swiftPart.setInitialCamera(std::forward<decltype(initialCamera)>(initialCamera));
|
|
91
|
+
}
|
|
92
|
+
inline bool getPauseRendering() noexcept override {
|
|
93
|
+
return _swiftPart.getPauseRendering();
|
|
94
|
+
}
|
|
95
|
+
inline void setPauseRendering(bool pauseRendering) noexcept override {
|
|
96
|
+
_swiftPart.setPauseRendering(std::forward<decltype(pauseRendering)>(pauseRendering));
|
|
97
|
+
}
|
|
98
|
+
inline double getMaximumScreenSpaceError() noexcept override {
|
|
99
|
+
return _swiftPart.getMaximumScreenSpaceError();
|
|
100
|
+
}
|
|
101
|
+
inline void setMaximumScreenSpaceError(double maximumScreenSpaceError) noexcept override {
|
|
102
|
+
_swiftPart.setMaximumScreenSpaceError(std::forward<decltype(maximumScreenSpaceError)>(maximumScreenSpaceError));
|
|
103
|
+
}
|
|
104
|
+
inline double getMaximumSimultaneousTileLoads() noexcept override {
|
|
105
|
+
return _swiftPart.getMaximumSimultaneousTileLoads();
|
|
106
|
+
}
|
|
107
|
+
inline void setMaximumSimultaneousTileLoads(double maximumSimultaneousTileLoads) noexcept override {
|
|
108
|
+
_swiftPart.setMaximumSimultaneousTileLoads(std::forward<decltype(maximumSimultaneousTileLoads)>(maximumSimultaneousTileLoads));
|
|
109
|
+
}
|
|
110
|
+
inline double getLoadingDescendantLimit() noexcept override {
|
|
111
|
+
return _swiftPart.getLoadingDescendantLimit();
|
|
112
|
+
}
|
|
113
|
+
inline void setLoadingDescendantLimit(double loadingDescendantLimit) noexcept override {
|
|
114
|
+
_swiftPart.setLoadingDescendantLimit(std::forward<decltype(loadingDescendantLimit)>(loadingDescendantLimit));
|
|
115
|
+
}
|
|
116
|
+
inline double getMsaaSampleCount() noexcept override {
|
|
117
|
+
return _swiftPart.getMsaaSampleCount();
|
|
118
|
+
}
|
|
119
|
+
inline void setMsaaSampleCount(double msaaSampleCount) noexcept override {
|
|
120
|
+
_swiftPart.setMsaaSampleCount(std::forward<decltype(msaaSampleCount)>(msaaSampleCount));
|
|
121
|
+
}
|
|
122
|
+
inline double getIonImageryAssetId() noexcept override {
|
|
123
|
+
return _swiftPart.getIonImageryAssetId();
|
|
124
|
+
}
|
|
125
|
+
inline void setIonImageryAssetId(double ionImageryAssetId) noexcept override {
|
|
126
|
+
_swiftPart.setIonImageryAssetId(std::forward<decltype(ionImageryAssetId)>(ionImageryAssetId));
|
|
127
|
+
}
|
|
128
|
+
inline std::optional<std::function<void(const CesiumMetrics& /* metrics */)>> getOnMetrics() noexcept override {
|
|
129
|
+
auto __result = _swiftPart.getOnMetrics();
|
|
130
|
+
return __result;
|
|
131
|
+
}
|
|
132
|
+
inline void setOnMetrics(const std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>& onMetrics) noexcept override {
|
|
133
|
+
_swiftPart.setOnMetrics(onMetrics);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public:
|
|
137
|
+
// Methods
|
|
138
|
+
inline std::shared_ptr<Promise<CameraState>> getCameraState() override {
|
|
139
|
+
auto __result = _swiftPart.getCameraState();
|
|
140
|
+
if (__result.hasError()) [[unlikely]] {
|
|
141
|
+
std::rethrow_exception(__result.error());
|
|
142
|
+
}
|
|
143
|
+
auto __value = std::move(__result.value());
|
|
144
|
+
return __value;
|
|
145
|
+
}
|
|
146
|
+
inline void setCamera(const CameraState& camera) override {
|
|
147
|
+
auto __result = _swiftPart.setCamera(std::forward<decltype(camera)>(camera));
|
|
148
|
+
if (__result.hasError()) [[unlikely]] {
|
|
149
|
+
std::rethrow_exception(__result.error());
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private:
|
|
154
|
+
ReactNativeCesium::HybridCesiumViewSpec_cxx _swiftPart;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
} // namespace margelo::nitro::reactnativecesium
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCesiumViewComponent.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import "HybridCesiumViewComponent.hpp"
|
|
9
|
+
#import <memory>
|
|
10
|
+
#import <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
11
|
+
#import <React/RCTViewComponentView.h>
|
|
12
|
+
#import <React/RCTComponentViewFactory.h>
|
|
13
|
+
#import <React/UIView+ComponentViewProtocol.h>
|
|
14
|
+
#import <NitroModules/NitroDefines.hpp>
|
|
15
|
+
#import <UIKit/UIKit.h>
|
|
16
|
+
|
|
17
|
+
#import "HybridCesiumViewSpecSwift.hpp"
|
|
18
|
+
#import "ReactNativeCesium-Swift-Cxx-Umbrella.hpp"
|
|
19
|
+
|
|
20
|
+
#if __has_include(<cxxreact/ReactNativeVersion.h>)
|
|
21
|
+
#include <cxxreact/ReactNativeVersion.h>
|
|
22
|
+
#if REACT_NATIVE_VERSION_MINOR >= 82
|
|
23
|
+
#define ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
24
|
+
#endif
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
using namespace facebook;
|
|
28
|
+
using namespace margelo::nitro::reactnativecesium;
|
|
29
|
+
using namespace margelo::nitro::reactnativecesium::views;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents the React Native View holder for the Nitro "CesiumView" HybridView.
|
|
33
|
+
*/
|
|
34
|
+
@interface HybridCesiumViewComponent: RCTViewComponentView
|
|
35
|
+
+ (BOOL)shouldBeRecycled;
|
|
36
|
+
@end
|
|
37
|
+
|
|
38
|
+
@implementation HybridCesiumViewComponent {
|
|
39
|
+
std::shared_ptr<HybridCesiumViewSpecSwift> _hybridView;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (void) load {
|
|
43
|
+
[super load];
|
|
44
|
+
[RCTComponentViewFactory.currentComponentViewFactory registerComponentViewClass:[HybridCesiumViewComponent class]];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
+ (react::ComponentDescriptorProvider) componentDescriptorProvider {
|
|
48
|
+
return react::concreteComponentDescriptorProvider<HybridCesiumViewComponentDescriptor>();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
- (instancetype) init {
|
|
52
|
+
if (self = [super init]) {
|
|
53
|
+
std::shared_ptr<HybridCesiumViewSpec> hybridView = ReactNativeCesium::ReactNativeCesiumAutolinking::createCesiumView();
|
|
54
|
+
_hybridView = std::dynamic_pointer_cast<HybridCesiumViewSpecSwift>(hybridView);
|
|
55
|
+
[self updateView];
|
|
56
|
+
}
|
|
57
|
+
return self;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void) updateView {
|
|
61
|
+
// 1. Get Swift part
|
|
62
|
+
ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
63
|
+
|
|
64
|
+
// 2. Get UIView*
|
|
65
|
+
void* viewUnsafe = swiftPart.getView();
|
|
66
|
+
UIView* view = (__bridge_transfer UIView*) viewUnsafe;
|
|
67
|
+
|
|
68
|
+
// 3. Update RCTViewComponentView's [contentView]
|
|
69
|
+
[self setContentView:view];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
- (void) updateProps:(const std::shared_ptr<const react::Props>&)props
|
|
73
|
+
oldProps:(const std::shared_ptr<const react::Props>&)oldProps {
|
|
74
|
+
// 1. Downcast props
|
|
75
|
+
const auto& newViewPropsConst = *std::static_pointer_cast<HybridCesiumViewProps const>(props);
|
|
76
|
+
auto& newViewProps = const_cast<HybridCesiumViewProps&>(newViewPropsConst);
|
|
77
|
+
ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
78
|
+
|
|
79
|
+
// 2. Update each prop individually
|
|
80
|
+
swiftPart.beforeUpdate();
|
|
81
|
+
|
|
82
|
+
// ionAccessToken: string
|
|
83
|
+
if (newViewProps.ionAccessToken.isDirty) {
|
|
84
|
+
swiftPart.setIonAccessToken(newViewProps.ionAccessToken.value);
|
|
85
|
+
newViewProps.ionAccessToken.isDirty = false;
|
|
86
|
+
}
|
|
87
|
+
// ionAssetId: number
|
|
88
|
+
if (newViewProps.ionAssetId.isDirty) {
|
|
89
|
+
swiftPart.setIonAssetId(newViewProps.ionAssetId.value);
|
|
90
|
+
newViewProps.ionAssetId.isDirty = false;
|
|
91
|
+
}
|
|
92
|
+
// initialCamera: struct
|
|
93
|
+
if (newViewProps.initialCamera.isDirty) {
|
|
94
|
+
swiftPart.setInitialCamera(newViewProps.initialCamera.value);
|
|
95
|
+
newViewProps.initialCamera.isDirty = false;
|
|
96
|
+
}
|
|
97
|
+
// pauseRendering: boolean
|
|
98
|
+
if (newViewProps.pauseRendering.isDirty) {
|
|
99
|
+
swiftPart.setPauseRendering(newViewProps.pauseRendering.value);
|
|
100
|
+
newViewProps.pauseRendering.isDirty = false;
|
|
101
|
+
}
|
|
102
|
+
// maximumScreenSpaceError: number
|
|
103
|
+
if (newViewProps.maximumScreenSpaceError.isDirty) {
|
|
104
|
+
swiftPart.setMaximumScreenSpaceError(newViewProps.maximumScreenSpaceError.value);
|
|
105
|
+
newViewProps.maximumScreenSpaceError.isDirty = false;
|
|
106
|
+
}
|
|
107
|
+
// maximumSimultaneousTileLoads: number
|
|
108
|
+
if (newViewProps.maximumSimultaneousTileLoads.isDirty) {
|
|
109
|
+
swiftPart.setMaximumSimultaneousTileLoads(newViewProps.maximumSimultaneousTileLoads.value);
|
|
110
|
+
newViewProps.maximumSimultaneousTileLoads.isDirty = false;
|
|
111
|
+
}
|
|
112
|
+
// loadingDescendantLimit: number
|
|
113
|
+
if (newViewProps.loadingDescendantLimit.isDirty) {
|
|
114
|
+
swiftPart.setLoadingDescendantLimit(newViewProps.loadingDescendantLimit.value);
|
|
115
|
+
newViewProps.loadingDescendantLimit.isDirty = false;
|
|
116
|
+
}
|
|
117
|
+
// msaaSampleCount: number
|
|
118
|
+
if (newViewProps.msaaSampleCount.isDirty) {
|
|
119
|
+
swiftPart.setMsaaSampleCount(newViewProps.msaaSampleCount.value);
|
|
120
|
+
newViewProps.msaaSampleCount.isDirty = false;
|
|
121
|
+
}
|
|
122
|
+
// ionImageryAssetId: number
|
|
123
|
+
if (newViewProps.ionImageryAssetId.isDirty) {
|
|
124
|
+
swiftPart.setIonImageryAssetId(newViewProps.ionImageryAssetId.value);
|
|
125
|
+
newViewProps.ionImageryAssetId.isDirty = false;
|
|
126
|
+
}
|
|
127
|
+
// onMetrics: optional
|
|
128
|
+
if (newViewProps.onMetrics.isDirty) {
|
|
129
|
+
swiftPart.setOnMetrics(newViewProps.onMetrics.value);
|
|
130
|
+
newViewProps.onMetrics.isDirty = false;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
swiftPart.afterUpdate();
|
|
134
|
+
|
|
135
|
+
// 3. Update hybridRef if it changed
|
|
136
|
+
if (newViewProps.hybridRef.isDirty) {
|
|
137
|
+
// hybridRef changed - call it with new this
|
|
138
|
+
const auto& maybeFunc = newViewProps.hybridRef.value;
|
|
139
|
+
if (maybeFunc.has_value()) {
|
|
140
|
+
maybeFunc.value()(_hybridView);
|
|
141
|
+
}
|
|
142
|
+
newViewProps.hybridRef.isDirty = false;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// 4. Continue in base class
|
|
146
|
+
[super updateProps:props oldProps:oldProps];
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
+ (BOOL)shouldBeRecycled {
|
|
150
|
+
return ReactNativeCesium::ReactNativeCesiumAutolinking::isCesiumViewRecyclable();
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
- (void)prepareForRecycle {
|
|
154
|
+
[super prepareForRecycle];
|
|
155
|
+
ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
156
|
+
swiftPart.maybePrepareForRecycle();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#ifdef ENABLE_RCT_COMPONENT_VIEW_INVALIDATE
|
|
160
|
+
- (void)invalidate {
|
|
161
|
+
ReactNativeCesium::HybridCesiumViewSpec_cxx& swiftPart = _hybridView->getSwiftPart();
|
|
162
|
+
swiftPart.onDropView();
|
|
163
|
+
[super invalidate];
|
|
164
|
+
}
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
@end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CameraState.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `CameraState`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias CameraState = margelo.nitro.reactnativecesium.CameraState
|
|
14
|
+
|
|
15
|
+
public extension CameraState {
|
|
16
|
+
private typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `CameraState`.
|
|
20
|
+
*/
|
|
21
|
+
init(latitude: Double, longitude: Double, altitude: Double, heading: Double, pitch: Double, roll: Double, verticalFovDeg: Double) {
|
|
22
|
+
self.init(latitude, longitude, altitude, heading, pitch, roll, verticalFovDeg)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var latitude: Double {
|
|
27
|
+
return self.__latitude
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var longitude: Double {
|
|
32
|
+
return self.__longitude
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var altitude: Double {
|
|
37
|
+
return self.__altitude
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var heading: Double {
|
|
42
|
+
return self.__heading
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var pitch: Double {
|
|
47
|
+
return self.__pitch
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var roll: Double {
|
|
52
|
+
return self.__roll
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inline(__always)
|
|
56
|
+
var verticalFovDeg: Double {
|
|
57
|
+
return self.__verticalFovDeg
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CesiumMetrics.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Represents an instance of `CesiumMetrics`, backed by a C++ struct.
|
|
12
|
+
*/
|
|
13
|
+
public typealias CesiumMetrics = margelo.nitro.reactnativecesium.CesiumMetrics
|
|
14
|
+
|
|
15
|
+
public extension CesiumMetrics {
|
|
16
|
+
private typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new instance of `CesiumMetrics`.
|
|
20
|
+
*/
|
|
21
|
+
init(fps: Double, tilesRendered: Double, tilesLoading: Double, tilesVisited: Double, ionTokenConfigured: Bool, tilesetReady: Bool, creditsPlainText: String) {
|
|
22
|
+
self.init(fps, tilesRendered, tilesLoading, tilesVisited, ionTokenConfigured, tilesetReady, std.string(creditsPlainText))
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@inline(__always)
|
|
26
|
+
var fps: Double {
|
|
27
|
+
return self.__fps
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@inline(__always)
|
|
31
|
+
var tilesRendered: Double {
|
|
32
|
+
return self.__tilesRendered
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@inline(__always)
|
|
36
|
+
var tilesLoading: Double {
|
|
37
|
+
return self.__tilesLoading
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@inline(__always)
|
|
41
|
+
var tilesVisited: Double {
|
|
42
|
+
return self.__tilesVisited
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@inline(__always)
|
|
46
|
+
var ionTokenConfigured: Bool {
|
|
47
|
+
return self.__ionTokenConfigured
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@inline(__always)
|
|
51
|
+
var tilesetReady: Bool {
|
|
52
|
+
return self.__tilesetReady
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@inline(__always)
|
|
56
|
+
var creditsPlainText: String {
|
|
57
|
+
return String(self.__creditsPlainText)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_CameraState.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ value: CameraState) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_CameraState {
|
|
15
|
+
public typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ value: CameraState) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ value: CameraState) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(value: CameraState) -> Void {
|
|
25
|
+
self.closure(value)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_CameraState`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_CameraState>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_CameraState {
|
|
44
|
+
return Unmanaged<Func_void_CameraState>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_CesiumMetrics.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ metrics: CesiumMetrics) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_CesiumMetrics {
|
|
15
|
+
public typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ metrics: CesiumMetrics) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ metrics: CesiumMetrics) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(metrics: CesiumMetrics) -> Void {
|
|
25
|
+
self.closure(metrics)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_CesiumMetrics`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_CesiumMetrics>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_CesiumMetrics {
|
|
44
|
+
return Unmanaged<Func_void_CesiumMetrics>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCesiumViewSpec.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/// See ``HybridCesiumViewSpec``
|
|
11
|
+
public protocol HybridCesiumViewSpec_protocol: HybridObject, HybridView {
|
|
12
|
+
// Properties
|
|
13
|
+
var ionAccessToken: String { get set }
|
|
14
|
+
var ionAssetId: Double { get set }
|
|
15
|
+
var initialCamera: CameraState { get set }
|
|
16
|
+
var pauseRendering: Bool { get set }
|
|
17
|
+
var maximumScreenSpaceError: Double { get set }
|
|
18
|
+
var maximumSimultaneousTileLoads: Double { get set }
|
|
19
|
+
var loadingDescendantLimit: Double { get set }
|
|
20
|
+
var msaaSampleCount: Double { get set }
|
|
21
|
+
var ionImageryAssetId: Double { get set }
|
|
22
|
+
var onMetrics: ((_ metrics: CesiumMetrics) -> Void)? { get set }
|
|
23
|
+
|
|
24
|
+
// Methods
|
|
25
|
+
func getCameraState() throws -> Promise<CameraState>
|
|
26
|
+
func setCamera(camera: CameraState) throws -> Void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public extension HybridCesiumViewSpec_protocol {
|
|
30
|
+
/// Default implementation of ``HybridObject.toString``
|
|
31
|
+
func toString() -> String {
|
|
32
|
+
return "[HybridObject CesiumView]"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/// See ``HybridCesiumViewSpec``
|
|
37
|
+
open class HybridCesiumViewSpec_base {
|
|
38
|
+
private weak var cxxWrapper: HybridCesiumViewSpec_cxx? = nil
|
|
39
|
+
public init() { }
|
|
40
|
+
public func getCxxWrapper() -> HybridCesiumViewSpec_cxx {
|
|
41
|
+
#if DEBUG
|
|
42
|
+
guard self is any HybridCesiumViewSpec else {
|
|
43
|
+
fatalError("`self` is not a `HybridCesiumViewSpec`! Did you accidentally inherit from `HybridCesiumViewSpec_base` instead of `HybridCesiumViewSpec`?")
|
|
44
|
+
}
|
|
45
|
+
#endif
|
|
46
|
+
if let cxxWrapper = self.cxxWrapper {
|
|
47
|
+
return cxxWrapper
|
|
48
|
+
} else {
|
|
49
|
+
let cxxWrapper = HybridCesiumViewSpec_cxx(self as! any HybridCesiumViewSpec)
|
|
50
|
+
self.cxxWrapper = cxxWrapper
|
|
51
|
+
return cxxWrapper
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A Swift base-protocol representing the CesiumView HybridObject.
|
|
58
|
+
* Implement this protocol to create Swift-based instances of CesiumView.
|
|
59
|
+
* ```swift
|
|
60
|
+
* class HybridCesiumView : HybridCesiumViewSpec {
|
|
61
|
+
* // ...
|
|
62
|
+
* }
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
public typealias HybridCesiumViewSpec = HybridCesiumViewSpec_protocol & HybridCesiumViewSpec_base
|