feat(selection): selecting a contact keeps its size and the camera's view: aircraft, vessels, trains and transit vehicles keep their form and size when selected (colour only); a click follows from the camera's own distance and angle, the contact gliding to the centre over one second (FollowTarget transitionS, shared rule render/camera/followTransition, conformance camera.follow.transition)

This commit is contained in:
Sameh Khamis committed 2026-11-13 15:02:28 -08:00
1 parent e3865f462f
commit 7a61bf04a0
52 files changed
+1648 -891

No files matched your search

+29
View File
@@ -44,6 +44,10 @@ import {
zeroToTwoPi,
} from './math.js';
import { createCameraEvents } from '../camera/events.js';
import {
followTransitionEye,
followTransitionFraction,
} from '../camera/followTransition.js';
import { geodesicAt } from '../../geo/geodesic.js';
const DEFAULT_FOV = Math.PI / 3;
@@ -116,6 +120,8 @@ export function createStubCamera({
let flight = null;
let followed = null;
let followFramed = false;
/** A follow's transition under way: where the eye began, and when. */
let transition = null;
let coast = Object.freeze({ drag: 0.4, zoom: 0.2 });
const controls = {
@@ -666,6 +672,7 @@ export function createStubCamera({
const changed = followed !== target;
followed = target;
followFramed = false;
transition = null;
if (!target) setFrame(IDENTITY);
if (changed) emit('followChanged');
requestRender('follow');
@@ -689,6 +696,28 @@ export function createStubCamera({
);
if (range < minRange && range > 0)
offset = scale(offset, minRange / range);
if (followed.transitionS > 0 && range > 0) {
// The eye moves from where it is to the framing (`transitionS`).
setFrame(targetFrame);
transition ??= {
startMs: now(),
eye: { position, direction, up },
};
const s = followTransitionFraction(
now() - transition.startMs,
followed.transitionS * 1000,
);
if (s < 1) {
const eye = followTransitionEye(transition.eye, offset, s);
position = eye.position;
direction = eye.direction;
up = eye.up;
right = eye.right;
requestRender('follow');
return;
}
transition = null;
}
lookAtFrame(targetFrame, offset);
followFramed = true;
return;