调整预览基点显示单位
This commit is contained in:
@@ -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(
|
||||
</div>
|
||||
|
||||
<div class="preview-basepoint-grid">
|
||||
<label><span>X</span><input name="baseX" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>Y</span><input name="baseY" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>Z</span><input name="baseZ" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>RX</span><input name="baseRx" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>RY</span><input name="baseRy" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>RZ</span><input name="baseRz" type="number" value="0" step="0.001" /></label>
|
||||
<label><span>X(mm)</span><input name="baseX" type="number" value="0.000" step="0.001" /></label>
|
||||
<label><span>Y(mm)</span><input name="baseY" type="number" value="0.000" step="0.001" /></label>
|
||||
<label><span>Z(mm)</span><input name="baseZ" type="number" value="0.000" step="0.001" /></label>
|
||||
<label><span>RX(°)</span><input name="baseRx" type="number" value="0.000" step="0.001" /></label>
|
||||
<label><span>RY(°)</span><input name="baseRy" type="number" value="0.000" step="0.001" /></label>
|
||||
<label><span>RZ(°)</span><input name="baseRz" type="number" value="0.000" step="0.001" /></label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -245,7 +248,7 @@ export function setPreviewBasePoint(basePoint: PreviewBasePoint, enabled = true)
|
||||
for (const [key, name] of fieldMap) {
|
||||
const input = document.querySelector<HTMLInputElement>(`.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[],
|
||||
|
||||
Reference in New Issue
Block a user