vim-web 0.5.0-dev.11 → 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;
@@ -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
  },
@@ -75330,15 +75342,18 @@ Averrage Date/Second ${avgDataRatePS} kb
75330
75342
  }
75331
75343
  }
75332
75344
  function MessageBox(props) {
75345
+ const [minimized, setMinimized] = React2.useState(true);
75333
75346
  const p = props.value;
75334
75347
  if (!p.title || !p.body) return null;
75335
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: [
75336
75349
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-flex vc-justify-between vc-items-center", children: [
75350
+ props.value.icon,
75337
75351
  title(p.title),
75338
- closeBtn(p.onClose)
75352
+ props.value.canClose && closeBtn(p.onClose),
75353
+ props.value.minimize && minimizeButton(minimized, setMinimized)
75339
75354
  ] }),
75340
- divider(),
75341
- body(p.body),
75355
+ !minimized && divider(),
75356
+ !minimized && body(p.body),
75342
75357
  footer(p.footer)
75343
75358
  ] });
75344
75359
  }
@@ -75349,6 +75364,9 @@ Averrage Date/Second ${avgDataRatePS} kb
75349
75364
  if (!onClose) return null;
75350
75365
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: onClose, className: "vc-text-[#212733] vc-text-xl", children: "×" });
75351
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
+ }
75352
75370
  function body(content2) {
75353
75371
  if (content2 === void 0) return null;
75354
75372
  if (typeof content2 === "string") {
@@ -76077,6 +76095,16 @@ Averrage Date/Second ${avgDataRatePS} kb
76077
76095
  side.setHasBim(((_a3 = viewerState.vim.get()) == null ? void 0 : _a3.bim) !== void 0);
76078
76096
  });
76079
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
+ });
76080
76108
  if (performanceRef.current) {
76081
76109
  addPerformanceCounter(performanceRef.current);
76082
76110
  }
@@ -76445,18 +76473,28 @@ Averrage Date/Second ${avgDataRatePS} kb
76445
76473
  return controllablePromise.promise;
76446
76474
  }
76447
76475
  function Viewer(props) {
76448
- const sectionBox2 = useUltraSectionBox(props.core);
76449
- const camera2 = useUltraCamera(props.core, sectionBox2);
76476
+ const sectionBoxRef = useUltraSectionBox(props.core);
76477
+ const camera2 = useUltraCamera(props.core, sectionBoxRef);
76450
76478
  const isolationPanelHandle = React2.useRef(null);
76451
76479
  const sectionBoxPanelHandle = React2.useRef(null);
76452
76480
  const modalHandle = React2.useRef(null);
76453
76481
  const side = useSideState(true, 400);
76454
76482
  const [_, setSelectState] = React2.useState(0);
76455
76483
  const [controlBarCustom, setControlBarCustom] = React2.useState(() => (c) => c);
76456
- const isolation = useUltraIsolation(props.core);
76457
- 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);
76458
76486
  useViewerInput(props.core.inputs, camera2);
76459
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
+ });
76460
76498
  props.core.onStateChanged.subscribe((state) => updateModal(modalHandle, state));
76461
76499
  props.core.selection.onSelectionChanged.subscribe(() => {
76462
76500
  setSelectState((i2) => (i2 + 1) % 2);
@@ -76466,8 +76504,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76466
76504
  get modal() {
76467
76505
  return modalHandle.current;
76468
76506
  },
76469
- isolation,
76470
- sectionBox: sectionBox2,
76507
+ isolation: isolationRef,
76508
+ sectionBox: sectionBoxRef,
76471
76509
  camera: camera2,
76472
76510
  get isolationPanel() {
76473
76511
  return isolationPanelHandle.current;
@@ -76495,8 +76533,8 @@ Averrage Date/Second ${avgDataRatePS} kb
76495
76533
  show: true
76496
76534
  }
76497
76535
  ),
76498
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBox2 }),
76499
- /* @__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 })
76500
76538
  ] });
76501
76539
  } }),
76502
76540
  /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modalHandle, canFollowLinks: true }),