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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vim-web.js CHANGED
@@ -50876,16 +50876,16 @@ class Validation {
50876
50876
  //= ===========================================================================
50877
50877
  // HANDLE VALIDATIONS
50878
50878
  //= ===========================================================================
50879
- static isComponentHandle(handle) {
50880
- if (!this.isPositiveInteger(handle)) return false;
50881
- if (handle === INVALID_HANDLE) {
50882
- console.warn(`Invalid handle ${handle}. Aborting operation.`);
50879
+ static isIndex(index2) {
50880
+ if (!this.isPositiveInteger(index2)) return false;
50881
+ if (index2 === INVALID_HANDLE) {
50882
+ console.warn(`Invalid index ${index2}. Aborting operation.`);
50883
50883
  return false;
50884
50884
  }
50885
50885
  return true;
50886
50886
  }
50887
- static areComponentHandles(handles) {
50888
- return handles.every((h) => this.isComponentHandle(h));
50887
+ static areIndices(indices) {
50888
+ return indices.every((h) => this.isIndex(h));
50889
50889
  }
50890
50890
  static isMaterialHandle(handle) {
50891
50891
  if (!materialHandles.includes(handle)) {
@@ -57529,7 +57529,7 @@ class Camera3 {
57529
57529
  * @returns Promise that resolves when the framing animation is complete
57530
57530
  */
57531
57531
  async frameAll(blendTime = this._defaultBlendTime) {
57532
- const segment = await this._rpc.RPCFrameAll(blendTime);
57532
+ const segment = await this._rpc.RPCFrameScene(blendTime);
57533
57533
  this._savedPosition = this._savedPosition ?? segment;
57534
57534
  return segment;
57535
57535
  }
@@ -57546,16 +57546,16 @@ class Camera3 {
57546
57546
  /**
57547
57547
  * Frames specific nodes of a Vim model in the camera view
57548
57548
  * @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
57549
+ * @param elements - Array of element indices to frame, or 'all' to frame the entire model
57550
57550
  * @param blendTime - Duration of the camera animation in seconds (defaults to 0.5)
57551
57551
  * @returns Promise that resolves when the framing animation is complete
57552
57552
  */
57553
- async frameVim(vim, nodes, blendTime = this._defaultBlendTime) {
57553
+ async frameVim(vim, elements, blendTime = this._defaultBlendTime) {
57554
57554
  let segment;
57555
- if (nodes === "all") {
57555
+ if (elements === "all") {
57556
57556
  segment = await this._rpc.RPCFrameVim(vim.handle, blendTime);
57557
57557
  } else {
57558
- segment = await this._rpc.RPCFrameElements(vim.handle, nodes, blendTime);
57558
+ segment = await this._rpc.RPCFrameElements(vim.handle, elements, blendTime);
57559
57559
  }
57560
57560
  this._savedPosition = this._savedPosition ?? segment;
57561
57561
  return segment;
@@ -57638,9 +57638,9 @@ class Marshal {
57638
57638
  // -------------------- HitCheckResult -------------------
57639
57639
  writeHitCheckResult(data2) {
57640
57640
  this.ensureCapacity(4 + 4 + 4 + 4 * 3 + 4 * 3);
57641
- this.writeUInt(data2.vimHandle);
57642
- this.writeUInt(data2.nodeIndex);
57643
- this.writeUInt(data2.elementIndex);
57641
+ this.writeUInt(data2.vimIndex);
57642
+ this.writeUInt(data2.vimElementIndex);
57643
+ this.writeUInt(data2.sceneElementIndex);
57644
57644
  this.writeVector3(data2.worldPosition);
57645
57645
  this.writeVector3(data2.worldNormal);
57646
57646
  }
@@ -57788,15 +57788,15 @@ class ReadMarshal {
57788
57788
  return textDecoder.decode(stringData);
57789
57789
  }
57790
57790
  readHitCheckResult() {
57791
- const vimHandle = this.readUInt();
57792
- const nodeIndex = this.readUInt();
57793
- const mElementIndex = this.readUInt();
57791
+ const vimIndex = this.readUInt();
57792
+ const vimElementIndex = this.readUInt();
57793
+ const sceneElementIndex = this.readUInt();
57794
57794
  const worldPosition = this.readVector3();
57795
57795
  const worldNormal = this.readVector3();
57796
57796
  return {
57797
- vimHandle,
57798
- nodeIndex,
57799
- elementIndex: mElementIndex,
57797
+ vimIndex,
57798
+ vimElementIndex,
57799
+ sceneElementIndex,
57800
57800
  worldPosition,
57801
57801
  worldNormal
57802
57802
  };
@@ -57928,10 +57928,9 @@ class RpcClient {
57928
57928
  get url() {
57929
57929
  return this._socket.url;
57930
57930
  }
57931
- RPCClearMaterialOverrides(componentHandle) {
57931
+ RPCClearMaterialOverrides() {
57932
57932
  const marshal = new Marshal();
57933
57933
  marshal.writeString("RPCClearMaterialOverrides");
57934
- marshal.writeUInt(componentHandle);
57935
57934
  this._socket.sendRPC(marshal);
57936
57935
  }
57937
57936
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
@@ -57954,10 +57953,10 @@ class RpcClient {
57954
57953
  const ret = returnMarshal.readUInt();
57955
57954
  return ret;
57956
57955
  }
57957
- RPCDestroyMaterialInstances(materialInstanceHandle) {
57956
+ RPCDestroyMaterialInstances(materialInstanceHandles) {
57958
57957
  const marshal = new Marshal();
57959
57958
  marshal.writeString("RPCDestroyMaterialInstances");
57960
- marshal.writeArrayOfUInt(materialInstanceHandle);
57959
+ marshal.writeArrayOfUInt(materialInstanceHandles);
57961
57960
  this._socket.sendRPC(marshal);
57962
57961
  }
57963
57962
  RPCDestroyText(componentHandle) {
@@ -57981,53 +57980,53 @@ class RpcClient {
57981
57980
  const ret = returnMarshal.readSegment();
57982
57981
  return ret;
57983
57982
  }
57984
- async RPCFrameAll(blendTime) {
57983
+ async RPCFrameElements(vimIndex, elementIndices, blendTime) {
57985
57984
  const marshal = new Marshal();
57986
- marshal.writeString("RPCFrameAll");
57985
+ marshal.writeString("RPCFrameElements");
57986
+ marshal.writeUInt(vimIndex);
57987
+ marshal.writeArrayOfUInt(elementIndices);
57987
57988
  marshal.writeFloat(blendTime);
57988
57989
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
57989
57990
  const ret = returnMarshal.readSegment();
57990
57991
  return ret;
57991
57992
  }
57992
- async RPCFrameElements(componentHandle, elementIndices, blendTime) {
57993
+ async RPCFrameScene(blendTime) {
57993
57994
  const marshal = new Marshal();
57994
- marshal.writeString("RPCFrameElements");
57995
- marshal.writeUInt(componentHandle);
57996
- marshal.writeArrayOfUInt(elementIndices);
57995
+ marshal.writeString("RPCFrameScene");
57997
57996
  marshal.writeFloat(blendTime);
57998
57997
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
57999
57998
  const ret = returnMarshal.readSegment();
58000
57999
  return ret;
58001
58000
  }
58002
- async RPCFrameVim(componentHandle, blendTime) {
58001
+ async RPCFrameVim(vimIndex, blendTime) {
58003
58002
  const marshal = new Marshal();
58004
58003
  marshal.writeString("RPCFrameVim");
58005
- marshal.writeUInt(componentHandle);
58004
+ marshal.writeUInt(vimIndex);
58006
58005
  marshal.writeFloat(blendTime);
58007
58006
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58008
58007
  const ret = returnMarshal.readSegment();
58009
58008
  return ret;
58010
58009
  }
58011
- async RPCGetAABBForAll() {
58010
+ async RPCGetAABBForElements(vimIndex, elementIndices) {
58012
58011
  const marshal = new Marshal();
58013
- marshal.writeString("RPCGetAABBForAll");
58012
+ marshal.writeString("RPCGetAABBForElements");
58013
+ marshal.writeUInt(vimIndex);
58014
+ marshal.writeArrayOfUInt(elementIndices);
58014
58015
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58015
58016
  const ret = returnMarshal.readBox3();
58016
58017
  return ret;
58017
58018
  }
58018
- async RPCGetAABBForElements(componentHandle, elementIndices) {
58019
+ async RPCGetAABBForScene() {
58019
58020
  const marshal = new Marshal();
58020
- marshal.writeString("RPCGetAABBForElements");
58021
- marshal.writeUInt(componentHandle);
58022
- marshal.writeArrayOfUInt(elementIndices);
58021
+ marshal.writeString("RPCGetAABBForScene");
58023
58022
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58024
58023
  const ret = returnMarshal.readBox3();
58025
58024
  return ret;
58026
58025
  }
58027
- async RPCGetAABBForVim(componentHandle) {
58026
+ async RPCGetAABBForVim(vimIndex) {
58028
58027
  const marshal = new Marshal();
58029
58028
  marshal.writeString("RPCGetAABBForVim");
58030
- marshal.writeUInt(componentHandle);
58029
+ marshal.writeUInt(vimIndex);
58031
58030
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58032
58031
  const ret = returnMarshal.readBox3();
58033
58032
  return ret;
@@ -58046,18 +58045,25 @@ class RpcClient {
58046
58045
  const ret = returnMarshal.readSegment();
58047
58046
  return ret;
58048
58047
  }
58049
- async RPCGetElementCount(componentHandle) {
58048
+ async RPCGetElementCountForScene() {
58050
58049
  const marshal = new Marshal();
58051
- marshal.writeString("RPCGetElementCount");
58052
- marshal.writeUInt(componentHandle);
58050
+ marshal.writeString("RPCGetElementCountForScene");
58051
+ const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58052
+ const ret = returnMarshal.readUInt();
58053
+ return ret;
58054
+ }
58055
+ async RPCGetElementCountForVim(vimIndex) {
58056
+ const marshal = new Marshal();
58057
+ marshal.writeString("RPCGetElementCountForVim");
58058
+ marshal.writeUInt(vimIndex);
58053
58059
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58054
58060
  const ret = returnMarshal.readUInt();
58055
58061
  return ret;
58056
58062
  }
58057
- async RPCGetElementIds(componentHandle) {
58063
+ async RPCGetElementIds(vimIndex) {
58058
58064
  const marshal = new Marshal();
58059
58065
  marshal.writeString("RPCGetElementIds");
58060
- marshal.writeUInt(componentHandle);
58066
+ marshal.writeUInt(vimIndex);
58061
58067
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58062
58068
  const ret = returnMarshal.readArrayOfUInt64();
58063
58069
  return ret;
@@ -58069,10 +58075,10 @@ class RpcClient {
58069
58075
  const ret = returnMarshal.readString();
58070
58076
  return ret;
58071
58077
  }
58072
- async RPCGetRoomElements(componentHandle) {
58078
+ async RPCGetRoomElements(vimIndex) {
58073
58079
  const marshal = new Marshal();
58074
58080
  marshal.writeString("RPCGetRoomElements");
58075
- marshal.writeUInt(componentHandle);
58081
+ marshal.writeUInt(vimIndex);
58076
58082
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58077
58083
  const ret = returnMarshal.readArrayOfUInt();
58078
58084
  return ret;
@@ -58084,10 +58090,10 @@ class RpcClient {
58084
58090
  const ret = returnMarshal.readSectionBoxState();
58085
58091
  return ret;
58086
58092
  }
58087
- async RPCGetVimLoadingState(componentHandle) {
58093
+ async RPCGetVimLoadingState(vimIndex) {
58088
58094
  const marshal = new Marshal();
58089
58095
  marshal.writeString("RPCGetVimLoadingState");
58090
- marshal.writeUInt(componentHandle);
58096
+ marshal.writeUInt(vimIndex);
58091
58097
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58092
58098
  const ret = returnMarshal.readVimStatus();
58093
58099
  return ret;
@@ -58221,10 +58227,10 @@ class RpcClient {
58221
58227
  marshal.writeRGBA(backgroundColor);
58222
58228
  this._socket.sendRPC(marshal);
58223
58229
  }
58224
- RPCSetMaterialOverrides(componentHandle, elementIndices, materialInstanceHandles) {
58230
+ RPCSetMaterialOverridesForElements(vimIndex, elementIndices, materialInstanceHandles) {
58225
58231
  const marshal = new Marshal();
58226
- marshal.writeString("RPCSetMaterialOverrides");
58227
- marshal.writeUInt(componentHandle);
58232
+ marshal.writeString("RPCSetMaterialOverridesForElements");
58233
+ marshal.writeUInt(vimIndex);
58228
58234
  marshal.writeArrayOfUInt(elementIndices);
58229
58235
  marshal.writeArrayOfUInt(materialInstanceHandles);
58230
58236
  this._socket.sendRPC(marshal);
@@ -58235,25 +58241,31 @@ class RpcClient {
58235
58241
  marshal.writeSectionBoxState(state);
58236
58242
  this._socket.sendRPC(marshal);
58237
58243
  }
58238
- RPCSetStateVim(componentHandle, state) {
58244
+ RPCSetStateElements(vimIndex, elementIndices, state) {
58239
58245
  const marshal = new Marshal();
58240
- marshal.writeString("RPCSetStateVim");
58241
- marshal.writeUInt(componentHandle);
58246
+ marshal.writeString("RPCSetStateElements");
58247
+ marshal.writeUInt(vimIndex);
58248
+ marshal.writeArrayOfUInt(elementIndices);
58242
58249
  marshal.writeUInt(state);
58243
58250
  this._socket.sendRPC(marshal);
58244
58251
  }
58245
- RPCSetStateElements(componentHandle, elementIndices, state) {
58252
+ RPCSetStateScene(state) {
58246
58253
  const marshal = new Marshal();
58247
- marshal.writeString("RPCSetStateElements");
58248
- marshal.writeUInt(componentHandle);
58249
- marshal.writeArrayOfUInt(elementIndices);
58254
+ marshal.writeString("RPCSetStateScene");
58255
+ marshal.writeUInt(state);
58256
+ this._socket.sendRPC(marshal);
58257
+ }
58258
+ RPCSetStateVim(vimIndex, state) {
58259
+ const marshal = new Marshal();
58260
+ marshal.writeString("RPCSetStateVim");
58261
+ marshal.writeUInt(vimIndex);
58250
58262
  marshal.writeUInt(state);
58251
58263
  this._socket.sendRPC(marshal);
58252
58264
  }
58253
- RPCSetStatesElements(componentHandle, elementIndices, states) {
58265
+ RPCSetStatesElements(vimIndex, elementIndices, states) {
58254
58266
  const marshal = new Marshal();
58255
58267
  marshal.writeString("RPCSetStatesElements");
58256
- marshal.writeUInt(componentHandle);
58268
+ marshal.writeUInt(vimIndex);
58257
58269
  marshal.writeArrayOfUInt(elementIndices);
58258
58270
  marshal.writeArrayOfUInt(states);
58259
58271
  this._socket.sendRPC(marshal);
@@ -58281,12 +58293,6 @@ class RpcClient {
58281
58293
  marshal.writeString("RPCUnloadAll");
58282
58294
  this._socket.sendRPC(marshal);
58283
58295
  }
58284
- RPCUnloadVim(componentHandle) {
58285
- const marshal = new Marshal();
58286
- marshal.writeString("RPCUnloadVim");
58287
- marshal.writeUInt(componentHandle);
58288
- this._socket.sendRPC(marshal);
58289
- }
58290
58296
  }
58291
58297
  class RemoteColor {
58292
58298
  /**
@@ -59037,9 +59043,9 @@ class Raycaster3 {
59037
59043
  if (!Validation.isRelativeVector2(position)) return void 0;
59038
59044
  const test2 = await this._rpc.RPCPerformHitTest(position);
59039
59045
  if (!test2) return void 0;
59040
- const vim = this._vims.getFromHandle(test2.vimHandle);
59046
+ const vim = this._vims.getFromHandle(test2.vimIndex);
59041
59047
  if (!vim) return void 0;
59042
- const object = vim.getElement(test2.elementIndex);
59048
+ const object = vim.getElement(test2.vimElementIndex);
59043
59049
  if (!object) return void 0;
59044
59050
  return new UltraRaycastResult(
59045
59051
  object,
@@ -59068,7 +59074,7 @@ const defaultSceneSettings = {
59068
59074
  hdrScale: 1.37,
59069
59075
  hdrBackgroundScale: 1,
59070
59076
  hdrBackgroundSaturation: 1,
59071
- backGroundBlur: 1,
59077
+ backgroundBlur: 1,
59072
59078
  backgroundColor: new RGBA(0.9, 0.9, 0.9, 1)
59073
59079
  };
59074
59080
  var VimLoadingStatus = /* @__PURE__ */ ((VimLoadingStatus2) => {
@@ -59081,15 +59087,26 @@ var VimLoadingStatus = /* @__PURE__ */ ((VimLoadingStatus2) => {
59081
59087
  return VimLoadingStatus2;
59082
59088
  })(VimLoadingStatus || {});
59083
59089
  class RpcSafeClient {
59090
+ /**
59091
+ * Creates a new RpcSafeClient instance.
59092
+ * @param rpc - The underlying RpcClient used for communication
59093
+ * @param batchSize - Maximum size of batched data for operations (default: 10000)
59094
+ */
59084
59095
  constructor(rpc, batchSize = defaultBatchSize) {
59085
59096
  __publicField(this, "rpc");
59086
59097
  __publicField(this, "batchSize");
59087
59098
  this.rpc = rpc;
59088
59099
  this.batchSize = batchSize;
59089
59100
  }
59101
+ /**
59102
+ * The URL used by the underlying RPC connection.
59103
+ */
59090
59104
  get url() {
59091
59105
  return this.rpc.url;
59092
59106
  }
59107
+ /**
59108
+ * Indicates whether the RPC client is currently connected.
59109
+ */
59093
59110
  get connected() {
59094
59111
  return this.rpc.connected;
59095
59112
  }
@@ -59099,9 +59116,10 @@ class RpcSafeClient {
59099
59116
  * and scene-wide settings.
59100
59117
  ******************************************************************************/
59101
59118
  /**
59102
- * Initializes and starts the scene with specified settings.
59119
+ * Initializes and starts the scene with the given settings.
59103
59120
  * @param settings - Optional partial scene settings to override defaults
59104
- * @remarks If no settings are provided, default values will be used
59121
+ * @returns Promise resolving to true if the scene started successfully, false otherwise
59122
+ * @remarks Missing values will be filled from {@link defaultSceneSettings}
59105
59123
  */
59106
59124
  async RPCStartScene(settings2) {
59107
59125
  const s = { ...defaultSceneSettings, ...settings2 ?? {} };
@@ -59111,15 +59129,15 @@ class RpcSafeClient {
59111
59129
  Validation.min0(s.hdrScale),
59112
59130
  Validation.clamp01(s.hdrBackgroundScale),
59113
59131
  Validation.clamp01(s.hdrBackgroundSaturation),
59114
- Validation.clamp01(s.backGroundBlur),
59132
+ Validation.clamp01(s.backgroundBlur),
59115
59133
  Validation.clampRGBA01(s.backgroundColor)
59116
59134
  ),
59117
59135
  false
59118
59136
  );
59119
59137
  }
59120
59138
  /**
59121
- * Sets the lighting settings for the scene.
59122
- * @param settings - The lighting settings to apply
59139
+ * Updates the scene’s lighting configuration.
59140
+ * @param settings - The complete lighting and background settings to apply
59123
59141
  */
59124
59142
  RPCSetLighting(settings2) {
59125
59143
  const s = settings2;
@@ -59128,43 +59146,80 @@ class RpcSafeClient {
59128
59146
  Validation.min0(s.hdrScale),
59129
59147
  Validation.clamp01(s.hdrBackgroundScale),
59130
59148
  Validation.clamp01(s.hdrBackgroundSaturation),
59131
- Validation.clamp01(s.backGroundBlur),
59149
+ Validation.clamp01(s.backgroundBlur),
59132
59150
  Validation.clampRGBA01(s.backgroundColor)
59133
59151
  );
59134
59152
  }
59153
+ /**
59154
+ * Retrieves the total number of elements across the entire scene.
59155
+ * @returns Promise resolving to the total number of elements (0 on failure).
59156
+ */
59157
+ RPCGetElementCountForScene() {
59158
+ return this.safeCall(
59159
+ () => this.rpc.RPCGetElementCountForScene(),
59160
+ 0
59161
+ );
59162
+ }
59163
+ /**
59164
+ * Retrieves the number of elements within a specific loaded vim.
59165
+ * @param vimIndex - Index of the loaded vim to query
59166
+ * @returns Promise resolving to the element count (0 on failure)
59167
+ */
59168
+ RPCGetElementCountForVim(vimIndex) {
59169
+ return this.safeCall(
59170
+ () => this.rpc.RPCGetElementCountForVim(vimIndex),
59171
+ 0
59172
+ );
59173
+ }
59135
59174
  /*******************************************************************************
59136
- * NODE VISIBILITY METHODS
59137
- * Methods for controlling node visibility, including show/hide, ghosting,
59175
+ * ELEMENTS VISIBILITY METHODS
59176
+ * Methods for controlling element visibility, including show/hide, ghosting,
59138
59177
  * and highlighting functionality.
59139
59178
  ******************************************************************************/
59140
59179
  /**
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);
59180
+ * Sets a single visibility state for given elements within a loaded vim.
59181
+ * The operation is automatically split into batches if the array is large.
59182
+ *
59183
+ * @param vimIndex - The index of the loaded vim containing the elements
59184
+ * @param vimElementIndices - Array of vim-based element indices to apply the state to
59185
+ * @param state - The visibility state to apply (e.g., VISIBLE, HIDDEN)
59186
+ */
59187
+ RPCSetStateElements(vimIndex, vimElementIndices, state) {
59188
+ if (vimElementIndices.length === 0) return;
59189
+ if (!Validation.isIndex(vimIndex)) return;
59190
+ if (!Validation.areIndices(vimElementIndices)) return;
59191
+ const batches = batchArray(vimElementIndices, this.batchSize);
59152
59192
  for (const batch of batches) {
59153
- this.rpc.RPCSetStateElements(componentHandle, batch, state);
59193
+ this.rpc.RPCSetStateElements(vimIndex, batch, state);
59154
59194
  }
59155
59195
  }
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);
59196
+ /**
59197
+ * Sets individual visibility states for multiple elements in a vim.
59198
+ * Each element receives a corresponding visibility state from the input array.
59199
+ * The operation is automatically split into batches if the array is large.
59200
+ *
59201
+ * @param vimIndex - The index of the loaded vim
59202
+ * @param vimElementIndices - Array of vim-based element indices
59203
+ * @param states - Array of visibility states to apply, one per element
59204
+ */
59205
+ RPCSetStatesElements(vimIndex, vimElementIndices, states) {
59206
+ if (!Validation.isIndex(vimIndex)) return;
59207
+ if (!Validation.areIndices(vimElementIndices)) return;
59208
+ if (!Validation.areSameLength(vimElementIndices, states)) return;
59209
+ const batches = batchArrays(vimElementIndices, states, this.batchSize);
59161
59210
  for (const [batchedElements, batchedStates] of batches) {
59162
- this.rpc.RPCSetStatesElements(componentHandle, batchedElements, batchedStates);
59211
+ this.rpc.RPCSetStatesElements(vimIndex, batchedElements, batchedStates);
59163
59212
  }
59164
59213
  }
59165
- RPCSetStateVim(componentHandle, state) {
59166
- if (!Validation.isComponentHandle(componentHandle)) return;
59167
- this.rpc.RPCSetStateVim(componentHandle, state);
59214
+ /**
59215
+ * Applies a single visibility state to all elements of a loaded vim.
59216
+ *
59217
+ * @param vimIndex - The index of the loaded vim
59218
+ * @param state - The visibility state to apply (e.g., VISIBLE, HIDDEN)
59219
+ */
59220
+ RPCSetStateVim(vimIndex, state) {
59221
+ if (!Validation.isIndex(vimIndex)) return;
59222
+ this.rpc.RPCSetStateVim(vimIndex, state);
59168
59223
  }
59169
59224
  /*******************************************************************************
59170
59225
  * TEXT AND UI METHODS
@@ -59176,7 +59231,6 @@ class RpcSafeClient {
59176
59231
  * @param color - The color of the text
59177
59232
  * @param text - The content to display
59178
59233
  * @returns Promise resolving to the handle of the created text component
59179
- * @throws {Error} If the text is empty
59180
59234
  */
59181
59235
  async RPCCreateText(position, color, text) {
59182
59236
  if (!Validation.isNonEmptyString(text)) return INVALID_HANDLE;
@@ -59189,19 +59243,26 @@ class RpcSafeClient {
59189
59243
  /**
59190
59244
  * Destroys a text component, removing it from the scene.
59191
59245
  * @param componentHandle - The handle of the text component to destroy
59192
- * @throws {Error} If the component handle is invalid
59193
59246
  */
59194
59247
  RPCDestroyText(componentHandle) {
59195
- if (!Validation.isComponentHandle(componentHandle)) return;
59248
+ if (!Validation.isIndex(componentHandle)) return;
59196
59249
  this.rpc.RPCDestroyText(componentHandle);
59197
59250
  }
59198
59251
  /*******************************************************************************
59199
59252
  * SECTION BOX METHODS
59200
59253
  * Methods for controlling section box visibility and position.
59201
59254
  ******************************************************************************/
59255
+ /**
59256
+ * Enables or disables the section box.
59257
+ * @param enable - True to enable the section box, false to disable it
59258
+ */
59202
59259
  RPCEnableSectionBox(enable) {
59203
59260
  this.rpc.RPCEnableSectionBox(enable);
59204
59261
  }
59262
+ /**
59263
+ * Sets the parameters of the section box.
59264
+ * @param state - The new section box state, including visibility and bounding box
59265
+ */
59205
59266
  RPCSetSectionBox(state) {
59206
59267
  this.rpc.RPCSetSectionBox(
59207
59268
  {
@@ -59210,6 +59271,10 @@ class RpcSafeClient {
59210
59271
  }
59211
59272
  );
59212
59273
  }
59274
+ /**
59275
+ * Retrieves the current section box state.
59276
+ * @returns Promise resolving to the section box state or undefined on failure
59277
+ */
59213
59278
  async RPCGetSectionBox() {
59214
59279
  return await this.safeCall(
59215
59280
  () => this.rpc.RPCGetSectionBox(),
@@ -59266,52 +59331,52 @@ class RpcSafeClient {
59266
59331
  }
59267
59332
  /**
59268
59333
  * Retrieves the axis-aligned bounding box (AABB) that encompasses the entire scene.
59269
- * This includes all loaded geometry across all VIM components.
59334
+ * This includes all loaded geometry across all loaded vims.
59270
59335
  *
59271
59336
  * @returns Promise resolving to the global AABB of the scene, or undefined on failure
59272
59337
  */
59273
- RPCGetAABBForAll() {
59338
+ RPCGetAABBForScene() {
59274
59339
  return this.safeCall(
59275
- () => this.rpc.RPCGetAABBForAll(),
59340
+ () => this.rpc.RPCGetAABBForScene(),
59276
59341
  void 0
59277
59342
  );
59278
59343
  }
59279
59344
  /**
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.
59345
+ * Retrieves the axis-aligned bounding box (AABB) for a specific loaded vim.
59346
+ * This bounding box represents the spatial bounds of all geometry within the given loaded vim.
59282
59347
  *
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
59348
+ * @param vimIndex - The index of the loaded vim to query
59349
+ * @returns Promise resolving to the vim bounding box, or undefined on failure
59285
59350
  */
59286
- async RPCGetAABBForVim(componentHandle) {
59351
+ async RPCGetAABBForVim(vimIndex) {
59352
+ if (!Validation.isIndex(vimIndex)) return void 0;
59287
59353
  return await this.safeCall(
59288
- () => this.rpc.RPCGetAABBForVim(componentHandle),
59354
+ () => this.rpc.RPCGetAABBForVim(vimIndex),
59289
59355
  void 0
59290
59356
  );
59291
59357
  }
59292
59358
  /**
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
59359
+ * Calculates the bounding box for specified elements of a loaded vim.
59360
+ * Large element arrays are automatically processed in batches.
59361
+ * @param vimIndex - The index of the loaded vim
59362
+ * @param vimElementIndices - Array of vim-based element indices to calculate bounds for
59363
+ * @returns Promise resolving to the combined bounding box or undefined on failure
59299
59364
  */
59300
- async RPCGetAABBForElements(componentHandle, elements) {
59301
- if (!Validation.isComponentHandle(componentHandle)) return;
59302
- if (!Validation.areComponentHandles(elements)) return;
59365
+ async RPCGetAABBForElements(vimIndex, vimElementIndices) {
59366
+ if (!Validation.isIndex(vimIndex)) return;
59367
+ if (!Validation.areIndices(vimElementIndices)) return;
59303
59368
  return await this.safeCall(
59304
- () => this.RPCGetAABBForElementsBatched(componentHandle, elements),
59369
+ () => this.RPCGetAABBForElementsBatched(vimIndex, vimElementIndices),
59305
59370
  void 0
59306
59371
  );
59307
59372
  }
59308
- async RPCGetAABBForElementsBatched(componentHandle, elements) {
59309
- if (elements.length === 0) {
59373
+ async RPCGetAABBForElementsBatched(vimIndex, vimElementIndices) {
59374
+ if (vimElementIndices.length === 0) {
59310
59375
  return new Box3();
59311
59376
  }
59312
- const batches = batchArray(elements, this.batchSize);
59377
+ const batches = batchArray(vimElementIndices, this.batchSize);
59313
59378
  const promises = batches.map(async (batch) => {
59314
- const aabb = await this.rpc.RPCGetAABBForElements(componentHandle, batch);
59379
+ const aabb = await this.rpc.RPCGetAABBForElements(vimIndex, batch);
59315
59380
  const v1 = new Vector3(aabb.min.x, aabb.min.y, aabb.min.z);
59316
59381
  const v2 = new Vector3(aabb.max.x, aabb.max.y, aabb.max.z);
59317
59382
  return new Box3(v1, v2);
@@ -59322,53 +59387,51 @@ class RpcSafeClient {
59322
59387
  return box;
59323
59388
  }
59324
59389
  /**
59325
- * Frames the camera to show all components in the scene.
59390
+ * Frames the camera to show all elements in the scene.
59326
59391
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59327
59392
  * @returns Promise resolving to camera segment representing the final position
59328
59393
  */
59329
- async RPCFrameAll(blendTime) {
59394
+ async RPCFrameScene(blendTime) {
59330
59395
  blendTime = Validation.clamp01(blendTime);
59331
59396
  return await this.safeCall(
59332
- () => this.rpc.RPCFrameAll(blendTime),
59397
+ () => this.rpc.RPCFrameScene(blendTime),
59333
59398
  void 0
59334
59399
  );
59335
59400
  }
59336
59401
  /**
59337
- * Frames a specific VIM component in the scene.
59338
- * @param componentHandle - The handle of the VIM component to frame
59402
+ * Frames a specific vim in the scene.
59403
+ * @param vimIndex - The index of the loaded vim to frame
59339
59404
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59340
59405
  * @returns Promise resolving to camera segment representing the final position
59341
- * @throws {Error} If the component handle is invalid
59342
59406
  */
59343
- async RPCFrameVim(componentHandle, blendTime) {
59344
- if (!Validation.isComponentHandle(componentHandle)) return;
59407
+ async RPCFrameVim(vimIndex, blendTime) {
59408
+ if (!Validation.isIndex(vimIndex)) return;
59345
59409
  blendTime = Validation.clamp01(blendTime);
59346
59410
  return await this.safeCall(
59347
- () => this.rpc.RPCFrameVim(componentHandle, blendTime),
59411
+ () => this.rpc.RPCFrameVim(vimIndex, blendTime),
59348
59412
  void 0
59349
59413
  );
59350
59414
  }
59351
59415
  /**
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
59416
+ * Frames specific elements of a loaded vim.
59417
+ * Automatically batches large arrays of elements.
59418
+ * @param vimIndex - The index of the loaded vim
59419
+ * @param vimElementIndices - Array of vim-based element indices to frame
59356
59420
  * @param blendTime - Duration of the camera transition in seconds (non-negative)
59357
59421
  * @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
59422
  */
59360
- async RPCFrameElements(componentHandle, elements, blendTime) {
59361
- if (!Validation.isComponentHandle(componentHandle)) return;
59362
- if (!Validation.areComponentHandles(elements)) return;
59423
+ async RPCFrameElements(vimIndex, vimElementIndices, blendTime) {
59424
+ if (!Validation.isIndex(vimIndex)) return;
59425
+ if (!Validation.areIndices(vimElementIndices)) return;
59363
59426
  blendTime = Validation.clamp01(blendTime);
59364
- if (elements.length < this.batchSize) {
59427
+ if (vimElementIndices.length < this.batchSize) {
59365
59428
  return await this.safeCall(
59366
- () => this.rpc.RPCFrameElements(componentHandle, elements, blendTime),
59429
+ () => this.rpc.RPCFrameElements(vimIndex, vimElementIndices, blendTime),
59367
59430
  void 0
59368
59431
  );
59369
59432
  } else {
59370
59433
  const box = await this.safeCall(
59371
- () => this.RPCGetAABBForElementsBatched(componentHandle, elements),
59434
+ () => this.RPCGetAABBForElementsBatched(vimIndex, vimElementIndices),
59372
59435
  void 0
59373
59436
  );
59374
59437
  if (!box) return void 0;
@@ -59382,7 +59445,6 @@ class RpcSafeClient {
59382
59445
  * Frames the camera to show a specific bounding box.
59383
59446
  * @param box - The bounding box to frame
59384
59447
  * @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
59448
  */
59387
59449
  async RPCFrameAABB(box, blendTime) {
59388
59450
  if (!Validation.isValidBox(box)) return;
@@ -59399,12 +59461,15 @@ class RpcSafeClient {
59399
59461
  /**
59400
59462
  * Sets the camera movement speed.
59401
59463
  * @param speed - The desired movement speed (must be positive)
59402
- * @throws {Error} If speed is not positive
59403
59464
  */
59404
59465
  RPCSetCameraSpeed(speed) {
59405
59466
  speed = Validation.min0(speed);
59406
59467
  this.rpc.RPCSetCameraSpeed(speed);
59407
59468
  }
59469
+ /**
59470
+ * Sets the camera control mode.
59471
+ * @param mode - The desired input mode (e.g., {@link InputMode.Orbit} or {@link InputMode.Free})
59472
+ */
59408
59473
  RPCSetCameraMode(mode) {
59409
59474
  this.rpc.RPCSetCameraMode(
59410
59475
  mode === "orbit"
@@ -59413,9 +59478,8 @@ class RpcSafeClient {
59413
59478
  }
59414
59479
  /**
59415
59480
  * 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
59481
+ * @param width - The width of the desired aspect ratio
59482
+ * @param height - The height of the desired aspect ratio
59419
59483
  */
59420
59484
  RPCSetCameraAspectRatio(width, height) {
59421
59485
  if (!Validation.isPositiveInteger(width)) return;
@@ -59424,13 +59488,12 @@ class RpcSafeClient {
59424
59488
  }
59425
59489
  /*******************************************************************************
59426
59490
  * VIM FILE MANAGEMENT METHODS
59427
- * Methods for loading, unloading, and managing VIM files and components.
59491
+ * Methods for loading, unloading, and managing VIM files.
59428
59492
  ******************************************************************************/
59429
59493
  /**
59430
59494
  * Loads a VIM file from the local filesystem.
59431
59495
  * @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
59496
+ * @returns Promise resolving to the index of the loaded vim
59434
59497
  */
59435
59498
  async RPCLoadVim(source) {
59436
59499
  if (!Validation.isNonEmptyString(source.url)) return INVALID_HANDLE;
@@ -59442,9 +59505,8 @@ class RpcSafeClient {
59442
59505
  }
59443
59506
  /**
59444
59507
  * 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
59508
+ * @param source - The URL or file path of the VIM file to load
59509
+ * @returns Promise resolving to the index of the loaded vim
59448
59510
  */
59449
59511
  async RPCLoadVimURL(source) {
59450
59512
  if (!Validation.isURL(source.url)) return INVALID_HANDLE;
@@ -59454,17 +59516,16 @@ class RpcSafeClient {
59454
59516
  );
59455
59517
  }
59456
59518
  /**
59457
- * Retrieves the current loading state and progress of a VIM component.
59458
- * @param componentHandle - The handle of the VIM component
59519
+ * Retrieves the current loading state and progress of a vim.
59520
+ * @param vimIndex - The index of the vim being loaded
59459
59521
  * @returns Promise resolving to the current loading state and progress
59460
- * @throws {Error} If the component handle is invalid
59461
59522
  */
59462
- async RPCGetVimLoadingState(componentHandle) {
59463
- if (!Validation.isComponentHandle(componentHandle)) {
59523
+ async RPCGetVimLoadingState(vimIndex) {
59524
+ if (!Validation.isIndex(vimIndex)) {
59464
59525
  return { status: 0, progress: 0 };
59465
59526
  }
59466
59527
  const result = await this.safeCall(
59467
- () => this.rpc.RPCGetVimLoadingState(componentHandle),
59528
+ () => this.rpc.RPCGetVimLoadingState(vimIndex),
59468
59529
  { status: 0, progress: 0 }
59469
59530
  );
59470
59531
  if (!(result.status in VimLoadingStatus)) {
@@ -59473,16 +59534,7 @@ class RpcSafeClient {
59473
59534
  return result;
59474
59535
  }
59475
59536
  /**
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.
59537
+ * Clears the entire scene, unloading all vims and resetting to initial state.
59486
59538
  */
59487
59539
  RPCUnloadAll() {
59488
59540
  this.rpc.RPCUnloadAll();
@@ -59498,7 +59550,7 @@ class RpcSafeClient {
59498
59550
  /**
59499
59551
  * Performs hit testing at a specified screen position.
59500
59552
  * @param pos - Normalized screen coordinates (0-1, 0-1)
59501
- * @returns Promise resolving to hit test result if something was hit, undefined otherwise
59553
+ * @returns Promise resolving to hit test result if a valid hit was detected, undefined otherwise
59502
59554
  */
59503
59555
  async RPCPerformHitTest(pos) {
59504
59556
  if (!Validation.isRelativeVector2(pos)) return;
@@ -59506,7 +59558,7 @@ class RpcSafeClient {
59506
59558
  () => this.rpc.RPCPerformHitTest(pos),
59507
59559
  void 0
59508
59560
  );
59509
- if (!result || result.nodeIndex < 0) {
59561
+ if (!result || result.vimIndex === INVALID_HANDLE) {
59510
59562
  return void 0;
59511
59563
  }
59512
59564
  return result;
@@ -59516,7 +59568,6 @@ class RpcSafeClient {
59516
59568
  * @param position - The normalized screen coordinates (0-1, 0-1)
59517
59569
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59518
59570
  * @param down - True if button is pressed down, false if released
59519
- * @throws {Error} If mouseButton is not a valid positive integer
59520
59571
  */
59521
59572
  RPCMouseButtonEvent(position, mouseButton, down) {
59522
59573
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59527,7 +59578,6 @@ class RpcSafeClient {
59527
59578
  * Sends a mouse double-click event to the viewer.
59528
59579
  * @param position - The normalized screen coordinates (0-1, 0-1)
59529
59580
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59530
- * @throws {Error} If mouseButton is not a valid positive integer
59531
59581
  */
59532
59582
  RPCMouseDoubleClickEvent(position, mouseButton) {
59533
59583
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59554,7 +59604,6 @@ class RpcSafeClient {
59554
59604
  * Sends a mouse selection event to the viewer.
59555
59605
  * @param position - The normalized screen coordinates (0-1, 0-1)
59556
59606
  * @param mouseButton - The mouse button code (0=left, 1=middle, 2=right)
59557
- * @throws {Error} If mouseButton is not a valid positive integer
59558
59607
  */
59559
59608
  RPCMouseSelectEvent(position, mouseButton) {
59560
59609
  if (!Validation.isPositiveInteger(mouseButton)) return;
@@ -59581,7 +59630,6 @@ class RpcSafeClient {
59581
59630
  * @param smoothness - The smoothness value to apply (clamped between 0 and 1)
59582
59631
  * @param colors - Array of colors for each material instance
59583
59632
  * @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
59633
  */
59586
59634
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
59587
59635
  if (!Validation.isMaterialHandle(materialHandle)) return;
@@ -59604,46 +59652,41 @@ class RpcSafeClient {
59604
59652
  }
59605
59653
  /**
59606
59654
  * 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
59655
+ * @param materialInstanceHandles - Array of handles for material instances to destroy
59609
59656
  */
59610
- RPCDestroyMaterialInstances(materialInstanceHandle) {
59611
- if (!Validation.areComponentHandles(materialInstanceHandle)) return;
59612
- this.rpc.RPCDestroyMaterialInstances(materialInstanceHandle);
59657
+ RPCDestroyMaterialInstances(materialInstanceHandles) {
59658
+ if (!Validation.areIndices(materialInstanceHandles)) return;
59659
+ this.rpc.RPCDestroyMaterialInstances(materialInstanceHandles);
59613
59660
  }
59614
59661
  /**
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
59662
+ * Sets material overrides for specific elements in a loaded vim.
59663
+ * Large arrays are automatically processed in batches.
59664
+ * @param vimIndex - The index of the loaded vim
59665
+ * @param vimElementIndices - Array of vim-based element indices to override
59666
+ * @param materialInstanceHandles - Array of material instance handles to apply (must match element length)
59621
59667
  */
59622
- RPCSetMaterialOverrides(componentHandle, nodes, materialInstanceHandles) {
59623
- if (!Validation.areSameLength(nodes, materialInstanceHandles)) return;
59624
- if (!Validation.isComponentHandle(componentHandle)) return;
59625
- if (!Validation.areComponentHandles(nodes)) return;
59668
+ RPCSetMaterialOverridesForElements(vimIndex, vimElementIndices, materialInstanceHandles) {
59669
+ if (!Validation.areSameLength(vimElementIndices, materialInstanceHandles)) return;
59670
+ if (!Validation.isIndex(vimIndex)) return;
59671
+ if (!Validation.areIndices(vimElementIndices)) return;
59626
59672
  if (!Validation.areIntegers(materialInstanceHandles)) return;
59627
59673
  this.setMaterialOverridesBatched(
59628
- componentHandle,
59629
- nodes,
59674
+ vimIndex,
59675
+ vimElementIndices,
59630
59676
  materialInstanceHandles
59631
59677
  );
59632
59678
  }
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);
59679
+ setMaterialOverridesBatched(vimIndex, vimElementIndices, materialInstanceHandles) {
59680
+ const batches = batchArrays(vimElementIndices, materialInstanceHandles, this.batchSize);
59681
+ for (const [batchedElements, batchedMaterials] of batches) {
59682
+ this.rpc.RPCSetMaterialOverridesForElements(vimIndex, batchedElements, batchedMaterials);
59637
59683
  }
59638
59684
  }
59639
59685
  /**
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
59686
+ * Clears all material overrides for the entire scene.
59643
59687
  */
59644
- RPCClearMaterialOverrides(componentHandle) {
59645
- if (!Validation.isComponentHandle(componentHandle)) return;
59646
- this.rpc.RPCClearMaterialOverrides(componentHandle);
59688
+ RPCClearMaterialOverrides() {
59689
+ this.rpc.RPCClearMaterialOverrides();
59647
59690
  }
59648
59691
  /*******************************************************************************
59649
59692
  * DEBUG AND UTILITY METHODS
@@ -59793,7 +59836,7 @@ class Renderer2 {
59793
59836
  * @returns Current background blur
59794
59837
  */
59795
59838
  get backgroundBlur() {
59796
- return this._settings.backGroundBlur;
59839
+ return this._settings.backgroundBlur;
59797
59840
  }
59798
59841
  /**
59799
59842
  * Gets the background color
@@ -59864,8 +59907,8 @@ class Renderer2 {
59864
59907
  */
59865
59908
  set backgroundBlur(value) {
59866
59909
  value = Validation.clamp01(value);
59867
- if (this._settings.backGroundBlur === value) return;
59868
- this._settings.backGroundBlur = value;
59910
+ if (this._settings.backgroundBlur === value) return;
59911
+ this._settings.backgroundBlur = value;
59869
59912
  this._updateLighting = true;
59870
59913
  this.requestSettingsUpdate();
59871
59914
  }
@@ -59881,7 +59924,7 @@ class Renderer2 {
59881
59924
  this.requestSettingsUpdate();
59882
59925
  }
59883
59926
  getBoundingBox() {
59884
- return this._rpc.RPCGetAABBForAll();
59927
+ return this._rpc.RPCGetAABBForScene();
59885
59928
  }
59886
59929
  /**
59887
59930
  * Requests an update to be performed on the next animation frame.
@@ -60020,7 +60063,7 @@ var VisibilityState$1 = /* @__PURE__ */ ((VisibilityState2) => {
60020
60063
  VisibilityState2[VisibilityState2["GHOSTED_HIGHLIGHTED"] = 18] = "GHOSTED_HIGHLIGHTED";
60021
60064
  return VisibilityState2;
60022
60065
  })(VisibilityState$1 || {});
60023
- class StateSynchronizer {
60066
+ class VisibilitySynchronizer {
60024
60067
  /**
60025
60068
  * Creates a new StateSynchronizer instance.
60026
60069
  *
@@ -60038,7 +60081,7 @@ class StateSynchronizer {
60038
60081
  __publicField(this, "_onUpdate");
60039
60082
  __publicField(this, "_isConnected");
60040
60083
  __publicField(this, "_animationFrame");
60041
- this._tracker = new StateTracker(defaultState);
60084
+ this._tracker = new VisibilityTracker(defaultState);
60042
60085
  this._rpc = rpc;
60043
60086
  this._onUpdate = onUpdate;
60044
60087
  this._getHandle = getHandle;
@@ -60087,7 +60130,7 @@ class StateSynchronizer {
60087
60130
  * @param elementIndex - The element index to update
60088
60131
  * @param state - The new state to apply
60089
60132
  */
60090
- setElementState(elementIndex, state) {
60133
+ setStateForElement(elementIndex, state) {
60091
60134
  this._tracker.setState(elementIndex, state);
60092
60135
  this.scheduleUpdate();
60093
60136
  }
@@ -60151,7 +60194,7 @@ class StateSynchronizer {
60151
60194
  this._onUpdate();
60152
60195
  }
60153
60196
  }
60154
- class StateTracker {
60197
+ class VisibilityTracker {
60155
60198
  /**
60156
60199
  * Creates a new StateTracker instance.
60157
60200
  *
@@ -60788,7 +60831,7 @@ class Element3D2 {
60788
60831
  return this.vim.visibility.getElementState(this.element);
60789
60832
  }
60790
60833
  set state(state) {
60791
- this.vim.visibility.setElementState(this.element, state);
60834
+ this.vim.visibility.setStateForElement(this.element, state);
60792
60835
  }
60793
60836
  /**
60794
60837
  * Gets or sets the color override of the element.
@@ -60818,19 +60861,21 @@ class Vim2 {
60818
60861
  __publicField(this, "_renderer");
60819
60862
  __publicField(this, "_logger");
60820
60863
  // The StateSynchronizer wraps a StateTracker and handles RPC synchronization.
60864
+ // Should be private
60821
60865
  __publicField(this, "visibility");
60822
60866
  // Color tracking remains unchanged.
60823
60867
  __publicField(this, "_nodeColors", /* @__PURE__ */ new Map());
60824
60868
  __publicField(this, "_updatedColors", /* @__PURE__ */ new Set());
60825
60869
  // Delayed update flag.
60826
60870
  __publicField(this, "_updateScheduled", false);
60871
+ __publicField(this, "_elementCount", 0);
60827
60872
  __publicField(this, "_objects", /* @__PURE__ */ new Map());
60828
60873
  this._rpc = rpc;
60829
60874
  this.source = source;
60830
60875
  this._colors = color;
60831
60876
  this._renderer = renderer;
60832
60877
  this._logger = logger;
60833
- this.visibility = new StateSynchronizer(
60878
+ this.visibility = new VisibilitySynchronizer(
60834
60879
  this._rpc,
60835
60880
  () => this._handle,
60836
60881
  () => this.connected,
@@ -60857,7 +60902,10 @@ class Vim2 {
60857
60902
  throw new Error("Method not implemented.");
60858
60903
  }
60859
60904
  getAllElements() {
60860
- throw new Error("Method not implemented.");
60905
+ for (var i = 0; i < this._elementCount; i++) {
60906
+ this.getElement(i);
60907
+ }
60908
+ return Array.from(this._objects.values());
60861
60909
  }
60862
60910
  get handle() {
60863
60911
  return this._handle;
@@ -60888,7 +60936,6 @@ class Vim2 {
60888
60936
  (_a3 = this._request) == null ? void 0 : _a3.error("cancelled", "The request was cancelled");
60889
60937
  this._request = void 0;
60890
60938
  if (this.connected) {
60891
- this._rpc.RPCUnloadVim(this._handle);
60892
60939
  this._handle = -1;
60893
60940
  }
60894
60941
  }
@@ -60910,12 +60957,12 @@ class Vim2 {
60910
60957
  case VimLoadingStatus.FailedToDownload:
60911
60958
  case VimLoadingStatus.FailedToLoad:
60912
60959
  case VimLoadingStatus.Unknown:
60913
- this._rpc.RPCUnloadVim(handle);
60914
60960
  const details = await this._rpc.RPCGetLastError();
60915
60961
  const error = this.getErrorType(state.status);
60916
60962
  return result.error(error, details);
60917
60963
  case VimLoadingStatus.Done:
60918
60964
  this._handle = handle;
60965
+ this._elementCount = await this._rpc.RPCGetElementCountForVim(handle);
60919
60966
  return result.success(this);
60920
60967
  }
60921
60968
  } catch (e) {
@@ -60996,18 +61043,18 @@ class Vim2 {
60996
61043
  }
60997
61044
  this.scheduleColorUpdate();
60998
61045
  }
60999
- clearColor(nodes) {
61000
- if (nodes === "all") {
61046
+ clearColor(elements) {
61047
+ if (elements === "all") {
61001
61048
  this._nodeColors.clear();
61002
61049
  } else {
61003
- nodes.forEach((n) => this._nodeColors.delete(n));
61050
+ elements.forEach((n) => this._nodeColors.delete(n));
61004
61051
  }
61005
61052
  if (!this.connected) return;
61006
- if (nodes === "all") {
61007
- this._rpc.RPCClearMaterialOverrides(this._handle);
61053
+ if (elements === "all") {
61054
+ this._rpc.RPCClearMaterialOverrides();
61008
61055
  } else {
61009
- const ids = new Array(nodes.length).fill(MaterialHandles.Invalid);
61010
- this._rpc.RPCSetMaterialOverrides(this._handle, nodes, ids);
61056
+ const ids = new Array(elements.length).fill(MaterialHandles.Invalid);
61057
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, ids);
61011
61058
  }
61012
61059
  }
61013
61060
  reapplyColors() {
@@ -61032,7 +61079,7 @@ class Vim2 {
61032
61079
  const colors = nodes.map((n) => this._nodeColors.get(n));
61033
61080
  const remoteColors = await this._colors.getColors(colors);
61034
61081
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61035
- this._rpc.RPCSetMaterialOverrides(this._handle, nodes, colorIds);
61082
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, nodes, colorIds);
61036
61083
  this._updatedColors.clear();
61037
61084
  }
61038
61085
  }
@@ -61333,6 +61380,9 @@ let Viewer$2 = class Viewer2 {
61333
61380
  this._vims.getAll().forEach((vim) => vim.disconnect());
61334
61381
  this._vims.clear();
61335
61382
  }
61383
+ getElement3Ds() {
61384
+ return this.rpc.RPCGetElementCountForScene();
61385
+ }
61336
61386
  /**
61337
61387
  * Disposes all resources used by the viewer and disconnects from the server.
61338
61388
  */