♻️ refactor: refactor zoom focus handling in video editor settings and playback
This commit is contained in:
@@ -52,6 +52,7 @@ import type {
|
||||
PlaybackSpeed,
|
||||
WebcamLayoutPreset,
|
||||
ZoomDepth,
|
||||
ZoomFocusMode,
|
||||
} from "./types";
|
||||
import { SPEED_OPTIONS } from "./types";
|
||||
|
||||
@@ -92,8 +93,8 @@ interface SettingsPanelProps {
|
||||
onWallpaperChange: (path: string) => void;
|
||||
selectedZoomDepth?: ZoomDepth | null;
|
||||
onZoomDepthChange?: (depth: ZoomDepth) => void;
|
||||
selectedZoomFocusMode?: import("./types").ZoomFocusMode | null;
|
||||
onZoomFocusModeChange?: (mode: import("./types").ZoomFocusMode) => void;
|
||||
selectedZoomFocusMode?: ZoomFocusMode | null;
|
||||
onZoomFocusModeChange?: (mode: ZoomFocusMode) => void;
|
||||
hasCursorTelemetry?: boolean;
|
||||
selectedZoomId?: string | null;
|
||||
onZoomDelete?: (id: string) => void;
|
||||
|
||||
@@ -199,8 +199,21 @@ function getConnectedRegionTransition(
|
||||
const currentScale = ZOOM_DEPTH_SCALES[currentRegion.depth];
|
||||
const nextScale = ZOOM_DEPTH_SCALES[nextRegion.depth];
|
||||
const transitionScale = lerp(currentScale, nextScale, transitionProgress);
|
||||
const currentFocus = getResolvedFocus(currentRegion, currentScale, timeMs, cursorTelemetry);
|
||||
const nextFocus = getResolvedFocus(nextRegion, nextScale, timeMs, cursorTelemetry);
|
||||
// Both regions share the same timeMs, so interpolate cursor once and reuse.
|
||||
const sharedCursorFocus =
|
||||
cursorTelemetry && cursorTelemetry.length > 0
|
||||
? interpolateCursorAt(cursorTelemetry, timeMs)
|
||||
: null;
|
||||
const currentFocus = clampFocusToScale(
|
||||
currentRegion.focusMode === "auto" && sharedCursorFocus
|
||||
? sharedCursorFocus
|
||||
: currentRegion.focus,
|
||||
currentScale,
|
||||
);
|
||||
const nextFocus = clampFocusToScale(
|
||||
nextRegion.focusMode === "auto" && sharedCursorFocus ? sharedCursorFocus : nextRegion.focus,
|
||||
nextScale,
|
||||
);
|
||||
const transitionFocus = getLinearFocus(currentFocus, nextFocus, transitionProgress);
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user