调整预览基点显示单位
This commit is contained in:
@@ -122,6 +122,9 @@ const zeroBasePoint: PreviewResolvedBasePoint = {
|
|||||||
ry: 0,
|
ry: 0,
|
||||||
rz: 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 previewEnvironmentUrl = "/DayCityOutdoor.exr";
|
||||||
const DEFAULT_PREVIEW_FRAME_INTERVAL_MS = 20;
|
const DEFAULT_PREVIEW_FRAME_INTERVAL_MS = 20;
|
||||||
@@ -179,12 +182,12 @@ export function openModelPreview(
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="preview-basepoint-grid">
|
<div class="preview-basepoint-grid">
|
||||||
<label><span>X</span><input name="baseX" 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</span><input name="baseY" type="number" value="0" step="0.001" /></label>
|
<label><span>Y(mm)</span><input name="baseY" type="number" value="0.000" step="0.001" /></label>
|
||||||
<label><span>Z</span><input name="baseZ" type="number" value="0" 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" 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" 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" step="0.001" /></label>
|
<label><span>RZ(°)</span><input name="baseRz" type="number" value="0.000" step="0.001" /></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -245,7 +248,7 @@ export function setPreviewBasePoint(basePoint: PreviewBasePoint, enabled = true)
|
|||||||
for (const [key, name] of fieldMap) {
|
for (const [key, name] of fieldMap) {
|
||||||
const input = document.querySelector<HTMLInputElement>(`.preview-basepoint-grid input[name="${name}"]`);
|
const input = document.querySelector<HTMLInputElement>(`.preview-basepoint-grid input[name="${name}"]`);
|
||||||
if (input && basePoint[key] !== undefined) {
|
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 {
|
function readPreviewBasePoint(): PreviewResolvedBasePoint {
|
||||||
return resolveBasePoint({
|
return resolveBasePoint({
|
||||||
x: readNumberInput("baseX"),
|
x: roundBasePointValue(readNumberInput("baseX")),
|
||||||
y: readNumberInput("baseY"),
|
y: roundBasePointValue(readNumberInput("baseY")),
|
||||||
z: readNumberInput("baseZ"),
|
z: roundBasePointValue(readNumberInput("baseZ")),
|
||||||
rx: readNumberInput("baseRx"),
|
rx: degreesToRadians(readNumberInput("baseRx")),
|
||||||
ry: readNumberInput("baseRy"),
|
ry: degreesToRadians(readNumberInput("baseRy")),
|
||||||
rz: readNumberInput("baseRz")
|
rz: degreesToRadians(readNumberInput("baseRz"))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,6 +644,30 @@ function readNumberInput(name: string) {
|
|||||||
return Number.isFinite(numberValue) ? numberValue : 0;
|
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(
|
function bindImportScene(
|
||||||
model: ModelItem,
|
model: ModelItem,
|
||||||
operations: PreviewOperation[],
|
operations: PreviewOperation[],
|
||||||
|
|||||||
Reference in New Issue
Block a user