vim-web 0.5.0-dev.10 → 0.5.0-dev.12

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.
@@ -2,6 +2,7 @@ import * as THREE from 'three';
2
2
  export interface IInputAdapter {
3
3
  init: () => void;
4
4
  toggleOrthographic: () => void;
5
+ toggleCameraOrbitMode: () => void;
5
6
  resetCamera: () => void;
6
7
  clearSelection: () => void;
7
8
  frameCamera: () => void;
@@ -19,6 +19,7 @@ export declare class Vim implements IVim<Element3D> {
19
19
  readonly visibility: VisibilitySynchronizer;
20
20
  private _elementColors;
21
21
  private _updatedColors;
22
+ private _removedColors;
22
23
  private _updateScheduled;
23
24
  private _elementCount;
24
25
  private _objects;
@@ -1,8 +1,10 @@
1
1
  export type MessageBoxProps = {
2
2
  title: string;
3
3
  body: string | JSX.Element;
4
+ icon?: JSX.Element;
4
5
  footer?: string | JSX.Element;
5
6
  canClose?: boolean;
7
+ minimize?: boolean;
6
8
  onClose?: () => void;
7
9
  };
8
10
  export type MessageBoxPropsTyped = MessageBoxProps & {
@@ -52756,13 +52756,20 @@ void main() {
52756
52756
  constructor() {
52757
52757
  __publicField(this, "_lastClickTime", 0);
52758
52758
  __publicField(this, "_clickDelay", 300);
52759
+ // Max time between clicks for double-click
52760
+ __publicField(this, "_lastClickPosition", null);
52761
+ __publicField(this, "_positionThreshold", 5);
52759
52762
  }
52760
- // Delay in milliseconds to consider a double click
52763
+ // Max pixel distance between clicks
52761
52764
  checkForDoubleClick(event) {
52762
52765
  const currentTime = Date.now();
52766
+ const currentPosition = new Vector2(event.clientX, event.clientY);
52763
52767
  const timeDiff = currentTime - this._lastClickTime;
52768
+ const isClose = this._lastClickPosition !== null && this._lastClickPosition.distanceTo(currentPosition) < this._positionThreshold;
52769
+ const isWithinTime = timeDiff < this._clickDelay;
52764
52770
  this._lastClickTime = currentTime;
52765
- return timeDiff < this._clickDelay;
52771
+ this._lastClickPosition = currentPosition;
52772
+ return isClose && isWithinTime;
52766
52773
  }
52767
52774
  }
52768
52775
  class DragHandler {
@@ -53014,11 +53021,7 @@ void main() {
53014
53021
  this.keyboard.registerKeyUp("KeyP", "replace", () => adapter.toggleOrthographic());
53015
53022
  this.keyboard.registerKeyUp("Equal", "replace", () => this.moveSpeed++);
53016
53023
  this.keyboard.registerKeyUp("Minus", "replace", () => this.moveSpeed--);
53017
- this.keyboard.registerKeyUp("Space", "replace", () => {
53018
- this._pointerActive = this._pointerActive === "orbit" ? "look" : "orbit";
53019
- this._pointerFallback = this._pointerActive;
53020
- this._onPointerModeChanged.dispatch();
53021
- });
53024
+ this.keyboard.registerKeyUp("Space", "replace", () => adapter.toggleCameraOrbitMode());
53022
53025
  this.keyboard.registerKeyUp("Home", "replace", () => adapter.resetCamera());
53023
53026
  this.keyboard.registerKeyUp("Escape", "replace", () => adapter.clearSelection());
53024
53027
  this.keyboard.registerKeyUp("KeyF", "replace", () => {
@@ -55916,6 +55919,11 @@ void main() {
55916
55919
  toggleOrthographic: () => {
55917
55920
  viewer.camera.orthographic = !viewer.camera.orthographic;
55918
55921
  },
55922
+ toggleCameraOrbitMode: () => {
55923
+ this._pointerActive = this._pointerActive === PointerMode$1.ORBIT ? PointerMode$1.LOOK : PointerMode$1.ORBIT;
55924
+ this._pointerFallback = this._pointerActive;
55925
+ this._onPointerModeChanged.dispatch();
55926
+ },
55919
55927
  resetCamera: () => {
55920
55928
  viewer.camera.lerp(0.75).reset();
55921
55929
  },
@@ -55940,7 +55948,7 @@ void main() {
55940
55948
  },
55941
55949
  frameAtPointer: async (pos) => {
55942
55950
  const result = await viewer.raycaster.raycastFromScreen(pos);
55943
- viewer.camera.lerp(0.75).frame(result.object);
55951
+ viewer.camera.lerp(0.75).frame(result.object ?? "all");
55944
55952
  },
55945
55953
  zoom: (value) => {
55946
55954
  viewer.camera.lerp(0.75).zoom(value);
@@ -58844,6 +58852,7 @@ void main() {
58844
58852
  }
58845
58853
  }
58846
58854
  const CODE_TO_KEYCODE = {
58855
+ "Space": 32,
58847
58856
  "ArrowUp": 38,
58848
58857
  "ArrowDown": 40,
58849
58858
  "ArrowLeft": 37,
@@ -58877,6 +58886,9 @@ void main() {
58877
58886
  toggleOrthographic: () => {
58878
58887
  console.log("toggleOrthographic. Not supported yet");
58879
58888
  },
58889
+ toggleCameraOrbitMode: () => {
58890
+ viewer.rpc.RPCKeyEvent(CODE_TO_KEYCODE["Space"], true);
58891
+ },
58880
58892
  resetCamera: () => {
58881
58893
  viewer.camera.restoreSavedPosition();
58882
58894
  },
@@ -60922,6 +60934,7 @@ Averrage Date/Second ${avgDataRatePS} kb
60922
60934
  // Color tracking remains unchanged.
60923
60935
  __publicField(this, "_elementColors", /* @__PURE__ */ new Map());
60924
60936
  __publicField(this, "_updatedColors", /* @__PURE__ */ new Set());
60937
+ __publicField(this, "_removedColors", /* @__PURE__ */ new Set());
60925
60938
  // Delayed update flag.
60926
60939
  __publicField(this, "_updateScheduled", false);
60927
60940
  __publicField(this, "_elementCount", 0);
@@ -61087,16 +61100,18 @@ Averrage Date/Second ${avgDataRatePS} kb
61087
61100
  }
61088
61101
  this.applyColor(elements, color);
61089
61102
  }
61090
- applyColor(elements, color) {
61091
- for (let i2 = 0; i2 < color.length; i2++) {
61092
- const c = color[i2];
61103
+ applyColor(elements, colors) {
61104
+ for (let i2 = 0; i2 < colors.length; i2++) {
61105
+ const color = colors[i2];
61093
61106
  const element = elements[i2];
61094
- if (c === void 0) {
61107
+ const existingColor = this._elementColors.get(element);
61108
+ if (color === void 0 && existingColor !== void 0) {
61095
61109
  this._elementColors.delete(element);
61096
- } else {
61097
- this._elementColors.set(element, c);
61110
+ this._removedColors.add(element);
61111
+ } else if (color !== existingColor) {
61112
+ this._elementColors.set(element, color);
61113
+ this._updatedColors.add(element);
61098
61114
  }
61099
- this._updatedColors.add(element);
61100
61115
  }
61101
61116
  this.scheduleColorUpdate();
61102
61117
  }
@@ -61116,6 +61131,7 @@ Averrage Date/Second ${avgDataRatePS} kb
61116
61131
  }
61117
61132
  reapplyColors() {
61118
61133
  this._updatedColors.clear();
61134
+ this._removedColors.clear();
61119
61135
  this._elementColors.forEach((c, n) => this._updatedColors.add(n));
61120
61136
  this.scheduleColorUpdate();
61121
61137
  }
@@ -61132,12 +61148,15 @@ Averrage Date/Second ${avgDataRatePS} kb
61132
61148
  this._renderer.notifySceneUpdated();
61133
61149
  }
61134
61150
  async updateRemoteColors() {
61135
- const elements = Array.from(this._updatedColors);
61136
- const colors = elements.map((n) => this._elementColors.get(n));
61151
+ const updatedElement = Array.from(this._updatedColors);
61152
+ const removedElement = Array.from(this._removedColors);
61153
+ const colors = updatedElement.map((n) => this._elementColors.get(n));
61137
61154
  const remoteColors = await this._colors.getColors(colors);
61138
61155
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61139
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, colorIds);
61156
+ this._rpc.RPCClearMaterialOverridesForElements(this._handle, removedElement);
61157
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, updatedElement, colorIds);
61140
61158
  this._updatedColors.clear();
61159
+ this._removedColors.clear();
61141
61160
  }
61142
61161
  }
61143
61162
  function wait(ms) {
@@ -75323,15 +75342,18 @@ Averrage Date/Second ${avgDataRatePS} kb
75323
75342
  }
75324
75343
  }
75325
75344
  function MessageBox(props) {
75345
+ const [minimized, setMinimized] = React2.useState(true);
75326
75346
  const p = props.value;
75327
75347
  if (!p.title || !p.body) return null;
75328
75348
  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: [
75329
75349
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-flex vc-justify-between vc-items-center", children: [
75350
+ props.value.icon,
75330
75351
  title(p.title),
75331
- closeBtn(p.onClose)
75352
+ props.value.canClose && closeBtn(p.onClose),
75353
+ props.value.minimize && minimizeButton(minimized, setMinimized)
75332
75354
  ] }),
75333
- divider(),
75334
- body(p.body),
75355
+ !minimized && divider(),
75356
+ !minimized && body(p.body),
75335
75357
  footer(p.footer)
75336
75358
  ] });
75337
75359
  }
