@nebula-spatial/cad-loader 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/README.md +56 -27
- package/dist/index.d.ts +9 -1
- package/dist/index.js +2797 -1632
- package/dist/loader/geo-loader.d.ts +3 -2
- package/dist/loader/internal/automatic-external-resources.d.ts +26 -0
- package/dist/loader/internal/geo-node.d.ts +22 -6
- package/dist/render-resource/cad-render-node.d.ts +71 -0
- package/dist/render-resource/geo-node-cad-render-node.d.ts +12 -0
- package/dist/selection/cad-text-selection.d.ts +31 -0
- package/dist/session/annotation-idle-gate.d.ts +14 -0
- package/dist/session/cad-document-session.d.ts +155 -0
- package/dist/session/cad-font-runtime.d.ts +11 -0
- package/dist/session/cad-insert-id.d.ts +6 -0
- package/dist/session/cad-text-warmup.d.ts +38 -0
- package/dist/session/create-cad-document-session.d.ts +5 -0
- package/dist/session/viewport-coverage.d.ts +32 -0
- package/package.json +2 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package are documented in this file.
|
|
4
|
+
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
- Added document-level CAD sessions with progressive content loading and viewport demand control.
|
|
8
|
+
- Added read-only CAD render resources, INSERT and text selection helpers, and CAD session metadata.
|
|
9
|
+
- Added public APIs for font resolution, document rendering, and scene annotations.
|
|
10
|
+
- Retained the existing `loadGeo()`, load session, and `core` APIs.
|
|
11
|
+
|
|
12
|
+
## 0.1.0
|
|
13
|
+
|
|
14
|
+
- Initial public release of the browser-side DXB3/DXBS CAD pack loader.
|
package/README.md
CHANGED
|
@@ -1,46 +1,75 @@
|
|
|
1
1
|
# @nebula-spatial/cad-loader
|
|
2
2
|
|
|
3
|
-
浏览器侧 DXB3/DXBS CAD pack
|
|
4
|
-
|
|
5
|
-
和 dispose 生命周期,并直接返回可挂载到 Three.js 场景的 `GeoNode`。
|
|
3
|
+
浏览器侧 DXB3/DXBS CAD pack 加载运行时。负责解析文档、构建 Three.js 渲染资源,并
|
|
4
|
+
提供图层、INSERT、文本和外部资源的文档级访问能力。
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
有完整视图需求的应用通常通过 `@nebula-spatial/viewer` 的 `viewer.cad.open()` 接入。
|
|
7
|
+
本包适用于需要自行管理 Three.js 场景或 CAD 文档生命周期的集成。
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
scene.add(node);
|
|
12
|
-
await node.ready;
|
|
13
|
-
```
|
|
9
|
+
## 文档会话
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
`createCadDocumentSession()` 是推荐的文档级入口。会话提供 header、基础内容就绪状态、
|
|
12
|
+
视口需求和只读渲染资源;调用方负责场景挂载和相机/视口同步。
|
|
17
13
|
|
|
18
14
|
```ts
|
|
19
15
|
import {
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
createCadDocumentSession,
|
|
17
|
+
getCadDocumentRenderResource,
|
|
22
18
|
} from '@nebula-spatial/cad-loader';
|
|
23
19
|
|
|
24
|
-
const
|
|
25
|
-
|
|
20
|
+
const session = createCadDocumentSession('/api/files/demo/result', {
|
|
21
|
+
filename: 'demo.dxf',
|
|
22
|
+
});
|
|
23
|
+
const renderNode = getCadDocumentRenderResource(session);
|
|
24
|
+
|
|
25
|
+
scene.add(renderNode.object);
|
|
26
|
+
const stopChanges = renderNode.onChange(() => requestRender());
|
|
27
|
+
|
|
28
|
+
const header = await session.headerReady;
|
|
29
|
+
fitCamera(header.bounds);
|
|
30
|
+
|
|
31
|
+
session.setDisplayContext(displayContext);
|
|
32
|
+
session.setViewportDemand(viewportDemand);
|
|
33
|
+
await session.initialContentReady;
|
|
34
|
+
|
|
35
|
+
stopChanges();
|
|
36
|
+
scene.remove(renderNode.object);
|
|
37
|
+
session.dispose();
|
|
26
38
|
```
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
`
|
|
30
|
-
`{ loadAnnotations: false }`。Product App 若要按视口渐进加载,应先使用
|
|
31
|
-
`ArrayBuffer` 和显式 sidecar 计划,再自行编排 annotation 的加载时机。
|
|
40
|
+
`headerReady` 提供文档边界和图层元数据,`initialContentReady` 表示基础内容已可用。
|
|
41
|
+
通过 `content-appended`、`demand-progress`、`phase-change` 和错误事件可监听后续变化。
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
`CadRenderNode` 是只读渲染资源。选择状态、属性面板、编辑命令和历史记录由产品层维护。
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
## 其他入口
|
|
46
|
+
|
|
47
|
+
- `loadGeo()`:简单的 `GeoNode` 增量加载。适合不需要文档会话的 Three.js 集成。
|
|
48
|
+
- `createLoadSession()`:以异步事件流消费 CAD pack,适合自定义渲染器或流量控制。
|
|
49
|
+
- `@nebula-spatial/cad-loader/core`:不依赖 Three.js、DOM 或 WebGL 的协议解析 API,可用于
|
|
50
|
+
Worker、Node.js 和 CLI。
|
|
37
51
|
|
|
38
52
|
```ts
|
|
39
|
-
import {
|
|
53
|
+
import { loadGeo } from '@nebula-spatial/cad-loader';
|
|
40
54
|
|
|
41
|
-
const
|
|
55
|
+
const node = loadGeo('/api/files/demo/result');
|
|
56
|
+
scene.add(node);
|
|
57
|
+
node.setViewportSize(canvas.clientWidth, canvas.clientHeight);
|
|
58
|
+
await node.ready;
|
|
42
59
|
```
|
|
43
60
|
|
|
44
|
-
默认 Worker
|
|
45
|
-
|
|
46
|
-
|
|
61
|
+
默认 Worker 使用包内 ESM 资源路径。使用非 Vite bundler 或自行托管 Worker 资源时,可通过
|
|
62
|
+
`LoadGeoOptions.workerUrl` 或 `workerFactory` 配置 Worker 创建方式。
|
|
63
|
+
|
|
64
|
+
## 边界
|
|
65
|
+
|
|
66
|
+
本包不处理上传、任务轮询、文件目录或原始 DXF/DWG 解析。运行时依赖为 `three` peer
|
|
67
|
+
dependency,要求 Node.js 18 或更高版本。
|
|
68
|
+
|
|
69
|
+
## 开发
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npm run typecheck --workspace @nebula-spatial/cad-loader
|
|
73
|
+
npm test --workspace @nebula-spatial/cad-loader
|
|
74
|
+
npm run build --workspace @nebula-spatial/cad-loader
|
|
75
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type { CadExternalVariantFetchSource, CadLoadErrorEvent, CadLoadEvent, Ca
|
|
|
10
10
|
export { appendExternalVariantDeltaToGeoNode, assertValidSourceOrThrow, loadExternalVariantDeltaFromBuffer, loadGeo, normalizeGeoError, parseBuffer, parseBufferBounds, parseBufferHeader, readBufferExternalAnnotationManifest, readBufferExternalBlockAnnotations, readBufferExternalVariantDependencyPlan, readBufferExternalVariantManifest, } from './loader/geo-loader';
|
|
11
11
|
export type { ExternalVariantDependencyOptions, ExternalVariantDependencyPlan, ExternalVariantFetchSource, LoadExternalVariantDeltaFetchSourceOptions, LoadExternalVariantDeltaOptions, LoadGeoOptions, } from './loader/geo-loader';
|
|
12
12
|
export { GEO_NODE_STRUCTURE_CHANGE, GEO_NODE_VISUAL_CHANGE, GeoNode, } from './loader/internal/geo-node';
|
|
13
|
-
export type { ColorPipelineStatsSnapshot, GeoNodeInternalChange, GeoNodeInternalChangeKind, InsertInstanceMatrix2D, } from './loader/internal/geo-node';
|
|
13
|
+
export type { ColorPipelineStatsSnapshot, GeoNodeChange, GeoNodeChangeKind, GeoNodeChangeListener, GeoNodeInternalChange, GeoNodeInternalChangeKind, InsertInstanceMatrix2D, } from './loader/internal/geo-node';
|
|
14
14
|
export type { LineMemoryStatsSnapshot, LineCanonicalMemoryStats, } from './loader/internal/line-canonical';
|
|
15
15
|
export { readBlockAnnotationSidecar, readSceneAnnotationSidecar, } from './core';
|
|
16
16
|
export type { DecodedAnnotationSidecar, DxbsContainer, DxbsSectionEntry, ParsedHeader, } from './core';
|
|
@@ -24,3 +24,11 @@ export type { BlockGeometryKind, VariantGeometry, } from './scene/instancing/blo
|
|
|
24
24
|
export type { InsertInstanceRecord } from './scene/instancing/insert-instance-table';
|
|
25
25
|
export { cadInsertSelectionEquals, pickCadInsertAtPoint, resolveCadInsertDetails, } from './selection/cad-insert-selection';
|
|
26
26
|
export type { CadInsertDetails, CadInsertPickOptions, CadInsertSelectionId, CadPoint2D, } from './selection/cad-insert-selection';
|
|
27
|
+
export { cadTextSelectionEquals, pickCadTextAtPoint, resolveCadTextDetails, } from './selection/cad-text-selection';
|
|
28
|
+
export type { CadTextDetails, CadTextPickOptions, CadTextSelection, CadTextSelectionId, } from './selection/cad-text-selection';
|
|
29
|
+
export { CAD_SESSION_PHASES } from './session/cad-document-session';
|
|
30
|
+
export { createCadDocumentSession, getCadDocumentRenderResource } from './session/create-cad-document-session';
|
|
31
|
+
export { formatCadInsertId, parseCadInsertId } from './session/cad-insert-id';
|
|
32
|
+
export type { CadDisplayContext, CadDocumentHeader, CadDocumentSession, CadDocumentSessionOptions, CadFontResolver, CadInsertUsageSummary, CadLayerMeta, CadSessionEventMap, CadSessionPhase, CadViewportDemand, CadViewportRect, CadVisibilityFilter, CadWorldBounds, CadWorldPoint, } from './session/cad-document-session';
|
|
33
|
+
export { CAD_RENDER_NODE_EDIT_METHODS, isCadRenderNodeEditMethod } from './render-resource/cad-render-node';
|
|
34
|
+
export type { CadInsertPreviewResource, CadRenderContentChunk, CadRenderNode, } from './render-resource/cad-render-node';
|