react-native-cesium 1.0.3 → 1.0.5
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 +32 -10
- package/cpp/engine/GlobeCamera.cpp +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -302,15 +302,27 @@ type CameraState = {
|
|
|
302
302
|
}
|
|
303
303
|
```
|
|
304
304
|
|
|
305
|
-
| Field | Type | Valid range / format | Description
|
|
306
|
-
| --- | --- | ---
|
|
307
|
-
| `latitude` | `number` | `-90..90` | Camera latitude in degrees.
|
|
308
|
-
| `longitude` | `number` | `-180..180` | Camera longitude in degrees.
|
|
309
|
-
| `altitude` | `number` | Meters above ellipsoid | Camera height in meters.
|
|
310
|
-
| `heading` | `number` | Degrees | Compass direction the camera faces. Example: `0` faces north, `90` faces east.
|
|
311
|
-
| `pitch` | `number` | Degrees | Tilt angle. Negative values look downward toward terrain; positive values tilt up toward horizon/sky.
|
|
312
|
-
| `roll` | `number` | Degrees | Bank/rotation around forward axis. Positive right bank, negative left bank.
|
|
313
|
-
| `verticalFovDeg` | `number` | `20..100` (clamped) | Vertical field of view
|
|
305
|
+
| Field | Type | Valid range / format | Description |
|
|
306
|
+
| --- | --- | --- |-------------------------------------------------------------------------------------------------------|
|
|
307
|
+
| `latitude` | `number` | `-90..90` | Camera latitude in degrees. |
|
|
308
|
+
| `longitude` | `number` | `-180..180` | Camera longitude in degrees. |
|
|
309
|
+
| `altitude` | `number` | Meters above ellipsoid | Camera height in meters. |
|
|
310
|
+
| `heading` | `number` | Degrees | Compass direction the camera faces. Example: `0` faces north, `90` faces east. |
|
|
311
|
+
| `pitch` | `number` | Degrees | Tilt angle. Negative values look downward toward terrain; positive values tilt up toward horizon/sky. |
|
|
312
|
+
| `roll` | `number` | Degrees | Bank/rotation around forward axis. Positive right bank, negative left bank. |
|
|
313
|
+
| `verticalFovDeg` | `number` | `20..100` (clamped) | Vertical field of view in degrees; see **Field of view** (next section). |
|
|
314
|
+
|
|
315
|
+
### Field of view: vertical vs horizontal, full vs half, and Cesium alignment
|
|
316
|
+
|
|
317
|
+
Use this when matching **Skia**, **custom HUDs**, or **CesiumJS** math to the same frustum as this view.
|
|
318
|
+
|
|
319
|
+
| Concept | What this library uses |
|
|
320
|
+
| --- | --- |
|
|
321
|
+
| **API field** | `verticalFovDeg` is the **full** vertical aperture in **degrees** (top to bottom through the view axis), not a half-angle and not the horizontal FOV. |
|
|
322
|
+
| **Horizontal FOV** | Not stored. With viewport width `w` and height `h` in pixels and `aspect = w / h`, the native tile `ViewState` uses **full** vertical FOV `vfov_rad = radians(verticalFovDeg)` and **full** horizontal FOV `hfov_rad = 2 * atan(tan(vfov_rad / 2) * aspect)`. |
|
|
323
|
+
| **Half-angles** | The projection uses the usual symmetric perspective form: `tan(vfov_rad / 2)` (and the same pattern horizontally via aspect). Those are **half** of the full vertical/horizontal FOV, in radians—standard for `tan` of frustum slopes, not an alternate “FOV definition.” |
|
|
324
|
+
| **Cesium Native `ViewState`** | `GlobeCamera` passes that `vfov_rad` and `hfov_rad` into `Cesium3DTilesSelection::ViewState` together with the viewport size—consistent with **full-angle** vertical/horizontal FOV in radians for culling. |
|
|
325
|
+
| **CesiumJS `PerspectiveFrustum` / `Camera.frustum`** | **Comparable vertical angle:** In CesiumJS, `PerspectiveFrustum#fovy` is the **full vertical** FOV in **radians** (derived from `fov` and `aspectRatio`). This package’s `verticalFovDeg` is always **vertical** in **degrees**; use `vfov_rad = Cesium.Math.toRadians(verticalFovDeg)` (or equivalent) to compare to `fovy` when the **same aspect ratio** and symmetric frustum assumptions apply. This repo uses **Cesium Native**, not CesiumJS—tile culling uses `ViewState` with `vfov_rad` / `hfov_rad` as above, not the JS frustum object. |
|
|
314
326
|
|
|
315
327
|
### `Quaternion`
|
|
316
328
|
|
|
@@ -334,6 +346,15 @@ type Quaternion = {
|
|
|
334
346
|
| `getCameraState` | `() => Promise<CameraState>` | Returns the current native camera snapshot (lat/lon/alt, HPR, VFOV). This is the underlying globe attitude; it does **not** encode the view correction into HPR. |
|
|
335
347
|
| `getViewCorrection` | `() => Promise<Quaternion>` | Returns the **smoothed** view-correction quaternion currently applied (identity `w=1,x=y=z=0` if you have never called `setCameraQuaternion`). |
|
|
336
348
|
|
|
349
|
+
#### Threading: `setCamera` / `setCameraQuaternion` vs `getCameraState` / `getViewCorrection`
|
|
350
|
+
|
|
351
|
+
| Call style | Supported / best practice |
|
|
352
|
+
| --- | --- |
|
|
353
|
+
| **`setCamera` / `setCameraQuaternion`** | **Synchronous** native updates. **Supported** from the **UI thread**, including **Reanimated worklets** and **`useAnimatedReaction`** when you call through a Nitro `hybridRef` (same pattern as driving camera demand from shared values). This is the intended path for high-frequency camera updates. |
|
|
354
|
+
| **`getCameraState` / `getViewCorrection`** | **Async** (`Promise`). **Call from the JavaScript thread** (e.g. `useEffect`, handlers, throttled HUD state)—not from worklets—unless you have a clear, tested pattern for async in your runtime. |
|
|
355
|
+
|
|
356
|
+
Avoid assuming **main-thread-only** vs **JS-thread-only** labels beyond the above: Nitro invokes the hybrid object on the thread that called the method; use sync setters on the UI/worklet path you already use for gestures, and reserve Promise-based getters for JS.
|
|
357
|
+
|
|
337
358
|
#### `setCamera` vs `setCameraQuaternion`
|
|
338
359
|
|
|
339
360
|
- Use **`setCamera`** alone when you only need the classic globe camera.
|
|
@@ -358,7 +379,8 @@ type Quaternion = {
|
|
|
358
379
|
The example app in [`example/App.tsx`](./example/App.tsx) is the best current integration reference. It shows:
|
|
359
380
|
|
|
360
381
|
- creating and storing a Nitro `hybridRef`
|
|
361
|
-
- driving camera updates with `setCamera(...)`
|
|
382
|
+
- driving camera updates with `setCamera(...)` from a Reanimated **`useAnimatedReaction`** (UI-thread / worklet path; see **Threading** under `CesiumViewMethods` above)
|
|
383
|
+
- the `setCameraQuaternion` / `getViewCorrection` APIs for camera-space HUD alignment (the example does not demonstrate them yet; see **`CesiumViewMethods`** above)
|
|
362
384
|
- listening to `onMetrics`
|
|
363
385
|
- switching imagery layers
|
|
364
386
|
- presenting Cesium attribution from `creditsPlainText`
|
|
@@ -58,7 +58,8 @@ void GlobeCamera::recompute() const {
|
|
|
58
58
|
|
|
59
59
|
double hdgRad = glm::radians(params_.heading);
|
|
60
60
|
double pitchRad = glm::radians(params_.pitch);
|
|
61
|
-
|
|
61
|
+
// Aviation-style sign: positive roll = right wing down, negative = left wing down.
|
|
62
|
+
double rollRad = -glm::radians(params_.roll);
|
|
62
63
|
|
|
63
64
|
// 1. Heading: forward and right in the horizontal plane.
|
|
64
65
|
glm::dvec3 fwdH = north * std::cos(hdgRad) + east * std::sin(hdgRad);
|
package/package.json
CHANGED