fix: close final viewer integration gaps (#5)
This commit is contained in:
@@ -23,8 +23,8 @@
|
||||
import {
|
||||
createViewer2D,
|
||||
isCad2DFile,
|
||||
parseCad,
|
||||
type CadParseResult,
|
||||
loadCad,
|
||||
type CadLoadSummary,
|
||||
} from '@hmwebviewer/viewer2d';
|
||||
import {
|
||||
assertCadByteLength,
|
||||
@@ -71,11 +71,8 @@ viewer.onSelect((entity: unknown) => {
|
||||
});
|
||||
|
||||
// ── ④ 파서 조합 ─────────────────────────────────────────────────
|
||||
async function loadAndRender(buf: ArrayBuffer, name: string): Promise<CadParseResult> {
|
||||
const result = await parseCad({ data: buf, name });
|
||||
viewer.load(result);
|
||||
viewer.resize();
|
||||
return result;
|
||||
async function loadAndRender(buf: ArrayBuffer, name: string): Promise<CadLoadSummary> {
|
||||
return loadCad(viewer, { data: buf, name });
|
||||
}
|
||||
|
||||
async function loadUrl(url: string, nameHint?: string) {
|
||||
@@ -117,13 +114,13 @@ function fillLayers() {
|
||||
}
|
||||
}
|
||||
|
||||
async function afterLoad(name: string, result: CadParseResult) {
|
||||
setStatus(`✓ ${name} · ${result.entities?.length ?? 0} entities`);
|
||||
async function afterLoad(name: string, result: CadLoadSummary) {
|
||||
setStatus(`✓ ${name} · ${result.entityCount} entities`);
|
||||
fillLayers();
|
||||
viewer.fit();
|
||||
}
|
||||
|
||||
async function run(label: string, job: () => Promise<CadParseResult>) {
|
||||
async function run(label: string, job: () => Promise<CadLoadSummary>) {
|
||||
setStatus(`loading ${label}…`);
|
||||
try {
|
||||
await afterLoad(label, await job());
|
||||
|
||||
Reference in New Issue
Block a user