how does the Method containsWorldPoint() tell which 3D camera to reference?
The Method containsWorldPoint() inputs a vec3 world position and returns whether or not the world position is contained within a screenspace set of bounds
my question is: If I have multiple 3D cameras and an object is visible in both. how do I choose which camera I want to check for the overlap of screen and world since the global coordinates technically have multiple screenspace coordinates?
Here is a link to the API that references this method https://lensstudio.snapchat.com/api/classes/ScreenTransform/
I had a similar question, would be nice if someone has an answer for this :/
If I understand correctly wouldn't it just use the screen transform you're calling containsWorldPoint() on?
I'm not sure because only one of the objects has a screen transform, I found a workaround though.
You can import the camera component of the camera you want, the world object, and the screen transform component of the screenspace object
// @input Component.ScreenTransform screenObjLocation
// @input SceneObject worldObjLocation
// @input Component.Camera cameraObj
// create a variable for world position of the scene object
var worldPos = script.worldObjLocation.getTransform().getWorldPosition();
// create a variable for the screenspace of the scene object using the camera's
// worldSpaceToScreenSpace() method
var screenPos = script.cameraObj.worldSpaceToScreenSpace(worldPos);
// then compare it with the bounds of the screenspace object using a screen space
// to screen space method.
if(script.screenObjLocation.containsScreenPoint(screenPos)) {
print("overlapping");
// put whatever you want to trigger in here
}
This worked for me so hopefully, it can help someone else who is struggling to get the other method to work