# thatopen/web-ifc-three architecture

> Architecture diagram of the GitHub repository thatopen/web-ifc-three, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/thatopen/web-ifc-three
- Repository: https://github.com/thatopen/web-ifc-three

## Overview

##### Project type and purpose
- This is an open-source JavaScript/TypeScript library (“web-ifc-three”) that integrates the Web-IFC parser (via WASM) with Three.js.
- Its purpose is to parse IFC BIM files in the browser or Node, generate Three.js geometries, expose APIs for selection, visibility, subsets, and property queries.

##### File structure
- Top-level:
- web-ifc-three/ → core source code, configs
- example/ → standalone demo app (bundled by Rollup)
- jest.config.ts, tests under web-ifc-three/test → automated unit tests
- package.json, tsconfigs, rollup configs → build and packaging
- In web-ifc-three/src/IFC:
- components/ → high-level classes (IFCManager, IFCModel, BvhManager, etc.)
- sequence, subsets, properties → subpackages for data flow, geometric subsets, property management
- indexedDB → local caching layer
- web-workers/ → handler code + message router for offloading parsing/serializing
- src/IFCLoader.ts → public entry point that ties everything together.

##### README for additional insights
- Confirms pre-alpha status, usage as Three.js IFCLoader, relies on web-ifc WASM and web workers, example provided.

## Diagram (Mermaid)

