Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(zoom): expose the 3D rotation presets

Etienne Lescot9dae790939cf
diff --git a/src/components/ai-edition/v4/FloatingInspector.tsx b/src/components/ai-edition/v4/FloatingInspector.tsx
index ea017b7bd..cf2c3513b 100644
--- a/src/components/ai-edition/v4/FloatingInspector.tsx
+++ b/src/components/ai-edition/v4/FloatingInspector.tsx
@@ -420,6 +420,28 @@ function SelectionPane({ tl, onClose }: { tl: TimelineApi; onClose: () => void }
))}
</select>,
)}
+ {paneRow(
+ ts("zoom.threeD.title"),
+ <select
+ value={region.rotationPreset ?? "none"}
+ onChange={(e) =>
+ void tl.updateZoomRotation(
+ region.id,
+ // "none" is the absence of a preset, not a fourth preset — the schema field
+ // is optional and `migrate.ts` drops it when falsy.
+ e.target.value === "none"
+ ? undefined
+ : (e.target.value as "iso" | "left" | "right"),
+ )
+ }
+ style={selectStyle}
+ >
+ <option value="none">{ts("zoom.threeD.none")}</option>
+ <option value="iso">{ts("zoom.threeD.preset.iso")}</option>
+ <option value="left">{ts("zoom.threeD.preset.left")}</option>
+ <option value="right">{ts("zoom.threeD.preset.right")}</option>
+ </select>,
+ )}
{paneRow(
ts("zoom.focusMode.title"),
// While the global toggle is on it OVERRIDES every region, so the control shows
diff --git a/src/i18n/locales/ar/settings.json b/src/i18n/locales/ar/settings.json
index 7b27972b7..7b553beeb 100644
--- a/src/i18n/locales/ar/settings.json
+++ b/src/i18n/locales/ar/settings.json
@@ -24,7 +24,8 @@
"iso": "متساوي القياس",
"left": "يسار",
"right": "يمين"
- }
+ },
+ "none": "بلا"
}
},
"speed": {
diff --git a/src/i18n/locales/en/settings.json b/src/i18n/locales/en/settings.json
index 7b4cb6f7d..3d9b623f2 100644
--- a/src/i18n/locales/en/settings.json
+++ b/src/i18n/locales/en/settings.json
@@ -18,7 +18,8 @@
"iso": "Iso",
"left": "Left",
"right": "Right"
- }
+ },
+ "none": "None"
},
"position": {
"title": "Focus Position",
diff --git a/src/i18n/locales/es/settings.json b/src/i18n/locales/es/settings.json
index a2b106713..846d7071c 100644
--- a/src/i18n/locales/es/settings.json
+++ b/src/i18n/locales/es/settings.json
@@ -17,7 +17,8 @@
"iso": "Iso",
"left": "Izquierda",
"right": "Derecha"
- }
+ },
+ "none": "Ninguna"
},
"customScale": "Zoom personalizado",
"position": {
diff --git a/src/i18n/locales/fr/settings.json b/src/i18n/locales/fr/settings.json
index e9f3787c9..d3bcf5854 100644
--- a/src/i18n/locales/fr/settings.json
+++ b/src/i18n/locales/fr/settings.json
@@ -17,7 +17,8 @@
"iso": "Iso",
"left": "Gauche",
"right": "Droite"
- }
+ },
+ "none": "Aucune"
},
"customScale": "Zoom personnalisé",
"position": {
diff --git a/src/i18n/locales/it/settings.json b/src/i18n/locales/it/settings.json
index be3186af7..293d7f200 100644
--- a/src/i18n/locales/it/settings.json
+++ b/src/i18n/locales/it/settings.json
@@ -18,7 +18,8 @@
"iso": "Iso",
"left": "Sinistra",
"right": "Destra"
- }
+ },
+ "none": "Nessuna"
},
"position": {
"title": "Posizione messa a fuoco",
diff --git a/src/i18n/locales/ja-JP/settings.json b/src/i18n/locales/ja-JP/settings.json
index afb522733..d9de9bf14 100644
--- a/src/i18n/locales/ja-JP/settings.json
+++ b/src/i18n/locales/ja-JP/settings.json
@@ -17,7 +17,8 @@
"iso": "Iso",
"left": "左",
"right": "右"
- }
+ },
+ "none": "なし"
},
"customScale": "カスタムズーム",
"position": {
diff --git a/src/i18n/locales/ko-KR/settings.json b/src/i18n/locales/ko-KR/settings.json
index b7a31b412..123c1ed60 100644
--- a/src/i18n/locales/ko-KR/settings.json
+++ b/src/i18n/locales/ko-KR/settings.json
@@ -18,7 +18,8 @@
"iso": "Iso",
"left": "왼쪽",
"right": "오른쪽"
- }
+ },
+ "none": "없음"
},
"position": {
"title": "포커스 위치",
diff --git a/src/i18n/locales/pt-BR/settings.json b/src/i18n/locales/pt-BR/settings.json
index 94f986288..d5af323e8 100644
--- a/src/i18n/locales/pt-BR/settings.json
+++ b/src/i18n/locales/pt-BR/settings.json
@@ -18,7 +18,8 @@
"iso": "Iso",
"left": "Esquerda",
"right": "Direita"
- }
+ },
+ "none": "Nenhuma"
},
"position": {
"title": "Posição do Foco",
diff --git a/src/i18n/locales/ru/settings.json b/src/i18n/locales/ru/settings.json
index 43f564023..3b5b91361 100644
--- a/src/i18n/locales/ru/settings.json
+++ b/src/i18n/locales/ru/settings.json
@@ -17,7 +17,8 @@
"iso": "Изометрия",
"left": "Слева",
"right": "Справа"
- }
+ },
+ "none": "Нет"
},
"customScale": "Пользовательский масштаб",
"position": {
diff --git a/src/i18n/locales/tr/settings.json b/src/i18n/locales/tr/settings.json
index 119b99937..007fa8759 100644
--- a/src/i18n/locales/tr/settings.json
+++ b/src/i18n/locales/tr/settings.json
@@ -17,7 +17,8 @@
"iso": "Iso",
"left": "Sol",
"right": "Sağ"
- }
+ },
+ "none": "Yok"
},
"customScale": "Özel Yakınlaştırma",
"position": {
diff --git a/src/i18n/locales/vi/settings.json b/src/i18n/locales/vi/settings.json
index 05cfd0495..90bb6b988 100644
--- a/src/i18n/locales/vi/settings.json
+++ b/src/i18n/locales/vi/settings.json
@@ -24,7 +24,8 @@
"iso": "Đẳng phối",
"left": "Trái",
"right": "Phải"
- }
+ },
+ "none": "Không"
}
},
"speed": {
diff --git a/src/i18n/locales/zh-CN/settings.json b/src/i18n/locales/zh-CN/settings.json
index 70526105b..a8acb6380 100644
--- a/src/i18n/locales/zh-CN/settings.json
+++ b/src/i18n/locales/zh-CN/settings.json
@@ -17,7 +17,8 @@
"iso": "Iso",
"left": "左",
"right": "右"
- }
+ },
+ "none": "无"
},
"customScale": "自定义缩放",
"position": {
diff --git a/src/i18n/locales/zh-TW/settings.json b/src/i18n/locales/zh-TW/settings.json
index 053d9ed50..3a627499b 100644
--- a/src/i18n/locales/zh-TW/settings.json
+++ b/src/i18n/locales/zh-TW/settings.json
@@ -18,7 +18,8 @@
"iso": "Iso",
"left": "左",
"right": "右"
- }
+ },
+ "none": "無"
},
"customScale": "自訂縮放",
"position": {
diff --git a/src/lib/ai-edition/store/useTimeline.test.ts b/src/lib/ai-edition/store/useTimeline.test.ts
index b6388bdf3..afce4da3f 100644
--- a/src/lib/ai-edition/store/useTimeline.test.ts
+++ b/src/lib/ai-edition/store/useTimeline.test.ts
@@ -513,3 +513,79 @@ describe("useTimeline.addAnnotation", () => {
});
});
});
+
+describe("useTimeline zoom modifiers (rotation + focus mode)", () => {
+ const docWithZoom = {
+ ...sampleDoc,
+ zoomRanges: [
+ {
+ id: "zoom_a",
+ startMs: 1000,
+ endMs: 3000,
+ depth: 3,
+ focus: { cx: 0.5, cy: 0.5 },
+ focusMode: "manual" as const,
+ clipId: "clip_a",
+ clipStartOffsetMs: 1000,
+ },
+ ],
+ };
+
+ beforeEach(() => {
+ useProjectStore.getState().clear();
+ for (const mock of Object.values(bridgeMocks)) mock.mockReset();
+ bridgeMocks.save.mockImplementation(async (doc: typeof sampleDoc) => ({
+ success: true,
+ document: doc,
+ }));
+ useProjectStore.setState({
+ projectId: "proj_test",
+ document: docWithZoom,
+ revision: 1,
+ status: "ready",
+ error: null,
+ });
+ });
+
+ afterEach(() => {
+ vi.clearAllMocks();
+ });
+
+ it("sets a 3D rotation preset on the region", async () => {
+ const { result } = renderHook(() => useTimeline());
+ await act(async () => {
+ await result.current.updateZoomRotation("zoom_a", "iso");
+ });
+ expect(useProjectStore.getState().document?.zoomRanges[0]).toMatchObject({
+ id: "zoom_a",
+ rotationPreset: "iso",
+ });
+ });
+
+ it("clears the preset back to a flat frame", async () => {
+ // "None" in the UI is the ABSENCE of a preset, not a fourth one: the schema field is
+ // optional and the native side treats anything unrecognised as zero rotation.
+ const { result } = renderHook(() => useTimeline());
+ await act(async () => {
+ await result.current.updateZoomRotation("zoom_a", "iso");
+ });
+ await act(async () => {
+ await result.current.updateZoomRotation("zoom_a", undefined);
+ });
+ expect(useProjectStore.getState().document?.zoomRanges[0].rotationPreset).toBeUndefined();
+ });
+
+ it("switches focus mode without disturbing the rotation preset", async () => {
+ const { result } = renderHook(() => useTimeline());
+ await act(async () => {
+ await result.current.updateZoomRotation("zoom_a", "left");
+ });
+ await act(async () => {
+ await result.current.updateZoomFocusMode("zoom_a", "auto");
+ });
+ expect(useProjectStore.getState().document?.zoomRanges[0]).toMatchObject({
+ rotationPreset: "left",
+ focusMode: "auto",
+ });
+ });
+});
diff --git a/src/lib/ai-edition/store/useTimeline.ts b/src/lib/ai-edition/store/useTimeline.ts
index 907622606..b2f6ef06f 100644
--- a/src/lib/ai-edition/store/useTimeline.ts
+++ b/src/lib/ai-edition/store/useTimeline.ts
@@ -495,6 +495,25 @@ export function useTimeline() {
[document, saveDocument],
);
+ // Same story as `focusMode` below: the 3D tilt was implemented end to end — schema
+ // (`rotationPreset`), migration, `sceneDescription` (`rotation:`), `rotation3d_for` in
+ // regions.rs and the perspective shader in compositor.rs — with no control to set it.
+ // `undefined` clears the preset back to a flat frame; `migrate.ts` already drops the field
+ // when it is falsy, so absent and "no rotation" are the same state.
+ const updateZoomRotation = useCallback(
+ async (id: string, rotationPreset: "iso" | "left" | "right" | undefined) => {
+ if (!document) return;
+ const next: AxcutDocument = {
+ ...document,
+ zoomRanges: patchPillById(document.zoomRanges, id, {
+ rotationPreset,
+ }) as AxcutDocument["zoomRanges"],
+ };
+ await saveDocument(next);
+ },
+ [document, saveDocument],
+ );
+
// Nothing could set `focusMode`: "auto" only ever arrived from the automatic suggestion pass
// (`zoomSuggestions.ts`), so a hand-drawn zoom stayed pinned to its static focus point with no
// way to make it follow the cursor. The capability itself was complete end to end —
@@ -1161,6 +1180,7 @@ export function useTimeline() {
updateZoomFocusLive,
commitZoomFocus,
updateZoomDepth,
+ updateZoomRotation,
updateZoomFocusMode,
updateAnnotationSpan,
updateAnnotationLive,