用途:指导在 Three.js 中加载与查看 IFC/BIM 模型,避免使用已废弃库并处理许可与内存问题。
库选择:web-ifc(MIT,底层 WASM 解析器,适合自定义管线);@thatopen/components 与 @thatopen/components-front(MIT v3.x,高层 BIM 工具包与浏览器扩展,适合快速构建查看器)。web-ifc-three 与 openbim-components v1 已废弃,禁止使用。@thatopen v3.x 为 MIT,但旧 IFC.js 生态包曾用 AGPL-3.0,须核对实际安装版本许可;使用 AGPL-3.0 包时整个应用须以 AGPL-3.0 或兼容许可开源。
安装:底层 npm install web-ifc three;高层 npm install @thatopen/components @thatopen/components-front web-ifc three。
用法要点:web-ifc 须 await ifcApi.Init(),SetWasmPath 指向含 web-ifc.wasm 的目录,用 OpenModel 返回 modelID,经 GetFlatMesh、GetPlacedGeometry 提取几何(vertexData 交错位置+法线,indexData 索引,flatTransformation 为 4x4 列主序矩阵)并转为 THREE.BufferGeometry;处理完调用 CloseModel 释放内存。@thatopen 通过 components.get 获取 Worlds、IfcLoader 等,IfcLoader.setup() 后 load 加载,模型自动加入 world;卸载时须 components.dispose()。
性能与限制:>1000 元素用 fragment 批处理;>50MB 不应一次加载全部几何,按楼层或类型流式加载并释放不可见几何;WASM 内存有上限且不可回收,须避免重复几何、始终用 BufferGeometry 并在移除网格时 dispose 几何与材质。大型模型可服务端预处理为碎片按需加载。
参考:references/methods.md、references/examples.md、references/anti-patterns.md 及 web-ifc、ThatOpen 官方文档与 buildingSMART IFC 规范。