I would like to place an object (in my case, a simple ViroBox) on a ground plane that has been before detected manually. For this, I would need to continuously determine a 3D position on (/relative to) said ground floor (which itself is a very thing ViroBox) based on which direction the camera is currently facing.
I am aware that this could be achieved by using a drag plane, but need to avoid any user interaction except rotating the device, so manually dragging the object along the ground plane is not an option.
I tried to illustrate the issue in the following image:
Possible Approaches
1: ViroARScene.performARHitTestWithPoint(x,y)
The array of ARHitTestResult objects returned from calling performARHitTestWithPoint() for my scene only returns anything I can work with (with typebeing either ExistingPlaneUsingExtent or ExistingPlane) when the camera center is really close to the ground plane's origin.
Since I can't control the size of the detected anchor that defines my ground plane, this method can't be used in a way that works for all cases ❌
It may be possible to use these 2 infos to cast a ray from the current camera center onto the ground plane, but I don't know how to since my vector math is kind of bad.
So basically my question is: Can I (and if yes, how) "convert" the camera center (a 2D point) to a 3D point (either in world coordinates, or relative to my found anchor) in my Viro 3D scene?
Thank you for any insights and this great library in general!
Environment
Ventura 13.3.1 (a)
)2.23.0
, React Native:0.71.7
, React:18.2.0
SM-A715F
)Description
I would like to place an object (in my case, a simple
ViroBox
) on a ground plane that has been before detected manually. For this, I would need to continuously determine a 3D position on (/relative to) said ground floor (which itself is a very thingViroBox
) based on which direction the camera is currently facing.I am aware that this could be achieved by using a drag plane, but need to avoid any user interaction except rotating the device, so manually dragging the object along the ground plane is not an option.
I tried to illustrate the issue in the following image:
Possible Approaches
1:
ViroARScene.performARHitTestWithPoint(x,y)
ARHitTestResult
objects returned from callingperformARHitTestWithPoint()
for my scene only returns anything I can work with (withtype
being eitherExistingPlaneUsingExtent
orExistingPlane
) when the camera center is really close to the ground plane's origin.2:
ViroARScene.getCameraOrientationAsync()
+ViroBox.getTransformAsync()
ViroARScene.getCameraOrientationAsync()
function,ViroBox.getTransformAsync()
function.So basically my question is: Can I (and if yes, how) "convert" the camera center (a 2D point) to a 3D point (either in world coordinates, or relative to my found anchor) in my Viro 3D scene?
Thank you for any insights and this great library in general!