@whdigitalbuild/ifc-viewer-core 0.0.0-stage → 1.0.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.
Files changed (92) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/NOTICE.md +26 -0
  3. package/README.md +181 -2
  4. package/THIRD_PARTY_LICENSES.txt +15130 -0
  5. package/dist/4d/index.d.ts +7 -0
  6. package/dist/4d/index.d.ts.map +1 -0
  7. package/dist/4d/index.js +520 -0
  8. package/dist/4d/mapping.d.ts +12 -0
  9. package/dist/4d/mapping.d.ts.map +1 -0
  10. package/dist/4d/match.d.ts +33 -0
  11. package/dist/4d/match.d.ts.map +1 -0
  12. package/dist/4d/overlay.d.ts +24 -0
  13. package/dist/4d/overlay.d.ts.map +1 -0
  14. package/dist/4d/parse.d.ts +29 -0
  15. package/dist/4d/parse.d.ts.map +1 -0
  16. package/dist/4d/status.d.ts +28 -0
  17. package/dist/4d/status.d.ts.map +1 -0
  18. package/dist/4d/types.d.ts +33 -0
  19. package/dist/4d/types.d.ts.map +1 -0
  20. package/dist/clash/engine.d.ts +44 -0
  21. package/dist/clash/engine.d.ts.map +1 -0
  22. package/dist/clash/index.d.ts +5 -0
  23. package/dist/clash/index.d.ts.map +1 -0
  24. package/dist/clash/index.js +342 -0
  25. package/dist/clash/overlay.d.ts +12 -0
  26. package/dist/clash/overlay.d.ts.map +1 -0
  27. package/dist/clash/prepare.d.ts +56 -0
  28. package/dist/clash/prepare.d.ts.map +1 -0
  29. package/dist/compare/compare.d.ts +52 -0
  30. package/dist/compare/compare.d.ts.map +1 -0
  31. package/dist/compare/index.d.ts +3 -0
  32. package/dist/compare/index.d.ts.map +1 -0
  33. package/dist/compare/index.js +715 -0
  34. package/dist/compare/overlay.d.ts +46 -0
  35. package/dist/compare/overlay.d.ts.map +1 -0
  36. package/dist/events.d.ts +10 -0
  37. package/dist/events.d.ts.map +1 -0
  38. package/dist/explode/Explode.d.ts +115 -0
  39. package/dist/explode/Explode.d.ts.map +1 -0
  40. package/dist/explode/LevelExplode.d.ts +57 -0
  41. package/dist/explode/LevelExplode.d.ts.map +1 -0
  42. package/dist/explode/index.d.ts +3 -0
  43. package/dist/explode/index.d.ts.map +1 -0
  44. package/dist/extensions/BaseExtension.d.ts +24 -0
  45. package/dist/extensions/BaseExtension.d.ts.map +1 -0
  46. package/dist/extensions/ExtensionManager.d.ts +26 -0
  47. package/dist/extensions/ExtensionManager.d.ts.map +1 -0
  48. package/dist/extensions/index.d.ts +3 -0
  49. package/dist/extensions/index.d.ts.map +1 -0
  50. package/dist/extensions/index.js +59 -0
  51. package/dist/index.d.ts +12 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +3459 -0
  54. package/dist/loading/LoadingOverlay.d.ts +41 -0
  55. package/dist/loading/LoadingOverlay.d.ts.map +1 -0
  56. package/dist/loading/brand.d.ts +6 -0
  57. package/dist/loading/brand.d.ts.map +1 -0
  58. package/dist/model/element.d.ts +23 -0
  59. package/dist/model/element.d.ts.map +1 -0
  60. package/dist/model/geometry-registry.d.ts +33 -0
  61. package/dist/model/geometry-registry.d.ts.map +1 -0
  62. package/dist/model/index.d.ts +3 -0
  63. package/dist/model/index.d.ts.map +1 -0
  64. package/dist/tools/HoverTool.d.ts +29 -0
  65. package/dist/tools/HoverTool.d.ts.map +1 -0
  66. package/dist/tools/MeasureTool.d.ts +75 -0
  67. package/dist/tools/MeasureTool.d.ts.map +1 -0
  68. package/dist/tools/NavigationTool.d.ts +63 -0
  69. package/dist/tools/NavigationTool.d.ts.map +1 -0
  70. package/dist/tools/SectionTool.d.ts +66 -0
  71. package/dist/tools/SectionTool.d.ts.map +1 -0
  72. package/dist/tools/SelectTool.d.ts +31 -0
  73. package/dist/tools/SelectTool.d.ts.map +1 -0
  74. package/dist/tools/ToolController.d.ts +115 -0
  75. package/dist/tools/ToolController.d.ts.map +1 -0
  76. package/dist/tools/defaults.d.ts +51 -0
  77. package/dist/tools/defaults.d.ts.map +1 -0
  78. package/dist/tools/index.d.ts +9 -0
  79. package/dist/tools/index.d.ts.map +1 -0
  80. package/dist/tools/overlay.d.ts +5 -0
  81. package/dist/tools/overlay.d.ts.map +1 -0
  82. package/dist/ui/index.d.ts +3 -0
  83. package/dist/ui/index.d.ts.map +1 -0
  84. package/dist/ui/properties.d.ts +18 -0
  85. package/dist/ui/properties.d.ts.map +1 -0
  86. package/dist/ui/widgets.d.ts +92 -0
  87. package/dist/ui/widgets.d.ts.map +1 -0
  88. package/dist/viewer/IfcViewer.d.ts +250 -0
  89. package/dist/viewer/IfcViewer.d.ts.map +1 -0
  90. package/dist/viewer/render-geometry.d.ts +8 -0
  91. package/dist/viewer/render-geometry.d.ts.map +1 -0
  92. package/package.json +94 -4
