Hello,
i need to have nicely styled ( crisp ) labels on a mesh that rotate with the mesh but always face the camera.
I came up with the following playground: https://playground.babylonjs.com/#RS9G14
( you can create markers / labels with alt-clicking the sphere )
I have two problems:
for some reason the z-position calculation and accompanying opacity change does not work
and
the marker gets created way of the clicked position.
Line 127, you set the sphere as the transform parent. But the sphere.position.y is 1, so everything you attach is offseted by 1 on Y. Replacing sphere with ground (position at 0,0,0) will make the mesh appears where it’s clicked.
Thank you.
That was an easy explanation.
Now I am working my way back to the original problem of showing and hiding the labels according to their position.
I have merged the label code into that cat playground linked by @sebavan https://playground.babylonjs.com/#4M4PMR#14
the code for showing / hiding the labels / sprites according to z-Index was taken from here: https://playground.babylonjs.com/#CUH660#32
But for some reason that is not working correctly.
Is this somehow connected to the model being more complex?
Or did I just miss something small?
It is this one here; https://playground.babylonjs.com/#4M4PMR#14
I have commented out the code for the actual labels and just used the simpler sprites from the other playground to make it easier to spot the error.
I updated the playground so that the sprite does not switch to opacity 0 but 0.5
this way one can see that px and py are correct ( the sprite is exactly where the decal was created )
For the other questions I really dont know, since I got the original code from the other playground mentioned in the above post ( https://playground.babylonjs.com/#CUH660#32 )
Thanks so much.
This was what I was missing.
Here is the final version with divs that actually look like labels.
For anyones future reference: https://playground.babylonjs.com/#4M4PMR#19