# Rotating the camera without moving away from the object

**URL:** <https://discourse.threejs.org/t/rotating-the-camera-without-moving-away-from-the-object/39213>\
**Category:** Questions\
**Tags:** rotation, controls\
**Created:** [June 13, 2022, 6:51am UTC](https://discourse.threejs.org/t/rotating-the-camera-without-moving-away-from-the-object/39213 "2022-06-13T06:51:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![binoy\_t](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/binoy_t/32/24330_2.png) [@binoy\_t](https://discourse.threejs.org/u/binoy_t)\
**Post date:** [June 13, 2022, 6:51am UTC](https://discourse.threejs.org/t/rotating-the-camera-without-moving-away-from-the-object/39213/1 "2022-06-13T06:51:19Z")

</div>

Hi,  
I am trying to rotate the camera on button click (something like 360-degree rotation), I want to rotate the camera in the same direction regardless of its position. I was able to achieve this by applying camera.translateX() in the animation frame. Since I’m using translation, the camera moves away from the object after a few seconds. Is there a way in which I could keep the distance between the camera and the object the same?

Thanks,  
Binoy

---

<div class="post-metadata">

**Author:** ![drcmda](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@drcmda](https://discourse.threejs.org/u/drcmda)\
**Post date:** [June 13, 2022, 7:51am UTC](https://discourse.threejs.org/t/rotating-the-camera-without-moving-away-from-the-object/39213/2 "2022-06-13T07:51:15Z")

</div>

something like this? [amazing-lake-n5yjgt - CodeSandbox](https://codesandbox.io/s/amazing-lake-n5yjgt?file=/src/App.js:988-1107)

```nohighlight
const t = clock.elapsedTime
const r = 5
camera.position.set(Math.sin(t) * r, 0, Math.cos(t) * r)
camera.lookAt(0, 0, 0)

```

btw you know you can also just rotate the object, or the group it’s in, that is often easier than having to deal with translation math.

---

<div class="post-metadata">

**Author:** ![binoy\_t](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/binoy_t/32/24330_2.png) [@binoy\_t](https://discourse.threejs.org/u/binoy_t)\
**Post date:** [June 13, 2022, 8:52am UTC](https://discourse.threejs.org/t/rotating-the-camera-without-moving-away-from-the-object/39213/3 "2022-06-13T08:52:49Z")

</div>

but rotating the group will be only in a single direction if move the camera the direction of rotation changes
