Is there any way to check to see if a mesh is visible by the camera? Not like the .isVisible but like if a mesh is in the way of it. https://playground.babylonjs.com/#QPQC8Z
Kinda like if you move above the sphere and look down. you cant see the ground object. Is there any way to test for that?
How precise do you need to be? The trick with this question (unless I’m misunderstanding) is that the answer isn’t simply yes or no; you have to define how you want to deal with partial visibility. Potential options range from a small number of raycasts (if you’re not too worried about partial visibility and the obstacles you care about are all pickable) to precomputed or periodically updated visibility maps (if your environment is relatively constrained and stable such that it makes sense to preprocess it) to shaders evaluating the rendered depth/scene pixel by pixel (if you need things very precise and have the resources – both dev and compute – to achieve this).
Picking a few important points on your target (for example, the center and/or corners of your ground plane in your Playground) and raycasting at them is almost certainly the easiest way to get off the ground, though it’s not really efficient and could be imprecise. Will that work? If not, can you tell us a little more about your use case?
It is a little voxel “engine” I’ve been making. with “stupid” meshing (every voxel is a cube!) basically having 1000 cubes all with textures and physics is not a good idea. Having the meshes be disabled when not visible might increase fps.
Oh. I’m assuming people wouldn’t try to play a voxel clone without touch contols on ios and internet explorer is probably not used by a computer literate person, so I think I’m fine because I’m just messing around.
From a perspective that takes in most of your block of cubes, I see approximately 7 milliseconds of occlusion query alone, without diving deeply into the profile. This is a relatively expensive check, so I’m not sure you’ll be able to do something like this indiscriminately without negatively impacting performance. If your scenario is voxel-specific, there are almost certainly tricks you can do depending on the specifics of your use case.