test(camera): compare recorded camera traces within platform roundoff

The camera golden test compared the recorded traces byte for byte, so it
failed on arm64, where trigonometry differs from the committed traces in the
last bits (at most 2.1e-9 m on a height, 33 of 1,530 numbers). Compare
structure, keys, array lengths, counters and the viewport exactly, and other
numbers within 1e-8 m for positions and heights and 1e-14 otherwise; a
self-test rejects larger errors, NaN, null, strings and missing or extra
keys. The pose test compares pitch by its sine within 1e-12, as the
conformance suite does, and checks the canonical range. The golden file and
production camera code are unchanged.
This commit is contained in:
manjunath22466 committed 2026-11-16 19:47:06 +05:30
1 parent a8ac8eeb9b
commit 0a8899d439
2 files changed
+75 -9

No files matched your search

+10 -1
View File
@@ -416,7 +416,16 @@ test('a pose measures heading, pitch and roll as Cesium does, and leaves the cam
const pitch = camera.pitch;
const roll = camera.roll;
assert.equal(pose.heading, heading, `heading ${k}`);
assert.ok(Math.abs(pose.pitch - pitch) < 1e-12, `pitch ${k}`);
assert.ok(
pose.pitch >= -Math.PI / 2 && pose.pitch <= Math.PI / 2,
`canonical pitch ${k}`,
);
// Near vertical, acos amplifies last-bit direction differences. Match
// the conformance suite's well-conditioned pitch comparison.
assert.ok(
Math.abs(Math.sin(pose.pitch) - Math.sin(pitch)) < 1e-12,
`pitch ${k}`,
);
const turn = Math.abs(pose.roll - roll);
assert.ok(Math.min(turn, 2 * Math.PI - turn) < 1e-12, `roll ${k}`);
}