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.
package/dist/vim-web.js CHANGED
@@ -52740,13 +52740,20 @@ class DoubleClickHandler {
52740
52740
  constructor() {
52741
52741
  __publicField(this, "_lastClickTime", 0);
52742
52742
  __publicField(this, "_clickDelay", 300);
52743
+ // Max time between clicks for double-click
52744
+ __publicField(this, "_lastClickPosition", null);
52745
+ __publicField(this, "_positionThreshold", 5);
52743
52746
  }
52744
- // Delay in milliseconds to consider a double click
52747
+ // Max pixel distance between clicks
52745
52748
  checkForDoubleClick(event) {
52746
52749
  const currentTime = Date.now();
52750
+ const currentPosition = new Vector2(event.clientX, event.clientY);
52747
52751
  const timeDiff = currentTime - this._lastClickTime;
52752
+ const isClose = this._lastClickPosition !== null && this._lastClickPosition.distanceTo(currentPosition) < this._positionThreshold;
52753
+ const isWithinTime = timeDiff < this._clickDelay;
52748
52754
  this._lastClickTime = currentTime;
52749
- return timeDiff < this._clickDelay;
52755
+ this._lastClickPosition = currentPosition;
52756
+ return isClose && isWithinTime;
52750
52757
  }
52751
52758
  }
52752
52759
  class DragHandler {
@@ -52998,11 +53005,7 @@ class InputHandler extends BaseInputHandler {
52998
53005
  this.keyboard.registerKeyUp("KeyP", "replace", () => adapter.toggleOrthographic());
52999
53006
  this.keyboard.registerKeyUp("Equal", "replace", () => this.moveSpeed++);
53000
53007
  this.keyboard.registerKeyUp("Minus", "replace", () => this.moveSpeed--);
53001
- this.keyboard.registerKeyUp("Space", "replace", () => {
53002
- this._pointerActive = this._pointerActive === "orbit" ? "look" : "orbit";
53003
- this._pointerFallback = this._pointerActive;
53004
- this._onPointerModeChanged.dispatch();
53005
- });
53008
+ this.keyboard.registerKeyUp("Space", "replace", () => adapter.toggleCameraOrbitMode());
53006
53009
  this.keyboard.registerKeyUp("Home", "replace", () => adapter.resetCamera());
53007
53010
  this.keyboard.registerKeyUp("Escape", "replace", () => adapter.clearSelection());
53008
53011
  this.keyboard.registerKeyUp("KeyF", "replace", () => {
@@ -55900,6 +55903,11 @@ function createAdapter$2(viewer) {
55900
55903
  toggleOrthographic: () => {
55901
55904
  viewer.camera.orthographic = !viewer.camera.orthographic;
55902
55905
  },
55906
+ toggleCameraOrbitMode: () => {
55907
+ this._pointerActive = this._pointerActive === PointerMode$1.ORBIT ? PointerMode$1.LOOK : PointerMode$1.ORBIT;
55908
+ this._pointerFallback = this._pointerActive;
55909
+ this._onPointerModeChanged.dispatch();
55910
+ },
55903
55911
  resetCamera: () => {
55904
55912
  viewer.camera.lerp(0.75).reset();
55905
55913
  },
@@ -55924,7 +55932,7 @@ function createAdapter$2(viewer) {
55924
55932
  },
55925
55933
  frameAtPointer: async (pos) => {
55926
55934
  const result = await viewer.raycaster.raycastFromScreen(pos);
55927
- viewer.camera.lerp(0.75).frame(result.object);
55935
+ viewer.camera.lerp(0.75).frame(result.object ?? "all");
55928
55936
  },
55929
55937
  zoom: (value) => {
55930
55938
  viewer.camera.lerp(0.75).zoom(value);
@@ -58828,6 +58836,7 @@ class Decoder {
58828
58836
  }
58829
58837
  }
58830
58838
  const CODE_TO_KEYCODE = {
58839
+ "Space": 32,
58831
58840
  "ArrowUp": 38,
58832
58841
  "ArrowDown": 40,
58833
58842
  "ArrowLeft": 37,
@@ -58861,6 +58870,9 @@ function createAdapter$1(viewer) {
58861
58870
  toggleOrthographic: () => {
58862
58871
  console.log("toggleOrthographic. Not supported yet");
58863
58872
  },
58873
+ toggleCameraOrbitMode: () => {
58874
+ viewer.rpc.RPCKeyEvent(CODE_TO_KEYCODE["Space"], true);
58875
+ },
58864
58876
  resetCamera: () => {
58865
58877
  viewer.camera.restoreSavedPosition();
58866
58878
  },
@@ -60906,6 +60918,7 @@ class Vim2 {
60906
60918
  // Color tracking remains unchanged.
60907
60919
  __publicField(this, "_elementColors", /* @__PURE__ */ new Map());
60908
60920
  __publicField(this, "_updatedColors", /* @__PURE__ */ new Set());
60921
+ __publicField(this, "_removedColors", /* @__PURE__ */ new Set());
60909
60922
  // Delayed update flag.
60910
60923
  __publicField(this, "_updateScheduled", false);
60911
60924
  __publicField(this, "_elementCount", 0);
@@ -61071,16 +61084,18 @@ class Vim2 {
61071
61084
  }
61072
61085
  this.applyColor(elements, color);
61073
61086
  }
61074
- applyColor(elements, color) {
61075
- for (let i = 0; i < color.length; i++) {
61076
- const c = color[i];
61087
+ applyColor(elements, colors) {
61088
+ for (let i = 0; i < colors.length; i++) {
61089
+ const color = colors[i];
61077
61090
  const element = elements[i];
61078
- if (c === void 0) {
61091
+ const existingColor = this._elementColors.get(element);
61092
+ if (color === void 0 && existingColor !== void 0) {
61079
61093
  this._elementColors.delete(element);
61080
- } else {
61081
- this._elementColors.set(element, c);
61094
+ this._removedColors.add(element);
61095
+ } else if (color !== existingColor) {
61096
+ this._elementColors.set(element, color);
61097
+ this._updatedColors.add(element);
61082
61098
  }
61083
- this._updatedColors.add(element);
61084
61099
  }
61085
61100
  this.scheduleColorUpdate();
61086
61101
  }
@@ -61100,6 +61115,7 @@ class Vim2 {
61100
61115
  }
61101
61116
  reapplyColors() {
61102
61117
  this._updatedColors.clear();
61118
+ this._removedColors.clear();
61103
61119
  this._elementColors.forEach((c, n) => this._updatedColors.add(n));
61104
61120
  this.scheduleColorUpdate();
61105
61121
  }
@@ -61116,12 +61132,15 @@ class Vim2 {
61116
61132
  this._renderer.notifySceneUpdated();
61117
61133
  }
61118
61134
  async updateRemoteColors() {
61119
- const elements = Array.from(this._updatedColors);
61120
- const colors = elements.map((n) => this._elementColors.get(n));
61135
+ const updatedElement = Array.from(this._updatedColors);
61136
+ const removedElement = Array.from(this._removedColors);
61137
+ const colors = updatedElement.map((n) => this._elementColors.get(n));
61121
61138
  const remoteColors = await this._colors.getColors(colors);
61122
61139
  const colorIds = remoteColors.map((c) => (c == null ? void 0 : c.id) ?? -1);
61123
- this._rpc.RPCSetMaterialOverridesForElements(this._handle, elements, colorIds);
61140
+ this._rpc.RPCClearMaterialOverridesForElements(this._handle, removedElement);
61141
+ this._rpc.RPCSetMaterialOverridesForElements(this._handle, updatedElement, colorIds);
61124
61142
  this._updatedColors.clear();
61143
+ this._removedColors.clear();
61125
61144
  }
61126
61145
  }
61127
61146
  function wait(ms) {
@@ -75307,15 +75326,18 @@ class ComponentLoader {
75307
75326
  }
75308
75327
  }
75309
75328
  function MessageBox(props) {
75329
+ const [minimized, setMinimized] = React__default.useState(true);
75310
75330
  const p = props.value;
75311
75331
  if (!p.title || !p.body) return null;
75312
75332
  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: [
75313
75333
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "vc-flex vc-justify-between vc-items-center", children: [
75334
+ props.value.icon,
75314
75335
  title(p.title),
75315
- closeBtn(p.onClose)
75336
+ props.value.canClose && closeBtn(p.onClose),
75337
+ props.value.minimize && minimizeButton(minimized, setMinimized)
75316
75338
  ] }),
75317
- divider(),
75318
- body(p.body),
75339
+ !minimized && divider(),
75340
+ !minimized && body(p.body),
75319
75341
  footer(p.footer)
75320
75342
  ] });
75321
75343
  }
@@ -75326,6 +75348,9 @@ function closeBtn(onClose) {
75326
75348
  if (!onClose) return null;
75327
75349
  return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: onClose, className: "vc-text-[#212733] vc-text-xl", children: "×" });
75328
75350
  }
75351
+ function minimizeButton(minimized, setMinimized) {
75352
+ 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: "▲" }) });
75353
+ }
75329
75354
  function body(content2) {
75330
75355
  if (content2 === void 0) return null;
75331
75356
  if (typeof content2 === "string") {
@@ -76054,6 +76079,16 @@ function Viewer$1(props) {
76054
76079
  side.setHasBim(((_a3 = viewerState.vim.get()) == null ? void 0 : _a3.bim) !== void 0);
76055
76080
  });
76056
76081
  useEffect(() => {
76082
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
76083
+ if (show) {
76084
+ isolationRef.showPanel.set(false);
76085
+ }
76086
+ });
76087
+ isolationRef.showPanel.onChange.subscribe((show) => {
76088
+ if (show) {
76089
+ sectionBoxRef.showOffsetPanel.set(false);
76090
+ }
76091
+ });
76057
76092
  if (performanceRef.current) {
76058
76093
  addPerformanceCounter(performanceRef.current);
76059
76094
  }
@@ -76422,18 +76457,28 @@ function createViewer(container) {
76422
76457
  return controllablePromise.promise;
76423
76458
  }
76424
76459
  function Viewer3(props) {
76425
- const sectionBox2 = useUltraSectionBox(props.core);
76426
- const camera2 = useUltraCamera(props.core, sectionBox2);
76460
+ const sectionBoxRef = useUltraSectionBox(props.core);
76461
+ const camera2 = useUltraCamera(props.core, sectionBoxRef);
76427
76462
  const isolationPanelHandle = useRef(null);
76428
76463
  const sectionBoxPanelHandle = useRef(null);
76429
76464
  const modalHandle = useRef(null);
76430
76465
  const side = useSideState(true, 400);
76431
76466
  const [_, setSelectState] = useState(0);
76432
76467
  const [controlBarCustom, setControlBarCustom] = useState(() => (c) => c);
76433
- const isolation = useUltraIsolation(props.core);
76434
- const controlBar = useUltraControlBar(props.core, sectionBox2, isolation, camera2, (_2) => _2);
76468
+ const isolationRef = useUltraIsolation(props.core);
76469
+ const controlBar = useUltraControlBar(props.core, sectionBoxRef, isolationRef, camera2, (_2) => _2);
76435
76470
  useViewerInput(props.core.inputs, camera2);
76436
76471
  useEffect(() => {
76472
+ sectionBoxRef.showOffsetPanel.onChange.subscribe((show) => {
76473
+ if (show) {
76474
+ isolationRef.showPanel.set(false);
76475
+ }
76476
+ });
76477
+ isolationRef.showPanel.onChange.subscribe((show) => {
76478
+ if (show) {
76479
+ sectionBoxRef.showOffsetPanel.set(false);
76480
+ }
76481
+ });
76437
76482
  props.core.onStateChanged.subscribe((state) => updateModal(modalHandle, state));
76438
76483
  props.core.selection.onSelectionChanged.subscribe(() => {
76439
76484
  setSelectState((i) => (i + 1) % 2);
@@ -76443,8 +76488,8 @@ function Viewer3(props) {
76443
76488
  get modal() {
76444
76489
  return modalHandle.current;
76445
76490
  },
76446
- isolation,
76447
- sectionBox: sectionBox2,
76491
+ isolation: isolationRef,
76492
+ sectionBox: sectionBoxRef,
76448
76493
  camera: camera2,
76449
76494
  get isolationPanel() {
76450
76495
  return isolationPanelHandle.current;
@@ -76472,8 +76517,8 @@ function Viewer3(props) {
76472
76517
  show: true
76473
76518
  }
76474
76519
  ),
76475
- /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBox2 }),
76476
- /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolation })
76520
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel$1, { ref: sectionBoxPanelHandle, state: sectionBoxRef }),
76521
+ /* @__PURE__ */ jsxRuntimeExports.jsx(IsolationPanel$1, { ref: isolationPanelHandle, state: isolationRef })
76477
76522
  ] });
76478
76523
  } }),
76479
76524
  /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { ref: modalHandle, canFollowLinks: true }),