Create professional demos and 3D mockups in seconds, directly in your browser
feat: add streamlined 3D camera controls
Efrain Chiri Ninaf2dd71f574e3
diff --git a/app/[locale]/(editor)/editor/page.tsx b/app/[locale]/(editor)/editor/page.tsxindex 5dbfba3..5133125 100644--- a/app/[locale]/(editor)/editor/page.tsx+++ b/app/[locale]/(editor)/editor/page.tsx@@ -31,7 +31,20 @@ import { DEFAULT_CAMERA_CONFIG } from "@/types/camera.types";import type { Preview3DConfig, ImageMaskConfig } from "@/types/photo.types";import { DEFAULT_MASK_CONFIG, PREVIEW_CONFIGS } from "@/types/photo.types";import { MOCKUPS } from "@/lib/mockup-data";-import { normalizeMockupCameraConfig } from "@/lib/viewer-controls3d";+import {+ createAutomaticMockupCameraTour,+ DEFAULT_MOCKUP_CAMERA_FOV,+ getAutomaticMockupCameraPreset,+ normalizeMockupCameraConfig,+} from "@/lib/viewer-controls3d";+import {+ sampleMockupCameraKeyframes,+} from "@/lib/viewer-controls3d";+import type {+ MockupCameraKeyframe,+ MockupCameraPose,+ MockupCameraPreset,+} from "@/lib/viewer-controls3d";import { gradientToCss, generateDefaultZoomFragments } from "@/types";import { ToolsSidebar } from "@/app/components/ui/editor/ToolsSidebar";import { MobileToolsMenu } from "@/app/components/ui/editor/MobileToolsMenu";@@ -87,6 +100,7 @@ export default function Editor() {imagePhoneShadow, setImagePhoneShadow,imagePhoneShadowColor, setImagePhoneShadowColor,imagePhoneRefWidth, setImagePhoneRefWidth,+ setCameraNavigationMode,} = useMockup3dContext();// Undo/Redo system - centralized state management@@ -255,6 +269,8 @@ export default function Editor() {// Mockup stateconst [mockupId, setMockupId] = useState<string>("none");const [mockupConfig, setMockupConfig] = useState<MockupConfig>(DEFAULT_MOCKUP_CONFIG);+ const [mockupCameraKeyframes, setMockupCameraKeyframes] = useState<MockupCameraKeyframe[]>([]);+ const [selectedMockupCameraKeyframeId, setSelectedMockupCameraKeyframeId] = useState<string | null>(null);// Whether the currently loaded source video file contains an audio streamconst [videoHasAudioTrack, setVideoHasAudioTrack] = useState<boolean>(true);@@ -345,6 +361,58 @@ export default function Editor() {setCameraConfig((prev) => (prev ? { ...prev, ...partial } : prev));}, []);+ const updateMockupCameraKeyframe = useCallback((id: string, updates: Partial<MockupCameraKeyframe>) => {+ setMockupCameraKeyframes((previous) => previous.map((keyframe) =>+ keyframe.id === id ? { ...keyframe, ...updates } : keyframe+ ));+ }, []);++ const upsertMockupCameraKeyframe = useCallback((pose: MockupCameraPose, time = currentTime) => {+ const existing = mockupCameraKeyframes.find((keyframe) => Math.abs(keyframe.time - time) <= 0.05);+ const keyframe: MockupCameraKeyframe = {+ id: existing?.id ?? `camera_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`,+ time,+ camera: normalizeMockupCameraConfig(pose.camera),+ rotationX: pose.rotationX,+ rotationY: pose.rotationY,+ };+ setMockupCameraKeyframes((previous) => [+ ...previous.filter((item) => item.id !== keyframe.id),+ keyframe,+ ].sort((a, b) => a.time - b.time));+ setSelectedMockupCameraKeyframeId(keyframe.id);+ return keyframe;+ }, [currentTime, mockupCameraKeyframes]);++ const handleAddOrUpdateMockupCameraKeyframe = useCallback((time = currentTime) => {+ const pose = sampleMockupCameraKeyframes(mockupCameraKeyframes, time, DEFAULT_MOCKUP_CAMERA_FOV[imagePhoneDevice])+ ?? { camera: mockupCamera, rotationX: imagePhoneRotX, rotationY: imagePhoneRotY };+ upsertMockupCameraKeyframe(pose, time);+ }, [mockupCameraKeyframes, currentTime, mockupCamera, imagePhoneRotX, imagePhoneRotY, imagePhoneDevice, upsertMockupCameraKeyframe]);++ const handleApplyMockupCameraPreset = useCallback((preset: MockupCameraPreset) => {+ setMockupCamera(preset.camera);+ setImagePhoneRotX(preset.rotationX);+ setImagePhoneRotY(preset.rotationY);+ if (!isPhotoMode) {+ upsertMockupCameraKeyframe(preset);+ }+ }, [isPhotoMode, setMockupCamera, setImagePhoneRotX, setImagePhoneRotY, upsertMockupCameraKeyframe]);++ const handleMockupCameraUpdate = useCallback((camera: typeof mockupCamera) => {+ setMockupCamera(camera);+ if (isPlaying) return;+ const selected = mockupCameraKeyframes.find((keyframe) =>+ keyframe.id === selectedMockupCameraKeyframeId && Math.abs(keyframe.time - currentTime) <= 0.05+ );+ if (selected) updateMockupCameraKeyframe(selected.id, { camera });+ }, [setMockupCamera, isPlaying, mockupCameraKeyframes, selectedMockupCameraKeyframeId, currentTime, updateMockupCameraKeyframe]);++ const handleDeleteMockupCameraKeyframe = useCallback((id: string) => {+ setMockupCameraKeyframes((previous) => previous.filter((keyframe) => keyframe.id !== id));+ setSelectedMockupCameraKeyframeId((previous) => previous === id ? null : previous);+ }, []);+const handleCameraClick = useCallback(() => {setActiveTool("camera");}, []);@@ -685,6 +753,7 @@ export default function Editor() {imagePhoneShadowColor,imagePhoneRefWidth,mockupCamera,+ mockupCameraKeyframes,mockupMotionFragments,videoClips,globalSpeed,@@ -702,7 +771,7 @@ export default function Editor() {imagePhoneActive, imagePhoneX, imagePhoneY, imagePhoneScale, imagePhoneRotX, imagePhoneRotY,imagePhoneRotZ, imagePhonePerspective, imagePhoneDevice, imagePhonePresetId, imagePhoneOpening,imagePhoneShadow, imagePhoneShadowColor, imagePhoneRefWidth, mockupMotionFragments,- mockupCamera,+ mockupCamera, mockupCameraKeyframes,setEditorState, videoClips, globalSpeed]);@@ -756,6 +825,8 @@ export default function Editor() {setImagePhoneShadowColor(editorState.imagePhoneShadowColor);setImagePhoneRefWidth(editorState.imagePhoneRefWidth ?? 0);setMockupCamera(normalizeMockupCameraConfig(editorState.mockupCamera));+ setMockupCameraKeyframes(editorState.mockupCameraKeyframes ?? []);+ setSelectedMockupCameraKeyframeId(null);setMockupMotionFragments(editorState.mockupMotionFragments ?? []);setGlobalSpeed(editorState.globalSpeed ?? 1);@@ -985,6 +1056,7 @@ export default function Editor() {mockupId,mockupConfig,mockupCamera,+ mockupCameraKeyframes,mockupMotionFragments,backgroundTab,selectedWallpaper,@@ -1013,7 +1085,7 @@ export default function Editor() {zoomFragments, zoomMovements,audioTracks, uploadedAudios, muteOriginalAudio, masterVolume,canvasElements,- mockupId, mockupConfig, mockupCamera,+ mockupId, mockupConfig, mockupCamera, mockupCameraKeyframes,mockupMotionFragments,backgroundTab, selectedWallpaper, backgroundBlur, selectedImageUrl,unsplashBgUrl, backgroundColorConfig,@@ -1776,6 +1848,8 @@ export default function Editor() {setMockupId(savedProject.mockupId);setMockupConfig(savedProject.mockupConfig);setMockupCamera(normalizeMockupCameraConfig(savedProject.mockupCamera));+ setMockupCameraKeyframes(savedProject.mockupCameraKeyframes ?? []);+ setSelectedMockupCameraKeyframeId(null);setCanvasElements(savedProject.canvasElements ?? []);setAudioTracks(savedProject.audioTracks ?? []);setMuteOriginalAudio(savedProject.muteOriginalAudio ?? false);@@ -2623,6 +2697,44 @@ export default function Editor() {}}, [isDraggingPlayhead, isPlaying, syncAudioPlayback, findActiveClipAtTime, timelineToClipTime, scheduleUpdateFrame]);+ const handleSelectMockupCameraKeyframe = useCallback((keyframe: MockupCameraKeyframe) => {+ setSelectedMockupCameraKeyframeId(keyframe.id);+ setMockupCamera(normalizeMockupCameraConfig(keyframe.camera));+ setImagePhoneRotX(keyframe.rotationX);+ setImagePhoneRotY(keyframe.rotationY);+ handleSeek(keyframe.time);+ }, [setMockupCamera, setImagePhoneRotX, setImagePhoneRotY, handleSeek]);++ const handleApplyAutomaticMockupCamera = useCallback(() => {+ if (isPhotoMode) {+ handleApplyMockupCameraPreset(getAutomaticMockupCameraPreset(imagePhoneDevice));+ setCameraNavigationMode("orbit");+ return;+ }++ const keyframes = createAutomaticMockupCameraTour(imagePhoneDevice, videoDuration, mockupCameraKeyframes);+ if (keyframes.length === 0) return;++ setCameraNavigationMode("orbit");+ setMockupCameraKeyframes((previous) => [...previous, ...keyframes].sort((a, b) => a.time - b.time));+ setSelectedMockupCameraKeyframeId(keyframes[0].id);+ setMockupCamera(keyframes[0].camera);+ setImagePhoneRotX(keyframes[0].rotationX);+ setImagePhoneRotY(keyframes[0].rotationY);+ handleSeek(keyframes[0].time);+ }, [+ isPhotoMode,+ imagePhoneDevice,+ videoDuration,+ mockupCameraKeyframes,+ handleApplyMockupCameraPreset,+ setCameraNavigationMode,+ setMockupCamera,+ setImagePhoneRotX,+ setImagePhoneRotY,+ handleSeek,+ ]);+const handleImageSelect = useCallback((url: string) => {if (backgroundTab === "wallpaper") setUnsplashBgUrl(url);else setSelectedImageUrl(url);@@ -2991,6 +3103,12 @@ export default function Editor() {onUpdateMockupMotionFragment={handleUpdateMockupMotionFragment}onSelectMockupMotionFragment={handleSelectMockupMotionFragment}onDeleteMockupMotionFragment={handleDeleteMockupMotionFragment}+ currentTime={currentTime}+ mockupCameraKeyframes={mockupCameraKeyframes}+ selectedMockupCameraKeyframeId={selectedMockupCameraKeyframeId}+ onApplyMockupCameraPreset={handleApplyMockupCameraPreset}+ onApplyAutomaticMockupCamera={handleApplyAutomaticMockupCamera}+ onUpdateMockupCameraKeyframe={handleMockupCameraUpdate}selectedAudioTrackId={selectedAudioTrackId}setSelectedAudioTrackId={handleSelectAudioTrack}/>@@ -3101,6 +3219,9 @@ export default function Editor() {onSelectZoomMovement={handleSelectZoomMovement}onUpdateZoomMovement={handleUpdateZoomMovement}videoClips={videoClips}+ mockupCameraKeyframes={mockupCameraKeyframes}+ selectedMockupCameraKeyframeId={selectedMockupCameraKeyframeId}+ onUpdateMockupCameraKeyframe={updateMockupCameraKeyframe}/>{/* Video mode: Show player controls and timeline */}@@ -3172,6 +3293,15 @@ export default function Editor() {isPlaying={isPlaying}onZoomChange={handleZoomChange}mockupMotionFragments={mockupMotionFragments}+ showCameraTrack={imagePhoneActive}+ mockupCameraKeyframes={mockupCameraKeyframes}+ selectedMockupCameraKeyframeId={selectedMockupCameraKeyframeId}+ onSelectMockupCameraKeyframe={handleSelectMockupCameraKeyframe}+ onDeleteMockupCameraKeyframe={handleDeleteMockupCameraKeyframe}+ onAddMockupCameraKeyframeAtTime={(time) => {+ handleAddOrUpdateMockupCameraKeyframe(time);+ handleSeek(time);+ }}selectedMockupMotionFragmentId={selectedMockupMotionFragmentId}onSelectMockupMotionFragment={handleSelectMockupMotionFragment}onUpdateMockupMotionFragment={handleUpdateMockupMotionFragment}diff --git a/app/components/ui/editor/ControlPanel.tsx b/app/components/ui/editor/ControlPanel.tsxindex 47651fa..f77c177 100644--- a/app/components/ui/editor/ControlPanel.tsx+++ b/app/components/ui/editor/ControlPanel.tsx@@ -135,6 +135,12 @@ export function ControlPanel({onUpdateMockupMotionFragment,onSelectMockupMotionFragment,onDeleteMockupMotionFragment,+ currentTime = 0,+ mockupCameraKeyframes = [],+ selectedMockupCameraKeyframeId = null,+ onApplyMockupCameraPreset,+ onApplyAutomaticMockupCamera,+ onUpdateMockupCameraKeyframe,}: ExtendedControlPanelProps) {const t = useTranslations("controlPanel");@@ -318,6 +324,13 @@ export function ControlPanel({backgroundColorCss={backgroundColorCss}initialPage={initialMockupMenuPage}mediaType={mediaType}+ currentTime={currentTime}+ mockupCameraKeyframes={mockupCameraKeyframes}+ selectedMockupCameraKeyframeId={selectedMockupCameraKeyframeId}+ onApplyCameraPreset={onApplyMockupCameraPreset}+ onApplyAutomaticCamera={onApplyAutomaticMockupCamera}+ onUpdateCameraKeyframe={onUpdateMockupCameraKeyframe}+ videoDuration={videoDuration}/></Suspense>)}diff --git a/app/components/ui/editor/LabelSidebar.tsx b/app/components/ui/editor/LabelSidebar.tsxindex 60685dd..6ea3a78 100644--- a/app/components/ui/editor/LabelSidebar.tsx+++ b/app/components/ui/editor/LabelSidebar.tsx@@ -1,6 +1,7 @@"use client";import { useTranslations } from 'next-intl';+import { Icon } from '@iconify/react';import { ELEMENT_ROW_HEIGHT } from '@/types/timeline.types';interface LabelSidebarProps {@@ -8,6 +9,7 @@ interface LabelSidebarProps {motionTracksCount?: number;elementLaneCount?: number;showMovementRow?: boolean;+ showCameraTrack?: boolean;}export default function LabelSidebar({@@ -15,6 +17,7 @@ export default function LabelSidebar({motionTracksCount = 0,elementLaneCount = 0,showMovementRow = false,+ showCameraTrack = false,}: LabelSidebarProps) {const t = useTranslations('labelSidebar');@@ -28,6 +31,18 @@ export default function LabelSidebar({</span></div>+ {showCameraTrack && (+ <div+ className="flex items-center justify-center border-t border-border/70 bg-muted/20 text-primary"+ style={{ height: 34 }}+ role="group"+ title={t('camera')}+ aria-label={t('camera')}+ >+ <Icon icon="mdi:camera" width="13" aria-hidden="true" />+ </div>+ )}+<divclassName="flex items-center px-3 border-t border-border"style={{ height: ELEMENT_ROW_HEIGHT }}diff --git a/app/components/ui/editor/Mockup3dMenu.tsx b/app/components/ui/editor/Mockup3dMenu.tsxindex 6c91303..e34d044 100644--- a/app/components/ui/editor/Mockup3dMenu.tsx+++ b/app/components/ui/editor/Mockup3dMenu.tsx@@ -8,8 +8,17 @@ import { HANDLE_R, ImageDeviceId, PAD_H, X_HALF, Y_HALF } from "@/types/mockup.timport { Button } from "@/components/ui/button";import { DetailPageHeader } from "@/components/ui/DetailHeaderMenu";import { Position3DPresetsEditor } from "@/components/ui/Position3DPresetsEditor";-import { ENVIRONMENT_OPTIONS, type EnvironmentPreset } from "@/lib/viewer-controls3d";-import type { CameraNavigationMode, MockupCameraConfig } from "@/lib/viewer-controls3d";+import { useMockup3dContext } from "@/app/contexts/Mockup3dContext";+import {+ ENVIRONMENT_OPTIONS,+ hasMockupCameraTourSpace,+ MOCKUP_CAMERA_PRESETS,+ type CameraNavigationMode,+ type EnvironmentPreset,+ type MockupCameraConfig,+ type MockupCameraKeyframe,+ type MockupCameraPreset,+} from "@/lib/viewer-controls3d";import {Select,SelectContent,@@ -18,6 +27,7 @@ import {SelectValue,} from "@/components/ui/select";import { Toggle } from "@/components/ui/toggle";+import { TooltipAction } from "@/components/ui/tooltip-action";function PositionPad({x,@@ -182,6 +192,7 @@ export interface Mockup3dMenuProps {imagePhonePresetId: string;setImagePhonePresetId: (id: string) => void;mediaType: "video" | "image";+ videoDuration: number;viewer3DAutoRotate: boolean;setViewer3DAutoRotate: (v: boolean) => void;viewer3DRotationSpeed: number;@@ -194,6 +205,12 @@ export interface Mockup3dMenuProps {setMockupCamera: (v: MockupCameraConfig) => void;cameraNavigationMode: CameraNavigationMode;setCameraNavigationMode: (v: CameraNavigationMode) => void;+ currentTime: number;+ mockupCameraKeyframes: MockupCameraKeyframe[];+ selectedMockupCameraKeyframeId: string | null;+ onApplyCameraPreset?: (preset: MockupCameraPreset) => void;+ onApplyAutomaticCamera?: () => void;+ onUpdateCameraKeyframe?: (camera: MockupCameraConfig) => void;}export function Mockup3dMenu({@@ -224,6 +241,7 @@ export function Mockup3dMenu({imagePhonePresetId,setImagePhonePresetId,mediaType,+ videoDuration,viewer3DAutoRotate,setViewer3DAutoRotate,viewer3DRotationSpeed,@@ -236,8 +254,22 @@ export function Mockup3dMenu({setMockupCamera,cameraNavigationMode,setCameraNavigationMode,+ currentTime,+ mockupCameraKeyframes,+ selectedMockupCameraKeyframeId,+ onApplyCameraPreset,+ onApplyAutomaticCamera,+ onUpdateCameraKeyframe,}: Mockup3dMenuProps) {const t = useTranslations("mockupMenu");+ const { cameraReviewGuides, setCameraReviewGuides } = useMockup3dContext();+ const canCreateAutomaticTour = mediaType !== "video"+ || hasMockupCameraTourSpace(videoDuration, mockupCameraKeyframes);++ const handleCameraChange = useCallback((camera: MockupCameraConfig) => {+ if (onUpdateCameraKeyframe) onUpdateCameraKeyframe(camera);+ else setMockupCamera(camera);+ }, [setMockupCamera, onUpdateCameraKeyframe]);const handleReset = useCallback(() => {setImagePhoneX(0);@@ -286,6 +318,10 @@ export function Mockup3dMenu({setCameraNavigationMode,]);+ const handleToggleReviewGuide = useCallback((guide: keyof typeof cameraReviewGuides) => {+ setCameraReviewGuides((previous) => ({ ...previous, [guide]: !previous[guide] }));+ }, [setCameraReviewGuides]);+return (<><div className="flex items-center gap-2 p-3 border-b border-border shrink-0">@@ -366,18 +402,64 @@ export function Mockup3dMenu({</div><section className="flex flex-col gap-3 pt-4 border-t border-border" aria-labelledby="camera-controls-title">- <div className="flex items-center gap-2">- <span className="flex size-8 shrink-0 items-center justify-center rounded-lg border border-primary/20 bg-primary/10 text-primary">- <Icon icon="mdi:camera" width="17" aria-hidden="true" />- </span>- <div className="min-w-0">- <h3 id="camera-controls-title" className="text-[11px] font-bold text-foreground uppercase tracking-wider">- {t("cameraControls")}- </h3>+ <h3 id="camera-controls-title" className="flex items-center gap-1.5 text-[10px] font-bold text-foreground uppercase tracking-wider">+ <Icon icon="mdi:camera" width="14" className="text-primary" aria-hidden="true" />+ {t("cameraControls")}+ </h3>++ <TooltipAction+ label={mediaType === "video" ? t("autoCameraHint") : t("autoCameraFrameHint")}+ side="right"+ >+ <button+ type="button"+ onClick={onApplyAutomaticCamera}+ disabled={!onApplyAutomaticCamera || !canCreateAutomaticTour}+ className="flex h-11 w-full items-center gap-2.5 rounded-xl border border-primary/30 bg-primary/10 px-2.5 text-left text-primary transition-colors hover:bg-primary/15 disabled:cursor-not-allowed disabled:opacity-45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"+ >+ <span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-primary text-primary-foreground">+ <Icon icon="lucide:sparkles" width="16" aria-hidden="true" />+ </span>+ <span className="min-w-0 flex-1 text-[11px] font-semibold">+ {mediaType === "video" ? t("autoCamera") : t("autoCameraFrame")}+ </span>+ <Icon icon="lucide:arrow-right" width="14" aria-hidden="true" />+ </button>+ </TooltipAction>++ {mediaType === "video" && !canCreateAutomaticTour && (+ <p className="flex items-center gap-1.5 px-1 text-[9px] leading-snug text-amber-600 dark:text-amber-400">+ <Icon icon="lucide:circle-alert" width="13" className="shrink-0" aria-hidden="true" />+ {t("autoCameraNoSpace")}+ </p>+ )}++ {mediaType === "video" && (+ <div className="flex items-center gap-1.5 px-1 text-[9px] text-muted-foreground">+ <TooltipAction label={`${t("cameraKeyframes")}: ${mockupCameraKeyframes.length}`}>+ <span+ tabIndex={0}+ aria-label={`${t("cameraKeyframes")}: ${mockupCameraKeyframes.length}`}+ className="inline-flex items-center gap-1 rounded-sm outline-none focus-visible:ring-2 focus-visible:ring-primary"+ >+ <Icon icon="mdi:movie-open-play-outline" width="13" className="text-primary" aria-hidden="true" />+ <span className="font-mono">{mockupCameraKeyframes.length}</span>+ </span>+ </TooltipAction>+ {selectedMockupCameraKeyframeId && (+ <span className="ml-auto font-mono">{currentTime.toFixed(1)}s</span>+ )}</div>- </div>+ )}- <div className="grid grid-cols-3 gap-1" role="group" aria-label={t("cameraControls")}>+ <details className="group rounded-lg border border-border/70 bg-muted/20">+ <summary className="flex cursor-pointer list-none items-center gap-2 px-2.5 py-2 text-[10px] font-medium text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-primary [&::-webkit-details-marker]:hidden">+ <Icon icon="lucide:sliders-horizontal" width="14" className="text-primary" aria-hidden="true" />+ <span>{t("cameraAdvanced")}</span>+ <Icon icon="lucide:chevron-down" width="13" className="ml-auto transition-transform group-open:rotate-180" aria-hidden="true" />+ </summary>+ <div className="space-y-3 border-t border-border/70 p-2.5">+ <div className="grid grid-cols-3 gap-1 rounded-lg border border-border bg-muted/30 p-1" role="group" aria-label={t("cameraControls")}>{([["orbit", "mdi:orbit-variant", "orbit"],["trackXY", "mdi:move", "trackXY"],@@ -388,33 +470,75 @@ export function Mockup3dMenu({type="button"onClick={() => setCameraNavigationMode(mode)}aria-pressed={cameraNavigationMode === mode}- aria-label={t(label)}+ aria-label={`${t(label)}: ${t(mode === "orbit" ? "orbitHint" : mode === "trackXY" ? "trackXYHint" : "trackZHint")}`}title={`${t(label)}: ${t(mode === "orbit" ? "orbitHint" : mode === "trackXY" ? "trackXYHint" : "trackZHint")}`}- className={`relative flex h-10 min-w-0 items-center justify-center gap-1.5 rounded-lg border px-2 text-[10px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background ${+ className={`flex h-9 min-w-0 items-center justify-center gap-1.5 rounded-md px-2 text-[10px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${cameraNavigationMode === mode- ? "border-primary/50 bg-primary/10 text-primary"- : "border-border bg-muted/40 text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground"+ ? "bg-primary text-primary-foreground shadow-sm"+ : "text-muted-foreground hover:bg-background hover:text-foreground"}`}><Icon icon={icon} width="15" aria-hidden="true" />- <span className="leading-tight">{mode === "trackXY" ? "XY" : mode === "trackZ" ? "Z" : t(label)}</span>- {cameraNavigationMode === mode && (- <Icon- icon="lucide:check"- width="11"- className="absolute right-1 top-1"- aria-hidden="true"- />- )}+ <span className="leading-tight">{mode === "orbit" ? t(label) : mode === "trackXY" ? "XY" : "Z"}</span></button>))}</div>+ <TooltipAction label={t("cameraDragHint")} side="right">+ <button+ type="button"+ aria-label={t("cameraDragHint")}+ className="ml-auto flex size-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"+ >+ <Icon icon="lucide:circle-help" width="14" aria-hidden="true" />+ </button>+ </TooltipAction><div className="space-y-2 border-t border-border/70 pt-2.5">- <h4 className="flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">- <Icon icon="mdi:camera-metering-center" width="13" aria-hidden="true" />- {t("cameraFraming")}- </h4>+ <div className="flex items-center justify-between">+ <h4 className="flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground">+ <Icon icon="mdi:camera-metering-center" width="13" aria-hidden="true" />+ {t("cameraFraming")}+ </h4>+ <span className="text-[9px] text-muted-foreground/70">{t("cameraPresets")}</span>+ </div>+ <div className="grid grid-cols-4 gap-1" role="group" aria-label={t("cameraPresets")}>+ {MOCKUP_CAMERA_PRESETS.map((preset) => (+ <button+ key={preset.id}+ type="button"+ onClick={() => onApplyCameraPreset?.(preset)}+ title={t(`cameraPreset.${preset.id}`)}+ aria-label={t(`cameraPreset.${preset.id}`)}+ className="flex h-8 items-center justify-center rounded-md border border-border bg-muted/40 text-muted-foreground transition-colors hover:border-primary/40 hover:bg-primary/10 hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"+ >+ <Icon icon={preset.icon} width="15" aria-hidden="true" />+ </button>+ ))}+ </div>+ <div className="flex items-center gap-1 rounded-lg border border-border/70 bg-muted/20 p-1" role="group" aria-label={t("cameraReviewGuides.title")}>+ {([+ ["thirds", "mdi:grid"],+ ["center", "mdi:crosshairs"],+ ["safeArea", "mdi:crop-free"],+ ] as const).map(([guide, icon]) => (+ <button+ key={guide}+ type="button"+ onClick={() => handleToggleReviewGuide(guide)}+ aria-label={t(`cameraReviewGuides.${guide}`)}+ aria-pressed={cameraReviewGuides[guide]}+ title={`${t("cameraReviewGuides.title")}: ${t(`cameraReviewGuides.${guide}`)}`}+ className={`flex size-7 items-center justify-center rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${+ cameraReviewGuides[guide]+ ? "bg-primary/15 text-primary"+ : "text-muted-foreground hover:bg-background hover:text-foreground"+ }`}+ >+ <Icon icon={icon} width="14" aria-hidden="true" />+ </button>+ ))}+ <span className="ml-auto mr-1 text-[9px] text-muted-foreground">{t("cameraReviewGuides.title")}</span>+ </div><SliderControlicon="mdi:arrow-expand-vertical"label={t("dolly")}@@ -422,7 +546,7 @@ export function Mockup3dMenu({min={25}max={400}step={1}- onChange={(value) => setMockupCamera({ ...mockupCamera, distance: value / 100 })}+ onChange={(value) => handleCameraChange({ ...mockupCamera, distance: value / 100 })}suffix="%"/><SliderControl@@ -432,7 +556,7 @@ export function Mockup3dMenu({min={20}max={80}step={1}- onChange={(fov) => setMockupCamera({ ...mockupCamera, fov })}+ onChange={(fov) => handleCameraChange({ ...mockupCamera, fov })}suffix="°"/></div>@@ -456,12 +580,14 @@ export function Mockup3dMenu({onChange={(value) => {const target = [...mockupCamera.target] as [number, number, number];target[index] = (value / 100) * targetRange;- setMockupCamera({ ...mockupCamera, target });+ handleCameraChange({ ...mockupCamera, target });}}/>);})}</div>+ </div>+ </details></section><div className="flex flex-col gap-3 pt-4 border-t border-border">diff --git a/app/components/ui/editor/MockupMenu.tsx b/app/components/ui/editor/MockupMenu.tsxindex 9926185..a991a56 100644--- a/app/components/ui/editor/MockupMenu.tsx+++ b/app/components/ui/editor/MockupMenu.tsx@@ -20,6 +20,11 @@ import { getWallpaperUrl } from "@/lib/wallpaper.utils";import { Mockup2dMenu } from "./Mockup2dMenu";import { Mockup3dMenu, type ActiveDeviceTpl } from "./Mockup3dMenu";import { DeviceCard } from "@/components/ui/DeviceCard";+import type {+ MockupCameraConfig,+ MockupCameraKeyframe,+ MockupCameraPreset,+} from "@/lib/viewer-controls3d";export interface MockupMenuProps {mockupId?: string;@@ -33,6 +38,13 @@ export interface MockupMenuProps {selectedImageUrl?: string;initialPage?: MenuPage;mediaType?: "video" | "image";+ currentTime?: number;+ mockupCameraKeyframes?: MockupCameraKeyframe[];+ selectedMockupCameraKeyframeId?: string | null;+ onApplyCameraPreset?: (preset: MockupCameraPreset) => void;+ onApplyAutomaticCamera?: () => void;+ onUpdateCameraKeyframe?: (camera: MockupCameraConfig) => void;+ videoDuration?: number;}export function MockupMenu({@@ -47,6 +59,13 @@ export function MockupMenu({selectedImageUrl,initialPage = "home",mediaType = "image",+ currentTime = 0,+ mockupCameraKeyframes = [],+ selectedMockupCameraKeyframeId = null,+ onApplyCameraPreset,+ onApplyAutomaticCamera,+ onUpdateCameraKeyframe,+ videoDuration = 0,}: MockupMenuProps) {const t = useTranslations("mockupMenu");@@ -301,6 +320,13 @@ export function MockupMenu({setMockupCamera={setMockupCamera}cameraNavigationMode={cameraNavigationMode}setCameraNavigationMode={setCameraNavigationMode}+ currentTime={currentTime}+ mockupCameraKeyframes={mockupCameraKeyframes}+ selectedMockupCameraKeyframeId={selectedMockupCameraKeyframeId}+ onApplyCameraPreset={onApplyCameraPreset}+ onApplyAutomaticCamera={onApplyAutomaticCamera}+ onUpdateCameraKeyframe={onUpdateCameraKeyframe}+ videoDuration={videoDuration}imagePhoneRotZ={imagePhoneRotZ}setImagePhoneRotZ={setImagePhoneRotZ}imagePhonePresetId={imagePhonePresetId}diff --git a/app/components/ui/editor/Timeline.tsx b/app/components/ui/editor/Timeline.tsxindex 37f5839..1348de3 100644--- a/app/components/ui/editor/Timeline.tsx+++ b/app/components/ui/editor/Timeline.tsx@@ -56,6 +56,12 @@ export function Timeline({onSelectMockupMotionFragment,onUpdateMockupMotionFragment,onDeleteMockupMotionFragment,+ showCameraTrack = false,+ mockupCameraKeyframes = [],+ selectedMockupCameraKeyframeId = null,+ onSelectMockupCameraKeyframe,+ onDeleteMockupCameraKeyframe,+ onAddMockupCameraKeyframeAtTime,onActivateMotionTool,canvasElements = [],selectedElementId = null,@@ -213,11 +219,12 @@ export function Timeline({const totalLanesCount = useMemo(() => {let count = 0;if (showMovementRow) count += 1;+ if (showCameraTrack) count += 1;if (canvasElements.length > 0) count += elementLaneCount;if (audioTracks.length > 0) count += audioLaneCount;if (mockupMotionFragments.length > 0) count += 1;return count;- }, [showMovementRow, canvasElements.length, elementLaneCount, audioTracks.length, audioLaneCount, mockupMotionFragments.length]);+ }, [showMovementRow, showCameraTrack, canvasElements.length, elementLaneCount, audioTracks.length, audioLaneCount, mockupMotionFragments.length]);useEffect(() => {if (!isDraggingTrim) {@@ -648,7 +655,7 @@ export function Timeline({<div className="flex-1 flex flex-col relative overflow-hidden"><divref={trackRef}- className={`flex-1 overflow-x-auto custom-scrollbar pr-2 ${audioTracks.length > 0 || elementLaneCount > 1 || canvasElements.length > 0 || showMovementRow+ className={`flex-1 overflow-x-auto custom-scrollbar pr-2 ${audioTracks.length > 0 || elementLaneCount > 1 || canvasElements.length > 0 || showMovementRow || showCameraTrack? "overflow-y-auto no-scrollbar": "overflow-y-hidden"}`}@@ -666,6 +673,7 @@ export function Timeline({audioLaneCount={audioTracks.length > 0 ? audioLaneCount : 0}motionTracksCount={mockupMotionFragments.length}showMovementRow={showMovementRow}+ showCameraTrack={showCameraTrack}/><div className="relative flex flex-col pb-1 min-w-0"><motion.div@@ -849,6 +857,47 @@ export function Timeline({</div></div>+ {showCameraTrack && (+ <div+ className="shrink-0 w-full flex items-center relative border-t border-border/70 bg-muted/20"+ style={{ height: 34 }}+ role="group"+ aria-label={t("cameraKeyframe")}+ title={t("cameraTrackClickHint")}+ onClick={(event) => {+ if (!onAddMockupCameraKeyframeAtTime || contentWidth <= 0 || scaledDuration <= 0) return;+ if ((event.target as HTMLElement).closest("button")) return;+ const bounds = event.currentTarget.getBoundingClientRect();+ const progress = Math.max(0, Math.min(1, (event.clientX - bounds.left) / contentWidth));+ onAddMockupCameraKeyframeAtTime(progress * scaledDuration);+ }}+ >+ <div className="pointer-events-none absolute inset-x-0 top-1/2 h-px bg-primary/15" aria-hidden="true" />+ {mockupCameraKeyframes.map((keyframe) => {+ const left = scaledDuration > 0+ ? (keyframe.time / scaledDuration) * contentWidth+ : 0;+ return (+ <button+ key={keyframe.id}+ type="button"+ className={`absolute top-1/2 z-10 size-3 -translate-x-1/2 -translate-y-1/2 rotate-45 rounded-[2px] border shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary ${+ selectedMockupCameraKeyframeId === keyframe.id+ ? "border-primary bg-primary text-primary-foreground"+ : "border-primary/40 bg-background text-primary hover:bg-primary/10"+ }`}+ style={{ left }}+ title={`${t("cameraKeyframe")} · ${formatTime(keyframe.time)} · ${t("cameraKeyframeMarkerHint")}`}+ aria-label={`${t("cameraKeyframe")} · ${formatTime(keyframe.time)} · ${t("cameraKeyframeMarkerHint")}`}+ aria-pressed={selectedMockupCameraKeyframeId === keyframe.id}+ onClick={() => onSelectMockupCameraKeyframe?.(keyframe)}+ onDoubleClick={() => onDeleteMockupCameraKeyframe?.(keyframe.id)}+ />+ );+ })}+ </div>+ )}+<divclassName="shrink-0 w-full flex items-center relative"style={{ minHeight: ELEMENT_ROW_HEIGHT }}diff --git a/app/components/ui/editor/VideoCanvas.tsx b/app/components/ui/editor/VideoCanvas.tsxindex 6277d85..53bc4e2 100644--- a/app/components/ui/editor/VideoCanvas.tsx+++ b/app/components/ui/editor/VideoCanvas.tsx@@ -36,6 +36,11 @@ import { drawPhone3DCompositeWithZoom, type Phone3DCompositeContext } from "@/liimport { buildMockupMotionCss, MockupMotionTransform, REST_MOCKUP_MOTION, sampleCombinedMockupMotion, sampleCombined3DMotion, REST_MOCKUP_3D_MOTION, Mockup3DMotionTransform, MOTION_PRESET_3D_IDS } from "@/lib/mockup-motion";import { filterVisibleElements } from "@/lib/canvas-elements-timeline.utils";import { ZoomPointOverlay, ZOOM_POINT_VISUAL_SCALE } from "@/components/ui/ZoomPointOverlay";+import {+ DEFAULT_MOCKUP_CAMERA_FOV,+ sampleMockupCameraKeyframes,+} from "@/lib/viewer-controls3d";+import type { MockupCameraKeyframe, MockupCameraPose } from "@/lib/viewer-controls3d";export type { VideoCanvasHandle, VideoCanvasProps };@@ -119,6 +124,9 @@ function VideoCanvasInner({onSelectZoomMovement,onUpdateZoomMovement,videoClips = [],+ mockupCameraKeyframes = [],+ selectedMockupCameraKeyframeId = null,+ onUpdateMockupCameraKeyframe,}: VideoCanvasProps & {ref?: React.Ref<VideoCanvasHandle>;onSelectedElementIdsChange?: (ids: string[]) => void;@@ -136,9 +144,16 @@ function VideoCanvasInner({imagePhoneShadow, imagePhoneShadowColor,imagePhoneRefWidth, setImagePhoneRefWidth,viewer3DAutoRotate, viewer3DRotationSpeed, viewer3DGlow, viewer3DEnvironment,- mockupCamera, setMockupCamera, cameraNavigationMode,+ mockupCamera, setMockupCamera, cameraNavigationMode, cameraReviewGuides, setCameraReviewGuides,} = useMockup3dContext();+ const previewCameraPose = useMemo(+ () => mediaType === "video"+ ? sampleMockupCameraKeyframes(mockupCameraKeyframes, currentTime, DEFAULT_MOCKUP_CAMERA_FOV[imagePhoneDevice])+ : null,+ [mediaType, mockupCameraKeyframes, currentTime, imagePhoneDevice],+ );+// 3D phone overlay is active in both video and image modeconst handlePhoneMount = useCallback((canvas: HTMLCanvasElement) => {imagePhoneCanvasRef.current = canvas;@@ -151,7 +166,24 @@ function VideoCanvasInner({const handlePhoneRotationChange = useCallback((rx: number, ry: number) => {setImagePhoneRotX(rx);setImagePhoneRotY(ry);- }, [setImagePhoneRotX, setImagePhoneRotY]);+ const selectedKeyframe = mockupCameraKeyframes.find((keyframe) =>+ keyframe.id === selectedMockupCameraKeyframeId && Math.abs(keyframe.time - currentTime) <= 0.05+ );+ if (selectedKeyframe) {+ onUpdateMockupCameraKeyframe?.(selectedKeyframe.id, { rotationX: rx, rotationY: ry });+ }+ }, [setImagePhoneRotX, setImagePhoneRotY, mockupCameraKeyframes, selectedMockupCameraKeyframeId, currentTime, onUpdateMockupCameraKeyframe]);++ const handleMockupCameraChange = useCallback((camera: typeof mockupCamera) => {+ setMockupCamera(camera);+ const selectedKeyframe = mockupCameraKeyframes.find((keyframe) =>+ keyframe.id === selectedMockupCameraKeyframeId && Math.abs(keyframe.time - currentTime) <= 0.05+ );+ if (selectedKeyframe) {+ onUpdateMockupCameraKeyframe?.(selectedKeyframe.id, { camera });+ }+ }, [setMockupCamera, mockupCameraKeyframes, selectedMockupCameraKeyframeId, currentTime, onUpdateMockupCameraKeyframe]);+// Ctrl+scroll zoom badge state for image phone overlayconst [imagePhoneZoomVisible, setImagePhoneZoomVisible] = useState(false);const imagePhoneZoomTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);@@ -249,7 +281,7 @@ function VideoCanvasInner({// Root THREE.Group ref for applying 3D motion during export rendering.const imagePhoneRootRef = useRef<THREE.Group | null>(null);const imagePhoneApiRef = useRef<{- renderAt: (w: number, h: number, motion?: Mockup3DMotionTransform) => void;+ renderAt: (w: number, h: number, motion?: Mockup3DMotionTransform, cameraPose?: MockupCameraPose) => void;restorePreview: () => void;hasBuiltInShadow?: boolean;getVisualSize?: () => { width: number; height: number; offsetY?: number } | null; // ← offsetY@@ -1395,6 +1427,9 @@ function VideoCanvasInner({effectivePhoneMaskConfig, maskCompositeCanvasRef,imagePhoneRootRef,motion3DForFrame,+ cameraPoseForFrame: mediaType === "video"+ ? sampleMockupCameraKeyframes(mockupCameraKeyframes, frameTime, DEFAULT_MOCKUP_CAMERA_FOV[imagePhoneDevice]) ?? undefined+ : undefined,};ctx.setTransform(1, 0, 0, 1, 0, 0);@@ -2554,13 +2589,13 @@ function VideoCanvasInner({modelUrl={imagePhoneDevice === "phone" || imagePhoneDevice === "iphone" ? imagePhoneModelUrl : undefined}imageMaskConfig={effectivePhoneMaskConfig}cropArea={cropArea}- initialRotationX={imagePhoneRotX}- initialRotationY={imagePhoneRotY}+ initialRotationX={previewCameraPose?.rotationX ?? imagePhoneRotX}+ initialRotationY={previewCameraPose?.rotationY ?? imagePhoneRotY}initialRotationZ={imagePhoneRotZ}onRotationChange={handlePhoneRotationChange}- cameraConfig={mockupCamera}+ cameraConfig={previewCameraPose?.camera ?? mockupCamera}cameraNavigationMode={cameraNavigationMode}- onCameraChange={setMockupCamera}+ onCameraChange={handleMockupCameraChange}onMount={handlePhoneMount}onApi={handlePhoneApi}zoom={1}@@ -2582,6 +2617,36 @@ function VideoCanvasInner({)}</div>{/* End perspective wrapper div */}+ {imagePhoneActive && (+ <>+ {(cameraReviewGuides.thirds || cameraReviewGuides.center || cameraReviewGuides.safeArea) && (+ <div+ className="pointer-events-none absolute inset-0"+ style={{ zIndex: 300 }}+ aria-hidden="true"+ >+ {cameraReviewGuides.thirds && (+ <div className="absolute inset-0">+ <div className="absolute inset-y-0 left-1/3 border-l border-dashed border-white/65 mix-blend-difference" />+ <div className="absolute inset-y-0 left-2/3 border-l border-dashed border-white/65 mix-blend-difference" />+ <div className="absolute inset-x-0 top-1/3 border-t border-dashed border-white/65 mix-blend-difference" />+ <div className="absolute inset-x-0 top-2/3 border-t border-dashed border-white/65 mix-blend-difference" />+ </div>+ )}+ {cameraReviewGuides.center && (+ <div className="absolute inset-0">+ <div className="absolute inset-y-0 left-1/2 border-l border-white/70 mix-blend-difference" />+ <div className="absolute inset-x-0 top-1/2 border-t border-white/70 mix-blend-difference" />+ <div className="absolute left-1/2 top-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/80 mix-blend-difference" />+ </div>+ )}+ {cameraReviewGuides.safeArea && (+ <div className="absolute inset-[5%] rounded-sm border border-dashed border-white/80 mix-blend-difference" />+ )}+ </div>+ )}+ </>+ )}{(isDraggingElement && (alignmentGuides.vertical.length > 0 || alignmentGuides.horizontal.length > 0)) && (<>{alignmentGuides.vertical.map((x, index) => (diff --git a/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx b/app/components/ui/editor/mockups-3d/Mockup3DStage.tsxindex dd272fe..e002ce0 100644--- a/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx+++ b/app/components/ui/editor/mockups-3d/Mockup3DStage.tsx@@ -17,6 +17,8 @@ import type {EnvironmentPreset,MockupCameraConfig,} from "@/lib/viewer-controls3d";+import { applyMockupCameraPoseForRender } from "@/lib/viewer-controls3d";+import type { MockupCameraPose } from "@/lib/viewer-controls3d";import { REST_MOCKUP_3D_MOTION, type Mockup3DMotionTransform } from "@/lib/mockup-motion-3d";import { useFrame } from "@react-three/fiber";@@ -155,6 +157,11 @@ function StageContent({ device, rootRef: externalRootRef, cameraRef: externalCamconst rootRef = externalRootRef ?? internalRootRef;const cameraRef = externalCameraRef ?? internalCameraRef;const canvasElRef = useRef<HTMLCanvasElement | null>(null);+ const zoomRef = useRef(props.zoom ?? 1);+ const onApi = props.onApi;+ useEffect(() => {+ zoomRef.current = props.zoom ?? 1;+ }, [props.zoom]);const hasMotion = props.motionTransform && props.motionTransform !== REST_MOCKUP_3D_MOTION;@@ -171,6 +178,29 @@ function StageContent({ device, rootRef: externalRootRef, cameraRef: externalCamonLoadedChange?.(true);}, [onLoadedChange]);+ const handleApi = useCallback((api: Mockup3DApi | null) => {+ if (!api) {+ onApi?.(null);+ return;+ }++ const wrappedApi = {+ ...api,+ renderAt: (width: number, height: number, _motion?: Mockup3DMotionTransform, cameraPose?: MockupCameraPose) => {+ const camera = cameraRef.current;+ const restoreCamera = camera && cameraPose+ ? applyMockupCameraPoseForRender(camera, cameraPose, device, zoomRef.current)+ : null;+ try {+ api.renderAt(width, height);+ } finally {+ restoreCamera?.();+ }+ },+ };+ onApi?.(wrappedApi as Mockup3DApi);+ }, [device, onApi, cameraRef]);+const handleMount = (canvas: HTMLCanvasElement) => {canvasElRef.current = canvas;props.onMount?.(canvas);@@ -201,25 +231,25 @@ function StageContent({ device, rootRef: externalRootRef, cameraRef: externalCam<Motion3DApplicator rootRef={rootRef} motionTransform={props.motionTransform ?? REST_MOCKUP_3D_MOTION} device={device} baseRotationZ={props.initialRotationZ ?? 0} /><Suspense fallback={null}>{device === "iphone-13-pro-max" && (- <IPhone13ProMaxScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <IPhone13ProMaxScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{device === "double_iphone_13_pro" && (- <DoubleIPhoneScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <DoubleIPhoneScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{device === "iphone-17-pro-max" && (- <IPhone17ProMaxScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <IPhone17ProMaxScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{device === "iphone-duo" && (- <IPhoneDuoScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <IPhoneDuoScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{device === "laptop" && (- <LaptopScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <LaptopScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{device === "ipad_mini_6_2021" && (- <IPadMiniScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <IPadMiniScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}{(device === "iphone" || device === "phone") && (- <Phone3DScene {...props} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />+ <Phone3DScene {...props} onApi={handleApi} rootRef={rootRef} cameraRef={cameraRef} onLoaded={markLoaded} />)}</Suspense></Canvas>diff --git a/app/contexts/Mockup3dContext.tsx b/app/contexts/Mockup3dContext.tsxindex d917efe..c3c4865 100644--- a/app/contexts/Mockup3dContext.tsx+++ b/app/contexts/Mockup3dContext.tsx@@ -47,6 +47,12 @@ interface Mockup3dState {setMockupCamera: (v: MockupCameraConfig) => void;cameraNavigationMode: CameraNavigationMode;setCameraNavigationMode: (v: CameraNavigationMode) => void;+ cameraReviewGuides: {+ thirds: boolean;+ center: boolean;+ safeArea: boolean;+ };+ setCameraReviewGuides: (v: Mockup3dState["cameraReviewGuides"] | ((previous: Mockup3dState["cameraReviewGuides"]) => Mockup3dState["cameraReviewGuides"])) => void;/** Active device from the shared 3D catalogue */imagePhoneDevice: ImageDeviceId;setImagePhoneDevice: (d: ImageDeviceId) => void;@@ -90,6 +96,11 @@ export function Mockup3dProvider({ children }: { children: ReactNode }) {const [imagePhonePerspective, setImagePhonePerspective] = useState(600);const [mockupCamera, setMockupCamera] = useState<MockupCameraConfig>(DEFAULT_MOCKUP_CAMERA);const [cameraNavigationMode, setCameraNavigationMode] = useState<CameraNavigationMode>("orbit");+ const [cameraReviewGuides, setCameraReviewGuides] = useState({+ thirds: false,+ center: false,+ safeArea: false,+ });const [imagePhoneDevice, setImagePhoneDevice] = useState<ImageDeviceId>('phone');const [imagePhonePresetId, setImagePhonePresetId] = useState('custom');const [imagePhoneOpening, setImagePhoneOpening] = useState(1);@@ -126,6 +137,7 @@ export function Mockup3dProvider({ children }: { children: ReactNode }) {imagePhonePerspective, setImagePhonePerspective,mockupCamera, setMockupCamera,cameraNavigationMode, setCameraNavigationMode,+ cameraReviewGuides, setCameraReviewGuides,imagePhoneDevice, setImagePhoneDevice,imagePhonePresetId, setImagePhonePresetId,imagePhoneOpening, setImagePhoneOpening,@@ -140,7 +152,7 @@ export function Mockup3dProvider({ children }: { children: ReactNode }) {selectedTemplateId, motionImageUrl, motionIntensity,imagePhoneActive, imagePhoneX, imagePhoneY, imagePhoneScale,imagePhoneRotX, imagePhoneRotY, imagePhoneRotZ, imagePhonePerspective,- mockupCamera, cameraNavigationMode,+ mockupCamera, cameraNavigationMode, cameraReviewGuides,imagePhoneDevice, imagePhonePresetId, imagePhoneOpening,imagePhoneShadow, imagePhoneShadowColor, imagePhoneRefWidth,viewer3DAutoRotate, viewer3DRotationSpeed, viewer3DGlow, viewer3DEnvironment,diff --git a/lib/canvas.utils.ts b/lib/canvas.utils.tsindex e81f6e0..97f82fd 100644--- a/lib/canvas.utils.ts+++ b/lib/canvas.utils.ts@@ -230,20 +230,12 @@ export function calculateSmoothZoom(return 1 + (targetScale - 1) * easeOutQuart(progress);}- feat/3d-camera-controls- // Exit ramp [end-T, end]: begin at targetScale and decay back to 1 by endTime.- const timeBeforeEnd = fragment.endTime - time;- if (transitionSec > 0 && timeBeforeEnd < transitionSec) {- const progress = Math.min(1, Math.max(0, (transitionSec - timeBeforeEnd) / transitionSec));- return 1 + (targetScale - 1) * (1 - easeOutQuart(progress));-=======- const timeBeforeEnd = fragment.endTime - time;- if (transitionSec > 0 && timeBeforeEnd < transitionSec) {- const timeIntoExit = transitionSec - timeBeforeEnd;- const progress = Math.min(1, Math.max(0, timeIntoExit / transitionSec));- return targetScale - (targetScale - 1) * easeOutQuart(progress);- main- }+ // Exit ramp [end-T, end]: begin at targetScale and decay back to 1 by endTime.+ const timeBeforeEnd = fragment.endTime - time;+ if (transitionSec > 0 && timeBeforeEnd < transitionSec) {+ const progress = Math.min(1, Math.max(0, (transitionSec - timeBeforeEnd) / transitionSec));+ return 1 + (targetScale - 1) * (1 - easeOutQuart(progress));+ }return targetScale;};diff --git a/lib/phone3d-composite-draw.utils.ts b/lib/phone3d-composite-draw.utils.tsindex 791fff0..3fd264a 100644--- a/lib/phone3d-composite-draw.utils.ts+++ b/lib/phone3d-composite-draw.utils.ts@@ -4,9 +4,10 @@ import { PHONE_H, PHONE_W, DEVICE_3D_DIMENSIONS, type ImageMaskConfigLike } fromimport type { Mockup3DMotionTransform } from "@/lib/mockup-motion-3d";import { REST_MOCKUP_3D_MOTION } from "@/lib/mockup-motion-3d";import * as THREE from "three";+import type { MockupCameraPose } from "@/lib/viewer-controls3d";export interface Phone3DApi {- renderAt: (w: number, h: number, motion?: Mockup3DMotionTransform) => void;+ renderAt: (w: number, h: number, motion?: Mockup3DMotionTransform, cameraPose?: MockupCameraPose) => void;restorePreview: () => void;hasBuiltInShadow?: boolean;getVisualSize?: () => { width: number; height: number; offsetY?: number } | null;@@ -28,6 +29,7 @@ export interface Phone3DCompositeContext {imagePhoneRootRef?: MutableRefObject<THREE.Group | null>;/** 3D motion transform to apply before rendering each export frame. */motion3DForFrame?: Mockup3DMotionTransform;+ cameraPoseForFrame?: MockupCameraPose;}// Cache of the base transform so we can restore after export rendering.@@ -53,6 +55,7 @@ export function drawPhone3DCompositeWithZoom(imagePhoneScale, imagePhoneX, imagePhoneY, imagePhoneShadow, imagePhoneShadowColor,effectivePhoneMaskConfig, maskCompositeCanvasRef,imagePhoneRootRef, motion3DForFrame,+ cameraPoseForFrame,} = ctx2;const phoneGL = imagePhoneCanvasRef.current!;@@ -95,8 +98,9 @@ export function drawPhone3DCompositeWithZoom(root.position.z = cachedBase.pz + motion.posZ;}- if (highQuality) {- imagePhoneApiRef.current?.renderAt(baseW, baseH, motion);+ const shouldRender3DFrame = highQuality || cameraPoseForFrame !== undefined;+ if (shouldRender3DFrame) {+ imagePhoneApiRef.current?.renderAt(baseW, baseH, motion, cameraPoseForFrame);}c.save();@@ -144,7 +148,7 @@ export function drawPhone3DCompositeWithZoom(c.restore();- if (highQuality) {+ if (shouldRender3DFrame) {imagePhoneApiRef.current?.restorePreview();}diff --git a/lib/video-project-cache.ts b/lib/video-project-cache.tsindex 6e1955c..7d007ff 100644--- a/lib/video-project-cache.ts+++ b/lib/video-project-cache.ts@@ -8,7 +8,7 @@ import type { BackgroundTab, BackgroundColorConfig, AspectRatio, CropArea } fromimport type { CameraConfig } from "@/types/camera.types";import type { Preview3DConfig, ImageMaskConfig } from "@/types/photo.types";import type { TrimRange } from "@/types/timeline.types";-import type { MockupCameraConfig } from "@/lib/viewer-controls3d";+import type { MockupCameraConfig, MockupCameraKeyframe } from "@/lib/viewer-controls3d";const DB_NAME = "openvid-video-project";const DB_VERSION = 3;@@ -40,6 +40,7 @@ export interface VideoProject {mockupId: string;mockupConfig: MockupConfig;mockupCamera?: MockupCameraConfig;+ mockupCameraKeyframes?: MockupCameraKeyframe[];mockupMotionFragments: MockupMotionFragment[];diff --git a/lib/viewer-controls3d.ts b/lib/viewer-controls3d.tsindex 6f679cd..dc32fe0 100644--- a/lib/viewer-controls3d.ts+++ b/lib/viewer-controls3d.ts@@ -2,6 +2,8 @@ import { useControls } from "leva";import { useEffect } from "react";import { MOUSE, TOUCH } from "three";import type { OrbitControls as OrbitControlsType } from "three-stdlib";+import type { PerspectiveCamera, Vector3Tuple } from "three";+import type { ImageDeviceId } from "@/types/mockup.types";export type EnvironmentPreset = "sunset" | "dawn" | "night" | "warehouse" | "forest" | "apartment" | "studio" | "city" | "park" | "lobby";export type CameraNavigationMode = "orbit" | "trackXY" | "trackZ";@@ -12,12 +14,258 @@ export interface MockupCameraConfig {fov: number | null;}+export interface MockupCameraPose {+ camera: MockupCameraConfig;+ rotationX: number;+ rotationY: number;+}++export interface MockupCameraKeyframe extends MockupCameraPose {+ id: string;+ time: number;+}++export interface MockupCameraPreset extends MockupCameraPose {+ id: "front" | "threeQuarter" | "top" | "detail";+ icon: string;+}++type MockupCameraTourId = "orbitShowcase" | "pushIn" | "topSweep";++const MOCKUP_CAMERA_TOURS: Array<{+ id: MockupCameraTourId;+ keyframes: Array<Pick<MockupCameraPose, "rotationX" | "rotationY"> & {+ progress: number;+ distance: number;+ }>;+}> = [+ {+ id: "orbitShowcase",+ keyframes: [+ { progress: 0, distance: 1.12, rotationX: 6, rotationY: -42 },+ { progress: 0.34, distance: 0.96, rotationX: 10, rotationY: -14 },+ { progress: 0.68, distance: 0.96, rotationX: 10, rotationY: 16 },+ { progress: 1, distance: 1.12, rotationX: 6, rotationY: 44 },+ ],+ },+ {+ id: "pushIn",+ keyframes: [+ { progress: 0, distance: 1.6, rotationX: 5, rotationY: -24 },+ { progress: 0.38, distance: 1.12, rotationX: 6, rotationY: -10 },+ { progress: 0.72, distance: 0.78, rotationX: 5, rotationY: 9 },+ { progress: 1, distance: 1.08, rotationX: 4, rotationY: 22 },+ ],+ },+ {+ id: "topSweep",+ keyframes: [+ { progress: 0, distance: 1.24, rotationX: 18, rotationY: -32 },+ { progress: 0.36, distance: 1.08, rotationX: 62, rotationY: -15 },+ { progress: 0.7, distance: 1.08, rotationX: 62, rotationY: 18 },+ { progress: 1, distance: 1.24, rotationX: 18, rotationY: 34 },+ ],+ },+];++export const MOCKUP_CAMERA_PRESETS: MockupCameraPreset[] = [+ { id: "front", icon: "mdi:camera", camera: { target: [0, 0, 0], distance: 1, fov: null }, rotationX: 0, rotationY: 0 },+ { id: "threeQuarter", icon: "mdi:camera-metering-center", camera: { target: [0, 0, 0], distance: 1, fov: null }, rotationX: 22, rotationY: 35 },+ { id: "top", icon: "lucide:arrow-up", camera: { target: [0, 0, 0], distance: 1.15, fov: null }, rotationX: 68, rotationY: 0 },+ { id: "detail", icon: "lucide:zoom-in", camera: { target: [0, 0, 0], distance: 0.68, fov: null }, rotationX: 8, rotationY: 18 },+];++const MIN_CAMERA_TOUR_DURATION = 0.8;++function findCameraTourWindow(+ duration: number,+ keyframes: MockupCameraKeyframe[] = [],+): { start: number; end: number } | null {+ if (!Number.isFinite(duration) || duration < MIN_CAMERA_TOUR_DURATION) return null;+ const sortedKeyframes = keyframes+ .filter((keyframe) => Number.isFinite(keyframe.time) && keyframe.time >= 0 && keyframe.time <= duration)+ .sort((a, b) => a.time - b.time);+ const boundaries = [+ { time: 0, isKeyframe: false },+ ...sortedKeyframes.map((keyframe) => ({ time: keyframe.time, isKeyframe: true })),+ { time: duration, isKeyframe: false },+ ];+ const padding = Math.min(0.12, duration / 6);+ let bestWindow: { start: number; end: number } | null = null;++ for (let index = 0; index < boundaries.length - 1; index += 1) {+ const left = boundaries[index];+ const right = boundaries[index + 1];+ const start = left.time + (left.isKeyframe ? padding : 0);+ const end = right.time - (right.isKeyframe ? padding : 0);+ if (end - start < MIN_CAMERA_TOUR_DURATION) continue;+ if (!bestWindow || end - start > bestWindow.end - bestWindow.start) {+ bestWindow = { start, end };+ }+ }++ return bestWindow;+}++export function hasMockupCameraTourSpace(+ duration: number,+ keyframes: MockupCameraKeyframe[] = [],+): boolean {+ return findCameraTourWindow(duration, keyframes) !== null;+}++function createMockupCameraTour(+ tourId: MockupCameraTourId,+ duration: number,+ existingKeyframes: MockupCameraKeyframe[] = [],+): MockupCameraKeyframe[] {+ const window = findCameraTourWindow(duration, existingKeyframes);+ if (!window) return [];+ const tour = MOCKUP_CAMERA_TOURS.find((item) => item.id === tourId);+ if (!tour) return [];+ const createdAt = Date.now();++ return tour.keyframes.map((frame, index) => ({+ id: `camera_tour_${createdAt}_${index}_${Math.random().toString(36).slice(2, 7)}`,+ time: window.start + (window.end - window.start) * frame.progress,+ camera: {+ target: [0, 0, 0],+ distance: frame.distance,+ fov: null,+ },+ rotationX: frame.rotationX,+ rotationY: frame.rotationY,+ }));+}++export function createAutomaticMockupCameraTour(+ device: ImageDeviceId,+ duration: number,+ existingKeyframes: MockupCameraKeyframe[] = [],+): MockupCameraKeyframe[] {+ const tourId: MockupCameraTourId = device === "laptop"+ ? "topSweep"+ : device === "ipad_mini_6_2021"+ ? "pushIn"+ : "orbitShowcase";+ return createMockupCameraTour(tourId, duration, existingKeyframes);+}++export function getAutomaticMockupCameraPreset(device: ImageDeviceId): MockupCameraPreset {+ return device === "laptop"+ ? MOCKUP_CAMERA_PRESETS[2]+ : MOCKUP_CAMERA_PRESETS[1];+}++export const DEFAULT_MOCKUP_CAMERA_FOV: Readonly<Record<ImageDeviceId, number>> = {+ phone: 40,+ iphone: 40,+ "iphone-13-pro-max": 40,+ "iphone-17-pro-max": 40,+ "iphone-duo": 30,+ double_iphone_13_pro: 40,+ ipad_mini_6_2021: 40,+ laptop: 40,+};+export const DEFAULT_MOCKUP_CAMERA: MockupCameraConfig = {target: [0, 0, 0],distance: 1,fov: null,};+export function sampleMockupCameraKeyframes(+ keyframes: MockupCameraKeyframe[],+ time: number,+ defaultFov = 40,+): MockupCameraPose | null {+ const sorted = keyframes+ .filter((keyframe) => Number.isFinite(keyframe.time))+ .sort((a, b) => a.time - b.time);+ if (sorted.length === 0 || !Number.isFinite(time)) return null;+ if (time <= sorted[0].time) return poseFromKeyframe(sorted[0]);+ const last = sorted[sorted.length - 1];+ if (time >= last.time) return poseFromKeyframe(last);++ const nextIndex = sorted.findIndex((keyframe) => keyframe.time >= time);+ const from = sorted[nextIndex - 1];+ const to = sorted[nextIndex];+ if (time === to.time) return poseFromKeyframe(to);++ const duration = to.time - from.time;+ if (duration <= 0) return poseFromKeyframe(to);+ const linearProgress = Math.max(0, Math.min(1, (time - from.time) / duration));+ const progress = linearProgress * linearProgress * (3 - 2 * linearProgress);+ const fromPose = poseFromKeyframe(from);+ const toPose = poseFromKeyframe(to);+ const fromFov = fromPose.camera.fov ?? defaultFov;+ const toFov = toPose.camera.fov ?? defaultFov;+ const fov = fromPose.camera.fov === null && toPose.camera.fov === null+ ? null+ : fromFov + (toFov - fromFov) * progress;++ return {+ camera: {+ target: [+ lerp(fromPose.camera.target[0], toPose.camera.target[0], progress),+ lerp(fromPose.camera.target[1], toPose.camera.target[1], progress),+ lerp(fromPose.camera.target[2], toPose.camera.target[2], progress),+ ],+ distance: lerp(fromPose.camera.distance, toPose.camera.distance, progress),+ fov,+ },+ rotationX: lerp(fromPose.rotationX, toPose.rotationX, progress),+ rotationY: lerpAngle(fromPose.rotationY, toPose.rotationY, progress),+ };+}++function poseFromKeyframe(keyframe: MockupCameraKeyframe): MockupCameraPose {+ return {+ camera: normalizeMockupCameraConfig(keyframe.camera),+ rotationX: Number.isFinite(keyframe.rotationX) ? keyframe.rotationX : 0,+ rotationY: Number.isFinite(keyframe.rotationY) ? keyframe.rotationY : 0,+ };+}++function lerp(from: number, to: number, progress: number): number {+ return from + (to - from) * progress;+}++function lerpAngle(from: number, to: number, progress: number): number {+ const difference = ((to - from + 540) % 360) - 180;+ return from + difference * progress;+}++export function applyMockupCameraPoseForRender(+ camera: PerspectiveCamera,+ pose: MockupCameraPose,+ device: ImageDeviceId,+ zoom: number,+): () => void {+ const position: Vector3Tuple = getMockupCameraPosition(+ pose.rotationX,+ pose.rotationY,+ pose.camera.distance / (device === "laptop" || device === "iphone-duo" ? Math.max(zoom, 0.001) : 1),+ pose.camera.target,+ device === "laptop" ? 90 : device === "iphone-duo" ? 1.7 : 1.5,+ );+ const previousPosition = camera.position.clone();+ const previousQuaternion = camera.quaternion.clone();+ const previousFov = camera.fov;++ camera.position.set(...position);+ camera.lookAt(...pose.camera.target);+ camera.fov = pose.camera.fov ?? DEFAULT_MOCKUP_CAMERA_FOV[device];+ camera.updateProjectionMatrix();++ return () => {+ camera.position.copy(previousPosition);+ camera.quaternion.copy(previousQuaternion);+ camera.fov = previousFov;+ camera.updateProjectionMatrix();+ };+}+export function normalizeMockupCameraConfig(value?: Partial<MockupCameraConfig> | null,): MockupCameraConfig {diff --git a/messages/en.json b/messages/en.jsonindex 2a6b3ce..6ee9dec 100644--- a/messages/en.json+++ b/messages/en.json@@ -644,6 +644,27 @@"position": "Position","cameraControls": "3D camera","cameraFraming": "Camera framing",+ "cameraPresets": "Camera views",+ "cameraPreset": {+ "front": "Front view",+ "threeQuarter": "Three-quarter view",+ "top": "Top view",+ "detail": "Close-up view"+ },+ "cameraKeyframes": "Camera keyframes",+ "autoCamera": "Auto camera",+ "autoCameraHint": "Creates a smooth, device-matched camera move.",+ "autoCameraNoSpace": "Add at least 0.8 s of free timeline space first.",+ "autoCameraFrame": "Auto frame",+ "autoCameraFrameHint": "Sets a polished angle for this device.",+ "cameraAdvanced": "Adjust",+ "cameraDragHint": "Choose a mode, then drag the 3D preview.",+ "cameraReviewGuides": {+ "title": "Framing guides",+ "thirds": "Rule of thirds",+ "center": "Center crosshair",+ "safeArea": "Safe area"+ },"cameraTarget": "Look-at point","orbit": "Orbit","trackXY": "Track XY",@@ -1206,6 +1227,9 @@},"timeline": {"noSpace": "No space",+ "cameraKeyframe": "Camera keyframe",+ "cameraTrackClickHint": "Click an empty spot to add a camera keyframe.",+ "cameraKeyframeMarkerHint": "Click to jump to this time; double-click to delete.","trimStartHint": "Drag to trim the start","trimEndHint": "Drag to trim the end","trimmedStart": "Trimmed {seconds}s from the start · double-click to restore",@@ -1509,6 +1533,7 @@},"labelSidebar": {"video": "Video",+ "camera": "Camera","zoom": "Zoom","elements": "Object","audio": "Audio",diff --git a/messages/es.json b/messages/es.jsonindex 3b7edff..7c25c24 100644--- a/messages/es.json+++ b/messages/es.json@@ -600,6 +600,27 @@"position": "Posición","cameraControls": "Cámara 3D","cameraFraming": "Encuadre de cámara",+ "cameraPresets": "Vistas de cámara",+ "cameraPreset": {+ "front": "Vista frontal",+ "threeQuarter": "Vista tres cuartos",+ "top": "Vista superior",+ "detail": "Primer plano"+ },+ "cameraKeyframes": "Fotogramas de cámara",+ "autoCamera": "Cámara automática",+ "autoCameraHint": "Crea un movimiento suave adaptado al dispositivo.",+ "autoCameraNoSpace": "Libera al menos 0,8 s en la línea de tiempo.",+ "autoCameraFrame": "Encuadre automático",+ "autoCameraFrameHint": "Aplica un ángulo cuidado para este dispositivo.",+ "cameraAdvanced": "Ajustes",+ "cameraDragHint": "Elige un modo y arrastra la vista 3D.",+ "cameraReviewGuides": {+ "title": "Guías de encuadre",+ "thirds": "Regla de tercios",+ "center": "Cruz central",+ "safeArea": "Área segura"+ },"cameraTarget": "Punto de enfoque","orbit": "Orbitar","trackXY": "Mover XY",@@ -1184,6 +1205,9 @@},"timeline": {"noSpace": "Sin espacio",+ "cameraKeyframe": "Fotograma de cámara",+ "cameraTrackClickHint": "Haz clic en un espacio vacío para añadir un fotograma de cámara.",+ "cameraKeyframeMarkerHint": "Clic para ir a ese momento; doble clic para eliminar.","trimStartHint": "Arrastra para recortar el inicio","trimEndHint": "Arrastra para recortar el final","trimmedStart": "Recortado {seconds}s al inicio · doble clic para restaurar",@@ -1487,6 +1511,7 @@},"labelSidebar": {"video": "Video",+ "camera": "Cámara","zoom": "Zoom","elements": "Objeto","audio": "Audio",diff --git a/messages/ko.json b/messages/ko.jsonindex 8b5b6f2..53f9520 100644--- a/messages/ko.json+++ b/messages/ko.json@@ -644,6 +644,27 @@"position": "위치","cameraControls": "3D 카메라","cameraFraming": "카메라 구도",+ "cameraPresets": "카메라 보기",+ "cameraPreset": {+ "front": "정면 보기",+ "threeQuarter": "3/4 보기",+ "top": "상단 보기",+ "detail": "근접 보기"+ },+ "cameraKeyframes": "카메라 키프레임",+ "autoCamera": "자동 카메라",+ "autoCameraHint": "기기에 맞는 부드러운 카메라 움직임을 만듭니다.",+ "autoCameraNoSpace": "타임라인에 0.8초 이상의 빈 공간을 확보하세요.",+ "autoCameraFrame": "자동 구도",+ "autoCameraFrameHint": "기기에 맞는 세련된 각도를 설정합니다.",+ "cameraAdvanced": "세부 설정",+ "cameraDragHint": "모드를 선택한 뒤 3D 미리보기를 드래그하세요.",+ "cameraReviewGuides": {+ "title": "구도 가이드",+ "thirds": "삼분할",+ "center": "중앙 십자선",+ "safeArea": "안전 영역"+ },"cameraTarget": "시선 대상","orbit": "회전","trackXY": "XY 이동",@@ -1206,6 +1227,9 @@},"timeline": {"noSpace": "공간 없음",+ "cameraKeyframe": "카메라 키프레임",+ "cameraTrackClickHint": "빈 곳을 클릭하면 카메라 키프레임이 추가됩니다.",+ "cameraKeyframeMarkerHint": "클릭하면 해당 시점으로 이동하고, 두 번 클릭하면 삭제합니다.","trimStartHint": "드래그하여 시작 부분 자르기","trimEndHint": "드래그하여 끝 부분 자르기","trimmedStart": "시작 부분 {seconds}초 잘림 · 더블 클릭하여 복원",@@ -1509,6 +1533,7 @@},"labelSidebar": {"video": "비디오",+ "camera": "카메라","zoom": "줌","elements": "오브젝트","audio": "오디오",diff --git a/messages/ru.json b/messages/ru.jsonindex 3675e2a..f7e215a 100644--- a/messages/ru.json+++ b/messages/ru.json@@ -611,6 +611,27 @@"position": "Позиция","cameraControls": "3D-камера","cameraFraming": "Кадрирование камеры",+ "cameraPresets": "Ракурсы камеры",+ "cameraPreset": {+ "front": "Вид спереди",+ "threeQuarter": "Вид в три четверти",+ "top": "Вид сверху",+ "detail": "Крупный план"+ },+ "cameraKeyframes": "Ключевые кадры камеры",+ "autoCamera": "Автокамера",+ "autoCameraHint": "Создает плавное движение с учетом устройства.",+ "autoCameraNoSpace": "Освободите на таймлайне не менее 0,8 с.",+ "autoCameraFrame": "Автокадрирование",+ "autoCameraFrameHint": "Устанавливает удачный ракурс для устройства.",+ "cameraAdvanced": "Настроить",+ "cameraDragHint": "Выберите режим и перетащите 3D-просмотр.",+ "cameraReviewGuides": {+ "title": "Сетка кадрирования",+ "thirds": "Правило третей",+ "center": "Центральный маркер",+ "safeArea": "Безопасная область"+ },"cameraTarget": "Точка фокуса","orbit": "Орбита","trackXY": "Перемещение XY",@@ -1173,6 +1194,9 @@},"timeline": {"noSpace": "Нет места",+ "cameraKeyframe": "Ключевой кадр камеры",+ "cameraTrackClickHint": "Нажмите на пустое место, чтобы добавить ключевой кадр камеры.",+ "cameraKeyframeMarkerHint": "Нажмите, чтобы перейти ко времени; двойной щелчок удаляет кадр.","trimStartHint": "Перетащите, чтобы обрезать начало","trimEndHint": "Перетащите, чтобы обрезать конец","trimmedStart": "Обрезано {seconds} с в начале · дважды щёлкните, чтобы восстановить",@@ -1509,6 +1533,7 @@},"labelSidebar": {"video": "Видео",+ "camera": "Камера","zoom": "Зум","elements": "Объект","audio": "Аудио",diff --git a/types/control-panel.types.ts b/types/control-panel.types.tsindex 8559787..a516da2 100644--- a/types/control-panel.types.ts+++ b/types/control-panel.types.ts@@ -7,6 +7,11 @@ import type { UploadedAudio, AudioTrack } from "./audio.types";import type { CameraConfig } from "./camera.types";import type { ImageProjectPreview } from "./image-project.types";import { MockupMotionFragment, MockupMotionPresetId } from "@/lib/mockup-motion";+import type {+ MockupCameraKeyframe,+ MockupCameraPreset,+ MockupCameraConfig,+} from "@/lib/viewer-controls3d";export interface ControlPanelProps {activeTool: Tool;@@ -105,6 +110,12 @@ export interface ControlPanelProps {onUpdateMockupMotionFragment?: (id: string, updates: Partial<MockupMotionFragment>) => void;onSelectMockupMotionFragment?: (id: string | null) => void;onDeleteMockupMotionFragment?: (id: string) => void;+ currentTime?: number;+ mockupCameraKeyframes?: MockupCameraKeyframe[];+ selectedMockupCameraKeyframeId?: string | null;+ onApplyMockupCameraPreset?: (preset: MockupCameraPreset) => void;+ onApplyAutomaticMockupCamera?: () => void;+ onUpdateMockupCameraKeyframe?: (camera: MockupCameraConfig) => void;selectedAudioTrackId?: string | null;setSelectedAudioTrackId?: (trackId: string | null) => void;}diff --git a/types/editor-state.types.ts b/types/editor-state.types.tsindex 91899f7..a8b2a49 100644--- a/types/editor-state.types.ts+++ b/types/editor-state.types.ts@@ -8,6 +8,7 @@ import type { Preview3DConfig, ImageMaskConfig } from "@/types/photo.types";import { MockupMotionFragment } from "@/lib/mockup-motion";import { VideoTrackClip } from "./video-track.types";import type { MockupCameraConfig } from "@/lib/viewer-controls3d";+import type { MockupCameraKeyframe } from "@/lib/viewer-controls3d";export interface VideoTransform {rotation: number;@@ -50,6 +51,7 @@ export interface EditorState {imagePhoneRotZ: number;imagePhonePerspective: number;mockupCamera: MockupCameraConfig;+ mockupCameraKeyframes: MockupCameraKeyframe[];imagePhoneDevice: ImageDeviceId;imagePhonePresetId: string;imagePhoneOpening: number;@@ -124,6 +126,7 @@ export function createInitialEditorState(overrides?: Partial<EditorState>): EditimagePhoneRotZ: 0,imagePhonePerspective: 600,mockupCamera: { target: [0, 0, 0], distance: 1, fov: null },+ mockupCameraKeyframes: [],imagePhoneDevice: 'phone',imagePhonePresetId: 'front',imagePhoneOpening: 1,diff --git a/types/editor.types.ts b/types/editor.types.tsindex 6968c1b..ff6d7d9 100644--- a/types/editor.types.ts+++ b/types/editor.types.ts@@ -6,6 +6,7 @@ import type { MockupConfig } from "./mockup.types";import type { CameraConfig } from "./camera.types";import { MockupMotionFragment } from "@/lib/mockup-motion";import type { VideoTrackClip } from "./video-track.types";+import type { MockupCameraKeyframe } from "@/lib/viewer-controls3d";export type Tool = "screenshot" | "elements" | "audio" | "zoom" | "mockup" | "cursor" | "video" | "camera" | "history" | "motion";export type BackgroundTab = "wallpaper" | "image" | "color";@@ -115,6 +116,9 @@ export interface VideoCanvasProps {onImageZoomScaleChange?: (scale: number) => void;otherSelectionActive?: boolean;mockupMotionFragments?: MockupMotionFragment[];+ mockupCameraKeyframes?: MockupCameraKeyframe[];+ selectedMockupCameraKeyframeId?: string | null;+ onUpdateMockupCameraKeyframe?: (id: string, updates: Partial<MockupCameraKeyframe>) => void;videoDuration?: number;onMockupConfigChange?: (config: Partial<MockupConfig>) => void;selectedZoomFragment?: ZoomFragment | null;diff --git a/types/timeline.types.ts b/types/timeline.types.tsindex 8b5e8f0..37f6181 100644--- a/types/timeline.types.ts+++ b/types/timeline.types.ts@@ -2,6 +2,7 @@ import { ZoomFragment, ZoomMovement } from "./zoom.types";import type { AudioTrack, UploadedAudio } from "./audio.types";import type { TrimEdge, VideoTrackClip } from "./video-track.types";import { MockupMotionFragment } from "@/lib/mockup-motion";+import type { MockupCameraKeyframe } from "@/lib/viewer-controls3d";import { CanvasElement } from "./canvas-elements.types";export interface TrimRange {@@ -49,6 +50,12 @@ export interface TimelineProps {onSelectMockupMotionFragment?: (id: string | null) => void;onUpdateMockupMotionFragment?: (id: string, updates: Partial<MockupMotionFragment>) => void;onDeleteMockupMotionFragment?: (id: string) => void;+ showCameraTrack?: boolean;+ mockupCameraKeyframes?: MockupCameraKeyframe[];+ selectedMockupCameraKeyframeId?: string | null;+ onSelectMockupCameraKeyframe?: (keyframe: MockupCameraKeyframe) => void;+ onDeleteMockupCameraKeyframe?: (id: string) => void;+ onAddMockupCameraKeyframeAtTime?: (time: number) => void;canvasElements?: CanvasElement[];selectedElementId?: string | null;onSelectElement?: (id: string | null) => void;