# How to Orbit Around Selected Object's Pivot Point

**URL:** https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724
**Category:** HOOPS Visualize Web
**Tags:** how-to, code, knowledge-base
**Created:** [June 11, 2025, 1:21pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724 "2025-06-11T13:21:11Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![cad-developer](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@cad-developer](https://forum.techsoft3d.com/u/cad-developer)
#### Post date: [June 11, 2025, 1:21pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/1 "2025-06-11T13:21:11Z")

</div>

**Hello TechSoft3D Team,**

Could you please guide me on how to implement orbit controls around the center point of a selected object?

Thank you!

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [June 11, 2025, 1:26pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/2 "2025-06-11T13:26:31Z")

</div>

Please see the function [setOrbitTarget](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Operators.Camera.CameraOrbitOperator.html#Operators.Camera.CameraOrbitOperator.setOrbitTarget) which is part of the [CameraOrbitOperator](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Operators.Camera.CameraOrbitOperator.html#cameraorbitoperator) class.

Also worth mentioning is that the orbit operator has a built-in feature of rotating about the **point of selection** on a face. To activate this, use the middle mouse button to intiate the orbit.

---

<div class="post-metadata">

### Author: ![cad-developer](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@cad-developer](https://forum.techsoft3d.com/u/cad-developer)
#### Post date: [June 19, 2025, 12:25pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/3 "2025-06-19T12:25:53Z")

</div>

```
      const selectionItems = viewer.selectionManager.getResults();
      console.log(selectionItems);
      const nodeIds = selectionItems
        .map((item) => item.getNodeId?.())
        .filter((id) => id !== undefined);

      console.log(nodeIds);
      const bounding = await viewer.model.getNodesBounding(nodeIds);
      // Calculate center
      const center = new Point3(
        (bounding.min.x + bounding.max.x) / 2,
        (bounding.min.y + bounding.max.y) / 2,
        (bounding.min.z + bounding.max.z) / 2,
      );
      console.log(center);
      const operator = new Operators.Camera.CameraOrbitOperator(viewer, viewer.view);
      operator.setOrbitTarget(center);

```

I implemented the code mentioned above, but orbiting around the selected objects is still not working. Is this implementation correct? How should it be properly implemented?

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [June 19, 2025, 1:34pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/4 "2025-06-19T13:34:57Z")

</div>

In addition to calling [setOrbitTarget](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Operators.Camera.CameraOrbitOperator.html#Operators.Camera.CameraOrbitOperator.setOrbitTarget), you will also need to call [setOrbitFallbackMode](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/enum/OrbitFallbackMode.html#orbitfallbackmode), that is:

```auto
operator.setOrbitTarget(center);
operator.setOrbitFallbackMode(Communicator.OrbitFallbackMode.OrbitTarget);

```

Also the [Box class](https://docs.techsoft3d.com/communicator/latest/api_ref/viewing/classes/Box.html#box), has the method `Box.center()` to get the center of the bounding box as another option to get the center point.

---

<div class="post-metadata">

### Author: ![cad-developer](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@cad-developer](https://forum.techsoft3d.com/u/cad-developer)
#### Post date: [June 19, 2025, 2:24pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/5 "2025-06-19T14:24:22Z")

</div>

```
      const selectionItems = viewer.selectionManager.getResults();
      console.log(selectionItems);
      const nodeIds = selectionItems
        .map((item) => item.getNodeId?.())
        .filter((id) => id !== undefined);

      console.log(nodeIds);
      const bounding = await viewer.model.getNodesBounding(nodeIds);
      const center = bounding.center();
      console.log(center);
      const operator = new Operators.Camera.CameraOrbitOperator(viewer, viewer.view);
      operator.setOrbitTarget(center);
      operator.setOrbitFallbackMode(OrbitFallbackMode.OrbitTarget);

```

I updated the code as you suggested. Still its not working.

---

<div class="post-metadata">

### Author: ![tino](https://avatars.discourse-cdn.com/v4/letter/t/9dc877/32.png) [@tino](https://forum.techsoft3d.com/u/tino)
#### Post date: [June 19, 2025, 2:31pm UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/6 "2025-06-19T14:31:06Z")

</div>

Let’s try this:

```auto
const selectionItems = viewer.selectionManager.getResults();
      console.log(selectionItems);
      const nodeIds = selectionItems
        .map((item) => item.getNodeId?.())
        .filter((id) => id !== undefined);

      console.log(nodeIds);
      const bounding = await viewer.model.getNodesBounding(nodeIds);
      const center = bounding.center();
      console.log(center);
      const om = viewer.operatorManager;
      const operator = om.getOperator(OperatorId.Orbit);
      operator.setOrbitTarget(center);
      operator.setOrbitFallbackMode(OrbitFallbackMode.OrbitTarget);

```

---

<div class="post-metadata">

### Author: ![cad-developer](https://avatars.discourse-cdn.com/v4/letter/c/f0a364/32.png) [@cad-developer](https://forum.techsoft3d.com/u/cad-developer)
#### Post date: [June 20, 2025, 5:46am UTC](https://forum.techsoft3d.com/t/how-to-orbit-around-selected-objects-pivot-point/4724/7 "2025-06-20T05:46:27Z")

</div>

Thanks, it’s working perfectly!
