vim-web 0.5.0-dev.7 → 0.5.0-dev.9

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
@@ -57927,9 +57927,22 @@ class RpcClient {
57927
57927
  get url() {
57928
57928
  return this._socket.url;
57929
57929
  }
57930
- RPCClearMaterialOverrides() {
57930
+ RPCClearMaterialOverridesForElements(vimIndex, elementIndices) {
57931
57931
  const marshal = new Marshal();
57932
- marshal.writeString("RPCClearMaterialOverrides");
57932
+ marshal.writeString("RPCClearMaterialOverridesForElements");
57933
+ marshal.writeUInt(vimIndex);
57934
+ marshal.writeArrayOfUInt(elementIndices);
57935
+ this._socket.sendRPC(marshal);
57936
+ }
57937
+ RPCClearMaterialOverridesForScene() {
57938
+ const marshal = new Marshal();
57939
+ marshal.writeString("RPCClearMaterialOverridesForScene");
57940
+ this._socket.sendRPC(marshal);
57941
+ }
57942
+ RPCClearMaterialOverridesForVim(vimIndex) {
57943
+ const marshal = new Marshal();
57944
+ marshal.writeString("RPCClearMaterialOverridesForVim");
57945
+ marshal.writeUInt(vimIndex);
57933
57946
  this._socket.sendRPC(marshal);
57934
57947
  }
57935
57948
  async RPCCreateMaterialInstances(materialHandle, smoothness, colors) {
@@ -58037,9 +58050,9 @@ class RpcClient {
58037
58050
  const ret = returnMarshal.readString();
58038
58051
  return ret;
58039
58052
  }
58040
- async RPCGetCameraView() {
58053
+ async RPCGetCameraPose() {
58041
58054
  const marshal = new Marshal();
58042
- marshal.writeString("RPCGetCameraView");
58055
+ marshal.writeString("RPCGetCameraPose");
58043
58056
  const returnMarshal = await this._socket.sendRPCWithReturn(marshal);
58044
58057
  const ret = returnMarshal.readSegment();
58045
58058
  return ret;
@@ -58182,6 +58195,13 @@ class RpcClient {
58182
58195
  marshal.writeBoolean(orbit2);
58183
58196
  this._socket.sendRPC(marshal);
58184
58197
  }
58198
+ RPCSetCameraPose(state, blendTime) {
58199
+ const marshal = new Marshal();
58200
+ marshal.writeString("RPCSetCameraPose");
58201
+ marshal.writeSegment(state);
58202
+ marshal.writeFloat(blendTime);
58203
+ this._socket.sendRPC(marshal);
58204
+ }
58185
58205
  RPCSetCameraPosition(position, blendTime) {
58186
58206
  const marshal = new Marshal();
58187
58207
  marshal.writeString("RPCSetCameraPosition");
@@ -58202,13 +58222,6 @@ class RpcClient {
58202
58222
  marshal.writeFloat(blendTime);
58203
58223
  this._socket.sendRPC(marshal);
58204
58224
  }
58205
- RPCSetCameraView(state, blendTime) {
58206
- const marshal = new Marshal();
58207
- marshal.writeString("RPCSetCameraView");
58208
- marshal.writeSegment(state);
58209
- marshal.writeFloat(blendTime);
58210
- this._socket.sendRPC(marshal);
58211
- }
58212
58225
  RPCSetGhostColor(ghostColor) {
58213
58226
  const marshal = new Marshal();
58214
58227
  marshal.writeString("RPCSetGhostColor");
@@ -58368,7 +58381,7 @@ class ColorManager {
58368
58381
  }
58369
58382
  /**
58370
58383
  * Creates or retrieves cached color instances for multiple hex values.
58371
- * @param colors - Array of RGBA32 color values
58384
+ * @param colors - Array of color values or undefined for no color
58372
58385
  * @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
58373
58386
  * @remarks Duplicate hex values will be mapped to the same color instance for efficiency
58374
58387
  */
@@ -58378,15 +58391,23 @@ class ColorManager {
58378
58391
  const toCreate = [];
58379
58392
  for (let i = 0; i < colors.length; i++) {
58380
58393
  const color = colors[i];
58381
- const hex = color.getHex();
58382
- if (this._hexToColor.has(hex)) {
58383
- result[i] = this._hexToColor.get(hex);
58384
- } else if (hexToIndices.has(hex)) {
58394
+ if (color === void 0) {
58395
+ result[i] = void 0;
58396
+ continue;
58397
+ }
58398
+ const hex = (color == null ? void 0 : color.getHex()) ?? -1;
58399
+ const remoteColor = this._hexToColor.get(hex);
58400
+ if (remoteColor) {
58401
+ result[i] = remoteColor;
58402
+ continue;
58403
+ }
58404
+ const indices = hexToIndices.get(hex);
58405
+ if (indices) {
58385
58406
  hexToIndices.get(hex).push(i);
58386
- } else {
58387
- toCreate.push(color);
58388
- hexToIndices.set(hex, [i]);
58407
+ continue;
58389
58408
  }
58409
+ toCreate.push(color);
58410
+ hexToIndices.set(hex, [i]);
58390
58411
  }
58391
58412
  const remoteColors = await this._createColors(toCreate);
58392
58413
  if (!remoteColors) return void 0;
@@ -59270,7 +59291,7 @@ class RpcSafeClient {
59270
59291
  */
59271
59292
  async RPCGetCameraView() {
59272
59293
  return await this.safeCall(
59273
- () => this.rpc.RPCGetCameraView(),
59294
+ () => this.rpc.RPCGetCameraPose(),
59274
59295
  void 0
59275
59296
  );
59276
59297
  }
@@ -59282,7 +59303,7 @@ class RpcSafeClient {
59282
59303
  RPCSetCameraView(segment, blendTime) {
59283
59304
  if (!Validation.isValidSegment(segment)) return;
59284
59305
  blendTime = Validation.clamp01(blendTime);
59285
- this.rpc.RPCSetCameraView(segment, blendTime);
59306
+ this.rpc.RPCSetCameraPose(segment, blendTime);
59286
59307
  }
59287
59308
  /**
59288
59309
  * Sets the camera's position without changing its target.
@@ -59664,8 +59685,23 @@ class RpcSafeClient {
59664
59685
  /**
59665
59686
  * Clears all material overrides for the entire scene.
59666
59687
  */
59667
- RPCClearMaterialOverrides() {
59668
- this.rpc.RPCClearMaterialOverrides();
59688
+ RPCClearMaterialOverridesForScene() {
59689
+ this.rpc.RPCClearMaterialOverridesForScene();
59690
+ }
59691
+ /**
59692
+ * Clears all material overrides for a specific loaded vim.
59693
+ * @param vimIndex - The index of the loaded vim
59694
+ */
59695
+ RPCClearMaterialOverridesForVim(vimIndex) {
59696
+ this.rpc.RPCClearMaterialOverridesForVim(vimIndex);
59697
+ }
59698
+ /**
59699
+ * Clears all material overrides for specific elements in a loaded vim.
59700
+ * @param vimIndex - The index of the loaded vim
59701
+ * @param vimElementIndices - Array of vim-based element indices to clear overrides for
59702
+ */
59703
+ RPCClearMaterialOverridesForElements(vimIndex, vimElementIndices) {
59704
+ this.rpc.RPCClearMaterialOverridesForElements(vimIndex, vimElementIndices);
59669
59705
  }
59670
59706
  /*******************************************************************************
59671
59707
  * DEBUG AND UTILITY METHODS
@@ -61018,25 +61054,26 @@ class Vim2 {
61018
61054
  const colors = new Array(elementIndex.length).fill(color);
61019
61055
  this.applyColor(elementIndex, colors);
61020
61056
  }
61021
- async setColors(nodes, color) {
61022
- if (color.length !== nodes.length) {
61023
- throw new Error("Color and nodes length must be equal");
61057
+ async setColors(elements, color) {
61058
+ if (color.length !== elements.length) {
61059
+ throw new Error("Color and elements length must be equal");
61024
61060
  }
61025
- this.applyColor(nodes, color);
61061
+ this.applyColor(elements, color);
61026
61062
  }
61027
- applyColor(nodes, color) {
61063
+ applyColor(elements, color) {
61028
61064
  for (let i = 0; i < color.length; i++) {
61029
61065
  const c = color[i];
61030
- const n = nodes[i];
61066
+ const element = elements[i];
61031
61067
  if (c === void 0) {
61032
- this._elementColors.delete(n);
61068
+ this._elementColors.delete(element);
61033
61069
  } else {
61034
- this._elementColors.set(n, c);
61070
+ this._elementColors.set(element, c);
61035
61071
  }
61036
- this._updatedColors.add(n);
61072
+ this._updatedColors.add(element);
61037
61073
  }
61038
61074
  this.scheduleColorUpdate();
61039
61075
  }
61076
+ //TODO: Remove and rely on element.color
61040
61077
  clearColor(elements) {
61041
61078
  if (elements === "all") {
61042
61079
  this._elementColors.clear();
@@ -61045,10 +61082,9 @@ class Vim2 {
61045
61082
  }
61046
61083
  if (!this.connected) return;
61047
61084
  if (elements === "all") {
61048
- this._rpc.RPCClearMaterialOverrides();
61085
+ this._rpc.RPCClearMaterialOverridesForVim(this._handle);
61049
61086
  } else {
61050
- const ids = new Array(elements.length).fill(MaterialHandles.Invalid);
61051
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, ids);
61087
+ this._rpc.RPCClearMaterialOverridesForElements(this._handle, elements);
61052
61088
  }
61053
61089
  }
61054
61090
  reapplyColors() {
@@ -61069,11 +61105,11 @@ class Vim2 {
61069
61105
  this._renderer.notifySceneUpdated();
61070
61106
  }
61071
61107
  async updateRemoteColors() {
61072
- const nodes = Array.from(this._updatedColors);
61073
- const colors = nodes.map((n) => this._elementColors.get(n));
61108
+ const elements = Array.from(this._updatedColors);
61109
+ const colors = elements.map((n) => this._elementColors.get(n));
61074
61110
  const remoteColors = await this._colors.getColors(colors);
61075
61111
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61076
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, nodes, colorIds);
61112
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, colorIds);
61077
61113
  this._updatedColors.clear();
61078
61114
  }
61079
61115
  }