Orbit, move, look and zoom through the camera port

The Cesium camera port gains move, look, rotateAround and zoom, and the
browser conformance run now checks them, the lookAt-frame commands, the
changed thresholds and moveEnd (timed by the clock, not a frame count).
Orbit, the Bhote Koshi focus and cinematic, the launch zoom anchor and
replay chase, the camera verbs' motion tick and roll levelling, and
voice zoom write through the port.
This commit is contained in:
Sameh Khamis committed 2026-11-06 10:21:04 -08:00
1 parent c722593791
commit 21d23034ec
19 files changed
+174 -112

No files matched your search

-4
View File
@@ -339,12 +339,8 @@ const EXPECTED_MISSING = [
'camera.followOffset.get',
'camera.followOffset.set',
'camera.followed',
'camera.look',
'camera.matrices',
'camera.move',
'camera.rotateAround',
'camera.setFov',
'camera.zoom',
'draw.atlas',
'draw.clampState',
'draw.on',
+37
View File
@@ -26,6 +26,25 @@ export const EASINGS = Object.freeze({
sineInOut: Cesium.EasingFunction.SINUSOIDAL_IN_OUT,
});
/**
* The contract's moves and looks as Cesium camera method names, called by
* name: a caller's camera may come from another copy of Cesium.
*/
const MOVES = Object.freeze({
forward: 'moveForward',
back: 'moveBackward',
left: 'moveLeft',
right: 'moveRight',
up: 'moveUp',
down: 'moveDown',
});
const LOOKS = Object.freeze({
left: 'lookLeft',
right: 'lookRight',
up: 'lookUp',
down: 'lookDown',
});
/** A contract destination as Cesium's: a Cartesian3, or a Rectangle. */
export function toDestination(d) {
if ('rect' in d) {
@@ -221,6 +240,24 @@ export function createCesiumCamera({ scene, camera, report }) {
camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
scene.requestRender();
},
move(direction, metres) {
camera[MOVES[direction]](metres);
scene.requestRender();
},
look(direction, radians) {
camera[LOOKS[direction]](radians);
scene.requestRender();
},
rotateAround(axis, radians) {
camera.rotate(toCartesian(axis), radians);
scene.requestRender();
},
zoom(metres) {
// Cesium's zoom, not a move: outside 3D it changes the view's width.
if (metres < 0) camera.zoomOut(-metres);
else camera.zoomIn(metres);
scene.requestRender();
},
viewRectangle() {
const rect = camera.computeViewRectangle(Cesium.Ellipsoid.WGS84);
if (!rect) return null;
+1 -1
View File
@@ -25,7 +25,7 @@ const QUERY_RECORDS = new Set([
'occluded',
]);
/** Commands and records the port does not have yet. */
const MISSING = new Set(['move', 'look', 'rotateAround', 'zoom', 'matrices']);
const MISSING = new Set(['matrices']);
const runnable = CAMERA_SCRIPTS.filter((script) =>
script.steps.every(
+4
View File
@@ -19,6 +19,10 @@ export const CESIUM_CHECKS = new Set([
'camera.trace.setView angles',
'camera.trace.setView keeps the position when only orientation is given',
'camera.trace.lookAt sweep and release',
'camera.trace.move, look, rotate and zoom',
'camera.trace.commands inside a lookAt frame',
'camera.trace.changed fires by each listener’s threshold',
'camera.moveEnd',
'camera.trace.flyTo with a duration of 0 completes inside the call',
'camera.trace.flyTo where the camera already is completes inside the call',
'camera.viewRectangle',
-1
View File
@@ -208,7 +208,6 @@
"src/maps/google3d.js",
"src/maps/imagery.js",
"src/maps/terrain.js",
"src/orbit.js",
"src/overlays/worldOverlay.js",
"src/queries/heights.js",
"src/sceneCommandRelease.js",
+15 -5
View File
@@ -316,20 +316,30 @@ export function cameraChecks() {
r.camera.on('moveStart', () => events.push(['start', h.now(r)]));
r.camera.on('moveEnd', () => events.push(['end', h.now(r)]));
await h.frame(r);
const movingAt = h.now(r);
r.camera.move('forward', 1000);
await h.frame(r);
equal(events[0]?.[0], 'start', 'moveStart after the move');
const movedAt = h.now(r);
for (let i = 0; i < 45; i++) await h.frame(r);
// By the clock, not a frame count: a page's frames come at the
// display's rate.
// The event comes on the first frame past 500 ms, so the slack is
// two of the longest frames seen, never less than two at 60 Hz.
let longestFrame = 1000 / 60;
for (let i = 0; i < 600 && h.now(r) - movedAt < 750; i++) {
const before = h.now(r);
await h.frame(r);
longestFrame = Math.max(longestFrame, h.now(r) - before);
}
const end = events.find(([kind]) => kind === 'end');
ok(end, 'moveEnd fired');
ok(
end[1] - movedAt >= 500 - 1e-6,
`moveEnd waited 500 ms (${end[1] - movedAt})`,
end[1] - movingAt >= 500 - 1e-6,
`moveEnd waited 500 ms (${end[1] - movingAt})`,
);
ok(
end[1] - movedAt < 500 + 2 * (1000 / 60) + 1e-6,
'moveEnd came within two frames of 500 ms',
end[1] - movedAt < 500 + 2 * longestFrame + 1e-6,
`moveEnd came within two frames of 500 ms (${end[1] - movedAt})`,
);
r.destroy();
},