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

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.
@@ -50664,7 +50664,7 @@ void main() {
50664
50664
  }
50665
50665
  init(duration) {
50666
50666
  this.cancel();
50667
- this._duration = duration;
50667
+ this._duration = Math.max(duration, 0.01);
50668
50668
  this._clock.start();
50669
50669
  }
50670
50670
  cancel() {
@@ -50985,6 +50985,7 @@ void main() {
50985
50985
  * @returns {CameraMovement} The camera movement api.
50986
50986
  */
50987
50987
  lerp(duration = 1, force = false) {
50988
+ if (duration <= 0) return this.snap(force);
50988
50989
  this.stop();
50989
50990
  this._force = force;
50990
50991
  this._lerp.init(duration);
@@ -51886,10 +51887,10 @@ void main() {
51886
51887
  });
51887
51888
  __publicField(this, "onMouseUp", (event) => {
51888
51889
  event.stopImmediatePropagation();
51890
+ event.preventDefault();
51889
51891
  const btn = this.getButton(event);
51890
51892
  if (btn === this._buttonDown) return;
51891
51893
  this._viewer.gizmos.rectangle.visible = false;
51892
- event.preventDefault();
51893
51894
  if (!this._buttonDown) return;
51894
51895
  if (this.inputs.pointerActive === "rect" && this._hasMouseMoved && !this._hasCameraMoved) {
51895
51896
  this.onRectEnd();
@@ -51906,6 +51907,7 @@ void main() {
51906
51907
  this.inputs.pointerOverride = void 0;
51907
51908
  });
51908
51909
  __publicField(this, "onDoubleClick", (event) => {
51910
+ console.log("Double click");
51909
51911
  event.stopImmediatePropagation();
51910
51912
  this.onMouseClick(
51911
51913
  new Vector2(event.offsetX, event.offsetY),
@@ -55469,6 +55471,7 @@ void main() {
55469
55471
  __publicField(this, "_color");
55470
55472
  __publicField(this, "_highlightColor");
55471
55473
  __publicField(this, "_materials");
55474
+ __publicField(this, "_camera");
55472
55475
  __publicField(this, "_camSub");
55473
55476
  this._materials = [matAlways, matBehind];
55474
55477
  this._forward = new Vector3();
@@ -55481,15 +55484,18 @@ void main() {
55481
55484
  this.quaternion.setFromUnitVectors(new Vector3(0, -1, 0), this._forward);
55482
55485
  }
55483
55486
  trackCamera(camera2) {
55484
- const rescale = () => {
55485
- const size = camera2.frustrumSizeAt(this.position);
55486
- this.scale.set(size.x * 3e-3, size.x * 3e-3, size.x * 3e-3);
55487
- };
55488
- this._camSub = camera2.onMoved.subscribe(() => rescale());
55489
- rescale();
55487
+ this._camera = camera2;
55488
+ this.update();
55489
+ this._camSub = camera2.onMoved.subscribe(() => this.update());
55490
+ }
55491
+ update() {
55492
+ if (!this._camera) return;
55493
+ const size = this._camera.frustrumSizeAt(this.position);
55494
+ this.scale.set(size.x * 3e-3, size.x * 3e-3, size.x * 3e-3);
55490
55495
  }
55491
55496
  setPosition(position) {
55492
55497
  this.position.copy(position);
55498
+ this.update();
55493
55499
  }
55494
55500
  get forward() {
55495
55501
  return this._forward;
@@ -57627,6 +57633,36 @@ void main() {
57627
57633
  }
57628
57634
  return Math.min(Math.max(value, min2), max2);
57629
57635
  }
57636
+ class CaptureStateMachine {
57637
+ constructor(canvas) {
57638
+ __publicField(this, "_canvas");
57639
+ __publicField(this, "state");
57640
+ __publicField(this, "id");
57641
+ this._canvas = canvas;
57642
+ this.state = "none";
57643
+ this.id = -1;
57644
+ }
57645
+ onPointerDown(event) {
57646
+ if (this.state === "captured") {
57647
+ this._canvas.releasePointerCapture(this.id);
57648
+ }
57649
+ this.id = event.pointerId;
57650
+ this.state = "captured";
57651
+ }
57652
+ onPointerMove(event) {
57653
+ if (this.state === "capture") {
57654
+ this._canvas.setPointerCapture(this.id);
57655
+ this.state = "captured";
57656
+ }
57657
+ }
57658
+ onPointerUp(event) {
57659
+ if (this.state === "captured") {
57660
+ this._canvas.releasePointerCapture(this.id);
57661
+ this.state = "none";
57662
+ this.id = -1;
57663
+ }
57664
+ }
57665
+ }
57630
57666
  class InputMouse extends InputHandler {
57631
57667
  constructor(canvas, rpc, selection, camera2) {
57632
57668
  super();
@@ -57635,45 +57671,47 @@ void main() {
57635
57671
  __publicField(this, "_lastMouseDownPosition", new Vector2(0, 0));
57636
57672
  __publicField(this, "_selection");
57637
57673
  __publicField(this, "_camera");
57674
+ __publicField(this, "_capture");
57638
57675
  this._canvas = canvas;
57639
57676
  this._rpc = rpc;
57640
57677
  this._selection = selection;
57641
57678
  this._camera = camera2;
57679
+ this._capture = new CaptureStateMachine(canvas);
57642
57680
  }
57643
57681
  register() {
57644
57682
  this.reg(this._canvas, "pointerdown", (e) => {
57645
- this.handlePointerDown(e);
57683
+ this.onPointerDown(e);
57646
57684
  });
57647
57685
  this.reg(this._canvas, "pointerup", (e) => {
57648
- this.handlePointerUp(e);
57686
+ this.onPointerUp(e);
57649
57687
  });
57650
57688
  this.reg(this._canvas, "pointermove", (e) => {
57651
- this.handlePointerMove(e);
57689
+ this.onPointerMove(e);
57652
57690
  });
57653
57691
  this.reg(this._canvas, "wheel", (e) => {
57654
- this.handleMouseScroll(e);
57692
+ this.onMouseScroll(e);
57655
57693
  });
57656
57694
  this.reg(this._canvas, "dblclick", (e) => {
57657
- this.handleDoubleClick(e);
57695
+ this.onDoubleClick(e);
57658
57696
  });
57659
57697
  }
57660
57698
  dispose() {
57661
57699
  this.unregister();
57662
57700
  }
57663
- handlePointerDown(event) {
57701
+ onPointerDown(event) {
57664
57702
  if (event.pointerType !== "mouse") return;
57665
57703
  const pos = this.relativePosition(event);
57666
57704
  this._rpc.RPCMouseButtonEvent(pos, event.button, true);
57667
57705
  this._lastMouseDownPosition = pos;
57668
- this._canvas.setPointerCapture(event.pointerId);
57706
+ this._capture.onPointerDown(event);
57669
57707
  event.preventDefault();
57670
57708
  }
57671
- handlePointerUp(event) {
57709
+ onPointerUp(event) {
57672
57710
  if (event.pointerType !== "mouse") return;
57673
57711
  const pos = this.relativePosition(event);
57674
57712
  this._rpc.RPCMouseButtonEvent(pos, event.button, false);
57675
57713
  this.handleMouseClick(event);
57676
- this._canvas.releasePointerCapture(event.pointerId);
57714
+ this._capture.onPointerUp(event);
57677
57715
  event.preventDefault();
57678
57716
  }
57679
57717
  async handleMouseClick(event) {
@@ -57693,21 +57731,24 @@ void main() {
57693
57731
  this._selection.select(hit.vim, hit.nodeIndex);
57694
57732
  }
57695
57733
  }
57696
- handlePointerMove(event) {
57734
+ onPointerMove(event) {
57697
57735
  if (event.pointerType !== "mouse") return;
57698
57736
  this._canvas.focus();
57737
+ this._capture.onPointerMove(event);
57699
57738
  const pos = this.relativePosition(event);
57700
57739
  this._rpc.RPCMouseMoveEvent(pos);
57701
57740
  }
57702
- async handleDoubleClick(event) {
57741
+ async onDoubleClick(event) {
57703
57742
  const pos = this.relativePosition(event);
57704
57743
  const hit = await this._selection.hitTest(pos);
57705
57744
  if (hit) {
57706
57745
  this._camera.frameVim(hit.vim, [hit.nodeIndex], 1);
57746
+ } else {
57747
+ this._camera.frameAll(1);
57707
57748
  }
57708
57749
  event.preventDefault();
57709
57750
  }
57710
- handleMouseScroll(event) {
57751
+ onMouseScroll(event) {
57711
57752
  this._rpc.RPCMouseScrollEvent(Math.sign(event.deltaY));
57712
57753
  event.preventDefault();
57713
57754
  }
@@ -59687,15 +59728,19 @@ void main() {
59687
59728
  switch (event.key) {
59688
59729
  case "Escape":
59689
59730
  this._selection.clear();
59731
+ event.preventDefault();
59690
59732
  break;
59691
59733
  case "f":
59692
59734
  this.frameContext();
59735
+ event.preventDefault();
59693
59736
  break;
59694
59737
  case "Home":
59695
59738
  this._camera.restoreSavedPosition();
59739
+ event.preventDefault();
59696
59740
  break;
59697
59741
  case " ":
59698
59742
  this._inputs.mode = this._inputs.mode === InputMode.Orbit ? InputMode.Free : InputMode.Orbit;
59743
+ event.preventDefault();
59699
59744
  break;
59700
59745
  }
59701
59746
  }
@@ -61235,11 +61280,15 @@ Averrage Date/Second ${avgDataRatePS} kb
61235
61280
  * Handles camera initialization when connection is established
61236
61281
  */
61237
61282
  onConnect() {
61283
+ this.set(new Vector3(-1e3, 1e3, 1e3), new Vector3(0, 0, 0), 0);
61238
61284
  this.restoreLastPosition();
61239
61285
  }
61240
61286
  onCameraPose(pose) {
61241
61287
  this._lastPosition = pose;
61242
61288
  }
61289
+ set(position, target, blendTime = this._defaultBlendTime) {
61290
+ this._rpc.RPCSetCameraPosition(new Segment(position, target), blendTime);
61291
+ }
61243
61292
  /**
61244
61293
  * Pauses or resumes rendering
61245
61294
  * @param value - True to pause rendering, false to resume
@@ -61253,6 +61302,7 @@ Averrage Date/Second ${avgDataRatePS} kb
61253
61302
  * @returns Promise that resolves when the framing animation is complete
61254
61303
  */
61255
61304
  async frameAll(blendTime = this._defaultBlendTime) {
61305
+ console.log("Camera.frameAll");
61256
61306
  const segment = await this._rpc.RPCFrameAll(blendTime);
61257
61307
  this._savedPosition = this._savedPosition ?? segment;
61258
61308
  return segment;
@@ -61263,6 +61313,7 @@ Averrage Date/Second ${avgDataRatePS} kb
61263
61313
  * @param blendTime - Duration of the camera animation in seconds (defaults to 0.5)
61264
61314
  */
61265
61315
  async frameBox(box, blendTime = this._defaultBlendTime) {
61316
+ console.log("Camera.frameAll");
61266
61317
  const segment = await this._rpc.RPCFrameBox(box, blendTime);
61267
61318
  this._savedPosition = this._savedPosition ?? segment;
61268
61319
  return segment;
@@ -66817,6 +66868,25 @@ Averrage Date/Second ${avgDataRatePS} kb
66817
66868
  }
66818
66869
  );
66819
66870
  }
66871
+ function autoCamera({ height, width, fill: fill2 = "", className }) {
66872
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66873
+ /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
66874
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66875
+ "path",
66876
+ {
66877
+ fill: fill2,
66878
+ 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"
66879
+ }
66880
+ ),
66881
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
66882
+ "path",
66883
+ {
66884
+ fill: "white",
66885
+ 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"
66886
+ }
66887
+ )
66888
+ ] });
66889
+ }
66820
66890
  function orbit({ height, width, fill: fill2 = "", className }) {
66821
66891
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("svg", { className, height, width, viewBox: "0 0 256 256", children: [
66822
66892
  /* @__PURE__ */ jsxRuntimeExports.jsx("path", { fill: "none", d: "M0 0h256v256H0z" }),
@@ -67340,6 +67410,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67340
67410
  const icons = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
67341
67411
  __proto__: null,
67342
67412
  arrowLeft,
67413
+ autoCamera,
67343
67414
  camera,
67344
67415
  checkmark,
67345
67416
  close,
@@ -67486,7 +67557,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67486
67557
  );
67487
67558
  };
67488
67559
  const onHomeBtn = () => {
67489
- props.camera.reset();
67560
+ props.camera.reset.call();
67490
67561
  };
67491
67562
  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
67563
  const btnIsolation = /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -67580,12 +67651,14 @@ Averrage Date/Second ${avgDataRatePS} kb
67580
67651
  const ids = {
67581
67652
  // Sections
67582
67653
  sectionCamera: "controlBar.sectionCamera",
67654
+ sectionInputs: "controlBar.sectionInputs",
67583
67655
  sectionActions: "controlBar.sectionActions",
67584
67656
  sectionTools: "controlBar.sectionTools",
67585
67657
  sectionSettings: "controlBar.sectionSettings",
67586
67658
  sectionMeasure: "controlBar.sectionMeasure",
67587
67659
  sectionSectionBox: "controlBar.sectionSectionBox",
67588
67660
  // Camera buttons
67661
+ buttonCameraAuto: "controlBar.camera.auto",
67589
67662
  buttonCameraOrbit: "controlBar.camera.orbit",
67590
67663
  buttonCameraLook: "controlBarcamera.look",
67591
67664
  buttonCameraPan: "controlBar.camera.pan",
@@ -67607,7 +67680,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67607
67680
  buttonSectionBoxVisible: "controlBar.sectionBox.visible",
67608
67681
  buttonSectionBoxShrinkToSelection: "controlBar.sectionBox.shrinkToSelection",
67609
67682
  buttonSectionBoxAuto: "controlBar.sectionBox.auto",
67610
- buttonSectionBoxClip: "controlBar.sectionBox.clip",
67683
+ buttonSectionBoxReset: "controlBar.sectionBox.reset",
67611
67684
  buttonSectionBoxSettings: "controlBar.sectionBox.settings"
67612
67685
  };
67613
67686
  function ControlBar(props) {
@@ -67849,7 +67922,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67849
67922
  icon: sectionBoxShrink
67850
67923
  },
67851
67924
  {
67852
- id: ids.buttonSectionBoxClip,
67925
+ id: ids.buttonSectionBoxReset,
67853
67926
  tip: "Reset Section",
67854
67927
  enabled: () => section.enable.get(),
67855
67928
  style: (on) => buttonDefaultStyle(on),
@@ -67889,7 +67962,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67889
67962
  function controlBarPointer(viewer, camera2, settings2, section) {
67890
67963
  const pointer = getPointerState(viewer);
67891
67964
  return {
67892
- id: ids.sectionCamera,
67965
+ id: ids.sectionInputs,
67893
67966
  enable: () => anyUiCursorButton(settings2),
67894
67967
  style: sectionDefaultStyle,
67895
67968
  buttons: [
@@ -67953,7 +68026,7 @@ Averrage Date/Second ${avgDataRatePS} kb
67953
68026
  id: ids.buttonZoomToFit,
67954
68027
  enabled: () => isTrue(settings2.ui.zoomToFit),
67955
68028
  tip: "Zoom to Fit",
67956
- action: () => camera2.frameContext(),
68029
+ action: () => camera2.frameSelection.call(),
67957
68030
  icon: frameSelection,
67958
68031
  isOn: () => false,
67959
68032
  style: buttonDefaultStyle
@@ -68020,15 +68093,34 @@ Averrage Date/Second ${avgDataRatePS} kb
68020
68093
  ]
68021
68094
  };
68022
68095
  }
68096
+ function controlBarCamera(camera2) {
68097
+ return {
68098
+ id: ids.sectionCamera,
68099
+ enable: () => true,
68100
+ style: sectionDefaultStyle,
68101
+ buttons: [
68102
+ {
68103
+ id: ids.buttonCameraAuto,
68104
+ tip: "Auto Camera",
68105
+ isOn: () => camera2.autoCamera.get(),
68106
+ action: () => camera2.autoCamera.set(!camera2.autoCamera.get()),
68107
+ icon: autoCamera,
68108
+ style: buttonDefaultStyle
68109
+ }
68110
+ ]
68111
+ };
68112
+ }
68023
68113
  function useControlBar(viewer, camera2, modal, side, isolation, cursor, settings2, section, customization) {
68024
68114
  const measure2 = getMeasureState(viewer, cursor);
68025
68115
  const pointerSection = controlBarPointer(viewer, camera2, settings2);
68026
68116
  const actionSection = controlBarActions(camera2, settings2, isolation, measure2);
68027
68117
  const sectionBoxSection = controlBarSectionBox(section, viewer.selection.count > 0);
68028
68118
  const settingsSection = controlBarSettings(modal, side, settings2);
68119
+ const cameraSection = controlBarCamera(camera2);
68029
68120
  let controlBarSections = [
68030
68121
  pointerSection,
68031
68122
  actionSection,
68123
+ cameraSection,
68032
68124
  sectionBoxSection,
68033
68125
  // Optional section
68034
68126
  settingsSection
@@ -72054,11 +72146,11 @@ Averrage Date/Second ${avgDataRatePS} kb
72054
72146
  e.stopPropagation();
72055
72147
  };
72056
72148
  const onCameraResetBtn = (e) => {
72057
- camera2.reset();
72149
+ camera2.reset.call();
72058
72150
  e.stopPropagation();
72059
72151
  };
72060
72152
  const onCameraFrameBtn = (e) => {
72061
- camera2.frameContext();
72153
+ camera2.frameSelection.call();
72062
72154
  e.stopPropagation();
72063
72155
  };
72064
72156
  const onSelectionIsolateBtn = (e) => {
@@ -72390,7 +72482,7 @@ Averrage Date/Second ${avgDataRatePS} kb
72390
72482
  createInteractiveElementProps: (item, treeId, actions, renderFlags) => ({
72391
72483
  onKeyUp: (e) => {
72392
72484
  if (e.key === "f") {
72393
- props.camera.frameContext();
72485
+ props.camera.frameSelection.call();
72394
72486
  }
72395
72487
  if (e.key === "Escape") {
72396
72488
  props.viewer.selection.clear();
@@ -72433,7 +72525,7 @@ Averrage Date/Second ${avgDataRatePS} kb
72433
72525
  },
72434
72526
  onPrimaryAction: (item, _) => {
72435
72527
  if (doubleClick.isDoubleClick(item.index)) {
72436
- props.camera.frameSelection();
72528
+ props.camera.frameSelection.call();
72437
72529
  }
72438
72530
  },
72439
72531
  onFocusItem: (item) => {
@@ -74724,7 +74816,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74724
74816
  return true;
74725
74817
  }
74726
74818
  case KEYS.KEY_F: {
74727
- this._camera.frameContext();
74819
+ this._camera.frameSelection.call();
74728
74820
  return true;
74729
74821
  }
74730
74822
  case KEYS.KEY_I: {
@@ -74918,7 +75010,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74918
75010
  if (!this._settings.isolation.enable) return;
74919
75011
  this._isolation = objects ?? [];
74920
75012
  this._apply(source);
74921
- this._camera.frameVisibleObjects();
75013
+ this._camera.frameScene.call();
74922
75014
  }
74923
75015
  /**
74924
75016
  * Toggles isolation by using the current selection.
@@ -74933,7 +75025,7 @@ Averrage Date/Second ${avgDataRatePS} kb
74933
75025
  if (!this._settings.isolation.enable) return;
74934
75026
  this._isolation = [...this._viewer.selection.objects].filter((o) => o.type === "Object3D");
74935
75027
  this._apply(source);
74936
- this._camera.frameVisibleObjects();
75028
+ this._camera.frameScene.call();
74937
75029
  this._viewer.selection.clear();
74938
75030
  }
74939
75031
  /**
@@ -75033,75 +75125,6 @@ Averrage Date/Second ${avgDataRatePS} kb
75033
75125
  return objects;
75034
75126
  }
75035
75127
  }
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);
75056
- }
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);
75068
- }
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);
75100
- }
75101
- }
75102
- return box;
75103
- }
75104
- }
75105
75128
  function createContainer(element) {
75106
75129
  let root = element;
75107
75130
  if (root === void 0) {
@@ -75855,6 +75878,17 @@ Averrage Date/Second ${avgDataRatePS} kb
75855
75878
  }
75856
75879
  };
75857
75880
  }
75881
+ function useActionRef(action) {
75882
+ const ref = React2.useRef(action);
75883
+ return {
75884
+ call() {
75885
+ ref == null ? void 0 : ref.current();
75886
+ },
75887
+ set(func) {
75888
+ ref.current = func;
75889
+ }
75890
+ };
75891
+ }
75858
75892
  function useArgActionRef(action) {
75859
75893
  const ref = React2.useRef(action);
75860
75894
  return {
@@ -75877,6 +75911,17 @@ Averrage Date/Second ${avgDataRatePS} kb
75877
75911
  }
75878
75912
  };
75879
75913
  }
75914
+ function useAsyncFuncRef(func) {
75915
+ const ref = React2.useRef(func);
75916
+ return {
75917
+ async call() {
75918
+ return ref == null ? void 0 : ref.current();
75919
+ },
75920
+ set(func2) {
75921
+ ref.current = func2;
75922
+ }
75923
+ };
75924
+ }
75880
75925
  function useSectionBox(adapter) {
75881
75926
  const enable = useStateRef(false);
75882
75927
  const visible2 = useStateRef(false);
@@ -75908,6 +75953,7 @@ Averrage Date/Second ${avgDataRatePS} kb
75908
75953
  });
75909
75954
  visible2.useOnChange((v) => adapter.setVisible(v));
75910
75955
  React2.useEffect(() => {
75956
+ adapter.setVisible(false);
75911
75957
  return adapter.onSelectionChanged.sub(() => {
75912
75958
  if (auto.get() && enable.get()) sectionSelection.call();
75913
75959
  });
@@ -75972,12 +76018,61 @@ Averrage Date/Second ${avgDataRatePS} kb
75972
76018
  fitBox: (box) => viewer.gizmos.sectionBox.fitBox(box),
75973
76019
  getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox()),
75974
76020
  getRendererBox: () => Promise.resolve(viewer.renderer.getBoundingBox()),
75975
- onSceneChanged: viewer.renderer.onBoxUpdated,
75976
76021
  onSelectionChanged: viewer.selection.onValueChanged
75977
76022
  };
75978
76023
  viewer.gizmos.sectionBox.clip = true;
75979
76024
  return useSectionBox(vimAdapter);
75980
76025
  }
76026
+ function useCamera(adapter) {
76027
+ const autoCamera2 = useStateRef(false);
76028
+ autoCamera2.useOnChange((v) => {
76029
+ if (v) {
76030
+ frameSelection2.call();
76031
+ }
76032
+ });
76033
+ React2.useEffect(() => {
76034
+ adapter.onSelectionChanged.sub(() => {
76035
+ if (autoCamera2.get()) {
76036
+ frameSelection2.call();
76037
+ }
76038
+ });
76039
+ }, []);
76040
+ const reset = useActionRef(() => adapter.resetCamera(1));
76041
+ const frameSelection2 = useAsyncFuncRef(async () => {
76042
+ console.log("frameSelection");
76043
+ if (!adapter.hasSelection()) {
76044
+ frameScene.call();
76045
+ return;
76046
+ }
76047
+ const box = await adapter.getSelectionBox();
76048
+ if (!box) {
76049
+ return;
76050
+ }
76051
+ adapter.frameCamera(box, 1);
76052
+ });
76053
+ const frameScene = useAsyncFuncRef(async () => {
76054
+ adapter.frameAll(1);
76055
+ });
76056
+ return {
76057
+ autoCamera: autoCamera2,
76058
+ reset,
76059
+ frameSelection: frameSelection2,
76060
+ frameScene
76061
+ };
76062
+ }
76063
+ function useWebglCamera(viewer) {
76064
+ return useCamera({
76065
+ onSelectionChanged: viewer.selection.onValueChanged,
76066
+ frameCamera: (box, duration) => viewer.camera.lerp(duration).frame(box),
76067
+ resetCamera: (duration) => viewer.camera.lerp(duration).reset(),
76068
+ frameAll: (duration) => {
76069
+ const box = viewer.renderer.getBoundingBox();
76070
+ viewer.camera.lerp(duration).frame(box);
76071
+ },
76072
+ hasSelection: () => viewer.selection.count > 0,
76073
+ getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox())
76074
+ });
76075
+ }
75981
76076
  function createWebglComponent(container, componentSettings = {}, viewerSettings = {}) {
75982
76077
  const promise2 = new DeferredPromise();
75983
76078
  const cmpContainer = container instanceof HTMLElement ? createContainer(container) : container ?? createContainer();
@@ -76009,7 +76104,7 @@ Averrage Date/Second ${avgDataRatePS} kb
76009
76104
  var _a2;
76010
76105
  const settings2 = useSettings(props.viewer, props.settings ?? {});
76011
76106
  const modal = useModal(settings2.value.capacity.canFollowUrl);
76012
- const camera2 = React2.useMemo(() => new ComponentCamera(props.viewer), []);
76107
+ const camera2 = useWebglCamera(props.viewer);
76013
76108
  const cursor = React2.useMemo(() => new CursorManager(props.viewer), []);
76014
76109
  const loader = React2.useRef(new ComponentLoader(props.viewer, modal));
76015
76110
  const [isolation] = React2.useState(() => new Isolation(props.viewer, camera2, settings2.value));
@@ -76465,6 +76560,7 @@ Averrage Date/Second ${avgDataRatePS} kb
76465
76560
  function useUltraSectionBox(viewer) {
76466
76561
  const ultraAdapter = {
76467
76562
  setVisible: (b) => {
76563
+ console.log("SetVisible!", b);
76468
76564
  viewer.sectionBox.visible = b;
76469
76565
  viewer.sectionBox.interactive = b;
76470
76566
  },
@@ -76472,15 +76568,26 @@ Averrage Date/Second ${avgDataRatePS} kb
76472
76568
  fitBox: (box) => viewer.sectionBox.fitBox(box),
76473
76569
  getSelectionBox: () => viewer.selection.getBoundingBox(),
76474
76570
  getRendererBox: () => viewer.renderer.getBoundingBox(),
76475
- onSelectionChanged: viewer.selection.onValueChanged,
76476
- onSceneChanged: viewer.vims.onChanged
76571
+ onSelectionChanged: viewer.selection.onValueChanged
76477
76572
  };
76478
76573
  return useSectionBox(ultraAdapter);
76479
76574
  }
76480
- function useUltraControlBar(viewer, section, customization) {
76481
- let controlBar2 = [controlBarSectionBox(section, viewer.selection.count > 0)];
76482
- controlBar2 = (customization == null ? void 0 : customization(controlBar2)) ?? controlBar2;
76483
- return controlBar2;
76575
+ function useUltraControlBar(viewer, section, camera2, customization) {
76576
+ const sectionSectionBox = controlBarSectionBox(section, viewer.selection.count > 0);
76577
+ const sectionCamera = controlBarCamera(camera2);
76578
+ let bar = [sectionCamera, sectionSectionBox];
76579
+ bar = (customization == null ? void 0 : customization(bar)) ?? bar;
76580
+ return bar;
76581
+ }
76582
+ function useUltraCamera(viewer) {
76583
+ return useCamera({
76584
+ onSelectionChanged: viewer.selection.onValueChanged,
76585
+ frameCamera: (box, duration) => void viewer.camera.frameBox(box, duration),
76586
+ frameAll: (duration) => viewer.camera.frameAll(duration),
76587
+ resetCamera: (duration) => viewer.camera.restoreSavedPosition(duration),
76588
+ hasSelection: () => viewer.selection.count > 0,
76589
+ getSelectionBox: () => viewer.selection.getBoundingBox()
76590
+ });
76484
76591
  }
76485
76592
  function createUltraComponent(container) {
76486
76593
  const promise2 = new DeferredPromise();
@@ -76510,10 +76617,11 @@ Averrage Date/Second ${avgDataRatePS} kb
76510
76617
  function UltraComponent(props) {
76511
76618
  const modal = useModal(true);
76512
76619
  const sectionBox2 = useUltraSectionBox(props.viewer);
76620
+ const camera2 = useUltraCamera(props.viewer);
76513
76621
  const side = useSideState(true, 400);
76514
76622
  const [_, setSelectState] = React2.useState(0);
76515
76623
  const [controlBarCustom, setControlBarCustom] = React2.useState(() => (c) => c);
76516
- const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, (_2) => _2);
76624
+ const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, camera2, (_2) => _2);
76517
76625
  React2.useEffect(() => {
76518
76626
  props.viewer.onStateChanged.subscribe((state) => updateModal(modal, state));
76519
76627
  props.viewer.selection.onValueChanged.subscribe(() => {