From 33f1163aa7795f543f648dc38d644a4e876cc3e2 Mon Sep 17 00:00:00 2001 From: zhangshun <453905631@qq.com> Date: Mon, 1 Jun 2026 16:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A2=84=E8=A7=88=E5=9F=BA?= =?UTF-8?q?=E7=82=B9=E6=98=BE=E7=A4=BA=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/pages/app/modules/preview.ts | 53 +++++++++++++++++++++------- 1 file changed, 40 insertions(+), 13 deletions(-) diff --git a/web/src/pages/app/modules/preview.ts b/web/src/pages/app/modules/preview.ts index a29648d..a02a2fa 100644 --- a/web/src/pages/app/modules/preview.ts +++ b/web/src/pages/app/modules/preview.ts @@ -122,6 +122,9 @@ const zeroBasePoint: PreviewResolvedBasePoint = { ry: 0, rz: 0 }; +const RAD_TO_DEG = 180 / Math.PI; +const DEG_TO_RAD = Math.PI / 180; +const BASE_POINT_DECIMAL_PLACES = 3; const previewEnvironmentUrl = "/DayCityOutdoor.exr"; const DEFAULT_PREVIEW_FRAME_INTERVAL_MS = 20; @@ -179,12 +182,12 @@ export function openModelPreview(
- - - - - - + + + + + +
@@ -245,7 +248,7 @@ export function setPreviewBasePoint(basePoint: PreviewBasePoint, enabled = true) for (const [key, name] of fieldMap) { const input = document.querySelector(`.preview-basepoint-grid input[name="${name}"]`); if (input && basePoint[key] !== undefined) { - input.value = String(basePoint[key]); + input.value = formatBasePointDisplayValue(key, basePoint[key]); } } @@ -626,12 +629,12 @@ function getSelectedOperation(operations: PreviewOperation[]) { function readPreviewBasePoint(): PreviewResolvedBasePoint { return resolveBasePoint({ - x: readNumberInput("baseX"), - y: readNumberInput("baseY"), - z: readNumberInput("baseZ"), - rx: readNumberInput("baseRx"), - ry: readNumberInput("baseRy"), - rz: readNumberInput("baseRz") + x: roundBasePointValue(readNumberInput("baseX")), + y: roundBasePointValue(readNumberInput("baseY")), + z: roundBasePointValue(readNumberInput("baseZ")), + rx: degreesToRadians(readNumberInput("baseRx")), + ry: degreesToRadians(readNumberInput("baseRy")), + rz: degreesToRadians(readNumberInput("baseRz")) }); } @@ -641,6 +644,30 @@ function readNumberInput(name: string) { return Number.isFinite(numberValue) ? numberValue : 0; } +function formatBasePointDisplayValue(key: keyof PreviewResolvedBasePoint, value: number) { + const displayValue = key === "rx" || key === "ry" || key === "rz" + ? radiansToDegrees(value) + : value; + return formatBasePointNumber(displayValue); +} + +function radiansToDegrees(value: number) { + return roundBasePointValue(value * RAD_TO_DEG); +} + +function degreesToRadians(value: number) { + return Number.isFinite(value) ? value * DEG_TO_RAD : 0; +} + +function roundBasePointValue(value: number) { + if (!Number.isFinite(value)) return 0; + return Number(value.toFixed(BASE_POINT_DECIMAL_PLACES)); +} + +function formatBasePointNumber(value: number) { + return roundBasePointValue(value).toFixed(BASE_POINT_DECIMAL_PLACES); +} + function bindImportScene( model: ModelItem, operations: PreviewOperation[],