Hide GUI placeholder when it's hidden by 3d model

Hello everyone,
I’m placing a target linked to a specific part of a gltf mesh (in the front part) with the GUI Advanced Dynamic Texture. When i click on the target some information about that mesh appear on the screen.
The problem is that when i rotate the camera the circle target is still visible, even if the back part of the model, in a realistic 3d world, should hide the target.
I couldn’t find any examples with this behaviour. I read the documentation and hoped that the advancedTexture.isForeground = false/true could help but it’s not what i need.
Is there a way to achieve this?
This is, by, far, what i wrote in the creating part of the target.
var advancedTexture = BABYLON.GUI.AdvancedDynamicTexture.CreateFullscreenUI(“UI”);
var target = new BABYLON.GUI.Ellipse();
target.width = “40px”;
target.height = “40px”;
target.color = “red”;
target.thickness = 4;
target.alpha = 1;
target.background = “transparent”;
advancedTexture.addControl(target);
target.linkWithMesh(gltf.meshes[4]);
target.isPointerBlocker = true;

Fron view:

Back view (wrong behaviour cause it should be hidden):

Thank you very much in advance,
happy weekend to everybody.

Hi ariwoot,

I might be misunderstanding, but it sounds like you might want to try using 3D GUI instead of ordinary GUI. Since I think you’re wanting to do 3D logic and calculations (occlusion, etc.), 3D GUI should allow you to create elements that are actually in the scene and so give you a lot of those capabilities out of the box. Will that work for your situation?

1 Like

Hi guys. I’m not on-topic, because, I’m not using linkWithMesh or fullScreenGui… but… I still felt the need to fool-around. https://www.babylonjs-playground.com/#MD0FHR#4 (yawn)

4 Likes

Hello syntheticmagus, thank you for the reply.
For this project, I’d like to keep a 2d feeling of the target to click. I’ll do some research on the 3d GUI and see if it’s possible to have 3d logics (like occlusion) for hiding the target when it’s behind, but still have the label and text not affected by the world perspective.
Thank you for the suggestion.

Hi Wingnut, you’re not far from the topic actually! This is really close to the effect I’d like to achieve. The only difference is that the target (so the text Box and the circle) shouldn’t be affected by the 3d perspective, so it should rotate and follow the main 3d shape but at the same time have a front orthogonal view.
Thank you for the example!

1 Like

Hey ariwoot, curious to know if you managed to pull this off

Hey @kuladeeparun and sorry for the late response.
At the end I decided to use the 2d GUI linked with the 3D meshes and, in order to hide the target when they were in background, I worked with the camera.
I made the camera trigger whenever it reached a certain range of radians (including also multiple numbers through the % operator).

Every target had it “hide” range, and according the alpha / beta of the camera, they were shown or hidden.

This was the only way I managed to do this, ugly but worked :slight_smile: