Expand description
Native writer for the browser-readable .ifclite cache, format v28
(@ifc-lite/cache, packages/cache/src/types.ts FORMAT_VERSION), so a
server or function can build the cache a browser then only reads (#9584).
Two entry points with one output: build_cache builds the cache in
memory, build_cache_to_path streams it to a file without holding the
mesh set, and the two are byte-identical for the same input and options
(tests/streamed_matches_in_memory.rs). The ifc-build-cache binary is a
thin CLI over the second. Both run the canonical pipeline and add no
ingest or geometry of their own: the scalar sections come from
ifc_lite_processing::data_model::extract_data_model_with (rooted
entities; property and quantity tables off), the geometry from
ifc_lite_processing::process. Each section module mirrors its TS
serializer field for field and names it.
§Determinism
The output is a pure function of the source bytes and CacheOptions:
meshes are chunked in the pipeline’s emit order (pinned by the
mesh-determinism contract, independent of thread count), the data model’s
tables are ordered, and deflate is miniz_oxide at a fixed level. The
stored chunk bytes therefore differ from the TS writer’s (node zlib), which
moves directory byteOffset/byteLength and can flip a chunk’s
DeflateRaw flag; the inflated payloads are what the two writers share.
scripts/cache-native-conformance.mjs checks both properties.
§What the native pipeline does not produce
Each is a value the format and the TS reader accept; none is faked:
- Properties / Quantities are written empty, as the TS writer does for
a STEP-parsed store (
packages/cache/README.md). - Selection coverage (the v28 EntityIndex trailer, #9947) is written
absent: it is computed by the TS parser alone
(
selection-relationship-index.ts), and porting it would be a second ingest implementation. - InstancedShards (IFNS) are never written: native
processhas no GPU-instancing partition, so every occurrence is a flat mesh. - Appearance provenance (v19) is mode 0 on every mesh and the source pool is empty: canonical-item source indices are a browser-batch output.
shadingColor(v25) is never present: the native pass reports one colour per mesh and no distinct authored DiffuseColour.- Mesh frame. Native
processmeshes with its own per-mesh origins (zero for most meshes; the browser path stores local-frame origins) and in its own frame tier. Its translation is recorded aswasmRtcOffset; when theIfcSite-local tier also removed the site rotation, whichCoordinateInfocannot express, the writer puts that rotation back into the stored origins, positions and normals (pipeline.rs), so every vertex reads back atMeshFrame::to_worldof its pass-frame point.wasmRtcFrame,buildingRotationandboundsRecoveryFallbackCountare left absent (each is producer provenance of the browser path;buildingRotationorients camera presets and is never applied to geometry). - Entity rows are the data model’s rooted table and naming rules (an
explicit
''Name and the own-Representation flag are re-read from the source, which the data model does not carry:row_facts.rs), not the TS parser’s row selection, so the scalar sections encode the same model the TS writer would be handed for this data, not the bytes a TS parse of the same file produces.scripts/cache-native-conformance.mjsstates and checks the row-set difference against a TS parse.
Structs§
- Cache
Options - What to write.
Defaultmatches the TS writer’s defaults. - Cache
Stats - What a build produced. Both entry points report the same values for the same input and options.
Enums§
Constants§
- FORMAT_
VERSION FORMAT_VERSION.
Functions§
- build_
cache - Build a complete
.ifclitecache forsource(the IFC STEP bytes), in memory: the pipeline retains every mesh. - build_
cache_ to_ path - Build the same cache straight to
output: byte-identical tobuild_cachefor the same input and options, without holding the mesh set. The pipeline runs withretain_meshesoff; each chunk is serialized when it closes and appended to a spool file besideoutput, so only the open chunks and the 44-byte directory entries stay in memory.