vim-web 0.3.44-dev.17 → 0.3.44-dev.18

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.
@@ -66817,6 +66817,25 @@ Averrage Date/Second ${avgDataRatePS} kb
66817
66817
  }
66818
66818
  );
66819
66819
  }
66820
+ function autoCamera({ height, width, fill: fill2 = "", className }) {
66821
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66822
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
66823
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66824
+ "path",
66825
+ {
66826
+ fill: fill2,
66827
+ d: "M 242.35934,69.720521 V 192.19034 c 0,9.46501 -7.97359,15.37204 -14.35248,10.67406 l -39.68884,-29.41993 v 8.38267 c 0,25.1595 -15.90243,45.64407 -35.51391,45.64407 H 48.520099 C 28.90861,227.51727 13.006195,206.98664 13.006195,181.80411 V 80.187338 c 0,-25.159506 15.902415,-45.644066 35.513904,-45.644066 H 152.55325 c 19.57566,0 35.51392,20.4385 35.51392,45.644066 v 8.382665 L 227.756,59.150074 c 6.33409,-4.801607 14.60334,1.162981 14.60334,10.570447 z"
66828
+ }
66829
+ ),
66830
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66831
+ "path",
66832
+ {
66833
+ fill: "white",
66834
+ d: "m 134.24221,179.28573 -6.38,-16.771 H 73.539201 l -6.38,17.135 c -2.492,6.684 -4.618,11.211 -6.38,13.581 -1.763,2.309 -4.649,3.464 -8.659,3.464 -3.403,0 -6.411,-1.246 -9.024,-3.737 -2.613,-2.492 -3.919,-5.317 -3.919,-8.477 0,-1.823 0.304,-3.706 0.911,-5.651 0.608,-1.944 1.611,-4.648 3.008,-8.112 l 34.18,-86.771005 c 0.972,-2.491 2.127,-5.469 3.463,-8.932 1.398,-3.525 2.856,-6.441 4.375,-8.75 1.58,-2.309 3.616,-4.163 6.107,-5.56 2.552005,-1.458 5.682005,-2.188 9.388009,-2.188 3.768,0 6.897,0.73 9.388,2.188 2.552,1.397 4.588,3.22 6.107,5.469 1.58,2.248 2.886,4.678 3.919,7.291 1.094,2.552 2.461,5.986 4.102,10.3 l 34.909,86.224005 c 2.734,6.562 4.101,11.332 4.101,14.31 0,3.099 -1.306,5.955 -3.919,8.568 -2.552,2.552 -5.651,3.828 -9.297,3.828 -2.126,0 -3.949,-0.395 -5.468,-1.185 -1.52,-0.729 -2.796,-1.732 -3.829,-3.008 -1.033,-1.337 -2.157,-3.342 -3.372,-6.016 -1.155,-2.734 -2.157,-5.134 -3.008,-7.2 z m -53.594009,-37.097 h 39.922009 l -20.143,-55.143005 z"
66835
+ }
66836
+ )
66837
+ ] });
66838
+ }
66820
66839
  function orbit({ height, width, fill: fill2 = "", className }) {
66821
66840
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66822
66841
  /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
@@ -67340,6 +67359,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67340
67359
  const icons = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
67341
67360
  __proto__: null,
67342
67361
  arrowLeft,
67362
+ autoCamera,
67343
67363
  camera,
67344
67364
  checkmark,
67345
67365
  close,
@@ -67486,7 +67506,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67486
67506
  );
67487
67507
  };
67488
67508
  const onHomeBtn = () => {
67489
- props.camera.reset();
67509
+ props.camera.reset.call();
67490
67510
  };
67491
67511
  const btnStyle2 = "vim-axes-button vc-flex vc-items-center vc-justify-center vc-text-gray-medium vc-transition-all hover:vc-text-primary-royal";
67492
67512
  const btnIsolation = /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -67580,12 +67600,14 @@ Averrage Date/Second ${avgDataRatePS} kb
