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.
package/dist/vim-web.js CHANGED
@@ -66801,6 +66801,25 @@ function hidden({ height, width, fill: fill2, className = "" }) {
66801
66801
  }
66802
66802
  );
66803
66803
  }
66804
+ function autoCamera({ height, width, fill: fill2 = "", className }) {
66805
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66806
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
66807
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66808
+ "path",
66809
+ {
66810
+ fill: fill2,
66811
+ 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"
66812
+ }
66813
+ ),
66814
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66815
+ "path",
66816
+ {
66817
+ fill: "white",
66818
+ 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"
66819
+ }
66820
+ )
66821
+ ] });
66822
+ }
66804
66823
  function orbit({ height, width, fill: fill2 = "", className }) {
66805
66824
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66806
66825
  /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
@@ -67324,6 +67343,7 @@ function ghostDead({ height, width, fill: fill2, className }) {
67324
67343
  const icons = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
67325
67344
  __proto__: null,
67326
67345
  arrowLeft,
67346
+ autoCamera,
67327
67347
  camera,
67328
67348
  checkmark,
67329
67349
  close,
@@ -67470,7 +67490,7 @@ function AxesPanel(props) {
67470
67490
  );
67471
67491
  };
67472
67492
  const onHomeBtn = () => {
67473
- props.camera.reset();
67493
+ props.camera.reset.call();
67474
67494
  };
67475
67495
  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";
67476
67496
  const btnIsolation = /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -67564,12 +67584,14 @@ function createSection$1(section) {
67564
67584
  const ids = {
67565
67585
  // Sections
67566
67586
  sectionCamera: "controlBar.sectionCamera",
67587
+ sectionInputs: "controlBar.sectionInputs",
67567
67588
  sectionActions: "controlBar.sectionActions",
67568
67589
  sectionTools: "controlBar.sectionTools",
67569
67590
  sectionSettings: "controlBar.sectionSettings",
67570
67591
  sectionMeasure: "controlBar.sectionMeasure",
67571
67592
  sectionSectionBox: "controlBar.sectionSectionBox",
67572
67593
  // Camera buttons
67594
+ buttonCameraAuto: "controlBar.camera.auto",
67573
67595
  buttonCameraOrbit: "controlBar.camera.orbit",
67574
67596
  buttonCameraLook: "controlBarcamera.look",
67575
67597
  buttonCameraPan: "controlBar.camera.pan",
@@ -67591,7 +67613,7 @@ const ids = {
67591
67613
  buttonSectionBoxVisible: "controlBar.sectionBox.visible",
67592
67614
  buttonSectionBoxShrinkToSelection: "controlBar.sectionBox.shrinkToSelection",
67593
67615
  buttonSectionBoxAuto: "controlBar.sectionBox.auto",
67594
- buttonSectionBoxClip: "controlBar.sectionBox.clip",
67616
+ buttonSectionBoxReset: "controlBar.sectionBox.reset",
67595
67617
  buttonSectionBoxSettings: "controlBar.sectionBox.settings"
67596
67618
  };
67597
67619
  function ControlBar(props) {
@@ -67833,7 +67855,7 @@ function controlBarSectionBox(section, hasSelection) {
67833
67855
  icon: sectionBoxShrink
67834
67856
  },
67835
67857
  {
67836
- id: ids.buttonSectionBoxClip,
67858
+ id: ids.buttonSectionBoxReset,
67837
67859
  tip: "Reset Section",
67838
67860
  enabled: () => section.enable.get(),
67839
67861
  style: (on) => buttonDefaultStyle(on),
@@ -67873,7 +67895,7 @@ function controlBarSectionBox(section, hasSelection) {
67873
67895
  function controlBarPointer(viewer, camera2, settings2, section) {
67874
67896
  const pointer = getPointerState(viewer);
67875
67897
  return {
67876
- id: ids.sectionCamera,
67898
+ id: ids.sectionInputs,
67877
67899
  enable: () => anyUiCursorButton(settings2),
67878
67900
  style: sectionDefaultStyle,
67879
67901
  buttons: [
@@ -67937,7 +67959,7 @@ function controlBarActions(camera2, settings2, isolation, measure$1) {
67937
67959
  id: ids.buttonZoomToFit,
67938
67960
  enabled: () => isTrue(settings2.ui.zoomToFit),
67939
67961
  tip: "Zoom to Fit",
67940
- action: () => camera2.frameContext(),
67962
+ action: () => camera2.frameSelection.call(),
67941
67963
  icon: frameSelection,
67942
67964
  isOn: () => false,
67943
67965
  style: buttonDefaultStyle
@@ -68004,15 +68026,34 @@ function controlBarSettings(modal, side, settings$1) {
68004
68026
  ]
68005
68027
  };
68006
68028
  }
68029
+ function controlBarCamera(camera2) {
68030
+ return {
68031
+ id: ids.sectionCamera,
68032
+ enable: () => true,
68033
+ style: sectionDefaultStyle,
68034
+ buttons: [
68035
+ {
68036
+ id: ids.buttonCameraAuto,
68037
+ tip: "Auto Camera",
68038
+ isOn: () => camera2.autoCamera.get(),
68039
+ action: () => camera2.autoCamera.set(!camera2.autoCamera.get()),
68040
+ icon: autoCamera,
68041
+ style: buttonDefaultStyle
68042
+ }
68043
+ ]
68044
+ };
68045
+ }
68007
68046
  function useControlBar(viewer, camera2, modal, side, isolation, cursor, settings2, section, customization) {
68008
68047
  const measure2 = getMeasureState(viewer, cursor);
68009
68048
  const pointerSection = controlBarPointer(viewer, camera2, settings2);
68010
68049
  const actionSection = controlBarActions(camera2, settings2, isolation, measure2);
68011
68050
  const sectionBoxSection = controlBarSectionBox(section, viewer.selection.count > 0);
68012
68051
  const settingsSection = controlBarSettings(modal, side, settings2);
68052
+ const cameraSection = controlBarCamera(camera2);
68013
68053
  let controlBarSections = [
68014
68054
  pointerSection,
68015
68055
  actionSection,
68056
+ cameraSection,
68016
68057
  sectionBoxSection,
68017
68058
  // Optional section
68018
68059
  settingsSection
@@ -72038,11 +72079,11 @@ function VimContextMenu(props) {
72038
72079
  e.stopPropagation();
72039
72080
  };
72040
72081
  const onCameraResetBtn = (e) => {
72041
- camera2.reset();
72082
+ camera2.reset.call();
72042
72083
  e.stopPropagation();
72043
72084
  };
72044
72085
  const onCameraFrameBtn = (e) => {
72045
- camera2.frameContext();
72086
+ camera2.frameSelection.call();
72046
72087
  e.stopPropagation();
72047
72088
  };
72048
72089
  const onSelectionIsolateBtn = (e) => {
@@ -72374,7 +72415,7 @@ function BimTree(props) {
72374
72415
  createInteractiveElementProps: (item, treeId, actions, renderFlags) => ({
72375
72416
  onKeyUp: (e) => {
72376
72417
  if (e.key === "f") {
72377
- props.camera.frameContext();
72418
+ props.camera.frameSelection.call();
72378
72419
  }
72379
72420
  if (e.key === "Escape") {
72380
72421
  props.viewer.selection.clear();
@@ -72417,7 +72458,7 @@ function BimTree(props) {
72417
72458
  },
72418
72459
  onPrimaryAction: (item, _) => {
72419
72460
  if (doubleClick.isDoubleClick(item.index)) {
72420
- props.camera.frameSelection();
72461
+ props.camera.frameSelection.call();
72421
72462
  }
72422
72463
  },
72423
72464
  onFocusItem: (item) => {
@@ -74708,7 +74749,7 @@ class ComponentInputs {
74708
74749
  return true;
74709
74750
  }
74710
74751
  case KEYS.KEY_F: {
74711
- this._camera.frameContext();
74752
+ this._camera.frameSelection.call();
74712
74753
  return true;
74713
74754
  }
74714
74755
  case KEYS.KEY_I: {
@@ -74902,7 +74943,7 @@ class Isolation {
74902
74943
  if (!this._settings.isolation.enable) return;
74903
74944
  this._isolation = objects ?? [];
74904
74945
  this._apply(source);
74905
- this._camera.frameVisibleObjects();
74946
+ this._camera.frameVisibleObjects.call();
74906
74947
  }
74907
74948
  /**
74908
74949
  * Toggles isolation by using the current selection.
@@ -74917,7 +74958,7 @@ class Isolation {
74917
74958
  if (!this._settings.isolation.enable) return;
74918
74959
  this._isolation = [...this._viewer.selection.objects].filter((o) => o.type === "Object3D");
74919
74960
  this._apply(source);
74920
- this._camera.frameVisibleObjects();
74961
+ this._camera.frameVisibleObjects.call();
74921
74962
  this._viewer.selection.clear();
74922
74963
  }
74923
74964
  /**
@@ -75017,74 +75058,139 @@ class Isolation {
75017
75058
  return objects;
75018
75059
  }
75019
75060
  }
75020
- class ComponentCamera {
75021
- constructor(viewer) {
75022
- __publicField(this, "_viewer");
75023
- this._viewer = viewer;
75024
- }
75025
- /**
75026
- * Resets the camera to its initial position.
75027
- */
75028
- reset() {
75029
- this._viewer.camera.lerp(1).reset();
75030
- }
75031
- /**
75032
- * Frames selected elements if there is an active selection; otherwise, frames all visible objects.
75033
- * @param duration Optional duration of the camera movement animation (default: 1).
75034
- */
75035
- frameContext(duration = 1) {
75036
- if (this._viewer.selection.count > 0) {
75037
- this.frameSelection(duration);
75038
- } else {
75039
- this.frameVisibleObjects(void 0, duration);
75061
+ function useStateRef(initialValue) {
75062
+ const [value, setValue] = useState(initialValue);
75063
+ const ref = useRef(initialValue);
75064
+ const event = useRef(new distExports.SimpleEventDispatcher());
75065
+ const validate = useRef((value2) => value2);
75066
+ const confirm = useRef((value2) => value2);
75067
+ const set3 = (value2) => {
75068
+ const finalValue = validate.current(value2) ?? value2;
75069
+ if (finalValue === void 0) return;
75070
+ if (finalValue === ref.current) return;
75071
+ ref.current = finalValue;
75072
+ setValue(finalValue);
75073
+ event.current.dispatch(finalValue);
75074
+ };
75075
+ return {
75076
+ get() {
75077
+ return ref.current;
75078
+ },
75079
+ set: set3,
75080
+ confirm() {
75081
+ set3(confirm.current(ref.current));
75082
+ },
75083
+ useOnChange(on) {
75084
+ useEffect(() => {
75085
+ return event.current.subscribe(on);
75086
+ }, []);
75087
+ },
75088
+ useMemo(on, deps) {
75089
+ return useMemo(() => on(value), [...deps || [], value]);
75090
+ },
75091
+ useValidate(on) {
75092
+ useEffect(() => {
75093
+ validate.current = on;
75094
+ }, []);
75095
+ },
75096
+ useConfirm(on) {
75097
+ useEffect(() => {
75098
+ confirm.current = on;
75099
+ }, []);
75040
75100
  }
75041
- }
75042
- /**
75043
- * Frames selected elements if there is an active selection; otherwise, does nothing.
75044
- * @param duration Optional duration of the camera movement animation (default: 1).
75045
- */
75046
- frameSelection(duration = 1) {
75047
- if (this._viewer.selection.count === 0) return;
75048
- const box = this._viewer.selection.getBoundingBox();
75049
- if (box && this._viewer.gizmos.sectionBox.box.intersectsBox(box)) {
75050
- const movement = duration === 0 ? this._viewer.camera.snap() : this._viewer.camera.lerp(duration);
75051
- movement.frame(box);
75101
+ };
75102
+ }
75103
+ function useActionRef(action) {
75104
+ const ref = useRef(action);
75105
+ return {
75106
+ call() {
75107
+ ref == null ? void 0 : ref.current();
75108
+ },
75109
+ set(func) {
75110
+ ref.current = func;
75052
75111
  }
75053
- }
75054
- /**
75055
- * Frames all visible objects in the scene.
75056
- * @param source Optional VIM to specify the source of objects to frame.
75057
- * @param duration Duration of the camera movement animation (default: 1).
75058
- */
75059
- frameVisibleObjects(source, duration = 1) {
75060
- const movement = duration === 0 ? this._viewer.camera.snap() : this._viewer.camera.lerp(duration);
75061
- const box = this.getVisibleBoundingBox(source);
75062
- movement.frame(box);
75063
- }
75064
- /**
75065
- * Returns the bounding box of all visible objects.
75066
- * @param source Optional VIM to specify the source of visible objects.
75067
- * @returns The bounding box of all visible objects.
75068
- */
75069
- getVisibleBoundingBox(source) {
75070
- let box;
75071
- const vimBoxUnion = (vim) => {
75072
- for (const obj of vim.getObjects()) {
75073
- if (!obj.visible) continue;
75074
- const b = obj.getBoundingBox();
75075
- if (!b) continue;
75076
- box = box ? box.union(b) : b == null ? void 0 : b.clone();
75077
- }
75078
- };
75079
- if (source) {
75080
- vimBoxUnion(source);
75081
- } else {
75082
- for (const vim of this._viewer.vims) {
75083
- vimBoxUnion(vim);
75112
+ };
75113
+ }
75114
+ function useArgActionRef(action) {
75115
+ const ref = useRef(action);
75116
+ return {
75117
+ call(arg) {
75118
+ ref == null ? void 0 : ref.current(arg);
75119
+ },
75120
+ set(func) {
75121
+ ref.current = func;
75122
+ }
75123
+ };
75124
+ }
75125
+ function useFuncRef(func) {
75126
+ const ref = useRef(func);
75127
+ return {
75128
+ call() {
75129
+ return ref == null ? void 0 : ref.current();
75130
+ },
75131
+ set(func2) {
75132
+ ref.current = func2;
75133
+ }
75134
+ };
75135
+ }
75136
+ function useCamera(viewer) {
75137
+ const autoCamera2 = useStateRef(false);
75138
+ autoCamera2.useOnChange((v) => {
75139
+ if (v) {
75140
+ frameSelection2.call();
75141
+ }
75142
+ });
75143
+ useEffect(() => {
75144
+ viewer.selection.onValueChanged.sub(() => {
75145
+ if (autoCamera2.get()) {
75146
+ frameSelection2.call();
75084
75147
  }
75148
+ });
75149
+ }, []);
75150
+ const reset = useActionRef(() => viewer.camera.lerp(1).reset());
75151
+ const frameSelection2 = useActionRef(() => {
75152
+ if (viewer.selection.count === 0) {
75153
+ frameVisibleObjects.call();
75154
+ return;
75155
+ }
75156
+ const box = viewer.selection.getBoundingBox();
75157
+ if (!box) {
75158
+ return;
75159
+ }
75160
+ box.intersect(viewer.gizmos.sectionBox.box);
75161
+ if (box.isEmpty()) {
75162
+ return;
75163
+ }
75164
+ viewer.camera.lerp(1).frame(box);
75165
+ });
75166
+ const frameVisibleObjects = useActionRef(() => {
75167
+ const movement = viewer.camera.lerp(1);
75168
+ const box = getVisibleBoundingBox(viewer);
75169
+ movement.frame(box);
75170
+ });
75171
+ return {
75172
+ autoCamera: autoCamera2,
75173
+ reset,
75174
+ frameSelection: frameSelection2,
75175
+ frameVisibleObjects
75176
+ };
75177
+ }
75178
+ function getVisibleBoundingBox(viewer, source) {
75179
+ let box;
75180
+ const vimBoxUnion = (vim) => {
75181
+ for (const obj of vim.getObjects()) {
75182
+ if (!obj.visible) continue;
75183
+ const b = obj.getBoundingBox();
75184
+ if (!b) continue;
75185
+ box = box ? box.union(b) : b == null ? void 0 : b.clone();
75186
+ }
75187
+ };
75188
+ {
75189
+ for (const vim of viewer.vims) {
75190
+ vimBoxUnion(vim);
75085
75191
  }
75086
- return box;
75087
75192
  }
75193
+ return box;
75088
75194
  }
75089
75195
  function createContainer(element) {
75090
75196
  let root = element;
@@ -75797,70 +75903,6 @@ function addBox(b1, b2) {
75797
75903
  r.max.z += b2.max.z;
75798
75904
  return r;
75799
75905
  }
75800
- function useStateRef(initialValue) {
75801
- const [value, setValue] = useState(initialValue);
75802
- const ref = useRef(initialValue);
75803
- const event = useRef(new distExports.SimpleEventDispatcher());
75804
- const validate = useRef((value2) => value2);
75805
- const confirm = useRef((value2) => value2);
75806
- const set3 = (value2) => {
75807
- const finalValue = validate.current(value2) ?? value2;
75808
- if (finalValue === void 0) return;
75809
- if (finalValue === ref.current) return;
75810
- ref.current = finalValue;
75811
- setValue(finalValue);
75812
- event.current.dispatch(finalValue);
75813
- };
75814
- return {
75815
- get() {
75816
- return ref.current;
75817
- },
75818
- set: set3,
75819
- confirm() {
75820
- set3(confirm.current(ref.current));
75821
- },
75822
- useOnChange(on) {
75823
- useEffect(() => {
75824
- return event.current.subscribe(on);
75825
- }, []);
75826
- },
75827
- useMemo(on, deps) {
75828
- return useMemo(() => on(value), [...deps || [], value]);
75829
- },
75830
- useValidate(on) {
75831
- useEffect(() => {
75832
- validate.current = on;
75833
- }, []);
75834
- },
75835
- useConfirm(on) {
75836
- useEffect(() => {
75837
- confirm.current = on;
75838
- }, []);
75839
- }
75840
- };
75841
- }
75842
- function useArgActionRef(action) {
75843
- const ref = useRef(action);
75844
- return {
75845
- call(arg) {
75846
- ref == null ? void 0 : ref.current(arg);
75847
- },
75848
- set(func) {
75849
- ref.current = func;
75850
- }
75851
- };
75852
- }
75853
- function useFuncRef(func) {
75854
- const ref = useRef(func);
75855
- return {
75856
- call() {
75857
- return ref == null ? void 0 : ref.current();
75858
- },
75859
- set(func2) {
75860
- ref.current = func2;
75861
- }
75862
- };
75863
- }
75864
75906
  function useSectionBox(adapter) {
75865
75907
  const enable = useStateRef(false);
75866
75908
  const visible2 = useStateRef(false);
@@ -75993,7 +76035,7 @@ function VimComponent(props) {
75993
76035
  var _a2;
75994
76036
  const settings2 = useSettings(props.viewer, props.settings ?? {});
75995
76037
  const modal = useModal(settings2.value.capacity.canFollowUrl);
75996
- const camera2 = useMemo(() => new ComponentCamera(props.viewer), []);
76038
+ const camera2 = useCamera(props.viewer);
75997
76039
  const cursor = useMemo(() => new CursorManager(props.viewer), []);
75998
76040
  const loader = useRef(new ComponentLoader(props.viewer, modal));
75999
76041
  const [isolation] = useState(() => new Isolation(props.viewer, camera2, settings2.value));