@@ -75342,6 +75364,9 @@ Averrage Date/Second ${avgDataRatePS} kb
75342
75364
  if (!onClose) return null;
75343
75365
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: onClose, className: "vc-text-[#212733] vc-text-xl", children: "×" });
75344
75366
  }
75367
+ function minimizeButton(minimized, setMinimized) {
75368
+ 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: "▲" }) });
75369
+ }
75345
75370
  function body(content2) {
75346
75371
  if (content2 === void 0) return null;
75347
75372
  if (typeof content2 === "string") {
@@ -76070,6 +76095,16 @@ Averrage Date/Second ${avgDataRatePS} kb
76070
76095
  side.setHasBim(((_a3 = viewerState.vim.get()) == null ? void 0 : _a3.bim) !== void 0);
76071
76096
  });
76072
76097
  React2.useEffect(() => {
76098
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
76099
+ if (show) {
76100
+ isolationRef.showPanel.set(false);
76101
+ }
76102
+ });
76103
+ isolationRef.showPanel.onChange.subscribe((show) => {
76104
+ if (show) {
76105
+ sectionBoxRef.showOffsetPanel.set(false);
76106
+ }
76107
+ });
76073
76108
  if (performanceRef.current) {
76074
76109
  addPerformanceCounter(performanceRef.current);
76075
76110
  }
