Give the Cesium camera port its user camera controls

camera.controls now maps the contract's CameraControls onto the scene's
ScreenSpaceCameraController: the enable flags, zoom distances, zoom
factor, coast as Cesium inertia (decay seconds, 0 for no coast), the
collision switch, the tilt limit as the upper end of pitchRange, and the
zoom bindings by name. suspend and enabled use the scene's shared input
holds, so they count with the input port's and the dispatcher's.

A follow's zoom hold now composes with the settings: minDistance and
coast.zoom read and set what the follow gives back, a higher floor takes
effect at once, and a follow never lengthens a shorter zoom coast.

The ctrl+wheel binding check reuses the controls' binding helpers, and
the controls checks run in the Cesium conformance set, the settings one
in Node as well.
This commit is contained in:
Sameh Khamis committed 2026-11-06 17:26:03 -08:00
1 parent f0c5eaa868
commit 09a84ea8a5
13 files changed
+574 -36

No files matched your search

+7 -1
View File
@@ -2,13 +2,15 @@
* @module render/cesium/camera
* @description The Cesium renderer's camera port over a Cesium camera:
* poses, views, flights, `lookAt`, events and command hooks, each mapped
* onto Cesium's own camera call.
* onto Cesium's own camera call, and the user's camera controls
* (`cameraControls.js`) on the scene's camera controller.
*/
import * as Cesium from 'cesium';
import { createCameraEvents } from '../camera/events.js';
import { listenerList, toCartesian, uncaught } from './common.js';
import { cameraFlightActive } from './internals.js';
import { createCesiumFollow } from './follow.js';
import { createCesiumControls } from './cameraControls.js';
import { cameraOf, findCamera, provideUnboundCamera } from '../rendererOf.js';
// Loads the factory an unbound viewer gets its credits port from.
import './credits.js';
@@ -110,6 +112,8 @@ export function createCesiumCamera({ scene, camera, report, widget }) {
})
: null;
const controlsPart = createCesiumControls({ scene });
// Camera commands: hooks run before each one, so an owner can yield.
const commandHooks = listenerList(report);
const command = (kind) => commandHooks.fire({ kind });
@@ -287,6 +291,7 @@ export function createCesiumCamera({ scene, camera, report, widget }) {
return following?.followFramed ?? false;
},
followOffset: following?.followOffset ?? NO_FOLLOW_OFFSET,
controls: controlsPart.controls,
release() {
command('release');
camera.lookAtTransform(Cesium.Matrix4.IDENTITY);
@@ -375,6 +380,7 @@ export function createCesiumCamera({ scene, camera, report, widget }) {
port: cameraPort,
dispose() {
following?.dispose();
controlsPart.dispose();
for (const off of removers.splice(0)) off();
cameraEvents.clear();
commandHooks.clear();