@file-viewer/geometry-engine 3.2.0 → 3.2.2

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.
Files changed (3) hide show
  1. package/README.en.md +40 -3
  2. package/README.md +40 -3
  3. package/package.json +1 -1
package/README.en.md CHANGED
@@ -1,7 +1,44 @@
1
1
  # @file-viewer/geometry-engine
2
2
 
3
- Runtime package version 3.2.0.
3
+ Framework-neutral, UI-free geometry kernel for Flyfish File Viewer. It now decodes STEP / STP, IGES / IGS, and BREP directly in the browser: OCCT tessellation runs in a local worker, with no upload or server-side conversion. IFC and Rhino 3DM currently provide signature detection and accurate capability notices only; their full geometry renderers are not wired yet.
4
4
 
5
- Usage and API documentation: https://doc.file-viewer.app/guide/format-fidelity
5
+ ```ts
6
+ import { importOcctGeometryFile } from '@file-viewer/geometry-engine'
6
7
 
7
- The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
8
+ const result = await importOcctGeometryFile(buffer, 'step', {
9
+ workerUrl: '/viewer-assets/wasm/model/occt-worker.js',
10
+ runtimeUrl: '/viewer-assets/wasm/model/occt-import-js.js',
11
+ wasmUrl: '/viewer-assets/wasm/model/occt-import-js.wasm',
12
+ params: {
13
+ linearUnit: 'millimeter',
14
+ linearDeflectionType: 'bounding_box_ratio',
15
+ linearDeflection: 0.001,
16
+ angularDeflection: 0.5,
17
+ },
18
+ })
19
+ ```
20
+
21
+ `result` contains the OCCT assembly hierarchy, meshes, normals, indices, and face colors for conversion into Three.js or another rendering layer. Parsing uses a one-shot worker by default and transfers both source bytes and mesh buffers. The worker is released after success, cancellation, failure, or timeout. `timeoutMs` defaults to 120 seconds. Set `useWorker: false` only when workers are genuinely unavailable, because that fallback parses on the main thread.
22
+
23
+ ## Offline Assets
24
+
25
+ The runtime never falls back to a CDN. Deploy these files with the viewer:
26
+
27
+ - `wasm/model/occt-worker.js`
28
+ - `wasm/model/occt-import-js.js`
29
+ - `wasm/model/occt-import-js.wasm`
30
+ - `wasm/model/LICENSE.occt.txt`
31
+ - `wasm/model/LICENSE.occt-import-js.txt`
32
+
33
+ `@file-viewer/vite-plugin`, full packages, and the repository build scripts copy these assets. A bare package integration must self-host them and provide `workerUrl`, `runtimeUrl`, and `wasmUrl`. For subpath deployments, asset domains, or controlled gateways, pass final absolute URLs or correctly prefixed URLs instead of relying on the site root.
34
+
35
+ A strict CSP must at least allow the asset origin in `worker-src`, `script-src`, and `connect-src` for the WASM fetch; some browsers also require `script-src 'wasm-unsafe-eval'` to compile WebAssembly. The classic worker loads the local runtime with `importScripts()`, so allowing only the WASM file is not sufficient.
36
+
37
+ ## Boundaries
38
+
39
+ - `inspectGeometryKernelFile()` still offers prefix-only detection for common STEP / IGES / IFC / 3DM / BREP signatures.
40
+ - STEP / STP, IGES / IGS, and BREP use `occt-import-js` / OpenCascade and have a complete mesh-preview path.
41
+ - IFC still needs a dedicated `web-ifc` / That Open integration; 3DM still needs McNeel `rhino3dm`. Neither format is presented as fully previewable yet.
42
+ - The OCCT and `occt-import-js` license notices must ship with the offline assets.
43
+
44
+ Keeping this heavy path in a separate package lets `@file-viewer/core` stay small while worker, WASM, licensing, and real engineering-file regressions remain independently maintainable.
package/README.md CHANGED
@@ -1,7 +1,44 @@
1
1
  # @file-viewer/geometry-engine
