# Camera attached object get orientation flipped when attached to WebXR Anchor (playground included)

**URL:** <https://forum.babylonjs.com/t/camera-attached-object-get-orientation-flipped-when-attached-to-webxr-anchor-playground-included/43395>\
**Category:** Questions\
**Tags:** quaternion, webxr, scene\
**Created:** [August 17, 2023, 10:19pm UTC](https://forum.babylonjs.com/t/camera-attached-object-get-orientation-flipped-when-attached-to-webxr-anchor-playground-included/43395 "2023-08-17T22:19:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wellandr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wellandr/32/19572_2.png) [@Wellandr](https://forum.babylonjs.com/u/Wellandr)\
**Post date:** [August 17, 2023, 10:19pm UTC](https://forum.babylonjs.com/t/camera-attached-object-get-orientation-flipped-when-attached-to-webxr-anchor-playground-included/43395/1 "2023-08-17T22:19:43Z")

</div>

Hello, I am facing a bug apparently caused by a lack of orientation of an object that get worse when I try to apply rotation. How do you fix that ?

Playground :

> **[Babylon.js Playground](https://playground.babylonjs.com/#FNT826%2322)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

Goal :  
place an object in AR based on the camera position and orientation. When it is placed, the object is attached to a WebXR Anchor.

Issue :  
when the object is attached to the anchor, it gets flipped randomly.

Intended behavior :  
The behavior in the playground in 3D not immersive is the intended behavior.

Attempts at fixing :  
I noticed that the rotation of the plane was never set. So I first tried to fix a rotation when adding to the camera, but the object is then not always facing the camera anymore when moving it around. Not ideal. I then tried to rotate it after dropping, but then it disappears…

How to reproduce :

1. Open the playground anywhere
2. click on spawn
3. move the camera around
4. click on place
5. move the camera around
6. Open the playground in a WebXR environment with anchors
7. reproduce 2 to 4

Author note :  
I am fairly new to babylonjs, so this might be super trivial, yet I could not find a mention of this neither on doc nor in the forum. Can you please help me ?

---

<div class="post-metadata">

**Author:** ![docEdub](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/docedub/32/14525_2.png) [@docEdub](https://forum.babylonjs.com/u/docEdub)\
**Post date:** [August 18, 2023, 7:39pm UTC](https://forum.babylonjs.com/t/camera-attached-object-get-orientation-flipped-when-attached-to-webxr-anchor-playground-included/43395/2 "2023-08-18T19:39:41Z")

</div>

Hey Wellandr!

The plane mesh’s `rotationQuaternion` is `null` in this case because by default the `rotation` member is used, so you’re passing in `undefined` for the rotation in `addAnchorAtPositionAndRotationAsync`.

Try using `camChild.rotation.toQuaternion()` instead. See [https://playground.babylonjs.com/#FNT826#26](https://playground.babylonjs.com/#FNT826#26) for an example that works in WebXR.

---

<div class="post-metadata">

**Author:** ![Wellandr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wellandr/32/19572_2.png) [@Wellandr](https://forum.babylonjs.com/u/Wellandr)\
**Post date:** [August 18, 2023, 9:07pm UTC](https://forum.babylonjs.com/t/camera-attached-object-get-orientation-flipped-when-attached-to-webxr-anchor-playground-included/43395/3 "2023-08-18T21:07:14Z")

</div>

Thank you, that was indeed what I was missing. Thank’s a lot !!!