67580
67600
  const ids = {
67581
67601
  // Sections
67582
67602
  sectionCamera: "controlBar.sectionCamera",
67603
+ sectionInputs: "controlBar.sectionInputs",
67583
67604
  sectionActions: "controlBar.sectionActions",
67584
67605
  sectionTools: "controlBar.sectionTools",
67585
67606
  sectionSettings: "controlBar.sectionSettings",
67586
67607
  sectionMeasure: "controlBar.sectionMeasure",
67587
67608
  sectionSectionBox: "controlBar.sectionSectionBox",
67588
67609
  // Camera buttons
67610
+ buttonCameraAuto: "controlBar.camera.auto",
67589
67611
  buttonCameraOrbit: "controlBar.camera.orbit",
67590
67612
  buttonCameraLook: "controlBarcamera.look",
67591
67613
  buttonCameraPan: "controlBar.camera.pan",
@@ -67607,7 +67629,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67607
67629
  buttonSectionBoxVisible: "controlBar.sectionBox.visible",
67608
67630
  buttonSectionBoxShrinkToSelection: "controlBar.sectionBox.shrinkToSelection",
67609
67631
  buttonSectionBoxAuto: "controlBar.sectionBox.auto",
67610
- buttonSectionBoxClip: "controlBar.sectionBox.clip",
67632
+ buttonSectionBoxReset: "controlBar.sectionBox.reset",
67611
67633
  buttonSectionBoxSettings: "controlBar.sectionBox.settings"
67612
67634
  };
67613
67635
  function ControlBar(props) {
@@ -67849,7 +67871,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67849
67871
  icon: sectionBoxShrink
67850
67872
  },