package/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 — 2026-12-03
4
+ First public release of `@whdigitalbuild/ifc-viewer-core`.
5
+
6
+ - `IfcViewer`: WebGPU (ifc-lite renderer 8.0.0) with WebGL fallback, streaming load, overlays, section, camera API,
7
+ home view, hover outline, orbit pivot, performance profile (LOD, contribution culling, quantized vertices).
8
+ - Tools: `ToolController`, `NavigationTool` (presets `ifclite`, `revit`, `aps`, `cad`), `SelectTool`, `HoverTool`,
9
+ `MeasureTool`, `SectionTool`, `setupDefaultTools`; custom tools via the `ViewerTool` interface.
10
+ - Explode: `LevelExplode` (per-level GPU layers, smooth) and `Explode` (per element).
11
+ - UI widgets (framework-free): `Toolbar`, `PropertiesPanel`, `FloatingPanel`, `elementProperties()`.
12
+ - `LoadingOverlay` with the WohHup mark; `ExtensionManager` / `BaseExtension`.
13
+ - Subpaths: `/4d` (schedule parse, match, status, overlay), `/clash`, `/compare`, `/extensions`.
package/NOTICE.md ADDED
@@ -0,0 +1,26 @@
1
+ # Notices
2
+
3
+ `@whdigitalbuild/ifc-viewer-core` — Copyright (c) Woh Hup (Pte) Ltd.
4
+
5
+ ## Third-party software
6
+
7
+ This package depends on, and an app that bundles it will ship, the following open-source software.
8
+ The full licence texts of every production dependency are in `THIRD_PARTY_LICENSES.txt`
9
+ (regenerate with `npm run licenses`).
10
+
11
+ | Component | Licence | Source |
12
+ | --- | --- | --- |
13
+ | `@ifc-lite/*` (renderer, geometry, cache, data, diff, clash, bcf, wasm, …) | MPL-2.0 | https://github.com/LTplus-AG/ifc-lite |
14
+ | `three` | MIT | https://github.com/mrdoob/three.js |
15
+ | Rust crates and Emscripten runtime compiled into `@ifc-lite/wasm` | MIT / Apache-2.0 / BSD / Zlib and similar permissive licences | see `node_modules/@ifc-lite/wasm/THIRD_PARTY_NOTICES.txt` |
16
+ | `jszip` | MIT (elected from "MIT OR GPL-3.0-or-later") | https://github.com/Stuk/jszip |
17
+
18
+ ### MPL-2.0 source availability
19
+
20
+ The `@ifc-lite/*` packages are used **unmodified**. Their source code, under MPL-2.0, is available at
21
+ https://github.com/LTplus-AG/ifc-lite (use the tag matching the versions pinned in `package.json`).
22
+ Apps that distribute this package (including serving it to browsers) must keep this notice, or an
23
+ equivalent one, reachable by their users — for example on an "About / Open-source licences" page.
24
+
25
+ If any `@ifc-lite/*` file is ever patched (e.g. with `patch-package`), the patched files must be
26
+ published under MPL-2.0. WohHup's own code that merely uses these packages is not affected.
package/README.md CHANGED
@@ -1,3 +1,182 @@
1
- # Temporary Holding Version
1
+ # @whdigitalbuild/ifc-viewer-core
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Framework-agnostic 3D viewer for IFC Lite models exported from Revit with **Export IFC Lite**.
4
+ WebGPU through `@ifc-lite/renderer`, with an automatic WebGL (three.js) fallback. No bundled UI:
5
+ host apps build their own model tree, properties panel and toolbar, and drive the viewer through
6
+ its API.
7
+
8
+ Full documentation (Vietnamese): **Tài liệu sử dụng thư viện** —
9
+ https://claude.ai/artifact/UxpYrnh2rYPrmGqSeByvu3
10
+
11
+ ## What's in the box (1.0)
12
+
13
+ | Import | What |
14
+ | --- | --- |
15
+ | `IfcViewer` (alias `IfcViewport`) | Streaming load, camera, picking, snapping, section box/plane, colour/alpha/hide/ghost overlays |
16
+ | `prepareRenderGeometry`, `GeometryRegistry`, `ElementRow` | Batch preparation (run in your loader worker) and a per-element world-geometry index for analyses |
17
+ | `LoadingOverlay` | "Powered by WohHup" loading screen |
18
+ | `BaseExtension`, `ExtensionManager` (also `/extensions`) | APS-Viewer-style custom tools |
19
+ | `/4d` | Read a programme (.xlsx/.csv/.txt), map columns, match tasks to elements, day status, `buildFourDOverlay` |
20
+ | `/clash` | `prepareClash` → worker (`installClashWorker`) → `toFindings`, `clashOverlay`, `clashFocusOverlay` |
21
+ | `/compare` | `loadModelGeometry`, `compareModels`, `baseGhostMeshes`, `compareOverlay`, `compareFocus` |
22
+
23
+ None of the subpaths ship UI: the dashboard's `ClashPanel`, `ComparePanel` and `SchedulePanel` are reference UIs.
24
+
25
+ ### Host-app setup for the subpaths
26
+
27
+ - **4D, Excel import**: `readScheduleFile` loads `exceljs` on demand. Install it (`exceljs@^4`, optional peer
28
+ dependency) if you import .xlsx; CSV/TXT need nothing.
29
+ - **Clash**: create a worker file in your app and point it at the engine:
30
+ ```ts
31
+ // clash.worker.ts
32
+ import {installClashWorker} from '@whdigitalbuild/ifc-viewer-core/clash';
33
+ installClashWorker();
34
+ ```
35
+ then `new Worker(new URL('./clash.worker.ts', import.meta.url), {type: 'module'})`, post
36
+ `prepared.request` with `prepared.transfer`, and read `ClashReply` messages.
37
+ - **Compare**: `@ifc-lite/diff` imports `node:fs/promises` on its Node path. Stub it in the browser build,
38
+ e.g. rsbuild/rspack: `new rspack.NormalModuleReplacementPlugin(/^node:fs\/promises$/, 'src/node-fs-stub.ts')`
39
+ with `export const readFile = () => { throw new Error('no fs'); };`. `loadModelGeometry` drives your model
40
+ loader worker (same protocol as the dashboard's `cache.worker.ts`).
41
+
42
+ ## Tools, Explode and UI widgets
43
+
44
+ Everything below is in the main entry (`@whdigitalbuild/ifc-viewer-core`). Each piece is optional and replaceable.
45
+
46
+ ### Built-in tools in one call
47
+
48
+ ```ts
49
+ import {IfcViewer,setupDefaultTools,Explode} from '@whdigitalbuild/ifc-viewer-core';
50
+ const viewer=new IfcViewer(canvas);await viewer.init();
51
+ const explode=new Explode(viewer);
52
+ const t=setupDefaultTools(viewer,{
53
+ navigation:{preset:'revit'}, // 'revit' | 'aps' | 'cad' | your own bindings
54
+ select:{onPick:hit=>mySelect(hit?.expressId),onContextMenu:(hit,e)=>openMenu(e.clientX,e.clientY,hit)},
55
+ section:{initialBounds:()=>selectionBounds()},
56
+ toolbar:{position:'bottom-center',explode}, // or false and build your own buttons
57
+ });
58
+ t.controller.setMode('measure'); // 'measure' | 'section' | undefined (select)
59
+ viewer.setHomeView({position:[50,40,50],target:[0,0,0]}); viewer.home();
60
+ ```
61
+
62
+ Selection state stays in your app: pass `selectedIds` to `viewer.render()`. Tools call `viewer.requestRender()`; your loop's `update()` returns true on the next frame.
63
+
64
+ ### Your own tools
65
+
66
+ ```ts
67
+ import type {ViewerTool} from '@whdigitalbuild/ifc-viewer-core';
68
+ const pinTool:ViewerTool={name:'pin',exclusive:true,priority:60,cursor:'copy',
69
+ async click(e){const p=await viewer.surfacePoint(e.x,e.y,true);if(p)addPin(p);return true;}, // true = consumed
70
+ keyDown(e){if(e.key==='Escape'){t.controller.setMode(undefined);return true;}}};
71
+ t.controller.register(pinTool); t.controller.setMode('pin');
72
+ ```
73
+
74
+ Hooks: `activate`, `deactivate`, `pointerDown/Move/Up`, `click`, `doubleClick`, `wheel`, `keyDown`, `dispose`. Higher `priority` sees input first; `exclusive` tools are modes. Follow the camera with `viewer.events.on('render',…)` and `viewer.screenOf(p)`. Built-in tools are classes too (`NavigationTool`, `SelectTool`, `MeasureTool`, `SectionTool`): subclass, reconfigure (`tool.options…`) or unregister and replace them.
75
+
76
+ ### Explode (like Autodesk.Explode)
77
+
78
+ ```ts
79
+ const explode=new Explode(viewer,{
80
+ mode:'radial', // 'radial' | 'levels' (stack storeys) | 'custom'
81
+ groupBy:id=>rows.get(id)?.category, // elements in a group move together (level, category, link…)
82
+ axisWeights:[1,0,1], // horizontal only; [0,1,0] vertical only
83
+ magnitude:1.5, center:'model', // or a point / function
84
+ exclude:id=>isSite(id), ids:()=>visibleIds(),
85
+ offset:ctx=>ctx.key==='Roofs'?[0,20,0]:undefined, // override any group's vector
86
+ curve:s=>s*s, duration:300, easing:t=>t,
87
+ });
88
+ explode.setScale(0.6); explode.events.on('change',e=>slider.value=e.scale); explode.reset();
89
+ ```
90
+
91
+ Also as an extension: `ExtensionManager.register('explode',ExplodeExtension)`. Low level: `viewer.translateElements(Map<id,[dx,dy,dz]>)`, `viewer.elementBounds(id)`, `viewer.elementIds()`.
92
+
93
+ ### Properties (or any panel) anywhere
94
+
95
+ `elementProperties(row, registry)` returns plain groups: render them in React/Vue/Angular, a tooltip, a table, another tab. Or use the framework-free widgets and mount them into any element:
96
+
97
+ ```ts
98
+ const win=new FloatingPanel({title:'Properties',x:40,y:80,width:320,height:400}); // draggable, resizable
99
+ const props=new PropertiesPanel(win.body,{storageKey:'my-props',renderValue:(v,k)=>k==='GlobalId'?myLink(v):undefined});
100
+ props.show(elementProperties(row,registry),row.name,row.category);
101
+ new PropertiesPanel(document.querySelector('#sidebar')!); // or docked anywhere
102
+ const bar=new Toolbar(viewer.container,{position:'top-right',orientation:'vertical'});
103
+ bar.addButton({id:'pin',label:'Pin',icon:'<svg…/>',onClick:()=>t.controller.toggle('pin'),isActive:()=>t.controller.isActive('pin')});
104
+ ```
105
+
106
+ Styling: every element has an `ifcv-*` class and colours come from CSS variables (`--ifcv-bg`, `--ifcv-fg`, `--ifcv-accent`, `--ifcv-measure-color`, `--ifcv-section-color`, `--ifcv-layer-z`, …).
107
+
108
+ ## Quick start
109
+
110
+ ```ts
111
+ import { IfcViewer, prepareRenderGeometry, type Options } from '@whdigitalbuild/ifc-viewer-core';
112
+ import { BinaryCacheReader } from '@ifc-lite/cache';
113
+
114
+ const viewer = new IfcViewer(canvas);
115
+ await viewer.init();
116
+ let options: Options = { hiddenIds: new Set(), selectedIds: new Set() }, dirty = true, last = performance.now();
117
+ const tick = (now: number) => {
118
+ if (viewer.update(Math.min((now - last) / 1000, 0.1)) || dirty) { viewer.render(options); dirty = false; }
119
+ last = now; requestAnimationFrame(tick);
120
+ };
121
+ requestAnimationFrame(tick);
122
+
123
+ const { geometry } = await new BinaryCacheReader().read(await (await fetch(url)).arrayBuffer());
124
+ viewer.begin();
125
+ viewer.load(prepareRenderGeometry(geometry!), true);
126
+ viewer.finish(); // REQUIRED — also on cancel and on error
127
+ viewer.fit(); dirty = true;
128
+ ```
129
+
130
+ For large models, decode in a Web Worker and stream batches; the dashboard's
131
+ `src/ifclite/cache.worker.ts` is the reference implementation.
132
+
133
+ ## Rules that matter
134
+
135
+ - **Always call `finish()`** when a load ends (done, cancelled or failed). Renderer 8 draws streamed
136
+ geometry from temporary fragments; without `finish()`, the first overlay (Compare, 4D, ghost)
137
+ drops every unfinalized fragment — tens of thousands of elements disappear. Covered by
138
+ `tests/viewer-streaming.test.ts`.
139
+ - `Options` is compared by reference: build new `Set`/`Map` objects instead of mutating.
140
+ - Coordinates are viewer frame (metres, Y up). Revit `(x, y, z)` → viewer `(x, z, -y)`.
141
+ - `@ifc-lite/*` versions are pinned exactly. The viewer relies on renderer internals
142
+ (instanced flattening, streaming finalization, opaque canvas). Bump them only after loading the
143
+ WHP federated model, running Compare and a 4D overlay, and comparing the images.
144
+
145
+ ## Develop
146
+
147
+ This folder uses **npm** (it has a `package-lock.json`).
148
+
149
+ | Command | Does |
150
+ | --- | --- |
151
+ | `npm run build` | rslib → `dist/` (ESM + `.d.ts`) |
152
+ | `npm test` | vitest: streaming/flattening regression, 4D parse/match/overlay, real clash and diff runs, extensions, loading overlay |
153
+ | `npm run typecheck` | `tsc --noEmit` |
154
+ | `npm run licenses` | Regenerates `THIRD_PARTY_LICENSES.txt` |
155
+ | `npm pack` | Runs typecheck + tests + build + licenses, then writes the `.tgz` |
156
+
157
+ ## Publish
158
+
159
+ The `@whdigitalbuild` scope lives on the public npm registry (npmjs.com), alongside
160
+ `@whdigitalbuild/forge-viewer-core` and `@whdigitalbuild/react-base-wh`. This package follows the
161
+ same setup: **public**, MIT.
162
+
163
+ **CI/CD (normal path):** `.github/workflows/cicd_publish_ifc_viewer_library.yml`.
164
+ Pull requests that touch `ifc_viewer_library/packages/core/**` run typecheck, tests, build, licence
165
+ report and a pack dry run. A push to `main` runs the same checks and then publishes with the
166
+ `NPM_TOKEN` secret (environment `production`) — only if that `version` is not on npm yet.
167
+
168
+ So, to release: bump `version` in `package.json` (semver: fix → patch, new API → minor, breaking →
169
+ major), run `npm install --package-lock-only` so `package-lock.json` matches, open a PR, merge to `main`.
170
+
171
+ Manual publish (fallback): `npm login` with a `whdigitalbuild` org member (or `.npmrc.example` →
172
+ `.npmrc` + `NPM_TOKEN`), then `npm publish` (runs typecheck, tests, build and licences first).
173
+
174
+ Consuming apps then depend on `"@whdigitalbuild/ifc-viewer-core": "^1.0.0"` with no extra
175
+ registry configuration.
176
+
177
+ ## Licence
178
+
179
+ WohHup's code in this package: see `license` in `package.json`. Third-party components and the
180
+ obligations they carry are listed in `NOTICE.md`; full texts in `THIRD_PARTY_LICENSES.txt`.
181
+ All dependencies allow commercial use. `@ifc-lite/*` is MPL-2.0 (file-level copyleft): used
182
+ unmodified, it only requires keeping the notice and pointing users to its source.