Best way to handle 1 camera in the main collection with proxies

I’m in a bit of a pickle. I have the camera in my main collection, with the usual screen_to_world helper function in a camera helper module.

I’d love to access that function from a collection loaded via proxy. I understand I can’t get/set GO.

What is the best way to handle this? I thought he function being in a lua module would have helped.
Do I need to send a message to the camera and have it populate some data in the camera module? Seems quite a roundtrip for this.

Using a lua module for this would be best and if are already using a module then why would you call that function using go.get?

You can call that function directly, say for example your module is named camera_utils then you would do:

local camera_utils = require "scripts.modules.camera_utils"

-- and to call the screen_to_world function you would have written in your module, just call it directly
local world_pos = camera_utils.screen_to_world(action.screen_x, action.screen_y, 0, self.camera_url)

my screen_to_world function in the camera module

called from my my proxy

print("AT: ", camera_utils.screen_to_world("main:/camera#camera", action.x, action.y, 0))

instead of go.get(), use

local projection = camera.get_projection(camera_url)

-- and 

local view = camera.get_view(camera_url)

Read more here: API reference (Camera)

1 Like