@@ -76438,18 +76473,28 @@ Averrage Date/Second ${avgDataRatePS} kb
76438
76473
  return controllablePromise.promise;
76439
76474
  }
76440
76475
  function Viewer(props) {
76441
- const sectionBox2 = useUltraSectionBox(props.core);
76442
- const camera2 = useUltraCamera(props.core, sectionBox2);
76476
+ const sectionBoxRef = useUltraSectionBox(props.core);
76477
+ const camera2 = useUltraCamera(props.core, sectionBoxRef);
76443
76478
  const isolationPanelHandle = React2.useRef(null);
76444
76479
  const sectionBoxPanelHandle = React2.useRef(null);
76445
76480
  const modalHandle = React2.useRef(null);
76446
76481
  const side = useSideState(true, 400);
76447
76482
  const [_, setSelectState] = React2.useState(0);
76448
76483
  const [controlBarCustom, setControlBarCustom] = React2.useState(() => (c) => c);
76449
- const isolation = useUltraIsolation(props.core);
76450
- const controlBar = useUltraControlBar(props.core, sectionBox2, isolation, camera2, (_2) => _2);
76484
+ const isolationRef = useUltraIsolation(props.core);
76485
+ const controlBar = useUltraControlBar(props.core, sectionBoxRef, isolationRef, camera2, (_2) => _2);
76451
76486
  useViewerInput(props.core.inputs, camera2);
76452
76487
  React2.useEffect(() => {
76488
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
76489
+ if (show) {
76490
+ isolationRef.showPanel.set(false);
76491
+ }
76492
+ });
76493
+ isolationRef.showPanel.onChange.subscribe((show) => {
76494
+ if (show) {
76495
+ sectionBoxRef.showOffsetPanel.set(false);
76496
+ }
76497
+ });
76453
76498
  props.core.onStateChanged.subscribe((state) => updateModal(modalHandle, state));
76454
76499
  props.core.selection.onSelectionChanged.subscribe(() => {
76455
76500
  setSelectState((i2) => (i2 + 1) % 2);
@@ -76459,8 +76504,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76459
76504
  get modal() {
76460
76505
  return modalHandle.current;
76461
76506
  },
76462
- isolation,
76463
- sectionBox: sectionBox2,
76507
+ isolation: isolationRef,
76508
+ sectionBox: sectionBoxRef,
76464
76509
  camera: camera2,
76465
76510
  get isolationPanel() {
76466
76511
  return isolationPanelHandle.current;
@@ -76488,8 +76533,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76488
76533
  show: true
76489
76534
  }
76490
76535
  ),
76491
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBox2 }),
76492
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolation })
76536
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),
76537
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolationRef })
76493
76538
  ] });
76494
76539
  } }),
76495
76540
  /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modalHandle, canFollowLinks: true }),