vim-web 0.5.0-dev.6 → 0.5.0-dev.8

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.
@@ -24,11 +24,11 @@ export declare class ColorManager {
24
24
  getColor(color: THREE.Color): Promise<RemoteColor | undefined>;
25
25
  /**
26
26
  * Creates or retrieves cached color instances for multiple hex values.
27
- * @param c - Array of RGBA32 color values
27
+ * @param colors - Array of color values or undefined for no color
28
28
  * @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
29
29
  * @remarks Duplicate hex values will be mapped to the same color instance for efficiency
30
30
  */
31
- getColors(c: THREE.Color[]): Promise<RemoteColor[]>;
31
+ getColors(colors: (THREE.Color | undefined)[]): Promise<RemoteColor[]>;
32
32
  /**
33
33
  * Retrieves a color instance by its unique identifier.
34
34
  * @param id - The unique identifier of the color
@@ -38,7 +38,7 @@ export declare class Vim implements IVim<Element3D> {
38
38
  getBoundingBox(): Promise<THREE.Box3 | undefined>;
39
39
  getColor(elementIndex: number): THREE.Color | undefined;
40
40
  setColor(elementIndex: number[], color: THREE.Color | undefined): Promise<void>;
41
- setColors(nodes: number[], color: (THREE.Color | undefined)[]): Promise<void>;
41
+ setColors(elements: number[], color: (THREE.Color | undefined)[]): Promise<void>;
42
42
  private applyColor;
43
43
  clearColor(elements: number[] | 'all'): void;
44
44
  reapplyColors(): void;
@@ -58384,33 +58384,41 @@ void main() {
58384
58384
  }
58385
58385
  /**
58386
58386
  * Creates or retrieves cached color instances for multiple hex values.
58387
- * @param c - Array of RGBA32 color values
58387
+ * @param colors - Array of color values or undefined for no color
58388
58388
  * @returns Promise resolving to an array of ColorHandles in the same order as input, or undefined if creation fails
58389
58389
  * @remarks Duplicate hex values will be mapped to the same color instance for efficiency
58390
58390
  */
58391
- async getColors(c) {
58392
- const result = new Array(c.length);
58391
+ async getColors(colors) {
58392
+ const result = new Array(colors.length);
58393
58393
  const hexToIndices = /* @__PURE__ */ new Map();
58394
58394
  const toCreate = [];
58395
- for (let i2 = 0; i2 < c.length; i2++) {
58396
- const color = c[i2];
58397
- const hex = color.getHex();
58398
- if (this._hexToColor.has(hex)) {
58399
- result[i2] = this._hexToColor.get(hex);
58400
- } else if (hexToIndices.has(hex)) {
58395
+ for (let i2 = 0; i2 < colors.length; i2++) {
58396
+ const color = colors[i2];
58397
+ if (color === void 0) {
58398
+ result[i2] = void 0;
58399
+ continue;
58400
+ }
58401
+ const hex = (color == null ? void 0 : color.getHex()) ?? -1;
58402
+ const remoteColor = this._hexToColor.get(hex);
58403
+ if (remoteColor) {
58404
+ result[i2] = remoteColor;
58405
+ continue;
58406
+ }
58407
+ const indices = hexToIndices.get(hex);
58408
+ if (indices) {
58401
58409
  hexToIndices.get(hex).push(i2);
58402
- } else {
58403
- toCreate.push(color);
58404
- hexToIndices.set(hex, [i2]);
58410
+ continue;
58405
58411
  }
58412
+ toCreate.push(color);
58413
+ hexToIndices.set(hex, [i2]);
58406
58414
  }
58407
- const colors = await this._createColors(toCreate);
58408
- if (!colors) return void 0;
58409
- for (let i2 = 0; i2 < colors.length; i2++) {
58415
+ const remoteColors = await this._createColors(toCreate);
58416
+ if (!remoteColors) return void 0;
58417
+ for (let i2 = 0; i2 < remoteColors.length; i2++) {
58410
58418
  const color = toCreate[i2];
58411
58419
  const indices = hexToIndices.get(color.getHex());
58412
58420
  for (const index2 of indices) {
58413
- result[index2] = colors[i2];
58421
+ result[index2] = remoteColors[i2];
58414
58422
  }
58415
58423
  }
58416
58424
  return result;
@@ -60893,6 +60901,7 @@ Averrage Date/Second ${avgDataRatePS} kb
60893
60901
  // default state
60894
60902
  );
60895
60903
  }
60904
+ //TODO: Rename this to getElementFromNode, prefer using element instead
60896
60905
  getElement(elementIndex) {
60897
60906
  if (this._objects.has(elementIndex)) {
60898
60907
  return this._objects.get(elementIndex);
@@ -60905,7 +60914,7 @@ Averrage Date/Second ${avgDataRatePS} kb
60905
60914
  throw new Error("Method not implemented.");
60906
60915
  }
60907
60916
  getElementFromIndex(element) {
60908
- throw new Error("Method not implemented.");
60917
+ return this.getElement(element);
60909
60918
  }
60910
60919
  getObjectsInBox(box) {
60911
60920
  throw new Error("Method not implemented.");
@@ -61033,22 +61042,22 @@ Averrage Date/Second ${avgDataRatePS} kb
61033
61042
  const colors = new Array(elementIndex.length).fill(color);
61034
61043
  this.applyColor(elementIndex, colors);
61035
61044
  }
61036
- async setColors(nodes, color) {
61037
- if (color.length !== nodes.length) {
61038
- throw new Error("Color and nodes length must be equal");
61045
+ async setColors(elements, color) {
61046
+ if (color.length !== elements.length) {
61047
+ throw new Error("Color and elements length must be equal");
61039
61048
  }
61040
- this.applyColor(nodes, color);
61049
+ this.applyColor(elements, color);
61041
61050
  }
61042
- applyColor(nodes, color) {
61051
+ applyColor(elements, color) {
61043
61052
  for (let i2 = 0; i2 < color.length; i2++) {
61044
61053
  const c = color[i2];
61045
- const n = nodes[i2];
61054
+ const element = elements[i2];
61046
61055
  if (c === void 0) {
61047
- this._elementColors.delete(n);
61056
+ this._elementColors.delete(element);
61048
61057
  } else {
61049
- this._elementColors.set(n, c);
61058
+ this._elementColors.set(element, c);
61050
61059
  }
61051
- this._updatedColors.add(n);
61060
+ this._updatedColors.add(element);
61052
61061
  }
61053
61062
  this.scheduleColorUpdate();
61054
61063
  }
@@ -61084,11 +61093,11 @@ Averrage Date/Second ${avgDataRatePS} kb
61084
61093
  this._renderer.notifySceneUpdated();
61085
61094
  }
61086
61095
  async updateRemoteColors() {
61087
- const nodes = Array.from(this._updatedColors);
61088
- const colors = nodes.map((n) => this._elementColors.get(n));
61096
+ const elements = Array.from(this._updatedColors);
61097
+ const colors = elements.map((n) => this._elementColors.get(n));
61089
61098
  const remoteColors = await this._colors.getColors(colors);
61090
61099
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61091
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, nodes, colorIds);
61100
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, colorIds);
61092
61101
  this._updatedColors.clear();
61093
61102
  }
61094
61103
  }
@@ -76284,6 +76293,7 @@ Averrage Date/Second ${avgDataRatePS} kb
76284
76293
  obj.state = VisibilityState.HIGHLIGHTED;
76285
76294
  });
76286
76295
  },
76296
+ // TODO: Change this api to use elements
76287
76297
  isolate: (instances) => {
76288
76298
  hide("all");
76289
76299
  viewer.selection.getAll().forEach((obj) => {