vim-web 0.5.0-dev.2 → 0.5.0-dev.20

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.
Files changed (69) hide show
  1. package/dist/style.css +37 -7
  2. package/dist/types/core-viewers/shared/inputAdapter.d.ts +1 -0
  3. package/dist/types/core-viewers/shared/keyboardHandler.d.ts +1 -1
  4. package/dist/types/core-viewers/shared/mouseHandler.d.ts +2 -0
  5. package/dist/types/core-viewers/ultra/camera.d.ts +2 -2
  6. package/dist/types/core-viewers/ultra/colorManager.d.ts +4 -4
  7. package/dist/types/core-viewers/ultra/element3d.d.ts +4 -4
  8. package/dist/types/core-viewers/ultra/index.d.ts +1 -1
  9. package/dist/types/core-viewers/ultra/remoteColor.d.ts +3 -23
  10. package/dist/types/core-viewers/ultra/renderer.d.ts +14 -11
  11. package/dist/types/core-viewers/ultra/rpcClient.d.ts +22 -19
  12. package/dist/types/core-viewers/ultra/rpcSafeClient.d.ts +200 -85
  13. package/dist/types/core-viewers/ultra/rpcTypes.d.ts +6 -3
  14. package/dist/types/core-viewers/ultra/rpcUtils.d.ts +8 -0
  15. package/dist/types/core-viewers/ultra/sectionBox.d.ts +1 -1
  16. package/dist/types/core-viewers/ultra/viewer.d.ts +6 -0
  17. package/dist/types/core-viewers/ultra/viewport.d.ts +6 -0
  18. package/dist/types/core-viewers/ultra/vim.d.ts +11 -9
  19. package/dist/types/core-viewers/ultra/visibility.d.ts +2 -2
  20. package/dist/types/core-viewers/webgl/loader/mesh.d.ts +3 -1
  21. package/dist/types/core-viewers/webgl/loader/progressive/insertableMesh.d.ts +4 -2
  22. package/dist/types/core-viewers/webgl/loader/progressive/instancedMesh.d.ts +5 -0
  23. package/dist/types/core-viewers/webgl/loader/vim.d.ts +5 -0
  24. package/dist/types/core-viewers/webgl/viewer/gizmos/markers/gizmoMarker.d.ts +1 -0
  25. package/dist/types/core-viewers/webgl/viewer/rendering/renderer.d.ts +7 -0
  26. package/dist/types/core-viewers/webgl/viewer/viewer.d.ts +5 -0
  27. package/dist/types/core-viewers/webgl/viewer/viewport.d.ts +1 -1
  28. package/dist/types/react-viewers/bim/bimPanel.d.ts +3 -3
  29. package/dist/types/react-viewers/errors/errorStyle.d.ts +1 -1
  30. package/dist/types/react-viewers/helpers/reactUtils.d.ts +2 -1
  31. package/dist/types/react-viewers/helpers/utils.d.ts +8 -0
  32. package/dist/types/react-viewers/panels/axesPanel.d.ts +2 -1
  33. package/dist/types/react-viewers/panels/index.d.ts +1 -0
  34. package/dist/types/react-viewers/panels/isolationPanel.d.ts +2 -0
  35. package/dist/types/react-viewers/panels/messageBox.d.ts +2 -0
  36. package/dist/types/react-viewers/panels/sidePanel.d.ts +1 -1
  37. package/dist/types/react-viewers/settings/anySettings.d.ts +7 -0
  38. package/dist/types/react-viewers/settings/index.d.ts +1 -1
  39. package/dist/types/react-viewers/settings/settingsInputBox.d.ts +4 -0
  40. package/dist/types/react-viewers/settings/settingsItem.d.ts +30 -0
  41. package/dist/types/react-viewers/settings/settingsKeys.d.ts +46 -0
  42. package/dist/types/react-viewers/settings/settingsPanel.d.ts +5 -4
  43. package/dist/types/react-viewers/settings/settingsPanelContent.d.ts +6 -0
  44. package/dist/types/react-viewers/settings/settingsState.d.ts +11 -11
  45. package/dist/types/react-viewers/settings/settingsStorage.d.ts +3 -3
  46. package/dist/types/react-viewers/settings/settingsSubtitle.d.ts +2 -0
  47. package/dist/types/react-viewers/settings/settingsToggle.d.ts +11 -0
  48. package/dist/types/react-viewers/state/controlBarState.d.ts +40 -7
  49. package/dist/types/react-viewers/state/sharedIsolation.d.ts +2 -0
  50. package/dist/types/react-viewers/ultra/controlBar.d.ts +3 -1
  51. package/dist/types/react-viewers/ultra/index.d.ts +1 -0
  52. package/dist/types/react-viewers/ultra/settings.d.ts +10 -0
  53. package/dist/types/react-viewers/ultra/settingsPanel.d.ts +5 -0
  54. package/dist/types/react-viewers/ultra/viewer.d.ts +3 -1
  55. package/dist/types/react-viewers/ultra/viewerRef.d.ts +3 -0
  56. package/dist/types/react-viewers/urls.d.ts +0 -1
  57. package/dist/types/react-viewers/webgl/index.d.ts +1 -0
  58. package/dist/types/react-viewers/webgl/loading.d.ts +2 -2
  59. package/dist/types/react-viewers/webgl/settings.d.ts +36 -0
  60. package/dist/types/react-viewers/webgl/settingsPanel.d.ts +12 -0
  61. package/dist/types/react-viewers/webgl/viewer.d.ts +3 -3
  62. package/dist/types/react-viewers/webgl/viewerRef.d.ts +12 -5
  63. package/dist/types/utils/validation.d.ts +6 -6
  64. package/dist/vim-web.iife.js +1751 -1030
  65. package/dist/vim-web.iife.js.map +1 -1
  66. package/dist/vim-web.js +1751 -1030
  67. package/dist/vim-web.js.map +1 -1
  68. package/package.json +2 -2
  69. package/dist/types/react-viewers/settings/settings.d.ts +0 -61
