soonspacejs 3.0.0-alpha.1 → 3.0.0-alpha.2

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/dist/index.esm.js CHANGED
@@ -25,7 +25,7 @@ import * as cn from "three/examples/jsm/utils/SkeletonUtils.js";
25
25
  import * as ul from "three/examples/jsm/libs/fflate.module.js";
26
26
  import { NURBSCurve as dl } from "three/examples/jsm/curves/NURBSCurve.js";
27
27
  import { RectAreaLightHelper as pl } from "three/examples/jsm/helpers/RectAreaLightHelper.js";
28
- const fl = "soonspacejs", ml = "3.0.0-alpha.1", ln = {
28
+ const fl = "soonspacejs", ml = "3.0.0-alpha.2", ln = {
29
29
  name: fl,
30
30
  version: ml
31
31
  }, ea = "[soonspacejs]: ";
@@ -6882,15 +6882,17 @@ class lu {
6882
6882
  enabled = !0;
6883
6883
  batchedEnabled = !0;
6884
6884
  rebuilds = 0;
6885
+ sourceParts = 0;
6886
+ batchCounts = { instancedBatches: 0, batchedBatches: 0, independentObjects: 0 };
6885
6887
  selection = /* @__PURE__ */ new Set();
6886
6888
  selectionDirty = !1;
6887
6889
  highlights = /* @__PURE__ */ new Map();
6888
6890
  highlightMaterial = new Jt({ color: 16753920, wireframe: !0, depthTest: !1, depthWrite: !1, toneMapped: !1, side: tt });
6889
6891
  add(e) {
6890
- this.entries.set(e.entity, e.parts.map((t, s) => ({ input: e, partIndex: s, matrix: new W(), visible: !1, eligible: !1 })));
6892
+ this.entries.has(e.entity) && this.remove(e.entity), this.entries.set(e.entity, e.parts.map((t, s) => ({ input: e, partIndex: s, matrix: new W(), visible: !1, eligible: !1 }))), this.sourceParts += e.parts.length;
6891
6893
  }
6892
6894
  remove(e) {
6893
- this.removeHighlight(e);
6895
+ this.removeHighlight(e), this.sourceParts -= this.entries.get(e)?.length ?? 0;
6894
6896
  for (const t of this.entries.get(e) ?? [])
6895
6897
  t.key && (this.groups.get(t.key)?.delete(t), this.dirtyGroups.add(t.key));
6896
6898
  this.entries.delete(e), this.bounds.delete(e);
@@ -6954,7 +6956,7 @@ class lu {
6954
6956
  }
6955
6957
  rebuildGroup(e) {
6956
6958
  for (const h of this.groupBatches.get(e) ?? [])
6957
- this.sideVariants?.unregister(h.object), h.object.removeFromParent(), (h.object instanceof Ye || h.object instanceof et) && h.object.dispose(), h.ownedMaterial?.dispose(), this.batches.delete(h), this.mappings.delete(h.object);
6959
+ this.sideVariants?.unregister(h.object), h.object.removeFromParent(), (h.object instanceof Ye || h.object instanceof et) && h.object.dispose(), h.ownedMaterial?.dispose(), this.batches.delete(h), this.countBatch(h, -1), this.mappings.delete(h.object);
6958
6960
  const t = [...this.groups.get(e) ?? []], s = [];
6959
6961
  if (t.length === 0) {
6960
6962
  this.groups.delete(e), this.groupBatches.delete(e);
@@ -7015,7 +7017,7 @@ class lu {
7015
7017
  }
7016
7018
  e.forEach((o) => {
7017
7019
  o.batch = n;
7018
- }), this.batches.add(n), t.push(n), this.mappings.set(i, n), this.sideVariants?.register(i), this.root.add(i), this.updateBatch(n);
7020
+ }), this.batches.add(n), this.countBatch(n, 1), t.push(n), this.mappings.set(i, n), this.sideVariants?.register(i), this.root.add(i), this.updateBatch(n);
7019
7021
  }
7020
7022
  updateBatch(e) {
7021
7023
  const { object: t } = e;
@@ -7043,19 +7045,21 @@ class lu {
7043
7045
  return this.bounds.get(e)?.clone() ?? new mt();
7044
7046
  }
7045
7047
  getStats() {
7046
- let e = 0, t = 0, s = 0;
7047
- return this.batches.forEach((r) => {
7048
- r.object instanceof et ? t++ : r.object instanceof Ye ? e++ : s++;
7049
- }), { instancedBatches: e, batchedBatches: t, independentObjects: s, rebuilds: this.rebuilds };
7048
+ const { instancedBatches: e, batchedBatches: t, independentObjects: s } = this.batchCounts;
7049
+ return { ...this.batchCounts, sourceParts: this.sourceParts, renderObjects: e + t + s, rebuilds: this.rebuilds };
7050
+ }
7051
+ countBatch(e, t) {
7052
+ const s = e.object instanceof et ? "batchedBatches" : e.object instanceof Ye ? "instancedBatches" : "independentObjects";
7053
+ this.batchCounts[s] += t;
7050
7054
  }
7051
7055
  clearBatches() {
7052
7056
  this.batches.forEach((e) => {
7053
7057
  this.sideVariants?.unregister(e.object), e.object.removeFromParent(), (e.object instanceof Ye || e.object instanceof et) && e.object.dispose(), e.ownedMaterial?.dispose();
7054
- }), this.batches.clear(), this.mappings.clear();
7058
+ }), this.batches.clear(), this.batchCounts = { instancedBatches: 0, batchedBatches: 0, independentObjects: 0 }, this.mappings.clear();
7055
7059
  }
7056
7060
  dispose() {
7057
7061
  for (const e of this.highlights.keys()) this.removeHighlight(e);
7058
- this.selection.clear(), this.highlightMaterial.dispose(), this.clearBatches(), this.entries.clear(), this.bounds.clear(), this.groups.clear(), this.groupBatches.clear(), this.root.removeFromParent();
7062
+ this.selection.clear(), this.highlightMaterial.dispose(), this.clearBatches(), this.entries.clear(), this.sourceParts = 0, this.bounds.clear(), this.groups.clear(), this.groupBatches.clear(), this.root.removeFromParent();
7059
7063
  }
7060
7064
  }
