# Need help turning on and off the ARscene/ Camera

**URL:** <https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502>\
**Category:** Technical Support\
**Tags:** general, ar-camera\
**Created:** [February 28, 2024, 6:26pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502 "2024-02-28T18:26:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Declan\_Johnson](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/declan_johnson/32/2074_2.png) [@Declan\_Johnson](https://forum.8thwall.com/u/Declan_Johnson)\
**Post date:** [February 28, 2024, 6:26pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/1 "2024-02-28T18:26:05Z")

</div>

I am currently working on a project that upon completion pops up a UI and removes xrweb to essentially turn the camera off and AR scene. I now need to add in reset functionality that will then turn the camera and scene back on, so I am adding xrweb back into the scene. It was working a few days ago but now is causing some bugs and headaches. Is there any other way to essentially turn on and off the camera and AR scene? I would normally just refresh the page to restart it but the client doesn’t want the loading screen to come back up.

---

<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:** [February 28, 2024, 7:04pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/2 "2024-02-28T19:04:24Z")

</div>

Hey Declan! What issues are you running into with `xrweb`?

You might try using `XR8.pause()` and `XR8.resume()` and covering up the paused camera feed with some 2D UI.

> **[XR8.pause() | 8th Wall](https://www.8thwall.com/docs/api/xr8/pause/)**
>
> XR8.pause()

> **[XR8.resume() | 8th Wall](https://www.8thwall.com/docs/api/xr8/resume/)**
>
> XR8.resume()

---

<div class="post-metadata">

**Author:** ![Declan\_Johnson](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/declan_johnson/32/2074_2.png) [@Declan\_Johnson](https://forum.8thwall.com/u/Declan_Johnson)\
**Post date:** [February 28, 2024, 9:39pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/4 "2024-02-28T21:39:43Z")

</div>

@Evan that seems like it will be a much better solution than what I am doing now. The project I am doing is a self hosted project being developed on VS Code with React and TypeScript. Do you know what I need to import to be able to use XR8 properly?

---

<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:** [February 28, 2024, 10:09pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/5 "2024-02-28T22:09:44Z")

</div>

@Declan_Johnson `XR8` is automatically added when the 8th Wall library loads (from the [apps.8thwall.com](http://apps.8thwall.com)… script tag). Usually good to guard your code to make sure it’s on the window before you try to access. Example

```auto
const onxrloaded = () => {
  // Do XR8 stuff here
}

// Wait until the XR javascript has loaded before making XR calls.
window.XR8 ? onxrloaded() : window.addEventListener('xrloaded', onxrloaded)

```

If you already initialized the `xrweb` component in your AFrame scene then XR8 is already on the window - but never hurts to code defensively 🙂

---

<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:** [February 28, 2024, 10:31pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/6 "2024-02-28T22:31:48Z")

</div>

Regarding the type declaration, I would just use a generic type:

```auto
declare let XR8: any

```

For reference: [A-Frame: React - Multiple Scenes | 8th Wall Playground | 8th Wall](https://www.8thwall.com/playground/multi-scene/code/lib/aframe-components.tsx#L6)

---

<div class="post-metadata">

**Author:** ![Declan\_Johnson](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/declan_johnson/32/2074_2.png) [@Declan\_Johnson](https://forum.8thwall.com/u/Declan_Johnson)\
**Post date:** [February 28, 2024, 11:42pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/7 "2024-02-28T23:42:27Z")

</div>

So currently i am getting back a message that says “[XR] Pause cannot be called at this time.”

---

<div class="post-metadata">

**Author:** ![Declan\_Johnson](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/declan_johnson/32/2074_2.png) [@Declan\_Johnson](https://forum.8thwall.com/u/Declan_Johnson)\
**Post date:** [February 29, 2024, 12:31am UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/8 "2024-02-29T00:31:25Z")

</div>

Never mind, I got it working. This was a problem not attached to this code, thank you!

---

<div class="post-metadata">

**Author:** ![Anderson\_Santos](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Anderson\_Santos](https://forum.8thwall.com/u/Anderson_Santos)\
**Post date:** [March 13, 2024, 6:54pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/9 "2024-03-13T18:54:53Z")

</div>

how did you fix the “[XR] Pause cannot be called at this time.” ?  
i keep getting it after the xrloaded event and even after i check the XR8.isInitialized()

---

<div class="post-metadata">

**Author:** ![Declan\_Johnson](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.8thwall.com/declan_johnson/32/2074_2.png) [@Declan\_Johnson](https://forum.8thwall.com/u/Declan_Johnson)\
**Post date:** [March 14, 2024, 6:16pm UTC](https://forum.8thwall.com/t/need-help-turning-on-and-off-the-arscene-camera/502/10 "2024-03-14T18:16:59Z")

</div>

For me this was occurring because the scene was re-rendering right before I called the XR8.pause() function. I am working in react and there was a small call that was breaking things. Not sure if that helps or not, but that is what was happening to me.
