What causes the miscalculation of raycast direction in WebXR?

Exploring the use of traditional Three.js raycasting in a web-based augmented reality application, not focused on AR hit-testing on actual surfaces.

The web application integrates A-Frame with the aframe-xr component to enable WebXR support in the WebXR Viewer for iOS and WebARCore for Android, successfully incorporating augmented reality features in these experimental browsers.

However, an issue arises within aframe-xr or the included libraries like three.xr.js and WebXR polyfill, causing an incorrect projection of the raycast direction in the experimental browsers supporting WebXR. While the origin of the raycast is accurate (at the current camera position), the direction consistently deviates downwards (y-coordinate offset too low) and slightly to the left (x-coordinate offset too small).

Coincidentally, the y-offset aligns with the default 1.6 meters camera offset previously managed by A-Frame, now possibly handled by Three.js in the newest version of A-Frame, upon which aframe-xr relies for functionality.

This discrepancy does not exist universally across raycasting operations, as evidenced by this incident reproduction on Glitch, where test outcomes are detailed as follows:

Device/Example run     | Normal 0.7.0   |   WebXR       |   Normal 0.8.0   |
-----------------------|----------------|---------------|------------------|   
Windows Chrome w/mouse |   Correct      |   Correct     |       Correct    |
S8 Chrome              |   Correct      |   Correct     |       Correct    |
S8 WebARCore           |   Correct      |   Incorrect   |       Correct    |
iPad Safari            |   Correct      |   Correct     |       Correct    |
iPad WebXR Viewer      |   Correct      |   Incorrect   |       Correct    |

In this comparison, "correct" indicates expected directional calculation with the sphere appearing appropriately underneath the cursor, while "incorrect" signifies erroneous direction vector output leading to misalignment of the sphere's visualization.

View the code for these instances here:

What causes the miscalculation of raycast direction in the WebXR libraries, and what corrective measures can be implemented?

Additional insight: Conducted tests utilizing the aframe-ar component showcased correct raycasting functionality in WebARCore on Android (potentially omitting the webxr polyfill), yet inconsistencies persisted with a distinct offset in WebXR Viewer on iPad (likely involving the utilization of the webxr polyfill).

Update: Per Roberto's feedback below, modifying the SITTING_EYE_HEIGHT constant in the webxr-polyfill by setting it to 0 offers some improvement but falls short of a comprehensive solution. With this adjustment - accessible here for testing - initial raycast direction accuracy is observed; however, any subsequent device movement or rotation results in direction miscalculations.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The predicament encountered with user registration in the realm of Node.js

I am encountering a problem with the sign-up route in node.js and MongoDB. Whenever I attempt to post data using Insomnia, it displays an error message. You can find the screenshot of the error [here](https://i.stack.imgur.com/qnGAv.png). Here is the code ...

An issue in ASP.net user control not triggering a specific javascript function

I am currently working on an asp.net web application where I have implemented a repeater that calls a registered user control. Within this user control, there is a button that is supposed to trigger a Javascript function to make an Ajax call for server-sid ...

Utilize JavaScript to extract and transform plain text into a JSON object through the filtering process

After receiving the plain text data from an input source, I have the following information: 1 agri dev ban lt shortform1 346 346 343 343 9,671 346 3,330,659 78 -3.00 -0.87 3.00 0.87 361.80 400.07 449.86 472.00 283.00 2 Api Pwr Cpy shortform2 355 355 347 ...

Issue with stacking layers

Currently facing a simple issue that I'm struggling to resolve. I'm integrating some code into my website, but the image is set as a background layer, preventing it from appearing above other elements on the page. Is there a way to embed the bac ...

Perform the subtraction operation on two boolean values using Typescript

I'm working with an array: main = [{ data: x, numberField: 1; }, { data: y, numberField: 2; }, { data: x, numberField: 3; }, { data: z, numberField: 4; }, { data: ...

Custom validation on the client side using ASP.NET and JavaScript WebMethods

I am encountering an issue with client-side validation using a JavaScript function. On my ASP.NET C# page, I have a WebMethod that successfully validates data entered by the user. The page includes a textbox with an AJAX AutoCompleteExtender, which is work ...

Launching numerous websites in separate browser tabs using the window.open function

I have a code snippet that opens one tab pointing to a website, but I need it to open two. For example: www.google.com and www.yahoo.com Currently, it only works with one site in the code: window.open("https://www.google.com"); but not when bot ...

I need help with creating an AJAX JSON call using Angular. Let me share the JavaScript function that I currently have

When a button is clicked, the function below is called. It retrieves data from a JSON file and stores it if a success message is received. Here is a screenshot of the returned data. My JavaScript function is working correctly, but I am new to Angular and l ...

Can you explain the meaning of assigning `function() {}` to a variable?

I understand that functions are considered objects in javascript and can be assigned to variables. I've come across this question as well: How does the (function() {})() construct work and why do people use it?. However, I'm curious about what e ...

What is the best way to invoke the datepicker function on all rows of table data that share the 'datepicker' class?

Hey there! I'm working with a table that features a JavaScript function for a datepicker, as well as the ability to add and delete rows. The challenge I'm facing is that each new row created has the same ID as the previous one. How can I ensure t ...

I am having trouble getting my website to work offline using caching

My cache file is displayed below: CACHE MANIFEST # 2013-11-22 14:38:54735779 CACHE: ../../../../assets/img/background_01.jpg ../../../../assets/img/background_02.jpg ../../../../assets/img/background_03.jpg ../../../../assets/img/datepicker_icon.png .. ...

Updating the Highcharts chart when new data is available

Utilizing Highcharts, I am looking to have this chart update every second. Here's my current setup: JSFiddle I've implemented a timer with window.setInterval(updateChart, 1000); which successfully updates data each second. However, I'm uns ...

What is the solution to preventing contentEditable="true" from inserting <div> instead of <p> when the return key is pressed?

I have a div <div contentEditable="true"> <h1> My headline</h1> </div> When editing the text inside the <h1> tag and pressing return, a new div is added underneath instead of the usual paragraph tag. Resulting in: < ...

What is the best way to handle a 3-element mode using an onClick function in Next.js?

Creating an accordion menu in Next.js comes with the challenge of implementing 3 different modes for an element: The first mode is default, where no click event has occurred: .mainLi_default In the second mode, the first click event triggers the opening o ...

Exploring the efficiency of AngularJS when binding to deeply nested object properties

Are there any performance differences to consider when data binding in Angularjs between the following: <div>{{bar}}</div> and <div>{{foo.bar}}</div>? What about <div>{{foo.bar.baz.qux}}</div>? Our team is working o ...

Error: Attempting to access the 'email' property of an undefined element during registration

I am facing an issue with my if statement. Below is the code snippet that I am currently working with: ` app.post('/register', redirectHome, async (req, res, next)=>{ try{ const email = req.body.email; let password = req.bo ...

What is the best way to modify an object within a pure function in JavaScript?

Currently, I am exploring different strategies to ensure that a function remains pure while depending on object updates. Would creating a deep copy be the only solution? I understand that questions regarding object copying are quite common here. However, ...

A guide on implementing the IF statement to prevent the Weather API fetch from crashing when the user inputs an incorrect city name

Explaining The Issue - Objectives of the Task Creating a weather application that displays data from the OpenWeather API on the screen. - Current and Desired Outcomes Regardless of whether the user enters a valid city name or leaves the field blank, n ...

Tips for avoiding HTML injections in HTML tooltips

I'm attempting to create a tooltip using HTML, but I need to escape specific HTML elements within it. So far, my attempts have been unsuccessful. Take a look at the example I've provided: http://jsfiddle.net/wrsantos/q3o1e4ut/1/ In this example ...

Wait for the playwright to detect a specific and exact change in the inner text

There is a specific innerText that transitions from Loading to Play after 2-3 seconds. I want to wait for this change to happen before proceeding. Currently, I am using the following code snippet: let attempt = 0; let maxRetries = 4; let payerButtonStatus ...