Start Navara's camera model from a placed pose only

Navara's camera sits at the Earth's centre until it is first placed. The
model took that as the pose, so camera.height() threw while a layer
attached to a starting Navara (wildlife sightings asks for it), and
switching to Navara with that layer on rolled back to Cesium.
This commit is contained in:
German Khokhlov committed 2026-11-09 13:03:13 +04:00
1 parent b4556f9763
commit 68845a4977
2 files changed
+23 -2

No files matched your search

+8 -2
View File
@@ -101,7 +101,13 @@ export function createCameraModel({
};
// A camera command takes the camera from whoever held it; say so first.
const announce = () => events.commanded.raiseEvent();
const initial = port.read();
// Navara's camera sits at the Earth's centre until it is first placed: no
// pose yet (Cesium's camera always has one).
const read = () => {
const pose = port.read();
return pose && cartesian3.magnitude(pose.position) > 1 ? pose : null;
};
const initial = read();
let state = initial
? copyPose(initial)
: (() => {
@@ -216,7 +222,7 @@ export function createCameraModel({
/** Reads Navara's drawn camera; called once per frame before preRender. */
function sync() {
const seen = port.read();
const seen = read();
if (!seen) return;
const moved = !lastSeen || !posesNear(seen, lastSeen, 1e-6, 1e-10);
lastSeen = copyPose(seen);