2
2
 
3
- Runtime package version 3.2.0.
3
+ Flyfish File Viewer 的无 UI、框架无关几何内核包。它已经提供浏览器原生的 STEP / STP、IGES / IGS 和 BREP 解析:文件在本地 OCCT Worker 中完成三角化,不需要上传或服务端转换。IFC 和 Rhino 3DM 目前只提供格式识别与准确的能力提示,尚未接入完整几何渲染。
4
4
 
5
- Usage and API documentation: https://doc.file-viewer.app/guide/format-fidelity
5
+ ```ts
6
+ import { importOcctGeometryFile } from '@file-viewer/geometry-engine'
6
7
 
7
- The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
8
+ const result = await importOcctGeometryFile(buffer, 'step', {
9
+ workerUrl: '/viewer-assets/wasm/model/occt-worker.js',
10
+ runtimeUrl: '/viewer-assets/wasm/model/occt-import-js.js',
11
+ wasmUrl: '/viewer-assets/wasm/model/occt-import-js.wasm',
12
+ params: {
13
+ linearUnit: 'millimeter',
14
+ linearDeflectionType: 'bounding_box_ratio',
15
+ linearDeflection: 0.001,
16
+ angularDeflection: 0.5,
17
+ },
18
+ })
19
+ ```
20
+
21
+ `result` 包含 OCCT 输出的装配层级、网格、法线、索引和面颜色信息,可继续转换为 Three.js 或其他渲染对象。解析默认在一次性 Worker 中执行,文件字节和网格缓冲区使用 transferable 传递;完成、取消、报错或超时后 Worker 都会释放。`timeoutMs` 默认是 120 秒。只有 Worker 确实不可用时才建议设置 `useWorker: false`,因为回退会占用主线程。
22
+
23
+ ## 离线资产
24
+
25
+ 运行时不访问 CDN。部署时需要把下列文件放到同一套静态资源中:
26
+
27
+ - `wasm/model/occt-worker.js`
28
+ - `wasm/model/occt-import-js.js`
29
+ - `wasm/model/occt-import-js.wasm`
30
+ - `wasm/model/LICENSE.occt.txt`
31
+ - `wasm/model/LICENSE.occt-import-js.txt`
32
+
33
+ `@file-viewer/vite-plugin`、full 包和仓库构建脚本会复制这些资产。直接集成本包时,需要自行托管并传入 `workerUrl`、`runtimeUrl` 和 `wasmUrl`。应用部署在子路径、资源域名或受控网关下时,请传入最终可访问的绝对 URL 或带前缀 URL,不要依赖站点根路径。
34
+
35
+ 严格 CSP 至少应允许资产来源出现在 `worker-src`、`script-src` 和用于获取 WASM 的 `connect-src` 中;部分浏览器还要求 `script-src 'wasm-unsafe-eval'` 才能编译 WebAssembly。Worker 使用本地 `importScripts()` 加载 runtime,因此不要只放行 WASM 而漏掉 runtime 脚本。
36
+
37
+ ## 能力边界
38
+
39
+ - `inspectGeometryKernelFile()` 仍可只读取文件前缀,识别 STEP / IGES / IFC / 3DM / BREP 常见签名。
40
+ - STEP / STP、IGES / IGS 和 BREP 走 `occt-import-js` / OpenCascade,已经具备完整网格预览路径。
41
+ - IFC 仍需要独立的 `web-ifc` / That Open 集成;3DM 仍需要 McNeel `rhino3dm` 集成。当前不会把它们伪装成已支持预览。
42
+ - OCCT 与 `occt-import-js` 的许可证文件必须随离线资产一起分发。
43
+
44
+ 把重型几何能力留在独立包中,可以让 `@file-viewer/core` 保持轻量,同时隔离 Worker、WASM、许可证和真实工程样本回归边界。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@file-viewer/geometry-engine",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Framework-neutral geometry kernel boundary package for STEP, IGES, IFC, 3DM, and BREP preview routes in File Viewer.",