Fix 3D Object to screen position on focal plane

I am trying to fix a 3D object to always be on the bottom left of the screen, independent of resolution or screen size. According to the documentation, this can be done with Scene.unprojectToFocalPlane

Here is the relevant code that I’m using. myObject is a direct child of “Focal Distance”

// project the 2D coordinates of the bottom left corner to focal plane
const bottomLeft = Scene.unprojectToFocalPlane(
  Reactive.point2d(0, CameraInfo.previewSize.y)

// set the object transform
myObject.transform.x = bottomLeft.x;
myObject.transform.y = bottomLeft.y;
myObject.transform.z = 0;

However this code doesn’t seems to work. Once I start moving around the camera in the world, myObject will be in all kinds of weird places which don’t make any sense to me.

Am I overlooking something obvious here? Or am I just misunderstanding the documentation…


Answering my own question here:

The coordinates returned by unprojectToFocalPlane are world coordinates. Therefore the result has to be assigned to worldTransform.position of “myObject”. This works as expected.

Glad you figured it out! I’ve been on vacation so I’ve been a little slow to reply