# Issue with creation of WebXRCamera

**URL:** <https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246>\
**Category:** Questions\
**Created:** [September 17, 2020, 3:52pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246 "2020-09-17T15:52:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ubercordes](https://avatars.discourse-cdn.com/v4/letter/u/b4bc9f/32.png) [@ubercordes](https://forum.babylonjs.com/u/ubercordes)\
**Post date:** [September 17, 2020, 3:52pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/1 "2020-09-17T15:52:03Z")

</div>

I’m trying to use the `WebXRCamera`. I hadn’t luck in finding a working example of the use of `WebXRCamera` by searching Playgrounds and on Google. I use the following lines to create the `WebXRCamera`:

```
const xrSessionManager = new BABYLON.WebXRSessionManager(scene);
const xrCamera = new BABYLON.WebXRCamera("camera", scene, xrSessionManager);

```

but the code doesn’t work. I should see a sphere, and instead the scene appears void. But, if I use a FreeCamera instead, the scene renders correctly.

I create a minimum, reproducible example at this Playground:

[https://www.babylonjs-playground.com/#RU6JWI](https://www.babylonjs-playground.com/#RU6JWI)

Where have I messed in the creation of the WebXRCamera?

Unfortunately I encountered and additional issue: the Playground prints the message `createEngine function must return an engine`, which I was unable to fix. But outside of the Playground this issue disappears.

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 17, 2020, 5:17pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/2 "2020-09-17T17:17:42Z")

</div>

If you look at the log, it states:

> Uncaught SyntaxError: await is only valid in async function

Does this work? [https://www.babylonjs-playground.com/#RU6JWI#1](https://www.babylonjs-playground.com/#RU6JWI#1)

---

<div class="post-metadata">

**Author:** ![bghgary](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bghgary/32/48532_2.png) [@bghgary](https://forum.babylonjs.com/u/bghgary)\
**Post date:** [September 17, 2020, 5:18pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/3 "2020-09-17T17:18:46Z")

</div>

As for the actual issue, maybe @RaananW can help.

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [September 18, 2020, 8:46am UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/4 "2020-09-18T08:46:37Z")

</div>

The XR camera is initialized when you call `createDefaultXRExperienceAsync`, there is no need to directly create it, unless you want to implement the experience helper yourself (i.e. initialize all needed parts and enter the scene manually). The scene’s initial camera should be a regular non-Vr supported camera (well, any other than the XR camera 🙂 ). Arc rotate or free camera will do just fine. Afterwards you have direct access to the XR camera inside the experience helper

---

<div class="post-metadata">

**Author:** ![ubercordes](https://avatars.discourse-cdn.com/v4/letter/u/b4bc9f/32.png) [@ubercordes](https://forum.babylonjs.com/u/ubercordes)\
**Post date:** [September 18, 2020, 1:44pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/5 "2020-09-18T13:44:26Z")

</div>

It worked as you suggested: I took an ordinary camera and then got the `xrCamera` from `xrHelper`.

Thanks!

---

<div class="post-metadata">

**Author:** ![ubercordes](https://avatars.discourse-cdn.com/v4/letter/u/b4bc9f/32.png) [@ubercordes](https://forum.babylonjs.com/u/ubercordes)\
**Post date:** [September 18, 2020, 3:53pm UTC](https://forum.babylonjs.com/t/issue-with-creation-of-webxrcamera/14246/6 "2020-09-18T15:53:17Z")

</div>

I’ve created a Playground which shows how to change position of the `WebXRCamera`, for future reference:

[https://www.babylonjs-playground.com/#BYNTY2](https://www.babylonjs-playground.com/#BYNTY2)
