# Raycast works on normal browser 3D scene, but doesn't works when enter to the VR mode simulation WebXR

**URL:** <https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079>\
**Category:** Questions\
**Tags:** webxr\
**Created:** [October 27, 2022, 4:52pm UTC](https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079 "2022-10-27T16:52:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![foxfairlane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/foxfairlane/32/30630_2.png) [@foxfairlane](https://discourse.threejs.org/u/foxfairlane)\
**Post date:** [October 27, 2022, 4:52pm UTC](https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079/1 "2022-10-27T16:52:59Z")

</div>

I wrote my problem on a jsfiddle.

> **[Bug WebXR phone/browser - JSFiddle - Code Playground](https://jsfiddle.net/foxfairlane/d3t7khvu/4/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.

If you try on normal browser, you can do click everywhere in the scene and you will see a blue ray working right, just under your mouse cursor.

> **[imagen](https://ibb.co/y0YRntZ)**
>
> Image imagen hosted in ImgBB

but if you enter in VR Mode (You need to have WebXR plugin installed) and do click, the ray is not working right, it’s not under your cursor and has a big offset.

> **[imagen](https://ibb.co/PCqwRDD)**
>
> Image imagen hosted in ImgBB

Why? How I can fix it?

It happens on mobile phone too, but you need to have installed the WebXR plugin and use a bluetooth mouse connected to the phone.

---

<div class="post-metadata">

**Author:** ![anidivr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/anidivr/32/32924_2.png) [@anidivr](https://discourse.threejs.org/u/anidivr)\
**Post date:** [October 28, 2022, 12:42pm UTC](https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079/2 "2022-10-28T12:42:12Z")

</div>

You can’t use the browser mouse when in VR.

You could create a plane in VR and draw a mouse cursor that moves inside its bounds. Ray cast from this VR mouse cursor (normal to the plane) and see what it hits.

Its not really the same, but gives you a mouse cursor in VR.

---

<div class="post-metadata">

**Author:** ![Peter\_Devine](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/peter_devine/32/11301_2.png) [@Peter\_Devine](https://discourse.threejs.org/u/Peter_Devine)\
**Post date:** [October 29, 2022, 7:05am UTC](https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079/3 "2022-10-29T07:05:30Z")

</div>

No mouse in VR, but Raycast works the same, just from the position and orientation of your controller.  
Check out the examples and work from there.  
[https://threejs.org/examples/?q=webxr#webxr\_vr\_dragging](https://threejs.org/examples/?q=webxr#webxr_vr_dragging)

---

<div class="post-metadata">

**Author:** ![foxfairlane](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/foxfairlane/32/30630_2.png) [@foxfairlane](https://discourse.threejs.org/u/foxfairlane)\
**Post date:** [October 29, 2022, 3:10pm UTC](https://discourse.threejs.org/t/raycast-works-on-normal-browser-3d-scene-but-doesnt-works-when-enter-to-the-vr-mode-simulation-webxr/44079/4 "2022-10-29T15:10:39Z")

</div>

Thank you very much to both, but I mean raycast directly in your browser with the plugin that simulates the VR Environment.

I think it could be great don’t have to use the VR helmet everytime compile and I want to try/debug something. I would like to do directly from my browser with the WebXR emulator or directly from my phone, that it will works like a VR helmet but without any hand controller.

You can install the plugin from chrome from here

> **[WebXR API Emulator](https://chrome.google.com/webstore/detail/webxr-api-emulator/mjddjgeghkdijejnciaefnkjmkafnnje)**
>
> WebXR API Emulator

and after installed, take a look to my fiddle, you will understand what I mean.

> **[Bug WebXR phone/browser - JSFiddle - Code Playground](https://jsfiddle.net/foxfairlane/d3t7khvu/4/)**
>
> Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
