vim-web 0.3.44-dev.16 → 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
@@ -45819,7 +45819,7 @@ class ElementNoMapping {
45819
45819
  }
45820
45820
  }
45821
45821
  class ElementMapping {
45822
- constructor(instances, instanceToElement, elementIds2, instanceMeshes) {
45822
+ constructor(instances, instanceToElement, elementIds, instanceMeshes) {
45823
45823
  __publicField(this, "_instanceToElement");
45824
45824
  __publicField(this, "_instanceMeshes");
45825
45825
  __publicField(this, "_elementToInstances");
@@ -45832,17 +45832,17 @@ class ElementMapping {
45832
45832
  this._elementToInstances = ElementMapping.invertMap(
45833
45833
  this._instanceToElement
45834
45834
  );
45835
- this._elementIds = elementIds2;
45836
- this._elementIdToElements = ElementMapping.invertArray(elementIds2);
45835
+ this._elementIds = elementIds;
45836
+ this._elementIdToElements = ElementMapping.invertArray(elementIds);
45837
45837
  this._instanceMeshes = instanceMeshes;
45838
45838
  }
45839
45839
  static async fromG3d(g3d2, bim) {
45840
45840
  const instanceToElement = await bim.node.getAllElementIndex();
45841
- const elementIds2 = await bim.element.getAllId();
45841
+ const elementIds = await bim.element.getAllId();
45842
45842
  return new ElementMapping(
45843
45843
  Array.from(g3d2.instanceNodes),
45844
45844
  instanceToElement,
45845
- elementIds2,
45845
+ elementIds,
45846
45846
  g3d2.instanceMeshes
45847
45847
  );
45848
45848
  }
@@ -60796,8 +60796,8 @@ class Vim2 {
60796
60796
  if (nodes === "all") {
60797
60797
  this._rpc.RPCClearMaterialOverrides(this._handle);
60798
60798
  } else {
60799
- const ids = new Array(nodes.length).fill(MaterialHandles.Invalid);
60800
- this._rpc.RPCSetMaterialOverrides(this._handle, nodes, ids);
60799
+ const ids2 = new Array(nodes.length).fill(MaterialHandles.Invalid);
60800
+ this._rpc.RPCSetMaterialOverrides(this._handle, nodes, ids2);
60801
60801
  }
60802
60802
  }
60803
60803
  updateMap(nodes, state) {
@@ -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(
@@ -67561,15 +67581,17 @@ function createSection$1(section) {
67561
67581
  if (section.enable !== void 0 && !section.enable()) return null;
67562
67582
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `vim-control-bar-section ${section.style ?? sectionDefaultStyle}`, children: section.buttons.map((b) => createButton(b)) }, section.id);
67563
67583
  }
67564
- const elementIds = {
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 elementIds = {
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) {
@@ -67623,7 +67645,7 @@ const controlBar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
67623
67645
  buttonExpandStyle,
67624
67646
  createButton,
67625
67647
  createSection: createSection$1,
67626
- elementIds,
67648
+ ids,
67627
67649
  sectionBlueStyle,
67628
67650
  sectionDefaultStyle,
67629
67651
  sectionNoPadStyle
@@ -67811,12 +67833,12 @@ function getMeasureState(viewer, cursor) {
67811
67833
  }
67812
67834
  function controlBarSectionBox(section, hasSelection) {
67813
67835
  return {
67814
- id: elementIds.sectionSectionBox,
67836
+ id: ids.sectionSectionBox,
67815
67837
  style: section.enable.get() ? sectionNoPadStyle : sectionDefaultStyle,
67816
67838
  //enable: () => section.getEnable(),
67817
67839
  buttons: [
67818
67840
  {
67819
- id: elementIds.buttonSectionBoxEnable,
67841
+ id: ids.buttonSectionBoxEnable,
67820
67842
  tip: "Enable Section Box",
67821
67843
  isOn: () => section.enable.get(),
67822
67844
  style: (on) => buttonExpandStyle(on),
@@ -67824,7 +67846,7 @@ function controlBarSectionBox(section, hasSelection) {
67824
67846
  icon: sectionBox
67825
67847
  },
67826
67848
  {
67827
- id: elementIds.buttonSectionBoxShrinkToSelection,
67849
+ id: ids.buttonSectionBoxShrinkToSelection,
67828
67850
  tip: "Fit Section",
67829
67851
  enabled: () => section.enable.get(),
67830
67852
  isOn: () => hasSelection,
@@ -67833,7 +67855,7 @@ function controlBarSectionBox(section, hasSelection) {
67833
67855
  icon: sectionBoxShrink
67834
67856
  },
67835
67857
  {
67836
- id: elementIds.buttonSectionBoxClip,
67858
+ id: ids.buttonSectionBoxReset,
67837
67859
  tip: "Reset Section",
67838
67860
  enabled: () => section.enable.get(),
67839
67861
  style: (on) => buttonDefaultStyle(on),
@@ -67841,7 +67863,7 @@ function controlBarSectionBox(section, hasSelection) {
67841
67863
  icon: sectionBoxReset
67842
67864
  },
67843
67865
  {
67844
- id: elementIds.buttonSectionBoxVisible,
67866
+ id: ids.buttonSectionBoxVisible,
67845
67867
  tip: "Show Section Box",
67846
67868
  enabled: () => section.enable.get(),
67847
67869
  isOn: () => section.visible.get(),
@@ -67850,7 +67872,7 @@ function controlBarSectionBox(section, hasSelection) {
67850
67872
  icon: visible
67851
67873
  },
67852
67874
  {
67853
- id: elementIds.buttonSectionBoxAuto,
67875
+ id: ids.buttonSectionBoxAuto,
67854
67876
  tip: "Auto Section",
67855
67877
  enabled: () => section.enable.get(),
67856
67878
  isOn: () => section.auto.get(),
@@ -67859,7 +67881,7 @@ function controlBarSectionBox(section, hasSelection) {
67859
67881
  icon: sectionBoxAuto
67860
67882
  },
67861
67883
  {
67862
- id: elementIds.buttonSectionBoxSettings,
67884
+ id: ids.buttonSectionBoxSettings,
67863
67885
  tip: "Section Settings",
67864
67886
  enabled: () => section.enable.get(),
67865
67887
  isOn: () => section.showOffsetPanel.get(),
@@ -67873,12 +67895,12 @@ function controlBarSectionBox(section, hasSelection) {
67873
67895
  function controlBarPointer(viewer, camera2, settings2, section) {
67874
67896
  const pointer = getPointerState(viewer);
67875
67897
  return {
67876
- id: elementIds.sectionCamera,
67898
+ id: ids.sectionInputs,
67877
67899
  enable: () => anyUiCursorButton(settings2),
67878
67900
  style: sectionDefaultStyle,
67879
67901
  buttons: [
67880
67902
  {
67881
- id: elementIds.buttonCameraOrbit,
67903
+ id: ids.buttonCameraOrbit,
67882
67904
  enabled: () => isTrue(settings2.ui.orbit),
67883
67905
  tip: "Orbit",
67884
67906
  action: () => pointer.onButton("orbit"),
@@ -67887,7 +67909,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67887
67909
  style: buttonDefaultStyle
67888
67910
  },
67889
67911
  {
67890
- id: elementIds.buttonCameraLook,
67912
+ id: ids.buttonCameraLook,
67891
67913
  enabled: () => isTrue(settings2.ui.lookAround),
67892
67914
  tip: "Look Around",
67893
67915
  action: () => pointer.onButton("look"),
@@ -67896,7 +67918,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67896
67918
  style: buttonDefaultStyle
67897
67919
  },
67898
67920
  {
67899
- id: elementIds.buttonCameraPan,
67921
+ id: ids.buttonCameraPan,
67900
67922
  enabled: () => isTrue(settings2.ui.pan),
67901
67923
  tip: "Pan",
67902
67924
  action: () => pointer.onButton("pan"),
@@ -67905,7 +67927,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67905
67927
  style: buttonDefaultStyle
67906
67928
  },
67907
67929
  {
67908
- id: elementIds.buttonCameraZoom,
67930
+ id: ids.buttonCameraZoom,
67909
67931
  enabled: () => isTrue(settings2.ui.zoom),
67910
67932
  tip: "Zoom",
67911
67933
  action: () => pointer.onButton("zoom"),
@@ -67914,7 +67936,7 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67914
67936
  style: buttonDefaultStyle
67915
67937
  },
67916
67938
  {
67917
- id: elementIds.buttonCameraZoomWindow,
67939
+ id: ids.buttonCameraZoomWindow,
67918
67940
  enabled: () => isTrue(settings2.ui.zoomWindow),
67919
67941
  tip: "Zoom Window",
67920
67942
  action: () => {
@@ -67929,21 +67951,21 @@ function controlBarPointer(viewer, camera2, settings2, section) {
67929
67951
  }
67930
67952
  function controlBarActions(camera2, settings2, isolation, measure$1) {
67931
67953
  return {
67932
- id: elementIds.sectionActions,
67954
+ id: ids.sectionActions,
67933
67955
  enable: () => true,
67934
67956
  style: sectionDefaultStyle,
67935
67957
  buttons: [
67936
67958
  {
67937
- id: elementIds.buttonZoomToFit,
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
67944
67966
  },
67945
67967
  {
67946
- id: elementIds.buttonToggleIsolation,
67968
+ id: ids.buttonToggleIsolation,
67947
67969
  enabled: () => isTrue(settings2.ui.toggleIsolation),
67948
67970
  tip: "Toggle Isolation",
67949
67971
  action: () => isolation.toggle("controlBar"),
@@ -67951,7 +67973,7 @@ function controlBarActions(camera2, settings2, isolation, measure$1) {
67951
67973
  style: buttonDefaultStyle
67952
67974
  },
67953
67975
  {
67954
- id: elementIds.buttonMeasure,
67976
+ id: ids.buttonMeasure,
67955
67977
  enabled: () => isTrue(settings2.ui.measuringMode),
67956
67978
  isOn: () => measure$1.active,
67957
67979
  tip: "Measuring Mode",
@@ -67965,12 +67987,12 @@ function controlBarActions(camera2, settings2, isolation, measure$1) {
67965
67987
  function controlBarSettings(modal, side, settings$1) {
67966
67988
  const fullScreen = getFullScreenState();
67967
67989
  return {
67968
- id: elementIds.sectionSettings,
67990
+ id: ids.sectionSettings,
67969
67991
  enable: () => anyUiSettingButton(settings$1),
67970
67992
  style: sectionDefaultStyle,
67971
67993
  buttons: [
67972
67994
  {
67973
- id: elementIds.buttonProjectInspector,
67995
+ id: ids.buttonProjectInspector,
67974
67996
  enabled: () => isTrue(settings$1.ui.projectInspector) && (isTrue(settings$1.ui.bimTreePanel) || isTrue(settings$1.ui.bimInfoPanel)),
67975
67997
  tip: "Project Inspector",
67976
67998
  action: () => side.toggleContent("bim"),
@@ -67978,7 +68000,7 @@ function controlBarSettings(modal, side, settings$1) {
67978
68000
  style: buttonDefaultStyle
67979
68001
  },
67980
68002
  {
67981
- id: elementIds.buttonSettings,
68003
+ id: ids.buttonSettings,
67982
68004
  enabled: () => isTrue(settings$1.ui.settings),
67983
68005
  tip: "Settings",
67984
68006
  action: () => side.toggleContent("settings"),
@@ -67986,7 +68008,7 @@ function controlBarSettings(modal, side, settings$1) {
67986
68008
  style: buttonDefaultStyle
67987
68009
  },
67988
68010
  {
67989
- id: elementIds.buttonHelp,
68011
+ id: ids.buttonHelp,
67990
68012
  enabled: () => isTrue(settings$1.ui.help),
67991
68013
  tip: "Help",
67992
68014
  action: () => modal.help(true),
@@ -67994,7 +68016,7 @@ function controlBarSettings(modal, side, settings$1) {
67994
68016
  style: buttonDefaultStyle
67995
68017
  },
67996
68018
  {
67997
- id: elementIds.buttonMaximize,
68019
+ id: ids.buttonMaximize,
67998
68020
  enabled: () => isTrue(settings$1.ui.maximise) && settings$1.capacity.canGoFullScreen,
67999
68021
  tip: fullScreen.get() ? "Minimize" : "Fullscreen",
68000
68022
  action: () => fullScreen.toggle(),
@@ -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));
@@ -76494,15 +76536,26 @@ function createUltraComponent(container) {
76494
76536
  function UltraComponent(props) {
76495
76537
  const modal = useModal(true);
76496
76538
  const sectionBox2 = useUltraSectionBox(props.viewer);
76497
- const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, (_2) => _2);
76498
76539
  const side = useSideState(true, 400);
76499
76540
  const [_, setSelectState] = useState(0);
76541
+ const [controlBarCustom, setControlBarCustom] = useState(() => (c) => c);
76542
+ const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, (_2) => _2);
76500
76543
  useEffect(() => {
76501
76544
  props.viewer.onStateChanged.subscribe((state) => updateModal(modal, state));
76502
76545
  props.viewer.selection.onValueChanged.subscribe(() => {
76503
76546
  setSelectState((i) => (i + 1) % 2);
76504
76547
  });
76505
- props.onMount(createComponentRef(props.viewer, modal, sectionBox2));
76548
+ props.onMount({
76549
+ viewer: props.viewer,
76550
+ modal,
76551
+ sectionBox: sectionBox2,
76552
+ dispose: () => {
76553
+ },
76554
+ controlBar: {
76555
+ customize: (v) => setControlBarCustom(() => v)
76556
+ },
76557
+ load: patchLoad(props.viewer, modal)
76558
+ });
76506
76559
  }, []);
76507
76560
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
76508
76561
  /* @__PURE__ */ jsxRuntimeExports.jsx(RestOfScreen, { side, content: () => {
@@ -76512,18 +76565,28 @@ function UltraComponent(props) {
76512
76565
  /* @__PURE__ */ jsxRuntimeExports.jsx(
76513
76566
  ControlBar,
76514
76567
  {
76515
- content: controlBar2,
76568
+ content: controlBarCustom(controlBar2),
76516
76569
  show: true
76517
76570
  }
76518
76571
  ),
76519
76572
  /* @__PURE__ */ jsxRuntimeExports.jsx(SectionBoxPanel, { state: sectionBox2 })
76520
76573
  ] });
76521
76574
  } }),
76522
- /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { state: modal })
76575
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Modal, { state: modal }),
76576
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
76577
+ ReactTooltip,
76578
+ {
76579
+ multiline: true,
76580
+ arrowColor: "transparent",
76581
+ type: "light",
76582
+ className: "!vc-max-w-xs !vc-border !vc-border-solid !vc-border-gray-medium !vc-bg-white !vc-text-xs !vc-text-gray-darkest !vc-opacity-100 !vc-shadow-[2px_6px_15px_rgba(0,0,0,0.3)] !vc-transition-opacity",
76583
+ delayShow: 200
76584
+ }
76585
+ )
76523
76586
  ] });
76524
76587
  }
76525
- function createComponentRef(viewer, modal, sectionBox2) {
76526
- function load(source) {
76588
+ function patchLoad(viewer, modal) {
76589
+ return function load(source) {
76527
76590
  const request2 = viewer.loadVim(source);
76528
76591
  void updateProgress(request2, modal);
76529
76592
  void request2.getResult().then(
@@ -76538,18 +76601,11 @@ function createComponentRef(viewer, modal, sectionBox2) {
76538
76601
  }
76539
76602
  );
76540
76603
  return request2;
76541
- }
76542
- return {
76543
- viewer,
76544
- modal,
76545
- sectionBox: sectionBox2,
76546
- dispose: () => {
76547
- },
76548
- load
76549
76604
  };
76550
76605
  }
76551
76606
  const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
76552
76607
  __proto__: null,
76608
+ ControlBar: controlBar,
76553
76609
  UltraComponent,
76554
76610
  createUltraComponent
76555
76611
  }, Symbol.toStringTag, { value: "Module" }));