Expand description
§IFC-Lite WebAssembly Bindings
JavaScript/TypeScript API for IFC-Lite built with wasm-bindgen.
§Overview
This crate provides WebAssembly bindings for IFC-Lite, enabling high-performance IFC parsing and geometry processing in web browsers.
§Features
- Zero-Copy Buffers: Direct GPU buffer access without data copying
- Streaming Parse: Event-based parsing with progress callbacks
- Small Bundle: ~60 KB WASM binary, ~20 KB gzipped
§JavaScript Usage
import init, { IfcAPI, version } from 'ifc-lite-wasm';
// Initialize WASM
await init();
// Create API instance
const api = new IfcAPI();
// Parse IFC file
const buffer = await fetch('model.ifc').then(r => r.arrayBuffer());
const result = api.parse(new Uint8Array(buffer));
console.log(`Parsed ${result.entityCount} entities`);
console.log(`Version: ${version()}`);§Streaming Parse
const result = await api.parseStreaming(data, (event) => {
if (event.type === 'progress') {
console.log(`Progress: ${event.percent}%`);
}
});Structs§
- IfcAPI
- Main IFC-Lite API
- Mesh
Collection - Collection of mesh data for returning multiple meshes
- Mesh
Data Js - Individual mesh data with express ID and color (matches MeshData interface)
- Symbolic
Circle - A 2D circle/arc for symbolic representations
- Symbolic
Fill Area - A 2D filled region (IfcAnnotationFillArea / IfcAnnotationFillAreaOccurrence).
- Symbolic
Polyline - A single 2D polyline for symbolic representations (Plan, Annotation, FootPrint) Points are stored as [x1, y1, x2, y2, …] in 2D coordinates
- Symbolic
Representation Collection - Collection of symbolic representations for an IFC model
- Symbolic
Text - A 2D text annotation (IfcTextLiteral / IfcTextLiteralWithExtent).
Functions§
- get_
memory - Get WASM memory to allow JavaScript to create TypedArray views
- init
- Initialize the WASM module.
- init_
panic_ hook - Set panic hook for better error messages in the browser
- set_
panic_ hook - Set the
console.errorpanic hook the first time this is called. Subsequent invocations do nothing. - version
- Get the version of IFC-Lite.