```mermaid
flowchart TD
  subgraph "Example App Layer"
    EX_main["main.js"]:::example
    EX_scene["scene.js"]:::example
    EX_ifc_manager["ifc-manager.js"]:::example
    EX_html["index.html"]:::example
  end

  subgraph "Main Thread Layer"
    IFCL["IFCLoader"]:::api
    IFCM["IFCManager"]:::core
    IFCMod["IFCModel"]:::core
    IFCP["IFCParser"]:::core
    BVH["BvhManager"]:::core
    TM["TypeManager"]:::core
    MC["MemoryCleaner"]:::core
    SM["SubsetManager"]:::core
    SC["SubsetCreator"]:::core
    IM["ItemsMap"]:::core
    PM["PropertyManager"]:::core
    JPM["JSONPropertyManager"]:::core
    WPM["WebIfcPropertyManager"]:::core
    PS["PropertySerializer"]:::core
    IDC["IndexedDatabase"]:::cache
    THREE["Three.js Scene"]:::external
  end

  subgraph "Web Worker Layer"
    WD_base["BaseDefinitions"]:::worker
    IFCW["IFCWorker"]:::worker
    IFCH["IFCWorkerHandler"]:::worker
    PH["ParserHandler"]:::worker
    PYH["PropertyHandler"]:::worker
    WH["WebIfcHandler"]:::worker
    SH["WorkerStateHandler"]:::worker
    W_PR["ParserWorker"]:::worker
    W_PY["PropertyWorker"]:::worker
    W_ST["StateWorker"]:::worker
    W_WI["WebIfcWorker"]:::worker
  end

  subgraph "Serializer/Data Structures"
    FM["FlatMesh"]:::data
    FMV["FlatMeshVector"]:::data
    GY["Geometry"]:::data
    IGY["IfcGeometry"]:::data
    MAT["Material"]:::data
    MES["Mesh"]:::data
    VEC["Vector"]:::data
  end

  subgraph "Web-IFC WASM"
    WASM["web-ifc.wasm / web-ifc-mt.wasm"]:::wasm
  end

  %% Example to Main Thread
  EX_main -->|"import/loadIfcUrl()"| IFCL
  EX_scene --> THREE
  EX_ifc_manager --> IFCL

  %% IFCLoader orchestration
  IFCL -->|"instantiates"| IFCW
  IFCL -->|"calls"| IDC
  IFCL --> THREE

  %% Main thread core workflow
  IFCW -->|"posts arraybuffer"| W_PR
  W_PR --> PH
  PH -->|"parse bytes"| WASM
  W_PR --> FM
  FM --> FMV
  FMV --> GY
  GY --> IGY
  IGY --> MAT
  MAT --> MES
  MES --> VEC
  W_PR --> IFCH

  %% Worker responses
  W_PR -->|"serialized data"| IFCH
  IFCH --> IFCL

  %% Main thread builds Three.js geometry
  IFCL --> IFCM
  IFCM --> IFCMod
  IFCM --> BVH
  IFCM --> TM
  IFCM --> MC
  IFCM --> SM
  SM --> SC
  SC --> IM
  IFCM --> PM
  PM --> JPM
  PM --> WPM
  PM --> PS
  IFCM --> THREE

  %% Caching
  IFCM --> IDC
  IDC --> IFCM

  %% Worker handlers registration
  IFCW --> IFCH
  IFCH --> PH
  IFCH --> PYH
  IFCH --> WH
  IFCH --> SH

  %% Workers entry points
  WD_base --> W_PR
  WD_base --> W_PY
  WD_base --> W_ST
  WD_base --> W_WI
  W_PY --> PYH
  W_ST --> SH
  W_WI --> WH

  %% Click Events
  click IFCL "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFCLoader.ts"
  click IFCM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/IFCManager.ts"
  click IFCMod "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/IFCModel.ts"
  click IFCP "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/IFCParser.ts"
  click BVH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/BvhManager.ts"
  click TM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/TypeManager.ts"
  click MC "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/MemoryCleaner.ts"
  click SM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/subsets/SubsetManager.ts"
  click SC "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/subsets/SubsetCreator.ts"
  click IM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/subsets/ItemsMap.ts"
  click PM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/properties/PropertyManager.ts"
  click JPM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/properties/JSONPropertyManager.ts"
  click WPM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/properties/WebIfcPropertyManager.ts"
  click PS "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/components/properties/PropertySerializer.ts"
  click IDC "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/indexedDB/IndexedDatabase.ts"
  click WD_base "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/BaseDefinitions.ts"
  click IFCW "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/IFCWorker.ts"
  click IFCH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/IFCWorkerHandler.ts"
  click PH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/handlers/ParserHandler.ts"
  click PYH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/handlers/PropertyHandler.ts"
  click WH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/handlers/WebIfcHandler.ts"
  click SH "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/handlers/WorkerStateHandler.ts"
  click W_PR "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/workers/ParserWorker.ts"
  click W_PY "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/workers/PropertyWorker.ts"
  click W_ST "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/workers/StateWorker.ts"
  click W_WI "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/workers/WebIfcWorker.ts"
  click FM "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/FlatMesh.ts"
  click FMV "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/FlatMeshVector.ts"
  click GY "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/Geometry.ts"
  click IGY "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/IfcGeometry.ts"
  click MAT "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/Material.ts"
  click MES "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/Mesh.ts"
  click VEC "https://github.com/thatopen/web-ifc-three/blob/main/web-ifc-three/src/IFC/web-workers/serializer/Vector.ts"
  click EX_main "https://github.com/thatopen/web-ifc-three/blob/main/example/src/main.js"
  click EX_scene "https://github.com/thatopen/web-ifc-three/blob/main/example/src/scene.js"
  click EX_ifc_manager "https://github.com/thatopen/web-ifc-three/blob/main/example/src/ifc-manager.js"
  click EX_html "https://github.com/thatopen/web-ifc-three/blob/main/example/index.html"

  classDef example fill:#E3F2FD,stroke:#2196F3,color:#0D47A1;
  classDef api fill:#E8F5E9,stroke:#43A047,color:#1B5E20;
  classDef core fill:#FFF3E0,stroke:#FB8C00,color:#E65100;
  classDef worker fill:#F3E5F5,stroke:#AB47BC,color:#4A148C;
  classDef data fill:#E0F7FA,stroke:#00ACC1,color:#006064;
  classDef wasm fill:#FFEBEE,stroke:#E53935,color:#B71C1C;
  classDef cache fill:#EFEBE9,stroke:#8D6E63,color:#4E342E;
  classDef external fill:#F1F8E9,stroke:#7CB342,color:#33691E;
```
