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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +12 -0
  3. package/README.md +308 -0
  4. package/ReactNativeCesium.podspec +54 -0
  5. package/android/CMakeLists.txt +146 -0
  6. package/android/build.gradle +178 -0
  7. package/android/fix-prefab.gradle +51 -0
  8. package/android/gradle.properties +5 -0
  9. package/android/src/main/AndroidManifest.xml +5 -0
  10. package/android/src/main/assets/cacert.pem +3529 -0
  11. package/android/src/main/cpp/CesiumBridgeAndroid.cpp +487 -0
  12. package/android/src/main/cpp/CesiumBridgeAndroid.h +94 -0
  13. package/android/src/main/cpp/cpp-adapter.cpp +17 -0
  14. package/android/src/main/cpp/vulkan/VulkanBackend.cpp +1781 -0
  15. package/android/src/main/cpp/vulkan/VulkanBackend.h +190 -0
  16. package/android/src/main/cpp/vulkan/shaders/sky.frag +86 -0
  17. package/android/src/main/cpp/vulkan/shaders/sky.vert +9 -0
  18. package/android/src/main/cpp/vulkan/shaders/terrain.frag +144 -0
  19. package/android/src/main/cpp/vulkan/shaders/terrain.vert +25 -0
  20. package/android/src/main/java/com/margelo/nitro/reactnativecesium/CesiumBridgeJNI.kt +84 -0
  21. package/android/src/main/java/com/margelo/nitro/reactnativecesium/HybridCesiumView.kt +225 -0
  22. package/android/src/main/java/com/reactnativecesium/ReactNativeCesiumPackage.kt +28 -0
  23. package/cpp/engine/CesiumEngine.cpp +413 -0
  24. package/cpp/engine/CesiumEngine.hpp +90 -0
  25. package/cpp/engine/DeletionQueue.cpp +28 -0
  26. package/cpp/engine/DeletionQueue.hpp +28 -0
  27. package/cpp/engine/GlobeCamera.cpp +181 -0
  28. package/cpp/engine/GlobeCamera.hpp +64 -0
  29. package/cpp/engine/GltfToMesh.cpp +154 -0
  30. package/cpp/engine/GltfToMesh.hpp +20 -0
  31. package/cpp/engine/ResourcePreparer.cpp +224 -0
  32. package/cpp/engine/ResourcePreparer.hpp +96 -0
  33. package/cpp/engine/TaskProcessor.cpp +61 -0
  34. package/cpp/engine/TaskProcessor.hpp +43 -0
  35. package/cpp/engine/TileLifecycleManager.cpp +30 -0
  36. package/cpp/engine/TileLifecycleManager.hpp +25 -0
  37. package/cpp/fmt/format.h +9 -0
  38. package/cpp/renderer/IGPUBackend.hpp +22 -0
  39. package/cpp/renderer/RenderTypes.hpp +112 -0
  40. package/cpp/renderer/ShaderTypes.hpp +29 -0
  41. package/example/README.md +43 -0
  42. package/example/react-native-cesium-example.jpg +0 -0
  43. package/ios/CesiumBridge.h +55 -0
  44. package/ios/CesiumBridge.mm +393 -0
  45. package/ios/HybridCesiumView.swift +299 -0
  46. package/ios/ReactNativeCesium-umbrella.h +16 -0
  47. package/ios/metal/MetalBackend.h +82 -0
  48. package/ios/metal/MetalBackend.mm +839 -0
  49. package/ios/react_native_cesium_ensure_native.rb +12 -0
  50. package/ios/react_native_cesium_post_install.rb +30 -0
  51. package/lib/commonjs/CesiumView.js +13 -0
  52. package/lib/commonjs/CesiumView.js.map +1 -0
  53. package/lib/commonjs/index.js +13 -0
  54. package/lib/commonjs/index.js.map +1 -0
  55. package/lib/commonjs/package.json +1 -0
  56. package/lib/commonjs/specs/cesium-view.nitro.js +6 -0
  57. package/lib/commonjs/specs/cesium-view.nitro.js.map +1 -0
  58. package/lib/module/CesiumView.js +9 -0
  59. package/lib/module/CesiumView.js.map +1 -0
  60. package/lib/module/index.js +4 -0
  61. package/lib/module/index.js.map +1 -0
  62. package/lib/module/specs/cesium-view.nitro.js +4 -0
  63. package/lib/module/specs/cesium-view.nitro.js.map +1 -0
  64. package/lib/typescript/src/CesiumView.d.ts +5 -0
  65. package/lib/typescript/src/CesiumView.d.ts.map +1 -0
  66. package/lib/typescript/src/index.d.ts +3 -0
  67. package/lib/typescript/src/index.d.ts.map +1 -0
  68. package/lib/typescript/src/specs/cesium-view.nitro.d.ts +43 -0
  69. package/lib/typescript/src/specs/cesium-view.nitro.d.ts.map +1 -0
  70. package/nitro.json +30 -0
  71. package/nitrogen/generated/.gitattributes +1 -0
  72. package/nitrogen/generated/android/ReactNativeCesium+autolinking.cmake +83 -0
  73. package/nitrogen/generated/android/ReactNativeCesium+autolinking.gradle +27 -0
  74. package/nitrogen/generated/android/ReactNativeCesiumOnLoad.cpp +58 -0
  75. package/nitrogen/generated/android/ReactNativeCesiumOnLoad.hpp +34 -0
  76. package/nitrogen/generated/android/c++/JCameraState.hpp +81 -0
  77. package/nitrogen/generated/android/c++/JCesiumMetrics.hpp +81 -0
  78. package/nitrogen/generated/android/c++/JFunc_void_CesiumMetrics.hpp +78 -0
  79. package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.cpp +178 -0
  80. package/nitrogen/generated/android/c++/JHybridCesiumViewSpec.hpp +83 -0
  81. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.cpp +92 -0
  82. package/nitrogen/generated/android/c++/views/JHybridCesiumViewStateUpdater.hpp +49 -0
  83. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CameraState.kt +56 -0
  84. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/CesiumMetrics.kt +56 -0
  85. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/Func_void_CesiumMetrics.kt +80 -0
  86. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/HybridCesiumViewSpec.kt +126 -0
  87. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/ReactNativeCesiumOnLoad.kt +35 -0
  88. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewManager.kt +80 -0
  89. package/nitrogen/generated/android/kotlin/com/margelo/nitro/reactnativecesium/views/HybridCesiumViewStateUpdater.kt +23 -0
  90. package/nitrogen/generated/ios/ReactNativeCesium+autolinking.rb +60 -0
  91. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.cpp +57 -0
  92. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Bridge.hpp +164 -0
  93. package/nitrogen/generated/ios/ReactNativeCesium-Swift-Cxx-Umbrella.hpp +53 -0
  94. package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.mm +33 -0
  95. package/nitrogen/generated/ios/ReactNativeCesiumAutolinking.swift +26 -0
  96. package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.cpp +11 -0
  97. package/nitrogen/generated/ios/c++/HybridCesiumViewSpecSwift.hpp +157 -0
  98. package/nitrogen/generated/ios/c++/views/HybridCesiumViewComponent.mm +167 -0
  99. package/nitrogen/generated/ios/swift/CameraState.swift +59 -0
  100. package/nitrogen/generated/ios/swift/CesiumMetrics.swift +59 -0
  101. package/nitrogen/generated/ios/swift/Func_void_CameraState.swift +46 -0
  102. package/nitrogen/generated/ios/swift/Func_void_CesiumMetrics.swift +46 -0
  103. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  104. package/nitrogen/generated/ios/swift/HybridCesiumViewSpec.swift +65 -0
  105. package/nitrogen/generated/ios/swift/HybridCesiumViewSpec_cxx.swift +306 -0
  106. package/nitrogen/generated/shared/c++/CameraState.hpp +107 -0
  107. package/nitrogen/generated/shared/c++/CesiumMetrics.hpp +107 -0
  108. package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.cpp +42 -0
  109. package/nitrogen/generated/shared/c++/HybridCesiumViewSpec.hpp +90 -0
  110. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.cpp +182 -0
  111. package/nitrogen/generated/shared/c++/views/HybridCesiumViewComponent.hpp +122 -0
  112. package/nitrogen/generated/shared/json/CesiumViewConfig.json +19 -0
  113. package/package.json +140 -0
  114. package/react-native.config.js +16 -0
  115. package/scripts/cesium/build.mjs +901 -0
  116. package/scripts/cesium/clean.mjs +35 -0
  117. package/scripts/cesium/clone.mjs +32 -0
  118. package/scripts/cesium/ensure-native.mjs +116 -0
  119. package/scripts/cesium/vcpkg-ports/zstd/fix-emscripten-and-clang-cl.patch +31 -0
  120. package/scripts/cesium/vcpkg-ports/zstd/fix-windows-rc-compile.patch +13 -0
  121. package/scripts/cesium/vcpkg-ports/zstd/no-static-suffix.patch +13 -0
  122. package/scripts/cesium/vcpkg-ports/zstd/portfile.cmake +77 -0
  123. package/scripts/cesium/vcpkg-ports/zstd/usage +4 -0
  124. package/scripts/cesium/vcpkg-ports/zstd/vcpkg.json +23 -0
  125. package/scripts/cesium/vcpkg-triplets/arm64-ios-simulator.cmake +10 -0
  126. package/scripts/cesium/vcpkg-triplets/arm64-ios.cmake +14 -0
  127. package/src/CesiumView.tsx +13 -0
  128. package/src/index.ts +7 -0
  129. package/src/specs/cesium-view.nitro.ts +51 -0
