fix: keep camera geometry aligned with trajectories
This commit is contained in:
@@ -62,10 +62,30 @@ export function shiftSceneDistance(scene, experiment, nextDistance) {
|
||||
const previousDistance = experiment.scan.z;
|
||||
const delta = nextDistance - previousDistance;
|
||||
experiment.scan.z = nextDistance;
|
||||
for (const source of scene.sources) source.position[2] += delta;
|
||||
for (const source of scene.sources) {
|
||||
source.position[2] += delta;
|
||||
for (const keyframe of source.trajectory ?? []) keyframe.position[2] += delta;
|
||||
}
|
||||
if (scene.image?.plane) scene.image.plane.z += delta;
|
||||
}
|
||||
|
||||
function sourceGeometryPositions(scene) {
|
||||
return (scene.sources ?? []).flatMap((source) => {
|
||||
const candidates = [source.position, ...(source.trajectory ?? []).map(({ position }) => position)];
|
||||
const uniquePositions = new Map();
|
||||
for (const position of candidates) {
|
||||
if (
|
||||
Array.isArray(position) &&
|
||||
position.length === 3 &&
|
||||
position.every(Number.isFinite)
|
||||
) {
|
||||
uniquePositions.set(position.join(","), position);
|
||||
}
|
||||
}
|
||||
return [...uniquePositions.values()];
|
||||
});
|
||||
}
|
||||
|
||||
export function alignExperimentToScene(experiment, scene) {
|
||||
const plane = scene.image?.plane;
|
||||
if (plane) {
|
||||
@@ -79,13 +99,7 @@ export function alignExperimentToScene(experiment, scene) {
|
||||
return "image-plane";
|
||||
}
|
||||
|
||||
const positions = (scene.sources ?? [])
|
||||
.map((source) => source.position)
|
||||
.filter((position) =>
|
||||
Array.isArray(position) &&
|
||||
position.length === 3 &&
|
||||
position.every(Number.isFinite),
|
||||
);
|
||||
const positions = sourceGeometryPositions(scene);
|
||||
if (positions.length === 0) return "unchanged";
|
||||
|
||||
const paddedBounds = (values) => {
|
||||
|
||||
Reference in New Issue
Block a user