7061
7065
  async function za(a, e, t, s) {
@@ -7345,6 +7349,7 @@ class fu {
7345
7349
  pendingModels = /* @__PURE__ */ new Map();
7346
7350
  selected = /* @__PURE__ */ new Set();
7347
7351
  selectionDirty = !1;
7352
+ selectionHighlight = !0;
7348
7353
  get roots() {
7349
7354
  return [...this.nodes.values()].filter((e) => !e.parent).map((e) => e.entity);
7350
7355
  }
@@ -7491,7 +7496,7 @@ class fu {
7491
7496
  }
7492
7497
  }
7493
7498
  if (this.selectionDirty) {
7494
- const n = /* @__PURE__ */ new Set(), o = [...this.selected];
7499
+ const n = /* @__PURE__ */ new Set(), o = this.selectionHighlight ? [...this.selected] : [];
7495
7500
  for (; o.length; ) {
7496
7501
  const c = o.pop();
7497
7502
  n.has(c) || (n.add(c), o.push(...this.node(c).children));
@@ -7542,8 +7547,9 @@ class fu {
7542
7547
  getStats() {
7543
7548
  return { ...this.renderer.getStats(), updatedEntities: this.updatedEntities, entities: this.nodes.size };
7544
7549
  }
7545
- setSelection(e) {
7546
- e.forEach((t) => this.node(t)), this.selected = new Set(e), this.selectionDirty = !0, this.schedule();
7550
+ /** Selection identity is retained even when the optional visual overlay is disabled. */
7551
+ setSelection(e, t = {}) {
7552
+ e.forEach((s) => this.node(s)), this.selected = new Set(e), this.selectionHighlight = t.highlight !== !1, this.selectionDirty = !0, this.schedule();
7547
7553
  }
7548
7554
  getSelection() {
7549
7555
  return [...this.selected];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soonspacejs",
3
- "version": "3.0.0-alpha.1",
3
+ "version": "3.0.0-alpha.2",
4
4
  "homepage": "https://www.xwbuilders.com/soonspacejs/",
5
5
  "description": "SoonSpace.js 3.0 alpha",
6
6
  "module": "./dist/index.esm.js",
@@ -19,6 +19,7 @@ export declare class EntityCollection {
19
19
  private pendingModels;
20
20
  private selected;
21
21
  private selectionDirty;
22
+ private selectionHighlight;
22
23
  constructor(scene: Scene, requestRender: () => void, models: ModelResources, sideVariants?: Pick<TransparentSideVariants, 'register' | 'unregister'>);
23
24
  get roots(): readonly Entity[];
24
25
  getById(id: string): Entity | undefined;
@@ -49,12 +50,17 @@ export declare class EntityCollection {
49
50
  getStats(): {
50
51
  updatedEntities: number;
51
52
  entities: number;
53
+ sourceParts: number;
54
+ renderObjects: number;
55
+ rebuilds: number;
52
56
  instancedBatches: number;
53
57
  batchedBatches: number;
54
58
  independentObjects: number;
55
- rebuilds: number;
56
59
  };
57
- setSelection(entities: readonly Entity[]): void;
60
+ /** Selection identity is retained even when the optional visual overlay is disabled. */
61
+ setSelection(entities: readonly Entity[], options?: {
62
+ highlight?: boolean;
63
+ }): void;
58
64
  getSelection(): readonly Entity[];
59
65
  setInstancingEnabled(enabled: boolean): void;
60
66
  setBatchedEnabled(enabled: boolean): void;
@@ -28,6 +28,8 @@ export declare class EntityRenderer {
28
28
  private enabled;
29
29
  private batchedEnabled;
30
30
  private rebuilds;
31
+ private sourceParts;
32
+ private batchCounts;
31
33
  private selection;
32
34
  private selectionDirty;
33
35
  private highlights;
@@ -48,11 +50,14 @@ export declare class EntityRenderer {
48
50
  pick(raycaster: Raycaster): EntityHit[];
49
51
  getBounds(entity: Entity): Box3;
50
52
  getStats(): {
53
+ sourceParts: number;
54
+ renderObjects: number;
55
+ rebuilds: number;
51
56
  instancedBatches: number;
52
57
  batchedBatches: number;
53
58
  independentObjects: number;
54
- rebuilds: number;
55
59
  };
60
+ private countBatch;
56
61
  private clearBatches;
57
62
  dispose(): void;
58
63
  }
package/types/index.d.ts CHANGED
@@ -2164,6 +2164,7 @@ export declare class EntityCollection {
2164
2164
  private pendingModels;
2165
2165
  private selected;
2166
2166
  private selectionDirty;
2167
+ private selectionHighlight;
2167
2168
  constructor(scene: Scene, requestRender: () => void, models: ModelResources, sideVariants?: Pick<TransparentSideVariants, 'register' | 'unregister'>);
2168
2169
  get roots(): readonly Entity[];
2169
2170
  getById(id: string): Entity | undefined;
@@ -2194,12 +2195,17 @@ export declare class EntityCollection {
2194
2195
  getStats(): {
2195
2196
  updatedEntities: number;
2196
2197
  entities: number;
2198
+ sourceParts: number;
2199
+ renderObjects: number;
2200
+ rebuilds: number;
2197
2201
  instancedBatches: number;
2198
2202
  batchedBatches: number;
2199
2203
  independentObjects: number;
2200
- rebuilds: number;
2201
2204
  };
2202
- setSelection(entities: readonly Entity[]): void;
2205
+ /** Selection identity is retained even when the optional visual overlay is disabled. */
2206
+ setSelection(entities: readonly Entity[], options?: {
2207
+ highlight?: boolean;
2208
+ }): void;
2203
2209
  getSelection(): readonly Entity[];
2204
2210
  setInstancingEnabled(enabled: boolean): void;
2205
2211
  setBatchedEnabled(enabled: boolean): void;