@@ -0,0 +1,306 @@
1
+ ///
2
+ /// HybridCesiumViewSpec_cxx.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
+ * A class implementation that bridges HybridCesiumViewSpec over to C++.
12
+ * In C++, we cannot use Swift protocols - so we need to wrap it in a class to make it strongly defined.
13
+ *
14
+ * Also, some Swift types need to be bridged with special handling:
15
+ * - Enums need to be wrapped in Structs, otherwise they cannot be accessed bi-directionally (Swift bug: https://github.com/swiftlang/swift/issues/75330)
16
+ * - Other HybridObjects need to be wrapped/unwrapped from the Swift TCxx wrapper
17
+ * - Throwing methods need to be wrapped with a Result<T, Error> type, as exceptions cannot be propagated to C++
18
+ */
19
+ open class HybridCesiumViewSpec_cxx {
20
+ /**
21
+ * The Swift <> C++ bridge's namespace (`margelo::nitro::reactnativecesium::bridge::swift`)
22
+ * from `ReactNativeCesium-Swift-Cxx-Bridge.hpp`.
23
+ * This contains specialized C++ templates, and C++ helper functions that can be accessed from Swift.
24
+ */
25
+ public typealias bridge = margelo.nitro.reactnativecesium.bridge.swift
26
+
27
+ /**
28
+ * Holds an instance of the `HybridCesiumViewSpec` Swift protocol.
29
+ */
30
+ private var __implementation: any HybridCesiumViewSpec
31
+
32
+ /**
33
+ * Holds a weak pointer to the C++ class that wraps the Swift class.
34
+ */
35
+ private var __cxxPart: bridge.std__weak_ptr_HybridCesiumViewSpec_
36
+
37
+ /**
38
+ * Create a new `HybridCesiumViewSpec_cxx` that wraps the given `HybridCesiumViewSpec`.
39
+ * All properties and methods bridge to C++ types.
40
+ */
41
+ public init(_ implementation: any HybridCesiumViewSpec) {
42
+ self.__implementation = implementation
43
+ self.__cxxPart = .init()
44
+ /* no base class */
45
+ }
46
+
47
+ /**
48
+ * Get the actual `HybridCesiumViewSpec` instance this class wraps.
49
+ */
50
+ @inline(__always)
51
+ public func getHybridCesiumViewSpec() -> any HybridCesiumViewSpec {
52
+ return __implementation
53
+ }
54
+
55
+ /**
56
+ * Casts this instance to a retained unsafe raw pointer.
57
+ * This acquires one additional strong reference on the object!
58
+ */
59
+ public func toUnsafe() -> UnsafeMutableRawPointer {
60
+ return Unmanaged.passRetained(self).toOpaque()
61
+ }
62
+
63
+ /**
64
+ * Casts an unsafe pointer to a `HybridCesiumViewSpec_cxx`.
65
+ * The pointer has to be a retained opaque `Unmanaged<HybridCesiumViewSpec_cxx>`.
66
+ * This removes one strong reference from the object!
67
+ */
68
+ public class func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> HybridCesiumViewSpec_cxx {
69
+ return Unmanaged<HybridCesiumViewSpec_cxx>.fromOpaque(pointer).takeRetainedValue()
70
+ }
71
+
72
+ /**
73
+ * Gets (or creates) the C++ part of this Hybrid Object.
74
+ * The C++ part is a `std::shared_ptr<HybridCesiumViewSpec>`.
75
+ */
76
+ public func getCxxPart() -> bridge.std__shared_ptr_HybridCesiumViewSpec_ {
77
+ let cachedCxxPart = self.__cxxPart.lock()
78
+ if Bool(fromCxx: cachedCxxPart) {
79
+ return cachedCxxPart
80
+ } else {
81
+ let newCxxPart = bridge.create_std__shared_ptr_HybridCesiumViewSpec_(self.toUnsafe())
82
+ __cxxPart = bridge.weakify_std__shared_ptr_HybridCesiumViewSpec_(newCxxPart)
83
+ return newCxxPart
84
+ }
85
+ }
86
+
87
+
88
+
89
+ /**
90
+ * Get the memory size of the Swift class (plus size of any other allocations)
91
+ * so the JS VM can properly track it and garbage-collect the JS object if needed.
92
+ */
93
+ @inline(__always)
94
+ public var memorySize: Int {
95
+ return MemoryHelper.getSizeOf(self.__implementation) + self.__implementation.memorySize
96
+ }
97
+
98
+ /**
99
+ * Compares this object with the given [other] object for reference equality.
100
+ */
101
+ @inline(__always)
102
+ public func equals(other: HybridCesiumViewSpec_cxx) -> Bool {
103
+ return self.__implementation === other.__implementation
104
+ }
105
+
106
+ /**
107
+ * Call dispose() on the Swift class.
108
+ * This _may_ be called manually from JS.
109
+ */
110
+ @inline(__always)
111
+ public func dispose() {
112
+ self.__implementation.dispose()
113
+ }
114
+
115
+ /**
116
+ * Call toString() on the Swift class.
117
+ */
118
+ @inline(__always)
119
+ public func toString() -> String {
120
+ return self.__implementation.toString()
121
+ }
122
+
123
+ // Properties
124
+ public final var ionAccessToken: std.string {
125
+ @inline(__always)
126
+ get {
127
+ return std.string(self.__implementation.ionAccessToken)
128
+ }
129
+ @inline(__always)
130
+ set {
131
+ self.__implementation.ionAccessToken = String(newValue)
132
+ }
133
+ }
134
+
135
+ public final var ionAssetId: Double {
136
+ @inline(__always)
137
+ get {
138
+ return self.__implementation.ionAssetId
139
+ }
140
+ @inline(__always)
141
+ set {
142
+ self.__implementation.ionAssetId = newValue
143
+ }
144
+ }
145
+
146
+ public final var initialCamera: CameraState {
147
+ @inline(__always)
148
+ get {
149
+ return self.__implementation.initialCamera
150
+ }
151
+ @inline(__always)
152
+ set {
153
+ self.__implementation.initialCamera = newValue
154
+ }
155
+ }
156
+
157
+ public final var pauseRendering: Bool {
158
+ @inline(__always)
159
+ get {
160
+ return self.__implementation.pauseRendering
161
+ }
162
+ @inline(__always)
163
+ set {
164
+ self.__implementation.pauseRendering = newValue
165
+ }
166
+ }
167
+
168
+ public final var maximumScreenSpaceError: Double {
169
+ @inline(__always)
170
+ get {
171
+ return self.__implementation.maximumScreenSpaceError
172
+ }
173
+ @inline(__always)
174
+ set {
175
+ self.__implementation.maximumScreenSpaceError = newValue
176
+ }
177
+ }
178
+
179
+ public final var maximumSimultaneousTileLoads: Double {
180
+ @inline(__always)
181
+ get {
182
+ return self.__implementation.maximumSimultaneousTileLoads
183
+ }
184
+ @inline(__always)
185
+ set {
186
+ self.__implementation.maximumSimultaneousTileLoads = newValue
187
+ }
188
+ }
189
+
190
+ public final var loadingDescendantLimit: Double {
191
+ @inline(__always)
192
+ get {
193
+ return self.__implementation.loadingDescendantLimit
194
+ }
195
+ @inline(__always)
196
+ set {
197
+ self.__implementation.loadingDescendantLimit = newValue
198
+ }
199
+ }
200
+
201
+ public final var msaaSampleCount: Double {
202
+ @inline(__always)
203
+ get {
204
+ return self.__implementation.msaaSampleCount
205
+ }
206
+ @inline(__always)
207
+ set {
208
+ self.__implementation.msaaSampleCount = newValue
209
+ }
210
+ }
211
+
212
+ public final var ionImageryAssetId: Double {
213
+ @inline(__always)
214
+ get {
215
+ return self.__implementation.ionImageryAssetId
216
+ }
217
+ @inline(__always)
218
+ set {
219
+ self.__implementation.ionImageryAssetId = newValue
220
+ }
221
+ }
222
+
223
+ public final var onMetrics: bridge.std__optional_std__function_void_const_CesiumMetrics_____metrics______ {
224
+ @inline(__always)
225
+ get {
226
+ return { () -> bridge.std__optional_std__function_void_const_CesiumMetrics_____metrics______ in
227
+ if let __unwrappedValue = self.__implementation.onMetrics {
228
+ return bridge.create_std__optional_std__function_void_const_CesiumMetrics_____metrics______({ () -> bridge.Func_void_CesiumMetrics in
229
+ let __closureWrapper = Func_void_CesiumMetrics(__unwrappedValue)
230
+ return bridge.create_Func_void_CesiumMetrics(__closureWrapper.toUnsafe())
231
+ }())
232
+ } else {
233
+ return .init()
234
+ }
235
+ }()
236
+ }
237
+ @inline(__always)
238
+ set {
239
+ self.__implementation.onMetrics = { () -> ((_ metrics: CesiumMetrics) -> Void)? in
240
+ if bridge.has_value_std__optional_std__function_void_const_CesiumMetrics_____metrics______(newValue) {
241
+ let __unwrapped = bridge.get_std__optional_std__function_void_const_CesiumMetrics_____metrics______(newValue)
242
+ return { () -> (CesiumMetrics) -> Void in
243
+ let __wrappedFunction = bridge.wrap_Func_void_CesiumMetrics(__unwrapped)
244
+ return { (__metrics: CesiumMetrics) -> Void in
245
+ __wrappedFunction.call(__metrics)
246
+ }
247
+ }()
248
+ } else {
249
+ return nil
250
+ }
251
+ }()
252
+ }
253
+ }
254
+
255
+ // Methods
256
+ @inline(__always)
257
+ public final func getCameraState() -> bridge.Result_std__shared_ptr_Promise_CameraState___ {
258
+ do {
259
+ let __result = try self.__implementation.getCameraState()
260
+ let __resultCpp = { () -> bridge.std__shared_ptr_Promise_CameraState__ in
261
+ let __promise = bridge.create_std__shared_ptr_Promise_CameraState__()
262
+ let __promiseHolder = bridge.wrap_std__shared_ptr_Promise_CameraState__(__promise)
263
+ __result
264
+ .then({ __result in __promiseHolder.resolve(__result) })
265
+ .catch({ __error in __promiseHolder.reject(__error.toCpp()) })
266
+ return __promise
267
+ }()
268
+ return bridge.create_Result_std__shared_ptr_Promise_CameraState___(__resultCpp)
269
+ } catch (let __error) {
270
+ let __exceptionPtr = __error.toCpp()
271
+ return bridge.create_Result_std__shared_ptr_Promise_CameraState___(__exceptionPtr)
272
+ }
273
+ }
274
+
275
+ @inline(__always)
276
+ public final func setCamera(camera: CameraState) -> bridge.Result_void_ {
277
+ do {
278
+ try self.__implementation.setCamera(camera: camera)
279
+ return bridge.create_Result_void_()
280
+ } catch (let __error) {
281
+ let __exceptionPtr = __error.toCpp()
282
+ return bridge.create_Result_void_(__exceptionPtr)
283
+ }
284
+ }
285
+
286
+ public final func getView() -> UnsafeMutableRawPointer {
287
+ return Unmanaged.passRetained(__implementation.view).toOpaque()
288
+ }
289
+
290
+ public final func beforeUpdate() {
291
+ __implementation.beforeUpdate()
292
+ }
293
+
294
+ public final func afterUpdate() {
295
+ __implementation.afterUpdate()
296
+ }
297
+
298
+ public final func maybePrepareForRecycle() {
299
+ guard let recyclable = __implementation as? any RecyclableView else { return }
300
+ recyclable.prepareForRecycle()
301
+ }
302
+
303
+ public final func onDropView() {
304
+ __implementation.onDropView()
305
+ }
306
+ }
@@ -0,0 +1,107 @@
1
+ ///
2
+ /// CameraState.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+
34
+
35
+ namespace margelo::nitro::reactnativecesium {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (CameraState).
39
+ */
40
+ struct CameraState final {
41
+ public:
42
+ double latitude SWIFT_PRIVATE;
43
+ double longitude SWIFT_PRIVATE;
44
+ double altitude SWIFT_PRIVATE;
45
+ double heading SWIFT_PRIVATE;
46
+ double pitch SWIFT_PRIVATE;
47
+ double roll SWIFT_PRIVATE;
48
+ double verticalFovDeg SWIFT_PRIVATE;
49
+
50
+ public:
51
+ CameraState() = default;
52
+ explicit CameraState(double latitude, double longitude, double altitude, double heading, double pitch, double roll, double verticalFovDeg): latitude(latitude), longitude(longitude), altitude(altitude), heading(heading), pitch(pitch), roll(roll), verticalFovDeg(verticalFovDeg) {}
53
+
54
+ public:
55
+ friend bool operator==(const CameraState& lhs, const CameraState& rhs) = default;
56
+ };
57
+
58
+ } // namespace margelo::nitro::reactnativecesium
59
+
60
+ namespace margelo::nitro {
61
+
62
+ // C++ CameraState <> JS CameraState (object)
63
+ template <>
64
+ struct JSIConverter<margelo::nitro::reactnativecesium::CameraState> final {
65
+ static inline margelo::nitro::reactnativecesium::CameraState fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
66
+ jsi::Object obj = arg.asObject(runtime);
67
+ return margelo::nitro::reactnativecesium::CameraState(
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude"))),
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading"))),
72
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch"))),
73
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "roll"))),
74
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "verticalFovDeg")))
75
+ );
76
+ }
77
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativecesium::CameraState& arg) {
78
+ jsi::Object obj(runtime);
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "latitude"), JSIConverter<double>::toJSI(runtime, arg.latitude));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "longitude"), JSIConverter<double>::toJSI(runtime, arg.longitude));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "altitude"), JSIConverter<double>::toJSI(runtime, arg.altitude));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "heading"), JSIConverter<double>::toJSI(runtime, arg.heading));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "pitch"), JSIConverter<double>::toJSI(runtime, arg.pitch));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "roll"), JSIConverter<double>::toJSI(runtime, arg.roll));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "verticalFovDeg"), JSIConverter<double>::toJSI(runtime, arg.verticalFovDeg));
86
+ return obj;
87
+ }
88
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
89
+ if (!value.isObject()) {
90
+ return false;
91
+ }
92
+ jsi::Object obj = value.getObject(runtime);
93
+ if (!nitro::isPlainObject(runtime, obj)) {
94
+ return false;
95
+ }
96
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latitude")))) return false;
97
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "longitude")))) return false;
98
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "altitude")))) return false;
99
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "heading")))) return false;
100
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pitch")))) return false;
101
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "roll")))) return false;
102
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "verticalFovDeg")))) return false;
103
+ return true;
104
+ }
105
+ };
106
+
107
+ } // namespace margelo::nitro
@@ -0,0 +1,107 @@
1
+ ///
2
+ /// CesiumMetrics.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
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+
32
+
33
+ #include <string>
34
+
35
+ namespace margelo::nitro::reactnativecesium {
36
+
37
+ /**
38
+ * A struct which can be represented as a JavaScript object (CesiumMetrics).
39
+ */
40
+ struct CesiumMetrics final {
41
+ public:
42
+ double fps SWIFT_PRIVATE;
43
+ double tilesRendered SWIFT_PRIVATE;
44
+ double tilesLoading SWIFT_PRIVATE;
45
+ double tilesVisited SWIFT_PRIVATE;
46
+ bool ionTokenConfigured SWIFT_PRIVATE;
47
+ bool tilesetReady SWIFT_PRIVATE;
48
+ std::string creditsPlainText SWIFT_PRIVATE;
49
+
50
+ public:
51
+ CesiumMetrics() = default;
52
+ explicit CesiumMetrics(double fps, double tilesRendered, double tilesLoading, double tilesVisited, bool ionTokenConfigured, bool tilesetReady, std::string creditsPlainText): fps(fps), tilesRendered(tilesRendered), tilesLoading(tilesLoading), tilesVisited(tilesVisited), ionTokenConfigured(ionTokenConfigured), tilesetReady(tilesetReady), creditsPlainText(creditsPlainText) {}
53
+
54
+ public:
55
+ friend bool operator==(const CesiumMetrics& lhs, const CesiumMetrics& rhs) = default;
56
+ };
57
+
58
+ } // namespace margelo::nitro::reactnativecesium
59
+
60
+ namespace margelo::nitro {
61
+
62
+ // C++ CesiumMetrics <> JS CesiumMetrics (object)
63
+ template <>
64
+ struct JSIConverter<margelo::nitro::reactnativecesium::CesiumMetrics> final {
65
+ static inline margelo::nitro::reactnativecesium::CesiumMetrics fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
66
+ jsi::Object obj = arg.asObject(runtime);
67
+ return margelo::nitro::reactnativecesium::CesiumMetrics(
68
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fps"))),
69
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesRendered"))),
70
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesLoading"))),
71
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesVisited"))),
72
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ionTokenConfigured"))),
73
+ JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesetReady"))),
74
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "creditsPlainText")))
75
+ );
76
+ }
77
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::reactnativecesium::CesiumMetrics& arg) {
78
+ jsi::Object obj(runtime);
79
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "fps"), JSIConverter<double>::toJSI(runtime, arg.fps));
80
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tilesRendered"), JSIConverter<double>::toJSI(runtime, arg.tilesRendered));
81
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tilesLoading"), JSIConverter<double>::toJSI(runtime, arg.tilesLoading));
82
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tilesVisited"), JSIConverter<double>::toJSI(runtime, arg.tilesVisited));
83
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "ionTokenConfigured"), JSIConverter<bool>::toJSI(runtime, arg.ionTokenConfigured));
84
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "tilesetReady"), JSIConverter<bool>::toJSI(runtime, arg.tilesetReady));
85
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "creditsPlainText"), JSIConverter<std::string>::toJSI(runtime, arg.creditsPlainText));
86
+ return obj;
87
+ }
88
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
89
+ if (!value.isObject()) {
90
+ return false;
91
+ }
92
+ jsi::Object obj = value.getObject(runtime);
93
+ if (!nitro::isPlainObject(runtime, obj)) {
94
+ return false;
95
+ }
96
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fps")))) return false;
97
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesRendered")))) return false;
98
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesLoading")))) return false;
99
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesVisited")))) return false;
100
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ionTokenConfigured")))) return false;
101
+ if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tilesetReady")))) return false;
102
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "creditsPlainText")))) return false;
103
+ return true;
104
+ }
105
+ };
106
+
107
+ } // namespace margelo::nitro
@@ -0,0 +1,42 @@
1
+ ///
2
+ /// HybridCesiumViewSpec.cpp
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
+ #include "HybridCesiumViewSpec.hpp"
9
+
10
+ namespace margelo::nitro::reactnativecesium {
11
+
12
+ void HybridCesiumViewSpec::loadHybridMethods() {
13
+ // load base methods/properties
14
+ HybridObject::loadHybridMethods();
15
+ // load custom methods/properties
16
+ registerHybrids(this, [](Prototype& prototype) {
17
+ prototype.registerHybridGetter("ionAccessToken", &HybridCesiumViewSpec::getIonAccessToken);
18
+ prototype.registerHybridSetter("ionAccessToken", &HybridCesiumViewSpec::setIonAccessToken);
19
+ prototype.registerHybridGetter("ionAssetId", &HybridCesiumViewSpec::getIonAssetId);
20
+ prototype.registerHybridSetter("ionAssetId", &HybridCesiumViewSpec::setIonAssetId);
21
+ prototype.registerHybridGetter("initialCamera", &HybridCesiumViewSpec::getInitialCamera);
22
+ prototype.registerHybridSetter("initialCamera", &HybridCesiumViewSpec::setInitialCamera);
23
+ prototype.registerHybridGetter("pauseRendering", &HybridCesiumViewSpec::getPauseRendering);
24
+ prototype.registerHybridSetter("pauseRendering", &HybridCesiumViewSpec::setPauseRendering);
25
+ prototype.registerHybridGetter("maximumScreenSpaceError", &HybridCesiumViewSpec::getMaximumScreenSpaceError);
26
+ prototype.registerHybridSetter("maximumScreenSpaceError", &HybridCesiumViewSpec::setMaximumScreenSpaceError);
27
+ prototype.registerHybridGetter("maximumSimultaneousTileLoads", &HybridCesiumViewSpec::getMaximumSimultaneousTileLoads);
28
+ prototype.registerHybridSetter("maximumSimultaneousTileLoads", &HybridCesiumViewSpec::setMaximumSimultaneousTileLoads);
29
+ prototype.registerHybridGetter("loadingDescendantLimit", &HybridCesiumViewSpec::getLoadingDescendantLimit);
30
+ prototype.registerHybridSetter("loadingDescendantLimit", &HybridCesiumViewSpec::setLoadingDescendantLimit);
31
+ prototype.registerHybridGetter("msaaSampleCount", &HybridCesiumViewSpec::getMsaaSampleCount);
32
+ prototype.registerHybridSetter("msaaSampleCount", &HybridCesiumViewSpec::setMsaaSampleCount);
33
+ prototype.registerHybridGetter("ionImageryAssetId", &HybridCesiumViewSpec::getIonImageryAssetId);
34
+ prototype.registerHybridSetter("ionImageryAssetId", &HybridCesiumViewSpec::setIonImageryAssetId);
35
+ prototype.registerHybridGetter("onMetrics", &HybridCesiumViewSpec::getOnMetrics);
36
+ prototype.registerHybridSetter("onMetrics", &HybridCesiumViewSpec::setOnMetrics);
37
+ prototype.registerHybridMethod("getCameraState", &HybridCesiumViewSpec::getCameraState);
38
+ prototype.registerHybridMethod("setCamera", &HybridCesiumViewSpec::setCamera);
39
+ });
40
+ }
41
+
42
+ } // namespace margelo::nitro::reactnativecesium
@@ -0,0 +1,90 @@
1
+ ///
2
+ /// HybridCesiumViewSpec.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
+ #if __has_include(<NitroModules/HybridObject.hpp>)
11
+ #include <NitroModules/HybridObject.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+
16
+ // Forward declaration of `CameraState` to properly resolve imports.
17
+ namespace margelo::nitro::reactnativecesium { struct CameraState; }
18
+ // Forward declaration of `CesiumMetrics` to properly resolve imports.
19
+ namespace margelo::nitro::reactnativecesium { struct CesiumMetrics; }
20
+
21
+ #include <string>
22
+ #include "CameraState.hpp"
23
+ #include "CesiumMetrics.hpp"
24
+ #include <functional>
25
+ #include <optional>
26
+ #include <NitroModules/Promise.hpp>
27
+
28
+ namespace margelo::nitro::reactnativecesium {
29
+
30
+ using namespace margelo::nitro;
31
+
32
+ /**
33
+ * An abstract base class for `CesiumView`
34
+ * Inherit this class to create instances of `HybridCesiumViewSpec` in C++.
35
+ * You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
36
+ * @example
37
+ * ```cpp
38
+ * class HybridCesiumView: public HybridCesiumViewSpec {
39
+ * public:
40
+ * HybridCesiumView(...): HybridObject(TAG) { ... }
41
+ * // ...
42
+ * };
43
+ * ```
44
+ */
45
+ class HybridCesiumViewSpec: public virtual HybridObject {
46
+ public:
47
+ // Constructor
48
+ explicit HybridCesiumViewSpec(): HybridObject(TAG) { }
49
+
50
+ // Destructor
51
+ ~HybridCesiumViewSpec() override = default;
52
+
53
+ public:
54
+ // Properties
55
+ virtual std::string getIonAccessToken() = 0;
56
+ virtual void setIonAccessToken(const std::string& ionAccessToken) = 0;
57
+ virtual double getIonAssetId() = 0;
58
+ virtual void setIonAssetId(double ionAssetId) = 0;
59
+ virtual CameraState getInitialCamera() = 0;
60
+ virtual void setInitialCamera(const CameraState& initialCamera) = 0;
61
+ virtual bool getPauseRendering() = 0;
62
+ virtual void setPauseRendering(bool pauseRendering) = 0;
63
+ virtual double getMaximumScreenSpaceError() = 0;
64
+ virtual void setMaximumScreenSpaceError(double maximumScreenSpaceError) = 0;
65
+ virtual double getMaximumSimultaneousTileLoads() = 0;
66
+ virtual void setMaximumSimultaneousTileLoads(double maximumSimultaneousTileLoads) = 0;
67
+ virtual double getLoadingDescendantLimit() = 0;
68
+ virtual void setLoadingDescendantLimit(double loadingDescendantLimit) = 0;
69
+ virtual double getMsaaSampleCount() = 0;
70
+ virtual void setMsaaSampleCount(double msaaSampleCount) = 0;
71
+ virtual double getIonImageryAssetId() = 0;
72
+ virtual void setIonImageryAssetId(double ionImageryAssetId) = 0;
73
+ virtual std::optional<std::function<void(const CesiumMetrics& /* metrics */)>> getOnMetrics() = 0;
74
+ virtual void setOnMetrics(const std::optional<std::function<void(const CesiumMetrics& /* metrics */)>>& onMetrics) = 0;
75
+
76
+ public:
77
+ // Methods
78
+ virtual std::shared_ptr<Promise<CameraState>> getCameraState() = 0;
79
+ virtual void setCamera(const CameraState& camera) = 0;
80
+
81
+ protected:
82
+ // Hybrid Setup
83
+ void loadHybridMethods() override;
84
+
85
+ protected:
86
+ // Tag for logging
87
+ static constexpr auto TAG = "CesiumView";
88
+ };
89
+
90
+ } // namespace margelo::nitro::reactnativecesium