# Fixed camera to 3DoF (rotation only)

**URL:** <https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336>\
**Category:** Technical Support\
**Tags:** general\
**Created:** [May 9, 2024, 9:53pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336 "2024-05-09T21:53:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Austin\_Donnelly](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Austin\_Donnelly](https://forum.8thwall.com/u/Austin_Donnelly)\
**Post date:** [May 9, 2024, 9:53pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/1 "2024-05-09T21:53:22Z")

</div>

Hi, my question this. When moving the camera via phone or headset, it is 6DoF and the camera’s position can change along with its rotation. I’d like to restrict to just rotation (so fixed position) like with 3DoF. How would I do this? emitting “Recenter” updates both position and rotation of the camera, but I read in the documentation you can set the target position and rotation. This is what I tried.

```auto
const FixedCamera = {
  schema: {
    x: { type: 'number', default: 0 },
    y: { type: 'number', default: 1.6 }, // Default camera height
    z: { type: 'number', default: 0 },
    updateInterval: { type: 'number', default: 500 } // Time in milliseconds
  },
  init() {
    this.scene = this.el.sceneEl
    this.tick = AFRAME.utils.throttleTick(this.tick, this.data.updateInterval, this)

    this.el.sceneEl.addEventListener('realityready', () => {
      this.recenterCamera();
    })
  },
  recenterCamera() {
    let currentRotation = this.el.object3D.rotation; // This is already a THREE.Euler object
    let facingQuaternion = new THREE.Quaternion();
    facingQuaternion.setFromEuler(currentRotation); // Convert Euler to Quaternion directly
    
    console.log(facingQuaternion.w, facingQuaternion.x, facingQuaternion.y, facingQuaternion.z)
    this.scene.emit('recenter', {
      origin: { x: this.data.x, y: this.data.y, z: this.data.z },
      facing: {
        w: facingQuaternion.w,
        x: facingQuaternion.x,
        y: facingQuaternion.y,
        z: facingQuaternion.z
      }
    });
  },
  tick() {
    this.recenterCamera()
  }
}

export { FixedCamera };

```

Attached to the a-camera. It doesn’t seem to be working, and the rotation is always updating to the same rotation instead of what the camera’s current rotation is.

---

<div class="post-metadata">

**Author:** ![Evan](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/evan/32/431_2.png) [@Evan](https://forum.8thwall.com/u/Evan)\
**Post date:** [May 9, 2024, 10:33pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/2 "2024-05-09T22:33:33Z")

</div>

I think you’re looking for the `disableWorldTracking` parameter on `xrweb`:

```auto
xrweb="disableWorldTracking: true"

```

> **[XR8.AFrame | 8th Wall](https://www.8thwall.com/docs/api/aframe/#world-tracking-image-targets-andor-lightship-vps)**
>
> A-Frame () is a web framework designed for building virtual reality experiences.

---

<div class="post-metadata">

**Author:** ![TonyT](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/tonyt/32/88_2.png) [@TonyT](https://forum.8thwall.com/u/TonyT)\
**Post date:** [May 9, 2024, 10:56pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/3 "2024-05-09T22:56:25Z")

</div>

@Austin_Donnelly - @Evan’s suggestion will work on Android (since gyro is enabled by default), but for iOS you’ll probably need to request gyro permissions explicitly (if disableWorldTracking is set to `true` then our engine doesn’t request gyro for you). You shouldn’t need any of your custom code from your original post.

> **[XR8.XrPermissions.permissions() | 8th Wall](https://www.8thwall.com/docs/api/xrpermissions/permissions/)**
>
> Enumeration

Simply add a pipeline module that sets gyro as a dependency, for example

```auto
XR8.addCameraPipelineModule({
  name: 'request-gyro',
  requiredPermissions: () => ([XR8.XrPermissions.permissions().DEVICE_ORIENTATION]),
})

```

---

<div class="post-metadata">

**Author:** ![Austin\_Donnelly](https://avatars.discourse-cdn.com/v4/letter/a/ce73a5/32.png) [@Austin\_Donnelly](https://forum.8thwall.com/u/Austin_Donnelly)\
**Post date:** [May 10, 2024, 1:46am UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/4 "2024-05-10T01:46:15Z")

</div>

> [@TonyT](#):
>
> ```auto
> XR8.addCameraPipelineModule({
> name: 'request-gyro',
> requiredPermissions: () => ([XR8.XrPermissions.permissions().DEVICE_ORIENTATION]),
> })
> 
> ```

Thanks for that extra tip actually, it was just what I needed after I initially got it working on Android.

So, this is what worked for me.

```auto
XR8.addCameraPipelineModule({
        name: 'request-gyro',
        requiredPermissions: () => ([XR8.XrPermissions.permissions().DEVICE_ORIENTATION]),
      })

```

Adding this helped with iOS when I wanted to set disableWorldTracking to true.

Next, I realized that just setting the attribute or value of disableWorldTracking to true on an existing xrweb component doesn’t actually change it. You either have to remove xrweb altogether and then add it again with this attribute or just add xrweb manually in a component instead.

For my goal, I wanted to essentially remove world tracking for mobile devices only, so I did this in one of my components.

```auto
const FixedCamera = {
  init() {
    this.scene = this.el.sceneEl

    this.scene.setAttribute('xrweb', this.isMobileDevice() ? 'disableWorldTracking: true' : '')
    
    this.el.sceneEl.addEventListener('realityready', () => {
      console.log("REALITY READY")      
      this.recenterCamera()
    })
  },
  recenterCamera() {
    this.scene.emit('recenter')
  },
  isMobileDevice() {
    return AFRAME.utils.device.isMobile()
  }
}

export { FixedCamera }

```

So far, it seems to work well, even with VR HMDs.

---

<div class="post-metadata">

**Author:** ![TonyT](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/tonyt/32/88_2.png) [@TonyT](https://forum.8thwall.com/u/TonyT)\
**Post date:** [May 10, 2024, 4:48pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/5 "2024-05-10T16:48:45Z")

</div>

@Austin_Donnelly Glad to hear you have things working. You are correct that you can’t modify `disableWorldTracking` at runtime, so you’ll have to remove and add/re-add `xrweb` to change things.

We do this in some of our other sample projects:

- [Swap Camera Settings | 8th Wall Playground | 8th Wall](https://www.8thwall.com/playground/swap-dof)
- [Splash Screen | 8th Wall Playground | 8th Wall](https://www.8thwall.com/playground/splash-screen-aframe)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/x8thwall/original/2X/9/9212a857458f1b03a6accb129e0f8cbea408e3e5.png) [@system](https://forum.8thwall.com/u/system)\
**Post date:** [May 14, 2024, 10:14pm UTC](https://forum.8thwall.com/t/fixed-camera-to-3dof-rotation-only/1336/6 "2024-05-14T22:14:34Z")

</div>

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.