67851
67873
  {
67852
- id: ids.buttonSectionBoxClip,
67874
+ id: ids.buttonSectionBoxReset,
67853
67875
  tip: "Reset Section",
67854
67876
  enabled: () => section.enable.get(),
67855
67877
  style: (on) => buttonDefaultStyle(on),
@@ -67889,7 +67911,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67889
67911
  function controlBarPointer(viewer, camera2, settings2, section) {
67890
67912
  const pointer = getPointerState(viewer);
67891
67913
  return {
67892
- id: ids.sectionCamera,
67914
+ id: ids.sectionInputs,
67893
67915
  enable: () => anyUiCursorButton(settings2),
67894
67916
  style: sectionDefaultStyle,
67895
67917
  buttons: [
@@ -67953,7 +67975,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67953
67975
  id: ids.buttonZoomToFit,
67954
67976
  enabled: () => isTrue(settings2.ui.zoomToFit),
67955
67977
  tip: "Zoom to Fit",
67956
- action: () => camera2.frameContext(),
67978
+ action: () => camera2.frameSelection.call(),
67957
67979
  icon: frameSelection,
67958
67980
  isOn: () => false,
67959
67981
  style: buttonDefaultStyle
@@ -68020,15 +68042,34 @@ Averrage Date/Second ${avgDataRatePS} kb
68020
68042
  ]
68021
68043
  };
68022
68044
  }
68045
+ function controlBarCamera(camera2) {
68046
+ return {
68047
+ id: ids.sectionCamera,
68048
+ enable: () => true,
68049
+ style: sectionDefaultStyle,
68050
+ buttons: [
68051
+ {
68052
+ id: ids.buttonCameraAuto,
68053
+ tip: "Auto Camera",
68054
+ isOn: () => camera2.autoCamera.get(),
68055
+ action: () => camera2.autoCamera.set(!camera2.autoCamera.get()),
68056
+ icon: autoCamera,
68057
+ style: buttonDefaultStyle
68058
+ }
68059
+ ]
68060
+ };
68061
+ }
68023
68062
  function useControlBar(viewer, camera2, modal, side, isolation, cursor, settings2, section, customization) {
68024
68063
  const measure2 = getMeasureState(viewer, cursor);
68025
68064
  const pointerSection = controlBarPointer(viewer, camera2, settings2);
68026
68065
  const actionSection = controlBarActions(camera2, settings2, isolation, measure2);
68027
68066
  const sectionBoxSection = controlBarSectionBox(section, viewer.selection.count > 0);
68028
68067
  const settingsSection = controlBarSettings(modal, side, settings2);
68068
+ const cameraSection = controlBarCamera(camera2);
68029
68069
  let controlBarSections = [
68030
68070
  pointerSection,
68031
68071
  actionSection,
68072
+ cameraSection,
68032
68073
  sectionBoxSection,
68033
68074
  // Optional section
68034
68075
  settingsSection
@@ -72054,11 +72095,11 @@ Averrage Date/Second ${avgDataRatePS} kb
72054
72095
  e.stopPropagation();
72055
72096
  };
72056
72097
  const onCameraResetBtn = (e) => {
72057
- camera2.reset();
72098
+ camera2.reset.call();
72058
72099
  e.stopPropagation();
72059
72100
  };
72060
72101
  const onCameraFrameBtn = (e) => {
72061
- camera2.frameContext();
72102
+ camera2.frameSelection.call();
72062
72103
  e.stopPropagation();
72063
72104
  };
72064
72105
  const onSelectionIsolateBtn = (e) => {
@@ -72390,7 +72431,7 @@ Averrage Date/Second ${avgDataRatePS} kb
72390
72431
  createInteractiveElementProps: (item, treeId, actions, renderFlags) => ({
72391
72432
  onKeyUp: (e) => {
72392
72433
  if (e.key === "f") {
72393
- props.camera.frameContext();
72434
+ props.camera.frameSelection.call();
72394
72435
  }
72395
72436
  if (e.key === "Escape") {
72396
72437
  props.viewer.selection.clear();
@@ -72433,7 +72474,7 @@ Averrage Date/Second ${avgDataRatePS} kb
72433
72474
  },
72434
72475
  onPrimaryAction: (item, _) => {
72435
72476
  if (doubleClick.isDoubleClick(item.index)) {
72436
- props.camera.frameSelection();
72477
+ props.camera.frameSelection.call();
72437
72478
  }
72438
72479
  },
72439
72480
  onFocusItem: (item) => {
@@ -74724,7 +74765,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74724
74765
  return true;
74725
74766
  }
74726
74767
  case KEYS.KEY_F: {
74727
- this._camera.frameContext();
74768
+ this._camera.frameSelection.call();
74728
74769
  return true;
74729
74770
  }
74730
74771
  case KEYS.KEY_I: {
@@ -74918,7 +74959,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74918
74959
  if (!this._settings.isolation.enable) return;
74919
74960
  this._isolation = objects ?? [];
74920
74961
  this._apply(source);
74921
- this._camera.frameVisibleObjects();
74962
+ this._camera.frameVisibleObjects.call();
74922
74963
  }
74923
74964
  /**
74924
74965
  * Toggles isolation by using the current selection.
@@ -74933,7 +74974,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74933
74974
  if (!this._settings.isolation.enable) return;
74934
74975
  this._isolation = [...this._viewer.selection.objects].filter((o) => o.type === "Object3D");
74935
74976
  this._apply(source);
74936
- this._camera.frameVisibleObjects();
74977
+ this._camera.frameVisibleObjects.call();
74937
74978
  this._viewer.selection.clear();
74938
74979
  }
74939
74980
  /**
@@ -75033,74 +75074,139 @@ Averrage Date/Second ${avgDataRatePS} kb
75033
75074
  return objects;
75034
75075
  }
75035
75076
  }
75036
- class ComponentCamera {
75037
- constructor(viewer) {
75038
- __publicField(this, "_viewer");
75039
- this._viewer = viewer;
75040
- }
75041
- /**
75042
- * Resets the camera to its initial position.
75043
- */
75044
- reset() {
75045
- this._viewer.camera.lerp(1).reset();
75046
- }
75047
- /**
75048
- * Frames selected elements if there is an active selection; otherwise, frames all visible objects.
75049
- * @param duration Optional duration of the camera movement animation (default: 1).
75050
- */
75051
- frameContext(duration = 1) {
75052
- if (this._viewer.selection.count > 0) {
75053
- this.frameSelection(duration);
75054
- } else {
75055
- this.frameVisibleObjects(void 0, duration);
75077
+ function useStateRef(initialValue) {
75078
+ const [value, setValue] = React2.useState(initialValue);
75079
+ const ref = React2.useRef(initialValue);
75080
+ const event = React2.useRef(new distExports.SimpleEventDispatcher());
75081
+ const validate = React2.useRef((value2) => value2);
75082
+ const confirm = React2.useRef((value2) => value2);
75083
+ const set2 = (value2) => {
75084
+ const finalValue = validate.current(value2) ?? value2;
75085
+ if (finalValue === void 0) return;
75086
+ if (finalValue === ref.current) return;
75087
+ ref.current = finalValue;
75088
+ setValue(finalValue);
75089
+ event.current.dispatch(finalValue);
75090
+ };
75091
+ return {
75092
+ get() {
75093
+ return ref.current;
75094
+ },
75095
+ set: set2,
75096
+ confirm() {
75097
+ set2(confirm.current(ref.current));
75098
+ },
75099
+ useOnChange(on) {
75100
+ React2.useEffect(() => {
75101
+ return event.current.subscribe(on);
75102
+ }, []);
75103
+ },
75104
+ useMemo(on, deps) {
75105
+ return React2.useMemo(() => on(value), [...deps || [], value]);
75106
+ },
75107
+ useValidate(on) {
75108
+ React2.useEffect(() => {
75109
+ validate.current = on;
75110
+ }, []);
75111
+ },
75112
+ useConfirm(on) {
75113
+ React2.useEffect(() => {
75114
+ confirm.current = on;
75115
+ }, []);
75056
75116
  }
75057
- }
75058
- /**
75059
- * Frames selected elements if there is an active selection; otherwise, does nothing.
75060
- * @param duration Optional duration of the camera movement animation (default: 1).
75061
- */
75062
- frameSelection(duration = 1) {
75063
- if (this._viewer.selection.count === 0) return;
75064
- const box = this._viewer.selection.getBoundingBox();
75065
- if (box && this._viewer.gizmos.sectionBox.box.intersectsBox(box)) {
75066
- const movement = duration === 0 ? this._viewer.camera.snap() : this._viewer.camera.lerp(duration);
75067
- movement.frame(box);
75117
+ };
75118
+ }
75119
+ function useActionRef(action) {
75120
+ const ref = React2.useRef(action);
75121
+ return {
75122
+ call() {
75123
+ ref == null ? void 0 : ref.current();
75124
+ },
75125
+ set(func) {
75126
+ ref.current = func;
75068
75127
  }
75069
- }
75070
- /**
75071
- * Frames all visible objects in the scene.
75072
- * @param source Optional VIM to specify the source of objects to frame.
75073
- * @param duration Duration of the camera movement animation (default: 1).
75074
- */
75075
- frameVisibleObjects(source, duration = 1) {
75076
- const movement = duration === 0 ? this._viewer.camera.snap() : this._viewer.camera.lerp(duration);
75077
- const box = this.getVisibleBoundingBox(source);
75078
- movement.frame(box);
75079
- }
75080
- /**
75081
- * Returns the bounding box of all visible objects.
75082
- * @param source Optional VIM to specify the source of visible objects.
75083
- * @returns The bounding box of all visible objects.
75084
- */
75085
- getVisibleBoundingBox(source) {
75086
- let box;
75087
- const vimBoxUnion = (vim) => {
75088
- for (const obj of vim.getObjects()) {
75089
- if (!obj.visible) continue;
75090
- const b = obj.getBoundingBox();
75091
- if (!b) continue;
75092
- box = box ? box.union(b) : b == null ? void 0 : b.clone();
75093
- }
75094
- };
75095
- if (source) {
75096
- vimBoxUnion(source);
75097
- } else {
75098
- for (const vim of this._viewer.vims) {
75099
- vimBoxUnion(vim);
75128
+ };
75129
+ }
75130
+ function useArgActionRef(action) {
75131
+ const ref = React2.useRef(action);
75132
+ return {
75133
+ call(arg) {
75134
+ ref == null ? void 0 : ref.current(arg);
75135
+ },
75136
+ set(func) {
75137
+ ref.current = func;
75138
+ }
75139
+ };
75140
+ }
75141
+ function useFuncRef(func) {
75142
+ const ref = React2.useRef(func);
75143
+ return {
75144
+ call() {
75145
+ return ref == null ? void 0 : ref.current();
75146
+ },
75147
+ set(func2) {
75148
+ ref.current = func2;
75149
+ }
75150
+ };
75151
+ }
75152
+ function useCamera(viewer) {
75153
+ const autoCamera2 = useStateRef(false);
75154
+ autoCamera2.useOnChange((v) => {
75155
+ if (v) {
75156
+ frameSelection2.call();
75157
+ }
75158
+ });
75159
+ React2.useEffect(() => {
75160
+ viewer.selection.onValueChanged.sub(() => {
75161
+ if (autoCamera2.get()) {
75162
+ frameSelection2.call();
75100
75163
  }
75164
+ });
75165
+ }, []);
75166
+ const reset = useActionRef(() => viewer.camera.lerp(1).reset());
75167
+ const frameSelection2 = useActionRef(() => {
75168
+ if (viewer.selection.count === 0) {
75169
+ frameVisibleObjects.call();
75170
+ return;
75171
+ }
75172
+ const box = viewer.selection.getBoundingBox();
75173
+ if (!box) {
75174
+ return;
75175
+ }
75176
+ box.intersect(viewer.gizmos.sectionBox.box);
75177
+ if (box.isEmpty()) {
75178
+ return;
75179
+ }
75180
+ viewer.camera.lerp(1).frame(box);
75181
+ });
75182
+ const frameVisibleObjects = useActionRef(() => {
75183
+ const movement = viewer.camera.lerp(1);
75184
+ const box = getVisibleBoundingBox(viewer);
75185
+ movement.frame(box);
75186
+ });
75187
+ return {
75188
+ autoCamera: autoCamera2,
75189
+ reset,
75190
+ frameSelection: frameSelection2,
75191
+ frameVisibleObjects
75192
+ };
75193
+ }
75194
+ function getVisibleBoundingBox(viewer, source) {
75195
+ let box;
75196
+ const vimBoxUnion = (vim) => {
75197
+ for (const obj of vim.getObjects()) {
75198
+ if (!obj.visible) continue;
75199
+ const b = obj.getBoundingBox();
75200
+ if (!b) continue;
75201
+ box = box ? box.union(b) : b == null ? void 0 : b.clone();
75202
+ }
75203
+ };
75204
+ {
75205
+ for (const vim of viewer.vims) {
75206
+ vimBoxUnion(vim);
75101
75207
  }
75102
- return box;
75103
75208
  }
75209
+ return box;
75104
75210
  }
75105
75211
  function createContainer(element) {
75106
75212
  let root = element;
@@ -75813,70 +75919,6 @@ Averrage Date/Second ${avgDataRatePS} kb
75813
75919
  r.max.z += b2.max.z;
75814
75920
  return r;
75815
75921
  }
75816
- function useStateRef(initialValue) {
75817
- const [value, setValue] = React2.useState(initialValue);
75818
- const ref = React2.useRef(initialValue);
75819
- const event = React2.useRef(new distExports.SimpleEventDispatcher());
75820
- const validate = React2.useRef((value2) => value2);
75821
- const confirm = React2.useRef((value2) => value2);
75822
- const set2 = (value2) => {
75823
- const finalValue = validate.current(value2) ?? value2;
75824
- if (finalValue === void 0) return;
75825
- if (finalValue === ref.current) return;
75826
- ref.current = finalValue;
75827
- setValue(finalValue);
75828
- event.current.dispatch(finalValue);
75829
- };
75830
- return {
75831
- get() {
75832
- return ref.current;
75833
- },
75834
- set: set2,
75835
- confirm() {
75836
- set2(confirm.current(ref.current));
75837
- },
75838
- useOnChange(on) {
75839
- React2.useEffect(() => {
75840
- return event.current.subscribe(on);
75841
- }, []);
75842
- },
75843
- useMemo(on, deps) {
75844
- return React2.useMemo(() => on(value), [...deps || [], value]);
75845
- },
75846
- useValidate(on) {
75847
- React2.useEffect(() => {
75848
- validate.current = on;
75849
- }, []);
75850
- },
75851
- useConfirm(on) {
75852
- React2.useEffect(() => {
75853
- confirm.current = on;
75854
- }, []);
75855
- }
75856
- };
75857
- }
75858
- function useArgActionRef(action) {
75859
- const ref = React2.useRef(action);
75860
- return {
75861
- call(arg) {
75862
- ref == null ? void 0 : ref.current(arg);
75863
- },
75864
- set(func) {
75865
- ref.current = func;
75866
- }
75867
- };
75868
- }
75869
- function useFuncRef(func) {
75870
- const ref = React2.useRef(func);
75871
- return {
75872
- call() {
75873
- return ref == null ? void 0 : ref.current();
75874
- },
75875
- set(func2) {
75876
- ref.current = func2;
75877
- }
75878
- };
75879
- }
75880
75922
  function useSectionBox(adapter) {
75881
75923
  const enable = useStateRef(false);
75882
75924
  const visible2 = useStateRef(false);
@@ -76009,7 +76051,7 @@ Averrage Date/Second ${avgDataRatePS} kb
76009
76051
  var _a2;
76010
76052
  const settings2 = useSettings(props.viewer, props.settings ?? {});
76011
76053
  const modal = useModal(settings2.value.capacity.canFollowUrl);
76012
- const camera2 = React2.useMemo(() => new ComponentCamera(props.viewer), []);
76054
+ const camera2 = useCamera(props.viewer);
76013
76055
  const cursor = React2.useMemo(() => new CursorManager(props.viewer), []);
76014
76056
  const loader = React2.useRef(new ComponentLoader(props.viewer, modal));
76015
76057
  const [isolation] = React2.useState(() => new Isolation(props.viewer, camera2, settings2.value));