Search code examples
androidkotlincoordinate-systemsarcoresceneform

[ARCore][SceneForm] worldPosition after phone rotation


I am trying to create a node in front of the camera.

However, when I rotate the phone first (for example to 90° along the Y axis), and then create the node at the position (cameraPosition.x, cameraPosition.y, cameraPosition.z - distancetoNode), it creates the node in front of the old position of the camera, as if the phone did not rotate.

As I understand it, the coordinate system didn't move with the phone. How can I make the node to be created in front the new position of the camera?

Thank you very much!


Solution

  • If you rotate the camera the world position of the camera does not change but only its rotation.

    In order to also account for the rotation you should use either the camera pose from the AR frame or use Sceneform's camera to create a ray from the center of your screen and position the node along that ray.