Control a ScreenImage's position
New to Lens Studio. I am trying to move a Screen Image around the screen. The ScreeImage object is instantiated as a child of an orthographic camera. Here's what I am trying:
// Get the transform:
var transform = script.getSceneObject().getTransform();
// Get the world position
var pos = transform.getWorldPosition();
// Change the x
pos.x = Math.max(pos.x, -5.0);
// Reassign the world position
transform.setWorldPosition(pos);
Now I know that objects that were created via Screen Image don't have a Transform component and they have a ScreenTransform instead (like Unity's RectTransform) so I'm assuming this is why getting the transform doesn't work, but I cannot find any straight forward way to access and control the position of ScreenTransform elements in the docs. I find weird that the SceneObject class doesn't have a getScreenTransform method. Could someone point me in the right direction please?
To answer my question: I missed this API before:
var screenTransf = script.getSceneObject().getFirstComponent("ScreenTransform");
Once this component is taken, the position can be changed via its position property. Example:
var pos = screenTransf.position;
pos.x -= getDeltaTime() * script.speed;
screenTransf.position = pos;