IFClite TypeScript API
    Preparing search index...

    Class BinaryCacheWriter

    @ifc-lite/cache - Binary cache format for fast model loading

    The .ifc-lite format skips re-running the parse + tessellation pipeline on a warm load: entities, relationships, spatial hierarchy and geometry are all pre-computed and read back directly. That's where the 5-10x is real.

    Properties and quantities are the exception: write() serializes whatever the store's property/quantity tables already hold. A STEP-parsed IfcDataStore resolves those lazily on demand and never populates the tables, so a cache written straight from a STEP parse has EMPTY property and quantity tables — a restored model queries properties exactly as slow as a fresh parse, unless the caller separately retains the source buffer and re-attaches on-demand extraction (see docs/guide/querying.md).

    import { BinaryCacheWriter, BinaryCacheReader, toCacheDataStore } from '@ifc-lite/cache';

    // Write cache — toCacheDataStore adapts a parser IfcDataStore
    // (string schemaVersion) to the format writer.write() requires
    // (numeric SchemaVersion enum).
    const writer = new BinaryCacheWriter();
    const cacheBuffer = await writer.write(toCacheDataStore(dataStore), geometry, sourceBuffer);

    // Read cache
    const reader = new BinaryCacheReader();
    const { dataStore, geometry } = await reader.read(cacheBuffer);
    Index
    • Write a complete cache file

      Parameters

      • dataStore: CacheDataStore

        The parsed IFC data store

      • geometry: GeometryData | undefined

        Optional geometry data

      • sourceBuffer: ArrayBuffer

        Original IFC buffer (for hash)

      • Optionaloptions: CacheWriteOptions

        Write options

      Returns Promise<ArrayBuffer>

      ArrayBuffer containing the binary cache