package/dist/vim-web.js CHANGED
@@ -46769,6 +46769,11 @@ let Vim$1 = class Vim {
46769
46769
  * @param {boolean} isLegacy - Indicates whether the Vim object uses a legacy loading pipeline.
46770
46770
  */
46771
46771
  constructor(header, document2, g3d2, scene, settings2, map, builder, source, format) {
46772
+ /**
46773
+ * The type of the viewer, indicating it is a WebGL viewer.
46774
+ * Useful for distinguishing between different viewer types in a multi-viewer application.
46775
+ */
46776
+ __publicField(this, "type", "webgl");
46772
46777
  /**
46773
46778
  * Indicates whether the vim was opened from a vim or vimx file.
46774
46779
  */
@@ -48846,19 +48851,38 @@ class InsertableMesh {
48846
48851
  return new InsertableSubmesh(this, index2);
48847
48852
  }
48848
48853
  /**
48849
- * Overrides mesh material, set to undefine to restore initial material.
48850
- */
48854
+ * Sets the material for this mesh.
48855
+ * Set to undefined to reset to original materials.
48856
+ */
48851
48857
  setMaterial(value) {
48852
- if (this._material === value) return;
48853
48858
  if (this.ignoreSceneMaterial) return;
48854
- this.mesh.material = value ?? this._material;
48859
+ const base = this._material;
48860
+ let mat;
48861
+ if (Array.isArray(value)) {
48862
+ mat = this._mergeMaterials(value, base);
48863
+ } else {
48864
+ mat = value ?? base;
48865
+ }
48866
+ this.mesh.material = mat;
48855
48867
  this.mesh.geometry.clearGroups();
48856
- if (value instanceof Array) {
48857
- value.forEach((m, i) => {
48868
+ if (Array.isArray(mat)) {
48869
+ mat.forEach((_m, i) => {
48858
48870
  this.mesh.geometry.addGroup(0, Infinity, i);
48859
48871
  });
48860
48872
  }
48861
48873
  }
48874
+ _mergeMaterials(value, base) {
48875
+ const baseArr = Array.isArray(base) ? base : [base];
48876
+ const result = [];
48877
+ for (const v of value) {
48878
+ if (v === void 0) {
48879
+ result.push(...baseArr);
48880
+ } else {
48881
+ result.push(v);
48882
+ }
48883
+ }
48884
+ return result;
48885
+ }
48862
48886
  }
48863
48887
  class InstancedSubmesh {
48864
48888
  constructor(mesh, index2) {
@@ -48945,17 +48969,39 @@ class InstancedMesh2 {
48945
48969
  }
48946
48970
  return submeshes;
48947
48971
  }
48972
+ /**
48973
+ * Sets the material for this mesh.
48974
+ * Set to undefined to reset to original materials.
48975
+ */
48948
48976
  setMaterial(value) {
48949
- if (this._material === value) return;
48950
48977
  if (this.ignoreSceneMaterial) return;
48951
- this.mesh.material = value ?? this._material;
48978
+ const base = this._material;
48979
+ let mat;
48980
+ if (Array.isArray(value)) {
48981
+ mat = this._mergeMaterials(value, base);
48982
+ } else {
48983
+ mat = value ?? base;
48984
+ }
48985
+ this.mesh.material = mat;
48952
48986
  this.mesh.geometry.clearGroups();
48953
- if (value instanceof Array) {
48954
- value.forEach((m, i) => {
48987
+ if (Array.isArray(mat)) {
48988
+ mat.forEach((_m, i) => {
48955
48989
  this.mesh.geometry.addGroup(0, Infinity, i);
48956
48990
  });
48957
48991
  }
48958
48992
  }
48993
+ _mergeMaterials(value, base) {
48994
+ const baseArr = Array.isArray(base) ? base : [base];
48995
+ const result = [];
48996
+ for (const v of value) {
48997
+ if (v === void 0) {
48998
+ result.push(...baseArr);
48999
+ } else {
49000
+ result.push(v);
49001
+ }
49002
+ }
49003
+ return result;
49004
+ }
48959
49005
  computeBoundingBoxes() {
48960
49006
  this.mesh.geometry.computeBoundingBox();
48961
49007
  const boxes = new Array(this.mesh.count);
@@ -50095,6 +50141,9 @@ const _Marker = class _Marker {
50095
50141
  get index() {
50096
50142
  return this._submesh.index;
50097
50143
  }
50144
+ get isRoom() {
50145
+ return false;
50146
+ }
50098
50147
  /**
50099
50148
  * Updates the underlying submesh and rebinds all attributes to the new mesh.
50100
50149
  * @param mesh - The new submesh to bind to this marker.
@@ -50825,6 +50874,164 @@ function isFilePathOrUri(input) {
50825
50874
  }
50826
50875
  return true;
50827
50876
  }
50877
+ class Segment {
50878
+ constructor(origin = new Vector3(), target = new Vector3()) {
50879
+ __publicField(this, "origin");
50880
+ __publicField(this, "target");
50881
+ this.origin = origin;
50882
+ this.target = target;
50883
+ }
50884
+ static fromArray(array) {
50885
+ return new Segment(
50886
+ new Vector3(array[0], array[1], array[2]),
50887
+ new Vector3(array[3], array[4], array[5])
50888
+ );
50889
+ }
50890
+ toArray() {
50891
+ return [this.origin.x, this.origin.y, this.origin.z, this.target.x, this.target.y, this.target.z];
50892
+ }
50893
+ isValid() {
50894
+ return !this.origin.equals(this.target);
50895
+ }
50896
+ equals(segment) {
50897
+ return this.origin.equals(segment.origin) && this.target.equals(segment.target);
50898
+ }
50899
+ }
50900
+ class RGBA {
50901
+ constructor(r, g, b, a = 1) {
50902
+ __publicField(this, "r");
50903
+ __publicField(this, "g");
50904
+ __publicField(this, "b");
50905
+ __publicField(this, "a");
50906
+ this.r = r;
50907
+ this.g = g;
50908
+ this.b = b;
50909
+ this.a = a;
50910
+ }
50911
+ static fromThree(color, opacity = 1) {
50912
+ return new RGBA(color.r, color.g, color.b, opacity);
50913
+ }
50914
+ toThree() {
50915
+ return new Color(this.r, this.g, this.b);
50916
+ }
50917
+ clone() {
50918
+ return new RGBA(this.r, this.g, this.b, this.a);
50919
+ }
50920
+ isValid() {
50921
+ return Number.isFinite(this.r) && Number.isFinite(this.g) && Number.isFinite(this.b) && Number.isFinite(this.a);
50922
+ }
50923
+ equals(color) {
50924
+ return this.r === color.r && this.g === color.g && this.b === color.b && this.a === color.a;
50925
+ }
50926
+ static fromString(str) {
50927
+ str = str.trim();
50928
+ if (str.startsWith("(")) {
50929
+ str = str.substring(1);
50930
+ }
50931
+ if (str.endsWith(")")) {
50932
+ str = str.substring(0, str.length - 1);
50933
+ }
50934
+ const parts = str.split(",");
50935
+ if (parts.length < 3 || parts.length > 4) {
50936
+ throw new Error("Invalid color string format. Expected 3 or 4 components.");
50937
+ }
50938
+ const r = parseFloat(parts[0]);
50939
+ const g = parseFloat(parts[1]);
50940
+ const b = parseFloat(parts[2]);
50941
+ const a = parts.length === 4 ? parseFloat(parts[3]) : 1;
50942
+ if ([r, g, b, a].some((n) => isNaN(n))) {
50943
+ throw new Error("Invalid number in color string.");
50944
+ }
50945
+ return new RGBA(r, g, b, a);
50946
+ }
50947
+ }
50948
+ class RGB {
50949
+ constructor(r, g, b) {
50950
+ __publicField(this, "r");
50951
+ __publicField(this, "g");
50952
+ __publicField(this, "b");
50953
+ this.r = r;
50954
+ this.g = g;
50955
+ this.b = b;
50956
+ }
50957
+ }
50958
+ class RGBA32 {
50959
+ constructor(hex) {
50960
+ __publicField(this, "hex");
50961
+ if (!Number.isInteger(hex) || hex < 0 || hex > 4294967295) {
50962
+ throw new Error("Invalid value: must be a 32-bit unsigned integer");
50963
+ }
50964
+ this.hex = hex;
50965
+ }
50966
+ static fromThree(color, opacity = 1) {
50967
+ return this.fromFloats(color.r, color.g, color.b, opacity);
50968
+ }
50969
+ static fromInts(r, g, b, a = 1) {
50970
+ if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 255) {
50971
+ throw new Error("Each RGBA component must be in the range 0-255.");
50972
+ }
50973
+ const hex = r * 2 ** 24 + g * 2 ** 16 + b * 2 ** 8 + a;
50974
+ return new RGBA32(hex);
50975
+ }
50976
+ static fromFloats(r, g, b, a = 1) {
50977
+ return this.fromInts(
50978
+ remap(r, 255),
50979
+ remap(g, 255),
50980
+ remap(b, 255),
50981
+ remap(a, 255)
50982
+ );
50983
+ }
50984
+ static fromString(str) {
50985
+ if (str.startsWith("#")) {
50986
+ str = str.slice(1);
50987
+ }
50988
+ if (str.length === 3 || str.length === 4) {
50989
+ str = str.split("").map((c) => c + c).join("");
50990
+ }
50991
+ let r = 0;
50992
+ let g = 0;
50993
+ let b = 0;
50994
+ let a = 255;
50995
+ if (str.length === 6 || str.length === 8) {
50996
+ r = parseInt(str.slice(0, 2), 16);
50997
+ g = parseInt(str.slice(2, 4), 16);
50998
+ b = parseInt(str.slice(4, 6), 16);
50999
+ if (str.length === 8) {
51000
+ a = parseInt(str.slice(6, 8), 16);
51001
+ }
51002
+ } else {
51003
+ throw new Error("Invalid color string format");
51004
+ }
51005
+ if ([r, g, b, a].some((v) => isNaN(v))) {
51006
+ throw new Error("Invalid color string format");
51007
+ }
51008
+ return this.fromInts(r, g, b, a);
51009
+ }
51010
+ /**
51011
+ * The red component of the color in the range [0-255].
51012
+ */
51013
+ get r() {
51014
+ return this.hex >>> 24;
51015
+ }
51016
+ /**
51017
+ * The green component of the color in the range [0-255].
51018
+ */
51019
+ get g() {
51020
+ return this.hex >>> 16 & 255;
51021
+ }
51022
+ /**
51023
+ * The blue component of the color in the range [0-255].
51024
+ */
51025
+ get b() {
51026
+ return this.hex >>> 8 & 255;
51027
+ }
51028
+ /**
51029
+ * The alpha component of the color in the range [0-255].
51030
+ */
51031
+ get a() {
51032
+ return this.hex & 255;
51033
+ }
51034
+ }
50828
51035
  class Validation {
50829
51036
  //= ===========================================================================
50830
51037
  // BASIC NUMBER VALIDATIONS
@@ -50876,16 +51083,16 @@ class Validation {
50876
51083
  //= ===========================================================================
50877
51084
  // HANDLE VALIDATIONS
50878
51085
  //= ===========================================================================
50879
- static isComponentHandle(handle) {
50880
- if (!this.isPositiveInteger(handle)) return false;
50881
- if (handle === INVALID_HANDLE) {
50882
- console.warn(`Invalid handle ${handle}. Aborting operation.`);
51086
+ static isIndex(index2) {
51087
+ if (!this.isPositiveInteger(index2)) return false;
51088
+ if (index2 === INVALID_HANDLE) {
51089
+ console.warn(`Invalid index ${index2}. Aborting operation.`);
50883
51090
  return false;
50884
51091
  }
50885
51092
  return true;
50886
51093
  }
50887
- static areComponentHandles(handles) {
50888
- return handles.every((h) => this.isComponentHandle(h));
51094
+ static areIndices(indices) {
51095
+ return indices.every((h) => this.isIndex(h));
50889
51096
  }
50890
51097
  static isMaterialHandle(handle) {
50891
51098
  if (!materialHandles.includes(handle)) {
@@ -50934,23 +51141,6 @@ class Validation {
50934
51141
  return true;
50935
51142
  }
50936
51143
  //= ===========================================================================
50937
- // COLOR VALIDATIONS
50938
- //= ===========================================================================
50939
- static isRelativeRGBA(color) {
50940
- if (color.r < 0 || color.r > 1 || color.g < 0 || color.g > 1 || color.b < 0 || color.b > 1) {
50941
- console.warn("Invalid value: must be a relative color (0-1, 0-1, 0-1)");
50942
- return false;
50943
- }
50944
- return true;
50945
- }
50946
- static isRelativeRGB(color) {
50947
- if (color.r < 0 || color.r > 1 || color.g < 0 || color.g > 1 || color.b < 0 || color.b > 1) {
50948
- console.warn("Invalid value: must be a relative color (0-1, 0-1, 0-1)");
50949
- return false;
50950
- }
50951
- return true;
50952
- }
50953
- //= ===========================================================================
50954
51144
  // STRING AND URL VALIDATIONS
50955
51145
  //= ===========================================================================
50956
51146
  static isNonEmptyString(value) {
@@ -51037,6 +51227,13 @@ class Validation {
51037
51227
  }
51038
51228
  return value;
51039
51229
  }
51230
+ static clampColor01(value) {
51231
+ return new Color(
51232
+ this.clamp01(value.r),
51233
+ this.clamp01(value.g),
51234
+ this.clamp01(value.b)
51235
+ );
51236
+ }
51040
51237
  static clampRGBA01(value) {
51041
51238
  return new RGBA(
51042
51239
  this.clamp01(value.r),
@@ -52433,7 +52630,11 @@ class KeyboardHandler extends BaseInputHandler {
52433
52630
  * @param handler Callback invoked on key up.
52434
52631
  */
52435
52632
  registerKeyUp(code, mode, handler) {
52436
- this.registerKey(this.keyUpHandlers, code, mode, handler);
52633
+ if (Array.isArray(code)) {
52634
+ code.forEach((c) => this.registerKey(this.keyUpHandlers, c, mode, handler));
52635
+ } else {
52636
+ this.registerKey(this.keyUpHandlers, code, mode, handler);
52637
+ }
52437
52638
  }
52438
52639
  registerKey(map, code, mode, callback) {
52439
52640
  mode = map.has(code) ? mode : "replace";
@@ -52479,6 +52680,7 @@ class MouseHandler extends BaseInputHandler {
52479
52680
  __publicField(this, "onClick");
52480
52681
  __publicField(this, "onDoubleClick");
52481
52682
  __publicField(this, "onWheel");
52683
+ __publicField(this, "onContextMenu");
52482
52684
  this._capture = new CaptureHandler(canvas);
52483
52685
  this._dragHandler = new DragHandler((delta, button) => this.onDrag(delta, button));
52484
52686
  }
@@ -52520,6 +52722,7 @@ class MouseHandler extends BaseInputHandler {
52520
52722
  this.handleDoubleClick(event);
52521
52723
  } else {
52522
52724
  this.handleMouseClick(event);
52725
+ this.handleContextMenu(event);
52523
52726
  }
52524
52727
  event.preventDefault();
52525
52728
  }
@@ -52534,6 +52737,16 @@ class MouseHandler extends BaseInputHandler {
52534
52737
  const modif = event.getModifierState("Shift") || event.getModifierState("Control");
52535
52738
  (_a3 = this.onClick) == null ? void 0 : _a3.call(this, pos, modif);
52536
52739
  }
52740
+ async handleContextMenu(event) {
52741
+ var _a3;
52742
+ if (event.pointerType !== "mouse") return;
52743
+ if (event.button !== 2) return;
52744
+ const pos = this.relativePosition(event);
52745
+ if (!almostEqual(this._lastMouseDownPosition, pos, 0.01)) {
52746
+ return;
52747
+ }
52748
+ (_a3 = this.onContextMenu) == null ? void 0 : _a3.call(this, new Vector2(event.clientX, event.clientY));
52749
+ }
52537
52750
  handlePointerMove(event) {
52538
52751
  var _a3;
52539
52752
  if (event.pointerType !== "mouse") return;
@@ -52587,13 +52800,20 @@ class DoubleClickHandler {
52587
52800
  constructor() {
52588
52801
  __publicField(this, "_lastClickTime", 0);
52589
52802
  __publicField(this, "_clickDelay", 300);
52803
+ // Max time between clicks for double-click
52804
+ __publicField(this, "_lastClickPosition", null);
52805
+ __publicField(this, "_positionThreshold", 5);
52590
52806
  }
52591
- // Delay in milliseconds to consider a double click
52807
+ // Max pixel distance between clicks
52592
52808
  checkForDoubleClick(event) {
52593
52809
  const currentTime = Date.now();
52810
+ const currentPosition = new Vector2(event.clientX, event.clientY);
52594
52811
  const timeDiff = currentTime - this._lastClickTime;
52812
+ const isClose = this._lastClickPosition !== null && this._lastClickPosition.distanceTo(currentPosition) < this._positionThreshold;
52813
+ const isWithinTime = timeDiff < this._clickDelay;
52595
52814
  this._lastClickTime = currentTime;
52596
- return timeDiff < this._clickDelay;
52815
+ this._lastClickPosition = currentPosition;
52816
+ return isClose && isWithinTime;
52597
52817
  }
52598
52818
  }
52599
52819
  class DragHandler {
@@ -52833,23 +53053,15 @@ class InputHandler extends BaseInputHandler {
52833
53053
  this._moveSpeed = settings2.moveSpeed ?? 1;
52834
53054
  this.rotateSpeed = settings2.rotateSpeed ?? 1;
52835
53055
  this.orbitSpeed = settings2.orbitSpeed ?? 1;
52836
- this.reg(document, "contextmenu", (e) => {
52837
- this._onContextMenu.dispatch(new Vector2(e.clientX, e.clientY));
52838
- e.preventDefault();
52839
- });
52840
53056
  this.keyboard = new KeyboardHandler(canvas);
52841
53057
  this.mouse = new MouseHandler(canvas);
52842
53058
  this.touch = new TouchHandler(canvas);
52843
53059
  this.keyboard.onKeyDown = (key) => adapter.keyDown(key);
52844
53060
  this.keyboard.onKeyUp = (key) => adapter.keyUp(key);
52845
53061
  this.keyboard.registerKeyUp("KeyP", "replace", () => adapter.toggleOrthographic());
52846
- this.keyboard.registerKeyUp("Equal", "replace", () => this.moveSpeed++);
52847
- this.keyboard.registerKeyUp("Minus", "replace", () => this.moveSpeed--);
52848
- this.keyboard.registerKeyUp("Space", "replace", () => {
52849
- this._pointerActive = this._pointerActive === "orbit" ? "look" : "orbit";
52850
- this._pointerFallback = this._pointerActive;
52851
- this._onPointerModeChanged.dispatch();
52852
- });
53062
+ this.keyboard.registerKeyUp(["Equal", "NumpadAdd"], "replace", () => this.moveSpeed++);
53063
+ this.keyboard.registerKeyUp(["Minus", "NumpadSubtract"], "replace", () => this.moveSpeed--);
53064
+ this.keyboard.registerKeyUp("Space", "replace", () => adapter.toggleCameraOrbitMode());
52853
53065
  this.keyboard.registerKeyUp("Home", "replace", () => adapter.resetCamera());
52854
53066
  this.keyboard.registerKeyUp("Escape", "replace", () => adapter.clearSelection());
52855
53067
  this.keyboard.registerKeyUp("KeyF", "replace", () => {
@@ -52859,18 +53071,28 @@ class InputHandler extends BaseInputHandler {
52859
53071
  const mul = Math.pow(1.25, this._moveSpeed);
52860
53072
  adapter.moveCamera(value.multiplyScalar(mul));
52861
53073
  };
53074
+ this.mouse.onContextMenu = (pos) => this._onContextMenu.dispatch(pos);
52862
53075
  this.mouse.onButtonDown = adapter.mouseDown;
52863
53076
  this.mouse.onMouseMove = adapter.mouseMove;
52864
- this.mouse.onButtonUp = adapter.mouseUp;
53077
+ this.mouse.onButtonUp = (pos, button) => {
53078
+ this.pointerOverride = void 0;
53079
+ adapter.mouseUp(pos, button);
53080
+ };
52865
53081
  this.mouse.onDrag = (delta, button) => {
52866
53082
  if (button === 0) {
52867
- if (this._pointerActive === "orbit") adapter.orbitCamera(toRotation(delta, this.orbitSpeed));
52868
- if (this._pointerActive === "look") adapter.rotateCamera(toRotation(delta, this.rotateSpeed));
52869
- if (this._pointerActive === "pan") adapter.panCamera(delta);
52870
- if (this._pointerActive === "zoom") adapter.dollyCamera(delta);
53083
+ if (this.pointerActive === "orbit") adapter.orbitCamera(toRotation(delta, this.orbitSpeed));
53084
+ if (this.pointerActive === "look") adapter.rotateCamera(toRotation(delta, this.rotateSpeed));
53085
+ if (this.pointerActive === "pan") adapter.panCamera(delta);
53086
+ if (this.pointerActive === "zoom") adapter.dollyCamera(delta);
53087
+ }
53088
+ if (button === 2) {
53089
+ this.pointerOverride = "look";
53090
+ adapter.rotateCamera(toRotation(delta, 1));
53091
+ }
53092
+ if (button === 1) {
53093
+ this.pointerOverride = "pan";
53094
+ adapter.panCamera(delta);
52871
53095
  }
52872
- if (button === 2) adapter.rotateCamera(toRotation(delta, 1));
52873
- if (button === 1) adapter.panCamera(delta);
52874
53096
  };
52875
53097
  this.mouse.onClick = (pos, modif) => adapter.selectAtPointer(pos, modif);
52876
53098
  this.mouse.onDoubleClick = adapter.frameAtPointer;
@@ -55693,7 +55915,7 @@ let Viewport$1 = class Viewport {
55693
55915
  /**
55694
55916
  * Resizes the canvas and updates the camera to match new parent dimensions.
55695
55917
  */
55696
- ResizeToParent() {
55918
+ resizeToParent() {
55697
55919
  this._onResize.dispatch();
55698
55920
  }
55699
55921
  /**
@@ -55747,6 +55969,9 @@ function createAdapter$2(viewer) {
55747
55969
  toggleOrthographic: () => {
55748
55970
  viewer.camera.orthographic = !viewer.camera.orthographic;
55749
55971
  },
55972
+ toggleCameraOrbitMode: () => {
55973
+ viewer.inputs.pointerActive = viewer.inputs.pointerActive === PointerMode$1.ORBIT ? PointerMode$1.LOOK : PointerMode$1.ORBIT;
55974
+ },
55750
55975
  resetCamera: () => {
55751
55976
  viewer.camera.lerp(0.75).reset();
55752
55977
  },
@@ -55771,7 +55996,7 @@ function createAdapter$2(viewer) {
55771
55996
  },
55772
55997
  frameAtPointer: async (pos) => {
55773
55998
  const result = await viewer.raycaster.raycastFromScreen(pos);
55774
- viewer.camera.lerp(0.75).frame(result.object);
55999
+ viewer.camera.lerp(0.75).frame(result.object ?? "all");
55775
56000
  },
55776
56001
  zoom: (value) => {
55777
56002
  viewer.camera.lerp(0.75).zoom(value);
@@ -56782,6 +57007,10 @@ let Renderer$1 = class Renderer {
56782
57007
  * Indicates whether the scene should be re-rendered on change only.
56783
57008
  */
56784
57009
  __publicField(this, "onDemand");
57010
+ /**
57011
+ * The material that will be used when setting model material to undefined.
57012
+ */
57013
+ __publicField(this, "defaultModelMaterial");
56785
57014
  __publicField(this, "fitViewport", () => {
56786
57015
  const size = this._viewport.getParentSize();
56787
57016
  this.renderer.setPixelRatio(window.devicePixelRatio);
@@ -56853,11 +57082,14 @@ let Renderer$1 = class Renderer {
56853
57082
  this._scene.threeScene.background = color;
56854
57083
  this.needsUpdate = true;
56855
57084
  }
57085
+ /**
57086
+ * Sets the material used to render models. If set to undefined, the default model or mesh material is used.
57087
+ */
56856
57088
  get modelMaterial() {
56857
57089
  return this._scene.modelMaterial;
56858
57090
  }
56859
57091
  set modelMaterial(material) {
56860
- this._scene.modelMaterial = material;
57092
+ this._scene.modelMaterial = material ?? this.defaultModelMaterial;
56861
57093
  }
56862
57094
  /**
56863
57095
  * Signal dispatched at the end of each frame if the scene was updated, such as visibility changes.
@@ -56993,6 +57225,11 @@ let Renderer$1 = class Renderer {
56993
57225
  };
56994
57226
  let Viewer$3 = class Viewer {
56995
57227
  constructor(settings2) {
57228
+ /**
57229
+ * The type of the viewer, indicating it is a WebGL viewer.
57230
+ * Useful for distinguishing between different viewer types in a multi-viewer application.
57231
+ */
57232
+ __publicField(this, "type", "webgl");
56996
57233
  /**
56997
57234
  * The settings configuration used by the viewer.
56998
57235
  */
@@ -57317,180 +57554,31 @@ const index$8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
57317
57554
  getDefaultVimSettings,
57318
57555
  request: requestVim
57319
57556
  }, Symbol.toStringTag, { value: "Module" }));
57320
- class Segment {
57321
- constructor(origin = new Vector3(), target = new Vector3()) {
57322
- __publicField(this, "origin");
57323
- __publicField(this, "target");
57324
- this.origin = origin;
57325
- this.target = target;
57326
- }
57327
- static fromArray(array) {
57328
- return new Segment(
57329
- new Vector3(array[0], array[1], array[2]),
57330
- new Vector3(array[3], array[4], array[5])
57331
- );
57557
+ class Camera3 {
57558
+ /**
57559
+ * Creates a new Camera instance
57560
+ * @param rpc - RPC client for camera communication
57561
+ */
57562
+ constructor(rpc) {
57563
+ __publicField(this, "_rpc");
57564
+ __publicField(this, "_lastPosition");
57565
+ __publicField(this, "_defaultBlendTime", 0.5);
57566
+ __publicField(this, "_savedPosition");
57567
+ this._rpc = rpc;
57332
57568
  }
57333
- toArray() {
57334
- return [this.origin.x, this.origin.y, this.origin.z, this.target.x, this.target.y, this.target.z];
57569
+ /**
57570
+ * Saves the current camera position for later restoration
57571
+ * @param segment - Optional segment to save as the camera position
57572
+ */
57573
+ async save(segment) {
57574
+ this._savedPosition = segment ?? await this._rpc.RPCGetCameraView();
57335
57575
  }
57336
- isValid() {
57337
- return !this.origin.equals(this.target);
57338
- }
57339
- equals(segment) {
57340
- return this.origin.equals(segment.origin) && this.target.equals(segment.target);
57341
- }
57342
- }
57343
- class RGBA {
57344
- constructor(r, g, b, a = 1) {
57345
- __publicField(this, "r");
57346
- __publicField(this, "g");
57347
- __publicField(this, "b");
57348
- __publicField(this, "a");
57349
- this.r = r;
57350
- this.g = g;
57351
- this.b = b;
57352
- this.a = a;
57353
- }
57354
- clone() {
57355
- return new RGBA(this.r, this.g, this.b, this.a);
57356
- }
57357
- isValid() {
57358
- return Number.isFinite(this.r) && Number.isFinite(this.g) && Number.isFinite(this.b) && Number.isFinite(this.a);
57359
- }
57360
- equals(color) {
57361
- return this.r === color.r && this.g === color.g && this.b === color.b && this.a === color.a;
57362
- }
57363
- static fromString(str) {
57364
- str = str.trim();
57365
- if (str.startsWith("(")) {
57366
- str = str.substring(1);
57367
- }
57368
- if (str.endsWith(")")) {
57369
- str = str.substring(0, str.length - 1);
57370
- }
57371
- const parts = str.split(",");
57372
- if (parts.length < 3 || parts.length > 4) {
57373
- throw new Error("Invalid color string format. Expected 3 or 4 components.");
57374
- }
57375
- const r = parseFloat(parts[0]);
57376
- const g = parseFloat(parts[1]);
57377
- const b = parseFloat(parts[2]);
57378
- const a = parts.length === 4 ? parseFloat(parts[3]) : 1;
57379
- if ([r, g, b, a].some((n) => isNaN(n))) {
57380
- throw new Error("Invalid number in color string.");
57381
- }
57382
- return new RGBA(r, g, b, a);
57383
- }
57384
- }
57385
- class RGB {
57386
- constructor(r, g, b) {
57387
- __publicField(this, "r");
57388
- __publicField(this, "g");
57389
- __publicField(this, "b");
57390
- this.r = r;
57391
- this.g = g;
57392
- this.b = b;
57393
- }
57394
- }
57395
- class RGBA32 {
57396
- constructor(hex) {
57397
- __publicField(this, "hex");
57398
- if (!Number.isInteger(hex) || hex < 0 || hex > 4294967295) {
57399
- throw new Error("Invalid value: must be a 32-bit unsigned integer");
57400
- }
57401
- this.hex = hex;
57402
- }
57403
- static fromInts(r, g, b, a = 1) {
57404
- if (r < 0 || r > 255 || g < 0 || g > 255 || b < 0 || b > 255 || a < 0 || a > 255) {
57405
- throw new Error("Each RGBA component must be in the range 0-255.");
57406
- }
57407
- const hex = r * 2 ** 24 + g * 2 ** 16 + b * 2 ** 8 + a;
57408
- return new RGBA32(hex);
57409
- }
57410
- static fromFloats(r, g, b, a = 1) {
57411
- return this.fromInts(
57412
- remap(r, 255),
57413
- remap(g, 255),
57414
- remap(b, 255),
57415
- remap(a, 255)
57416
- );
57417
- }
57418
- static fromString(str) {
57419
- if (str.startsWith("#")) {
57420
- str = str.slice(1);
57421
- }
57422
- if (str.length === 3 || str.length === 4) {
57423
- str = str.split("").map((c) => c + c).join("");
57424
- }
57425
- let r = 0;
57426
- let g = 0;
57427
- let b = 0;
57428
- let a = 255;
57429
- if (str.length === 6 || str.length === 8) {
57430
- r = parseInt(str.slice(0, 2), 16);
57431
- g = parseInt(str.slice(2, 4), 16);
57432
- b = parseInt(str.slice(4, 6), 16);
57433
- if (str.length === 8) {
57434
- a = parseInt(str.slice(6, 8), 16);
57435
- }
57436
- } else {
57437
- throw new Error("Invalid color string format");
57438
- }
57439
- if ([r, g, b, a].some((v) => isNaN(v))) {
57440
- throw new Error("Invalid color string format");
57441
- }
57442
- return this.fromInts(r, g, b, a);
57443
- }
57444
- /**
57445
- * The red component of the color in the range [0-255].
57446
- */
57447
- get r() {
57448
- return this.hex >>> 24;
57449
- }
57450
- /**
57451
- * The green component of the color in the range [0-255].
57452
- */
57453
- get g() {
57454
- return this.hex >>> 16 & 255;
57455
- }
57456
- /**
57457
- * The blue component of the color in the range [0-255].
57458
- */
57459
- get b() {
57460
- return this.hex >>> 8 & 255;
57461
- }
57462
- /**
57463
- * The alpha component of the color in the range [0-255].
57464
- */
57465
- get a() {
57466
- return this.hex & 255;
57467
- }
57468
- }
57469
- class Camera3 {
57470
- /**
57471
- * Creates a new Camera instance
57472
- * @param rpc - RPC client for camera communication
57473
- */
57474
- constructor(rpc) {
57475
- __publicField(this, "_rpc");
57476
- __publicField(this, "_lastPosition");
57477
- __publicField(this, "_defaultBlendTime", 0.5);
57478
- __publicField(this, "_savedPosition");
57479
- this._rpc = rpc;
57480
- }
57481
- /**
57482
- * Saves the current camera position for later restoration
57483
- * @param segment - Optional segment to save as the camera position
57484
- */
57485
- async save(segment) {
57486
- this._savedPosition = segment ?? await this._rpc.RPCGetCameraView();
57487
- }
57488
- /**
57489
- * Resets the camera to the last saved position
57490
- */
57491
- restoreSavedPosition(blendTime = this._defaultBlendTime) {
57492
- if (!this._savedPosition) return;
57493
- this._rpc.RPCSetCameraView(this._savedPosition, blendTime);
57576
+ /**
57577
+ * Resets the camera to the last saved position
57578
+ */
57579
+ restoreSavedPosition(blendTime = this._defaultBlendTime) {
57580
+ if (!this._savedPosition) return;
57581
+ this._rpc.RPCSetCameraView(this._savedPosition, blendTime);
57494
57582
  }
57495
57583
  /**
57496
57584
  * Restores the camera to its last tracked position
@@ -57529,7 +57617,7 @@ class Camera3 {
57529
57617
  * @returns Promise that resolves when the framing animation is complete
57530
57618
  */
57531
57619
  async frameAll(blendTime = this._defaultBlendTime) {
57532
- const segment = await this._rpc.RPCFrameAll(blendTime);
57620
+ const segment = await this._rpc.RPCFrameScene(blendTime);
57533
57621
  this._savedPosition = this._savedPosition ?? segment;
57534
57622
  return segment;
57535
57623
  }
@@ -57546,16 +57634,16 @@ class Camera3 {
57546
57634
  /**
57547
57635
  * Frames specific nodes of a Vim model in the camera view
57548
57636
  * @param vim - The Vim model containing the nodes to frame
57549
- * @param nodes - Array of node indices to frame, or 'all' to frame the entire model
57637
+ * @param elements - Array of element indices to frame, or 'all' to frame the entire model
57550
57638
  * @param blendTime - Duration of the camera animation in seconds (defaults to 0.5)
57551
57639
  * @returns Promise that resolves when the framing animation is complete
57552
57640
  */
57553
- async frameVim(vim, nodes, blendTime = this._defaultBlendTime) {
57641
+ async frameVim(vim, elements, blendTime = this._defaultBlendTime) {
57554
57642
  let segment;
57555
- if (nodes === "all") {
57643
+ if (elements === "all") {
57556
57644
  segment = await this._rpc.RPCFrameVim(vim.handle, blendTime);
57557
57645
  } else {
57558
- segment = await this._rpc.RPCFrameElements(vim.handle, nodes, blendTime);
57646
+ segment = await this._rpc.RPCFrameElements(vim.handle, elements, blendTime);
57559
57647
  }
57560
57648
  this._savedPosition = this._savedPosition ?? segment;
57561
57649
  return segment;
@@ -57638,9 +57726,9 @@ class Marshal {
57638
57726
  // -------------------- HitCheckResult -------------------
57639
57727
  writeHitCheckResult(data2) {
57640
57728
  this.ensureCapacity(4 + 4 + 4 + 4 * 3 + 4 * 3);
57641
- this.writeUInt(data2.vimHandle);
57642
- this.writeUInt(data2.nodeIndex);
57643
- this.writeUInt(data2.elementIndex);
57729
+ this.writeUInt(data2.vimIndex);
57730
+ this.writeUInt(data2.vimElementIndex);
57731
+ this.writeUInt(data2.sceneElementIndex);
57644
57732
  this.writeVector3(data2.worldPosition);
57645
57733
  this.writeVector3(data2.worldNormal);
57646
57734
  }
@@ -57788,15 +57876,15 @@ class ReadMarshal {
57788
57876
  return textDecoder.decode(stringData);
57789
57877
  }
57790
57878
  readHitCheckResult() {
57791
- const vimHandle = this.readUInt();
57792
- const nodeIndex = this.readUInt();
57793
- const mElementIndex = this.readUInt();
57879
+ const vimIndex = this.readUInt();
57880
+ const vimElementIndex = this.readUInt();
57881
+ const sceneElementIndex = this.readUInt();
57794
57882
  const worldPosition = this.readVector3();
57795
57883
  const worldNormal = this.readVector3();
57796
57884
  return {
57797
- vimHandle,
57798
- nodeIndex,
57799
- elementIndex: mElementIndex,
57885
+ vimIndex,
57886
+ vimElementIndex,
57887
+ sceneElementIndex,
57800
57888
  worldPosition,
57801
57889
  worldNormal
57802
57890
  };
@@ -57928,10 +58016,22 @@ class RpcClient {
57928
58016
  get url() {
57929
58017
  return this._socket.url;
57930
58018
  }
57931
- RPCClearMaterialOverrides(componentHandle) {
58019
+ RPCClearMaterialOverridesForElements(vimIndex, elementIndices) {
57932
58020
  const marshal = new Marshal();
57933
- marshal.writeString("RPCClearMaterialOverrides");
57934
- marshal.writeUInt(componentHandle);
58021
+ marshal.writeString("RPCClearMaterialOverridesForElements");
58022
+ marshal.writeUInt(vimIndex);
58023
+ marshal.writeArrayOfUInt(elementIndices);
58024
+ this._socket.sendRPC(marshal);
58025
+ }
58026
+ RPCClearMaterialOverridesForScene() {
58027
+ const marshal = new Marshal();
58028
+ marshal.writeString("RPCClearMaterialOverridesForScene");
58029
+ this._socket.sendRPC(marshal);
58030
+ }
58031
+ RPCClearMaterialOverridesForVim(vimIndex) {
58032
+ const marshal = new Marshal();
58033
+ marshal.writeString("RPCClearMaterialOverridesForVim");
58034
+ marshal.writeUInt(vimIndex);
57935
58035
  this._socket.sendRPC(marshal);
57936
58036
  }
57937
58037
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
@@ -57954,10 +58054,10 @@ class RpcClient {
57954
58054
  const ret = returnMarshal.readUInt();
57955
58055
  return ret;
57956
58056
  }
57957
- RPCDestroyMaterialInstances(materialInstanceHandle) {
58057
+ RPCDestroyMaterialInstances(materialInstanceHandles) {
57958
58058
  const marshal = new Marshal();
57959
58059
  marshal.writeString("RPCDestroyMaterialInstances");
57960
- marshal.writeArrayOfUInt(materialInstanceHandle);
58060
+ marshal.writeArrayOfUInt(materialInstanceHandles);
57961
58061
  this._socket.sendRPC(marshal);
57962
58062
  }
57963
58063
  RPCDestroyText(componentHandle) {
@@ -57981,53 +58081,53 @@ class RpcClient {
57981
58081
  const ret = returnMarshal.readSegment();
57982
58082
  return ret;
57983
58083
  }
57984
- async RPCFrameAll(blendTime) {
58084
+ async RPCFrameElements(vimIndex, elementIndices, blendTime) {
57985
58085
  const marshal = new Marshal();
57986
- marshal.writeString("RPCFrameAll");
58086
+ marshal.writeString("RPCFrameElements");
58087
+ marshal.writeUInt(vimIndex);
58088
+ marshal.writeArrayOfUInt(elementIndices);
57987
58089
  marshal.writeFloat(blendTime);
57988
58090
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
57989
58091
  const ret = returnMarshal.readSegment();
57990
58092
  return ret;
57991
58093
  }
57992
- async RPCFrameElements(componentHandle, elementIndices, blendTime) {
58094
+ async RPCFrameScene(blendTime) {
57993
58095
  const marshal = new Marshal();
57994
- marshal.writeString("RPCFrameElements");
57995
- marshal.writeUInt(componentHandle);
57996
- marshal.writeArrayOfUInt(elementIndices);
58096
+ marshal.writeString("RPCFrameScene");
57997
58097
  marshal.writeFloat(blendTime);
57998
58098
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
57999
58099
  const ret = returnMarshal.readSegment();
58000
58100
  return ret;
58001
58101
  }
58002
- async RPCFrameVim(componentHandle, blendTime) {
58102
+ async RPCFrameVim(vimIndex, blendTime) {
58003
58103
  const marshal = new Marshal();
58004
58104
  marshal.writeString("RPCFrameVim");
58005
- marshal.writeUInt(componentHandle);
58105
+ marshal.writeUInt(vimIndex);
58006
58106
  marshal.writeFloat(blendTime);
58007
58107
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58008
58108
  const ret = returnMarshal.readSegment();
58009
58109
  return ret;
58010
58110
  }
58011
- async RPCGetAABBForAll() {
58111
+ async RPCGetAABBForElements(vimIndex, elementIndices) {
58012
58112
  const marshal = new Marshal();
58013
- marshal.writeString("RPCGetAABBForAll");
58113
+ marshal.writeString("RPCGetAABBForElements");
58114
+ marshal.writeUInt(vimIndex);
58115
+ marshal.writeArrayOfUInt(elementIndices);
58014
58116
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58015
58117
  const ret = returnMarshal.readBox3();
58016
58118
  return ret;
58017
58119
  }
58018
- async RPCGetAABBForElements(componentHandle, elementIndices) {
58120
+ async RPCGetAABBForScene() {
58019
58121
  const marshal = new Marshal();
58020
- marshal.writeString("RPCGetAABBForElements");
58021
- marshal.writeUInt(componentHandle);
58022
- marshal.writeArrayOfUInt(elementIndices);
58122
+ marshal.writeString("RPCGetAABBForScene");
58023
58123
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58024
58124
  const ret = returnMarshal.readBox3();
58025
58125
  return ret;
58026
58126
  }
58027
- async RPCGetAABBForVim(componentHandle) {
58127
+ async RPCGetAABBForVim(vimIndex) {
58028
58128
  const marshal = new Marshal();
58029
58129
  marshal.writeString("RPCGetAABBForVim");
58030
- marshal.writeUInt(componentHandle);
58130
+ marshal.writeUInt(vimIndex);
58031
58131
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58032
58132
  const ret = returnMarshal.readBox3();
58033
58133
  return ret;
@@ -58039,25 +58139,32 @@ class RpcClient {
58039
58139
  const ret = returnMarshal.readString();
58040
58140
  return ret;
58041
58141
  }
58042
- async RPCGetCameraView() {
58142
+ async RPCGetCameraPose() {
58043
58143
  const marshal = new Marshal();
58044
- marshal.writeString("RPCGetCameraView");
58144
+ marshal.writeString("RPCGetCameraPose");
58045
58145
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58046
58146
  const ret = returnMarshal.readSegment();
58047
58147
  return ret;
58048
58148
  }
58049
- async RPCGetElementCount(componentHandle) {
58149
+ async RPCGetElementCountForScene() {
58050
58150
  const marshal = new Marshal();
58051
- marshal.writeString("RPCGetElementCount");
58052
- marshal.writeUInt(componentHandle);
58151
+ marshal.writeString("RPCGetElementCountForScene");
58152
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58153
+ const ret = returnMarshal.readUInt();
58154
+ return ret;
58155
+ }
58156
+ async RPCGetElementCountForVim(vimIndex) {
58157
+ const marshal = new Marshal();
58158
+ marshal.writeString("RPCGetElementCountForVim");
58159
+ marshal.writeUInt(vimIndex);
58053
58160
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58054
58161
  const ret = returnMarshal.readUInt();
58055
58162
  return ret;
58056
58163
  }
58057
- async RPCGetElementIds(componentHandle) {
58164
+ async RPCGetElementIds(vimIndex) {
58058
58165
  const marshal = new Marshal();
58059
58166
  marshal.writeString("RPCGetElementIds");
58060
- marshal.writeUInt(componentHandle);
58167
+ marshal.writeUInt(vimIndex);
58061
58168
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58062
58169
  const ret = returnMarshal.readArrayOfUInt64();
58063
58170
  return ret;
@@ -58069,10 +58176,10 @@ class RpcClient {
58069
58176
  const ret = returnMarshal.readString();
58070
58177
  return ret;
58071
58178
  }
58072
- async RPCGetRoomElements(componentHandle) {
58179
+ async RPCGetRoomElements(vimIndex) {
58073
58180
  const marshal = new Marshal();
58074
58181
  marshal.writeString("RPCGetRoomElements");
58075
- marshal.writeUInt(componentHandle);
58182
+ marshal.writeUInt(vimIndex);
58076
58183
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58077
58184
  const ret = returnMarshal.readArrayOfUInt();
58078
58185
  return ret;
@@ -58084,10 +58191,10 @@ class RpcClient {
58084
58191
  const ret = returnMarshal.readSectionBoxState();
58085
58192
  return ret;
58086
58193
  }
58087
- async RPCGetVimLoadingState(componentHandle) {
58194
+ async RPCGetVimLoadingState(vimIndex) {
58088
58195
  const marshal = new Marshal();
58089
58196
  marshal.writeString("RPCGetVimLoadingState");
58090
- marshal.writeUInt(componentHandle);
58197
+ marshal.writeUInt(vimIndex);
58091
58198
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58092
58199
  const ret = returnMarshal.readVimStatus();
58093
58200
  return ret;
@@ -58177,6 +58284,13 @@ class RpcClient {
58177
58284
  marshal.writeBoolean(orbit2);
58178
58285
  this._socket.sendRPC(marshal);
58179
58286
  }
58287
+ RPCSetCameraPose(state, blendTime) {
58288
+ const marshal = new Marshal();
58289
+ marshal.writeString("RPCSetCameraPose");
58290
+ marshal.writeSegment(state);
58291
+ marshal.writeFloat(blendTime);
58292
+ this._socket.sendRPC(marshal);
58293
+ }
58180
58294
  RPCSetCameraPosition(position, blendTime) {
58181
58295
  const marshal = new Marshal();
58182
58296
  marshal.writeString("RPCSetCameraPosition");
@@ -58197,13 +58311,6 @@ class RpcClient {
58197
58311
  marshal.writeFloat(blendTime);
58198
58312
  this._socket.sendRPC(marshal);
58199
58313
  }
58200
- RPCSetCameraView(state, blendTime) {
58201
- const marshal = new Marshal();
58202
- marshal.writeString("RPCSetCameraView");
58203
- marshal.writeSegment(state);
58204
- marshal.writeFloat(blendTime);
58205
- this._socket.sendRPC(marshal);
58206
- }
58207
58314
  RPCSetGhostColor(ghostColor) {
58208
58315
  const marshal = new Marshal();
58209
58316
  marshal.writeString("RPCSetGhostColor");
@@ -58221,10 +58328,10 @@ class RpcClient {
58221
58328
  marshal.writeRGBA(backgroundColor);
58222
58329
  this._socket.sendRPC(marshal);
58223
58330
  }
58224
- RPCSetMaterialOverrides(componentHandle, elementIndices, materialInstanceHandles) {
58331
+ RPCSetMaterialOverridesForElements(vimIndex, elementIndices, materialInstanceHandles) {
58225
58332
  const marshal = new Marshal();
58226
- marshal.writeString("RPCSetMaterialOverrides");
58227
- marshal.writeUInt(componentHandle);
58333
+ marshal.writeString("RPCSetMaterialOverridesForElements");
58334
+ marshal.writeUInt(vimIndex);
58228
58335
  marshal.writeArrayOfUInt(elementIndices);
58229
58336
  marshal.writeArrayOfUInt(materialInstanceHandles);
58230
58337
  this._socket.sendRPC(marshal);
@@ -58235,25 +58342,31 @@ class RpcClient {
58235
58342
  marshal.writeSectionBoxState(state);
58236
58343
  this._socket.sendRPC(marshal);
58237
58344
  }
58238
- RPCSetStateVim(componentHandle, state) {
58345
+ RPCSetStateElements(vimIndex, elementIndices, state) {
58239
58346
  const marshal = new Marshal();
58240
- marshal.writeString("RPCSetStateVim");
58241
- marshal.writeUInt(componentHandle);
58347
+ marshal.writeString("RPCSetStateElements");
58348
+ marshal.writeUInt(vimIndex);
58349
+ marshal.writeArrayOfUInt(elementIndices);
58242
58350
  marshal.writeUInt(state);
58243
58351
  this._socket.sendRPC(marshal);
58244
58352
  }
58245
- RPCSetStateElements(componentHandle, elementIndices, state) {
58353
+ RPCSetStateScene(state) {
58246
58354
  const marshal = new Marshal();
58247
- marshal.writeString("RPCSetStateElements");
58248
- marshal.writeUInt(componentHandle);
58249
- marshal.writeArrayOfUInt(elementIndices);
58355
+ marshal.writeString("RPCSetStateScene");
58356
+ marshal.writeUInt(state);
58357
+ this._socket.sendRPC(marshal);
58358
+ }
58359
+ RPCSetStateVim(vimIndex, state) {
58360
+ const marshal = new Marshal();
58361
+ marshal.writeString("RPCSetStateVim");
58362
+ marshal.writeUInt(vimIndex);
58250
58363
  marshal.writeUInt(state);
58251
58364
  this._socket.sendRPC(marshal);
58252
58365
  }
58253
- RPCSetStatesElements(componentHandle, elementIndices, states) {
58366
+ RPCSetStatesElements(vimIndex, elementIndices, states) {
58254
58367
  const marshal = new Marshal();
58255
58368
  marshal.writeString("RPCSetStatesElements");
58256
- marshal.writeUInt(componentHandle);
58369
+ marshal.writeUInt(vimIndex);
58257
58370
  marshal.writeArrayOfUInt(elementIndices);
58258
58371
  marshal.writeArrayOfUInt(states);
58259
58372
  this._socket.sendRPC(marshal);
@@ -58281,12 +58394,6 @@ class RpcClient {
58281
58394
  marshal.writeString("RPCUnloadAll");
58282
58395
  this._socket.sendRPC(marshal);
58283
58396
  }
58284
- RPCUnloadVim(componentHandle) {
58285
- const marshal = new Marshal();
58286
- marshal.writeString("RPCUnloadVim");
58287
- marshal.writeUInt(componentHandle);
58288
- this._socket.sendRPC(marshal);
58289
- }
58290
58397
  }
58291
58398
  class RemoteColor {
58292
58399
  /**
@@ -58318,35 +58425,7 @@ class RemoteColor {
58318
58425
  * @returns {number} The color value as a hexadecimal number.
58319
58426
  */
58320
58427
  get hex() {
58321
- return this.color.hex;
58322
- }
58323
- /**
58324
- * Gets the red component of the color.
58325
- * @returns {number} The red component value in the range [0-255].
58326
- */
58327
- get r() {
58328
- return this.color.r;
58329
- }
58330
- /**
58331
- * Gets the green component of the color.
58332
- * @returns {number} The green component value in the range [0-255].
58333
- */
58334
- get g() {
58335
- return this.color.g;
58336
- }
58337
- /**
58338
- * Gets the blue component of the color.
58339
- * @returns {number} The blue component value in the range [0-255].
58340
- */
58341
- get b() {
58342
- return this.color.b;
58343
- }
58344
- /**
58345
- * Gets the alpha (opacity) component of the color.
58346
- * @returns {number} The alpha component value in the range [0-255].
58347
- */
58348
- get a() {
58349
- return this.color.a;
58428
+ return this.color.getHex();
58350
58429
  }
58351
58430
  /**
58352
58431
  * Disposes of the color handle and releases associated resources.
@@ -58359,6 +58438,12 @@ class RemoteColor {
58359
58438
  this._disposed = true;
58360
58439
  }
58361
58440
  }
58441
+ function RGBAfromThree(color, opacity = 1) {
58442
+ return new RGBA(color.r, color.g, color.b, opacity);
58443
+ }
58444
+ function RGBA32fromThree(color, opacity = 1) {
58445
+ return RGBA32.fromFloats(color.r, color.g, color.b, opacity);
58446
+ }
58362
58447
  const MAX_BATCH_SIZE = 3e3;
58363
58448
  class ColorManager {
58364
58449
  /**
@@ -58378,39 +58463,48 @@ class ColorManager {
58378
58463
  * @param hex - The RGBA32 color value
58379
58464
  * @returns Promise resolving to a ColorHandle, or undefined if creation fails
58380
58465
  */
58381
- async getColor(hex) {
58382
- const colors = await this.getColors([hex]);
58466
+ async getColor(color) {
58467
+ const colors = await this.getColors([color]);
58383
58468
  if (!colors) return void 0;
58384
58469
  return colors[0];
58385
58470
  }
58386
58471
  /**
58387
58472
  * Creates or retrieves cached color instances for multiple hex values.
58388
- * @param c - Array of RGBA32 color values
58473
+ * @param colors - Array of color values or undefined for no color
58389
58474
  * @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
58390
58475
  * @remarks Duplicate hex values will be mapped to the same color instance for efficiency
58391
58476
  */
58392
- async getColors(c) {
58393
- const result = new Array(c.length);
58477
+ async getColors(colors) {
58478
+ const result = new Array(colors.length);
58394
58479
  const hexToIndices = /* @__PURE__ */ new Map();
58395
58480
  const toCreate = [];
58396
- for (let i = 0; i < c.length; i++) {
58397
- const color = c[i];
58398
- if (this._hexToColor.has(color.hex)) {
58399
- result[i] = this._hexToColor.get(color.hex);
58400
- } else if (hexToIndices.has(color.hex)) {
58401
- hexToIndices.get(color.hex).push(i);
58402
- } else {
58403
- toCreate.push(color);
58404
- hexToIndices.set(color.hex, [i]);
58481
+ for (let i = 0; i < colors.length; i++) {
58482
+ const color = colors[i];
58483
+ if (color === void 0) {
58484
+ result[i] = void 0;
58485
+ continue;
58486
+ }
58487
+ const hex = (color == null ? void 0 : color.getHex()) ?? -1;
58488
+ const remoteColor = this._hexToColor.get(hex);
58489
+ if (remoteColor) {
58490
+ result[i] = remoteColor;
58491
+ continue;
58492
+ }
58493
+ const indices = hexToIndices.get(hex);
58494
+ if (indices) {
58495
+ hexToIndices.get(hex).push(i);
58496
+ continue;
58405
58497
  }
58498
+ toCreate.push(color);
58499
+ hexToIndices.set(hex, [i]);
58406
58500
  }
58407
- const colors = await this._createColors(toCreate);
58408
- if (!colors) return void 0;
58409
- for (let i = 0; i < colors.length; i++) {
58501
+ const remoteColors = await this._createColors(toCreate);
58502
+ if (!remoteColors) return void 0;
58503
+ for (let i = 0; i < remoteColors.length; i++) {
58410
58504
  const color = toCreate[i];
58411
- const indices = hexToIndices.get(color.hex);
58505
+ const indices = hexToIndices.get(color.getHex());
58412
58506
  for (const index2 of indices) {
58413
- result[index2] = colors[i];
58507
+ result[index2] = remoteColors[i];
58414
58508
  }
58415
58509
  }
58416
58510
  return result;
@@ -58453,7 +58547,8 @@ class ColorManager {
58453
58547
  if (colors.length === 0) {
58454
58548
  return result;
58455
58549
  }
58456
- const instances = await this._rpc.RPCCreateMaterialInstances(MaterialHandles.StandardOpaque, 1, colors);
58550
+ const rpcColors = colors.map((c) => RGBA32fromThree(c));
58551
+ const instances = await this._rpc.RPCCreateMaterialInstances(MaterialHandles.StandardOpaque, 1, rpcColors);
58457
58552
  if (!instances) return void 0;
58458
58553
  for (let i = 0; i < colors.length; i++) {
58459
58554
  const color = this._createColor(colors[i], instances[i]);
@@ -58470,7 +58565,7 @@ class ColorManager {
58470
58565
  */
58471
58566
  _createColor(color, id2) {
58472
58567
  const handle = new RemoteColor(color, id2, this);
58473
- this._hexToColor.set(color.hex, handle);
58568
+ this._hexToColor.set(color.getHex(), handle);
58474
58569
  this._idToColor.set(handle.id, handle);
58475
58570
  return handle;
58476
58571
  }
@@ -58812,6 +58907,7 @@ class Decoder {
58812
58907
  }
58813
58908
  }
58814
58909
  const CODE_TO_KEYCODE = {
58910
+ "Space": 32,
58815
58911
  "ArrowUp": 38,
58816
58912
  "ArrowDown": 40,
58817
58913
  "ArrowLeft": 37,
@@ -58845,6 +58941,9 @@ function createAdapter$1(viewer) {
58845
58941
  toggleOrthographic: () => {
58846
58942
  console.log("toggleOrthographic. Not supported yet");
58847
58943
  },
58944
+ toggleCameraOrbitMode: () => {
58945
+ viewer.rpc.RPCKeyEvent(CODE_TO_KEYCODE["Space"], true);
58946
+ },
58848
58947
  resetCamera: () => {
58849
58948
  viewer.camera.restoreSavedPosition();
58850
58949
  },
@@ -59037,9 +59136,9 @@ class Raycaster3 {
59037
59136
  if (!Validation.isRelativeVector2(position)) return void 0;
59038
59137
  const test2 = await this._rpc.RPCPerformHitTest(position);
59039
59138
  if (!test2) return void 0;
59040
- const vim = this._vims.getFromHandle(test2.vimHandle);
59139
+ const vim = this._vims.getFromHandle(test2.vimIndex);
59041
59140
  if (!vim) return void 0;
59042
- const object = vim.getElement(test2.elementIndex);
59141
+ const object = vim.getElement(test2.vimElementIndex);
59043
59142
  if (!object) return void 0;
59044
59143
  return new UltraRaycastResult(
59045
59144
  object,
@@ -59068,7 +59167,7 @@ const defaultSceneSettings = {
59068
59167
  hdrScale: 1.37,
59069
59168
  hdrBackgroundScale: 1,
59070
59169
  hdrBackgroundSaturation: 1,
59071
- backGroundBlur: 1,
59170
+ backgroundBlur: 1,
59072
59171
  backgroundColor: new RGBA(0.9, 0.9, 0.9, 1)
59073
59172
  };
59074
59173
  var VimLoadingStatus = /* @__PURE__ */ ((VimLoadingStatus2) => {
@@ -59081,15 +59180,26 @@ var VimLoadingStatus = /* @__PURE__ */ ((VimLoadingStatus2) => {
59081
59180
  return VimLoadingStatus2;
59082
59181
  })(VimLoadingStatus || {});
59083
59182
  class RpcSafeClient {
59183
+ /**
59184
+ * Creates a new RpcSafeClient instance.
59185
+ * @param rpc - The underlying RpcClient used for communication
59186
+ * @param batchSize - Maximum size of batched data for operations (default: 10000)
59187
+ */
59084
59188
  constructor(rpc, batchSize = defaultBatchSize) {
59085
59189
  __publicField(this, "rpc");
59086
59190
  __publicField(this, "batchSize");
59087
59191
  this.rpc = rpc;
59088
59192
  this.batchSize = batchSize;
59089
59193
  }
59194
+ /**
59195
+ * The URL used by the underlying RPC connection.
59196
+ */
59090
59197
  get url() {
59091
59198
  return this.rpc.url;
59092
59199
  }
59200
+ /**
59201
+ * Indicates whether the RPC client is currently connected.
59202
+ */
59093
59203
  get connected() {
59094
59204
  return this.rpc.connected;
59095
59205
  }
@@ -59099,9 +59209,10 @@ class RpcSafeClient {
59099
59209
  * and scene-wide settings.
59100
59210
  ******************************************************************************/
59101
59211
  /**
59102
- * Initializes and starts the scene with specified settings.
59212
+ * Initializes and starts the scene with the given settings.
59103
59213
  * @param settings - Optional partial scene settings to override defaults
59104
- * @remarks If no settings are provided, default values will be used
59214
+ * @returns Promise resolving to true if the scene started successfully, false otherwise
59215
+ * @remarks Missing values will be filled from {@link defaultSceneSettings}
59105
59216
  */
59106
59217
  async RPCStartScene(settings2) {
59107
59218
  const s = { ...defaultSceneSettings, ...settings2 ?? {} };
@@ -59111,15 +59222,15 @@ class RpcSafeClient {
59111
59222
  Validation.min0(s.hdrScale),
59112
59223
  Validation.clamp01(s.hdrBackgroundScale),
59113
59224
  Validation.clamp01(s.hdrBackgroundSaturation),
59114
- Validation.clamp01(s.backGroundBlur),
59225
+ Validation.clamp01(s.backgroundBlur),
59115
59226
  Validation.clampRGBA01(s.backgroundColor)
59116
59227
  ),
59117
59228
  false
59118
59229
  );
59119
59230
  }
59120
59231
  /**
59121
- * Sets the lighting settings for the scene.
59122
- * @param settings - The lighting settings to apply
59232
+ * Updates the scene’s lighting configuration.
59233
+ * @param settings - The complete lighting and background settings to apply
59123
59234
  */
59124
59235
  RPCSetLighting(settings2) {
59125
59236
  const s = settings2;
@@ -59128,43 +59239,80 @@ class RpcSafeClient {
59128
59239
  Validation.min0(s.hdrScale),
59129
59240
  Validation.clamp01(s.hdrBackgroundScale),
59130
59241
  Validation.clamp01(s.hdrBackgroundSaturation),
59131
- Validation.clamp01(s.backGroundBlur),
59242
+ Validation.clamp01(s.backgroundBlur),
59132
59243
  Validation.clampRGBA01(s.backgroundColor)
59133
59244
  );
59134
59245
  }
59135
- /*******************************************************************************
59136
- * NODE VISIBILITY METHODS
59137
- * Methods for controlling node visibility, including show/hide, ghosting,
59138
- * and highlighting functionality.
59139
- ******************************************************************************/
59140
59246
  /**
59141
- * Highlights specified nodes in a component.
59142
- * Large node arrays are automatically processed in batches.
59143
- * @param componentHandle - The component containing the nodes
59144
- * @param nodes - Array of node indices to highlight
59145
- * @throws {Error} If the component handle is invalid or nodes array is invalid
59146
- */
59147
- RPCSetStateElements(componentHandle, elements, state) {
59148
- if (elements.length === 0) return;
59149
- if (!Validation.isComponentHandle(componentHandle)) return;
59150
- if (!Validation.areComponentHandles(elements)) return;
59151
- const batches = batchArray(elements, this.batchSize);
59152
- for (const batch of batches) {
59153
- this.rpc.RPCSetStateElements(componentHandle, batch, state);
59154
- }
59155
- }
59156
- RPCSetStatesElements(componentHandle, elements, states) {
59157
- if (!Validation.isComponentHandle(componentHandle)) return;
59158
- if (!Validation.areComponentHandles(elements)) return;
59159
- if (!Validation.areSameLength(elements, states)) return;
59160
- const batches = batchArrays(elements, states, this.batchSize);
59161
- for (const [batchedElements, batchedStates] of batches) {
59162
- this.rpc.RPCSetStatesElements(componentHandle, batchedElements, batchedStates);
59247
+ * Retrieves the total number of elements across the entire scene.
59248
+ * @returns Promise resolving to the total number of elements (0 on failure).
59249
+ */
59250
+ RPCGetElementCountForScene() {
59251
+ return this.safeCall(
59252
+ () => this.rpc.RPCGetElementCountForScene(),
59253
+ 0
59254
+ );
59255
+ }
59256
+ /**
59257
+ * Retrieves the number of elements within a specific loaded vim.
59258
+ * @param vimIndex - Index of the loaded vim to query
59259
+ * @returns Promise resolving to the element count (0 on failure)
59260
+ */
59261
+ RPCGetElementCountForVim(vimIndex) {
59262
+ return this.safeCall(
59263
+ () => this.rpc.RPCGetElementCountForVim(vimIndex),
59264
+ 0
59265
+ );
59266
+ }
59267
+ /*******************************************************************************
59268
+ * ELEMENTS VISIBILITY METHODS
59269
+ * Methods for controlling element visibility, including show/hide, ghosting,
59270
+ * and highlighting functionality.
59271
+ ******************************************************************************/
59272
+ /**
59273
+ * Sets a single visibility state for given elements within a loaded vim.
59274
+ * The operation is automatically split into batches if the array is large.
59275
+ *
59276
+ * @param vimIndex - The index of the loaded vim containing the elements
59277
+ * @param vimElementIndices - Array of vim-based element indices to apply the state to
59278
+ * @param state - The visibility state to apply (e.g., VISIBLE, HIDDEN)
59279
+ */
59280
+ RPCSetStateElements(vimIndex, vimElementIndices, state) {
59281
+ if (vimElementIndices.length === 0) return;
59282
+ if (!Validation.isIndex(vimIndex)) return;
59283
+ if (!Validation.areIndices(vimElementIndices)) return;
59284
+ const batches = batchArray(vimElementIndices, this.batchSize);
59285
+ for (const batch of batches) {
59286
+ this.rpc.RPCSetStateElements(vimIndex, batch, state);
59287
+ }
59288
+ }
59289
+ /**
59290
+ * Sets individual visibility states for multiple elements in a vim.
59291
+ * Each element receives a corresponding visibility state from the input array.
59292
+ * The operation is automatically split into batches if the array is large.
59293
+ *
59294
+ * @param vimIndex - The index of the loaded vim
59295
+ * @param vimElementIndices - Array of vim-based element indices
59296
+ * @param states - Array of visibility states to apply, one per element
59297
+ */
59298
+ RPCSetStatesElements(vimIndex, vimElementIndices, states) {
59299
+ if (!Validation.isIndex(vimIndex)) return;
59300
+ if (!Validation.areIndices(vimElementIndices)) return;
59301
+ if (!Validation.areSameLength(vimElementIndices, states)) return;
59302
+ const batches = batchArrays(vimElementIndices, states, this.batchSize);
59303
+ for (const [batchedElements, batchedStates] of batches) {
59304
+ this.rpc.RPCSetStatesElements(vimIndex, batchedElements, batchedStates);
59163
59305
  }
59164
59306
  }
59165
- RPCSetStateVim(componentHandle, state) {
59166
- if (!Validation.isComponentHandle(componentHandle)) return;
59167
- this.rpc.RPCSetStateVim(componentHandle, state);
59307
+ /**
59308
+ * Applies a single visibility state to all elements of a loaded vim.
59309
+ *
59310
+ * @param vimIndex - The index of the loaded vim
59311
+ * @param state - The visibility state to apply (e.g., VISIBLE, HIDDEN)
59312
+ */
59313
+ RPCSetStateVim(vimIndex, state) {
59314
+ if (!Validation.isIndex(vimIndex)) return;
59315
+ this.rpc.RPCSetStateVim(vimIndex, state);
59168
59316
  }
59169
59317
  /*******************************************************************************
59170
59318
  * TEXT AND UI METHODS
@@ -59176,7 +59324,6 @@ class RpcSafeClient {
59176
59324
  * @param color - The color of the text
59177
59325
  * @param text - The content to display
59178
59326
  * @returns Promise resolving to the handle of the created text component
59179
- * @throws {Error} If the text is empty
59180
59327
  */
59181
59328
  async RPCCreateText(position, color, text) {
59182
59329
  if (!Validation.isNonEmptyString(text)) return INVALID_HANDLE;
@@ -59189,19 +59336,26 @@ class RpcSafeClient {
59189
59336
  /**
59190
59337
  * Destroys a text component, removing it from the scene.
59191
59338
  * @param componentHandle - The handle of the text component to destroy
59192
- * @throws {Error} If the component handle is invalid
59193
59339
  */
59194
59340
  RPCDestroyText(componentHandle) {
59195
- if (!Validation.isComponentHandle(componentHandle)) return;
59341
+ if (!Validation.isIndex(componentHandle)) return;
59196
59342
  this.rpc.RPCDestroyText(componentHandle);
59197
59343
  }
59198
59344
  /*******************************************************************************
59199
59345
  * SECTION BOX METHODS
59200
59346
  * Methods for controlling section box visibility and position.
59201
59347
  ******************************************************************************/
59348
+ /**
59349
+ * Enables or disables the section box.
59350
+ * @param enable - True to enable the section box, false to disable it
59351
+ */
59202
59352
  RPCEnableSectionBox(enable) {
59203
59353
  this.rpc.RPCEnableSectionBox(enable);
59204
59354
  }
59355
+ /**
59356
+ * Sets the parameters of the section box.
59357
+ * @param state - The new section box state, including visibility and bounding box
59358
+ */
59205
59359
  RPCSetSectionBox(state) {
59206
59360
  this.rpc.RPCSetSectionBox(
59207
59361
  {
@@ -59210,6 +59364,10 @@ class RpcSafeClient {
59210
59364
  }
59211
59365
  );
59212
59366
  }
59367
+ /**
59368
+ * Retrieves the current section box state.
59369
+ * @returns Promise resolving to the section box state or undefined on failure
59370
+ */
59213
59371
  async RPCGetSectionBox() {
59214
59372
  return await this.safeCall(
59215
59373
  () => this.rpc.RPCGetSectionBox(),
@@ -59226,7 +59384,7 @@ class RpcSafeClient {
59226
59384
  */
59227
59385
  async RPCGetCameraView() {
59228
59386
  return await this.safeCall(
59229
- () => this.rpc.RPCGetCameraView(),
59387
+ () => this.rpc.RPCGetCameraPose(),
59230
59388
  void 0
59231
59389
  );
59232
59390
  }
@@ -59238,7 +59396,7 @@ class RpcSafeClient {
59238
59396
  RPCSetCameraView(segment, blendTime) {
59239
59397
  if (!Validation.isValidSegment(segment)) return;
59240
59398
  blendTime = Validation.clamp01(blendTime);
59241
- this.rpc.RPCSetCameraView(segment, blendTime);
59399
+ this.rpc.RPCSetCameraPose(segment, blendTime);
59242
59400
  }
59243
59401
  /**
59244
59402
  * Sets the camera's position without changing its target.
@@ -59266,52 +59424,52 @@ class RpcSafeClient {
59266
59424
  }
59267
59425
  /**
59268
59426
  * Retrieves the axis-aligned bounding box (AABB) that encompasses the entire scene.
59269
- * This includes all loaded geometry across all VIM components.
59427
+ * This includes all loaded geometry across all loaded vims.
59270
59428
  *
59271
59429
  * @returns Promise resolving to the global AABB of the scene, or undefined on failure
59272
59430
  */
59273
- RPCGetAABBForAll() {
59431
+ RPCGetAABBForScene() {
59274
59432
  return this.safeCall(
59275
- () => this.rpc.RPCGetAABBForAll(),
59433
+ () => this.rpc.RPCGetAABBForScene(),
59276
59434
  void 0
59277
59435
  );
59278
59436
  }
59279
59437
  /**
59280
- * Retrieves the axis-aligned bounding box (AABB) for a specific VIM component.
59281
- * This bounding box represents the spatial bounds of all geometry within the given component.
59438
+ * Retrieves the axis-aligned bounding box (AABB) for a specific loaded vim.
59439
+ * This bounding box represents the spatial bounds of all geometry within the given loaded vim.
59282
59440
  *
59283
- * @param componentHandle - The handle of the VIM component to query
59284
- * @returns Promise resolving to the component’s bounding box, or undefined on failure
59441
+ * @param vimIndex - The index of the loaded vim to query
59442
+ * @returns Promise resolving to the vim bounding box, or undefined on failure
59285
59443
  */
59286
- async RPCGetAABBForVim(componentHandle) {
59444
+ async RPCGetAABBForVim(vimIndex) {
59445
+ if (!Validation.isIndex(vimIndex)) return void 0;
59287
59446
  return await this.safeCall(
59288
- () => this.rpc.RPCGetAABBForVim(componentHandle),
59447
+ () => this.rpc.RPCGetAABBForVim(vimIndex),
59289
59448
  void 0
59290
59449
  );
59291
59450
  }
59292
59451
  /**
59293
- * Calculates the bounding box for specified nodes in a component.
59294
- * Large node arrays are automatically processed in batches for better performance.
59295
- * @param componentHandle - The component containing the nodes
59296
- * @param elements - Array of node indices to calculate bounds for
59297
- * @returns Promise resolving to the combined bounding box
59298
- * @throws {Error} If the component handle is invalid or nodes array is invalid
59452
+ * Calculates the bounding box for specified elements of a loaded vim.
59453
+ * Large element arrays are automatically processed in batches.
59454
+ * @param vimIndex - The index of the loaded vim
59455
+ * @param vimElementIndices - Array of vim-based element indices to calculate bounds for
59456
+ * @returns Promise resolving to the combined bounding box or undefined on failure
59299
59457
  */
59300
- async RPCGetAABBForElements(componentHandle, elements) {
59301
- if (!Validation.isComponentHandle(componentHandle)) return;
59302
- if (!Validation.areComponentHandles(elements)) return;
59458
+ async RPCGetAABBForElements(vimIndex, vimElementIndices) {
59459
+ if (!Validation.isIndex(vimIndex)) return;
59460
+ if (!Validation.areIndices(vimElementIndices)) return;
59303
59461
  return await this.safeCall(
59304
- () => this.RPCGetAABBForElementsBatched(componentHandle, elements),
59462
+ () => this.RPCGetAABBForElementsBatched(vimIndex, vimElementIndices),
59305
59463
  void 0
59306
59464
  );
59307
59465
  }
59308
- async RPCGetAABBForElementsBatched(componentHandle, elements) {
59309
- if (elements.length === 0) {
59466
+ async RPCGetAABBForElementsBatched(vimIndex, vimElementIndices) {
59467
+ if (vimElementIndices.length === 0) {
59310
59468
  return new Box3();
59311
59469
  }
59312
- const batches = batchArray(elements, this.batchSize);
59470
+ const batches = batchArray(vimElementIndices, this.batchSize);
59313
59471
  const promises = batches.map(async (batch) => {
59314
- const aabb = await this.rpc.RPCGetAABBForElements(componentHandle, batch);
59472
+ const aabb = await this.rpc.RPCGetAABBForElements(vimIndex, batch);
59315
59473
  const v1 = new Vector3(aabb.min.x, aabb.min.y, aabb.min.z);
59316
59474
  const v2 = new Vector3(aabb.max.x, aabb.max.y, aabb.max.z);
59317
59475
  return new Box3(v1, v2);
@@ -59322,53 +59480,51 @@ class RpcSafeClient {
59322
59480
  return box;
59323
59481
  }
59324
59482
  /**
59325
- * Frames the camera to show all components in the scene.
59483
+ * Frames the camera to show all elements in the scene.
59326
59484
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59327
59485
  * @returns Promise resolving to camera segment representing the final position
59328
59486
  */
59329
- async RPCFrameAll(blendTime) {
59487
+ async RPCFrameScene(blendTime) {
59330
59488
  blendTime = Validation.clamp01(blendTime);
59331
59489
  return await this.safeCall(
59332
- () => this.rpc.RPCFrameAll(blendTime),
59490
+ () => this.rpc.RPCFrameScene(blendTime),
59333
59491
  void 0
59334
59492
  );
59335
59493
  }
59336
59494
  /**
59337
- * Frames a specific VIM component in the scene.
59338
- * @param componentHandle - The handle of the VIM component to frame
59495
+ * Frames a specific vim in the scene.
59496
+ * @param vimIndex - The index of the loaded vim to frame
59339
59497
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59340
59498
  * @returns Promise resolving to camera segment representing the final position
59341
- * @throws {Error} If the component handle is invalid
59342
59499
  */
59343
- async RPCFrameVim(componentHandle, blendTime) {
59344
- if (!Validation.isComponentHandle(componentHandle)) return;
59500
+ async RPCFrameVim(vimIndex, blendTime) {
59501
+ if (!Validation.isIndex(vimIndex)) return;
59345
59502
  blendTime = Validation.clamp01(blendTime);
59346
59503
  return await this.safeCall(
59347
- () => this.rpc.RPCFrameVim(componentHandle, blendTime),
59504
+ () => this.rpc.RPCFrameVim(vimIndex, blendTime),
59348
59505
  void 0
59349
59506
  );
59350
59507
  }
59351
59508
  /**
59352
- * Frames specific instances within a component. For large numbers of instances,
59353
- * automatically switches to bounding box framing for better performance.
59354
- * @param componentHandle - The component containing the instances
59355
- * @param elements - Array of node indices to frame
59509
+ * Frames specific elements of a loaded vim.
59510
+ * Automatically batches large arrays of elements.
59511
+ * @param vimIndex - The index of the loaded vim
59512
+ * @param vimElementIndices - Array of vim-based element indices to frame
59356
59513
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59357
59514
  * @returns Promise resolving to camera segment representing the final position
59358
- * @throws {Error} If the component handle is invalid or nodes array is empty
59359
59515
  */
59360
- async RPCFrameElements(componentHandle, elements, blendTime) {
59361
- if (!Validation.isComponentHandle(componentHandle)) return;
59362
- if (!Validation.areComponentHandles(elements)) return;
59516
+ async RPCFrameElements(vimIndex, vimElementIndices, blendTime) {
59517
+ if (!Validation.isIndex(vimIndex)) return;
59518
+ if (!Validation.areIndices(vimElementIndices)) return;
59363
59519
  blendTime = Validation.clamp01(blendTime);
59364
- if (elements.length < this.batchSize) {
59520
+ if (vimElementIndices.length < this.batchSize) {
59365
59521
  return await this.safeCall(
59366
- () => this.rpc.RPCFrameElements(componentHandle, elements, blendTime),
59522
+ () => this.rpc.RPCFrameElements(vimIndex, vimElementIndices, blendTime),
59367
59523
  void 0
59368
59524
  );
59369
59525
  } else {
59370
59526
  const box = await this.safeCall(
59371
- () => this.RPCGetAABBForElementsBatched(componentHandle, elements),
59527
+ () => this.RPCGetAABBForElementsBatched(vimIndex, vimElementIndices),
59372
59528
  void 0
59373
59529
  );
59374
59530
  if (!box) return void 0;
@@ -59382,7 +59538,6 @@ class RpcSafeClient {
59382
59538
  * Frames the camera to show a specific bounding box.
59383
59539
  * @param box - The bounding box to frame
59384
59540
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59385
- * @throws {Error} If the box is invalid (min values must be less than max values)
59386
59541
  */
59387
59542
  async RPCFrameAABB(box, blendTime) {
59388
59543
  if (!Validation.isValidBox(box)) return;
@@ -59399,12 +59554,15 @@ class RpcSafeClient {
59399
59554
  /**
59400
59555
  * Sets the camera movement speed.
59401
59556
  * @param speed - The desired movement speed (must be positive)
59402
- * @throws {Error} If speed is not positive
59403
59557
  */
59404
59558
  RPCSetCameraSpeed(speed) {
59405
59559
  speed = Validation.min0(speed);
59406
59560
  this.rpc.RPCSetCameraSpeed(speed);
59407
59561
  }
59562
+ /**
59563
+ * Sets the camera control mode.
59564
+ * @param mode - The desired input mode (e.g., {@link InputMode.Orbit} or {@link InputMode.Free})
59565
+ */
59408
59566
  RPCSetCameraMode(mode) {
59409
59567
  this.rpc.RPCSetCameraMode(
59410
59568
  mode === "orbit"
@@ -59413,9 +59571,8 @@ class RpcSafeClient {
59413
59571
  }
59414
59572
  /**
59415
59573
  * Sets the viewer's aspect ratio.
59416
- * @param width - The width component of the aspect ratio
59417
- * @param height - The height component of the aspect ratio
59418
- * @throws {Error} If width or height are not positive integers
59574
+ * @param width - The width of the desired aspect ratio
59575
+ * @param height - The height of the desired aspect ratio
59419
59576
  */
59420
59577
  RPCSetCameraAspectRatio(width, height) {
59421
59578
  if (!Validation.isPositiveInteger(width)) return;
@@ -59424,13 +59581,12 @@ class RpcSafeClient {
59424
59581
  }
59425
59582
  /*******************************************************************************
59426
59583
  * VIM FILE MANAGEMENT METHODS
59427
- * Methods for loading, unloading, and managing VIM files and components.
59584
+ * Methods for loading, unloading, and managing VIM files.
59428
59585
  ******************************************************************************/
59429
59586
  /**
59430
59587
  * Loads a VIM file from the local filesystem.
59431
59588
  * @param source - The path to the VIM file (supports file:// protocol)
59432
- * @returns Promise resolving to the handle of the loaded VIM component
59433
- * @throws {Error} If the filename is invalid or empty
59589
+ * @returns Promise resolving to the index of the loaded vim
59434
59590
  */
59435
59591
  async RPCLoadVim(source) {
59436
59592
  if (!Validation.isNonEmptyString(source.url)) return INVALID_HANDLE;
@@ -59442,9 +59598,8 @@ class RpcSafeClient {
59442
59598
  }
59443
59599
  /**
59444
59600
  * Loads a VIM file from a remote URL.
59445
- * @param url - The URL of the VIM file to load
59446
- * @returns Promise resolving to the handle of the loaded VIM component
59447
- * @throws {Error} If the URL is invalid
59601
+ * @param source - The URL or file path of the VIM file to load
59602
+ * @returns Promise resolving to the index of the loaded vim
59448
59603
  */
59449
59604
  async RPCLoadVimURL(source) {
59450
59605
  if (!Validation.isURL(source.url)) return INVALID_HANDLE;
@@ -59454,17 +59609,16 @@ class RpcSafeClient {
59454
59609
  );
59455
59610
  }
59456
59611
  /**
59457
- * Retrieves the current loading state and progress of a VIM component.
59458
- * @param componentHandle - The handle of the VIM component
59612
+ * Retrieves the current loading state and progress of a vim.
59613
+ * @param vimIndex - The index of the vim being loaded
59459
59614
  * @returns Promise resolving to the current loading state and progress
59460
- * @throws {Error} If the component handle is invalid
59461
59615
  */
59462
- async RPCGetVimLoadingState(componentHandle) {
59463
- if (!Validation.isComponentHandle(componentHandle)) {
59616
+ async RPCGetVimLoadingState(vimIndex) {
59617
+ if (!Validation.isIndex(vimIndex)) {
59464
59618
  return { status: 0, progress: 0 };
59465
59619
  }
59466
59620
  const result = await this.safeCall(
59467
- () => this.rpc.RPCGetVimLoadingState(componentHandle),
59621
+ () => this.rpc.RPCGetVimLoadingState(vimIndex),
59468
59622
  { status: 0, progress: 0 }
59469
59623
  );
59470
59624
  if (!(result.status in VimLoadingStatus)) {
@@ -59473,16 +59627,7 @@ class RpcSafeClient {
59473
59627
  return result;
59474
59628
  }
59475
59629
  /**
59476
- * Unloads a VIM component and frees associated resources.
59477
- * @param componentHandle - The handle of the component to unload
59478
- * @throws {Error} If the component handle is invalid
59479
- */
59480
- RPCUnloadVim(componentHandle) {
59481
- if (!Validation.isComponentHandle(componentHandle)) return;
59482
- this.rpc.RPCUnloadVim(componentHandle);
59483
- }
59484
- /**
59485
- * Clears the entire scene, removing all components and resetting to initial state.
59630
+ * Clears the entire scene, unloading all vims and resetting to initial state.
59486
59631
  */
59487
59632
  RPCUnloadAll() {
59488
59633
  this.rpc.RPCUnloadAll();
@@ -59498,7 +59643,7 @@ class RpcSafeClient {
59498
59643
  /**
59499
59644
  * Performs hit testing at a specified screen position.
59500
59645
  * @param pos - Normalized screen coordinates (0-1, 0-1)
59501
- * @returns Promise resolving to hit test result if something was hit, undefined otherwise
59646
+ * @returns Promise resolving to hit test result if a valid hit was detected, undefined otherwise
59502
59647
  */
59503
59648
  async RPCPerformHitTest(pos) {
59504
59649
  if (!Validation.isRelativeVector2(pos)) return;
@@ -59506,7 +59651,7 @@ class RpcSafeClient {
59506
59651
  () => this.rpc.RPCPerformHitTest(pos),
59507
59652
  void 0
59508
59653
  );
59509
- if (!result || result.nodeIndex < 0) {
59654
+ if (!result || result.vimIndex === INVALID_HANDLE) {
59510
59655
  return void 0;
59511
59656
  }
59512
59657
  return result;
@@ -59516,7 +59661,6 @@ class RpcSafeClient {
59516
59661
  * @param position - The normalized screen coordinates (0-1, 0-1)
59517
59662
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59518
59663
  * @param down - True if button is pressed down, false if released
59519
- * @throws {Error} If mouseButton is not a valid positive integer
59520
59664
  */
59521
59665
  RPCMouseButtonEvent(position, mouseButton, down) {
59522
59666
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59527,7 +59671,6 @@ class RpcSafeClient {
59527
59671
  * Sends a mouse double-click event to the viewer.
59528
59672
  * @param position - The normalized screen coordinates (0-1, 0-1)
59529
59673
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59530
- * @throws {Error} If mouseButton is not a valid positive integer
59531
59674
  */
59532
59675
  RPCMouseDoubleClickEvent(position, mouseButton) {
59533
59676
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59554,7 +59697,6 @@ class RpcSafeClient {
59554
59697
  * Sends a mouse selection event to the viewer.
59555
59698
  * @param position - The normalized screen coordinates (0-1, 0-1)
59556
59699
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59557
- * @throws {Error} If mouseButton is not a valid positive integer
59558
59700
  */
59559
59701
  RPCMouseSelectEvent(position, mouseButton) {
59560
59702
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59581,7 +59723,6 @@ class RpcSafeClient {
59581
59723
  * @param smoothness - The smoothness value to apply (clamped between 0 and 1)
59582
59724
  * @param colors - Array of colors for each material instance
59583
59725
  * @returns Array of handles for the created material instances
59584
- * @throws {Error} If the material handle is invalid or smoothness is out of range
59585
59726
  */
59586
59727
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
59587
59728
  if (!Validation.isMaterialHandle(materialHandle)) return;
@@ -59604,46 +59745,56 @@ class RpcSafeClient {
59604
59745
  }
59605
59746
  /**
59606
59747
  * Destroys multiple material instances, freeing associated resources.
59607
- * @param materialInstanceHandle - Array of handles for material instances to destroy
59608
- * @throws {Error} If any handle in the array is invalid
59748
+ * @param materialInstanceHandles - Array of handles for material instances to destroy
59609
59749
  */
59610
- RPCDestroyMaterialInstances(materialInstanceHandle) {
59611
- if (!Validation.areComponentHandles(materialInstanceHandle)) return;
59612
- this.rpc.RPCDestroyMaterialInstances(materialInstanceHandle);
59750
+ RPCDestroyMaterialInstances(materialInstanceHandles) {
59751
+ if (!Validation.areIndices(materialInstanceHandles)) return;
59752
+ this.rpc.RPCDestroyMaterialInstances(materialInstanceHandles);
59613
59753
  }
59614
59754
  /**
59615
- * Sets material overrides for specific nodes in a component.
59616
- * Large arrays are automatically processed in batches for better performance.
59617
- * @param componentHandle - The component containing the nodes
59618
- * @param nodes - Array of node indices to override
59619
- * @param materialInstanceHandles - Array of material instance handles to apply (must match nodes length)
59620
- * @throws {Error} If arrays have different lengths or any handle is invalid
59755
+ * Sets material overrides for specific elements in a loaded vim.
59756
+ * Large arrays are automatically processed in batches.
59757
+ * @param vimIndex - The index of the loaded vim
59758
+ * @param vimElementIndices - Array of vim-based element indices to override
59759
+ * @param materialInstanceHandles - Array of material instance handles to apply (must match element length)
59621
59760
  */
59622
- RPCSetMaterialOverrides(componentHandle, nodes, materialInstanceHandles) {
59623
- if (!Validation.areSameLength(nodes, materialInstanceHandles)) return;
59624
- if (!Validation.isComponentHandle(componentHandle)) return;
59625
- if (!Validation.areComponentHandles(nodes)) return;
59761
+ RPCSetMaterialOverridesForElements(vimIndex, vimElementIndices, materialInstanceHandles) {
59762
+ if (!Validation.areSameLength(vimElementIndices, materialInstanceHandles)) return;
59763
+ if (!Validation.isIndex(vimIndex)) return;
59764
+ if (!Validation.areIndices(vimElementIndices)) return;
59626
59765
  if (!Validation.areIntegers(materialInstanceHandles)) return;
59627
59766
  this.setMaterialOverridesBatched(
59628
- componentHandle,
59629
- nodes,
59767
+ vimIndex,
59768
+ vimElementIndices,
59630
59769
  materialInstanceHandles
59631
59770
  );
59632
59771
  }
59633
- setMaterialOverridesBatched(componentHandle, nodes, materialInstanceHandles) {
59634
- const batches = batchArrays(nodes, materialInstanceHandles, this.batchSize);
59635
- for (const [batchedNodes, batchedMaterials] of batches) {
59636
- this.rpc.RPCSetMaterialOverrides(componentHandle, batchedNodes, batchedMaterials);
59772
+ setMaterialOverridesBatched(vimIndex, vimElementIndices, materialInstanceHandles) {
59773
+ const batches = batchArrays(vimElementIndices, materialInstanceHandles, this.batchSize);
59774
+ for (const [batchedElements, batchedMaterials] of batches) {
59775
+ this.rpc.RPCSetMaterialOverridesForElements(vimIndex, batchedElements, batchedMaterials);
59637
59776
  }
59638
59777
  }
59639
59778
  /**
59640
- * Clears all material overrides for the specified component, restoring default materials.
59641
- * @param componentHandle - The unique identifier of the component
59642
- * @throws {Error} If the component handle is invalid or INVALID_HANDLE
59779
+ * Clears all material overrides for the entire scene.
59780
+ */
59781
+ RPCClearMaterialOverridesForScene() {
59782
+ this.rpc.RPCClearMaterialOverridesForScene();
59783
+ }
59784
+ /**
59785
+ * Clears all material overrides for a specific loaded vim.
59786
+ * @param vimIndex - The index of the loaded vim
59787
+ */
59788
+ RPCClearMaterialOverridesForVim(vimIndex) {
59789
+ this.rpc.RPCClearMaterialOverridesForVim(vimIndex);
59790
+ }
59791
+ /**
59792
+ * Clears all material overrides for specific elements in a loaded vim.
59793
+ * @param vimIndex - The index of the loaded vim
59794
+ * @param vimElementIndices - Array of vim-based element indices to clear overrides for
59643
59795
  */
59644
- RPCClearMaterialOverrides(componentHandle) {
59645
- if (!Validation.isComponentHandle(componentHandle)) return;
59646
- this.rpc.RPCClearMaterialOverrides(componentHandle);
59796
+ RPCClearMaterialOverridesForElements(vimIndex, vimElementIndices) {
59797
+ this.rpc.RPCClearMaterialOverridesForElements(vimIndex, vimElementIndices);
59647
59798
  }
59648
59799
  /*******************************************************************************
59649
59800
  * DEBUG AND UTILITY METHODS
@@ -59700,7 +59851,8 @@ class RpcSafeClient {
59700
59851
  }
59701
59852
  const defaultRenderSettings = {
59702
59853
  ...defaultSceneSettings,
59703
- ghostColor: new RGBA(14 / 255, 14 / 255, 14 / 255, 64 / 255)
59854
+ ghostColor: new Color(14 / 255, 14 / 255, 14 / 255),
59855
+ ghostOpacity: 64 / 255
59704
59856
  };
59705
59857
  class Renderer2 {
59706
59858
  /**
@@ -59747,7 +59899,8 @@ class Renderer2 {
59747
59899
  * Sets up initial scene settings, ghost color, and IBL rotation
59748
59900
  */
59749
59901
  onConnect() {
59750
- this._rpc.RPCSetGhostColor(this._settings.ghostColor);
59902
+ const color = RGBAfromThree(this._settings.ghostColor, this._settings.ghostOpacity);
59903
+ this._rpc.RPCSetGhostColor(color);
59751
59904
  }
59752
59905
  notifySceneUpdated() {
59753
59906
  this._onSceneUpdated.dispatch();
@@ -59755,11 +59908,14 @@ class Renderer2 {
59755
59908
  // Getters
59756
59909
  /**
59757
59910
  * Gets the ghost color used for transparent rendering
59758
- * @returns Current ghost color as RGBA
59911
+ * @returns Current ghost color as a THREE.Color
59759
59912
  */
59760
59913
  get ghostColor() {
59761
59914
  return this._settings.ghostColor;
59762
59915
  }
59916
+ get ghostOpacity() {
59917
+ return this._settings.ghostOpacity;
59918
+ }
59763
59919
  /**
59764
59920
  * Gets the tone mapping white point value
59765
59921
  * @returns Current tone mapping white point
@@ -59793,27 +59949,33 @@ class Renderer2 {
59793
59949
  * @returns Current background blur
59794
59950
  */
59795
59951
  get backgroundBlur() {
59796
- return this._settings.backGroundBlur;
59952
+ return this._settings.backgroundBlur;
59797
59953
  }
59798
59954
  /**
59799
59955
  * Gets the background color
59800
59956
  * @returns Current background color as RGBA
59801
59957
  */
59802
59958
  get backgroundColor() {
59803
- return this._settings.backgroundColor;
59959
+ return this._settings.backgroundColor.toThree();
59804
59960
  }
59805
59961
  // Setters
59806
59962
  /**
59807
59963
  * Updates the ghost color used for transparent rendering
59808
- * @param value - New ghost color as RGBA
59964
+ * @param value - New ghost color as THREE.Color
59809
59965
  */
59810
59966
  set ghostColor(value) {
59811
- value = Validation.clampRGBA01(value);
59812
59967
  if (this._settings.ghostColor.equals(value)) return;
59813
59968
  this._settings.ghostColor = value;
59814
59969
  this._updateGhostColor = true;
59815
59970
  this.requestSettingsUpdate();
59816
59971
  }
59972
+ set ghostOpacity(value) {
59973
+ value = Validation.clamp01(value);
59974
+ if (this._settings.ghostOpacity === value) return;
59975
+ this._settings.ghostOpacity = value;
59976
+ this._updateGhostColor = true;
59977
+ this.requestSettingsUpdate();
59978
+ }
59817
59979
  /**
59818
59980
  * Sets the tone mapping white point value
59819
59981
  * @param value - New tone mapping white point value
@@ -59864,24 +60026,24 @@ class Renderer2 {
59864
60026
  */
59865
60027
  set backgroundBlur(value) {
59866
60028
  value = Validation.clamp01(value);
59867
- if (this._settings.backGroundBlur === value) return;
59868
- this._settings.backGroundBlur = value;
60029
+ if (this._settings.backgroundBlur === value) return;
60030
+ this._settings.backgroundBlur = value;
59869
60031
  this._updateLighting = true;
59870
60032
  this.requestSettingsUpdate();
59871
60033
  }
59872
60034
  /**
59873
60035
  * Sets the background color
59874
- * @param value - New background color as RGBA
60036
+ * @param value - New background color as THREE.Color
59875
60037
  */
59876
60038
  set backgroundColor(value) {
59877
- value = Validation.clampRGBA01(value);
59878
- if (this._settings.backgroundColor.equals(value)) return;
59879
- this._settings.backgroundColor = value;
60039
+ const color = RGBAfromThree(value, 1);
60040
+ if (this._settings.backgroundColor.equals(color)) return;
60041
+ this._settings.backgroundColor = color;
59880
60042
  this._updateLighting = true;
59881
60043
  this.requestSettingsUpdate();
59882
60044
  }
59883
60045
  getBoundingBox() {
59884
- return this._rpc.RPCGetAABBForAll();
60046
+ return this._rpc.RPCGetAABBForScene();
59885
60047
  }
59886
60048
  /**
59887
60049
  * Requests an update to be performed on the next animation frame.
@@ -59896,7 +60058,10 @@ class Renderer2 {
59896
60058
  }
59897
60059
  async applySettings() {
59898
60060
  if (this._updateLighting) await this._rpc.RPCSetLighting(this._settings);
59899
- if (this._updateGhostColor) await this._rpc.RPCSetGhostColor(this._settings.ghostColor);
60061
+ if (this._updateGhostColor) {
60062
+ const color = RGBAfromThree(this._settings.ghostColor, this._settings.ghostOpacity);
60063
+ await this._rpc.RPCSetGhostColor(color);
60064
+ }
59900
60065
  this._updateLighting = false;
59901
60066
  this._updateGhostColor = false;
59902
60067
  this._animationFrame = void 0;
@@ -59996,7 +60161,7 @@ class SectionBox2 {
59996
60161
  * Fits the given box, invalid dimensions will be reversed.
59997
60162
  * @param box - The new bounding box.
59998
60163
  */
59999
- fitBox(box) {
60164
+ setBox(box) {
60000
60165
  box = safeBox(box);
60001
60166
  this._box = box;
60002
60167
  this.scheduleUpdate();
@@ -60020,7 +60185,7 @@ var VisibilityState$1 = /* @__PURE__ */ ((VisibilityState2) => {
60020
60185
  VisibilityState2[VisibilityState2["GHOSTED_HIGHLIGHTED"] = 18] = "GHOSTED_HIGHLIGHTED";
60021
60186
  return VisibilityState2;
60022
60187
  })(VisibilityState$1 || {});
60023
- class StateSynchronizer {
60188
+ class VisibilitySynchronizer {
60024
60189
  /**
60025
60190
  * Creates a new StateSynchronizer instance.
60026
60191
  *
@@ -60038,7 +60203,7 @@ class StateSynchronizer {
60038
60203
  __publicField(this, "_onUpdate");
60039
60204
  __publicField(this, "_isConnected");
60040
60205
  __publicField(this, "_animationFrame");
60041
- this._tracker = new StateTracker(defaultState);
60206
+ this._tracker = new VisibilityTracker(defaultState);
60042
60207
  this._rpc = rpc;
60043
60208
  this._onUpdate = onUpdate;
60044
60209
  this._getHandle = getHandle;
@@ -60087,7 +60252,7 @@ class StateSynchronizer {
60087
60252
  * @param elementIndex - The element index to update
60088
60253
  * @param state - The new state to apply
60089
60254
  */
60090
- setElementState(elementIndex, state) {
60255
+ setStateForElement(elementIndex, state) {
60091
60256
  this._tracker.setState(elementIndex, state);
60092
60257
  this.scheduleUpdate();
60093
60258
  }
@@ -60151,7 +60316,7 @@ class StateSynchronizer {
60151
60316
  this._onUpdate();
60152
60317
  }
60153
60318
  }
60154
- class StateTracker {
60319
+ class VisibilityTracker {
60155
60320
  /**
60156
60321
  * Creates a new StateTracker instance.
60157
60322
  *
@@ -60747,6 +60912,12 @@ class Viewport2 {
60747
60912
  this._rpc.RPCSetCameraAspectRatio(this.canvas.offsetWidth, this.canvas.offsetHeight);
60748
60913
  }
60749
60914
  }
60915
+ /**
60916
+ * Resizes the viewport to match its parent's dimensions
60917
+ */
60918
+ resizeToParent() {
60919
+ this.update();
60920
+ }
60750
60921
  /**
60751
60922
  * Cleans up resources by removing resize observer and clearing timeouts
60752
60923
  */
@@ -60788,7 +60959,7 @@ class Element3D2 {
60788
60959
  return this.vim.visibility.getElementState(this.element);
60789
60960
  }
60790
60961
  set state(state) {
60791
- this.vim.visibility.setElementState(this.element, state);
60962
+ this.vim.visibility.setStateForElement(this.element, state);
60792
60963
  }
60793
60964
  /**
60794
60965
  * Gets or sets the color override of the element.
@@ -60805,11 +60976,12 @@ class Element3D2 {
60805
60976
  * @returns A promise resolving to the element's bounding box.
60806
60977
  */
60807
60978
  async getBoundingBox() {
60808
- return this.vim.getBoundingBoxNodes([this.element]);
60979
+ return this.vim.getBoundingBoxForElements([this.element]);
60809
60980
  }
60810
60981
  }
60811
60982
  class Vim2 {
60812
60983
  constructor(rpc, color, renderer, source, logger) {
60984
+ __publicField(this, "type", "ultra");
60813
60985
  __publicField(this, "source");
60814
60986
  __publicField(this, "_handle", -1);
60815
60987
  __publicField(this, "_request");
@@ -60818,19 +60990,22 @@ class Vim2 {
60818
60990
  __publicField(this, "_renderer");
60819
60991
  __publicField(this, "_logger");
60820
60992
  // The StateSynchronizer wraps a StateTracker and handles RPC synchronization.
60993
+ // Should be private
60821
60994
  __publicField(this, "visibility");
60822
60995
  // Color tracking remains unchanged.
60823
- __publicField(this, "_nodeColors", /* @__PURE__ */ new Map());
60996
+ __publicField(this, "_elementColors", /* @__PURE__ */ new Map());
60824
60997
  __publicField(this, "_updatedColors", /* @__PURE__ */ new Set());
60998
+ __publicField(this, "_removedColors", /* @__PURE__ */ new Set());
60825
60999
  // Delayed update flag.
60826
61000
  __publicField(this, "_updateScheduled", false);
61001
+ __publicField(this, "_elementCount", 0);
60827
61002
  __publicField(this, "_objects", /* @__PURE__ */ new Map());
60828
61003
  this._rpc = rpc;
60829
61004
  this.source = source;
60830
61005
  this._colors = color;
60831
61006
  this._renderer = renderer;
60832
61007
  this._logger = logger;
60833
- this.visibility = new StateSynchronizer(
61008
+ this.visibility = new VisibilitySynchronizer(
60834
61009
  this._rpc,
60835
61010
  () => this._handle,
60836
61011
  () => this.connected,
@@ -60839,6 +61014,7 @@ class Vim2 {
60839
61014
  // default state
60840
61015
  );
60841
61016
  }
61017
+ //TODO: Rename this to getElementFromNode, prefer using element instead
60842
61018
  getElement(elementIndex) {
60843
61019
  if (this._objects.has(elementIndex)) {
60844
61020
  return this._objects.get(elementIndex);
@@ -60851,13 +61027,16 @@ class Vim2 {
60851
61027
  throw new Error("Method not implemented.");
60852
61028
  }
60853
61029
  getElementFromIndex(element) {
60854
- throw new Error("Method not implemented.");
61030
+ return this.getElement(element);
60855
61031
  }
60856
61032
  getObjectsInBox(box) {
60857
61033
  throw new Error("Method not implemented.");
60858
61034
  }
60859
61035
  getAllElements() {
60860
- throw new Error("Method not implemented.");
61036
+ for (var i = 0; i < this._elementCount; i++) {
61037
+ this.getElement(i);
61038
+ }
61039
+ return Array.from(this._objects.values());
60861
61040
  }
60862
61041
  get handle() {
60863
61042
  return this._handle;
@@ -60888,7 +61067,6 @@ class Vim2 {
60888
61067
  (_a3 = this._request) == null ? void 0 : _a3.error("cancelled", "The request was cancelled");
60889
61068
  this._request = void 0;
60890
61069
  if (this.connected) {
60891
- this._rpc.RPCUnloadVim(this._handle);
60892
61070
  this._handle = -1;
60893
61071
  }
60894
61072
  }
@@ -60910,12 +61088,12 @@ class Vim2 {
60910
61088
  case VimLoadingStatus.FailedToDownload:
60911
61089
  case VimLoadingStatus.FailedToLoad:
60912
61090
  case VimLoadingStatus.Unknown:
60913
- this._rpc.RPCUnloadVim(handle);
60914
61091
  const details = await this._rpc.RPCGetLastError();
60915
61092
  const error = this.getErrorType(state.status);
60916
61093
  return result.error(error, details);
60917
61094
  case VimLoadingStatus.Done:
60918
61095
  this._handle = handle;
61096
+ this._elementCount = await this._rpc.RPCGetElementCountForVim(handle);
60919
61097
  return result.success(this);
60920
61098
  }
60921
61099
  } catch (e) {
@@ -60955,14 +61133,14 @@ class Vim2 {
60955
61133
  }
60956
61134
  return handle;
60957
61135
  }
60958
- async getBoundingBoxNodes(nodes) {
60959
- if (!this.connected || nodes !== "all" && nodes.length === 0) {
61136
+ async getBoundingBoxForElements(elements) {
61137
+ if (!this.connected || elements !== "all" && elements.length === 0) {
60960
61138
  return Promise.resolve(void 0);
60961
61139
  }
60962
- if (nodes === "all") {
61140
+ if (elements === "all") {
60963
61141
  return await this._rpc.RPCGetAABBForVim(this._handle);
60964
61142
  }
60965
- return await this._rpc.RPCGetAABBForElements(this._handle, nodes);
61143
+ return await this._rpc.RPCGetAABBForElements(this._handle, elements);
60966
61144
  }
60967
61145
  async getBoundingBox() {
60968
61146
  if (!this.connected) {
@@ -60970,49 +61148,52 @@ class Vim2 {
60970
61148
  }
60971
61149
  return await this._rpc.RPCGetAABBForVim(this._handle);
60972
61150
  }
60973
- getColor(node) {
60974
- return this._nodeColors.get(node);
61151
+ getColor(elementIndex) {
61152
+ return this._elementColors.get(elementIndex);
60975
61153
  }
60976
- async setColor(nodes, color) {
60977
- const colors = new Array(nodes.length).fill(color);
60978
- this.applyColor(nodes, colors);
61154
+ async setColor(elementIndex, color) {
61155
+ const colors = new Array(elementIndex.length).fill(color);
61156
+ this.applyColor(elementIndex, colors);
60979
61157
  }
60980
- async setColors(nodes, color) {
60981
- if (color.length !== nodes.length) {
60982
- throw new Error("Color and nodes length must be equal");
61158
+ async setColors(elements, color) {
61159
+ if (color.length !== elements.length) {
61160
+ throw new Error("Color and elements length must be equal");
60983
61161
  }
60984
- this.applyColor(nodes, color);
61162
+ this.applyColor(elements, color);
60985
61163
  }
60986
- applyColor(nodes, color) {
60987
- for (let i = 0; i < color.length; i++) {
60988
- const c = color[i];
60989
- const n = nodes[i];
60990
- if (c === void 0) {
60991
- this._nodeColors.delete(n);
60992
- } else {
60993
- this._nodeColors.set(n, c);
61164
+ applyColor(elements, colors) {
61165
+ for (let i = 0; i < colors.length; i++) {
61166
+ const color = colors[i];
61167
+ const element = elements[i];
61168
+ const existingColor = this._elementColors.get(element);
61169
+ if (color === void 0 && existingColor !== void 0) {
61170
+ this._elementColors.delete(element);
61171
+ this._removedColors.add(element);
61172
+ } else if (color !== existingColor) {
61173
+ this._elementColors.set(element, color);
61174
+ this._updatedColors.add(element);
60994
61175
  }
60995
- this._updatedColors.add(n);
60996
61176
  }
60997
61177
  this.scheduleColorUpdate();
60998
61178
  }
60999
- clearColor(nodes) {
61000
- if (nodes === "all") {
61001
- this._nodeColors.clear();
61179
+ //TODO: Remove and rely on element.color
61180
+ clearColor(elements) {
61181
+ if (elements === "all") {
61182
+ this._elementColors.clear();
61002
61183
  } else {
61003
- nodes.forEach((n) => this._nodeColors.delete(n));
61184
+ elements.forEach((n) => this._elementColors.delete(n));
61004
61185
  }
61005
61186
  if (!this.connected) return;
61006
- if (nodes === "all") {
61007
- this._rpc.RPCClearMaterialOverrides(this._handle);
61187
+ if (elements === "all") {
61188
+ this._rpc.RPCClearMaterialOverridesForVim(this._handle);
61008
61189
  } else {
61009
- const ids = new Array(nodes.length).fill(MaterialHandles.Invalid);
61010
- this._rpc.RPCSetMaterialOverrides(this._handle, nodes, ids);
61190
+ this._rpc.RPCClearMaterialOverridesForElements(this._handle, elements);
61011
61191
  }
61012
61192
  }
61013
61193
  reapplyColors() {
61014
61194
  this._updatedColors.clear();
61015
- this._nodeColors.forEach((c, n) => this._updatedColors.add(n));
61195
+ this._removedColors.clear();
61196
+ this._elementColors.forEach((c, n) => this._updatedColors.add(n));
61016
61197
  this.scheduleColorUpdate();
61017
61198
  }
61018
61199
  scheduleColorUpdate() {
@@ -61028,12 +61209,15 @@ class Vim2 {
61028
61209
  this._renderer.notifySceneUpdated();
61029
61210
  }
61030
61211
  async updateRemoteColors() {
61031
- const nodes = Array.from(this._updatedColors);
61032
- const colors = nodes.map((n) => this._nodeColors.get(n));
61212
+ const updatedElement = Array.from(this._updatedColors);
61213
+ const removedElement = Array.from(this._removedColors);
61214
+ const colors = updatedElement.map((n) => this._elementColors.get(n));
61033
61215
  const remoteColors = await this._colors.getColors(colors);
61034
61216
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61035
- this._rpc.RPCSetMaterialOverrides(this._handle, nodes, colorIds);
61217
+ this._rpc.RPCClearMaterialOverridesForElements(this._handle, removedElement);
61218
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, updatedElement, colorIds);
61036
61219
  this._updatedColors.clear();
61220
+ this._removedColors.clear();
61037
61221
  }
61038
61222
  }
61039
61223
  function wait(ms) {
@@ -61110,6 +61294,11 @@ let Viewer$2 = class Viewer2 {
61110
61294
  * @param logger - Optional logger for logging messages.
61111
61295
  */
61112
61296
  constructor(canvas, logger) {
61297
+ /**
61298
+ * The type of the viewer, indicating it is a WebGL viewer.
61299
+ * Useful for distinguishing between different viewer types in a multi-viewer application.
61300
+ */
61301
+ __publicField(this, "type", "ultra");
61113
61302
  __publicField(this, "_decoder");
61114
61303
  __publicField(this, "_socketClient");
61115
61304
  __publicField(this, "_input");
@@ -61333,6 +61522,9 @@ let Viewer$2 = class Viewer2 {
61333
61522
  this._vims.getAll().forEach((vim) => vim.disconnect());
61334
61523
  this._vims.clear();
61335
61524
  }
61525
+ getElement3Ds() {
61526
+ return this.rpc.RPCGetElementCountForScene();
61527
+ }
61336
61528
  /**
61337
61529
  * Disposes all resources used by the viewer and disconnects from the server.
61338
61530
  */
@@ -61354,9 +61546,6 @@ const index$7 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
61354
61546
  INVALID_HANDLE,
61355
61547
  InputMode,
61356
61548
  MaterialHandles,
61357
- RGB,
61358
- RGBA,
61359
- RGBA32,
61360
61549
  Segment,
61361
61550
  Viewer: Viewer$2,
61362
61551
  VimLoadingStatus,
@@ -63536,50 +63725,6 @@ const icons = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
63536
63725
  visible,
63537
63726
  zoom
63538
63727
  }, Symbol.toStringTag, { value: "Module" }));
63539
- function getDefaultSettings() {
63540
- return {
63541
- capacity: {
63542
- canFollowUrl: true,
63543
- canGoFullScreen: true,
63544
- canDownload: true,
63545
- canReadLocalStorage: true
63546
- },
63547
- ui: {
63548
- logo: true,
63549
- performance: false,
63550
- bimTreePanel: true,
63551
- bimInfoPanel: true,
63552
- // axesPanel
63553
- axesPanel: true,
63554
- orthographic: true,
63555
- resetCamera: true,
63556
- // Control bar
63557
- controlBar: true,
63558
- // Control bar - cursors
63559
- orbit: true,
63560
- lookAround: true,
63561
- pan: true,
63562
- zoom: true,
63563
- zoomWindow: true,
63564
- // Control bar - camera
63565
- autoCamera: true,
63566
- frameScene: true,
63567
- frameSelection: true,
63568
- // Control bar - tools
63569
- sectioningMode: true,
63570
- measuringMode: true,
63571
- toggleIsolation: true,
63572
- // Control bar - settings
63573
- projectInspector: true,
63574
- settings: true,
63575
- help: true,
63576
- maximise: true
63577
- }
63578
- };
63579
- }
63580
- function createSettings(settings2) {
63581
- return settings2 !== void 0 ? deepmerge(getDefaultSettings(), settings2) : getDefaultSettings();
63582
- }
63583
63728
  function getLocalSettings(settings2 = {}) {
63584
63729
  try {
63585
63730
  const json = localStorage.getItem("viewer.settings");
@@ -63634,8 +63779,6 @@ function isFalse(value) {
63634
63779
  }
63635
63780
  const index$4 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
63636
63781
  __proto__: null,
63637
- createSettings,
63638
- getDefaultSettings,
63639
63782
  getLocalSettings,
63640
63783
  isFalse,
63641
63784
  isTrue,
@@ -67467,7 +67610,7 @@ function getMeasureState(viewer, cursor) {
67467
67610
  }
67468
67611
  const Style = style;
67469
67612
  const Ids$2 = controlBarIds;
67470
- function controlBarSectionBox(section, hasSelection) {
67613
+ function controlBarSectionBox(section, hasSelection, settings2) {
67471
67614
  return {
67472
67615
  id: Ids$2.sectionSectionBox,
67473
67616
  style: section.enable.get() ? Style.sectionNoPadStyle : Style.sectionDefaultStyle,
@@ -67475,6 +67618,7 @@ function controlBarSectionBox(section, hasSelection) {
67475
67618
  buttons: [
67476
67619
  {
67477
67620
  id: Ids$2.buttonSectionBoxEnable,
67621
+ enabled: () => isTrue(settings2.sectioningEnable),
67478
67622
  tip: "Enable Section Box",
67479
67623
  isOn: () => section.enable.get(),
67480
67624
  style: (on) => Style.buttonExpandStyle(on),
@@ -67484,7 +67628,7 @@ function controlBarSectionBox(section, hasSelection) {
67484
67628
  {
67485
67629
  id: Ids$2.buttonSectionBoxToSelection,
67486
67630
  tip: "Fit Section",
67487
- enabled: () => section.enable.get(),
67631
+ enabled: () => section.enable.get() && isTrue(settings2.sectioningFitToSelection),
67488
67632
  isOn: () => hasSelection,
67489
67633
  style: (on) => Style.buttonDisableStyle(on),
67490
67634
  action: () => section.sectionSelection.call(),
@@ -67493,7 +67637,7 @@ function controlBarSectionBox(section, hasSelection) {
67493
67637
  {
67494
67638
  id: Ids$2.buttonSectionBoxToScene,
67495
67639
  tip: "Reset Section",
67496
- enabled: () => section.enable.get(),
67640
+ enabled: () => section.enable.get() && isTrue(settings2.sectioningReset),
67497
67641
  style: (on) => Style.buttonDefaultStyle(on),
67498
67642
  action: () => section.sectionScene.call(),
67499
67643
  icon: sectionBoxReset
@@ -67501,7 +67645,7 @@ function controlBarSectionBox(section, hasSelection) {
67501
67645
  {
67502
67646
  id: Ids$2.buttonSectionBoxVisible,
67503
67647
  tip: "Show Section Box",
67504
- enabled: () => section.enable.get(),
67648
+ enabled: () => section.enable.get() && isTrue(settings2.sectioningShow),
67505
67649
  isOn: () => section.visible.get(),
67506
67650
  style: (on) => Style.buttonDefaultStyle(on),
67507
67651
  action: () => section.visible.set(!section.visible.get()),
@@ -67510,7 +67654,7 @@ function controlBarSectionBox(section, hasSelection) {
67510
67654
  {
67511
67655
  id: Ids$2.buttonSectionBoxAuto,
67512
67656
  tip: "Auto Section",
67513
- enabled: () => section.enable.get(),
67657
+ enabled: () => section.enable.get() && isTrue(settings2.sectioningAuto),
67514
67658
  isOn: () => section.auto.get(),
67515
67659
  style: (on) => Style.buttonDefaultStyle(on),
67516
67660
  action: () => section.auto.set(!section.auto.get()),
@@ -67519,7 +67663,7 @@ function controlBarSectionBox(section, hasSelection) {
67519
67663
  {
67520
67664
  id: Ids$2.buttonSectionBoxSettings,
67521
67665
  tip: "Section Settings",
67522
- enabled: () => section.enable.get(),
67666
+ enabled: () => section.enable.get() && isTrue(settings2.sectioningSettings),
67523
67667
  isOn: () => section.showOffsetPanel.get(),
67524
67668
  style: (on) => Style.buttonDefaultStyle(on),
67525
67669
  action: () => section.showOffsetPanel.set(!section.showOffsetPanel.get()),
@@ -67537,7 +67681,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67537
67681
  buttons: [
67538
67682
  {
67539
67683
  id: Ids$2.buttonCameraOrbit,
67540
- enabled: () => isTrue(settings2.ui.orbit),
67684
+ enabled: () => isTrue(settings2.cursorOrbit),
67541
67685
  tip: "Orbit",
67542
67686
  action: () => pointer2.onButton(PointerMode$1.ORBIT),
67543
67687
  icon: orbit,
@@ -67546,7 +67690,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67546
67690
  },
67547
67691
  {
67548
67692
  id: Ids$2.buttonCameraLook,
67549
- enabled: () => isTrue(settings2.ui.lookAround),
67693
+ enabled: () => isTrue(settings2.cursorLookAround),
67550
67694
  tip: "Look Around",
67551
67695
  action: () => pointer2.onButton(PointerMode$1.LOOK),
67552
67696
  icon: look,
@@ -67555,7 +67699,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67555
67699
  },
67556
67700
  {
67557
67701
  id: Ids$2.buttonCameraPan,
67558
- enabled: () => isTrue(settings2.ui.pan),
67702
+ enabled: () => isTrue(settings2.cursorPan),
67559
67703
  tip: "Pan",
67560
67704
  action: () => pointer2.onButton(PointerMode$1.PAN),
67561
67705
  icon: pan,
@@ -67564,7 +67708,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67564
67708
  },
67565
67709
  {
67566
67710
  id: Ids$2.buttonCameraZoom,
67567
- enabled: () => isTrue(settings2.ui.zoom),
67711
+ enabled: () => isTrue(settings2.cursorZoom),
67568
67712
  tip: "Zoom",
67569
67713
  action: () => pointer2.onButton(PointerMode$1.ZOOM),
67570
67714
  icon: zoom,
@@ -67574,7 +67718,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67574
67718
  ]
67575
67719
  };
67576
67720
  }
67577
- function controlBarMeasure(settings2, measure$1) {
67721
+ function controlBarMeasure(measure$1, settings2) {
67578
67722
  return {
67579
67723
  id: Ids$2.sectionActions,
67580
67724
  enable: () => true,
@@ -67582,7 +67726,7 @@ function controlBarMeasure(settings2, measure$1) {
67582
67726
  buttons: [
67583
67727
  {
67584
67728
  id: Ids$2.buttonMeasure,
67585
- enabled: () => isTrue(settings2.ui.measuringMode),
67729
+ enabled: () => isTrue(settings2.measureEnable),
67586
67730
  isOn: () => measure$1.active,
67587
67731
  tip: "Measuring Mode",
67588
67732
  action: () => measure$1.toggle(),
@@ -67592,6 +67736,23 @@ function controlBarMeasure(settings2, measure$1) {
67592
67736
  ]
67593
67737
  };
67594
67738
  }
67739
+ function controlBarSettingsUltra(side, settings$1) {
67740
+ return {
67741
+ id: Ids$2.sectionSettings,
67742
+ enable: () => isTrue(settings$1.ui.settings),
67743
+ style: Style.sectionDefaultStyle,
67744
+ buttons: [
67745
+ {
67746
+ id: Ids$2.buttonSettings,
67747
+ enabled: () => isTrue(settings$1.ui.settings),
67748
+ tip: "Settings",
67749
+ action: () => side.toggleContent("settings"),
67750
+ icon: settings,
67751
+ style: Style.buttonDefaultStyle
67752
+ }
67753
+ ]
67754
+ };
67755
+ }
67595
67756
  function controlBarSettings(modal, side, settings$1) {
67596
67757
  const fullScreen = getFullScreenState();
67597
67758
  return {
@@ -67601,7 +67762,7 @@ function controlBarSettings(modal, side, settings$1) {
67601
67762
  buttons: [
67602
67763
  {
67603
67764
  id: Ids$2.buttonProjectInspector,
67604
- enabled: () => isTrue(settings$1.ui.projectInspector) && (isTrue(settings$1.ui.bimTreePanel) || isTrue(settings$1.ui.bimInfoPanel)),
67765
+ enabled: () => isTrue(settings$1.ui.miscProjectInspector) && (isTrue(settings$1.ui.bimTreePanel) || isTrue(settings$1.ui.bimInfoPanel)),
67605
67766
  tip: "Project Inspector",
67606
67767
  action: () => side.toggleContent("bim"),
67607
67768
  icon: treeView,
@@ -67609,7 +67770,7 @@ function controlBarSettings(modal, side, settings$1) {
67609
67770
  },
67610
67771
  {
67611
67772
  id: Ids$2.buttonSettings,
67612
- enabled: () => isTrue(settings$1.ui.settings),
67773
+ enabled: () => isTrue(settings$1.ui.miscSettings),
67613
67774
  tip: "Settings",
67614
67775
  action: () => side.toggleContent("settings"),
67615
67776
  icon: settings,
@@ -67617,7 +67778,7 @@ function controlBarSettings(modal, side, settings$1) {
67617
67778
  },
67618
67779
  {
67619
67780
  id: Ids$2.buttonHelp,
67620
- enabled: () => isTrue(settings$1.ui.help),
67781
+ enabled: () => isTrue(settings$1.ui.miscHelp),
67621
67782
  tip: "Help",
67622
67783
  action: () => modal.help(true),
67623
67784
  icon: help,
@@ -67625,7 +67786,7 @@ function controlBarSettings(modal, side, settings$1) {
67625
67786
  },
67626
67787
  {
67627
67788
  id: Ids$2.buttonMaximize,
67628
- enabled: () => isTrue(settings$1.ui.maximise) && settings$1.capacity.canGoFullScreen,
67789
+ enabled: () => isTrue(settings$1.ui.miscMaximise) && settings$1.capacity.canGoFullScreen,
67629
67790
  tip: fullScreen.get() ? "Minimize" : "Fullscreen",
67630
67791
  action: () => fullScreen.toggle(),
67631
67792
  icon: fullScreen.get() ? minimize : fullsScreen,
@@ -67634,7 +67795,7 @@ function controlBarSettings(modal, side, settings$1) {
67634
67795
  ]
67635
67796
  };
67636
67797
  }
67637
- function controlBarCamera(camera2) {
67798
+ function controlBarCamera(camera2, settings2) {
67638
67799
  return {
67639
67800
  id: Ids$2.sectionCamera,
67640
67801
  enable: () => true,
@@ -67642,6 +67803,7 @@ function controlBarCamera(camera2) {
67642
67803
  buttons: [
67643
67804
  {
67644
67805
  id: Ids$2.buttonCameraAuto,
67806
+ enabled: () => isTrue(settings2.cameraAuto),
67645
67807
  tip: "Auto Camera",
67646
67808
  isOn: () => camera2.autoCamera.get(),
67647
67809
  action: () => camera2.autoCamera.set(!camera2.autoCamera.get()),
@@ -67650,7 +67812,7 @@ function controlBarCamera(camera2) {
67650
67812
  },
67651
67813
  {
67652
67814
  id: Ids$2.buttonCameraFrameSelection,
67653
- // enabled: () => isTrue(settings.ui.zoomToFit), TODO: Implement ui toggles in Ultra
67815
+ enabled: () => isTrue(settings2.cameraFrameSelection),
67654
67816
  tip: "Frame Selection",
67655
67817
  action: () => camera2.frameSelection.call(),
67656
67818
  icon: frameSelection,
@@ -67659,7 +67821,7 @@ function controlBarCamera(camera2) {
67659
67821
  },
67660
67822
  {
67661
67823
  id: Ids$2.buttonCameraFrameScene,
67662
- // enabled: () => isTrue(settings.ui.zoomToFit), TODO: Implement ui toggles in Ultra
67824
+ enabled: () => isTrue(settings2.cameraFrameScene),
67663
67825
  tip: "Frame All",
67664
67826
  action: () => camera2.frameScene.call(),
67665
67827
  icon: frameScene,
@@ -67669,7 +67831,7 @@ function controlBarCamera(camera2) {
67669
67831
  ]
67670
67832
  };
67671
67833
  }
67672
- function controlBarSelection(isolation) {
67834
+ function controlBarVisibility(isolation, settings2) {
67673
67835
  const adapter = isolation.adapter.current;
67674
67836
  const someVisible = adapter.hasVisibleSelection() || !adapter.hasHiddenSelection();
67675
67837
  return {
@@ -67679,6 +67841,7 @@ function controlBarSelection(isolation) {
67679
67841
  buttons: [
67680
67842
  {
67681
67843
  id: Ids$2.buttonClearSelection,
67844
+ enabled: () => isTrue(settings2.visibilityClearSelection),
67682
67845
  tip: "Clear Selection",
67683
67846
  action: () => adapter.clearSelection(),
67684
67847
  icon: pointer,
@@ -67688,6 +67851,7 @@ function controlBarSelection(isolation) {
67688
67851
  {
67689
67852
  id: Ids$2.buttonShowAll,
67690
67853
  tip: "Show All",
67854
+ enabled: () => isTrue(settings2.visibilityShowAll),
67691
67855
  action: () => adapter.showAll(),
67692
67856
  icon: showAll,
67693
67857
  isOn: () => !isolation.autoIsolate.get() && isolation.visibility.get() !== "all",
@@ -67695,7 +67859,7 @@ function controlBarSelection(isolation) {
67695
67859
  },
67696
67860
  {
67697
67861
  id: Ids$2.buttonHideSelection,
67698
- enabled: () => someVisible,
67862
+ enabled: () => someVisible && isTrue(settings2.visibilityToggle),
67699
67863
  tip: "Hide Selection",
67700
67864
  action: () => adapter.hideSelection(),
67701
67865
  icon: hideSelection,
@@ -67704,7 +67868,7 @@ function controlBarSelection(isolation) {
67704
67868
  },
67705
67869
  {
67706
67870
  id: Ids$2.buttonShowSelection,
67707
- enabled: () => !someVisible,
67871
+ enabled: () => !someVisible && isTrue(settings2.visibilityToggle),
67708
67872
  tip: "Show Selection",
67709
67873
  action: () => adapter.showSelection(),
67710
67874
  icon: showSelection,
@@ -67713,6 +67877,7 @@ function controlBarSelection(isolation) {
67713
67877
  },
67714
67878
  {
67715
67879
  id: Ids$2.buttonIsolateSelection,
67880
+ enabled: () => isTrue(settings2.visibilityIsolate),
67716
67881
  tip: "Isolate Selection",
67717
67882
  action: () => adapter.isolateSelection(),
67718
67883
  icon: isolateSelection,
@@ -67721,6 +67886,7 @@ function controlBarSelection(isolation) {
67721
67886
  },
67722
67887
  {
67723
67888
  id: Ids$2.buttonAutoIsolate,
67889
+ enabled: () => isTrue(settings2.visibilityAutoIsolate),
67724
67890
  tip: "Auto Isolate",
67725
67891
  action: () => isolation.autoIsolate.set(!isolation.autoIsolate.get()),
67726
67892
  isOn: () => isolation.autoIsolate.get(),
@@ -67728,6 +67894,7 @@ function controlBarSelection(isolation) {
67728
67894
  },
67729
67895
  {
67730
67896
  id: Ids$2.buttonIsolationSettings,
67897
+ enabled: () => isTrue(settings2.visibilitySettings),
67731
67898
  tip: "Isolation Settings",
67732
67899
  action: () => isolation.showPanel.set(!isolation.showPanel.get()),
67733
67900
  icon: slidersHoriz,
@@ -67738,28 +67905,22 @@ function controlBarSelection(isolation) {
67738
67905
  }
67739
67906
  function useControlBar(viewer, camera2, modal, side, cursor, settings2, section, isolationRef, customization) {
67740
67907
  const measure2 = getMeasureState(viewer, cursor);
67741
- const pointerSection = controlBarPointer(viewer, camera2, settings2);
67742
- const actionSection = controlBarMeasure(settings2, measure2);
67743
- const sectionBoxSection = controlBarSectionBox(section, viewer.selection.any());
67744
- const settingsSection = controlBarSettings(modal, side, settings2);
67745
- const cameraSection = controlBarCamera(camera2);
67746
- const selectionSection = controlBarSelection(isolationRef);
67747
67908
  let controlBarSections = [
67748
- pointerSection,
67749
- actionSection,
67750
- cameraSection,
67751
- sectionBoxSection,
67752
- selectionSection,
67753
- settingsSection
67909
+ controlBarPointer(viewer, camera2, settings2.ui),
67910
+ controlBarCamera(camera2, settings2.ui),
67911
+ controlBarVisibility(isolationRef, settings2.ui),
67912
+ controlBarMeasure(measure2, settings2.ui),
67913
+ controlBarSectionBox(section, viewer.selection.any(), settings2.ui),
67914
+ controlBarSettings(modal, side, settings2)
67754
67915
  ];
67755
67916
  controlBarSections = (customization == null ? void 0 : customization(controlBarSections)) ?? controlBarSections;
67756
67917
  return controlBarSections;
67757
67918
  }
67758
67919
  function anyUiCursorButton(settings2) {
67759
- return isTrue(settings2.ui.orbit) || isTrue(settings2.ui.lookAround) || isTrue(settings2.ui.pan) || isTrue(settings2.ui.zoom) || isTrue(settings2.ui.zoomWindow);
67920
+ return isTrue(settings2.cursorOrbit) || isTrue(settings2.cursorLookAround) || isTrue(settings2.cursorPan) || isTrue(settings2.cursorZoom);
67760
67921
  }
67761
67922
  function anyUiSettingButton(settings2) {
67762
- return isTrue(settings2.ui.projectInspector) || isTrue(settings2.ui.settings) || isTrue(settings2.ui.help) || isTrue(settings2.ui.maximise);
67923
+ return isTrue(settings2.ui.miscProjectInspector) || isTrue(settings2.ui.miscSettings) || isTrue(settings2.ui.miscHelp) || isTrue(settings2.ui.miscMaximise);
67763
67924
  }
67764
67925
  function RestOfScreen(props) {
67765
67926
  const [, setVersion] = useState(0);
@@ -72660,7 +72821,7 @@ function scrollToSelection(div) {
72660
72821
  return;
72661
72822
  }
72662
72823
  if (rectElem.top < rectContainer.top || rectElem.top < 0) {
72663
- selection.scrollIntoView();
72824
+ selection.scrollIntoView({ block: "nearest", inline: "nearest" });
72664
72825
  }
72665
72826
  }
72666
72827
  const isControlKey = (e) => {
@@ -73771,7 +73932,7 @@ function SidePanel(props) {
73771
73932
  } else {
73772
73933
  props.container.gfx.style.left = "0px";
73773
73934
  }
73774
- props.viewer.viewport.ResizeToParent();
73935
+ props.viewer.viewport.resizeToParent();
73775
73936
  };
73776
73937
  const getMaxSize = () => {
73777
73938
  return props.container.root.clientWidth * MAX_WIDTH;
@@ -73830,7 +73991,10 @@ function SidePanel(props) {
73830
73991
  style: {
73831
73992
  position: "absolute"
73832
73993
  },
73833
- className: `vim-side-panel vc-top-0 vc-left-0 vc-z-20 vc-bg-gray-lightest vc-text-gray-darker ${props.side.getContent() !== "none" ? "" : "vc-hidden"}`,
73994
+ className: `vim-side-panel vc-top-0 vc-left-0 vc-z-20
73995
+ vc-bg-gray-lightest vc-text-gray-darker
73996
+ vc-border-r vc-border-gray-light
73997
+ ${props.side.getContent() !== "none" ? "" : "vc-hidden"}`,
73834
73998
  children: [
73835
73999
  /* @__PURE__ */ jsxRuntimeExports.jsx(
73836
74000
  "button",
@@ -73913,180 +74077,6 @@ function useSideState(useInspector, defaultWidth) {
73913
74077
  [side, width]
73914
74078
  );
73915
74079
  }
73916
- function SettingsPanel(props) {
73917
- if (!props.visible) return null;
73918
- const toggleElement = (label, state, action) => {
73919
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "vc-m-1 vc-block vc-select-none vc-items-center vc-py-1 vc-text-gray-warm", children: [
73920
- /* @__PURE__ */ jsxRuntimeExports.jsx(
73921
- "input",
73922
- {
73923
- type: "checkbox",
73924
- checked: state,
73925
- onChange: action,
73926
- className: "vim-settings-checkbox vc-checked:bg-primary-royal vc-mr-2 vc-rounded vc-border vc-border-gray-medium "
73927
- }
73928
- ),
73929
- " ",
73930
- label
73931
- ] });
73932
- };
73933
- const settingsToggle = (label, getter, setter) => {
73934
- const value = getter(props.settings.value);
73935
- if (value === "AlwaysTrue" || value === "AlwaysFalse") {
73936
- return null;
73937
- }
73938
- return toggleElement(label, value, () => {
73939
- const value2 = getter(props.settings.value);
73940
- props.settings.update((s) => setter(s, !value2));
73941
- });
73942
- };
73943
- const settingsBox = (label, info, transform, getter, setter) => {
73944
- const ref = React__default.useRef(null);
73945
- useEffect(() => {
73946
- ref.current.value = props.viewer.inputs.scrollSpeed.toFixed(2);
73947
- }, []);
73948
- getter(props.settings.value).toString();
73949
- const update = (event) => {
73950
- const str = event.target.value;
73951
- const n = Number.parseFloat(str);
73952
- if (Number.isNaN(n)) {
73953
- event.target.value = getter(props.settings.value).toString();
73954
- } else {
73955
- const value2 = transform(n);
73956
- event.target.value = value2.toString();
73957
- props.settings.update((s) => setter(s, value2));
73958
- }
73959
- };
73960
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-box-input vc-my-1", children: [
73961
- /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "textbox", className: "vc-w-3 vc-h-2", children: [
73962
- label,
73963
- ":"
73964
- ] }),
73965
- /* @__PURE__ */ jsxRuntimeExports.jsx("input", { ref, type: "text", className: "vim-settings-textbox vc-w-14 vc-ml-1 vc-p-1", onBlur: (e) => update(e) }),
73966
- /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "textbox", className: "vc-w-3 vc-h-2 vc-text-gray vc-ml-1", children: info })
73967
- ] });
73968
- };
73969
- function settingsSubtitle(title2) {
73970
- return /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "vc-subtitle", children: title2 });
73971
- }
73972
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
73973
- "div",
73974
- {
73975
- className: "vc-absolute vc-inset-0",
73976
- children: [
73977
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "vc-title", children: "Settings " }),
73978
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vim-settings vc-absolute vc-top-6 vc-left-0 vc-bottom-0 vc-right-0 vc-overflow-y-auto", children: [
73979
- settingsSubtitle("Inputs"),
73980
- settingsBox(
73981
- "Scroll Speed",
73982
- "[0.1,10]",
73983
- (n) => MathUtils.clamp(n, 0.1, 10),
73984
- (s) => props.viewer.inputs.scrollSpeed,
73985
- (s, v) => {
73986
- props.viewer.inputs.scrollSpeed = v;
73987
- }
73988
- ),
73989
- settingsSubtitle("Panels"),
73990
- settingsToggle(
73991
- "Show Logo",
73992
- (settings2) => settings2.ui.logo,
73993
- (settings2, value) => settings2.ui.logo = value
73994
- ),
73995
- settingsToggle(
73996
- "Show Bim Tree",
73997
- (settings2) => settings2.ui.bimTreePanel,
73998
- (settings2, value) => settings2.ui.bimTreePanel = value
73999
- ),
74000
- settingsToggle(
74001
- "Show Bim Info",
74002
- (settings2) => settings2.ui.bimInfoPanel,
74003
- (settings2, value) => settings2.ui.bimInfoPanel = value
74004
- ),
74005
- settingsToggle(
74006
- "Show Axes Panel",
74007
- (settings2) => settings2.ui.axesPanel,
74008
- (settings2, value) => settings2.ui.axesPanel = value
74009
- ),
74010
- settingsToggle(
74011
- "Show Performance Panel",
74012
- (settings2) => settings2.ui.performance,
74013
- (settings2, value) => settings2.ui.performance = value
74014
- ),
74015
- settingsSubtitle("Axes"),
74016
- settingsToggle(
74017
- "Show Orthographic Button",
74018
- (settings2) => settings2.ui.orthographic,
74019
- (settings2, value) => settings2.ui.orthographic = value
74020
- ),
74021
- settingsToggle(
74022
- "Show Reset Camera Button",
74023
- (settings2) => settings2.ui.resetCamera,
74024
- (settings2, value) => settings2.ui.resetCamera = value
74025
- ),
74026
- settingsSubtitle("Control Bar"),
74027
- settingsToggle(
74028
- "Show Control Bar",
74029
- (settings2) => settings2.ui.controlBar,
74030
- (settings2, value) => settings2.ui.controlBar = value
74031
- ),
74032
- settingsSubtitle("Control Bar - Cursors"),
74033
- settingsToggle(
74034
- "Show Orbit Button",
74035
- (settings2) => settings2.ui.orbit,
74036
- (settings2, value) => settings2.ui.orbit = value
74037
- ),
74038
- settingsToggle(
74039
- "Show Look Around Button",
74040
- (settings2) => settings2.ui.lookAround,
74041
- (settings2, value) => settings2.ui.lookAround = value
74042
- ),
74043
- settingsToggle(
74044
- "Show Pan Button",
74045
- (settings2) => settings2.ui.pan,
74046
- (settings2, value) => settings2.ui.pan = value
74047
- ),
74048
- settingsToggle(
74049
- "Show Zoom Button",
74050
- (settings2) => settings2.ui.zoom,
74051
- (settings2, value) => settings2.ui.zoom = value
74052
- ),
74053
- settingsToggle(
74054
- "Show Zoom Window Button",
74055
- (settings2) => settings2.ui.zoomWindow,
74056
- (settings2, value) => settings2.ui.zoomWindow = value
74057
- ),
74058
- settingsSubtitle("Control Bar - Tools"),
74059
- settingsToggle(
74060
- "Show Measuring Mode Button",
74061
- (settings2) => settings2.ui.measuringMode,
74062
- (settings2, value) => settings2.ui.measuringMode = value
74063
- ),
74064
- settingsSubtitle("Control Bar - Settings"),
74065
- settingsToggle(
74066
- "Show Project Inspector Button",
74067
- (settings2) => settings2.ui.projectInspector,
74068
- (settings2, value) => settings2.ui.projectInspector = value
74069
- ),
74070
- settingsToggle(
74071
- "Show Settings Button",
74072
- (settings2) => settings2.ui.settings,
74073
- (settings2, value) => settings2.ui.settings = value
74074
- ),
74075
- settingsToggle(
74076
- "Show Help Button",
74077
- (settings2) => settings2.ui.help,
74078
- (settings2, value) => settings2.ui.help = value
74079
- ),
74080
- settingsToggle(
74081
- "Show Maximise Button",
74082
- (settings2) => settings2.ui.maximise,
74083
- (settings2, value) => settings2.ui.maximise = value
74084
- )
74085
- ] })
74086
- ]
74087
- }
74088
- );
74089
- }
74090
74080
  const MenuToastMemo = React__default.memo(MenuToast);
74091
74081
  function MenuToast(props) {
74092
74082
  const [visible2, setVisible] = useState();
@@ -74251,118 +74241,6 @@ function applyWebglBindings(viewer, camera2, isolation, sideState) {
74251
74241
  }
74252
74242
  });
74253
74243
  }
74254
- function useSettings(viewer, value) {
74255
- const merged = createSettings(value);
74256
- const [settings2, setSettings] = useState(merged);
74257
- const onUpdate = useRef();
74258
- const update = function(updater) {
74259
- var _a3;
74260
- const next = { ...settings2 };
74261
- updater(next);
74262
- saveSettingsToLocal(next);
74263
- setSettings(next);
74264
- (_a3 = onUpdate.current) == null ? void 0 : _a3.call(onUpdate, next);
74265
- };
74266
- useEffect(() => {
74267
- applySettings(viewer, settings2);
74268
- }, []);
74269
- useEffect(() => {
74270
- applySettings(viewer, settings2);
74271
- }, [settings2]);
74272
- return useMemo(
74273
- () => ({
74274
- value: settings2,
74275
- update,
74276
- register: (v) => onUpdate.current = v
74277
- }),
74278
- [settings2]
74279
- );
74280
- }
74281
- function applySettings(viewer, settings2) {
74282
- const performance2 = document.getElementsByClassName("vim-performance-div")[0];
74283
- if (performance2) {
74284
- if (isTrue(settings2.ui.performance)) {
74285
- performance2.classList.remove("vc-hidden");
74286
- } else {
74287
- performance2.classList.add("vc-hidden");
74288
- }
74289
- }
74290
- }
74291
- function createContainer(element) {
74292
- let root = element;
74293
- if (root === void 0) {
74294
- root = document.createElement("div");
74295
- document.body.append(root);
74296
- root.classList.add("vc-inset-0");
74297
- }
74298
- root.style.position = "absolute";
74299
- root.classList.add("vim-component");
74300
- const gfx = document.createElement("div");
74301
- gfx.className = "vim-gfx vc-absolute vc-inset-0 vc-pointer-events-none";
74302
- const ui = document.createElement("div");
74303
- ui.className = "vim-ui vc-absolute vc-inset-0";
74304
- root.append(gfx);
74305
- root.append(ui);
74306
- const dispose = () => {
74307
- if (element === void 0) {
74308
- root.remove();
74309
- } else {
74310
- root.classList.remove("vim-component");
74311
- gfx.remove();
74312
- ui.remove();
74313
- }
74314
- };
74315
- return { root, ui, gfx, dispose };
74316
- }
74317
- async function getElements(vim) {
74318
- var _a3, _b2, _c, _d, _e;
74319
- if (!vim.bim) return [];
74320
- const [elements, bimDocument, category, levels, worksets] = await Promise.all(
74321
- [
74322
- (_a3 = vim.bim.element) == null ? void 0 : _a3.getAll(),
74323
- (_b2 = vim.bim.bimDocument) == null ? void 0 : _b2.getAllTitle(),
74324
- (_c = vim.bim.category) == null ? void 0 : _c.getAllName(),
74325
- (_d = vim.bim.level) == null ? void 0 : _d.getAllElementIndex(),
74326
- (_e = vim.bim.workset) == null ? void 0 : _e.getAllName()
74327
- ]
74328
- );
74329
- const familyTypeMap = await getFamilyTypeNameMap(vim.bim);
74330
- if (!elements) return void 0;
74331
- const result = elements.map((e) => {
74332
- var _a4;
74333
- return {
74334
- ...e,
74335
- bimDocumentName: bimDocument ? bimDocument[e.bimDocumentIndex] : void 0,
74336
- categoryName: category ? category[e.categoryIndex] : void 0,
74337
- familyTypeName: familyTypeMap.get(e.index),
74338
- levelName: levels ? (_a4 = elements[levels[(e == null ? void 0 : e.levelIndex) ?? -1]]) == null ? void 0 : _a4.name : void 0,
74339
- worksetName: worksets ? worksets[(e == null ? void 0 : e.worksetIndex) ?? -1] : void 0
74340
- };
74341
- });
74342
- const real = result.filter((e) => vim.getElementFromIndex(e.index).hasMesh);
74343
- return real;
74344
- }
74345
- async function getFamilyTypeNameMap(document2) {
74346
- const [
74347
- familyInstanceElement,
74348
- familyInstanceFamilyType,
74349
- familyTypeElement,
74350
- elementName
74351
- ] = await Promise.all([
74352
- document2.familyInstance.getAllElementIndex(),
74353
- document2.familyInstance.getAllFamilyTypeIndex(),
74354
- document2.familyType.getAllElementIndex(),
74355
- document2.element.getAllName()
74356
- ]);
74357
- return new Map(
74358
- familyInstanceElement.map((e, i) => {
74359
- const familyType = familyInstanceFamilyType == null ? void 0 : familyInstanceFamilyType[i];
74360
- const element = Number.isInteger(familyType) ? familyTypeElement[familyType] : void 0;
74361
- const name = Number.isInteger(element) ? elementName == null ? void 0 : elementName[element] : void 0;
74362
- return [e, name];
74363
- })
74364
- );
74365
- }
74366
74244
  class MutableState {
74367
74245
  constructor(initial) {
74368
74246
  __publicField(this, "_value");
@@ -74391,24 +74269,28 @@ function useRefresher() {
74391
74269
  }
74392
74270
  };
74393
74271
  }
74394
- function useStateRef(initialValue) {
74395
- const [value, setValue] = useState(initialValue);
74272
+ function useStateRef(initialValue, isLazy = false) {
74273
+ const getInitialValue = () => {
74274
+ if (isLazy && typeof initialValue === "function") {
74275
+ return initialValue();
74276
+ }
74277
+ return initialValue;
74278
+ };
74279
+ const [box, setBox] = useState(() => ({
74280
+ current: getInitialValue()
74281
+ }));
74396
74282
  const ref = useRef(void 0);
74397
74283
  if (ref.current === void 0) {
74398
- if (typeof initialValue === "function") {
74399
- ref.current = initialValue();
74400
- } else {
74401
- ref.current = initialValue;
74402
- }
74284
+ ref.current = getInitialValue();
74403
74285
  }
74404
74286
  const event = useRef(new distExports.SimpleEventDispatcher());
74405
74287
  const validate = useRef((next, current) => next);
74406
- const confirm = useRef((value2) => value2);
74407
- const set3 = (value2) => {
74408
- const finalValue = validate.current(value2, ref.current);
74288
+ const confirm = useRef((value) => value);
74289
+ const set3 = (value) => {
74290
+ const finalValue = validate.current(value, ref.current);
74409
74291
  if (finalValue === ref.current) return;
74410
74292
  ref.current = finalValue;
74411
- setValue(finalValue);
74293
+ setBox({ current: finalValue });
74412
74294
  event.current.dispatch(finalValue);
74413
74295
  };
74414
74296
  return {
@@ -74434,8 +74316,8 @@ function useStateRef(initialValue) {
74434
74316
  */
74435
74317
  useOnChange(on) {
74436
74318
  useEffect(() => {
74437
- return event.current.subscribe((value2) => {
74438
- const result = on(value2);
74319
+ return event.current.subscribe((value) => {
74320
+ const result = on(value);
74439
74321
  if (result instanceof Promise) {
74440
74322
  result.catch(console.error);
74441
74323
  }
@@ -74449,7 +74331,7 @@ function useStateRef(initialValue) {
74449
74331
  * @returns The memoized value.
74450
74332
  */
74451
74333
  useMemo(on, deps) {
74452
- return useMemo(() => on(value), [...deps || [], value]);
74334
+ return useMemo(() => on(box.current), [...deps || [], box.current]);
74453
74335
  },
74454
74336
  /**
74455
74337
  * Sets a validation function to process any new state value before updating.
@@ -74626,14 +74508,122 @@ const reactUtils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
74626
74508
  useRefresher,
74627
74509
  useStateRef
74628
74510
  }, Symbol.toStringTag, { value: "Module" }));
74629
- function useViewerState(viewer) {
74630
- const getVim = () => {
74511
+ function useSettings(value, defaultSettings, applySettings = () => {
74512
+ }) {
74513
+ const merged = createSettings(value, defaultSettings);
74514
+ const [settings2, setSettings] = useState(merged);
74515
+ const onUpdate = useRef();
74516
+ const customizer = useStateRef((settings22) => settings22);
74517
+ const update = function(updater) {
74631
74518
  var _a3;
74632
- const v = (_a3 = viewer.vims) == null ? void 0 : _a3[0];
74633
- return v;
74634
- };
74635
- const getSelection = () => {
74636
- return [...viewer.selection.getAll()].filter((o) => o.type === "Element3D");
74519
+ const next = { ...settings2 };
74520
+ updater(next);
74521
+ saveSettingsToLocal(next);
74522
+ setSettings(next);
74523
+ (_a3 = onUpdate.current) == null ? void 0 : _a3.call(onUpdate, next);
74524
+ };
74525
+ useEffect(() => {
74526
+ applySettings(settings2);
74527
+ }, []);
74528
+ useEffect(() => {
74529
+ applySettings(settings2);
74530
+ }, [settings2]);
74531
+ return useMemo(
74532
+ () => ({
74533
+ value: settings2,
74534
+ update,
74535
+ register: (v) => onUpdate.current = v,
74536
+ customizer
74537
+ }),
74538
+ [settings2]
74539
+ );
74540
+ }
74541
+ function createSettings(settings2, defaultSettings) {
74542
+ return settings2 !== void 0 ? deepmerge(defaultSettings, settings2) : defaultSettings;
74543
+ }
74544
+ function createContainer(element) {
74545
+ let root = element;
74546
+ if (root === void 0) {
74547
+ root = document.createElement("div");
74548
+ document.body.append(root);
74549
+ root.classList.add("vc-inset-0");
74550
+ }
74551
+ root.style.position = "absolute";
74552
+ root.classList.add("vim-component");
74553
+ const gfx = document.createElement("div");
74554
+ gfx.className = "vim-gfx vc-absolute vc-inset-0 vc-pointer-events-none";
74555
+ const ui = document.createElement("div");
74556
+ ui.className = "vim-ui vc-absolute vc-inset-0";
74557
+ root.append(gfx);
74558
+ root.append(ui);
74559
+ const dispose = () => {
74560
+ if (element === void 0) {
74561
+ root.remove();
74562
+ } else {
74563
+ root.classList.remove("vim-component");
74564
+ gfx.remove();
74565
+ ui.remove();
74566
+ }
74567
+ };
74568
+ return { root, ui, gfx, dispose };
74569
+ }
74570
+ async function getElements(vim) {
74571
+ var _a3, _b2, _c, _d, _e;
74572
+ if (!vim.bim) return [];
74573
+ const [elements, bimDocument, category, levels, worksets] = await Promise.all(
74574
+ [
74575
+ (_a3 = vim.bim.element) == null ? void 0 : _a3.getAll(),
74576
+ (_b2 = vim.bim.bimDocument) == null ? void 0 : _b2.getAllTitle(),
74577
+ (_c = vim.bim.category) == null ? void 0 : _c.getAllName(),
74578
+ (_d = vim.bim.level) == null ? void 0 : _d.getAllElementIndex(),
74579
+ (_e = vim.bim.workset) == null ? void 0 : _e.getAllName()
74580
+ ]
74581
+ );
74582
+ const familyTypeMap = await getFamilyTypeNameMap(vim.bim);
74583
+ if (!elements) return void 0;
74584
+ const result = elements.map((e) => {
74585
+ var _a4;
74586
+ return {
74587
+ ...e,
74588
+ bimDocumentName: bimDocument ? bimDocument[e.bimDocumentIndex] : void 0,
74589
+ categoryName: category ? category[e.categoryIndex] : void 0,
74590
+ familyTypeName: familyTypeMap.get(e.index),
74591
+ levelName: levels ? (_a4 = elements[levels[(e == null ? void 0 : e.levelIndex) ?? -1]]) == null ? void 0 : _a4.name : void 0,
74592
+ worksetName: worksets ? worksets[(e == null ? void 0 : e.worksetIndex) ?? -1] : void 0
74593
+ };
74594
+ });
74595
+ const real = result.filter((e) => vim.getElementFromIndex(e.index).hasMesh);
74596
+ return real;
74597
+ }
74598
+ async function getFamilyTypeNameMap(document2) {
74599
+ const [
74600
+ familyInstanceElement,
74601
+ familyInstanceFamilyType,
74602
+ familyTypeElement,
74603
+ elementName
74604
+ ] = await Promise.all([
74605
+ document2.familyInstance.getAllElementIndex(),
74606
+ document2.familyInstance.getAllFamilyTypeIndex(),
74607
+ document2.familyType.getAllElementIndex(),
74608
+ document2.element.getAllName()
74609
+ ]);
74610
+ return new Map(
74611
+ familyInstanceElement.map((e, i) => {
74612
+ const familyType = familyInstanceFamilyType == null ? void 0 : familyInstanceFamilyType[i];
74613
+ const element = Number.isInteger(familyType) ? familyTypeElement[familyType] : void 0;
74614
+ const name = Number.isInteger(element) ? elementName == null ? void 0 : elementName[element] : void 0;
74615
+ return [e, name];
74616
+ })
74617
+ );
74618
+ }
74619
+ function useViewerState(viewer) {
74620
+ const getVim = () => {
74621
+ var _a3;
74622
+ const v = (_a3 = viewer.vims) == null ? void 0 : _a3[0];
74623
+ return v;
74624
+ };
74625
+ const getSelection = () => {
74626
+ return [...viewer.selection.getAll()].filter((o) => o.type === "Element3D");
74637
74627
  };
74638
74628
  const vim = useStateRef(getVim());
74639
74629
  const selection = useStateRef(getSelection());
@@ -74767,12 +74757,8 @@ const vcColorLink = "vc-text-[#0590CC]";
74767
74757
  const vcLink = `${vcColorLink} vc-underline`;
74768
74758
  const vcLabel = "vc-text-[#3F444F]";
74769
74759
  const vcRoboto = "vc-font-['Roboto',sans-serif]";
74770
- function footer$1(url) {
74771
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: `vc-text-xs vc-font-normal ${vcColorSecondary}`, children: [
74772
- "More troubleshooting tips can be found",
74773
- " ",
74774
- link(url, "here")
74775
- ] });
74760
+ function footer$1() {
74761
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, {});
74776
74762
  }
74777
74763
  function mainText(text) {
74778
74764
  return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `vim-main-text vc-text-base ${vcColorPrimary} vc-mb-4 vc-font-normal`, children: text });
@@ -74820,20 +74806,11 @@ const errorStyle = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
74820
74806
  vcLink,
74821
74807
  vcRoboto
74822
74808
  }, Symbol.toStringTag, { value: "Module" }));
74823
- const support = "https://docs.vimaec.com";
74824
- const supportUltra = "https://docs.vimaec.com/docs/vim-for-windows/configuring-vim-ultra";
74825
- const supportControls = "https://docs.vimaec.com/docs/vim-cloud/webgl-navigation-and-controls-guide";
74826
- const urls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
74827
- __proto__: null,
74828
- support,
74829
- supportControls,
74830
- supportUltra
74831
- }, Symbol.toStringTag, { value: "Module" }));
74832
74809
  function fileOpeningError(url) {
74833
74810
  return {
74834
74811
  title: "File Opening Error",
74835
74812
  body: serverFileOpeningErrorBody(url),
74836
- footer: footer$1(support),
74813
+ footer: footer$1(),
74837
74814
  canClose: false
74838
74815
  };
74839
74816
  }
@@ -74855,7 +74832,7 @@ function serverFileDownloadingError(url, authToken, server) {
74855
74832
  return {
74856
74833
  title: "File Downloading Error",
74857
74834
  body: body$5(url, authToken, server),
74858
- footer: footer$1(support),
74835
+ footer: footer$1(),
74859
74836
  canClose: false
74860
74837
  };
74861
74838
  }
@@ -74884,7 +74861,7 @@ function serverFileLoadingError(url) {
74884
74861
  return {
74885
74862
  title: "File Loading Error",
74886
74863
  body: body$4(url),
74887
- footer: footer$1(support),
74864
+ footer: footer$1(),
74888
74865
  canClose: false
74889
74866
  };
74890
74867
  }
@@ -74904,11 +74881,18 @@ function body$4(url) {
74904
74881
  ])
74905
74882
  ] });
74906
74883
  }
74884
+ const supportUltra = "https://docs.vimaec.com/docs/vim-for-windows/configuring-vim-ultra";
74885
+ const supportControls = "https://docs.vimaec.com/docs/vim-cloud/webgl-navigation-and-controls-guide";
74886
+ const urls = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
74887
+ __proto__: null,
74888
+ supportControls,
74889
+ supportUltra
74890
+ }, Symbol.toStringTag, { value: "Module" }));
74907
74891
  function serverConnectionError(url) {
74908
74892
  return {
74909
74893
  title: "Connection Error",
74910
74894
  body: body$3(url, isLocalUrl(url)),
74911
- footer: footer$1(support),
74895
+ footer: footer$1(),
74912
74896
  canClose: false
74913
74897
  };
74914
74898
  }
@@ -74938,7 +74922,7 @@ function serverCompatibilityError(url, localVersion, remoteVersion) {
74938
74922
  return {
74939
74923
  title: "Compatibility Error",
74940
74924
  body: body$2(url, localVersion, remoteVersion),
74941
- footer: footer$1(support),
74925
+ footer: footer$1(),
74942
74926
  canClose: false
74943
74927
  };
74944
74928
  }
@@ -74967,7 +74951,7 @@ function serverStreamError(url) {
74967
74951
  return {
74968
74952
  title: "Stream Error",
74969
74953
  body: body$1(),
74970
- footer: footer$1(support),
74954
+ footer: footer$1(),
74971
74955
  canClose: false
74972
74956
  };
74973
74957
  }
@@ -75214,16 +75198,19 @@ class ComponentLoader {
75214
75198
  }
75215
75199
  }
75216
75200
  function MessageBox(props) {
75201
+ const [minimized, setMinimized] = React__default.useState(props.value.minimize ?? false);
75217
75202
  const p = props.value;
75218
75203
  if (!p.title || !p.body) return null;
75219
75204
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vim-message-box vc-p-6 vc-max-h-[80%] vc-max-w-[80%] vc-w-[424px] vc-bg-white vc-rounded-md vc-shadow-message vc-shadow-[0px_4px_16px_rgba(33,39,51,0.5)] vc-font-roboto", children: [
75220
75205
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-flex vc-justify-between vc-items-center", children: [
75206
+ props.value.icon,
75221
75207
  title(p.title),
75222
- closeBtn(p.onClose)
75208
+ props.value.canClose && closeBtn(p.onClose),
75209
+ props.value.minimize && minimizeButton(minimized, setMinimized)
75223
75210
  ] }),
75224
- divider(),
75225
- body(p.body),
75226
- footer(p.footer)
75211
+ !minimized && divider(),
75212
+ !minimized && body(p.body),
75213
+ !minimized && footer(p.footer)
75227
75214
  ] });
75228
75215
  }
75229
75216
  function title(title2) {
@@ -75233,6 +75220,9 @@ function closeBtn(onClose) {
75233
75220
  if (!onClose) return null;
75234
75221
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: onClose, className: "vc-text-[#212733] vc-text-xl", children: "×" });
75235
75222
  }
75223
+ function minimizeButton(minimized, setMinimized) {
75224
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => setMinimized(!minimized), className: "vc-text-[#212733] vc-text-xl", children: minimized ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "▼" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "▲" }) });
75225
+ }
75236
75226
  function body(content2) {
75237
75227
  if (content2 === void 0) return null;
75238
75228
  if (typeof content2 === "string") {
@@ -75738,7 +75728,8 @@ function useViewerInput(handler, camera2) {
75738
75728
  }
75739
75729
  const Ids = {
75740
75730
  showGhost: "isolationPanel.showGhost",
75741
- ghostOpacity: "isolationPanel.ghostOpacity"
75731
+ ghostOpacity: "isolationPanel.ghostOpacity",
75732
+ transparency: "isolationPanel.transparency"
75742
75733
  };
75743
75734
  const IsolationPanel$1 = forwardRef(
75744
75735
  (props, ref) => {
@@ -75750,8 +75741,20 @@ const IsolationPanel$1 = forwardRef(
75750
75741
  anchorElement: document.getElementById("vim-control-bar"),
75751
75742
  showPanel: props.state.showPanel,
75752
75743
  entries: [
75753
- { type: "bool", id: Ids.showGhost, label: "Show Ghost", state: props.state.showGhost },
75754
- // { type: "bool", id: "showRooms", label: "Show Rooms", state: props.state.showRooms },
75744
+ {
75745
+ type: "bool",
75746
+ id: Ids.showGhost,
75747
+ label: "Show Ghost",
75748
+ state: props.state.showGhost
75749
+ },
75750
+ /*
75751
+ {
75752
+ type: "bool",
75753
+ id: "showRooms",
75754
+ label: "Show Rooms",
75755
+ state: props.state.showRooms
75756
+ },
75757
+ */
75755
75758
  {
75756
75759
  type: "number",
75757
75760
  id: Ids.ghostOpacity,
@@ -75761,6 +75764,13 @@ const IsolationPanel$1 = forwardRef(
75761
75764
  min: 0,
75762
75765
  max: 1,
75763
75766
  step: 0.05
75767
+ },
75768
+ {
75769
+ type: "bool",
75770
+ visible: () => props.transparency,
75771
+ id: Ids.transparency,
75772
+ label: "Transparency",
75773
+ state: props.state.transparency
75764
75774
  }
75765
75775
  ]
75766
75776
  }
@@ -75769,12 +75779,13 @@ const IsolationPanel$1 = forwardRef(
75769
75779
  );
75770
75780
  function useSharedIsolation(adapter) {
75771
75781
  const _adapter = useRef(adapter);
75772
- const visibility = useStateRef(() => adapter.computeVisibility());
75782
+ const visibility = useStateRef(() => adapter.computeVisibility(), true);
75773
75783
  const autoIsolate2 = useStateRef(false);
75774
75784
  const showPanel = useStateRef(false);
75775
75785
  const showRooms = useStateRef(false);
75776
75786
  const showGhost = useStateRef(false);
75777
- const ghostOpacity = useStateRef(() => adapter.getGhostOpacity());
75787
+ const ghostOpacity = useStateRef(() => adapter.getGhostOpacity(), true);
75788
+ const transparency = useStateRef(true);
75778
75789
  const onAutoIsolate = useFuncRef(() => {
75779
75790
  if (adapter.hasSelection()) {
75780
75791
  adapter.isolateSelection();
@@ -75799,6 +75810,7 @@ function useSharedIsolation(adapter) {
75799
75810
  });
75800
75811
  showGhost.useOnChange((v) => adapter.showGhost(v));
75801
75812
  showRooms.useOnChange((v) => adapter.setShowRooms(v));
75813
+ transparency.useOnChange((v) => adapter.enableTransparency(v));
75802
75814
  ghostOpacity.useValidate((next, current) => {
75803
75815
  return next <= 0 ? current : next;
75804
75816
  });
@@ -75812,7 +75824,8 @@ function useSharedIsolation(adapter) {
75812
75824
  showRooms,
75813
75825
  ghostOpacity,
75814
75826
  onAutoIsolate,
75815
- onVisibilityChange
75827
+ onVisibilityChange,
75828
+ transparency
75816
75829
  };
75817
75830
  }
75818
75831
  function useWebglIsolation(viewer) {
@@ -75820,6 +75833,29 @@ function useWebglIsolation(viewer) {
75820
75833
  return useSharedIsolation(adapter);
75821
75834
  }
75822
75835
  function createWebglIsolationAdapter(viewer) {
75836
+ var transparency = true;
75837
+ var ghost2 = false;
75838
+ var rooms = false;
75839
+ function updateMaterials() {
75840
+ viewer.renderer.modelMaterial = !ghost2 && transparency ? void 0 : ghost2 && transparency ? [void 0, viewer.materials.ghost] : !ghost2 && !transparency ? viewer.materials.simple : ghost2 && !transparency ? [viewer.materials.simple, viewer.materials.ghost] : (() => {
75841
+ throw new Error("Unreachable state in isolation materials");
75842
+ })();
75843
+ }
75844
+ function updateVisibility(elements, predicate) {
75845
+ if (elements === "all") {
75846
+ for (let v of viewer.vims) {
75847
+ for (let o of v.getAllElements()) {
75848
+ if (o.type === "Element3D") {
75849
+ o.visible = o.isRoom ? rooms : predicate(o);
75850
+ }
75851
+ }
75852
+ }
75853
+ } else {
75854
+ for (let o of elements) {
75855
+ o.visible = o.isRoom ? rooms : predicate(o);
75856
+ }
75857
+ }
75858
+ }
75823
75859
  return {
75824
75860
  onVisibilityChange: viewer.renderer.onSceneUpdated,
75825
75861
  onSelectionChanged: viewer.selection.onSelectionChanged,
@@ -75828,28 +75864,28 @@ function createWebglIsolationAdapter(viewer) {
75828
75864
  hasVisibleSelection: () => viewer.selection.any() && viewer.selection.getAll().every((o) => o.visible),
75829
75865
  hasHiddenSelection: () => viewer.selection.any() && viewer.selection.getAll().every((o) => !o.visible),
75830
75866
  clearSelection: () => viewer.selection.clear(),
75831
- isolateSelection: () => updateAllVisibility(viewer, (o) => viewer.selection.has(o)),
75867
+ isolateSelection: () => updateVisibility("all", (o) => viewer.selection.has(o)),
75832
75868
  hideSelection: () => {
75833
- viewer.selection.getAll().forEach((o) => o.visible = false);
75869
+ updateVisibility(viewer.selection.getAll(), (o) => false);
75834
75870
  },
75835
75871
  showSelection: () => {
75836
- viewer.selection.getAll().forEach((o) => o.visible = true);
75872
+ updateVisibility(viewer.selection.getAll(), (o) => true);
75837
75873
  },
75838
75874
  hideAll: () => {
75839
- updateAllVisibility(viewer, (o) => false);
75875
+ updateVisibility("all", (o) => false);
75840
75876
  },
75841
75877
  showAll: () => {
75842
- updateAllVisibility(viewer, (o) => true);
75878
+ updateVisibility("all", (o) => true);
75843
75879
  },
75844
75880
  isolate: (instances) => {
75845
75881
  const set3 = new Set(instances);
75846
- updateAllVisibility(viewer, (o) => o.instances.some((i) => set3.has(i)));
75882
+ updateVisibility("all", (o) => o.instances.some((i) => set3.has(i)));
75847
75883
  },
75848
75884
  show: (instances) => {
75849
75885
  for (let i of instances) {
75850
75886
  for (let v of viewer.vims) {
75851
75887
  const o = v.getElement(i);
75852
- o.visible = true;
75888
+ o.visible = o.isRoom ? rooms : true;
75853
75889
  }
75854
75890
  }
75855
75891
  },
@@ -75857,29 +75893,30 @@ function createWebglIsolationAdapter(viewer) {
75857
75893
  for (let i of instances) {
75858
75894
  for (let v of viewer.vims) {
75859
75895
  const o = v.getElement(i);
75860
- o.visible = false;
75896
+ o.visible = o.isRoom ? rooms : false;
75861
75897
  }
75862
75898
  }
75863
75899
  },
75900
+ enableTransparency: (enable) => {
75901
+ if (transparency !== enable) {
75902
+ transparency = enable;
75903
+ updateMaterials();
75904
+ }
75905
+ },
75864
75906
  showGhost: (show) => {
75865
- viewer.renderer.modelMaterial = show ? [viewer.materials.simple, viewer.materials.ghost] : void 0;
75907
+ ghost2 = show;
75908
+ updateMaterials();
75866
75909
  },
75867
75910
  getGhostOpacity: () => viewer.materials.ghostOpacity,
75868
75911
  setGhostOpacity: (opacity) => viewer.materials.ghostOpacity = opacity,
75869
- getShowRooms: () => true,
75912
+ getShowRooms: () => rooms,
75870
75913
  setShowRooms: (show) => {
75871
- console.log("setShowRooms not implemented");
75872
- }
75873
- };
75874
- }
75875
- function updateAllVisibility(viewer, predicate) {
75876
- for (let v of viewer.vims) {
75877
- for (let o of v.getAllElements()) {
75878
- if (o.type === "Element3D") {
75879
- o.visible = predicate(o);
75914
+ if (rooms !== show) {
75915
+ rooms = show;
75916
+ updateVisibility("all", (o) => o.visible);
75880
75917
  }
75881
75918
  }
75882
- }
75919
+ };
75883
75920
  }
75884
75921
  function getVisibilityState$1(viewer) {
75885
75922
  let all = true;
@@ -75905,6 +75942,574 @@ function getVisibilityState$1(viewer) {
75905
75942
  if (onlySelectionFlag) return "onlySelection";
75906
75943
  return "some";
75907
75944
  }
75945
+ function getDefaultSettings() {
75946
+ return {
75947
+ capacity: {
75948
+ canFollowUrl: true,
75949
+ canGoFullScreen: true,
75950
+ canDownload: true,
75951
+ canReadLocalStorage: true
75952
+ },
75953
+ ui: {
75954
+ logo: true,
75955
+ performance: false,
75956
+ bimTreePanel: true,
75957
+ bimInfoPanel: true,
75958
+ // axesPanel
75959
+ axesPanel: true,
75960
+ orthographic: true,
75961
+ resetCamera: true,
75962
+ // Control bar
75963
+ controlBar: true,
75964
+ // Control bar - cursors
75965
+ cursorOrbit: true,
75966
+ cursorLookAround: true,
75967
+ cursorPan: true,
75968
+ cursorZoom: true,
75969
+ // Control bar - camera
75970
+ cameraAuto: true,
75971
+ cameraFrameScene: true,
75972
+ cameraFrameSelection: true,
75973
+ // Control bar - tools
75974
+ sectioningEnable: true,
75975
+ sectioningFitToSelection: true,
75976
+ sectioningReset: true,
75977
+ sectioningShow: true,
75978
+ sectioningAuto: true,
75979
+ sectioningSettings: true,
75980
+ measureEnable: true,
75981
+ // Control bar - Visibility
75982
+ visibilityClearSelection: true,
75983
+ visibilityShowAll: true,
75984
+ visibilityToggle: true,
75985
+ visibilityIsolate: true,
75986
+ visibilityAutoIsolate: true,
75987
+ visibilitySettings: true,
75988
+ // Control bar - settings
75989
+ miscProjectInspector: true,
75990
+ miscSettings: true,
75991
+ miscHelp: true,
75992
+ miscMaximise: true
75993
+ }
75994
+ };
75995
+ }
75996
+ function renderSettingsInputBox(settings2, item) {
75997
+ const ref = React__default.useRef(null);
75998
+ useEffect(() => {
75999
+ var _a3;
76000
+ ref.current.value = (_a3 = item.getter(settings2.value)) == null ? void 0 : _a3.toString();
76001
+ }, []);
76002
+ const update = (event) => {
76003
+ const str = event.target.value;
76004
+ const n = Number.parseFloat(str);
76005
+ if (Number.isNaN(n)) {
76006
+ event.target.value = item.getter(settings2.value).toString();
76007
+ } else {
76008
+ const value = item.transform(n);
76009
+ event.target.value = value.toString();
76010
+ settings2.update((s) => item.setter(s, value));
76011
+ }
76012
+ };
76013
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-box-input vc-my-1 ", children: [
76014
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "textbox", className: "vc-w-3 vc-h-2", children: [
76015
+ item.label,
76016
+ ":"
76017
+ ] }),
76018
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76019
+ "input",
76020
+ {
76021
+ ref,
76022
+ type: "text",
76023
+ className: "vim-settings-textbox vc-border vc-rounded-sm vc-border-gray vc-w-14 vc-ml-1 vc-p-1",
76024
+ onBlur: update
76025
+ }
76026
+ ),
76027
+ /* @__PURE__ */ jsxRuntimeExports.jsx("label", { htmlFor: "textbox", className: "vc-w-3 vc-h-2 vc-text-gray vc-ml-1", children: item.info })
76028
+ ] });
76029
+ }
76030
+ function renderSettingsToggle(settings2, item) {
76031
+ const value = item.getter(settings2.value);
76032
+ if (value === "AlwaysTrue" || value === "AlwaysFalse") return null;
76033
+ const handleChange = () => {
76034
+ const current = item.getter(settings2.value);
76035
+ settings2.update((s) => item.setter(s, !current));
76036
+ };
76037
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "vc-m-1 vc-block vc-select-none vc-items-center vc-py-1 vc-text-gray-warm", children: [
76038
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76039
+ "input",
76040
+ {
76041
+ type: "checkbox",
76042
+ checked: value,
76043
+ onChange: handleChange,
76044
+ className: "vim-settings-checkbox vc-checked:bg-primary-royal vc-mr-2 vc-rounded vc-border vc-border-gray-medium"
76045
+ }
76046
+ ),
76047
+ " ",
76048
+ item.label
76049
+ ] });
76050
+ }
76051
+ function renderSettingsSubtitle(item) {
76052
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "vc-subtitle", children: item.title });
76053
+ }
76054
+ function SettingsPanel(props) {
76055
+ if (!props.visible) return null;
76056
+ function renderItem(settings2, item) {
76057
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: (() => {
76058
+ switch (item.type) {
76059
+ case "subtitle":
76060
+ return renderSettingsSubtitle(item);
76061
+ case "toggle":
76062
+ return renderSettingsToggle(settings2, item);
76063
+ case "box":
76064
+ return renderSettingsInputBox(settings2, item);
76065
+ case "element":
76066
+ return item.element;
76067
+ default:
76068
+ return null;
76069
+ }
76070
+ })() }, item.key);
76071
+ }
76072
+ const customizer = props.settings.customizer.get();
76073
+ const content2 = customizer ? customizer(props.content) : props.content;
76074
+ const sections = buildSections(content2);
76075
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-absolute vc-inset-0", children: [
76076
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "vc-title vc-mb-2", children: "Settings" }),
76077
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "\r\n vim-settings\r\n vc-absolute vc-top-8 vc-left-0 vc-right-0 vc-bottom-0\r\n vc-overflow-y-auto\r\n vc-pr-2\r\n vc-space-y-2\r\n vc-box-border\r\n ", children: sections.map((section) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
76078
+ "details",
76079
+ {
76080
+ open: true,
76081
+ className: "\r\n vim-settings-section\r\n vc-bg-white\r\n vc-rounded-md\r\n vc-shadow-sm\r\n vc-border\r\n vc-border-slate-200\r\n vc-p-2\r\n vc-space-y-2\r\n ",
76082
+ children: [
76083
+ /* @__PURE__ */ jsxRuntimeExports.jsx("summary", { className: "vim-settings-section-title vc-font-medium vc-text-sm vc-cursor-pointer", children: section.title }),
76084
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "vim-settings-section-content vc-mt-2 vc-space-y-2", children: section.items.map(
76085
+ (item) => renderItem(props.settings, item)
76086
+ ) })
76087
+ ]
76088
+ },
76089
+ section.key
76090
+ )) })
76091
+ ] });
76092
+ }
76093
+ function buildSections(items) {
76094
+ const sections = [];
76095
+ let current = null;
76096
+ for (const item of items) {
76097
+ if (item.type === "subtitle") {
76098
+ current = {
76099
+ key: item.key,
76100
+ title: item.title,
76101
+ items: []
76102
+ };
76103
+ sections.push(current);
76104
+ } else {
76105
+ if (!current) {
76106
+ current = {
76107
+ key: "default",
76108
+ title: "",
76109
+ items: []
76110
+ };
76111
+ sections.push(current);
76112
+ }
76113
+ current.items.push(item);
76114
+ }
76115
+ }
76116
+ return sections;
76117
+ }
76118
+ class SettingsPanelKeys {
76119
+ }
76120
+ // === Inputs ===
76121
+ __publicField(SettingsPanelKeys, "InputsSubtitle", "inputs");
76122
+ __publicField(SettingsPanelKeys, "InputsScrollSpeedBox", "scrollSpeed");
76123
+ // === Panels ===
76124
+ __publicField(SettingsPanelKeys, "PanelsSubtitle", "panels");
76125
+ __publicField(SettingsPanelKeys, "PanelsShowLogoToggle", "logo");
76126
+ __publicField(SettingsPanelKeys, "PanelsShowBimTreeToggle", "bimTree");
76127
+ __publicField(SettingsPanelKeys, "PanelsShowBimInfoToggle", "bimInfo");
76128
+ __publicField(SettingsPanelKeys, "PanelsShowAxesPanelToggle", "axesPanel");
76129
+ __publicField(SettingsPanelKeys, "PanelsShowPerformancePanelToggle", "performance");
76130
+ // === Axes ===
76131
+ __publicField(SettingsPanelKeys, "AxesSubtitle", "axes");
76132
+ __publicField(SettingsPanelKeys, "AxesShowOrthographicButtonToggle", "orthographic");
76133
+ __publicField(SettingsPanelKeys, "AxesShowResetCameraButtonToggle", "resetCamera");
76134
+ // === Control Bar ===
76135
+ __publicField(SettingsPanelKeys, "ControlBarSubtitle", "controlBar");
76136
+ __publicField(SettingsPanelKeys, "ControlBarShowControlBarToggle", "controlBarVisible");
76137
+ // --- Control Bar - Cursors ---
76138
+ __publicField(SettingsPanelKeys, "ControlBarCursorsSubtitle", "controlBarCursors");
76139
+ __publicField(SettingsPanelKeys, "ControlBarCursorsShowOrbitButtonToggle", "orbit");
76140
+ __publicField(SettingsPanelKeys, "ControlBarCursorsShowLookAroundButtonToggle", "lookAround");
76141
+ __publicField(SettingsPanelKeys, "ControlBarCursorsShowPanButtonToggle", "pan");
76142
+ __publicField(SettingsPanelKeys, "ControlBarCursorsShowZoomButtonToggle", "zoom");
76143
+ __publicField(SettingsPanelKeys, "ControlBarCursorsShowZoomWindowButtonToggle", "zoomWindow");
76144
+ // --- Control Bar - Tools ---
76145
+ __publicField(SettingsPanelKeys, "ControlBarToolsSubtitle", "controlBarTools");
76146
+ __publicField(SettingsPanelKeys, "ControlBarToolsShowMeasuringModeButtonToggle", "measuringMode");
76147
+ // --- Control Bar Camera ---
76148
+ __publicField(SettingsPanelKeys, "ControlBarCameraSubtitle", "settingsPanel.controlBar.Camera");
76149
+ __publicField(SettingsPanelKeys, "ControlBarAutoCamera", "settingsPanel.controlBar.autoCamera");
76150
+ __publicField(SettingsPanelKeys, "ControlBarFrameSelection", "settingsPanel.controlBar.frameSelection");
76151
+ __publicField(SettingsPanelKeys, "ControlBarFrameAll", "settingsPanel.controlBar.frameAll");
76152
+ // --- Control Bar - Sectioning ---
76153
+ __publicField(SettingsPanelKeys, "ControlBarSectioningSubtitle", "settingsPanel.controlBar.sectioning");
76154
+ __publicField(SettingsPanelKeys, "ControlBarSectioningEnable", "settingsPanel.controlBar.enableSectioning");
76155
+ __publicField(SettingsPanelKeys, "ControlBarSectioningFitToSelection", "settingsPanel.controlBar.fitToSelection");
76156
+ __publicField(SettingsPanelKeys, "ControlBarSectioningReset", "settingsPanel.controlBar.reset");
76157
+ __publicField(SettingsPanelKeys, "ControlBarSectioningShow", "settingsPanel.controlBar.show");
76158
+ __publicField(SettingsPanelKeys, "ControlBarSectioningAuto", "settingsPanel.controlBar.auto");
76159
+ __publicField(SettingsPanelKeys, "ControlBarSectioningSettings", "settingsPanel.controlBar.settings");
76160
+ // --- Control Bar - Visibility ---
76161
+ __publicField(SettingsPanelKeys, "ControlBarVisibilitySubtitle", "controlBar.visibility.subtitle");
76162
+ __publicField(SettingsPanelKeys, "ControlBarVisibilityClearSelection", "controlBar.visibility.clearSelection");
76163
+ __publicField(SettingsPanelKeys, "ControlBarVisibilityShowAll", "controlBar.visibility.showAll");
76164
+ __publicField(SettingsPanelKeys, "ControlBarVisibilityToggle", "controlBar.visibility.toggle");
76165
+ __publicField(SettingsPanelKeys, "ControlBarVisibilityIsolate", "controlBar.visibility.isolate");
76166
+ __publicField(SettingsPanelKeys, "ControlBarVisibilityAutoIsolate", "controlBar.visibility.autoIsolate");
76167
+ __publicField(SettingsPanelKeys, "ControlBarVisibilitySettings", "controlBar.visibility.settings");
76168
+ // --- Control Bar - Settings ---
76169
+ __publicField(SettingsPanelKeys, "ControlBarSettingsSubtitle", "controlBarSettings");
76170
+ __publicField(SettingsPanelKeys, "ControlBarSettingsShowProjectInspectorButtonToggle", "projectInspector");
76171
+ __publicField(SettingsPanelKeys, "ControlBarSettingsShowSettingsButtonToggle", "settingsButton");
76172
+ __publicField(SettingsPanelKeys, "ControlBarSettingsShowHelpButtonToggle", "help");
76173
+ __publicField(SettingsPanelKeys, "ControlBarSettingsShowMaximiseButtonToggle", "maximise");
76174
+ function getControlBarCursorSettings() {
76175
+ return [
76176
+ {
76177
+ type: "subtitle",
76178
+ key: SettingsPanelKeys.ControlBarCursorsSubtitle,
76179
+ title: "Control Bar - Cursors"
76180
+ },
76181
+ {
76182
+ type: "toggle",
76183
+ key: SettingsPanelKeys.ControlBarCursorsShowOrbitButtonToggle,
76184
+ label: "Orbit",
76185
+ getter: (s) => s.ui.cursorOrbit,
76186
+ setter: (s, v) => s.ui.cursorOrbit = v
76187
+ },
76188
+ {
76189
+ type: "toggle",
76190
+ key: SettingsPanelKeys.ControlBarCursorsShowLookAroundButtonToggle,
76191
+ label: "Look Around",
76192
+ getter: (s) => s.ui.cursorLookAround,
76193
+ setter: (s, v) => s.ui.cursorLookAround = v
76194
+ },
76195
+ {
76196
+ type: "toggle",
76197
+ key: SettingsPanelKeys.ControlBarCursorsShowPanButtonToggle,
76198
+ label: "Pan",
76199
+ getter: (s) => s.ui.cursorPan,
76200
+ setter: (s, v) => s.ui.cursorPan = v
76201
+ },
76202
+ {
76203
+ type: "toggle",
76204
+ key: SettingsPanelKeys.ControlBarCursorsShowZoomButtonToggle,
76205
+ label: "Zoom",
76206
+ getter: (s) => s.ui.cursorZoom,
76207
+ setter: (s, v) => s.ui.cursorZoom = v
76208
+ }
76209
+ ];
76210
+ }
76211
+ function getControlBarCameraSettings() {
76212
+ return [
76213
+ {
76214
+ type: "subtitle",
76215
+ key: SettingsPanelKeys.ControlBarCameraSubtitle,
76216
+ title: "Control Bar - Camera"
76217
+ },
76218
+ {
76219
+ type: "toggle",
76220
+ key: SettingsPanelKeys.ControlBarAutoCamera,
76221
+ label: "Auto Camera",
76222
+ getter: (s) => s.ui.cameraAuto,
76223
+ setter: (s, v) => s.ui.cameraAuto = v
76224
+ },
76225
+ {
76226
+ type: "toggle",
76227
+ key: SettingsPanelKeys.ControlBarFrameSelection,
76228
+ label: "Frame Selection",
76229
+ getter: (s) => s.ui.cameraFrameSelection,
76230
+ setter: (s, v) => s.ui.cameraFrameSelection = v
76231
+ },
76232
+ {
76233
+ type: "toggle",
76234
+ key: SettingsPanelKeys.ControlBarFrameAll,
76235
+ label: "Frame All",
76236
+ getter: (s) => s.ui.cameraFrameScene,
76237
+ setter: (s, v) => s.ui.cameraFrameScene = v
76238
+ }
76239
+ ];
76240
+ }
76241
+ function getControlBarSectionBoxSettings() {
76242
+ return [
76243
+ {
76244
+ type: "subtitle",
76245
+ key: SettingsPanelKeys.ControlBarSectioningSubtitle,
76246
+ title: "Control Bar - Sectioning"
76247
+ },
76248
+ {
76249
+ type: "toggle",
76250
+ key: SettingsPanelKeys.ControlBarSectioningEnable,
76251
+ label: "Enable Sectioning",
76252
+ getter: (s) => s.ui.sectioningEnable,
76253
+ setter: (s, v) => s.ui.sectioningEnable = v
76254
+ },
76255
+ {
76256
+ type: "toggle",
76257
+ key: SettingsPanelKeys.ControlBarSectioningFitToSelection,
76258
+ label: "Fit To Selection",
76259
+ getter: (s) => s.ui.sectioningFitToSelection,
76260
+ setter: (s, v) => s.ui.sectioningFitToSelection = v
76261
+ },
76262
+ {
76263
+ type: "toggle",
76264
+ key: SettingsPanelKeys.ControlBarSectioningReset,
76265
+ label: "Reset",
76266
+ getter: (s) => s.ui.sectioningReset,
76267
+ setter: (s, v) => s.ui.sectioningReset = v
76268
+ },
76269
+ {
76270
+ type: "toggle",
76271
+ key: SettingsPanelKeys.ControlBarSectioningShow,
76272
+ label: "Show",
76273
+ getter: (s) => s.ui.sectioningShow,
76274
+ setter: (s, v) => s.ui.sectioningShow = v
76275
+ },
76276
+ {
76277
+ type: "toggle",
76278
+ key: SettingsPanelKeys.ControlBarSectioningAuto,
76279
+ label: "Auto",
76280
+ getter: (s) => s.ui.sectioningAuto,
76281
+ setter: (s, v) => s.ui.sectioningAuto = v
76282
+ },
76283
+ {
76284
+ type: "toggle",
76285
+ key: SettingsPanelKeys.ControlBarSectioningSettings,
76286
+ label: "Settings",
76287
+ getter: (s) => s.ui.sectioningSettings,
76288
+ setter: (s, v) => s.ui.sectioningSettings = v
76289
+ }
76290
+ ];
76291
+ }
76292
+ function getControlBarVisibilitySettings() {
76293
+ return [
76294
+ {
76295
+ type: "subtitle",
76296
+ key: SettingsPanelKeys.ControlBarVisibilitySubtitle,
76297
+ title: "Control Bar - Visibility"
76298
+ },
76299
+ {
76300
+ type: "toggle",
76301
+ key: SettingsPanelKeys.ControlBarVisibilityClearSelection,
76302
+ label: "Clear Selection",
76303
+ getter: (s) => s.ui.visibilityClearSelection,
76304
+ setter: (s, v) => s.ui.visibilityClearSelection = v
76305
+ },
76306
+ {
76307
+ type: "toggle",
76308
+ key: SettingsPanelKeys.ControlBarVisibilityShowAll,
76309
+ label: "Show All",
76310
+ getter: (s) => s.ui.visibilityShowAll,
76311
+ setter: (s, v) => s.ui.visibilityShowAll = v
76312
+ },
76313
+ {
76314
+ type: "toggle",
76315
+ key: SettingsPanelKeys.ControlBarVisibilityToggle,
76316
+ label: "Toggle",
76317
+ getter: (s) => s.ui.visibilityToggle,
76318
+ setter: (s, v) => s.ui.visibilityToggle = v
76319
+ },
76320
+ {
76321
+ type: "toggle",
76322
+ key: SettingsPanelKeys.ControlBarVisibilityIsolate,
76323
+ label: "Isolate",
76324
+ getter: (s) => s.ui.visibilityIsolate,
76325
+ setter: (s, v) => s.ui.visibilityIsolate = v
76326
+ },
76327
+ {
76328
+ type: "toggle",
76329
+ key: SettingsPanelKeys.ControlBarVisibilityAutoIsolate,
76330
+ label: "Auto Isolate",
76331
+ getter: (s) => s.ui.visibilityAutoIsolate,
76332
+ setter: (s, v) => s.ui.visibilityAutoIsolate = v
76333
+ },
76334
+ {
76335
+ type: "toggle",
76336
+ key: SettingsPanelKeys.ControlBarVisibilitySettings,
76337
+ label: "Settings",
76338
+ getter: (s) => s.ui.visibilitySettings,
76339
+ setter: (s, v) => s.ui.visibilitySettings = v
76340
+ }
76341
+ ];
76342
+ }
76343
+ function getControlBarVariousSettings() {
76344
+ return [
76345
+ {
76346
+ type: "subtitle",
76347
+ key: SettingsPanelKeys.ControlBarSettingsSubtitle,
76348
+ title: "Control Bar - Settings"
76349
+ },
76350
+ {
76351
+ type: "toggle",
76352
+ key: SettingsPanelKeys.ControlBarSettingsShowProjectInspectorButtonToggle,
76353
+ label: "Project Inspector",
76354
+ getter: (s) => s.ui.miscProjectInspector,
76355
+ setter: (s, v) => s.ui.miscProjectInspector = v
76356
+ },
76357
+ {
76358
+ type: "toggle",
76359
+ key: SettingsPanelKeys.ControlBarSettingsShowSettingsButtonToggle,
76360
+ label: "Settings",
76361
+ getter: (s) => s.ui.miscSettings,
76362
+ setter: (s, v) => s.ui.miscSettings = v
76363
+ },
76364
+ {
76365
+ type: "toggle",
76366
+ key: SettingsPanelKeys.ControlBarSettingsShowHelpButtonToggle,
76367
+ label: "Help",
76368
+ getter: (s) => s.ui.miscHelp,
76369
+ setter: (s, v) => s.ui.miscHelp = v
76370
+ },
76371
+ {
76372
+ type: "toggle",
76373
+ key: SettingsPanelKeys.ControlBarSettingsShowMaximiseButtonToggle,
76374
+ label: "Maximise",
76375
+ getter: (s) => s.ui.miscMaximise,
76376
+ setter: (s, v) => s.ui.miscMaximise = v
76377
+ }
76378
+ ];
76379
+ }
76380
+ function getPanelsVisibilitySettings() {
76381
+ return [
76382
+ {
76383
+ type: "subtitle",
76384
+ key: SettingsPanelKeys.PanelsSubtitle,
76385
+ title: "Panels Visibility"
76386
+ },
76387
+ {
76388
+ type: "toggle",
76389
+ key: SettingsPanelKeys.PanelsShowLogoToggle,
76390
+ label: "Logo",
76391
+ getter: (s) => s.ui.logo,
76392
+ setter: (s, v) => s.ui.logo = v
76393
+ },
76394
+ {
76395
+ type: "toggle",
76396
+ key: SettingsPanelKeys.PanelsShowBimTreeToggle,
76397
+ label: "Bim Tree",
76398
+ getter: (s) => s.ui.bimTreePanel,
76399
+ setter: (s, v) => s.ui.bimTreePanel = v
76400
+ },
76401
+ {
76402
+ type: "toggle",
76403
+ key: SettingsPanelKeys.PanelsShowBimInfoToggle,
76404
+ label: "Bim Info",
76405
+ getter: (s) => s.ui.bimInfoPanel,
76406
+ setter: (s, v) => s.ui.bimInfoPanel = v
76407
+ },
76408
+ {
76409
+ type: "toggle",
76410
+ key: SettingsPanelKeys.PanelsShowAxesPanelToggle,
76411
+ label: "Axes",
76412
+ getter: (s) => s.ui.axesPanel,
76413
+ setter: (s, v) => s.ui.axesPanel = v
76414
+ },
76415
+ {
76416
+ type: "toggle",
76417
+ key: SettingsPanelKeys.PanelsShowPerformancePanelToggle,
76418
+ label: "Performance",
76419
+ getter: (s) => s.ui.performance,
76420
+ setter: (s, v) => s.ui.performance = v
76421
+ },
76422
+ {
76423
+ type: "toggle",
76424
+ key: SettingsPanelKeys.ControlBarShowControlBarToggle,
76425
+ label: "Control Bar",
76426
+ getter: (s) => s.ui.controlBar,
76427
+ setter: (s, v) => s.ui.controlBar = v
76428
+ }
76429
+ ];
76430
+ }
76431
+ function getInputsSettings(viewer) {
76432
+ return [
76433
+ {
76434
+ type: "subtitle",
76435
+ key: SettingsPanelKeys.InputsSubtitle,
76436
+ title: "Inputs"
76437
+ },
76438
+ {
76439
+ type: "box",
76440
+ key: SettingsPanelKeys.InputsScrollSpeedBox,
76441
+ label: "Scroll Speed",
76442
+ info: "[0.1,10]",
76443
+ transform: (n) => MathUtils.clamp(n, 0.1, 10),
76444
+ getter: (_s) => viewer.inputs.scrollSpeed,
76445
+ setter: (_s, v) => {
76446
+ viewer.inputs.scrollSpeed = v;
76447
+ }
76448
+ }
76449
+ ];
76450
+ }
76451
+ function getAxesPanelSettings() {
76452
+ return [
76453
+ {
76454
+ type: "subtitle",
76455
+ key: SettingsPanelKeys.AxesSubtitle,
76456
+ title: "Axes Panel"
76457
+ },
76458
+ {
76459
+ type: "toggle",
76460
+ key: SettingsPanelKeys.AxesShowOrthographicButtonToggle,
76461
+ label: "Orthographic Camera",
76462
+ getter: (s) => s.ui.orthographic,
76463
+ setter: (s, v) => s.ui.orthographic = v
76464
+ },
76465
+ {
76466
+ type: "toggle",
76467
+ key: SettingsPanelKeys.AxesShowResetCameraButtonToggle,
76468
+ label: "Reset Camera",
76469
+ getter: (s) => s.ui.resetCamera,
76470
+ setter: (s, v) => s.ui.resetCamera = v
76471
+ }
76472
+ ];
76473
+ }
76474
+ function getControlBarMeasureSettings() {
76475
+ return [
76476
+ {
76477
+ type: "subtitle",
76478
+ key: SettingsPanelKeys.ControlBarToolsSubtitle,
76479
+ title: "Control Bar - Measurement"
76480
+ },
76481
+ {
76482
+ type: "toggle",
76483
+ key: SettingsPanelKeys.ControlBarToolsShowMeasuringModeButtonToggle,
76484
+ label: "Enable",
76485
+ getter: (s) => s.ui.measureEnable,
76486
+ setter: (s, v) => s.ui.measureEnable = v
76487
+ }
76488
+ ];
76489
+ }
76490
+ function getWebglSettingsContent(viewer) {
76491
+ return [
76492
+ ...getInputsSettings(viewer),
76493
+ ...getPanelsVisibilitySettings(),
76494
+ ...getAxesPanelSettings(),
76495
+ ...getControlBarCursorSettings(),
76496
+ ...getControlBarCameraSettings(),
76497
+ ...getControlBarVisibilitySettings(),
76498
+ ...getControlBarMeasureSettings(),
76499
+ ...getControlBarSectionBoxSettings(),
76500
+ ...getControlBarVariousSettings()
76501
+ ];
76502
+ }
76503
+ function applyWebglSettings(settings2) {
76504
+ const performance2 = document.getElementsByClassName("vim-performance-div")[0];
76505
+ if (performance2) {
76506
+ if (isTrue(settings2.ui.performance)) {
76507
+ performance2.classList.remove("vc-hidden");
76508
+ } else {
76509
+ performance2.classList.add("vc-hidden");
76510
+ }
76511
+ }
76512
+ }
75908
76513
  function createViewer$1(container, settings2 = {}, coreSettings = {}) {
75909
76514
  const controllablePromise = new ControllablePromise();
75910
76515
  const cmpContainer = container instanceof HTMLElement ? createContainer(container) : container ?? createContainer();
@@ -75935,7 +76540,7 @@ function createViewer$1(container, settings2 = {}, coreSettings = {}) {
75935
76540
  return controllablePromise.promise;
75936
76541
  }
75937
76542
  function Viewer$1(props) {
75938
- const settings2 = useSettings(props.viewer, props.settings ?? {});
76543
+ const settings2 = useSettings(props.settings ?? {}, getDefaultSettings(), (s) => applyWebglSettings(s));
75939
76544
  const modal = useRef(null);
75940
76545
  const sectionBoxRef = useWebglSectionBox(props.viewer);
75941
76546
  const isolationPanelHandle = useRef(null);
@@ -75961,6 +76566,16 @@ function Viewer$1(props) {
75961
76566
  side.setHasBim(((_a3 = viewerState.vim.get()) == null ? void 0 : _a3.bim) !== void 0);
75962
76567
  });
75963
76568
  useEffect(() => {
76569
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
76570
+ if (show) {
76571
+ isolationRef.showPanel.set(false);
76572
+ }
76573
+ });
76574
+ isolationRef.showPanel.onChange.subscribe((show) => {
76575
+ if (show) {
76576
+ sectionBoxRef.showOffsetPanel.set(false);
76577
+ }
76578
+ });
75964
76579
  if (performanceRef.current) {
75965
76580
  addPerformanceCounter(performanceRef.current);
75966
76581
  }
@@ -75974,7 +76589,11 @@ function Viewer$1(props) {
75974
76589
  loader: loader.current,
75975
76590
  isolation: isolationRef,
75976
76591
  camera: camera2,
75977
- settings: settings2,
76592
+ settings: {
76593
+ update: settings2.update,
76594
+ register: settings2.register,
76595
+ customize: (c) => settings2.customizer.set(c)
76596
+ },
75978
76597
  get isolationPanel() {
75979
76598
  return isolationPanelHandle.current;
75980
76599
  },
@@ -76020,7 +76639,7 @@ function Viewer$1(props) {
76020
76639
  SettingsPanel,
76021
76640
  {
76022
76641
  visible: side.getContent() === "settings",
76023
- viewer: props.viewer,
76642
+ content: getWebglSettingsContent(props.viewer),
76024
76643
  settings: settings2
76025
76644
  }
76026
76645
  )
@@ -76049,7 +76668,7 @@ function Viewer$1(props) {
76049
76668
  }
76050
76669
  ),
76051
76670
  /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),
76052
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolationRef }),
76671
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolationRef, transparency: true }),
76053
76672
  /* @__PURE__ */ jsxRuntimeExports.jsx(
76054
76673
  AxesPanelMemo,
76055
76674
  {
@@ -76088,7 +76707,8 @@ function Viewer$1(props) {
76088
76707
  const index$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76089
76708
  __proto__: null,
76090
76709
  Viewer: Viewer$1,
76091
- createViewer: createViewer$1
76710
+ createViewer: createViewer$1,
76711
+ getDefaultSettings
76092
76712
  }, Symbol.toStringTag, { value: "Module" }));
76093
76713
  function getErrorMessage(state) {
76094
76714
  if (state.status !== "error") return void 0;
@@ -76147,18 +76767,20 @@ function useUltraSectionBox(viewer) {
76147
76767
  viewer.sectionBox.interactive = b;
76148
76768
  },
76149
76769
  getBox: () => viewer.sectionBox.getBox(),
76150
- setBox: (box) => viewer.sectionBox.fitBox(box),
76770
+ setBox: (box) => viewer.sectionBox.setBox(box),
76151
76771
  onSelectionChanged: viewer.selection.onSelectionChanged,
76152
76772
  getSelectionBox: () => viewer.selection.getBoundingBox(),
76153
76773
  getSceneBox: () => viewer.renderer.getBoundingBox()
76154
76774
  };
76155
76775
  return useSectionBox(ultraAdapter);
76156
76776
  }
76157
- function useUltraControlBar(viewer, section, isolation, camera2, customization) {
76158
- const sectionSectionBox2 = controlBarSectionBox(section, viewer.selection.any());
76159
- const selection = controlBarSelection(isolation);
76160
- const sectionCamera2 = controlBarCamera(camera2);
76161
- let bar = [selection, sectionCamera2, sectionSectionBox2];
76777
+ function useUltraControlBar(viewer, section, isolation, camera2, settings2, side, customization) {
76778
+ let bar = [
76779
+ controlBarCamera(camera2, settings2.ui),
76780
+ controlBarVisibility(isolation, settings2.ui),
76781
+ controlBarSectionBox(section, viewer.selection.any(), settings2.ui),
76782
+ controlBarSettingsUltra(side, settings2)
76783
+ ];
76162
76784
  bar = (customization == null ? void 0 : customization(bar)) ?? bar;
76163
76785
  return bar;
76164
76786
  }
@@ -76228,6 +76850,7 @@ function createAdapter(viewer) {
76228
76850
  obj.state = VisibilityState.HIGHLIGHTED;
76229
76851
  });
76230
76852
  },
76853
+ // TODO: Change this api to use elements
76231
76854
  isolate: (instances) => {
76232
76855
  hide("all");
76233
76856
  viewer.selection.getAll().forEach((obj) => {
@@ -76261,11 +76884,12 @@ function createAdapter(viewer) {
76261
76884
  }
76262
76885
  }
76263
76886
  },
76264
- getGhostOpacity: () => viewer.renderer.ghostColor.a,
76887
+ enableTransparency: (enable) => {
76888
+ console.log("enableTransparency not implemented");
76889
+ },
76890
+ getGhostOpacity: () => viewer.renderer.ghostOpacity,
76265
76891
  setGhostOpacity: (opacity) => {
76266
- const c = viewer.renderer.ghostColor.clone();
76267
- c.a = opacity;
76268
- viewer.renderer.ghostColor = c;
76892
+ viewer.renderer.ghostOpacity = opacity;
76269
76893
  },
76270
76894
  getShowRooms: () => true,
76271
76895
  setShowRooms: (show) => {
@@ -76304,7 +76928,61 @@ function onlySelection(viewer, vim) {
76304
76928
  function allButSelection(viewer, vim) {
76305
76929
  return false;
76306
76930
  }
76307
- function createViewer(container) {
76931
+ function getDefaultUltraSettings() {
76932
+ return {
76933
+ ui: {
76934
+ // Control bar - cursors
76935
+ cursorOrbit: true,
76936
+ cursorLookAround: true,
76937
+ cursorPan: true,
76938
+ cursorZoom: true,
76939
+ // Control bar - camera
76940
+ cameraAuto: true,
76941
+ cameraFrameScene: true,
76942
+ cameraFrameSelection: true,
76943
+ // Control bar - tools
76944
+ sectioningEnable: true,
76945
+ sectioningFitToSelection: true,
76946
+ sectioningReset: true,
76947
+ sectioningShow: true,
76948
+ sectioningAuto: true,
76949
+ sectioningSettings: true,
76950
+ // Control bar - Visibility
76951
+ visibilityClearSelection: true,
76952
+ visibilityShowAll: true,
76953
+ visibilityToggle: true,
76954
+ visibilityIsolate: true,
76955
+ visibilityAutoIsolate: true,
76956
+ visibilitySettings: true,
76957
+ settings: true
76958
+ }
76959
+ };
76960
+ }
76961
+ function getControlBarUltraSettings() {
76962
+ return [
76963
+ {
76964
+ type: "subtitle",
76965
+ key: SettingsPanelKeys.ControlBarSettingsSubtitle,
76966
+ title: "Control Bar - Settings"
76967
+ },
76968
+ {
76969
+ type: "toggle",
76970
+ key: SettingsPanelKeys.ControlBarSettingsShowSettingsButtonToggle,
76971
+ label: "Settings",
76972
+ getter: (s) => s.ui.settings,
76973
+ setter: (s, v) => s.ui.settings = v
76974
+ }
76975
+ ];
76976
+ }
76977
+ function getUltraSettingsContent(viewer) {
76978
+ return [
76979
+ ...getControlBarCameraSettings(),
76980
+ ...getControlBarVisibilitySettings(),
76981
+ ...getControlBarSectionBoxSettings(),
76982
+ ...getControlBarUltraSettings()
76983
+ ];
76984
+ }
76985
+ function createViewer(container, settings2) {
76308
76986
  const controllablePromise = new ControllablePromise();
76309
76987
  const cmpContainer = container instanceof HTMLElement ? createContainer(container) : container ?? createContainer();
76310
76988
  const core = Viewer$2.createWithCanvas(cmpContainer.gfx);
@@ -76323,6 +77001,7 @@ function createViewer(container) {
76323
77001
  {
76324
77002
  container: cmpContainer,
76325
77003
  core,
77004
+ settings: settings2,
76326
77005
  onMount: (cmp) => controllablePromise.resolve(attachDispose(cmp))
76327
77006
  }
76328
77007
  )
@@ -76330,18 +77009,37 @@ function createViewer(container) {
76330
77009
  return controllablePromise.promise;
76331
77010
  }
76332
77011
  function Viewer3(props) {
76333
- const sectionBox2 = useUltraSectionBox(props.core);
76334
- const camera2 = useUltraCamera(props.core, sectionBox2);
77012
+ const settings2 = useSettings(props.settings ?? {}, getDefaultUltraSettings());
77013
+ const sectionBoxRef = useUltraSectionBox(props.core);
77014
+ const camera2 = useUltraCamera(props.core, sectionBoxRef);
76335
77015
  const isolationPanelHandle = useRef(null);
76336
77016
  const sectionBoxPanelHandle = useRef(null);
76337
77017
  const modalHandle = useRef(null);
76338
77018
  const side = useSideState(true, 400);
76339
77019
  const [_, setSelectState] = useState(0);
76340
77020
  const [controlBarCustom, setControlBarCustom] = useState(() => (c) => c);
76341
- const isolation = useUltraIsolation(props.core);
76342
- const controlBar = useUltraControlBar(props.core, sectionBox2, isolation, camera2, (_2) => _2);
77021
+ const isolationRef = useUltraIsolation(props.core);
77022
+ const controlBar = useUltraControlBar(
77023
+ props.core,
77024
+ sectionBoxRef,
77025
+ isolationRef,
77026
+ camera2,
77027
+ settings2.value,
77028
+ side,
77029
+ (_2) => _2
77030
+ );
76343
77031
  useViewerInput(props.core.inputs, camera2);
76344
77032
  useEffect(() => {
77033
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
77034
+ if (show) {
77035
+ isolationRef.showPanel.set(false);
77036
+ }
77037
+ });
77038
+ isolationRef.showPanel.onChange.subscribe((show) => {
77039
+ if (show) {
77040
+ sectionBoxRef.showOffsetPanel.set(false);
77041
+ }
77042
+ });
76345
77043
  props.core.onStateChanged.subscribe((state) => updateModal(modalHandle, state));
76346
77044
  props.core.selection.onSelectionChanged.subscribe(() => {
76347
77045
  setSelectState((i) => (i + 1) % 2);
@@ -76351,9 +77049,14 @@ function Viewer3(props) {
76351
77049
  get modal() {
76352
77050
  return modalHandle.current;
76353
77051
  },
76354
- isolation,
76355
- sectionBox: sectionBox2,
77052
+ isolation: isolationRef,
77053
+ sectionBox: sectionBoxRef,
76356
77054
  camera: camera2,
77055
+ settings: {
77056
+ update: settings2.update,
77057
+ register: settings2.register,
77058
+ customize: (c) => settings2.customizer.set(c)
77059
+ },
76357
77060
  get isolationPanel() {
76358
77061
  return isolationPanelHandle.current;
76359
77062
  },
@@ -76368,7 +77071,24 @@ function Viewer3(props) {
76368
77071
  load: patchLoad(props.core, modalHandle)
76369
77072
  });
76370
77073
  }, []);
77074
+ const sidePanel = () => /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
77075
+ SettingsPanel,
77076
+ {
77077
+ visible: side.getContent() === "settings",
77078
+ content: getUltraSettingsContent(props.core),
77079
+ settings: settings2
77080
+ }
77081
+ ) });
76371
77082
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
77083
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
77084
+ SidePanelMemo,
77085
+ {
77086
+ container: props.container,
77087
+ viewer: props.core,
77088
+ side,
77089
+ content: sidePanel
77090
+ }
77091
+ ),
76372
77092
  /* @__PURE__ */ jsxRuntimeExports.jsx(RestOfScreen, { side, content: () => {
76373
77093
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
76374
77094
  whenTrue(true, /* @__PURE__ */ jsxRuntimeExports.jsx(LogoMemo, {})),
@@ -76380,8 +77100,8 @@ function Viewer3(props) {
76380
77100
  show: true
76381
77101
  }
76382
77102
  ),
76383
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBox2 }),
76384
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolation })
77103
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),
77104
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolationRef, transparency: false })
76385
77105
  ] });
76386
77106
  } }),
76387
77107
  /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modalHandle, canFollowLinks: true }),
@@ -76419,7 +77139,8 @@ function patchLoad(viewer, modal) {
76419
77139
  const index$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76420
77140
  __proto__: null,
76421
77141
  Viewer: Viewer3,
76422
- createViewer
77142
+ createViewer,
77143
+ getDefaultUltraSettings
76423
77144
  }, Symbol.toStringTag, { value: "Module" }));
76424
77145
  const SectionBoxPanel = {
76425
77146
  Ids