Adding XR to scene creates offset while raycasting

Hi,

I seem to have run into some issues raycasting from touch from an XR tracking camera (currently using 8thwall for XR). The current issue, is the further away I tap from the center of the screen, the actual raycast seems to be happening slightly closer to the center (If I wanted to tap on an entity at 400x600 for example, I would have to tap at maybe 450x650 to get it to click correctly). It also seems to vary for each device so I haven’t been able to multiply the screen position by a fixed amount to get the actual position.

I recall seeing someone having a similar problem here [SOLVED] Raycast not working as expected in AR mode , but I believe they fixed their issue by just hard-coding in the center of the screen. Wanted to see if this was a known issue? Or if I may be doing something wrong on my side with the XR. (For reference if I turn off the XR the raycasting works just fine, it is only when its on that I get issues.)

I wonder if it’s related to the FOV or position of the camera in AR mode.

Would you be able to provide a small reproducible and it could be something that the team or @max can look at?

Hi @yaustar

I have a quick test project here: https://playcanvas.com/project/775086/overview/xrraycasttest
and the build for it here: https://playcanv.as/p/dQjsoi2w/

Before hitting the start XR button, you can click all the cubes and they seem to be clickable in the right spots, but after you hit Start XR the camera looks like it kind of zooms out and then all the raycast points are slightly closer to the center of the screen than where you tap. I also tried logging the fov before and after XR and it seemed to be 45 both times. Also I used the touch events for this project so it kinda only works on mobile at the moment.

1 Like

Just realised this is 8th Wall rather than WebXR AR. I will still take a look at this but may need to ping the 8th Wall team on this.

All good, Im also in the middle of asking 8thwall if they have any ideas as well. I figured I would ask on both ends to see if anyone had any hints as to getting it working.

It looks like when going into AR, it makes change to the camera as it looks like it moves it back a bit. @atomarch Would you be able to help here?

What does the library do to the PlayCanvas camera when entering AR?

I was able to repro the issue. We will have to investigate to see why this is happening…

1 Like

To close out this thread, a fix for this issue was released with Release 16 of 8th Wall’s AR Engine.

5 Likes