vim-web 0.3.44-dev.18 → 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.
package/dist/vim-web.js CHANGED
@@ -50648,7 +50648,7 @@ class CameraLerp extends CameraMovement {
50648
50648
  }
50649
50649
  init(duration) {
50650
50650
  this.cancel();
50651
- this._duration = duration;
50651
+ this._duration = Math.max(duration, 0.01);
50652
50652
  this._clock.start();
50653
50653
  }
50654
50654
  cancel() {
@@ -50969,6 +50969,7 @@ let Camera$1 = class Camera2 {
50969
50969
  * @returns {CameraMovement} The camera movement api.
50970
50970
  */
50971
50971
  lerp(duration = 1, force = false) {
50972
+ if (duration <= 0) return this.snap(force);
50972
50973
  this.stop();
50973
50974
  this._force = force;
50974
50975
  this._lerp.init(duration);
@@ -51870,10 +51871,10 @@ class MouseHandler extends InputHandler$1 {
51870
51871
  });
51871
51872
  __publicField(this, "onMouseUp", (event) => {
51872
51873
  event.stopImmediatePropagation();
51874
+ event.preventDefault();
51873
51875
  const btn = this.getButton(event);
51874
51876
  if (btn === this._buttonDown) return;
51875
51877
  this._viewer.gizmos.rectangle.visible = false;
51876
- event.preventDefault();
51877
51878
  if (!this._buttonDown) return;
51878
51879
  if (this.inputs.pointerActive === "rect" && this._hasMouseMoved && !this._hasCameraMoved) {
51879
51880
  this.onRectEnd();
@@ -51890,6 +51891,7 @@ class MouseHandler extends InputHandler$1 {
51890
51891
  this.inputs.pointerOverride = void 0;
51891
51892
  });
51892
51893
  __publicField(this, "onDoubleClick", (event) => {
51894
+ console.log("Double click");
51893
51895
  event.stopImmediatePropagation();
51894
51896
  this.onMouseClick(
51895
51897
  new Vector2(event.offsetX, event.offsetY),
@@ -55453,6 +55455,7 @@ class SectionBoxHandle extends Mesh {
55453
55455
  __publicField(this, "_color");
55454
55456
  __publicField(this, "_highlightColor");
55455
55457
  __publicField(this, "_materials");
55458
+ __publicField(this, "_camera");
55456
55459
  __publicField(this, "_camSub");
55457
55460
  this._materials = [matAlways, matBehind];
55458
55461
  this._forward = new Vector3();
@@ -55465,15 +55468,18 @@ class SectionBoxHandle extends Mesh {
55465
55468
  this.quaternion.setFromUnitVectors(new Vector3(0, -1, 0), this._forward);
55466
55469
  }
55467
55470
  trackCamera(camera2) {
55468
- const rescale = () => {
55469
- const size = camera2.frustrumSizeAt(this.position);
55470
- this.scale.set(size.x * 3e-3, size.x * 3e-3, size.x * 3e-3);
55471
- };
55472
- this._camSub = camera2.onMoved.subscribe(() => rescale());
55473
- rescale();
55471
+ this._camera = camera2;
55472
+ this.update();
55473
+ this._camSub = camera2.onMoved.subscribe(() => this.update());
55474
+ }
55475
+ update() {
55476
+ if (!this._camera) return;
55477
+ const size = this._camera.frustrumSizeAt(this.position);
55478
+ this.scale.set(size.x * 3e-3, size.x * 3e-3, size.x * 3e-3);
55474
55479
  }
55475
55480
  setPosition(position) {
55476
55481
  this.position.copy(position);
55482
+ this.update();
55477
55483
  }
55478
55484
  get forward() {
55479
55485
  return this._forward;
@@ -57611,6 +57617,36 @@ function clamp$1(value, min2, max2) {
57611
57617
  }
57612
57618
  return Math.min(Math.max(value, min2), max2);
57613
57619
  }
57620
+ class CaptureStateMachine {
57621
+ constructor(canvas) {
57622
+ __publicField(this, "_canvas");
57623
+ __publicField(this, "state");
57624
+ __publicField(this, "id");
57625
+ this._canvas = canvas;
57626
+ this.state = "none";
57627
+ this.id = -1;
57628
+ }
57629
+ onPointerDown(event) {
57630
+ if (this.state === "captured") {
57631
+ this._canvas.releasePointerCapture(this.id);
57632
+ }
57633
+ this.id = event.pointerId;
57634
+ this.state = "captured";
57635
+ }
57636
+ onPointerMove(event) {
57637
+ if (this.state === "capture") {
57638
+ this._canvas.setPointerCapture(this.id);
57639
+ this.state = "captured";
57640
+ }
57641
+ }
57642
+ onPointerUp(event) {
57643
+ if (this.state === "captured") {
57644
+ this._canvas.releasePointerCapture(this.id);
57645
+ this.state = "none";
57646
+ this.id = -1;
57647
+ }
57648
+ }
57649
+ }
57614
57650
  class InputMouse extends InputHandler2 {
57615
57651
  constructor(canvas, rpc, selection, camera2) {
57616
57652
  super();
@@ -57619,45 +57655,47 @@ class InputMouse extends InputHandler2 {
57619
57655
  __publicField(this, "_lastMouseDownPosition", new Vector2(0, 0));
57620
57656
  __publicField(this, "_selection");
57621
57657
  __publicField(this, "_camera");
57658
+ __publicField(this, "_capture");
57622
57659
  this._canvas = canvas;
57623
57660
  this._rpc = rpc;
57624
57661
  this._selection = selection;
57625
57662
  this._camera = camera2;
57663
+ this._capture = new CaptureStateMachine(canvas);
57626
57664
  }
57627
57665
  register() {
57628
57666
  this.reg(this._canvas, "pointerdown", (e) => {
57629
- this.handlePointerDown(e);
57667
+ this.onPointerDown(e);
57630
57668
  });
57631
57669
  this.reg(this._canvas, "pointerup", (e) => {
57632
- this.handlePointerUp(e);
57670
+ this.onPointerUp(e);
57633
57671
  });
57634
57672
  this.reg(this._canvas, "pointermove", (e) => {
57635
- this.handlePointerMove(e);
57673
+ this.onPointerMove(e);
57636
57674
  });
57637
57675
  this.reg(this._canvas, "wheel", (e) => {
57638
- this.handleMouseScroll(e);
57676
+ this.onMouseScroll(e);
57639
57677
  });
57640
57678
  this.reg(this._canvas, "dblclick", (e) => {
57641
- this.handleDoubleClick(e);
57679
+ this.onDoubleClick(e);
57642
57680
  });
57643
57681
  }
57644
57682
  dispose() {
57645
57683
  this.unregister();
57646
57684
  }
57647
- handlePointerDown(event) {
57685
+ onPointerDown(event) {
57648
57686
  if (event.pointerType !== "mouse") return;
57649
57687
  const pos = this.relativePosition(event);
57650
57688
  this._rpc.RPCMouseButtonEvent(pos, event.button, true);
57651
57689
  this._lastMouseDownPosition = pos;
57652
- this._canvas.setPointerCapture(event.pointerId);
57690
+ this._capture.onPointerDown(event);
57653
57691
  event.preventDefault();
57654
57692
  }
57655
- handlePointerUp(event) {
57693
+ onPointerUp(event) {
57656
57694
  if (event.pointerType !== "mouse") return;
57657
57695
  const pos = this.relativePosition(event);
57658
57696
  this._rpc.RPCMouseButtonEvent(pos, event.button, false);
57659
57697
  this.handleMouseClick(event);
57660
- this._canvas.releasePointerCapture(event.pointerId);
57698
+ this._capture.onPointerUp(event);
57661
57699
  event.preventDefault();
57662
57700
  }
57663
57701
  async handleMouseClick(event) {
@@ -57677,21 +57715,24 @@ class InputMouse extends InputHandler2 {
57677
57715
  this._selection.select(hit.vim, hit.nodeIndex);
57678
57716
  }
57679
57717
  }
57680
- handlePointerMove(event) {
57718
+ onPointerMove(event) {
57681
57719
  if (event.pointerType !== "mouse") return;
57682
57720
  this._canvas.focus();
57721
+ this._capture.onPointerMove(event);
57683
57722
  const pos = this.relativePosition(event);
57684
57723
  this._rpc.RPCMouseMoveEvent(pos);
57685
57724
  }
57686
- async handleDoubleClick(event) {
57725
+ async onDoubleClick(event) {
57687
57726
  const pos = this.relativePosition(event);
57688
57727
  const hit = await this._selection.hitTest(pos);
57689
57728
  if (hit) {
57690
57729
  this._camera.frameVim(hit.vim, [hit.nodeIndex], 1);
57730
+ } else {
57731
+ this._camera.frameAll(1);
57691
57732
  }
57692
57733
  event.preventDefault();
57693
57734
  }
57694
- handleMouseScroll(event) {
57735
+ onMouseScroll(event) {
57695
57736
  this._rpc.RPCMouseScrollEvent(Math.sign(event.deltaY));
57696
57737
  event.preventDefault();
57697
57738
  }
@@ -59671,15 +59712,19 @@ class InputKeyboard extends InputHandler2 {
59671
59712
  switch (event.key) {
59672
59713
  case "Escape":
59673
59714
  this._selection.clear();
59715
+ event.preventDefault();
59674
59716
  break;
59675
59717
  case "f":
59676
59718
  this.frameContext();
59719
+ event.preventDefault();
59677
59720
  break;
59678
59721
  case "Home":
59679
59722
  this._camera.restoreSavedPosition();
59723
+ event.preventDefault();
59680
59724
  break;
59681
59725
  case " ":
59682
59726
  this._inputs.mode = this._inputs.mode === InputMode.Orbit ? InputMode.Free : InputMode.Orbit;
59727
+ event.preventDefault();
59683
59728
  break;
59684
59729
  }
59685
59730
  }
@@ -61219,11 +61264,15 @@ class Camera3 {
61219
61264
  * Handles camera initialization when connection is established
61220
61265
  */
61221
61266
  onConnect() {
61267
+ this.set(new Vector3(-1e3, 1e3, 1e3), new Vector3(0, 0, 0), 0);
61222
61268
  this.restoreLastPosition();
61223
61269
  }
61224
61270
  onCameraPose(pose) {
61225
61271
  this._lastPosition = pose;
61226
61272
  }
61273
+ set(position, target, blendTime = this._defaultBlendTime) {
61274
+ this._rpc.RPCSetCameraPosition(new Segment(position, target), blendTime);
61275
+ }
61227
61276
  /**
61228
61277
  * Pauses or resumes rendering
61229
61278
  * @param value - True to pause rendering, false to resume
@@ -61237,6 +61286,7 @@ class Camera3 {
61237
61286
  * @returns Promise that resolves when the framing animation is complete
61238
61287
  */
61239
61288
  async frameAll(blendTime = this._defaultBlendTime) {
61289
+ console.log("Camera.frameAll");
61240
61290
  const segment = await this._rpc.RPCFrameAll(blendTime);
61241
61291
  this._savedPosition = this._savedPosition ?? segment;
61242
61292
  return segment;
@@ -61247,6 +61297,7 @@ class Camera3 {
61247
61297
  * @param blendTime - Duration of the camera animation in seconds (defaults to 0.5)
61248
61298
  */
61249
61299
  async frameBox(box, blendTime = this._defaultBlendTime) {
61300
+ console.log("Camera.frameAll");
61250
61301
  const segment = await this._rpc.RPCFrameBox(box, blendTime);
61251
61302
  this._savedPosition = this._savedPosition ?? segment;
61252
61303
  return segment;
@@ -74943,7 +74994,7 @@ class Isolation {
74943
74994
  if (!this._settings.isolation.enable) return;
74944
74995
  this._isolation = objects ?? [];
74945
74996
  this._apply(source);
74946
- this._camera.frameVisibleObjects.call();
74997
+ this._camera.frameScene.call();
74947
74998
  }
74948
74999
  /**
74949
75000
  * Toggles isolation by using the current selection.
@@ -74958,7 +75009,7 @@ class Isolation {
74958
75009
  if (!this._settings.isolation.enable) return;
74959
75010
  this._isolation = [...this._viewer.selection.objects].filter((o) => o.type === "Object3D");
74960
75011
  this._apply(source);
74961
- this._camera.frameVisibleObjects.call();
75012
+ this._camera.frameScene.call();
74962
75013
  this._viewer.selection.clear();
74963
75014
  }
74964
75015
  /**
@@ -75058,140 +75109,6 @@ class Isolation {
75058
75109
  return objects;
75059
75110
  }
75060
75111
  }
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
- }, []);
75100
- }
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;
75111
- }
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();
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);
75191
- }
75192
- }
75193
- return box;
75194
- }
75195
75112
  function createContainer(element) {
75196
75113
  let root = element;
75197
75114
  if (root === void 0) {
@@ -75903,6 +75820,92 @@ function addBox(b1, b2) {
75903
75820
  r.max.z += b2.max.z;
75904
75821
  return r;
75905
75822
  }
75823
+ function useStateRef(initialValue) {
75824
+ const [value, setValue] = useState(initialValue);
75825
+ const ref = useRef(initialValue);
75826
+ const event = useRef(new distExports.SimpleEventDispatcher());
75827
+ const validate = useRef((value2) => value2);
75828
+ const confirm = useRef((value2) => value2);
75829
+ const set3 = (value2) => {
75830
+ const finalValue = validate.current(value2) ?? value2;
75831
+ if (finalValue === void 0) return;
75832
+ if (finalValue === ref.current) return;
75833
+ ref.current = finalValue;
75834
+ setValue(finalValue);
75835
+ event.current.dispatch(finalValue);
75836
+ };
75837
+ return {
75838
+ get() {
75839
+ return ref.current;
75840
+ },
75841
+ set: set3,
75842
+ confirm() {
75843
+ set3(confirm.current(ref.current));
75844
+ },
75845
+ useOnChange(on) {
75846
+ useEffect(() => {
75847
+ return event.current.subscribe(on);
75848
+ }, []);
75849
+ },
75850
+ useMemo(on, deps) {
75851
+ return useMemo(() => on(value), [...deps || [], value]);
75852
+ },
75853
+ useValidate(on) {
75854
+ useEffect(() => {
75855
+ validate.current = on;
75856
+ }, []);
75857
+ },
75858
+ useConfirm(on) {
75859
+ useEffect(() => {
75860
+ confirm.current = on;
75861
+ }, []);
75862
+ }
75863
+ };
75864
+ }
75865
+ function useActionRef(action) {
75866
+ const ref = useRef(action);
75867
+ return {
75868
+ call() {
75869
+ ref == null ? void 0 : ref.current();
75870
+ },
75871
+ set(func) {
75872
+ ref.current = func;
75873
+ }
75874
+ };
75875
+ }
75876
+ function useArgActionRef(action) {
75877
+ const ref = useRef(action);
75878
+ return {
75879
+ call(arg) {
75880
+ ref == null ? void 0 : ref.current(arg);
75881
+ },
75882
+ set(func) {
75883
+ ref.current = func;
75884
+ }
75885
+ };
75886
+ }
75887
+ function useFuncRef(func) {
75888
+ const ref = useRef(func);
75889
+ return {
75890
+ call() {
75891
+ return ref == null ? void 0 : ref.current();
75892
+ },
75893
+ set(func2) {
75894
+ ref.current = func2;
75895
+ }
75896
+ };
75897
+ }
75898
+ function useAsyncFuncRef(func) {
75899
+ const ref = useRef(func);
75900
+ return {
75901
+ async call() {
75902
+ return ref == null ? void 0 : ref.current();
75903
+ },
75904
+ set(func2) {
75905
+ ref.current = func2;
75906
+ }
75907
+ };
75908
+ }
75906
75909
  function useSectionBox(adapter) {
75907
75910
  const enable = useStateRef(false);
75908
75911
  const visible2 = useStateRef(false);
@@ -75934,6 +75937,7 @@ function useSectionBox(adapter) {
75934
75937
  });
75935
75938
  visible2.useOnChange((v) => adapter.setVisible(v));
75936
75939
  useEffect(() => {
75940
+ adapter.setVisible(false);
75937
75941
  return adapter.onSelectionChanged.sub(() => {
75938
75942
  if (auto.get() && enable.get()) sectionSelection.call();
75939
75943
  });
@@ -75998,12 +76002,61 @@ function useWebglSectionBox(viewer) {
75998
76002
  fitBox: (box) => viewer.gizmos.sectionBox.fitBox(box),
75999
76003
  getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox()),
76000
76004
  getRendererBox: () => Promise.resolve(viewer.renderer.getBoundingBox()),
76001
- onSceneChanged: viewer.renderer.onBoxUpdated,
76002
76005
  onSelectionChanged: viewer.selection.onValueChanged
76003
76006
  };
76004
76007
  viewer.gizmos.sectionBox.clip = true;
76005
76008
  return useSectionBox(vimAdapter);
76006
76009
  }
76010
+ function useCamera(adapter) {
76011
+ const autoCamera2 = useStateRef(false);
76012
+ autoCamera2.useOnChange((v) => {
76013
+ if (v) {
76014
+ frameSelection2.call();
76015
+ }
76016
+ });
76017
+ useEffect(() => {
76018
+ adapter.onSelectionChanged.sub(() => {
76019
+ if (autoCamera2.get()) {
76020
+ frameSelection2.call();
76021
+ }
76022
+ });
76023
+ }, []);
76024
+ const reset = useActionRef(() => adapter.resetCamera(1));
76025
+ const frameSelection2 = useAsyncFuncRef(async () => {
76026
+ console.log("frameSelection");
76027
+ if (!adapter.hasSelection()) {
76028
+ frameScene.call();
76029
+ return;
76030
+ }
76031
+ const box = await adapter.getSelectionBox();
76032
+ if (!box) {
76033
+ return;
76034
+ }
76035
+ adapter.frameCamera(box, 1);
76036
+ });
76037
+ const frameScene = useAsyncFuncRef(async () => {
76038
+ adapter.frameAll(1);
76039
+ });
76040
+ return {
76041
+ autoCamera: autoCamera2,
76042
+ reset,
76043
+ frameSelection: frameSelection2,
76044
+ frameScene
76045
+ };
76046
+ }
76047
+ function useWebglCamera(viewer) {
76048
+ return useCamera({
76049
+ onSelectionChanged: viewer.selection.onValueChanged,
76050
+ frameCamera: (box, duration) => viewer.camera.lerp(duration).frame(box),
76051
+ resetCamera: (duration) => viewer.camera.lerp(duration).reset(),
76052
+ frameAll: (duration) => {
76053
+ const box = viewer.renderer.getBoundingBox();
76054
+ viewer.camera.lerp(duration).frame(box);
76055
+ },
76056
+ hasSelection: () => viewer.selection.count > 0,
76057
+ getSelectionBox: () => Promise.resolve(viewer.selection.getBoundingBox())
76058
+ });
76059
+ }
76007
76060
  function createWebglComponent(container, componentSettings = {}, viewerSettings = {}) {
76008
76061
  const promise2 = new DeferredPromise2();
76009
76062
  const cmpContainer = container instanceof HTMLElement ? createContainer(container) : container ?? createContainer();
@@ -76035,7 +76088,7 @@ function VimComponent(props) {
76035
76088
  var _a2;
76036
76089
  const settings2 = useSettings(props.viewer, props.settings ?? {});
76037
76090
  const modal = useModal(settings2.value.capacity.canFollowUrl);
76038
- const camera2 = useCamera(props.viewer);
76091
+ const camera2 = useWebglCamera(props.viewer);
76039
76092
  const cursor = useMemo(() => new CursorManager(props.viewer), []);
76040
76093
  const loader = useRef(new ComponentLoader(props.viewer, modal));
76041
76094
  const [isolation] = useState(() => new Isolation(props.viewer, camera2, settings2.value));
@@ -76491,6 +76544,7 @@ async function updateProgress(request2, modal) {
76491
76544
  function useUltraSectionBox(viewer) {
76492
76545
  const ultraAdapter = {
76493
76546
  setVisible: (b) => {
76547
+ console.log("SetVisible!", b);
76494
76548
  viewer.sectionBox.visible = b;
76495
76549
  viewer.sectionBox.interactive = b;
76496
76550
  },
@@ -76498,15 +76552,26 @@ function useUltraSectionBox(viewer) {
76498
76552
  fitBox: (box) => viewer.sectionBox.fitBox(box),
76499
76553
  getSelectionBox: () => viewer.selection.getBoundingBox(),
76500
76554
  getRendererBox: () => viewer.renderer.getBoundingBox(),
76501
- onSelectionChanged: viewer.selection.onValueChanged,
76502
- onSceneChanged: viewer.vims.onChanged
76555
+ onSelectionChanged: viewer.selection.onValueChanged
76503
76556
  };
76504
76557
  return useSectionBox(ultraAdapter);
76505
76558
  }
76506
- function useUltraControlBar(viewer, section, customization) {
76507
- let controlBar2 = [controlBarSectionBox(section, viewer.selection.count > 0)];
76508
- controlBar2 = (customization == null ? void 0 : customization(controlBar2)) ?? controlBar2;
76509
- return controlBar2;
76559
+ function useUltraControlBar(viewer, section, camera2, customization) {
76560
+ const sectionSectionBox = controlBarSectionBox(section, viewer.selection.count > 0);
76561
+ const sectionCamera = controlBarCamera(camera2);
76562
+ let bar = [sectionCamera, sectionSectionBox];
76563
+ bar = (customization == null ? void 0 : customization(bar)) ?? bar;
76564
+ return bar;
76565
+ }
76566
+ function useUltraCamera(viewer) {
76567
+ return useCamera({
76568
+ onSelectionChanged: viewer.selection.onValueChanged,
76569
+ frameCamera: (box, duration) => void viewer.camera.frameBox(box, duration),
76570
+ frameAll: (duration) => viewer.camera.frameAll(duration),
76571
+ resetCamera: (duration) => viewer.camera.restoreSavedPosition(duration),
76572
+ hasSelection: () => viewer.selection.count > 0,
76573
+ getSelectionBox: () => viewer.selection.getBoundingBox()
76574
+ });
76510
76575
  }
76511
76576
  function createUltraComponent(container) {
76512
76577
  const promise2 = new DeferredPromise2();
@@ -76536,10 +76601,11 @@ function createUltraComponent(container) {
76536
76601
  function UltraComponent(props) {
76537
76602
  const modal = useModal(true);
76538
76603
  const sectionBox2 = useUltraSectionBox(props.viewer);
76604
+ const camera2 = useUltraCamera(props.viewer);
76539
76605
  const side = useSideState(true, 400);
76540
76606
  const [_, setSelectState] = useState(0);
76541
76607
  const [controlBarCustom, setControlBarCustom] = useState(() => (c) => c);
76542
- const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, (_2) => _2);
76608
+ const controlBar2 = useUltraControlBar(props.viewer, sectionBox2, camera2, (_2) => _2);
76543
76609
  useEffect(() => {
76544
76610
  props.viewer.onStateChanged.subscribe((state) => updateModal(modal, state));
76545
76611
  props.viewer.selection.onValueChanged.subscribe(() => {