How to check if something is on screen

Hi, I was wondering if there was a way to see if something is being displayed on the current canvas in WEBGL mode. I’m working on a game and i have a class of objects that i need to know if they are on screen (that includes being infront of the camera, being within the bounds of the viewport, and it must be at least partially unobstructed). I have multiple objects in the game world, each of which has a defined position and size (including the objects that need to be checked). I have a vague idea of how to make this happen, but I wanted some further guidance.

I would think that the best choice of action was to first project the position of the object to see if it would be on screen, then raycast to see if obstructed, and use the direction of the raycast to see if it is behind the camera or not.

Thanks for any help!


Useful videos and some hints

I think OP is talking about the virtual 3D camera we use in webgl and not about the webcam.

So the camera() command

1 Like

Yes you are true I didn’t notice

1 Like

yeah im looking for how to with the webgl camera

1 Like