From 331f9a3c31490fa48727c485d2a3d4c659a3fc94 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Fri, 1 May 2026 06:45:26 -0700 Subject: [PATCH] PromptBox3D: drive letterbox from the new aspect-ratio picker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For models with `supportsNewAspectRatio()`, the picker only stored a `CommonAspectRatio` in local state for the API request payload — it never called `onAspectRatioSelect`, so the editor's render-camera aspect and the Letterbox stayed on the previous setting. Wrap the picker's callback to also map the chosen `CommonAspectRatio` to the closest `CameraAspectRatio` and forward it through `onAspectRatioSelect`. `Auto*` ratios have no fixed shape, so they leave the letterbox alone. --- .../promptbox/src/lib/PromptBox3D.tsx | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx b/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx index 5cf4fce30a..68afe2f74b 100644 --- a/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx +++ b/frontend/libs/components/promptbox/src/lib/PromptBox3D.tsx @@ -174,6 +174,15 @@ export const PromptBox3D = ({ CommonAspectRatio | undefined >(undefined); + // The new picker drives both the API request payload (commonAspectRatio) + // and the 3D editor's letterbox/render-camera. Auto* ratios have no + // fixed shape, so they leave the letterbox alone. + const handleCommonAspectRatioSelect = (ratio: CommonAspectRatio) => { + setCommonAspectRatio(ratio); + const mapped = commonToCameraAspect(ratio); + if (mapped) onAspectRatioSelect(mapped); + }; + useEffect(() => { if (textareaRef.current && !isExpanded) { textareaRef.current.style.height = "auto"; @@ -643,7 +652,7 @@ export const PromptBox3D = ({ )} {selectedImageModel?.canChangeAspectRatio && @@ -812,3 +821,37 @@ export const PromptBox3D = ({ ); }; + +// Map a CommonAspectRatio (the 2D/API-side enum) to the closest +// CameraAspectRatio variant the 3D editor's letterbox supports. Returns +// undefined for Auto* values, which have no fixed shape. +const commonToCameraAspect = ( + ratio: CommonAspectRatio, +): CameraAspectRatio | undefined => { + switch (ratio) { + case CommonAspectRatio.Square: + case CommonAspectRatio.SquareHd: + return CameraAspectRatio.SQUARE_1_1; + case CommonAspectRatio.WideSixteenByNine: + case CommonAspectRatio.WideTwentyOneByNine: + return CameraAspectRatio.HORIZONTAL_16_9; + case CommonAspectRatio.WideThreeByTwo: + case CommonAspectRatio.WideFourByThree: + case CommonAspectRatio.WideFiveByFour: + case CommonAspectRatio.Wide: + return CameraAspectRatio.HORIZONTAL_3_2; + case CommonAspectRatio.TallNineBySixteen: + case CommonAspectRatio.TallNineByTwentyOne: + return CameraAspectRatio.VERTICAL_9_16; + case CommonAspectRatio.TallTwoByThree: + case CommonAspectRatio.TallThreeByFour: + case CommonAspectRatio.TallFourByFive: + case CommonAspectRatio.Tall: + return CameraAspectRatio.VERTICAL_2_3; + case CommonAspectRatio.Auto: + case CommonAspectRatio.Auto2k: + case CommonAspectRatio.Auto3k: + case CommonAspectRatio.Auto4k: + return undefined; + } +};