IfcAPI

Struct IfcAPI 

Source
pub struct IfcAPI { /* private fields */ }
Expand description

Main IFC-Lite API

Implementations§

Source§

impl IfcAPI

Source

pub fn new() -> Self

Create and initialize the IFC API

Source

pub fn is_ready(&self) -> bool

Check if API is initialized

Source

pub fn parse_streaming(&self, content: String, callback: Function) -> Promise

Parse IFC file with streaming events Calls the callback function for each parse event

Example:

const api = new IfcAPI();
await api.parseStreaming(ifcData, (event) => {
  console.log('Event:', event);
});
Source

pub fn parse(&self, content: String) -> Promise

Parse IFC file (traditional - waits for completion)

Example:

const api = new IfcAPI();
const result = await api.parse(ifcData);
console.log('Entities:', result.entityCount);
Source

pub fn parse_zero_copy(&self, content: String) -> ZeroCopyMesh

Parse IFC file with zero-copy mesh data Maximum performance - returns mesh with direct memory access

Example:

const api = new IfcAPI();
const mesh = await api.parseZeroCopy(ifcData);

// Create TypedArray views (NO COPYING!)
const memory = await api.getMemory();
const positions = new Float32Array(
  memory.buffer,
  mesh.positions_ptr,
  mesh.positions_len
);

// Upload directly to GPU
gl.bufferData(gl.ARRAY_BUFFER, positions, gl.STATIC_DRAW);
Source

pub fn parse_meshes(&self, content: String) -> MeshCollection

Parse IFC file and return individual meshes with express IDs and colors This matches the MeshData[] format expected by the viewer

Example:

const api = new IfcAPI();
const collection = api.parseMeshes(ifcData);
for (let i = 0; i < collection.length; i++) {
  const mesh = collection.get(i);
  console.log('Express ID:', mesh.expressId);
  console.log('Positions:', mesh.positions);
  console.log('Color:', mesh.color);
}
Source

pub fn parse_meshes_instanced(&self, content: String) -> InstancedMeshCollection

Parse IFC file and return instanced geometry grouped by geometry hash This reduces draw calls by grouping identical geometries with different transforms

Example:

const api = new IfcAPI();
const collection = api.parseMeshesInstanced(ifcData);
for (let i = 0; i < collection.length; i++) {
  const geometry = collection.get(i);
  console.log('Geometry ID:', geometry.geometryId);
  console.log('Instances:', geometry.instanceCount);
  for (let j = 0; j < geometry.instanceCount; j++) {
    const inst = geometry.getInstance(j);
    console.log('  Express ID:', inst.expressId);
    console.log('  Transform:', inst.transform);
  }
}
Source

pub fn parse_meshes_instanced_async( &self, content: String, options: JsValue, ) -> Promise

Parse IFC file with streaming instanced geometry batches for progressive rendering Groups identical geometries and yields batches of InstancedGeometry Uses fast-first-frame streaming: simple geometry (walls, slabs) first

Example:

const api = new IfcAPI();
await api.parseMeshesInstancedAsync(ifcData, {
  batchSize: 25,  // Number of unique geometries per batch
  onBatch: (geometries, progress) => {
    for (const geom of geometries) {
      renderer.addInstancedGeometry(geom);
    }
  },
  onComplete: (stats) => {
    console.log(`Done! ${stats.totalGeometries} unique geometries, ${stats.totalInstances} instances`);
  }
});
Source

pub fn parse_meshes_async(&self, content: String, options: JsValue) -> Promise

Parse IFC file with streaming mesh batches for progressive rendering Calls the callback with batches of meshes, yielding to browser between batches

Example:

const api = new IfcAPI();
await api.parseMeshesAsync(ifcData, {
  batchSize: 100,
  onBatch: (meshes, progress) => {
    // Add meshes to scene
    for (const mesh of meshes) {
      scene.add(createThreeMesh(mesh));
    }
    console.log(`Progress: ${progress.percent}%`);
  },
  onComplete: (stats) => {
    console.log(`Done! ${stats.totalMeshes} meshes`);
  }
});
Source

pub fn get_memory(&self) -> JsValue

Get WASM memory for zero-copy access

Source

pub fn version(&self) -> String

Get version string

Source

pub fn get_geo_reference(&self, content: String) -> Option<GeoReferenceJs>

Extract georeferencing information from IFC content Returns null if no georeferencing is present

Example:

const api = new IfcAPI();
const georef = api.getGeoReference(ifcData);
if (georef) {
  console.log('CRS:', georef.crsName);
  const [e, n, h] = georef.localToMap(10, 20, 5);
}
Source

pub fn parse_meshes_with_rtc(&self, content: String) -> MeshCollectionWithRtc

Parse IFC file and return mesh with RTC offset for large coordinates This handles georeferenced models by shifting to centroid

Example:

const api = new IfcAPI();
const result = api.parseMeshesWithRtc(ifcData);
const rtcOffset = result.rtcOffset;
const meshes = result.meshes;

// Convert local coords back to world:
if (rtcOffset.isSignificant()) {
  const [wx, wy, wz] = rtcOffset.toWorld(localX, localY, localZ);
}
Source

pub fn debug_process_entity_953(&self, content: String) -> String

Debug: Test processing entity #953 (FacetedBrep wall)

Source

pub fn debug_process_first_wall(&self, content: String) -> String

Debug: Test processing a single wall

Trait Implementations§

Source§

impl Default for IfcAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<IfcAPI> for JsValue

Source§

fn from(value: IfcAPI) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for IfcAPI

Source§

type Abi = u32

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: u32) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for IfcAPI

Source§

type Abi = u32

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for IfcAPI

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<IfcAPI>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for IfcAPI

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for IfcAPI

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for IfcAPI

Source§

type Abi = u32

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<IfcAPI>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for IfcAPI

Source§

type Abi = u32

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<IfcAPI>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl TryFromJsValue for IfcAPI

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for IfcAPI

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[IfcAPI]>

Source§

impl VectorIntoWasmAbi for IfcAPI

Source§

type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi

Source§

fn vector_into_abi(vector: Box<[IfcAPI]>) -> Self::Abi

Source§

impl WasmDescribe for IfcAPI

Source§

impl WasmDescribeVector for IfcAPI

Source§

impl SupportsConstructor for IfcAPI

Source§

impl SupportsInstanceProperty for IfcAPI

Source§

impl SupportsStaticProperty for IfcAPI

Auto Trait Implementations§

§

impl Freeze for IfcAPI

§

impl RefUnwindSafe for IfcAPI

§

impl Send for IfcAPI

§

impl Sync for IfcAPI

§

impl Unpin for IfcAPI

§

impl UnwindSafe for IfcAPI

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.