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}%`);
}
});§Zero-Copy Memory Access
For optimal performance, mesh data can be accessed directly from WASM memory:
const positions = api.getPositionsBuffer(expressId);
const view = positions.asFloat32Array();
// Upload directly to GPU without copying
device.queue.writeBuffer(gpuBuffer, 0, view);Structs§
- IfcAPI
- Main IFC-Lite API
- Instance
Data - Instance data for instanced rendering
- Instanced
Geometry - Instanced geometry - one geometry definition with multiple instances
- Instanced
Mesh Collection - Collection of instanced geometries
- Mesh
Collection - Collection of mesh data for returning multiple meshes
- Mesh
Data Js - Individual mesh data with express ID and color (matches MeshData interface)
- Zero
Copy Mesh - Zero-copy mesh that exposes pointers to WASM memory
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.