feat(viewer2d): 2.5D view, viewport fill transform and Z-aware fit box

- 2.5D view: a toolbar toggle (plus an options-panel checkbox) re-aims the
  orthographic camera at an SE-isometric angle and unlocks orbit, so the
  CAD elevation already in the vertex buffers (contours, TIN, 3D
  polylines) becomes visible. Nothing is re-tessellated; switching back
  restores the locked top view. A Z exaggeration slider (persisted in the
  options store) makes kilometre-wide sheets with metres of relief
  legible; picking and the X/Y readout intersect the Z=0 plane.
- Viewport fills: SOLID/HATCH fills and dimension arrowheads drawn
  through a paper-space VIEWPORT now get the model-to-paper transform
  (_fillXf / _bakeFillXf), as lines already did via pushSeg.
- The trimmed content box keeps the drawing's real Z range instead of
  collapsing to z=0, so the 2.5D fit and clip slab cover the relief.
- src/topProgress.ts: driver for the existing #progress loading bar. It
  is not imported from main.ts yet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minsungandClaude Opus 5.5 committed 2026-10-19 19:48:19 +09:00
1 parent e51114dbfd
commit aa27945d61
5 files changed
+477 -4

No files matched your search

+36
View File
@@ -231,6 +231,7 @@ document.getElementById('theme')!.addEventListener('click', () => {
viewer.setTheme(dark);
fillLayers();
});
// ── 옵션 패널 ────────────────────────────────────────────────────
// 값은 IndexedDB(hmw-viewer/options)에 남는다. 선가중치 배율은 재파싱 없이
// 즉시 반영되므로 드래그하면서 화면을 보고 맞출 수 있다.
@@ -242,6 +243,10 @@ const optLwOut = document.getElementById('optLwOut')!;
const optGrid = document.getElementById('optGrid') as HTMLInputElement;
const optZoomSpeed = document.getElementById('optZoomSpeed') as HTMLInputElement;
const optZoomSpeedNum = document.getElementById('optZoomSpeedNum') as HTMLInputElement;
const opt25D = document.getElementById('opt25D') as HTMLInputElement;
const optZRow = document.getElementById('optZRow')!;
const optZScale = document.getElementById('optZScale') as HTMLInputElement;
const optZScaleNum = document.getElementById('optZScaleNum') as HTMLInputElement;
makePanelDraggableAndCollapsible(optionsPanel, {
collapseBtnEl: document.getElementById('collapseOptBtn')!,
@@ -295,11 +300,41 @@ function applyZoomSpeed(v: number, persist = true) {
optZoomSpeed.addEventListener('input', () => applyZoomSpeed(parseFloat(optZoomSpeed.value)));
optZoomSpeedNum.addEventListener('input', () => applyZoomSpeed(parseFloat(optZoomSpeedNum.value)));
// ── 2.5D 보기 토글 ───────────────────────────────────────────────
// Top 뷰를 풀고 남동 등각(SE Isometric)으로 기울인다. 도면 정점은 이미 CAD
// 표고(Z)를 갖고 있으므로 재파싱·재생성 없이 카메라만 돌리면 등고선 같은
// 높낮이가 그대로 드러난다. 다시 누르면 원래 Top 뷰(회전 잠금)로 돌아온다.
// 뷰 상태라 IndexedDB 에 저장하지 않는다 — Z 과장 배율만 저장한다.
const view25Btn = document.getElementById('view25Btn')!;
function apply25D(on: boolean) {
viewer.set25D(on);
view25Btn.classList.toggle('on', on);
view25Btn.textContent = on ? '2.5D 보기 ✓' : '2.5D 보기';
opt25D.checked = on;
optZRow.classList.toggle('disabled', !on);
setStatus(on ? '2.5D 보기 · 왼쪽 드래그=회전, 가운데·오른쪽 드래그=이동' : 'Top 뷰');
}
view25Btn.addEventListener('click', () => apply25D(!viewer.is25D()));
opt25D.addEventListener('change', () => apply25D(opt25D.checked));
function applyZScale(v: number, persist = true) {
if (!Number.isFinite(v) || v <= 0) return;
viewer.setZScale(v);
optZScale.value = String(v);
optZScaleNum.value = String(v);
if (persist) void setOption('zScale', v);
}
optZScale.addEventListener('input', () => applyZScale(parseFloat(optZScale.value)));
optZScaleNum.addEventListener('input', () => applyZScale(parseFloat(optZScaleNum.value)));
document.getElementById('optReset')!.addEventListener('click', () => {
viewer.setLineweightScale(null); // 뷰어 기본 배율
viewer.setLineweightEnabled(null); // 도면의 LWDISPLAY 를 다시 따름
viewer.setGrid(false);
applyZoomSpeed(1);
applyZScale(1);
apply25D(false);
optGrid.checked = false;
void setOption('lineweightScale', null);
void setOption('lineweightOn', null);
@@ -313,6 +348,7 @@ void getAllOptions().then((o) => {
if (typeof o.lineweightOn === 'boolean') viewer.setLineweightEnabled(o.lineweightOn);
if (o.grid === true) { viewer.setGrid(true); optGrid.checked = true; }
if (typeof o.zoomSpeed === 'number') applyZoomSpeed(o.zoomSpeed, false);
if (typeof o.zScale === 'number') applyZScale(o.zScale, false);
syncOptions();
});
syncOptions();