跪拜 Guibai
← All articles
Frontend

A Hospital Digital Twin in One R3F Scene: Editor, Dashboard, and Browser-Based IFC Viewer

By 前端繁华如梦 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Keeping the editor and the dashboard on the same R3F scene eliminates the geometry sync problem that plagues many digital twin stacks, and parsing IFC in the browser removes the need for a separate model conversion service.

Summary

The project splits into four routes: a scene editor, a dashboard, a BIM browser, and a design page. The editor and dashboard share one BuildingScene component, so placement changes and visual settings are not duplicated. The hospital campus is built from block geometry, with a procedural city around it rendered via shaders.

The editor offers a 15-category device library, layers, floor expansion and sectioning, and a range of effects and heatmaps. The dashboard pulls metrics from a backend when available, falling back to local demo data otherwise. The BIM browser uses web-ifc-three to parse IFC files entirely in the browser, offering component trees, measurements, and sectioning. The full stack is React 19, TypeScript, Vite, Zustand, Three.js, and React Three Fiber.

IoT device status, alarms, and model version management are still placeholders. Until live data arrives, the editor and dashboard run with demo curves and a local backend, which keeps the whole interactive shell usable.

Takeaways
— Editor and dashboard share the same BuildingScene component, so geometry, lighting, and post-processing are not duplicated.
— The four routes are: `/` editor, `/screen` dashboard, `/bim` BIM browser, and `/design` external parametric designer.
— Tech stack includes React 19, TypeScript, Vite, Zustand, Ant Design 6, Three.js, React Three Fiber, drei, ECharts, and web-ifc-three.
— The device library has 15 categories, covering IoT sensors, HVAC, electrical, fire safety, and parking spaces.
— The editor supports layers, floor expansion, sectioning, first-person walking, security patrol, and spatial heatmaps.
— The dashboard refreshes about every 15 seconds from `dt-api` at `127.0.0.1:9100`, falling back to local demo data when offline.
— The BIM browser parses `.ifc` files client-side, with a searchable component tree, distance/area/angle measurements, and a section box.
— Scene persistence saves only the device list, placed effects, and trees; building geometry is regenerated from code.
— IoT protocol configuration is reserved (MQTT, Modbus TCP, OPC UA, HTTP) but all devices remain in 'not connected' state.
— Device status, alarm pushes, and model version management are still placeholders.
Conclusions

Unifying the editor and dashboard in a single R3F scene is a pragmatic answer to the common digital twin problem of keeping backend and presentation in sync.

Parsing IFC entirely in the browser with web-ifc-three avoids a server-side conversion pipeline, but likely limits the size of models that can be handled.

The project is a front-end-focused demonstrator; it explicitly acknowledges missing IoT integration and uses demo data, so its value lies in the interaction model rather than live data.

The procedural city rendered via shaders is a performance-conscious choice, replacing thousands of instanced meshes with a single shader pass.

Concepts & terms
Digital twin
A virtual replica of a physical asset, here a hospital campus, that can be viewed, edited, and used for monitoring.
IFC
Industry Foundation Classes, an open file format for building information modeling (BIM) that describes building elements and their properties.
React Three Fiber
A React renderer for Three.js that lets developers build 3D scenes with declarative React components.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