im really having a hard time to get labels for my meshes up and running in a way i need them to:
they should follow the mesh
they should not scale when the mesh scales
they should be covered by other elements
For what i have found, there seem to be two ways:
AdvancedDynamicTexture in fullscreen: but that will violate the ‘should be covered by other elements’ constraint
AdvancedDynamicTexture.CreateForMesh: the lable/rect/etc only follows my Mesh when i set my mesh as parent of the lableMesh. Thats going to violate containt ‘dont scale’, because the lable mesh will scale the way its parent scales. Babylon.js Playground
i just tried it using the 3D GUI but its the same behviour as soon as i link the control to the mesh (which - as far as im understanding it correctly - is exactly the behaviour described in the docs).
I do not think we support this by default. My guess is that you need either the 3dGUI or the createForMesh behavior. In order to not break the latest constraint you will need to adapt the scale of the control depending on the camera distance on each frame ???
I worked around it by extending the mesh classes (i needed those classes anyhow) and making the label (created with CreateForMesh) a part of those domain specific classes without setting the mesh as the parent of the label. Now depending on my use case i update the label position e.g. when the onAfterWorldMatrixUpdateObservable emits. Works like a charm, for now.