Skip to main content

Crate ifc_lite_wasm

Crate ifc_lite_wasm 

Source
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
MeshCollection
Collection of mesh data for returning multiple meshes
MeshDataJs
Individual mesh data with express ID and color (matches MeshData interface)
SymbolicCircle
A 2D circle/arc for symbolic representations
SymbolicFillArea
A 2D filled region (IfcAnnotationFillArea / IfcAnnotationFillAreaOccurrence).
SymbolicPolyline
A single 2D polyline for symbolic representations (Plan, Annotation, FootPrint) Points are stored as [x1, y1, x2, y2, …] in 2D coordinates
SymbolicRepresentationCollection
Collection of symbolic representations for an IFC model
SymbolicText
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.error panic hook the first time this is called. Subsequent invocations do nothing.
version
Get the version of IFC-Lite.