Updating block visibility in a game environment using raycasting and clipping

My method (BabylonJS and Typescript) updates visibility of blocks in my game environment, and I do it by checking if there is any blocks in the way between the camera and the player using a ray and removes blocks that are within a certain radius from the player.

It adds the hidden blocks to a list and creates a new environment and updates the clipping when player rotates camera or moves.

I have some issues as you can see, and if anyone know about any resources that can guide me on this subject ?

Many thanks in advance :slight_smile:

The simplified and less universal way could be to check if a player is near a group of blocks and reduce alpha property for these blocks material(s) while player is near this group of blocks.

I cannot use alpha only, as it may need multiple layers of clipping and the user should be able to interact with the blocks that are left visible.

It’s a complex subject (for me), how I can effectively control what parts of the blocks are visible based on the camera’s viewpoint and how many layers of the blocks there are in the scene.

At the moment it works with simple structure, but I want it to work with more complex structures :slight_smile:

re: “I cannot use alpha only…should be able to interact”

Not sure I understand. Meshes that are interactable are always visible, right? And you have a list of meshes that are temporarily hidden? Can you change the logic in that you do not hide the meshes, but instead lower their alpha and set them to isPickable=false? (Or use a custom property and the ray’s predicate callback if you need meshes to remain pickable)