Skip to content

Create professional demos and 3D mockups in seconds, directly in your browser

feat: simplify 3D camera framing controls

Efrain Chiri Nina0e6c4ee6d227
diff --git a/app/components/ui/editor/LabelSidebar.tsx b/app/components/ui/editor/LabelSidebar.tsx
index 6ea3a78..6dd8e49 100644
--- a/app/components/ui/editor/LabelSidebar.tsx
+++ b/app/components/ui/editor/LabelSidebar.tsx
@@ -10,6 +10,8 @@ interface LabelSidebarProps {
elementLaneCount?: number;
showMovementRow?: boolean;
showCameraTrack?: boolean;
+ cameraAddLabel?: string;
+ onAddCameraKeyframe?: () => void;
}
export default function LabelSidebar({
@@ -18,6 +20,8 @@ export default function LabelSidebar({
elementLaneCount = 0,
showMovementRow = false,
showCameraTrack = false,
+ cameraAddLabel,
+ onAddCameraKeyframe,
}: LabelSidebarProps) {
const t = useTranslations('labelSidebar');
@@ -33,13 +37,25 @@ export default function LabelSidebar({
{showCameraTrack && (
<div
- className="flex items-center justify-center border-t border-border/70 bg-muted/20 text-primary"
+ className="flex items-center justify-center border-t border-border/70 bg-muted/20"
style={{ height: 34 }}
role="group"
title={t('camera')}
aria-label={t('camera')}
>
- <Icon icon="mdi:camera" width="13" aria-hidden="true" />
+ <button
+ type="button"
+ onClick={onAddCameraKeyframe}
+ disabled={!onAddCameraKeyframe}
+ title={cameraAddLabel}
+ aria-label={cameraAddLabel ?? t('camera')}
+ className="relative flex size-7 items-center justify-center rounded-md text-primary transition-colors hover:bg-primary/10 disabled:cursor-default focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
+ >
+ <Icon icon="mdi:camera" width="14" aria-hidden="true" />
+ <span className="absolute -right-0.5 -top-0.5 flex size-3.5 items-center justify-center rounded-full border border-background bg-primary text-primary-foreground" aria-hidden="true">
+ <Icon icon="lucide:plus" width="9" />
+ </span>
+ </button>
</div>
)}
diff --git a/app/components/ui/editor/Mockup3dMenu.tsx b/app/components/ui/editor/Mockup3dMenu.tsx
index f8cbb44..2a555d2 100644
--- a/app/components/ui/editor/Mockup3dMenu.tsx
+++ b/app/components/ui/editor/Mockup3dMenu.tsx
@@ -159,17 +159,26 @@ function CameraTargetPad({
x,
y,
range,
+ distance,
onChange,
+ onDistanceChange,
label,
hint,
+ backgroundUrl,
+ backgroundColorCss,
}: {
x: number;
y: number;
range: number;
+ distance: number;
onChange: (x: number, y: number) => void;
+ onDistanceChange: (distance: number) => void;
label: string;
hint: string;
+ backgroundUrl?: string | null;
+ backgroundColorCss?: string | null;
}) {
+ const t = useTranslations("mockupMenu");
const padRef = useRef<HTMLDivElement>(null);
const dragPointerId = useRef<number | null>(null);
const rectCache = useRef<DOMRect | null>(null);
@@ -177,6 +186,18 @@ function CameraTargetPad({
const positionY = Math.max(-range, Math.min(range, y));
const left = ((positionX / range + 1) / 2) * 100;
const top = ((1 - positionY / range) / 2) * 100;
+ const clampedDistance = Math.max(0.25, Math.min(4, distance));
+ const backgroundStyle: React.CSSProperties = backgroundUrl
+ ? {
+ backgroundImage: `url('${backgroundUrl}')`,
+ backgroundSize: "cover",
+ backgroundPosition: "center",
+ }
+ : backgroundColorCss
+ ? backgroundColorCss.startsWith("#") || backgroundColorCss.startsWith("rgb")
+ ? { backgroundColor: backgroundColorCss }
+ : { backgroundImage: backgroundColorCss, backgroundSize: "cover", backgroundPosition: "center" }
+ : {};
const updateFromPointer = useCallback((event: React.PointerEvent<HTMLDivElement>) => {
const rect = rectCache.current;
@@ -245,9 +266,10 @@ function CameraTargetPad({
Math.max(-range, Math.min(range, nextY)),
);
}}
- className="group relative h-28 touch-none select-none overflow-hidden rounded-xl border border-border bg-gradient-to-br from-cyan-500/35 via-emerald-500/25 to-violet-500/35 shadow-inner outline-none focus-visible:ring-2 focus-visible:ring-primary"
+ className={`group relative h-28 touch-none select-none overflow-hidden rounded-xl border border-border shadow-inner outline-none focus-visible:ring-2 focus-visible:ring-primary ${!backgroundUrl && !backgroundColorCss ? "bg-gradient-to-br from-cyan-500/35 via-emerald-500/25 to-violet-500/35" : ""}`}
+ style={backgroundStyle}
>
- <div className="pointer-events-none absolute inset-0 bg-[radial-gradient(ellipse_at_50%_45%,transparent_0%,rgba(0,0,0,0.22)_100%)]" />
+ <div className="pointer-events-none absolute inset-0 bg-black/20" />
<div className="pointer-events-none absolute inset-0 opacity-25 [background-image:linear-gradient(to_right,rgba(255,255,255,0.3)_1px,transparent_1px),linear-gradient(to_bottom,rgba(255,255,255,0.3)_1px,transparent_1px)] [background-size:25%_25%]" />
<div className="pointer-events-none absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-white/25" />
<div className="pointer-events-none absolute left-0 top-1/2 h-px w-full -translate-y-1/2 bg-white/25" />
@@ -260,6 +282,53 @@ function CameraTargetPad({
>
<span className="absolute left-1/2 top-1/2 size-1.5 -translate-x-1/2 -translate-y-1/2 rounded-full bg-white" />
</span>
+ <div
+ className="absolute right-1.5 top-1.5 z-20 flex items-center gap-0.5 rounded-lg border border-white/15 bg-black/40 p-0.5 shadow-sm backdrop-blur-sm"
+ onPointerDown={(event) => event.stopPropagation()}
+ >
+ {([
+ ["left", "mdi:arrow-left", -0.45, 0],
+ ["right", "mdi:arrow-right", 0.45, 0],
+ ["top", "mdi:arrow-up", 0, 0.45],
+ ["bottom", "mdi:arrow-down", 0, -0.45],
+ ["center", "mdi:crosshairs-gps", 0, 0],
+ ] as const).map(([position, icon, normalizedX, normalizedY]) => (
+ <TooltipAction key={position} label={t(`cameraTargetQuick.${position}`)}>
+ <button
+ type="button"
+ aria-label={t(`cameraTargetQuick.${position}`)}
+ onPointerDown={(event) => event.stopPropagation()}
+ onKeyDown={(event) => event.stopPropagation()}
+ onClick={() => onChange(normalizedX * range, normalizedY * range)}
+ className="flex size-6 items-center justify-center rounded-md text-white/85 transition-colors hover:bg-white/20 hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white"
+ >
+ <Icon icon={icon} width="14" aria-hidden="true" />
+ </button>
+ </TooltipAction>
+ ))}
+ </div>
+ <div
+ className="absolute inset-x-0 bottom-0 z-20 flex h-8 items-center gap-2 border-t border-white/10 bg-black/45 px-2 backdrop-blur-sm"
+ onPointerDown={(event) => event.stopPropagation()}
+ >
+ <Icon icon="mdi:arrow-expand-vertical" width="14" className="shrink-0 text-white/80" aria-hidden="true" />
+ <input
+ type="range"
+ min={0.25}
+ max={4}
+ step={0.01}
+ value={clampedDistance}
+ aria-label={t("dolly")}
+ title={t("dolly")}
+ onPointerDown={(event) => event.stopPropagation()}
+ onKeyDown={(event) => event.stopPropagation()}
+ onChange={(event) => onDistanceChange(Number(event.target.value))}
+ className="h-1 min-w-0 flex-1 cursor-ew-resize accent-white"
+ />
+ <span className="w-9 shrink-0 text-right font-mono text-[9px] text-white/90">
+ {clampedDistance.toFixed(2)}×
+ </span>
+ </div>
</div>
</div>
);
@@ -513,30 +582,33 @@ export function Mockup3dMenu({
</div>
<section className="flex flex-col gap-3 pt-4 border-t border-border" aria-labelledby="camera-controls-title">
- <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"
+ <div className="flex items-center justify-between">
+ <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"
+ ? canCreateAutomaticTour ? t("autoCameraHint") : t("autoCameraNoSpace")
+ : t("autoCameraFrameHint")}
+ side="right"
>
- <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
+ tabIndex={!canCreateAutomaticTour && mediaType === "video" ? 0 : -1}
+ className="inline-flex rounded-md focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary"
+ >
+ <button
+ type="button"
+ onClick={onApplyAutomaticCamera}
+ disabled={!onApplyAutomaticCamera || !canCreateAutomaticTour}
+ aria-label={mediaType === "video" ? t("autoCamera") : t("autoCameraFrame")}
+ className="flex size-8 items-center justify-center rounded-md border border-primary/25 bg-primary/10 text-primary transition-colors hover:bg-primary/20 disabled:cursor-not-allowed disabled:opacity-45 focus-visible:outline-none"
+ >
+ <Icon icon="lucide:sparkles" width="16" aria-hidden="true" />
+ </button>
</span>
- <Icon icon="lucide:arrow-right" width="14" aria-hidden="true" />
- </button>
- </TooltipAction>
+ </TooltipAction>
+ </div>
{mediaType === "video" && !canCreateAutomaticTour && (
<p className="flex items-center gap-1.5 px-1 text-[9px] leading-snug text-amber-600 dark:text-amber-400">
@@ -650,16 +722,6 @@ export function Mockup3dMenu({
))}
<span className="ml-auto mr-1 text-[9px] text-muted-foreground">{t("cameraReviewGuides.title")}</span>
</div>
- <SliderControl
- icon="mdi:arrow-expand-vertical"
- label={t("dolly")}
- value={Math.round(mockupCamera.distance * 100)}
- min={25}
- max={400}
- step={1}
- onChange={(value) => handleCameraChange({ ...mockupCamera, distance: value / 100 })}
- suffix="%"
- />
<SliderControl
icon="mdi:camera-metering-center"
label={t("fieldOfView")}
@@ -681,8 +743,12 @@ export function Mockup3dMenu({
x={mockupCamera.target[0]}
y={mockupCamera.target[1]}
range={cameraTargetRange}
+ distance={mockupCamera.distance}
label={t("cameraTargetPosition")}
hint={t("cameraTargetPadHint")}
+ backgroundUrl={backgroundUrl}
+ backgroundColorCss={backgroundColorCss}
+ onDistanceChange={(distance) => handleCameraChange({ ...mockupCamera, distance })}
onChange={(x, y) => {
const target: [number, number, number] = [x, y, mockupCamera.target[2]];
handleCameraChange({ ...mockupCamera, target });
diff --git a/app/components/ui/editor/Timeline.tsx b/app/components/ui/editor/Timeline.tsx
index 1348de3..5b0e55c 100644
--- a/app/components/ui/editor/Timeline.tsx
+++ b/app/components/ui/editor/Timeline.tsx
@@ -674,6 +674,10 @@ export function Timeline({
motionTracksCount={mockupMotionFragments.length}
showMovementRow={showMovementRow}
showCameraTrack={showCameraTrack}
+ cameraAddLabel={t("cameraAddAtPlayhead")}
+ onAddCameraKeyframe={onAddMockupCameraKeyframeAtTime
+ ? () => onAddMockupCameraKeyframeAtTime(currentTime)
+ : undefined}
/>
<div className="relative flex flex-col pb-1 min-w-0">
<motion.div
@@ -862,7 +866,7 @@ export function Timeline({
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")}
+ aria-label={`${t("cameraKeyframe")} · ${t("cameraTrackClickHint")}`}
title={t("cameraTrackClickHint")}
onClick={(event) => {
if (!onAddMockupCameraKeyframeAtTime || contentWidth <= 0 || scaledDuration <= 0) return;
@@ -873,6 +877,11 @@ export function Timeline({
}}
>
<div className="pointer-events-none absolute inset-x-0 top-1/2 h-px bg-primary/15" aria-hidden="true" />
+ {mockupCameraKeyframes.length === 0 && (
+ <span className="pointer-events-none absolute inset-0 flex items-center justify-center text-primary/35" aria-hidden="true">
+ <Icon icon="mdi:camera-plus-outline" width="16" />
+ </span>
+ )}
{mockupCameraKeyframes.map((keyframe) => {
const left = scaledDuration > 0
? (keyframe.time / scaledDuration) * contentWidth
diff --git a/messages/en.json b/messages/en.json
index 5b097b7..039c7d7 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -668,6 +668,13 @@
"cameraTarget": "Look-at point",
"cameraTargetPosition": "XY position",
"cameraTargetPadHint": "Drag the dot to move the framing. Use arrow keys to adjust and Home to center.",
+ "cameraTargetQuick": {
+ "left": "Focus left",
+ "right": "Focus right",
+ "top": "Focus up",
+ "bottom": "Focus down",
+ "center": "Center framing"
+ },
"orbit": "Orbit",
"trackXY": "Track XY",
"trackZ": "Track Z",
@@ -1231,6 +1238,7 @@
"noSpace": "No space",
"cameraKeyframe": "Camera keyframe",
"cameraTrackClickHint": "Click an empty spot to add a camera keyframe.",
+ "cameraAddAtPlayhead": "Add a keyframe at the playhead",
"cameraKeyframeMarkerHint": "Click to jump to this time; double-click to delete.",
"trimStartHint": "Drag to trim the start",
"trimEndHint": "Drag to trim the end",
diff --git a/messages/es.json b/messages/es.json
index 2a73894..87916da 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -624,6 +624,13 @@
"cameraTarget": "Punto de enfoque",
"cameraTargetPosition": "Posición XY",
"cameraTargetPadHint": "Arrastra el punto para mover el encuadre. Usa las flechas para ajustar y Home para centrar.",
+ "cameraTargetQuick": {
+ "left": "Enfocar a la izquierda",
+ "right": "Enfocar a la derecha",
+ "top": "Enfocar arriba",
+ "bottom": "Enfocar abajo",
+ "center": "Centrar encuadre"
+ },
"orbit": "Orbitar",
"trackXY": "Mover XY",
"trackZ": "Acercar / alejar",
@@ -1209,6 +1216,7 @@
"noSpace": "Sin espacio",
"cameraKeyframe": "Fotograma de cámara",
"cameraTrackClickHint": "Haz clic en un espacio vacío para añadir un fotograma de cámara.",
+ "cameraAddAtPlayhead": "Añadir fotograma en el cabezal de reproducción",
"cameraKeyframeMarkerHint": "Clic para ir a ese momento; doble clic para eliminar.",
"trimStartHint": "Arrastra para recortar el inicio",
"trimEndHint": "Arrastra para recortar el final",
diff --git a/messages/ko.json b/messages/ko.json
index fdab7a4..2609f73 100644
--- a/messages/ko.json
+++ b/messages/ko.json
@@ -668,6 +668,13 @@
"cameraTarget": "시선 대상",
"cameraTargetPosition": "XY 위치",
"cameraTargetPadHint": "점을 드래그해 구도를 이동하세요. 화살표 키로 조정하고 Home 키로 가운데에 놓으세요.",
+ "cameraTargetQuick": {
+ "left": "왼쪽에 초점",
+ "right": "오른쪽에 초점",
+ "top": "위쪽에 초점",
+ "bottom": "아래쪽에 초점",
+ "center": "구도 중앙 정렬"
+ },
"orbit": "회전",
"trackXY": "XY 이동",
"trackZ": "Z 이동",
@@ -1231,6 +1238,7 @@
"noSpace": "공간 없음",
"cameraKeyframe": "카메라 키프레임",
"cameraTrackClickHint": "빈 곳을 클릭하면 카메라 키프레임이 추가됩니다.",
+ "cameraAddAtPlayhead": "재생 헤드에 키프레임 추가",
"cameraKeyframeMarkerHint": "클릭하면 해당 시점으로 이동하고, 두 번 클릭하면 삭제합니다.",
"trimStartHint": "드래그하여 시작 부분 자르기",
"trimEndHint": "드래그하여 끝 부분 자르기",
diff --git a/messages/ru.json b/messages/ru.json
index 3d0eae4..2cd9b64 100644
--- a/messages/ru.json
+++ b/messages/ru.json
@@ -635,6 +635,13 @@
"cameraTarget": "Точка фокуса",
"cameraTargetPosition": "Положение XY",
"cameraTargetPadHint": "Перетащите точку, чтобы изменить кадр. Используйте стрелки для настройки, Home — для центрирования.",
+ "cameraTargetQuick": {
+ "left": "Сместить фокус влево",
+ "right": "Сместить фокус вправо",
+ "top": "Сместить фокус вверх",
+ "bottom": "Сместить фокус вниз",
+ "center": "Центрировать кадр"
+ },
"orbit": "Орбита",
"trackXY": "Перемещение XY",
"trackZ": "Перемещение Z",
@@ -1198,6 +1205,7 @@
"noSpace": "Нет места",
"cameraKeyframe": "Ключевой кадр камеры",
"cameraTrackClickHint": "Нажмите на пустое место, чтобы добавить ключевой кадр камеры.",
+ "cameraAddAtPlayhead": "Добавить ключевой кадр в позицию воспроизведения",
"cameraKeyframeMarkerHint": "Нажмите, чтобы перейти ко времени; двойной щелчок удаляет кадр.",
"trimStartHint": "Перетащите, чтобы обрезать начало",
"trimEndHint": "Перетащите, чтобы обрезать конец",