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.

4

1 回答 1

0

您需要查看 SceneModule。平面应该是焦距的子级。



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;
        }
    );
于 2020-01-22T10:39:41.490 回答