@ifc-lite/cache 3.7.4 → 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/SPEC.md +522 -0
- package/dist/adapt.d.ts +2 -1
- package/dist/adapt.d.ts.map +1 -1
- package/dist/adapt.js +1 -0
- package/dist/adapt.js.map +1 -1
- package/dist/chunk-inflate-pool.d.ts +3 -0
- package/dist/chunk-inflate-pool.d.ts.map +1 -0
- package/dist/chunk-inflate-pool.js +6 -0
- package/dist/chunk-inflate-pool.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/reader.d.ts +4 -1
- package/dist/reader.d.ts.map +1 -1
- package/dist/reader.js +7 -2
- package/dist/reader.js.map +1 -1
- package/dist/sections/coordinate-info.d.ts.map +1 -1
- package/dist/sections/coordinate-info.js +14 -0
- package/dist/sections/coordinate-info.js.map +1 -1
- package/dist/sections/geometry-chunks.d.ts +24 -4
- package/dist/sections/geometry-chunks.d.ts.map +1 -1
- package/dist/sections/geometry-chunks.js +20 -8
- package/dist/sections/geometry-chunks.js.map +1 -1
- package/dist/sections/mesh-metadata.d.ts +1 -1
- package/dist/sections/selection-relationships.d.ts +9 -0
- package/dist/sections/selection-relationships.d.ts.map +1 -0
- package/dist/sections/selection-relationships.js +71 -0
- package/dist/sections/selection-relationships.js.map +1 -0
- package/dist/types-entity-index.d.ts +27 -0
- package/dist/types-entity-index.d.ts.map +1 -0
- package/dist/types-entity-index.js +5 -0
- package/dist/types-entity-index.js.map +1 -0
- package/dist/types.d.ts +10 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/buffer-utils.d.ts +23 -0
- package/dist/utils/buffer-utils.d.ts.map +1 -1
- package/dist/utils/buffer-utils.js +58 -0
- package/dist/utils/buffer-utils.js.map +1 -1
- package/dist/workers/chunk-inflate-pool.d.ts +30 -0
- package/dist/workers/chunk-inflate-pool.d.ts.map +1 -0
- package/dist/workers/chunk-inflate-pool.js +167 -0
- package/dist/workers/chunk-inflate-pool.js.map +1 -0
- package/dist/workers/geometry-compression-client.d.ts +19 -2
- package/dist/workers/geometry-compression-client.d.ts.map +1 -1
- package/dist/workers/geometry-compression-client.js +53 -16
- package/dist/workers/geometry-compression-client.js.map +1 -1
- package/dist/workers/geometry-compression-handler.d.ts.map +1 -1
- package/dist/workers/geometry-compression-handler.js +12 -2
- package/dist/workers/geometry-compression-handler.js.map +1 -1
- package/dist/workers/geometry-compression-protocol.d.ts +7 -0
- package/dist/workers/geometry-compression-protocol.d.ts.map +1 -1
- package/dist/workers/geometry-compression-protocol.js +7 -1
- package/dist/workers/geometry-compression-protocol.js.map +1 -1
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +20 -1
- package/dist/writer.js.map +1 -1
- package/package.json +14 -8
package/README.md
CHANGED
|
@@ -96,8 +96,14 @@ const rawKey = xxhash64(buffer); // same hash as a bigint
|
|
|
96
96
|
|
|
97
97
|
The cache keys models by the xxHash64 of the source IFC, and `reader.validate(cacheBuffer, sourceBuffer)` uses the same hash to detect when the source has changed.
|
|
98
98
|
|
|
99
|
+
## Building a cache outside the browser
|
|
100
|
+
|
|
101
|
+
`ifc-build-cache` is a native CLI that writes this format from an IFC file without a browser or the WASM heap, so a server, a build step or a function can prepare the cache that `BinaryCacheReader` then reads. It installs through cargo from the repository. See the [Native Cache Builder guide](https://ifclite.dev/docs/guide/native-cache/) for installation, which format version a build writes, and what a native cache leaves out.
|
|
102
|
+
|
|
99
103
|
## Format versioning
|
|
100
104
|
|
|
105
|
+
The byte-level layout, the reader's compatibility rules and the conformance criterion for another writer are specified in [`SPEC.md`](./SPEC.md).
|
|
106
|
+
|
|
101
107
|
The binary layout is versioned via the exported `FORMAT_VERSION` constant. Readers accept entries written by the current or an older format version (with backward-compatible decoding, e.g. the per-mesh geometry-class byte added in v5) and reject entries written by a newer one, so mixed-version deployments fail safely toward a cold parse.
|
|
102
108
|
|
|
103
109
|
Version 19 preserves explicitly supplied canonical `MeshData.appearanceSource` provenance. Fresh canonical meshes store an identity marker; fragmented or expanded meshes reference a geometry-header source-index pool, shared across spatial chunks, plus their corner mapping. Restored metadata points to the restored mesh indices, preserving the topology identity fence required by appearance preview. Invalid identities, source lengths, pool references and corner ranges fail cache reading/writing instead of enabling an unsafe preview. Unmarked meshes remain unmarked; old records never acquire inferred canonical identity.
|
package/SPEC.md
ADDED
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
# `.ifclite` binary cache format
|
|
2
|
+
|
|
3
|
+
> - **Current format version: 28** (`FORMAT_VERSION`, `src/types.ts:165`).
|
|
4
|
+
> - **Status:** descriptive contract of the format as written and read by `@ifc-lite/cache` on `main`.
|
|
5
|
+
> Where this document and the code disagree, the code is the bug report: fix one of them in the same PR.
|
|
6
|
+
> - **Change policy:** bump `FORMAT_VERSION` and update this file (§13 history, §11 gates) in the same PR
|
|
7
|
+
> for any change to the wire layout, to how a reader interprets existing bytes, or to the cache's
|
|
8
|
+
> semantics (what a decoded field means or what a producer puts in it). Two writer-side choices are
|
|
9
|
+
> **not** format changes and need no bump, because readers trust only the stored directory and decode
|
|
10
|
+
> the same values either way: the chunk grouping policy (§9.4), and the compressed representation of a
|
|
11
|
+
> chunk, i.e. which valid DEFLATE stream is stored and whether the strictly-smaller rule keeps it (§9.4,
|
|
12
|
+
> §12 item 5). A bump that changes no bytes (producer semantics only) is still recorded in §13.
|
|
13
|
+
> `src/spec.test.ts` fails when the version line above or the enum tables in §2 drift from the code.
|
|
14
|
+
> - **Scope:** the file layout, every section's wire encoding, what the reader accepts, rejects and
|
|
15
|
+
> degrades, and the conformance criterion for a second (non-TypeScript) writer (§12). The IFNS
|
|
16
|
+
> instanced-shard payload is a separate format owned by `@ifc-lite/geometry` and only referenced here.
|
|
17
|
+
|
|
18
|
+
All `file:line` citations are relative to `packages/cache/` unless they name another root.
|
|
19
|
+
|
|
20
|
+
## 1. Conventions
|
|
21
|
+
|
|
22
|
+
| Rule | Detail | Source |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| Endianness | Every multi-byte integer and float is **little-endian**. | `src/utils/buffer-utils.ts:42-76`, `:225-265` |
|
|
25
|
+
| Alignment | **None.** No field, array or section is padded or aligned; the writer never calls `align()`. Readers copy arrays out (`slice`), so unaligned typed arrays are legal. | `src/utils/buffer-utils.ts:267-321` |
|
|
26
|
+
| Typed arrays | `T[n]` = `n` packed little-endian elements, no length prefix unless the table shows one. | `src/utils/buffer-utils.ts:84-87` |
|
|
27
|
+
| `lpstr` | `u32` UTF-8 byte length, then that many UTF-8 bytes, no terminator. | `src/utils/buffer-utils.ts:89-94`, `:323-328` |
|
|
28
|
+
| String index | `u32` index into the Strings pool (§4). The parser's null index `-1` is stored as `0xFFFFFFFF`. | `../data/src/string-table.ts:14` |
|
|
29
|
+
| Absent source id | `0xFFFFFFFF` (never `0`: `0` is a real material-layer id). | `src/sections/geometry.ts:153-156` |
|
|
30
|
+
| Floats | IEEE-754 as produced by `DataView`. Absent-finish NaN is written as `0x7FC00000`. | `src/sections/geometry.ts:121-124` |
|
|
31
|
+
| Bounds | Every `BufferReader` read throws `read past end of buffer` before overrunning; `skip()` and the `position` setter do not check. | `src/utils/buffer-utils.ts:211-218`, `:189-191`, `:337-339` |
|
|
32
|
+
|
|
33
|
+
## 2. File header (64 bytes) and section table
|
|
34
|
+
|
|
35
|
+
| Offset | Type | Field | Notes |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| 0 | `u32` | `magic` | `0x4C434649` = bytes `49 46 43 4C` ("IFCL"). Mismatch → throw. (`src/types.ts:16`, `src/sections/header.ts:75-78`) |
|
|
38
|
+
| 4 | `u16` | `version` | `> FORMAT_VERSION` → throw `Unsupported format version`. No lower bound. (`src/sections/header.ts:81-84`) |
|
|
39
|
+
| 6 | `u16` | `flags` | `HeaderFlags`, below. |
|
|
40
|
+
| 8 | `u64` | `sourceHash` | §3. |
|
|
41
|
+
| 16 | `u8` | `schema` | `SchemaVersion`, below. Not validated on read. |
|
|
42
|
+
| 17 | `u32` | `entityCount` | `store.entityCount \|\| entities.count` (`src/adapt.ts:109`). Not cross-checked on read. |
|
|
43
|
+
| 21 | `u32` | `totalVertices` | Caller-supplied `GeometryData.totalVertices`, 0 without geometry (`src/writer.ts:132-147`). |
|
|
44
|
+
| 25 | `u32` | `totalTriangles` | As above. |
|
|
45
|
+
| 29 | `u16` | `sectionCount` | |
|
|
46
|
+
| 31 | 33 bytes | reserved | Written as zero, skipped unread (`src/sections/header.ts:53-58`, `:103-105`). |
|
|
47
|
+
| 64 | 16 × `sectionCount` | section table | Entries below. |
|
|
48
|
+
|
|
49
|
+
### Header flags
|
|
50
|
+
|
|
51
|
+
`HeaderFlags` (`src/types.ts:224-238`). Unknown bits are ignored on read.
|
|
52
|
+
|
|
53
|
+
| Bit | Mask | Name | Writer | Reader |
|
|
54
|
+
|---|---|---|---|---|
|
|
55
|
+
| 0 | `0x0001` | `Compressed` | Never set. | Never consulted. |
|
|
56
|
+
| 1 | `0x0002` | `HasGeometry` | Set iff `includeGeometry && geometry` (even with zero meshes) (`src/writer.ts:180-182`). | Gates the geometry and shard reads (`src/reader.ts:150`). |
|
|
57
|
+
| 2 | `0x0004` | `HasSpatial` | Never set; no Spatial section exists (`src/writer.ts:183-188`). | Surfaced as `hasSpatialHierarchy` only (`src/sections/header.ts:128`). |
|
|
58
|
+
| 3 | `0x0008` | `SourceHashUnset` | Set iff `omitSourceHash` (`src/writer.ts:189-191`). | `hasSourceHash = bit clear` (`src/sections/header.ts:123`). |
|
|
59
|
+
|
|
60
|
+
### Schema
|
|
61
|
+
|
|
62
|
+
`SchemaVersion` (`src/types.ts:217-221`): `0` IFC2X3, `1` IFC4, `2` IFC4X3. `toCacheDataStore` maps `IFC5`
|
|
63
|
+
and anything unrecognised to `0` (`src/adapt.ts:62-70`).
|
|
64
|
+
|
|
65
|
+
### Section table entry (16 bytes)
|
|
66
|
+
|
|
67
|
+
| Offset | Type | Field | Notes |
|
|
68
|
+
|---|---|---|---|
|
|
69
|
+
| +0 | `u16` | `type` | `SectionType`, below. |
|
|
70
|
+
| +2 | `u16` | `flags` | `SectionFlags`: bit 0 `Compressed` (`0x0001`). Writer always `0`; reader ignores it (`src/writer.ts:169`). A writer MUST write `0`. |
|
|
71
|
+
| +4 | `u32` | `offset` | Absolute byte offset from file start. |
|
|
72
|
+
| +8 | `u32` | `size` | Section byte length. **Not used by the reader to bound decoding** (§10). |
|
|
73
|
+
| +12 | `u32` | `compressedSize` | Writer always `0`; never read. |
|
|
74
|
+
|
|
75
|
+
### Section types
|
|
76
|
+
|
|
77
|
+
`SectionType` (`src/types.ts:203-214`). The reader indexes sections by type into a `Map`
|
|
78
|
+
(`src/reader.ts:88`): unknown types are ignored, and a duplicated type resolves to the **last** entry.
|
|
79
|
+
|
|
80
|
+
| Value | Name | Written | Required on read | Section |
|
|
81
|
+
|---|---|---|---|---|
|
|
82
|
+
| 1 | `Strings` | always | yes (`src/reader.ts:91-94`) | §4 |
|
|
83
|
+
| 2 | `Entities` | always | yes (`src/reader.ts:99-102`) | §5 |
|
|
84
|
+
| 3 | `Properties` | always | yes (`src/reader.ts:107-110`) | §6 |
|
|
85
|
+
| 4 | `Quantities` | always | yes (`src/reader.ts:115-118`) | §6 |
|
|
86
|
+
| 5 | `Relationships` | always | yes (`src/reader.ts:123-126`) | §7 |
|
|
87
|
+
| 6 | `Geometry` | with geometry | no | §9 |
|
|
88
|
+
| 7 | `Spatial` | never | never read | reserved |
|
|
89
|
+
| 8 | `Bounds` | never | never read | reserved |
|
|
90
|
+
| 9 | `EntityIndex` | iff `dataStore.entityIndex` | no | §8 |
|
|
91
|
+
| 10 | `InstancedShards` | iff geometry has ≥1 shard | no | §9.8 |
|
|
92
|
+
|
|
93
|
+
### Section order and offsets (writer)
|
|
94
|
+
|
|
95
|
+
Sections are emitted in this order, each immediately after the previous one with no padding, the first at
|
|
96
|
+
`64 + 16 × sectionCount`: Strings, Entities, Properties, Quantities, Relationships, [EntityIndex],
|
|
97
|
+
[Geometry, [InstancedShards]] (`src/writer.ts:76-176`). The file ends at the last section's end. The reader
|
|
98
|
+
seeks each section by its `offset` and does not require this order, contiguity, or a file end at the last
|
|
99
|
+
section.
|
|
100
|
+
|
|
101
|
+
## 3. Source hash
|
|
102
|
+
|
|
103
|
+
`sourceHash` is **XXH64, seed 0, over the complete source IFC bytes** (`src/writer.ts:69`,
|
|
104
|
+
`src/utils/hash.ts:49-107`; reference vectors pinned in `src/cache.test.ts:73-92`).
|
|
105
|
+
|
|
106
|
+
- With `omitSourceHash`, the writer stores `0` and sets `SourceHashUnset` (`src/writer.ts:69`, `:189-191`).
|
|
107
|
+
- `read({ sourceBuffer })` compares only when the flag is clear; a mismatch throws
|
|
108
|
+
`Cache validation failed: source file has changed` (`src/reader.ts:80-85`).
|
|
109
|
+
- `validate()` throws when the flag is set, otherwise returns the comparison (`src/reader.ts:47-56`).
|
|
110
|
+
- The viewer's lookup key is a different, sampled fingerprint plus `FORMAT_VERSION`
|
|
111
|
+
(`src/source-fingerprint.ts`, `apps/viewer/src/hooks/geometryCacheKey.ts:72`); it is not part of this format.
|
|
112
|
+
|
|
113
|
+
## 4. Strings
|
|
114
|
+
|
|
115
|
+
| Type | Field |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `u32` | `count` |
|
|
118
|
+
| `u32[count + 1]` | cumulative byte offsets into `data`; `offsets[count]` = total bytes |
|
|
119
|
+
| `u8[offsets[count]]` | concatenated UTF-8 |
|
|
120
|
+
|
|
121
|
+
Written from `StringTable.getAll()` in pool order (`src/sections/strings.ts:19-46`). A `StringTable` always
|
|
122
|
+
holds `''` at index 0 (`../data/src/string-table.ts:11`), so a TS-written pool starts with the empty string.
|
|
123
|
+
|
|
124
|
+
Reader (`src/sections/strings.ts:51-116`): throws unless `offsets[0] === 0` (`:86-90`) and offsets are
|
|
125
|
+
non-decreasing (`:91-97`); strings decode positionally via `StringTable.fromArray`. **`fromArray` prepends
|
|
126
|
+
`''` when entry 0 is not empty** (`../data/src/string-table.ts:24`), shifting every index by one: a writer
|
|
127
|
+
MUST emit `''` as entry 0.
|
|
128
|
+
|
|
129
|
+
## 5. Entities
|
|
130
|
+
|
|
131
|
+
| Type | Field | Since |
|
|
132
|
+
|---|---|---|
|
|
133
|
+
| `u32` | `count` | |
|
|
134
|
+
| `u32[count]` | `expressId` | |
|
|
135
|
+
| `u16[count]` | `typeEnum` | |
|
|
136
|
+
| `u32[count]` | `globalId` (string index) | |
|
|
137
|
+
| `u32[count]` | `name` (string index) | |
|
|
138
|
+
| `u32[count]` | `description` (string index) | |
|
|
139
|
+
| `u32[count]` | `objectType` (string index) | |
|
|
140
|
+
| `u8[count]` | `flags` | |
|
|
141
|
+
| `i32[count]` | `containedInStorey` | |
|
|
142
|
+
| `i32[count]` | `definedByType` | |
|
|
143
|
+
| `i32[count]` | `geometryIndex` | |
|
|
144
|
+
| `u16` | `typeRangeCount` | |
|
|
145
|
+
| `typeRangeCount × {u16 type, u32 start, u32 end}` | type ranges | |
|
|
146
|
+
| `u32[count]` | `rawTypeName` (string index; zeros when the table has none) | v15 |
|
|
147
|
+
|
|
148
|
+
Source: `src/sections/entities.ts:41-78`. Every column MUST be exactly `count` long: the writer writes each
|
|
149
|
+
typed array whole (`:49-58`); only `rawTypeName` is clipped (`:76-77`). Type ranges are written in the
|
|
150
|
+
table's `typeRanges` iteration order, which the builder fills in first-appearance row order with
|
|
151
|
+
`[firstRow, lastRow + 1]` (`../data/src/entity-table.ts:152-158`). The reader consumes and **discards** the
|
|
152
|
+
ranges, re-deriving them from `typeEnum` (`src/sections/entities.ts:114-120`), because pre-#3101 caches
|
|
153
|
+
stored a different meaning under the same version.
|
|
154
|
+
|
|
155
|
+
## 6. Properties and quantities
|
|
156
|
+
|
|
157
|
+
### 6.1 Properties (`src/sections/properties.ts:52-72`, read `:77-93`)
|
|
158
|
+
|
|
159
|
+
`u32 count`, then columns: `entityId u32`, `psetName u32`, `psetGlobalId u32`, `propName u32`,
|
|
160
|
+
`propType u8` (`PropertyValueType`, `../data/src/types.ts:178-190`), `valueString u32`, `valueReal f64`,
|
|
161
|
+
`valueInt i32`, `valueBool u8` (`255` = null), `unitId i32`; each `[count]`. Then three row indices in order
|
|
162
|
+
`entityIndex`, `psetIndex`, `propIndex`.
|
|
163
|
+
|
|
164
|
+
### 6.2 Quantities (`src/sections/quantities.ts:16-34`, read `:39-53`)
|
|
165
|
+
|
|
166
|
+
`u32 count`, then `entityId u32`, `qsetName u32`, `qsetGlobalId u32` (v17), `quantityName u32`,
|
|
167
|
+
`quantityType u8`, `value f64`, `unitId i32`, `formula u32`; each `[count]`. Then row indices
|
|
168
|
+
`entityIndex`, `qsetIndex`, `quantityIndex`.
|
|
169
|
+
|
|
170
|
+
### 6.3 Row index encoding (both tables)
|
|
171
|
+
|
|
172
|
+
`u32 keyCount`, then per key in `Map` iteration order: `u32 key`, `u32 n`, `u32 rows[n]`
|
|
173
|
+
(`src/sections/properties.ts:207-216`). The reader throws if any row `>= count`
|
|
174
|
+
(`src/sections/properties.ts:229-249`, `src/sections/quantities.ts:171-191`).
|
|
175
|
+
|
|
176
|
+
### 6.4 Source-retention semantics
|
|
177
|
+
|
|
178
|
+
`write()` serializes whatever the store's tables already hold. A STEP-parsed store resolves properties and
|
|
179
|
+
quantities lazily and never populates these tables, so **a cache written from a STEP parse carries
|
|
180
|
+
`count = 0` and three empty indices in both sections** (`README.md`, "Properties and quantities are not part
|
|
181
|
+
of that speedup"; `src/index.ts:12-18`). Empty is the correct encoding for that input, not data loss:
|
|
182
|
+
on-demand values come from the source bytes, which the caller must retain and re-attach
|
|
183
|
+
(`docs/guide/querying.md`). The cache records no flag distinguishing "empty because on-demand" from
|
|
184
|
+
"empty because the model has none"; a second writer given the same STEP input MUST also write empty tables.
|
|
185
|
+
|
|
186
|
+
## 7. Relationships
|
|
187
|
+
|
|
188
|
+
Two direction blocks, `forward` then `inverse` (`src/sections/relationships.ts:36-42`), each:
|
|
189
|
+
|
|
190
|
+
| Type | Field | Since |
|
|
191
|
+
|---|---|---|
|
|
192
|
+
| `u32` | `nodeCount` | |
|
|
193
|
+
| `nodeCount × {u32 entityId, u32 offset, u32 count}` | CSR node table, `offsets` Map iteration order | |
|
|
194
|
+
| `u32` | `edgeCount` | |
|
|
195
|
+
| `u32[edgeCount]` | `edgeTargets` | |
|
|
196
|
+
| `u16[edgeCount]` | `edgeTypes` (`RelationshipType`, `@ifc-lite/data`) | |
|
|
197
|
+
| `u32[edgeCount]` | `edgeRelIds` (the `IfcRel*` express id) | |
|
|
198
|
+
| `u32` | `shadowedGroupCount` (`g`) | v18 |
|
|
199
|
+
| `u32[g]` | `shadowedEdgeIndex` | v18 |
|
|
200
|
+
| `u32[g + 1]` | `shadowedGroupOffsets` | v18 |
|
|
201
|
+
| `u32` | `shadowedIdCount` | v18 |
|
|
202
|
+
| `u32[shadowedIdCount]` | `shadowedRelIds` | v18 |
|
|
203
|
+
|
|
204
|
+
Source: `src/sections/relationships.ts:44-87`. With no shadowing the trailer is `0`, `[0]`, `0`
|
|
205
|
+
(`:79-86`). Reader (`:207-268`): throws if any node range exceeds `edgeCount` (`:248-256`); the trailer is read
|
|
206
|
+
only when `version >= 18` (`:261`) and must satisfy (`:161-205`): `offsets.length == g + 1`, `offsets[0] == 0`,
|
|
207
|
+
`offsets[g] == shadowedIdCount`, groups non-empty (strictly increasing offsets), `shadowedEdgeIndex`
|
|
208
|
+
strictly ascending and `< edgeCount`.
|
|
209
|
+
|
|
210
|
+
## 8. Entity index (section 9)
|
|
211
|
+
|
|
212
|
+
### 8.1 Columns (`src/sections/entity-index.ts:48-56`, read `:58-85`)
|
|
213
|
+
|
|
214
|
+
| Type | Field |
|
|
215
|
+
|---|---|
|
|
216
|
+
| `u32` | `count` |
|
|
217
|
+
| `u32` | `typeNameCount` |
|
|
218
|
+
| `typeNameCount × lpstr` | `typeNames`, upper-case, first-appearance order |
|
|
219
|
+
| `u32[count]` | `ids` (express ids, non-decreasing) |
|
|
220
|
+
| `u32[count]` | `byteOffsets` into the source IFC |
|
|
221
|
+
| `u32[count]` | `byteLengths` |
|
|
222
|
+
| `u16[count]` | `typeIndices` into `typeNames` |
|
|
223
|
+
|
|
224
|
+
Rows are sorted by express id: the iterable path sorts (`:17-18`); the borrowed-column path accepts only
|
|
225
|
+
non-decreasing ids and keeps duplicate order (`src/sections/entity-index-columns.ts:20`). Type names are
|
|
226
|
+
upper-cased and deduplicated in first-row order (`entity-index-columns.ts:25-31`, `entity-index.ts:33-41`);
|
|
227
|
+
more than 65535 names throws on write. The reader throws on any `typeIndex >= typeNameCount`
|
|
228
|
+
(`src/sections/entity-index.ts:75-82`).
|
|
229
|
+
|
|
230
|
+
### 8.2 Parser relationship-coverage trailer (v28, #9947)
|
|
231
|
+
|
|
232
|
+
Appended inside the same section, directly after the columns (`src/writer.ts:121-125`); read only when
|
|
233
|
+
`version >= 28` (`src/reader.ts:146`). It exists only when the EntityIndex section exists.
|
|
234
|
+
Source: `src/sections/selection-relationships.ts:10-29`, read `:30-54`.
|
|
235
|
+
|
|
236
|
+
| Type | Field |
|
|
237
|
+
|---|---|
|
|
238
|
+
| `u32` | `present`: `0` → nothing follows; `1` → body; other → throw |
|
|
239
|
+
| `u32` | `typeRows` |
|
|
240
|
+
| `f64` | `typeReferences` (must be a non-negative safe integer) |
|
|
241
|
+
| 3 × id list | `missing`, `unverifiedTypeRows`, `retryTypeRows`; each `u32 n`, `u32[n]` |
|
|
242
|
+
| 3 × id map | `typeDefinitions`, `exceptionalSubjects`, `exceptionalDefinitionTargets`; each `u32 n`, then `n × {u32 key, u32 m, u32[m]}` |
|
|
243
|
+
| `u32 n`, `n × {u32 id, f64 references}` | `typeExceptionalReferences` (non-negative safe integers) |
|
|
244
|
+
| `u32 n`, `n × {u32 id, lpstr reason}` | `typeRefusals` |
|
|
245
|
+
|
|
246
|
+
## 9. Geometry (section 6)
|
|
247
|
+
|
|
248
|
+
All offsets in this section are relative to the **geometry section start**. The reader refuses geometry
|
|
249
|
+
for `version < 13` (§11).
|
|
250
|
+
|
|
251
|
+
### 9.1 Head (`src/sections/geometry-chunks.ts:8-33`, write `:210-236`, read `:247-270`)
|
|
252
|
+
|
|
253
|
+
| Type | Field | Since |
|
|
254
|
+
|---|---|---|
|
|
255
|
+
| `u32` | `headLength`: bytes from offset 4 to the end of the directory | 13 |
|
|
256
|
+
| `u32` | `meshCount` (meshes surviving `validateMeshes`) | 13 |
|
|
257
|
+
| `u32` | `totalVertices` (recomputed from surviving meshes) | 13 |
|
|
258
|
+
| `u32` | `totalTriangles` (`Σ indexCount / 3`) | 13 |
|
|
259
|
+
| CoordinateInfo | §9.2 | |
|
|
260
|
+
| source pool | §9.6 | v19 |
|
|
261
|
+
| `u32` | `chunkCount` | 13 |
|
|
262
|
+
| `chunkCount × 44` | directory, §9.3 | 13 |
|
|
263
|
+
|
|
264
|
+
The reader validates `4 + headLength` against where the head parse actually ended
|
|
265
|
+
(`src/sections/geometry-directory.ts:32-36`). It does **not** check `meshCount` against the directory's mesh
|
|
266
|
+
counts or the totals against decoded data.
|
|
267
|
+
|
|
268
|
+
### 9.2 CoordinateInfo (`src/sections/coordinate-info.ts:8-40`, read `:84-142`)
|
|
269
|
+
|
|
270
|
+
| Type | Field | Since | Read rule |
|
|
271
|
+
|---|---|---|---|
|
|
272
|
+
| `f64×3` | `originShift` | | |
|
|
273
|
+
| `f64×6` | `originalBounds` (min xyz, max xyz) | | |
|
|
274
|
+
| `f64×6` | `shiftedBounds` | | |
|
|
275
|
+
| `u8` | `hasLargeCoordinates` | | `=== 1` |
|
|
276
|
+
| `u8` [+ `f64×3`] | `wasmRtcOffset` presence [+ value] | v3 | `=== 1` (lenient) |
|
|
277
|
+
| `u8` [+ `f64`] | `buildingRotation` presence [+ radians] | v3 | `=== 1` (lenient) |
|
|
278
|
+
| `u8` [+ `f64×3` + `u8`] | `wasmRtcFrame` presence [+ x y z, `needsShift`] — RTC frame provenance | v20 | flags must be 0/1; frame validated (below) |
|
|
279
|
+
| `u8` [+ `f64`] | `boundsRecoveryFallbackCount` (recovery count) | v24 | flag must be 0/1 |
|
|
280
|
+
| `u8` [+ `f64`] | `lengthUnitScale` | v24 | flag must be 0/1 |
|
|
281
|
+
| `u8` [+ `f64×3`] | `siteOrigin` (IfcSite world origin, #9480) | v27 | flag must be 0/1 |
|
|
282
|
+
|
|
283
|
+
Absent optional values stay `undefined`; a recorded `0` count or scale is known, not absent (`:33-35`).
|
|
284
|
+
`wasmRtcFrame` is validated on write and read (`:55-76`): finite components, `needsShift` equal to
|
|
285
|
+
"`wasmRtcOffset` present", and when shifting, components `Object.is`-equal to the offset.
|
|
286
|
+
|
|
287
|
+
### 9.3 Chunk directory entry (44 bytes, `src/sections/geometry-chunks.ts:55-56`, `:223-236`)
|
|
288
|
+
|
|
289
|
+
| Offset | Type | Field |
|
|
290
|
+
|---|---|---|
|
|
291
|
+
| +0 | `f32×3` | `aabbMin` (world: `origin + position`, min in f64 then rounded to f32) |
|
|
292
|
+
| +12 | `f32×3` | `aabbMax`; an empty chunk stores all zeros (`:127-144`) |
|
|
293
|
+
| +24 | `u32` | `byteOffset` of the stored record, relative to section start |
|
|
294
|
+
| +28 | `u32` | `byteLength`: stored bytes (compressed length when compressed) |
|
|
295
|
+
| +32 | `u32` | `uncompressedLength` |
|
|
296
|
+
| +36 | `u32` | `meshCount` |
|
|
297
|
+
| +40 | `u32` | `flags` (`GeometryChunkFlags`, below) |
|
|
298
|
+
|
|
299
|
+
Layout rules the reader **enforces** (`src/sections/geometry-directory.ts:62-77`): chunk 0 starts at
|
|
300
|
+
`4 + headLength`, and each chunk starts exactly where the previous one ends (no gaps, directory order =
|
|
301
|
+
file order). A chunk whose `[byteOffset, byteOffset + byteLength)` runs past the buffer is rejected
|
|
302
|
+
(`src/sections/geometry-chunks.ts:372-376`).
|
|
303
|
+
|
|
304
|
+
### Geometry chunk flags
|
|
305
|
+
|
|
306
|
+
`GeometryChunkFlags` (`src/types.ts:179-183`). The reader tests only `DeflateRaw`; other bits are ignored
|
|
307
|
+
(`src/sections/geometry-chunks.ts:301`).
|
|
308
|
+
|
|
309
|
+
| Bit | Mask | Name | Meaning |
|
|
310
|
+
|---|---|---|---|
|
|
311
|
+
| 0 | `0x0001` | `DeflateRaw` | Stored bytes are a raw DEFLATE stream (RFC 1951, no zlib/gzip wrapper) of the record. |
|
|
312
|
+
|
|
313
|
+
### 9.4 Chunk records and compression
|
|
314
|
+
|
|
315
|
+
A chunk record is the concatenation of `meshCount` mesh records (§9.5), stored raw or deflate-raw.
|
|
316
|
+
|
|
317
|
+
Decode (`src/sections/geometry-chunks.ts:293-330`): inflate if flagged; throw unless the inflated length equals
|
|
318
|
+
`uncompressedLength` (`:302-304`); decode `meshCount` records; throw unless they consume the record exactly
|
|
319
|
+
(`:324-328`). A corrupt DEFLATE stream rejects with the platform `DecompressionStream` error, unwrapped.
|
|
320
|
+
|
|
321
|
+
Write-side storage rule (`src/sections/geometry-chunks.ts:183-187`, `src/sections/geometry-codec.ts:19-24`):
|
|
322
|
+
|
|
323
|
+
1. If compression is disabled (`compressGeometryChunks: false`) or `uncompressedLength < 65536`
|
|
324
|
+
(`GEOMETRY_CHUNK_COMPRESS_MIN_BYTES`, `src/types.ts:176`): store raw, flag clear.
|
|
325
|
+
2. Otherwise `chooseStoredGeometryChunk`: deflate-raw the record; store the compressed bytes and set
|
|
326
|
+
`DeflateRaw` **only when the compressed length is strictly smaller** than the raw length; else store raw,
|
|
327
|
+
flag clear. The worker path uses the same function (`src/workers/geometry-compression-handler.ts:24`).
|
|
328
|
+
|
|
329
|
+
The TS writer's compressor is `CompressionStream('deflate-raw')`; nothing in the format requires that
|
|
330
|
+
compressor. Compression concurrency (4 chunks) does not affect output order (`:196-202`).
|
|
331
|
+
|
|
332
|
+
**Chunk grouping policy (write side only).** Readers trust only the directory; the grouping can change
|
|
333
|
+
without a version bump (`src/types.ts:168-171`). The TS writer, for reproducibility
|
|
334
|
+
(`src/sections/geometry-chunks.ts:78-125`):
|
|
335
|
+
|
|
336
|
+
- Cell key per mesh: `floor((origin + firstVertex) / 32)` per axis in f64 (`GEOMETRY_CHUNK_CELL_SIZE`);
|
|
337
|
+
meshes with no vertex use `origin`; a non-finite cell uses the single key `nan`.
|
|
338
|
+
- Meshes are visited in input order. A mesh joins the open chunk of its cell unless that chunk is non-empty
|
|
339
|
+
and adding the mesh's exact record size would exceed 8 MiB (`GEOMETRY_CHUNK_SOFT_BYTES`); then that chunk
|
|
340
|
+
is closed (appended to the output) and a new one opened **under the same Map key, keeping the key's
|
|
341
|
+
original insertion position**. A mesh never splits.
|
|
342
|
+
- Output order: chunks in the order they were closed, then the still-open chunks in cell-key first-insertion
|
|
343
|
+
order. `onGeometryOrder` receives the meshes in this order (`:159`).
|
|
344
|
+
|
|
345
|
+
### 9.5 Mesh record (`src/sections/geometry.ts:58-115`, read `:205-300`)
|
|
346
|
+
|
|
347
|
+
| Type | Field | Since | Read behaviour |
|
|
348
|
+
|---|---|---|---|
|
|
349
|
+
| `u32` | `expressId` | | |
|
|
350
|
+
| `u32` | `vertexCount` (`positions.length / 3`) | | `> 100,000,000` → throw |
|
|
351
|
+
| `u32` | `indexCount` | | `> 300,000,000` → throw |
|
|
352
|
+
| `f32×4` | `color` RGBA | | |
|
|
353
|
+
| `lpstr` | `ifcType` | v2 | `''` → `undefined` |
|
|
354
|
+
| `u8` | `geometryClass` | v5 | |
|
|
355
|
+
| `u32` | `geometryItemId` (`0xFFFFFFFF` absent) | v14 | |
|
|
356
|
+
| `u32` | `materialId` (`0xFFFFFFFF` absent) | v14 | |
|
|
357
|
+
| `f64×3` | `origin` (world = origin + position; zeros when absent) | v6 | all-zero (incl. `-0`) → `undefined` |
|
|
358
|
+
| `f32[3V]` | `positions` | | any NaN/±Inf → throw |
|
|
359
|
+
| `f32[3V]` | `normals` | | any NaN/±Inf → throw |
|
|
360
|
+
| `u32[I]` | `indices` | | not range-checked unless provenance present |
|
|
361
|
+
| provenance | §9.6 | v19 | |
|
|
362
|
+
| `f32`, `f32` | finish `metallic`, `roughness` (NaN = absent) | v22 | non-finite → absent |
|
|
363
|
+
| metadata | `u8 flags` + payloads, below | v25 | unknown flag bit → throw |
|
|
364
|
+
|
|
365
|
+
Write-side filter (`src/sections/geometry.ts:18-51`): meshes with `vertexCount`/`indexCount` over the caps
|
|
366
|
+
above, or `normals.length !== positions.length`, are dropped with a warning before grouping. NaN vertex data
|
|
367
|
+
is **not** filtered on write.
|
|
368
|
+
|
|
369
|
+
Mesh-metadata trailer (`src/sections/mesh-metadata.ts:25-79`), payloads in flag order:
|
|
370
|
+
|
|
371
|
+
| Bit | Mask | Field | Payload |
|
|
372
|
+
|---|---|---|---|
|
|
373
|
+
| 0 | `0x01` | `shadingColor` | `f32×4` (RGBA) |
|
|
374
|
+
| 1 | `0x02` | `localBounds` | `f32×3` min, `f32×3` max |
|
|
375
|
+
| 2 | `0x04` | `localToWorld` | `f64×16`, row-major (`../geometry/src/types.ts:191-198`) |
|
|
376
|
+
|
|
377
|
+
### 9.6 Appearance provenance (v19)
|
|
378
|
+
|
|
379
|
+
Head pool (`src/sections/appearance-provenance.ts:78-92`), after CoordinateInfo: `u32 poolCount`, then per
|
|
380
|
+
entry `u32 length`, `u32[length]`. Read rules: `poolCount <= meshCount`; each `length` non-zero, a multiple
|
|
381
|
+
of 3, `<= 300,000,000`, and within the declared head. Meshes whose mode would be 0 or 1 (no provenance, or
|
|
382
|
+
canonical identity) are skipped before pooling, so a model of only such meshes writes `poolCount = 0`. Over the
|
|
383
|
+
rest, the pool holds each distinct `sourceIndices` array **by object identity**, in first-appearance order over
|
|
384
|
+
the surviving meshes in input order (`:69-77`).
|
|
385
|
+
|
|
386
|
+
Per-mesh record (`:40-67`): `u8 mode`, then:
|
|
387
|
+
|
|
388
|
+
| Mode | Meaning | Payload |
|
|
389
|
+
|---|---|---|
|
|
390
|
+
| 0 | no provenance | — |
|
|
391
|
+
| 1 | canonical identity: source indices equal the mesh indices **and** no corner map (`:31`); with a corner map the mesh is mode 3 or 5 even when the indices are equal | — |
|
|
392
|
+
| 2 | inline source indices | `u32 n`, `u32[n]` |
|
|
393
|
+
| 3 | inline source + corner map | `u32 n`, `u32[n]`, `u32[indexCount]` |
|
|
394
|
+
| 4 | pooled source | `u32 poolIndex` |
|
|
395
|
+
| 5 | pooled source + corner map | `u32 poolIndex`, `u32[indexCount]` |
|
|
396
|
+
| > 5 | — | throw |
|
|
397
|
+
|
|
398
|
+
Through `buildGeometrySectionV13` every mode-2/3 source is in the pool, so the TS writer emits only modes
|
|
399
|
+
0, 1, 4 and 5; readers accept 2 and 3. Both sides run the same validation (`:13-27`): `geometryItemId` in
|
|
400
|
+
`(0, 0xFFFFFFFF)`, no `entityIds`, non-empty `indices` with length a multiple of 3 and every index
|
|
401
|
+
`< vertexCount`, and corner entries in range. Failure throws `malformed canonical appearance provenance`.
|
|
402
|
+
|
|
403
|
+
### 9.7 Header vs geometry-head totals
|
|
404
|
+
|
|
405
|
+
The file header's `totalVertices`/`totalTriangles` come from the caller (`src/writer.ts:146-147`), the
|
|
406
|
+
geometry head's from the meshes actually written (`src/sections/geometry.ts:46-47`). They differ when
|
|
407
|
+
`validateMeshes` drops a mesh. Readers return the geometry head's values (`src/sections/geometry-chunks.ts:394-398`).
|
|
408
|
+
|
|
409
|
+
### 9.8 Instanced shards (section 10)
|
|
410
|
+
|
|
411
|
+
`u32 count`, then per shard `u32 length`, `u8[length]` (`src/sections/instanced-shards.ts:17-27`). Each shard
|
|
412
|
+
is an opaque, self-describing IFNS blob stored verbatim (layout, versioning and stride rules:
|
|
413
|
+
`../geometry/src/packed-instanced-decoder.ts:6-80`, matching the Rust `wire.rs`). The reader checks each
|
|
414
|
+
length against remaining bytes (`:29-52`), and reads the section only when geometry was read
|
|
415
|
+
(`src/reader.ts:168-172`). Shard order is the producer's.
|
|
416
|
+
|
|
417
|
+
## 10. Truncated and corrupt input
|
|
418
|
+
|
|
419
|
+
Every failure below is a thrown `Error` (or a rejected promise for geometry). Callers treat a throw as a miss
|
|
420
|
+
and rebuild; the viewer does (`apps/viewer/src/hooks/ifcCacheDecode.ts:139-144`). Representative cases are
|
|
421
|
+
pinned in `src/cache.test.ts:471` and `src/sections/*.test.ts`.
|
|
422
|
+
|
|
423
|
+
| Input | Result |
|
|
424
|
+
|---|---|
|
|
425
|
+
| Buffer shorter than any declared field or array | `BufferReader: read past end of buffer` (`src/utils/buffer-utils.ts:211-218`) |
|
|
426
|
+
| Bad magic / newer version | throw (`src/sections/header.ts:75-84`) |
|
|
427
|
+
| Missing Strings/Entities/Properties/Quantities/Relationships | `Missing required … section` (`src/reader.ts:91-126`) |
|
|
428
|
+
| Section bytes overrun into the next section | **Not detected**: the reader never applies the table's `size`; decoding continues into whatever follows until a structural check or end of buffer stops it |
|
|
429
|
+
| Corrupt string offsets, row indices, CSR ranges, shadow trailer, type indices, coverage flag | throw (§4, §6.3, §7, §8) |
|
|
430
|
+
| Geometry `headLength` / chunk-0 anchor / contiguity mismatch | throw (`src/sections/geometry-directory.ts:32-77`) |
|
|
431
|
+
| Chunk range past buffer end; inflated length ≠ `uncompressedLength`; record under- or over-consumption | throw / reject (§9.3, §9.4) |
|
|
432
|
+
| Non-finite vertex data, unknown metadata bits, bad provenance, bad CoordinateInfo presence flags | throw (§9.2, §9.5, §9.6) |
|
|
433
|
+
| Truncated shard | `Truncated InstancedShards` (`src/sections/instanced-shards.ts:37-45`) |
|
|
434
|
+
|
|
435
|
+
## 11. Reader compatibility (current reader)
|
|
436
|
+
|
|
437
|
+
`readHeader` accepts any `version <= 28` (`src/sections/header.ts:82`). `read()` then decodes each section with
|
|
438
|
+
the current layout plus the version gates below. Only `read()`'s geometry path refuses old versions outright:
|
|
439
|
+
`version < 13` with `HasGeometry`, a Geometry section and `!skipGeometry` throws
|
|
440
|
+
`… geometry is no longer readable (v13+ only); discard and rebuild` (`src/reader.ts:153-161`). The viewer refuses
|
|
441
|
+
any `version < 13` before decoding (`apps/viewer/src/hooks/ifcCacheDecode.ts:141-144`), and its lookup key embeds
|
|
442
|
+
`FORMAT_VERSION`, so it never opens an older entry in normal operation.
|
|
443
|
+
|
|
444
|
+
| Data | Introduced | Gate | Older entry reads as |
|
|
445
|
+
|---|---|---|---|
|
|
446
|
+
| `Entities.rawTypeName` | v15 | `src/sections/entities.ts:125` | absent; enum-only type names |
|
|
447
|
+
| Relationship shadow trailer | v18 | `src/sections/relationships.ts:261` | no `shadowedRelationshipIds` |
|
|
448
|
+
| Entity-index coverage trailer | v28 | `src/reader.ts:146` | `selectionRelationshipIndex` undefined |
|
|
449
|
+
| Mesh `geometryItemId`/`materialId` | v14 | `src/sections/geometry.ts:243` | both undefined |
|
|
450
|
+
| Provenance + head pool | v19 | `src/sections/geometry.ts:296`, `src/sections/geometry-chunks.ts:254` | no `appearanceSource` |
|
|
451
|
+
| Finish trailer | v22 | `src/sections/geometry.ts:297` | no `material` |
|
|
452
|
+
| Mesh-metadata trailer | v25 | `src/sections/geometry.ts:298` | fields absent |
|
|
453
|
+
| `wasmRtcFrame` | v20 | `src/sections/coordinate-info.ts:101` | undefined |
|
|
454
|
+
| Recovery count, `lengthUnitScale` | v24 | `src/sections/coordinate-info.ts:117` | undefined |
|
|
455
|
+
| `siteOrigin` | v27 | `src/sections/coordinate-info.ts:122` | absent |
|
|
456
|
+
| `ifcType`/`geometryClass`/`origin`; CoordinateInfo RTC offset + rotation | v2/v5/v6; v3 | `src/sections/geometry.ts:227-259`, `src/sections/coordinate-info.ts:96` | unreachable through `read()` (geometry < 13 refused) |
|
|
457
|
+
| `Quantities.qsetGlobalId` | v17 | **none** | v ≤ 16 with `count > 0` is misread (column shift); `count = 0` is layout-identical |
|
|
458
|
+
| `Properties.psetGlobalId` | at v16 (#3603), no bump | **none** | pre-#3603 v ≤ 16 with `count > 0` is misread |
|
|
459
|
+
|
|
460
|
+
Direct use of the exported `readGeometryHeadV13`, `openGeometryChunksV13` and `decodeGeometryChunk` takes the
|
|
461
|
+
version as an argument; `readGeometryHeadV13` defaults it to `FORMAT_VERSION` (`src/sections/geometry-chunks.ts:247`).
|
|
462
|
+
|
|
463
|
+
## 12. Conformance for a second writer
|
|
464
|
+
|
|
465
|
+
A second writer (e.g. a native Rust writer) conforms when all of the following hold. **Counts alone are
|
|
466
|
+
never sufficient**: equal mesh, edge or row counts can hide wrong ids, coordinates, units, colours or
|
|
467
|
+
relationships.
|
|
468
|
+
|
|
469
|
+
1. **Self-reproducible.** For the same input, it produces byte-identical files across runs and across thread
|
|
470
|
+
counts (e.g. every `RAYON_NUM_THREADS` value).
|
|
471
|
+
2. **Readable.** `BinaryCacheReader.read()` on `main` accepts the file and `FORMAT_VERSION` matches the TS
|
|
472
|
+
writer's.
|
|
473
|
+
3. **Scalar sections byte-identical.** For the same input, the header (except as allowed in 5), Strings,
|
|
474
|
+
Entities, Properties, Quantities, Relationships, EntityIndex (including the v28 trailer) and
|
|
475
|
+
InstancedShards (verbatim IFNS, never compressed) are byte-identical to the TS writer's. That fixes every
|
|
476
|
+
order this document leaves to iteration order: pool order, row order, `typeRanges`, row-index and CSR
|
|
477
|
+
node order, entity-index row and type-name order, and coverage map order.
|
|
478
|
+
4. **Geometry compared by exact decoded payload and directory semantics.** After inflating every chunk with
|
|
479
|
+
`DeflateRaw` set:
|
|
480
|
+
- the head bytes (`headLength` through `chunkCount`, i.e. counts, CoordinateInfo and the source pool) are
|
|
481
|
+
byte-identical;
|
|
482
|
+
- the chunk count and order, and per chunk `aabbMin`, `aabbMax`, `uncompressedLength`, `meshCount` and
|
|
483
|
+
every flag bit other than `DeflateRaw`, are identical;
|
|
484
|
+
- each chunk's decoded record bytes are byte-identical (so every mesh field: express id, f32 position,
|
|
485
|
+
normal and index bits, colour, origin, source ids, provenance, finish, `shadingColor`, `localBounds`,
|
|
486
|
+
`localToWorld`).
|
|
487
|
+
5. **Storage representation may differ, and every difference is checked, not ignored.** Different valid
|
|
488
|
+
DEFLATE streams may change a chunk's stored `byteLength`, every later `byteOffset`, the per-chunk
|
|
489
|
+
`DeflateRaw` bit (which follows the strictly-smaller rule of §9.4 under each writer's own compressor), and
|
|
490
|
+
consequently the Geometry section's `size` and the `offset` of any section after it. For each such
|
|
491
|
+
difference the test MUST check: the stored bytes inflate (when flagged) or equal (when not) the identical
|
|
492
|
+
decoded payload; `byteLength` equals the stored byte count; offsets satisfy the §9.3 layout rules; the flag
|
|
493
|
+
is clear for chunks under 64 KiB or with compression disabled. A comparison that masks the flag, skips the
|
|
494
|
+
inflate, or loosens a value tolerance does not meet this criterion.
|
|
495
|
+
6. **Same semantics for empty tables.** Given a STEP-parsed store, Properties and Quantities are empty in both
|
|
496
|
+
writers (§6.4).
|
|
497
|
+
7. **Negative cases.** The conformance suite also covers truncated input, bad magic, a newer version, and a
|
|
498
|
+
corrupt chunk length (§10), against both writers' outputs.
|
|
499
|
+
|
|
500
|
+
## 13. Version history
|
|
501
|
+
|
|
502
|
+
Every bump changes the viewer's cache key, so entries written by an older version re-parse once.
|
|
503
|
+
|
|
504
|
+
| Version | Change | Bytes changed | Source |
|
|
505
|
+
|---|---|---|---|
|
|
506
|
+
| ≤ 12 | Sequential geometry section; layouts no longer written or read | — | `src/types.ts:19-77` |
|
|
507
|
+
| 13 | Chunked geometry: head, directory, per-chunk deflate-raw (#1682) | yes | `src/types.ts:78-89` |
|
|
508
|
+
| 14 | Mesh `geometryItemId`, `materialId` (#3199) | yes | `src/types.ts:91-106` |
|
|
509
|
+
| 15 | Entities `rawTypeName` column | yes | `src/types.ts:108-119` |
|
|
510
|
+
| 16 | IFNS v2 shards (92-byte stride, #2985); deliberate key split | shard payload | `src/types.ts:121-135` |
|
|
511
|
+
| 17 | Quantities `qsetGlobalId` (#3606) | yes | `src/types.ts:137-143` |
|
|
512
|
+
| 18 | Relationship shadowed-rel-ids trailer (#3782) | yes | `src/types.ts:145-155` |
|
|
513
|
+
| 19 | Appearance provenance per mesh + head source pool | yes | `src/types.ts:157-159` |
|
|
514
|
+
| 20 | CoordinateInfo `wasmRtcFrame` (#4842) | yes | `src/types.ts:160-161` |
|
|
515
|
+
| 21 | Relationship indexing covers every exact `IfcRel*` class (#4205) | no | `src/types.ts:162-164` |
|
|
516
|
+
| 22 | Mesh finish trailer (#5582) | yes | `src/sections/geometry.ts:117-124` |
|
|
517
|
+
| 23 | Finishes on type, mapped and instanced geometry (IFNS field 2, #5984) | shard payload | commit `888a9a72e` |
|
|
518
|
+
| 24 | CoordinateInfo `boundsRecoveryFallbackCount`, `lengthUnitScale` (#7239) | yes | `src/types.ts:166` |
|
|
519
|
+
| 25 | Mesh `shadingColor`/`localBounds`/`localToWorld` trailer (#7350) | yes | `src/types.ts:166` |
|
|
520
|
+
| 26 | Keys miss v25 graphs with a misread relationship edge (#9192) | no | `src/types.ts:166` |
|
|
521
|
+
| 27 | CoordinateInfo `siteOrigin` (#9480) | yes | `src/types.ts:166` |
|
|
522
|
+
| 28 | Parser relationship-coverage trailer in the EntityIndex section (#9947) | yes | `src/types.ts:165` |
|
package/dist/adapt.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { StringTable, EntityTable, PropertyTable, QuantityTable, RelationshipGraph, SpatialHierarchy } from '@ifc-lite/data';
|
|
1
|
+
import type { IfcStoreBase, StringTable, EntityTable, PropertyTable, QuantityTable, RelationshipGraph, SpatialHierarchy } from '@ifc-lite/data';
|
|
2
2
|
import { type CacheDataStore, type CacheEntityIndex } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* The subset of `@ifc-lite/parser`'s `IfcDataStore` (what `IfcParser.parseColumnar`
|
|
@@ -9,6 +9,7 @@ import { type CacheDataStore, type CacheEntityIndex } from './types.js';
|
|
|
9
9
|
* `@ifc-lite/data`, which `@ifc-lite/cache` depends on regardless.
|
|
10
10
|
*/
|
|
11
11
|
export interface ParsedIfcStore {
|
|
12
|
+
selectionRelationshipIndex?: IfcStoreBase['selectionRelationshipIndex'];
|
|
12
13
|
schemaVersion: 'IFC2X3' | 'IFC4' | 'IFC4X3' | 'IFC5';
|
|
13
14
|
entityCount: number;
|
|
14
15
|
strings: StringTable;
|
package/dist/adapt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapt.d.ts","sourceRoot":"","sources":["../src/adapt.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,gBAAgB,GAAG;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACvD;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"adapt.d.ts","sourceRoot":"","sources":["../src/adapt.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAiB,KAAK,cAAc,EAAE,KAAK,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEvF;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,0BAA0B,CAAC,EAAE,YAAY,CAAC,4BAA4B,CAAC,CAAC;IACxE,aAAa,EAAE,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,WAAW,CAAC;IACrB,QAAQ,EAAE,WAAW,CAAC;IACtB,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,aAAa,CAAC;IAC1B,aAAa,EAAE,iBAAiB,CAAC;IACjC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CAAC,EAAE,gBAAgB,GAAG;QAAE,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACvD;AAsBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CActE"}
|
package/dist/adapt.js
CHANGED
|
@@ -55,6 +55,7 @@ function toSchemaVersion(schemaVersion) {
|
|
|
55
55
|
export function toCacheDataStore(store) {
|
|
56
56
|
// @raw-entity-enumeration-ok Cache metadata counts the parsed source snapshot, not live overlay rows.
|
|
57
57
|
return {
|
|
58
|
+
selectionRelationshipIndex: store.selectionRelationshipIndex,
|
|
58
59
|
schema: toSchemaVersion(store.schemaVersion),
|
|
59
60
|
entityCount: store.entityCount || store.entities.count,
|
|
60
61
|
strings: store.strings,
|
package/dist/adapt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapt.js","sourceRoot":"","sources":["../src/adapt.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"adapt.js","sourceRoot":"","sources":["../src/adapt.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAW/D,OAAO,EAAE,aAAa,EAA8C,MAAM,YAAY,CAAC;AAuCvF;;;;;;;;GAQG;AACH,SAAS,eAAe,CAAC,aAA8C;IACrE,QAAQ,aAAa,EAAE,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC,IAAI,CAAC;QAC5B,KAAK,QAAQ;YACX,OAAO,aAAa,CAAC,MAAM,CAAC;QAC9B;YACE,OAAO,aAAa,CAAC,MAAM,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAqB;IACpD,sGAAsG;IACtG,OAAO;QACL,0BAA0B,EAAE,KAAK,CAAC,0BAA0B;QAC5D,MAAM,EAAE,eAAe,CAAC,KAAK,CAAC,aAAa,CAAC;QAC5C,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK;QACtD,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,WAAW,EAAE,KAAK,CAAC,WAAW;KAC/B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-inflate-pool.d.ts","sourceRoot":"","sources":["../src/chunk-inflate-pool.ts"],"names":[],"mappings":"AAIA,sGAAsG;AACtG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,KAAK,uBAAuB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/** `@ifc-lite/cache/chunk-inflate-pool`: a separate entry, so a viewer can import the pool lazily. */
|
|
5
|
+
export { ChunkInflatePool, CorruptChunkError } from './workers/chunk-inflate-pool.js';
|
|
6
|
+
//# sourceMappingURL=chunk-inflate-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-inflate-pool.js","sourceRoot":"","sources":["../src/chunk-inflate-pool.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D,sGAAsG;AACtG,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAgC,MAAM,iCAAiC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -34,13 +34,13 @@ export { BinaryCacheReader } from './reader.js';
|
|
|
34
34
|
export { toCacheDataStore } from './adapt.js';
|
|
35
35
|
export type { ParsedIfcStore } from './adapt.js';
|
|
36
36
|
export { MAGIC, FORMAT_VERSION, HEADER_SIZE, SECTION_ENTRY_SIZE, SectionType, SchemaVersion, HeaderFlags, SectionFlags, GeometryChunkFlags, GEOMETRY_CHUNK_CELL_SIZE, GEOMETRY_CHUNK_SOFT_BYTES, GEOMETRY_CHUNK_COMPRESS_MIN_BYTES, } from './types.js';
|
|
37
|
-
export { openGeometryChunksV13, readGeometryHeadV13, decodeGeometryChunk, groupMeshesIntoChunks, buildGeometrySectionV13, } from './sections/geometry-chunks.js';
|
|
37
|
+
export { openGeometryChunksV13, readGeometryHeadV13, decodeGeometryChunk, groupMeshesIntoChunks, buildGeometrySectionV13, inflateRaw, } from './sections/geometry-chunks.js';
|
|
38
38
|
export { readInstancedShards } from './sections/instanced-shards.js';
|
|
39
|
-
export type { GeometryHead } from './sections/geometry-chunks.js';
|
|
39
|
+
export type { ChunkDecodeOptions, GeometryHead, ChunkInflate } from './sections/geometry-chunks.js';
|
|
40
40
|
export type { GeometryChunkInfo } from './types.js';
|
|
41
41
|
export type { CacheHeader, SectionEntry, CacheWriteOptions, CacheReadOptions, CacheHeaderInfo, CacheReadResult, CachedEntityIndexColumns, CacheEntityIndex, CacheEntityRef, CacheDataStore, } from './types.js';
|
|
42
42
|
export { xxhash64, xxhash64Hex } from './utils/hash.js';
|
|
43
|
-
export { BufferWriter, BufferReader } from './utils/buffer-utils.js';
|
|
43
|
+
export { ArrayArena, BufferWriter, BufferReader } from './utils/buffer-utils.js';
|
|
44
44
|
export { computeSourceFingerprint, computeSourceFingerprintFromBlob, HEAD_TAIL_BYTES, INTERIOR_WINDOW_BYTES, INTERIOR_WINDOWS, sourceModelIdentity, } from './source-fingerprint.js';
|
|
45
45
|
export type { SourceFingerprint } from './source-fingerprint.js';
|
|
46
46
|
export { parseGLB, extractGLBMapping, parseGLBToMeshData, loadGLBToMeshData, } from './glb.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EACL,KAAK,EACL,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EACL,KAAK,EACL,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,wBAAwB,EACxB,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,GACX,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAEpG,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,YAAY,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKjF,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,eAAe,EACf,qBAAqB,EACrB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGjE,OAAO,EACL,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -38,11 +38,11 @@ export { MAGIC, FORMAT_VERSION, HEADER_SIZE, SECTION_ENTRY_SIZE, SectionType, Sc
|
|
|
38
38
|
// v13 chunked geometry: incremental access for streamed cache-hit loads
|
|
39
39
|
// (issue #1682 phase 4). openGeometryChunksV13 wants the Geometry section's
|
|
40
40
|
// absolute offset from the header's section table.
|
|
41
|
-
export { openGeometryChunksV13, readGeometryHeadV13, decodeGeometryChunk, groupMeshesIntoChunks, buildGeometrySectionV13, } from './sections/geometry-chunks.js';
|
|
41
|
+
export { openGeometryChunksV13, readGeometryHeadV13, decodeGeometryChunk, groupMeshesIntoChunks, buildGeometrySectionV13, inflateRaw, } from './sections/geometry-chunks.js';
|
|
42
42
|
export { readInstancedShards } from './sections/instanced-shards.js';
|
|
43
43
|
// Utilities
|
|
44
44
|
export { xxhash64, xxhash64Hex } from './utils/hash.js';
|
|
45
|
-
export { BufferWriter, BufferReader } from './utils/buffer-utils.js';
|
|
45
|
+
export { ArrayArena, BufferWriter, BufferReader } from './utils/buffer-utils.js';
|
|
46
46
|
// Source fingerprinting (#5138 PR 7b: moved from the viewer so headless
|
|
47
47
|
// callers — the CLI, the MCP server — can compute the SAME
|
|
48
48
|
// `filterIdentity` the viewer stores as `FederatedModel.sourceFingerprint`)
|