Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move object along detected ground plane via camera center (without dragging/touch events) #990

Open
skizzo opened this issue May 26, 2023 · 0 comments

Comments

@skizzo
Copy link

skizzo commented May 26, 2023

Environment

  1. Development OS: Mac (OS: Ventura 13.3.1 (a))
  2. Device OS & Version: Android 12
  3. Version: ViroReact: 2.23.0, React Native: 0.71.7, React: 18.2.0
  4. Device(s): Samsung Galaxy A71 (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 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:

ViroArCameraProjectionProblem_All

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 ❌

2: ViroARScene.getCameraOrientationAsync() + ViroBox.getTransformAsync()

  • The current camera position & orientation can be determined with the ViroARScene.getCameraOrientationAsync() function,
  • the current ground plane's rotation can be determined with the ViroBox.getTransformAsync() function.
  • 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant