@ifc-lite/renderer 1.37.0 → 1.38.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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Content-based change tracking for the per-frame hide/isolate sets.
3
+ *
4
+ * The renderer caches per-batch visibility keyed by the version this tracker
5
+ * produces, so correctness demands the version bumps EXACTLY when the
6
+ * effective filter changes:
7
+ * - Callers may mutate the SAME Set object in place between frames (the
8
+ * per-mesh filters read the live set every frame, so a reference-compare
9
+ * epoch would silently diverge from them) — content comparison against a
10
+ * snapshot catches this.
11
+ * - Callers may pass a FRESH Set with identical content every frame (zustand
12
+ * slices rebuild the Set on every action) — content comparison avoids a
13
+ * needless cache rebuild that a reference compare would force.
14
+ */
15
+ export declare class VisibilityEpochTracker {
16
+ private version;
17
+ private hiddenSnapshot;
18
+ private isolatedSnapshot;
19
+ /**
20
+ * Feed the sets passed to render(); returns the current version, bumped when
21
+ * the content changed since the previous call. An EMPTY hidden set is
22
+ * equivalent to no hidden filter; an EMPTY isolated set is NOT equivalent to
23
+ * null (it isolates nothing, i.e. hides everything). Cost is
24
+ * O(|hidden| + |isolated|) membership checks per call — strictly below the
25
+ * O(scene elements) per-batch scan this version key lets the renderer skip.
26
+ */
27
+ update(hiddenIds: ReadonlySet<number> | null | undefined, isolatedIds: ReadonlySet<number> | null | undefined): number;
28
+ getVersion(): number;
29
+ }
30
+ //# sourceMappingURL=visibility-epoch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visibility-epoch.d.ts","sourceRoot":"","sources":["../src/visibility-epoch.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,OAAO,CAAK;IAIpB,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,gBAAgB,CAAoC;IAE5D;;;;;;;OAOG;IACH,MAAM,CACJ,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,EACjD,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAClD,MAAM;IAaT,UAAU,IAAI,MAAM;CAGrB"}
@@ -0,0 +1,64 @@
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
+ /**
5
+ * Content-based change tracking for the per-frame hide/isolate sets.
6
+ *
7
+ * The renderer caches per-batch visibility keyed by the version this tracker
8
+ * produces, so correctness demands the version bumps EXACTLY when the
9
+ * effective filter changes:
10
+ * - Callers may mutate the SAME Set object in place between frames (the
11
+ * per-mesh filters read the live set every frame, so a reference-compare
12
+ * epoch would silently diverge from them) — content comparison against a
13
+ * snapshot catches this.
14
+ * - Callers may pass a FRESH Set with identical content every frame (zustand
15
+ * slices rebuild the Set on every action) — content comparison avoids a
16
+ * needless cache rebuild that a reference compare would force.
17
+ */
18
+ export class VisibilityEpochTracker {
19
+ version = 0;
20
+ // Snapshots (copies) of the last-seen effective sets. Copies, not the
21
+ // caller's references — an in-place mutation of the caller's Set must
22
+ // compare against what we saw LAST frame, not against itself.
23
+ hiddenSnapshot = null;
24
+ isolatedSnapshot = null;
25
+ /**
26
+ * Feed the sets passed to render(); returns the current version, bumped when
27
+ * the content changed since the previous call. An EMPTY hidden set is
28
+ * equivalent to no hidden filter; an EMPTY isolated set is NOT equivalent to
29
+ * null (it isolates nothing, i.e. hides everything). Cost is
30
+ * O(|hidden| + |isolated|) membership checks per call — strictly below the
31
+ * O(scene elements) per-batch scan this version key lets the renderer skip.
32
+ */
33
+ update(hiddenIds, isolatedIds) {
34
+ const hidden = hiddenIds && hiddenIds.size > 0 ? hiddenIds : null;
35
+ const isolated = isolatedIds ?? null;
36
+ const hiddenChanged = !contentEquals(hidden, this.hiddenSnapshot);
37
+ const isolatedChanged = !contentEquals(isolated, this.isolatedSnapshot);
38
+ if (hiddenChanged || isolatedChanged) {
39
+ this.version++;
40
+ if (hiddenChanged)
41
+ this.hiddenSnapshot = hidden ? new Set(hidden) : null;
42
+ if (isolatedChanged)
43
+ this.isolatedSnapshot = isolated ? new Set(isolated) : null;
44
+ }
45
+ return this.version;
46
+ }
47
+ getVersion() {
48
+ return this.version;
49
+ }
50
+ }
51
+ function contentEquals(live, snapshot) {
52
+ if (live === snapshot)
53
+ return true; // covers null === null
54
+ if (live === null || snapshot === null)
55
+ return false;
56
+ if (live.size !== snapshot.size)
57
+ return false;
58
+ for (const id of live) {
59
+ if (!snapshot.has(id))
60
+ return false;
61
+ }
62
+ return true;
63
+ }
64
+ //# sourceMappingURL=visibility-epoch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"visibility-epoch.js","sourceRoot":"","sources":["../src/visibility-epoch.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,sBAAsB;IACzB,OAAO,GAAG,CAAC,CAAC;IACpB,sEAAsE;IACtE,sEAAsE;IACtE,8DAA8D;IACtD,cAAc,GAA+B,IAAI,CAAC;IAClD,gBAAgB,GAA+B,IAAI,CAAC;IAE5D;;;;;;;OAOG;IACH,MAAM,CACJ,SAAiD,EACjD,WAAmD;QAEnD,MAAM,MAAM,GAAG,SAAS,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;QAClE,MAAM,QAAQ,GAAG,WAAW,IAAI,IAAI,CAAC;QACrC,MAAM,aAAa,GAAG,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,MAAM,eAAe,GAAG,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACxE,IAAI,aAAa,IAAI,eAAe,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,IAAI,aAAa;gBAAE,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YACzE,IAAI,eAAe;gBAAE,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAED,SAAS,aAAa,CACpB,IAAgC,EAChC,QAAoC;IAEpC,IAAI,IAAI,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,CAAC,uBAAuB;IAC3D,IAAI,IAAI,KAAK,IAAI,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACrD,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAC9C,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAAE,OAAO,KAAK,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ifc-lite/renderer",
3
- "version": "1.37.0",
3
+ "version": "1.38.1",
4
4
  "description": "WebGPU renderer for IFC-Lite",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -13,12 +13,12 @@
13
13
  }
14
14
  },
15
15
  "dependencies": {
16
- "@ifc-lite/spatial": "^1.14.12",
17
- "@ifc-lite/geometry": "^3.2.0"
16
+ "@ifc-lite/geometry": "^3.2.1",
17
+ "@ifc-lite/spatial": "^1.14.12"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@webgpu/types": "^0.1.71",
21
- "tsx": "^4.23.0",
21
+ "tsx": "^4.23.1",
22
22
  "typescript": "^6.0.3"
23
23
  },
24
24
  "license": "MPL-2.0",