2

How can I convert Spark AR device's screen coordinates to local world coordinates? For example, I want to position an object at the left edge of the screen. My problem is that the objects are using local coordinates based on a central pivot point measured in meters at the center of the screen, whether the device gives the screen size in pixels.

I don't know if there is a ration and how Spark AR measured this on different devices.

Liron Harel
  • 10,819
  • 26
  • 118
  • 217

1 Answers1

0

You need to look at SceneModule. Plane should be a child of Focal Distance.



const TouchGestures = require('TouchGestures');
const Scene = require('Scene');
const R = require('Reactive');

const plane = Scene.root.find('plane0');

TouchGestures
    .onTap()
    .subscribe(
        (gesture) => {
            const focalPosition = Scene.unprojectToFocalPlane(R.point2d(gesture.location.x, gesture.location.y));
            plane.transform.x = focalPosition.x.neg();
            plane.transform.y = focalPosition.y;
            plane.transform.z = 0;
        }
    );
lisichka ggg
  • 563
  • 3
  • 15