Apologies if this is an inappropriate place to raise this question, but I have seen similar types of question on here.
I am investigating whether it is possible in WebXR to place a virtual object (sourced, for example, from a geodata API) on the floor by casting a ray downwards from its position, and detecting hits made from this ray. My use-case is a geographic AR application which downloads points of interest from a server, which might otherwise (if the Hit Test API was not used) be "floating" above the ground. The aim is to use the Hit Test API to place them on the closest detected plane below them. I create an XRHitTestSource for each object (three boxes, in the example), using a ray which starts from the object and points downwards, using local-floor space.(I realise that setting y to 0 in local-floor space would probably work in many cases, but might not work if the plane below the point is raised above the lowest detected plane).
When I test this, it does detect planes using these XRHitTestSources but seemingly in the wrong location. Frequently the planes are above the cube (larger y) even though the ray has a y component of -1.
Hi,
Apologies if this is an inappropriate place to raise this question, but I have seen similar types of question on here.
I am investigating whether it is possible in WebXR to place a virtual object (sourced, for example, from a geodata API) on the floor by casting a ray downwards from its position, and detecting hits made from this ray. My use-case is a geographic AR application which downloads points of interest from a server, which might otherwise (if the Hit Test API was not used) be "floating" above the ground. The aim is to use the Hit Test API to place them on the closest detected plane below them. I create an
XRHitTestSource
for each object (three boxes, in the example), using a ray which starts from the object and points downwards, usinglocal-floor
space.(I realise that settingy
to 0 inlocal-floor
space would probably work in many cases, but might not work if the plane below the point is raised above the lowest detected plane).When I test this, it does detect planes using these
XRHitTestSource
s but seemingly in the wrong location. Frequently the planes are above the cube (largery
) even though the ray has ay
component of -1.My code is here: https://github.com/nickw1/webxr-expts/blob/master/3/index.js
Note it uses WebXR with A-Frame but usage of the WebXR API should be pretty clear, and there are extensive comments.
I may of course be mis-understanding something, apologies if so.
Thanks!